PageSourceSearch

https://balloon99-kj7qgchv.manus.space/assets/tier3-babylon-z6xMXPxH.js

js balloon99-kj7qgchv.manus.space collected 2026-10-03 05:00:18 UTC 523,743 bytes, 2,714 lines download raw bytes

vendor: 10,190 bytes, lines 1-2
1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/scene-BZpG6kJx.js","assets/scene.pure--hyippSf.js","assets/tools.pure-PAKPbutq.js","assets/fileTools.pure-O3hflNMy.js","assets/smartArray-B7wVGkJ5.js","assets/deviceInputEvents-BYmA4r4v.js","assets/perfCounter-BXP6OJRQ.js","assets/index-DY6XcbtQ.js","assets/index-DK3k_-YE.css","assets/thinEngine-DI9LWTqR.js","assets/helperFunctions-D7-zXdUR.js","assets/math.color-DBdvdSDj.js","assets/math.vector-Dx30T4M2.js","assets/meshBuilder-g_krcYA6.js","assets/shaderMaterial.pure-BD7SHfvy.js","assets/texture.pure-Df8EqGL8.js","assets/baseTexture.pure-BeMB4zCM.js","assets/math.size-F3xmSqZc.js","assets/effectFallbacks-DqrlKF7n.js","assets/vertexPullingHelper.functions-C384XxIb.js","assets/standardMaterial-C93UVSXE.js","assets/shaderMaterial-CxFpRvHi.js","assets/hemisphericLight-DXitrgl2.js","assets/light-KoECxAgJ.js","assets/directionalLight-CAC3iWIj.js","assets/shadowLight-Be7cBySd.js","assets/pointLight-jLSQ-UDJ.js","assets/arcRotateCamera-_1DRbdwW.js","assets/defaultRenderingPipeline-BUzIWdM6.js","assets/postProcess.pure-DaBR2bKQ.js"])))=>i.map(i=>d[i]);
2import{_ as Ue,g as bn}from"./index-DY6XcbtQ.js";import{V as T,aE as rt,M as j,ae as et,h as N,H as tt,j as k,_ as w,x as Ie,L as fe,g as mt,aF as Tn,aG as Cn,z as le,c as Vi,O as ge,E as ot,S as Be,k as H,Q as Ee,y as Me,s as nt,aH as Pn,f as $e,a as xt,A as me,F as be,av as yn,aI as Rn,aJ as Ln,an as De,r as Ui,aK as pt,aL as lt,aM as Fn,am as On,I as wn,G as fs,i as Nn,p as y}from"./fileTools.pure-O3hflNMy.js";import{D as js,V as g,c as Bn,a as Vn,S as Un,B as ds}from"./smartArray-B7wVGkJ5.js";import{T as at,D as Qs,A as Wn}from"./tools.pure-PAKPbutq.js";import{P as Js}from"./thinEngine-DI9LWTqR.js";import{h as er}from"./helperFunctions-D7-zXdUR.js";var us;(function(o){o[o.LOCAL=0]="LOCAL",o[o.WORLD=1]="WORLD",o[o.BONE=2]="BONE"})(us||(us={}));class vt{}vt.X=new T(1,0,0);vt.Y=new T(0,1,0);vt.Z=new T(0,0,1);var ms;(function(o){o[o.X=0]="X",o[o.Y=1]="Y",o[o.Z=2]="Z"})(ms||(ms={}));class Ke{static GetPlanes(e){const t=[];for(let i=0;i<6;i++)t.push(new Js(0,0,0,0));return Ke.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[2],t.normal.y=i[7]+i[6],t.normal.z=i[11]+i[10],t.d=i[15]+i[14],t.normalize()}static GetFarPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[2],t.normal.y=i[7]-i[6],t.normal.z=i[11]-i[10],t.d=i[15]-i[14],t.normalize()}static GetLeftPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[0],t.normal.y=i[7]+i[4],t.normal.z=i[11]+i[8],t.d=i[15]+i[12],t.normalize()}static GetRightPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[0],t.normal.y=i[7]-i[4],t.normal.z=i[11]-i[8],t.d=i[15]-i[12],t.normalize()}static GetTopPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[1],t.normal.y=i[7]-i[5],t.normal.z=i[11]-i[9],t.d=i[15]-i[13],t.normalize()}static GetBottomPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[1],t.normal.y=i[7]+i[5],t.normal.z=i[11]+i[9],t.d=i[15]+i[13],t.normalize()}static GetPlanesToRef(e,t){Ke.GetNearPlaneToRef(e,t[0]),Ke.GetFarPlaneToRef(e,t[1]),Ke.GetLeftPlaneToRef(e,t[2]),Ke.GetRightPlaneToRef(e,t[3]),Ke.GetTopPlaneToRef(e,t[4]),Ke.GetBottomPlaneToRef(e,t[5])}static IsPointInFrustum(e,t){for(let i=0;i<6;i++)if(t[i].dotCoordinate(e)<0)return!1;return!0}}function Dt(o,e,t){try{const i=o.next();i.done?e(i):i.value?i.value.then(()=>{i.value=void 0,e(i)},t):e(i)}catch(i){t(i)}}function kn(o=25){let e;return(t,i,s)=>{const r=performance.now();e===void 0||r-e>o?(e=r,setTimeout(()=>{Dt(t,i,s)},0)):Dt(t,i,s)}}function tr(o,e,t,i,s){const r=()=>{let a;const n=l=>{l.done?t(l.value):a===void 0?a=!0:r()};do a=void 0,e(o,n,i),a===void 0&&(a=!1);while(a)};r()}function Wi(o,e){let t;return tr(o,Dt,i=>t=i,i=>{throw i}),t}async function Xn(o,e,t){return await new Promise((i,s)=>{tr(o,e,i,s)})}function zn(o,e){return(...t)=>Wi(o(...t))}class ps{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0,this._internalSubMeshId=0}}class qe{constructor(e,t,i){this.vectors=rt(8,T.Zero),this.center=T.Zero(),this.centerWorld=T.Zero(),this.extendSize=T.Zero(),this.extendSizeWorld=T.Zero(),this.directions=rt(3,T.Zero),this.vectorsWorld=rt(8,T.Zero),this.minimumWorld=T.Zero(),this.maximumWorld=T.Zero(),this.minimum=T.Zero(),this.maximum=T.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,i)}reConstruct(e,t,i){const s=e.x,r=e.y,a=e.z,n=t.x,l=t.y,c=t.z,h=this.vectors;this.minimum.copyFromFloats(s,r,a),this.maximum.copyFromFloats(n,l,c),h[0].copyFromFloats(s,r,a),h[1].copyFromFloats(n,l,c),h[2].copyFromFloats(n,r,a),h[3].copyFromFloats(s,l,a),h[4].copyFromFloats(s,r,c),h[5].copyFromFloats(n,l,a),h[6].copyFromFloats(s,l,c),h[7].copyFromFloats(n,r,c),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||j.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=qe._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),s=i.length();i.normalizeFromLength(s);const r=s*e,a=i.scaleInPlace(r*.5),n=this.center.subtractToRef(a,t[1]),l=this.center.addToRef(a,t[2]);return this.reConstruct(n,l,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){const t=this.minimumWorld,i=this.maximumWorld,s=this.directions,r=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let n=0;n<8;++n)r[n].copyFrom(a[n]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),i.setAll(-Number.MAX_VALUE);for(let n=0;n<8;++n){const l=r[n];T.TransformCoordinatesToRef(a[n],e,l),t.minimizeInPlace(l),i.maximizeInPlace(l)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}T.FromArrayToRef(e.m,0,s[0]),T.FromArrayToRef(e.m,4,s[1]),T.FromArrayToRef(e.m,8,s[2]),this._worldMatrix=e}isInFrustum(e){return qe.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return qe.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){const t=this.minimumWorld,i=this.maximumWorld,s=t.x,r=t.y,a=t.z,n=i.x,l=i.y,c=i.z,h=e.x,f=e.y,d=e.z,u=-et;return!(n-h<u||u>h-s||l-f<u||u>f-r||c-d<u||u>d-a)}intersectsSphere(e){return qe.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){const i=this.minimumWorld,s=this.maximumWorld,r=i.x,a=i.y,n=i.z,l=s.x,c=s.y,h=s.z,f=e.x,d=e.y,u=e.z,E=t.x,_=t.y,M=t.z;return!(l<f||r>E||c<d||a>_||h<u||n>M)}dispose(){this._drawWrapperFront?.dispose(),this._drawWrapperBack?.dispose()}static Intersects(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)}static IntersectsSphere(e,t,i,s){const r=qe._TmpVector3[0];return T.ClampToRef(i,e,t,r),T.DistanceSquared(i,r)<=s*s}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){const s=t[i];for(let r=0;r<8;++r)if(s.dotCoordinate(e[r])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let s=!0;const r=t[i];for(let a=0;a<8;++a)if(r.dotCoordinate(e[a])>=0){s=!1;break}if(s)return!1}return!0}}qe._TmpVector3=rt(3,T.Zero);class it{constructor(e,t,i){this.center=T.Zero(),this.centerWorld=T.Zero(),this.minimum=T.Zero(),this.maximum=T.Zero(),this.reConstruct(e,t,i)}reConstruct(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);const s=T.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=s*.5,this._update(i||j.IdentityReadOnly)}scale(e){const t=this.radius*e,i=it._TmpVector3,s=i[0].setAll(t),r=this.center.subtractToRef(s,i[1]),a=this.center.addToRef(s,i[2]);return this.reConstruct(r,a,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{T.TransformCoordinatesToRef(this.center,e,this.centerWorld);const t=it._TmpVector3[0];T.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,i=this.radiusWorld;for(let s=0;s<6;s++)if(e[s].dotCoordinate(t)<=-i)return!1;return!0}isCenterInFrustum(e){const t=this.centerWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){const t=T.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)}static Intersects(e,t){const i=T.DistanceSquared(e.centerWorld,t.centerWorld),s=e.radiusWorld+t.radiusWorld;return!(s*s<i)}static CreateFromCenterAndRadius(e,t,i){this._TmpVector3[0].copyFrom(e),this._TmpVector3[1].copyFromFloats(0,0,t),this._TmpVector3[2].copyFrom(e),this._TmpVector3[0].addInPlace(this._TmpVector3[1]),this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);const s=new it(this._TmpVector3[0],this._TmpVector3[2]);return i?s._worldMatrix=i:s._worldMatrix=j.Identity(),s}}it._TmpVector3=rt(3,T.Zero);const St={min:0,max:0},Et={min:0,max:0},gs=(o,e,t)=>{const i=T.Dot(e.centerWorld,o),s=Math.abs(T.Dot(e.directions[0],o))*e.extendSize.x,r=Math.abs(T.Dot(e.directions[1],o))*e.extendSize.y,a=Math.abs(T.Dot(e.directions[2],o))*e.extendSize.z,n=s+r+a;t.min=i-n,t.max=i+n},Re=(o,e,t)=>(gs(o,e,St),gs(o,t,Et),!(St.min>Et.max||Et.min>St.max));class we{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new qe(e,t,i),this.boundingSphere=new it(e,t,i)}reConstruct(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)}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 i=we._TmpVector3[0].copyFrom(e).subtractInPlace(t),s=we._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this}encapsulate(e){const t=T.Minimize(this.minimum,e),i=T.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){const t=N.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const i=N.Vector3[0];return T.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i
2),this.encapsulate(i),T.TransformCoordinatesToRef(e.boundingBox.maximumWorld,t,i),this.encapsulate(i),this}scale(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this}isInFrustum(e,t=0){return(t===2||t===3)&&this.boundingSphere.isCenterInFrustum(e)?!0:this.boundingSphere.isInFrustum(e)?t===1||t===3?!0:this.boundingBox.isInFrustum(e):!1}get diagonalLength(){const e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,we._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(!it.Intersects(this.boundingSphere,e.boundingSphere)||!qe.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const i=this.boundingBox,s=e.boundingBox;return!(!Re(i.directions[0],i,s)||!Re(i.directions[1],i,s)||!Re(i.directions[2],i,s)||!Re(s.directions[0],i,s)||!Re(s.directions[1],i,s)||!Re(s.directions[2],i,s)||!Re(T.Cross(i.directions[0],s.directions[0]),i,s)||!Re(T.Cross(i.directions[0],s.directions[1]),i,s)||!Re(T.Cross(i.directions[0],s.directions[2]),i,s)||!Re(T.Cross(i.directions[1],s.directions[0]),i,s)||!Re(T.Cross(i.directions[1],s.directions[1]),i,s)||!Re(T.Cross(i.directions[1],s.directions[2]),i,s)||!Re(T.Cross(i.directions[2],s.directions[0]),i,s)||!Re(T.Cross(i.directions[2],s.directions[1]),i,s)||!Re(T.Cross(i.directions[2],s.directions[2]),i,s))}}we._TmpVector3=rt(2,T.Zero);let ir=(()=>{var o;let e=[],t,i;return o=class{static extractMinAndMaxIndexed(r,a,n,l,c,h){for(let f=n;f<n+l;f++){const d=a[f]*3,u=r[d],E=r[d+1],_=r[d+2];c.minimizeInPlaceFromFloats(u,E,_),h.maximizeInPlaceFromFloats(u,E,_)}}static extractMinAndMax(r,a,n,l,c,h){for(let f=a,d=a*l;f<a+n;f++,d+=l){const u=r[d],E=r[d+1],_=r[d+2];c.minimizeInPlaceFromFloats(u,E,_),h.maximizeInPlaceFromFloats(u,E,_)}}},(()=>{const s=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;t=[tt.filter((...r)=>!Array.isArray(r[0])&&!Array.isArray(r[1]))],i=[tt.filter((...r)=>!Array.isArray(r[0]))],k(o,null,t,{kind:"method",name:"extractMinAndMaxIndexed",static:!0,private:!1,access:{has:r=>"extractMinAndMaxIndexed"in r,get:r=>r.extractMinAndMaxIndexed},metadata:s},null,e),k(o,null,i,{kind:"method",name:"extractMinAndMax",static:!0,private:!1,access:{has:r=>"extractMinAndMax"in r,get:r=>r.extractMinAndMax},metadata:s},null,e),s&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s}),w(o,e)})(),o})();function Hn(o,e,t,i,s=null){const r=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return ir.extractMinAndMaxIndexed(o,e,t,i,r,a),s&&(r.x-=r.x*s.x+s.y,r.y-=r.y*s.x+s.y,r.z-=r.z*s.x+s.y,a.x+=a.x*s.x+s.y,a.y+=a.y*s.x+s.y,a.z+=a.z*s.x+s.y),{minimum:r,maximum:a}}function sr(o,e,t,i=null,s){const r=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return s||(s=3),ir.extractMinAndMax(o,e,t,s,r,a),i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,r.z-=r.z*i.x+i.y,a.x+=a.x*i.x+i.y,a.y+=a.y*i.x+i.y,a.z+=a.z*i.x+i.y),{minimum:r,maximum:a}}var _s;class Ne{get materialDefines(){const e=this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:this._getDrawWrapper()?.defines;return typeof e=="string"?null:e}set materialDefines(e){const t=this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0);t.defines=e}_getDrawWrapper(e,t=!1){e=e??this._engine.currentRenderPassId;let i=this._drawWrappers[e];return!i&&t&&(this._drawWrappers[e]=i=new js(this._mesh.getScene().getEngine())),i}_removeDrawWrapper(e,t=!0,i=!1){t&&this._drawWrappers[e]?.dispose(i),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,i,s=!0){const r=this._drawWrapper;r.setEffect(e,t,s),i!==void 0&&(r.materialContext=i),e||(r.defines=null,r.materialContext=void 0)}resetDrawCache(e,t=!1){if(this._drawWrappers)if(e!==void 0){this._removeDrawWrapper(e,!0,t);return}else for(const i of this._drawWrappers)i?.dispose(t);this._drawWrappers=[]}static AddToMesh(e,t,i,s,r,a,n,l=!0){return new Ne(e,t,i,s,r,a,n,l)}constructor(e,t,i,s,r,a,n,l=!0,c=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=s,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=a,this._renderingMesh=n||a,c&&a.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=a.subMeshes.length-1,l&&(this.refreshBoundingInfo(),a.computeWorldMatrix(!0))}get IsGlobal(){return this.verticesStart===0&&this.verticesCount===this._mesh.getTotalVertices()&&this.indexStart===0&&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(){const e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh}getMaterial(e=!0){const t=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)??this._renderingMesh.material;if(t){if(this._isMultiMaterial(t)){const i=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==i&&(this._currentMaterial=i,this.resetDrawCache()),i}}else return e&&this._mesh.getScene()._hasDefaultMaterial?this._mesh.getScene().defaultMaterial:null;return t}_isMultiMaterial(e){return e.getSubMaterial!==void 0}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(g.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;const t=this._renderingMesh.getIndices();let i;if(this.indexStart===0&&this.indexCount===t.length){const s=this._renderingMesh.getBoundingInfo();i={minimum:s.minimum.clone(),maximum:s.maximum.clone()}}else i=Hn(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);
vendor: 23,522 bytes, line 2
2return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new we(i.minimum,i.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):!1}isCompletelyInFrustum(e){const t=this.getBoundingInfo();return t?t.isCompletelyInFrustum(e):!1}render(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this}_getLinesIndexBuffer(e,t){if(!this._linesIndexBuffer){const i=Math.floor(this.indexCount/3)*6,r=this.verticesStart+this.verticesCount>65535?new Uint32Array(i):new Uint16Array(i);let a=0;if(e.length===0)for(let n=this.indexStart;n<this.indexStart+this.indexCount;n+=3)r[a++]=n,r[a++]=n+1,r[a++]=n+1,r[a++]=n+2,r[a++]=n+2,r[a++]=n;else for(let n=this.indexStart;n<this.indexStart+this.indexCount;n+=3)r[a++]=e[n],r[a++]=e[n+1],r[a++]=e[n+1],r[a++]=e[n+2],r[a++]=e[n+2],r[a++]=e[n];this._linesIndexBuffer=t.createIndexBuffer(r),this._linesIndexCount=r.length}return this._linesIndexBuffer}canIntersects(e){const t=this.getBoundingInfo();return t?e.intersectsBox(t.boundingBox):!1}intersects(e,t,i,s,r){const a=this.getMaterial();if(!a)return null;let n=3,l=!1;switch(a.fillMode){case 3:case 5:case 6:case 8:return null;case 7:n=1,l=!0;break}return a.fillMode===4?i.length?this._intersectLines(e,t,i,this._mesh.intersectionThreshold,s):this._intersectUnIndexedLines(e,t,i,this._mesh.intersectionThreshold,s):!i.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(e,t,i,s,r):this._intersectTriangles(e,t,i,n,l,s,r)}_intersectLines(e,t,i,s,r){let a=null;for(let n=this.indexStart;n<this.indexStart+this.indexCount;n+=2){const l=t[i[n]],c=t[i[n+1]],h=e.intersectionSegment(l,c,s);if(!(h<0)&&(r||!a||h<a.distance)&&(a=new ps(null,null,h),a.faceId=n/2,r))break}return a}_intersectUnIndexedLines(e,t,i,s,r){let a=null;for(let n=this.verticesStart;n<this.verticesStart+this.verticesCount;n+=2){const l=t[n],c=t[n+1],h=e.intersectionSegment(l,c,s);if(!(h<0)&&(r||!a||h<a.distance)&&(a=new ps(null,null,h),a.faceId=n/2,r))break}return a}_intersectTriangles(e,t,i,s,r,a,n){let l=null,c=-1;for(let h=this.indexStart;h<this.indexStart+this.indexCount-(3-s);h+=s){c++;const f=i[h],d=i[h+1],u=i[h+2];if(r&&u===4294967295){h+=2;continue}const E=t[f],_=t[d],M=t[u];if(!E||!_||!M||n&&!n(E,_,M,e,f,d,u))continue;const v=e.intersectsTriangle(E,_,M);if(v){if(v.distance<0)continue;if((a||!l||v.distance<l.distance)&&(l=v,l.faceId=c,a))break}}return l}_intersectUnIndexedTriangles(e,t,i,s,r){let a=null;for(let n=this.verticesStart;n<this.verticesStart+this.verticesCount;n+=3){const l=t[n],c=t[n+1],h=t[n+2];if(r&&!r(l,c,h,e,-1,-1,-1))continue;const f=e.intersectsTriangle(l,c,h);if(f){if(f.distance<0)continue;if((s||!a||f.distance<a.distance)&&(a=f,a.faceId=n/3,s))break}}return a}_rebuild(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)}clone(e,t){const i=new Ne(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,t,!1);if(!this.IsGlobal){const s=this.getBoundingInfo();if(!s)return i;i._boundingInfo=new we(s.minimum,s.maximum)}return i}dispose(e=!1){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);const t=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(t,1),this.resetDrawCache(void 0,e)}getClassName(){return"SubMesh"}static CreateFromIndices(e,t,i,s,r,a=!0){let n=Number.MAX_VALUE,l=-Number.MAX_VALUE;const h=(r||s).getIndices();for(let f=t;f<t+i;f++){const d=h[f];d<n&&(n=d),d>l&&(l=d)}return new Ne(e,n,l-n+1,t,i,s,r,a)}}(_s=Ne.prototype).projectToRef??(_s.projectToRef=Ie("SubMesh","projectToRef"));class Mt{}let Ae=(()=>{var o;let e=[],t,i,s,r;return o=class{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=zn(this._applyToCoroutine.bind(this)),this.uniqueId=o._UniqueIdGenerator,o._UniqueIdGenerator++}set(n,l){switch(n.length||fe.Warn(`Setting vertex data kind '${l}' with an empty array`),l){case g.PositionKind:this.positions=n;break;case g.NormalKind:this.normals=n;break;case g.TangentKind:this.tangents=n;break;case g.UVKind:this.uvs=n;break;case g.UV2Kind:this.uvs2=n;break;case g.UV3Kind:this.uvs3=n;break;case g.UV4Kind:this.uvs4=n;break;case g.UV5Kind:this.uvs5=n;break;case g.UV6Kind:this.uvs6=n;break;case g.ColorKind:this.colors=n;break;case g.MatricesIndicesKind:this.matricesIndices=n;break;case g.MatricesWeightsKind:this.matricesWeights=n;break;case g.MatricesIndicesExtraKind:this.matricesIndicesExtra=n;break;case g.MatricesWeightsExtraKind:this.matricesWeightsExtra=n;break}}applyToMesh(n,l){return this._applyTo(n,l,!1),this}applyToGeometry(n,l){return this._applyTo(n,l,!1),this}updateMesh(n){return this._update(n),this}updateGeometry(n){return this._update(n),this}*_applyToCoroutine(n,l=!1,c){if(this.positions&&(n.setVerticesData(g.PositionKind,this.positions,l),c&&(yield)),this.normals&&(n.setVerticesData(g.NormalKind,this.normals,l),c&&(yield)),this.tangents&&(n.setVerticesData(g.TangentKind,this.tangents,l),c&&(yield)),this.uvs&&(n.setVerticesData(g.UVKind,this.uvs,l),c&&(yield)),this.uvs2&&(n.setVerticesData(g.UV2Kind,this.uvs2,l),c&&(yield)),this.uvs3&&(n.setVerticesData(g.UV3Kind,this.uvs3,l),c&&(yield)),this.uvs4&&(n.setVerticesData(g.UV4Kind,this.uvs4,l),c&&(yield)),this.uvs5&&(n.setVerticesData(g.UV5Kind,this.uvs5,l),c&&(yield)),this.uvs6&&(n.setVerticesData(g.UV6Kind,this.uvs6,l),c&&(yield)),this.colors){const h=this.positions&&this.colors.length===this.positions.length?3:4;n.setVerticesData(g.ColorKind,this.colors,l,h),this.hasVertexAlpha&&n.hasVertexAlpha!==void 0&&(n.hasVertexAlpha=!0),c&&(yield)}if(this.matricesIndices&&(n.setVerticesData(g.MatricesIndicesKind,this.matricesIndices,l),c&&(yield)),this.matricesWeights&&(n.setVerticesData(g.MatricesWeightsKind,this.matricesWeights,l),c&&(yield)),this.matricesIndicesExtra&&(n.setVerticesData(g.MatricesIndicesExtraKind,this.matricesIndicesExtra,l),c&&(yield)),this.matricesWeightsExtra&&(n.setVerticesData(g.MatricesWeightsExtraKind,this.matricesWeightsExtra,l),c&&(yield)),this.indices?(n.setIndices(this.indices,null,l),c&&(yield)):n.setIndices([],null),n.subMeshes&&this.materialInfos&&this.materialInfos.length>1){const h=n;h.subMeshes=[];for(const f of this.materialInfos)new Ne(f.materialIndex,f.verticesStart,f.verticesCount,f.indexStart,f.indexCount,h)}return this}_update(n,l,c){return this.positions&&n.updateVerticesData(g.PositionKind,this.positions,l,c),this.normals&&n.updateVerticesData(g.NormalKind,this.normals,l,c),this.tangents&&n.updateVerticesData(g.TangentKind,this.tangents,l,c),this.uvs&&n.updateVerticesData(g.UVKind,this.uvs,l,c),this.uvs2&&n.updateVerticesData(g.UV2Kind,this.uvs2,l,c),this.uvs3&&n.updateVerticesData(g.UV3Kind,this.uvs3,l,c),this.uvs4&&n.updateVerticesData(g.UV4Kind,this.uvs4,l,c),this.uvs5&&n.updateVerticesData(g.UV5Kind,this.uvs5,l,c),this.uvs6&&n.updateVerticesData(g.UV6Kind,this.uvs6,l,c),this.colors&&n.updateVerticesData(g.ColorKind,this.colors,l,c),this.matricesIndices&&n.updateVerticesData(g.MatricesIndicesKind,this.matricesIndices,l,c),this.matricesWeights&&n.updateVerticesData(g.MatricesWeightsKind,this.matricesWeights,l,c),this.matricesIndicesExtra&&n.updateVerticesData(g.MatricesIndicesExtraKind,this.matricesIndicesExtra,l,c),this.matricesWeightsExtra&&n.updateVerticesData(g.MatricesWeightsExtraKind,this.matricesWeightsExtra,l,c),this.indices&&n.setIndices(this.indices,null),this}static _TransformVector3Coordinates(n,l,c=0,h=n.length){const f=N.Vector3[0],d=N.Vector3[1];for(let u=c;u<c+h;u+=3)T.FromArrayToRef(n,u,f),T.TransformCoordinatesToRef(f,l,d),n[u]=d.x,n[u+1]=d.y,n[u+2]=d.z}static _TransformVector3Normals(n,l,c=0,h=n.length){const f=N.Vector3[0],d=N.Vector3[1];for(let u=c;u<c+h;u+=3)T.FromArrayToRef(n,u,f),T.TransformNormalToRef(f,l,d),n[u]=d.x,n[u+1]=d.y,n[u+2]=d.z}static _TransformVector4Normals(n,l,c=0,h=n.length){const f=N.Vector4[0],d=N.Vector4[1];for(let u=c;u<c+h;u+=4)mt.FromArrayToRef(n,u,f),mt.TransformNormalToRef(f,l,d),n[u]=d.x,n[u+1]=d.y,n[u+2]=d.z,n[u+3]=d.w}static _FlipFaces(n,l=0,c=n.length){for(let h=l;h<l+c;h+=3){const f=n[h+1];n[h+1]=n[h+2],n[h+2]=f}}transform(n){const l=n.determinant()<0;return this.positions&&o._TransformVector3Coordinates(this.positions,n),this.normals&&o._TransformVector3Normals(this.normals,n),this.tangents&&o._TransformVector4Normals(this.tangents,n),l&&this.indices&&o._FlipFaces(this.indices),this}splitBasedOnMaterialID(){if(!this.materialInfos||this.materialInfos.length<2)return[this];const n=[];for(const l of this.materialInfos){const c=new o;if(this.positions&&(c.positions=this.positions.slice(l.verticesStart*3,(l.verticesCount+l.verticesStart)*3)),this.normals&&(c.normals=this.normals.slice(l.verticesStart*3,(l.verticesCount+l.verticesStart)*3)),this.tangents&&(c.tangents=this.tangents.slice(l.verticesStart*4,(l.verticesCount+l.verticesStart)*4)),this.colors&&(c.colors=this.colors.slice(l.verticesStart*4,(l.verticesCount+l.verticesStart)*4)),this.uvs&&(c.uvs=this.uvs.slice(l.verticesStart*2,(l.verticesCount+l.verticesStart)*2)),this.uvs2&&(c.uvs2=this.uvs2.slice(l.verticesStart*2,(l.verticesCount+l.verticesStart)*2)),this.uvs3&&(c.uvs3=this.uvs3.slice(l.verticesStart*2,(l.verticesCount+l.verticesStart)*2)),this.uvs4&&(c.uvs4=this.uvs4.slice(l.verticesStart*2,(l.verticesCount+l.verticesStart)*2)),this.uvs5&&(c.uvs5=this.uvs5.slice(l.verticesStart*2,(l.verticesCount+l.verticesStart)*2)),this.uvs6&&(c.uvs6=this.uvs6.slice(l.verticesStart*2,(l.verticesCount+l.verticesStart)*2)),this.matricesIndices&&(c.matricesIndices=this.matricesIndices.slice(l.verticesStart*4,(l.verticesCount+l.verticesStart)*4)),this.matricesIndicesExtra&&(c.matricesIndicesExtra=this.matricesIndicesExtra.slice(l.verticesStart*4,(l.verticesCount+l.verticesStart)*4)),this.matricesWeights&&(c.matricesWeights=this.matricesWeights.slice(l.verticesStart*4,(l.verticesCount+l.verticesStart)*4)),this.matricesWeightsExtra&&(c.matricesWeightsExtra=this.matricesWeightsExtra.slice(l.verticesStart*4,(l.verticesCount+l.verticesStart)*4)),this.indices){c.indices=[];for(let f=l.indexStart;f<l.indexStart+l.indexCount;f++)c.indices.push(this.indices[f]-l.verticesStart)}const h=new Mt;h.indexStart=0,h.indexCount=c.indices?c.indices.length:0,h.materialIndex=l.materialIndex,h.verticesStart=0,h.verticesCount=(c.positions?c.positions.length:0)/3,c.materialInfos=[h],n.push(c)}return n}merge(n,l=!1,c=!1,h=!1,f=!1){const d=Array.isArray(n)?n.map(u=>({vertexData:u})):[{vertexData:n}];return Wi(this._mergeCoroutine(void 0,d,l,!1,c,h,f))}*_mergeCoroutine(n,l,c=!1,h,f,d=!1,u=!1){this._validate();let E=l.map(m=>m.vertexData),_=this;if(u)for(const m of E)m&&(m._validate(),!this.normals&&m.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&m.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&m.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&m.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&m.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&m.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&m.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&m.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&m.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&m.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&m.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&m.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&m.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(const m of E)if(m){if(u)this.normals&&!m.normals&&(m.normals=new Float32Array(m.positions.length)),this.tangents&&!m.tangents&&(m.tangents=new Float32Array(m.positions.length/3*4)),this.uvs&&!m.uvs&&(m.uvs=new Float32Array(m.positions.length/3*2)),this.uvs2&&!m.uvs2&&(m.uvs2=new Float32Array(m.positions.length/3*2)),this.uvs3&&!m.uvs3&&(m.uvs3=new Float32Array(m.positions.length/3*2)),this.uvs4&&!m.uvs4&&(m.uvs4=new Float32Array(m.positions.length/3*2)),this.uvs5&&!m.uvs5&&(m.uvs5=new Float32Array(m.positions.length/3*2)),this.uvs6&&!m.uvs6&&(m.uvs6=new Float32Array(m.positions.length/3*2)),this.colors&&!m.colors&&(m.colors=new Float32Array(m.positions.length/3*4),m.colors.fill(1)),this.matricesIndices&&!m.matricesIndices&&(m.matricesIndices=new Float32Array(m.positions.length/3*4)),this.matricesWeights&&!m.matricesWeights&&(m.matricesWeights=new Float32Array(m.positions.length/3*4)),this.matricesIndicesExtra&&!m.matricesIndicesExtra&&(m.matricesIndicesExtra=new Float32Array(m.positions.length/3*4)),this.matricesWeightsExtra&&!m.matricesWeightsExtra&&(m.matricesWeightsExtra=new Float32Array(m.positions.length/3*4));else if(m._validate(),!this.normals!=!m.normals||!this.tangents!=!m.tangents||!this.uvs!=!m.uvs||!this.uvs2!=!m.uvs2||!this.uvs3!=!m.uvs3||!this.uvs4!=!m.uvs4||!this.uvs5!=!m.uvs5||!this.uvs6!=!m.uvs6||!this.colors!=!m.colors||!this.matricesIndices!=!m.matricesIndices||!this.matricesWeights!=!m.matricesWeights||!this.matricesIndicesExtra!=!m.matricesIndicesExtra||!this.matricesWeightsExtra!=!m.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes")}if(d){let m,b=0,x=0;const A=[];let C=null;const B=[];for(const P of this.splitBasedOnMaterialID())B.push({vertexData:P,transform:n});for(const P of l)if(P.vertexData)for(const Z of P.vertexData.splitBasedOnMaterialID())B.push({vertexData:Z,transform:P.transform});B.sort((P,Z)=>{const Y=P.vertexData.materialInfos?P.vertexData.materialInfos[0].materialIndex:0,W=Z.vertexData.materialInfos?Z.vertexData.materialInfos[0].materialIndex:0;return Y>W?1:Y===W?0:-1});for(const P of B){const Z=P.vertexData;if(Z.materialInfos?m=Z.materialInfos[0].materialIndex:m=0,C&&C.materialIndex===m)C.indexCount+=Z.indices.length,C.verticesCount+=Z.positions.length/3;else{const Y=new Mt;Y.materialIndex=m,Y.indexStart=b,Y.indexCount=Z.indices.length,Y.verticesStart=x,Y.verticesCount=Z.positions.length/3,A.push(Y),C=Y}b+=Z.indices.length,x+=Z.positions.length/3}const O=B.splice(0,1)[0];_=O.vertexData,n=O.transform,E=B.map(P=>P.vertexData),l=B,this.materialInfos=A}const M=E.reduce((m,b)=>m+(b.indices?.length??0),_.indices?.length??0);let S=f||E.some(m=>m.indices===_.indices)?_.indices?.slice():_.indices;if(M>0){let m=S?.length??0;if(S||(S=new Array(M)),S.length!==M){if(Array.isArray(S))S.length=M;else{const x=c||S instanceof Uint32Array?new Uint32Array(M):new Uint16Array(M);x.set(S),S=x}n&&n.determinant()<0&&o._FlipFaces(S,0,m)}let b=_.positions?_.positions.length/3:0;for(const{vertexData:x,transform:A}of l)if(x.indices){for(let C=0;C<x.indices.length;C++)S[m+C]=x.indices[C]+b;A&&A.determinant()<0&&o._FlipFaces(S,m,x.indices.length),b+=x.positions.length/3,m+=x.indices.length,h&&(yield)}}return this.indices=S,this.positions=o._MergeElement(g.PositionKind,_.positions,n,l.map(m=>[m.vertexData.positions,m.transform])),h&&(yield),_.normals&&(this.normals=o._MergeElement(g.NormalKind,_.normals,n,l.map(m=>[m.vertexData.normals,m.transform])),h&&(yield)),_.tangents&&(this.tangents=o._MergeElement(g.TangentKind,_.tangents,n,l.map(m=>[m.vertexData.tangents,m.transform])),h&&(yield)),_.uvs&&(this.uvs=o._MergeElement(g.UVKind,_.uvs,n,l.map(m=>[m.vertexData.uvs,m.transform])),h&&(yield)),_.uvs2&&(this.uvs2=o._MergeElement(g.UV2Kind,_.uvs2,n,l.map(m=>[m.vertexData.uvs2,m.transform])),h&&(yield)),_.uvs3&&(this.uvs3=o._MergeElement(g.UV3Kind,_.uvs3,n,l.map(m=>[m.vertexData.uvs3,m.transform])),h&&(yield)),_.uvs4&&(this.uvs4=o._MergeElement(g.UV4Kind,_.uvs4,n,l.map(m=>[m.vertexData.uvs4,m.transform])),h&&(yield)),_.uvs5&&(this.uvs5=o._MergeElement(g.UV5Kind,_.uvs5,n,l.map(m=>[m.vertexData.uvs5,m.transform])),h&&(yield)),_.uvs6&&(this.uvs6=o._MergeElement(g.UV6Kind,_.uvs6,n,l.map(m=>[m.vertexData.uvs6,m.transform])),h&&(yield)),_.colors&&(this.colors=o._MergeElement(g.ColorKind,_.colors,n,l.map(m=>[m.vertexData.colors,m.transform])),(_.hasVertexAlpha!==void 0||l.some(m=>m.vertexData.hasVertexAlpha!==void 0))&&(this.hasVertexAlpha=_.hasVertexAlpha||l.some(m=>m.vertexData.hasVertexAlpha)),h&&(yield)),_.matricesIndices&&(this.matricesIndices=o._MergeElement(g.MatricesIndicesKind,_.matricesIndices,n,l.map(m=>[m.vertexData.matricesIndices,m.transform])),h&&(yield)),_.matricesWeights&&(this.matricesWeights=o._MergeElement(g.MatricesWeightsKind,_.matricesWeights,n,l.map(m=>[m.vertexData.matricesWeights,m.transform])),h&&(yield)),_.matricesIndicesExtra&&(this.matricesIndicesExtra=o._MergeElement(g.MatricesIndicesExtraKind,_.matricesIndicesExtra,n,l.map(m=>[m.vertexData.matricesIndicesExtra,m.transform])),h&&(yield)),_.matricesWeightsExtra&&(this.matricesWeightsExtra=o._MergeElement(g.MatricesWeightsExtraKind,_.matricesWeightsExtra,n,l.map(m=>[m.vertexData.matricesWeightsExtra,m.transform]))),this}static _MergeElement(n,l,c,h){const f=h.filter(E=>E[0]!==null&&E[0]!==void 0);if(!l&&f.length==0)return l;if(!l)return this._MergeElement(n,f[0][0],f[0][1],f.slice(1));const d=f.reduce((E,_)=>E+_[0].length,l.length),u=n===g.PositionKind?o._TransformVector3Coordinates:n===g.NormalKind?o._TransformVector3Normals:n===g.TangentKind?o._TransformVector4Normals:()=>{};if(l instanceof Float32Array){const E=new Float32Array(d);E.set(l),c&&u(E,c,0,l.length);let _=l.length;for(const[M,v]of f)E.set(M,_),v&&u(E,v,_,M.length),_+=M.length;return E}else{const E=new Array(d);for(let M=0;M<l.length;M++)E[M]=l[M];c&&u(E,c,0,l.length);let _=l.length;for(const[M,v]of f){for(let S=0;S<M.length;S++)E[_+S]=M[S];v&&u(E,v,_,M.length),_+=M.length}return E}}_validate(){if(!this.positions)throw new Tn("Positions are required",Cn.MeshInvalidPositionsError);const n=(h,f)=>{const d=Bn(h);if(f.length%d!==0)throw new Error("The "+h+"s array count must be a multiple of "+d);return f.length/d},l=n(g.PositionKind,this.positions),c=(h,f)=>{const d=n(h,f);if(d!==l)throw new Error("The "+h+"s element count ("+d+") does not match the positions count ("+l+")")};this.normals&&c(g.NormalKind,this.normals),this.tangents&&c(g.TangentKind,this.tangents),this.uvs&&c(g.UVKind,this.uvs),this.uvs2&&c(g.UV2Kind,this.uvs2),this.uvs3&&c(g.UV3Kind,this.uvs3),this.uvs4&&c(g.UV4Kind,this.uvs4),this.uvs5&&c(g.UV5Kind,this.uvs5),this.uvs6&&c(g.UV6Kind,this.uvs6),this.colors&&c(g.ColorKind,this.colors),this.matricesIndices&&c(g.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&c(g.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&c(g.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&c(g.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const n=this.serialize();return o.Parse(n)}serialize(){const n={};if(this.positions&&(n.positions=Array.from(this.positions)),this.normals&&(n.normals=Array.from(this.normals)),this.tangents&&(n.tangents=Array.from(this.tangents)),this.uvs&&(n.uvs=Array.from(this.uvs)),this.uvs2&&(n.uvs2=Array.from(this.uvs2)),this.uvs3&&(n.uvs3=Array.from(this.uvs3)),this.uvs4&&(n.uvs4=Array.from(this.uvs4)),this.uvs5&&(n.uvs5=Array.from(this.uvs5)),this.uvs6&&(n.uvs6=Array.from(this.uvs6)),this.colors&&(n.colors=Array.from(this.colors),n.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(n.matricesIndices=Array.from(this.matricesIndices),n.matricesIndicesExpanded=!0),this.matricesWeights&&(n.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(n.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),n.matricesIndicesExtraExpanded=!0),this.matricesWeightsExtra&&(n.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),n.indices=this.indices?Array.from(this.indices):[],this.materialInfos){n.materialInfos=[];for(const l of this.materialInfos){const c={indexStart:l.indexStart,indexCount:l.indexCount,materialIndex:l.materialIndex,verticesStart:l.verticesStart,verticesCount:l.verticesCount};n.materialInfos.push(c)}}return n}static ExtractFromMesh(n,l,c){return o._ExtractFrom(n,l,c)}static ExtractFromGeometry(n,l,c){return o._ExtractFrom(n,l,c)}static _ExtractFrom(n,l,c){const h=new o;if(n.isVerticesDataPresent(g.PositionKind)&&(h.positions=n.getVerticesData(g.PositionKind,l,c)),n.isVerticesDataPresent(g.NormalKind)&&(h.normals=n.getVerticesData(g.NormalKind,l,c)),n.isVerticesDataPresent(g.TangentKind)&&(h.tangents=n.getVerticesData(g.TangentKind,l,c)),n.isVerticesDataPresent(g.UVKind)&&(h.uvs=n.getVerticesData(g.UVKind,l,c)),n.isVerticesDataPresent(g.UV2Kind)&&(h.uvs2=n.getVerticesData(g.UV2Kind,l,c)),n.isVerticesDataPresent(g.UV3Kind)&&(h.uvs3=n.getVerticesData(g.UV3Kind,l,c)),n.isVerticesDataPresent(g.UV4Kind)&&(h.uvs4=n.getVerticesData(g.UV4Kind,l,c)),n.isVerticesDataPresent(g.UV5Kind)&&(h.uvs5=n.getVerticesData(g.UV5Kind,l,c)),n.isVerticesDataPresent(g.UV6Kind)&&(h.uvs6=n.getVerticesData(g.UV6Kind,l,c)),n.isVerticesDataPresent(g.ColorKind)){const f=n.geometry||n,d=f.getVertexBuffer(g.ColorKind),u=f.getVerticesData(g.ColorKind,l,c);if(d.getSize()===3){const E=new Float32Array(u.length*4/3);for(let _=0,M=0;_<u.length;_+=3,M+=4)E[M]=u[_],E[M+1]=u[_+1],E[M+2]=u[_+2],E[M+3]=1;h.colors=E}else if(d.getSize()===4)h.colors=u;else throw new Error(`Unexpected number of color components: ${d.getSize()}`)}return n.isVerticesDataPresent(g.MatricesIndicesKind)&&(h.matricesIndices=n.getVerticesData(g.MatricesIndicesKind,l,c)),n.isVerticesDataPresent(g.MatricesWeightsKind)&&(h.matricesWeights=n.getVerticesData(g.MatricesWeightsKind,l,c)),n.isVerticesDataPresent(g.MatricesIndicesExtraKind)&&(h.matricesIndicesExtra=n.getVerticesData(g.MatricesIndicesExtraKind,l,c)),n.isVerticesDataPresent(g.MatricesWeightsExtraKind)&&(h.matricesWeightsExtra=n.getVerticesData(g.MatricesWeightsExtraKind,l,c)),h.indices=n.getIndices(l,c),h}static CreateRibbon(n){throw le("ribbonBuilder")}static CreateBox(n){throw le("boxBuilder")}static CreateTiledBox(n){throw le("tiledBoxBuilder")}static CreateTiledPlane(n){throw le("tiledPlaneBuilder")}static CreateSphere(n){throw le("sphereBuilder")}static CreateCylinder(n){throw le("cylinderBuilder")}static CreateTorus(n){throw le("torusBuilder")}static CreateLineSystem(n){throw le("linesBuilder")}static CreateDashedLines(n){throw le("linesBuilder")}static CreateGround(n){throw le("groundBuilder")}static CreateTiledGround(n){throw le("groundBuilder")}static CreateGroundFromHeightMap(n){throw le("groundBuilder")}static CreatePlane(n){throw le("planeBuilder")}static CreateDisc(n){throw le("discBuilder")}static CreatePolygon(n,l,c,h,f,d,u){throw le("polygonBuilder")}static CreateIcoSphere(n){throw le("icoSphereBuilder")}static CreatePolyhedron(n){throw le("polyhedronBuilder")}static CreateCapsule(n={orientation:T.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){throw le("capsuleBuilder")}static CreateTorusKnot(n){throw le("torusKnotBuilder")}static ComputeNormals(n,l,c,h){let f,d,u,E,_,M,v,S,m,b,x,A,C,B,O,P,Z,Y,W,I,R=!1,z=!1,V=!1,q=!1,ee=1,Q=0,te=null;h&&(R=!!h.facetNormals,z=!!h.facetPositions,V=!!h.facetPartitioning,ee=h.useRightHandedSystem===!0?-1:1,Q=
2h.ratio||0,q=!!h.depthSort,te=h.distanceTo,q&&te===void 0&&(te=T.Zero()));let J=0,se=0,re=0,xe=0;for(V&&h&&h.bbSize&&(J=h.subDiv.X*Q/h.bbSize.x,se=h.subDiv.Y*Q/h.bbSize.y,re=h.subDiv.Z*Q/h.bbSize.z,xe=h.subDiv.max*h.subDiv.max,h.facetPartitioning.length=0),f=0;f<n.length;f++)c[f]=0;const We=l.length/3|0;for(f=0;f<We;f++){if(A=l[f*3]*3,C=A+1,B=A+2,O=l[f*3+1]*3,P=O+1,Z=O+2,Y=l[f*3+2]*3,W=Y+1,I=Y+2,d=n[A]-n[O],u=n[C]-n[P],E=n[B]-n[Z],_=n[Y]-n[O],M=n[W]-n[P],v=n[I]-n[Z],S=ee*(u*v-E*M),m=ee*(E*_-d*v),b=ee*(d*M-u*_),x=Math.sqrt(S*S+m*m+b*b),x=x===0?1:x,S/=x,m/=x,b/=x,R&&h&&(h.facetNormals[f].x=S,h.facetNormals[f].y=m,h.facetNormals[f].z=b),z&&h&&(h.facetPositions[f].x=(n[A]+n[O]+n[Y])/3,h.facetPositions[f].y=(n[C]+n[P]+n[W])/3,h.facetPositions[f].z=(n[B]+n[Z]+n[I])/3),V&&h){const Fe=Math.floor((h.facetPositions[f].x-h.bInfo.minimum.x*Q)*J),pe=Math.floor((h.facetPositions[f].y-h.bInfo.minimum.y*Q)*se),he=Math.floor((h.facetPositions[f].z-h.bInfo.minimum.z*Q)*re),D=Math.floor((n[A]-h.bInfo.minimum.x*Q)*J),F=Math.floor((n[C]-h.bInfo.minimum.y*Q)*se),K=Math.floor((n[B]-h.bInfo.minimum.z*Q)*re),ae=Math.floor((n[O]-h.bInfo.minimum.x*Q)*J),ue=Math.floor((n[P]-h.bInfo.minimum.y*Q)*se),Se=Math.floor((n[Z]-h.bInfo.minimum.z*Q)*re),Oe=Math.floor((n[Y]-h.bInfo.minimum.x*Q)*J),dt=Math.floor((n[W]-h.bInfo.minimum.y*Q)*se),ut=Math.floor((n[I]-h.bInfo.minimum.z*Q)*re),ke=D+h.subDiv.max*F+xe*K,Xe=ae+h.subDiv.max*ue+xe*Se,ze=Oe+h.subDiv.max*dt+xe*ut,He=Fe+h.subDiv.max*pe+xe*he;h.facetPartitioning[He]=h.facetPartitioning[He]?h.facetPartitioning[He]:[],h.facetPartitioning[ke]=h.facetPartitioning[ke]?h.facetPartitioning[ke]:[],h.facetPartitioning[Xe]=h.facetPartitioning[Xe]?h.facetPartitioning[Xe]:[],h.facetPartitioning[ze]=h.facetPartitioning[ze]?h.facetPartitioning[ze]:[],h.facetPartitioning[ke].push(f),Xe!=ke&&h.facetPartitioning[Xe].push(f),ze==Xe||ze==ke||h.facetPartitioning[ze].push(f),He==ke||He==Xe||He==ze||h.facetPartitioning[He].push(f)}if(q&&h&&h.facetPositions){const Fe=h.depthSortedFacets[f];Fe.ind=f*3,Fe.sqDistance=T.DistanceSquared(h.facetPositions[f],te)}c[A]+=S,c[C]+=m,c[B]+=b,c[O]+=S,c[P]+=m,c[Z]+=b,c[Y]+=S,c[W]+=m,c[I]+=b}for(f=0;f<c.length/3;f++)S=c[f*3],m=c[f*3+1],b=c[f*3+2],x=Math.sqrt(S*S+m*m+b*b),x=x===0?1:x,S/=x,m/=x,b/=x,c[f*3]=S,c[f*3+1]=m,c[f*3+2]=b}static _ComputeSides(n,l,c,h,f,d,u){const E=c.length,_=h.length;let M,v;switch(n=n||o.DEFAULTSIDE,n){case o.FRONTSIDE:break;case o.BACKSIDE:for(M=0;M<E;M+=3){const S=c[M];c[M]=c[M+2],c[M+2]=S}for(v=0;v<_;v++)h[v]=-h[v];break;case o.DOUBLESIDE:{const S=l.length,m=S/3;for(let A=0;A<S;A++)l[S+A]=l[A];for(M=0;M<E;M+=3)c[M+E]=c[M+2]+m,c[M+1+E]=c[M+1]+m,c[M+2+E]=c[M]+m;for(v=0;v<_;v++)h[_+v]=-h[v];const b=f.length;let x;for(x=0;x<b;x++)f[x+b]=f[x];for(d=d||new mt(0,0,1,1),u=u||new mt(0,0,1,1),x=0,M=0;M<b/2;M++)f[x]=d.x+(d.z-d.x)*f[x],f[x+1]=d.y+(d.w-d.y)*f[x+1],f[x+b]=u.x+(u.z-u.x)*f[x+b],f[x+b+1]=u.y+(u.w-u.y)*f[x+b+1],x+=2;break}}}static Parse(n){const l=new o,c=n.positions;c&&l.set(c,g.PositionKind);const h=n.normals;h&&l.set(h,g.NormalKind);const f=n.tangents;f&&l.set(f,g.TangentKind);const d=n.uvs;d&&l.set(d,g.UVKind);const u=n.uvs2;u&&l.set(u,g.UV2Kind);const E=n.uvs3;E&&l.set(E,g.UV3Kind);const _=n.uvs4;_&&l.set(_,g.UV4Kind);const M=n.uvs5;M&&l.set(M,g.UV5Kind);const v=n.uvs6;v&&l.set(v,g.UV6Kind);const S=n.colors;S&&(l.set(Vi.CheckColors4(S,c.length/3),g.ColorKind),n.hasVertexAlpha!==void 0&&(l.hasVertexAlpha=n.hasVertexAlpha));const m=n.matricesIndices;m&&l.set(m,g.MatricesIndicesKind);const b=n.matricesWeights;b&&l.set(b,g.MatricesWeightsKind);const x=n.indices;x&&(l.indices=x);const A=n.materialInfos;if(A){l.materialInfos=[];for(const C of A){const B=new Mt;B.indexCount=C.indexCount,B.indexStart=C.indexStart,B.verticesCount=C.verticesCount,B.verticesStart=C.verticesStart,B.materialIndex=C.materialIndex,l.materialInfos.push(B)}}return l}static ImportVertexData(n,l){const c=o.Parse(n);l.setAllVerticesData(c,n.updatable)}},(()=>{const a=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;t=[tt.filter((...n)=>!Array.isArray(n[0]))],i=[tt.filter((...n)=>!Array.isArray(n[0]))],s=[tt.filter((...n)=>!Array.isArray(n[0]))],r=[tt.filter((...n)=>!Array.isArray(n[0]))],k(o,null,t,{kind:"method",name:"_TransformVector3Coordinates",static:!0,private:!1,access:{has:n=>"_TransformVector3Coordinates"in n,get:n=>n._TransformVector3Coordinates},metadata:a},null,e),k(o,null,i,{kind:"method",name:"_TransformVector3Normals",static:!0,private:!1,access:{has:n=>"_TransformVector3Normals"in n,get:n=>n._TransformVector3Normals},metadata:a},null,e),k(o,null,s,{kind:"method",name:"_TransformVector4Normals",static:!0,private:!1,access:{has:n=>"_TransformVector4Normals"in n,get:n=>n._TransformVector4Normals},metadata:a},null,e),k(o,null,r,{kind:"method",name:"_FlipFaces",static:!0,private:!1,access:{has:n=>"_FlipFaces"in n,get:n=>n._FlipFaces},metadata:a},null,e),a&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:a})})(),o.FRONTSIDE=(w(o,e),0),o.BACKSIDE=1,o.DOUBLESIDE=2,o.DEFAULTSIDE=0,o._UniqueIdGenerator=0,o})();class Gn{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new ge,this._onEffectiveEnabledStateChangedObservable=null,this._onClonedObservable=new ge,this._inheritVisibility=!1,this._isVisible=!0}}let ct=(()=>{var o;let e,t=[],i=[],s,r=[],a=[],n,l=[],c=[],h,f=[],d=[],u,E=[],_=[];return o=class{static AddNodeConstructor(v,S){this._NodeConstructors[v]=S}static Construct(v,S,m,b){const x=this._NodeConstructors[v];return x?x(S,m,b):null}set accessibilityTag(v){this._accessibilityTag=v,this.onAccessibilityTagChangedObservable.notifyObservers(v)}get accessibilityTag(){return this._accessibilityTag}get doNotSerialize(){return this._nodeDataStorage._doNotSerialize?!0:this._parentNode?this._parentNode.doNotSerialize:!1}set doNotSerialize(v){this._nodeDataStorage._doNotSerialize=v}isDisposed(){return this._nodeDataStorage._isDisposed}set parent(v){if(this._parentNode===v)return;const S=this._parentNode;if(this._parentNode&&this._parentNode._children!==void 0&&this._parentNode._children!==null){const m=this._parentNode._children.indexOf(this);m!==-1&&this._parentNode._children.splice(m,1),!v&&!this._nodeDataStorage._isDisposed&&this._addToSceneRootNodes()}this._parentNode=v,this._isDirty=!0,this._parentNode&&((this._parentNode._children===void 0||this._parentNode._children===null)&&(this._parentNode._children=new Array),this._parentNode._children.push(this),S||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}get inheritVisibility(){return this._nodeDataStorage._inheritVisibility}set inheritVisibility(v){this._nodeDataStorage._inheritVisibility=v}get isVisible(){return this.inheritVisibility&&this._parentNode&&!this._parentNode.isVisible?!1:this._nodeDataStorage._isVisible}set isVisible(v){this._nodeDataStorage._isVisible=v}_serializeAsParent(v){v.parentId=this.uniqueId}_addToSceneRootNodes(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){const v=this._scene.rootNodes,S=v.length-1;v[this._nodeDataStorage._sceneRootNodesIndex]=v[S],v[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(v){this._animationPropertiesOverride=v}getClassName(){return"Node"}set onDispose(v){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(v)}get onEnabledStateChangedObservable(){return this._nodeDataStorage._onEnabledStateChangedObservable}get onEffectiveEnabledStateChangedObservable(){var v;return(v=this._nodeDataStorage)._onEffectiveEnabledStateChangedObservable??(v._onEffectiveEnabledStateChangedObservable=new ge)}get onClonedObservable(){return this._nodeDataStorage._onClonedObservable}constructor(v,S=null,m=!0){this._isDirty=!1,this._nodeDataStorage=new Gn,this.name=w(this,t,void 0),this.id=(w(this,i),w(this,r,void 0)),this.uniqueId=(w(this,a),w(this,l,void 0)),this.state=(w(this,c),w(this,f,"")),this.metadata=(w(this,d),w(this,E,null)),this._internalMetadata=w(this,_),this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new ge,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=j.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new ge,this._onDisposeObserver=null,this._behaviors=new Array,this.name=v,this.id=v,this._scene=S||ot.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),m&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(v,S=!1){return this._behaviors.indexOf(v)!==-1?this:(v.init(),this._scene.isLoading&&!S?this._scene.onDataLoadedObservable.addOnce(()=>{this._behaviors.includes(v)&&v.attach(this)}):v.attach(this),this._behaviors.push(v),this)}removeBehavior(v){const S=this._behaviors.indexOf(v);return S===-1?this:(this._behaviors.splice(S,1),v.detach(),this)}get behaviors(){return this._behaviors}getBehaviorByName(v){for(const S of this._behaviors)if(S.name===v)return S;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(v){!v&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(v,S=!0){return this.parent?this.parent._getActionManagerForTrigger(v,!1):null}_updateCache(v){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return this._parentNode?this._parentNode._isDirty||this._parentUpdateId!==this._parentNode._childUpdateId?!1:this._parentNode.isSynchronized():!0}isSynchronized(){return this._parentNode&&!this.isSynchronizedWithParent()?!1:this._isSynchronized()}isReady(v=!1){return this._nodeDataStorage._isReady}markAsDirty(v){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(v=!0){return v===!1?this._nodeDataStorage._isEnabled:this._nodeDataStorage._isEnabled?this._nodeDataStorage._isParentEnabled:!1}_hasEffectiveEnabledStateObservers(){const v=this._nodeDataStorage._onEffectiveEnabledStateChangedObservable;return!!v&&v.hasObservers()}_syncParentEnabledState(){const v=this._hasEffectiveEnabledStateObservers(),S=v?this.isEnabled():null;if(this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,this._children)for(const m of this._children)m._syncParentEnabledState();if(v){const m=this.isEnabled();m!==S&&this._nodeDataStorage._onEffectiveEnabledStateChangedObservable.notifyObservers(m)}}setEnabled(v){if(this._nodeDataStorage._isEnabled===v)return;const S=this._hasEffectiveEnabledStateObservers(),m=S?this.isEnabled():null;if(this._nodeDataStorage._isEnabled=v,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(v),S){const b=this.isEnabled();b!==m&&this._nodeDataStorage._onEffectiveEnabledStateChangedObservable.notifyObservers(b)}}isDescendantOf(v){return this.parent?this.parent===v?!0:this.parent.isDescendantOf(v):!1}_getDescendants(v,S=!1,m){if(this._children)for(let b=0;b<this._children.length;b++){const x=this._children[b];(!m||m(x))&&v.push(x),S||x._getDescendants(v,!1,m)}}getDescendants(v,S){const m=[];return this._getDescendants(m,v,S),m}getChildMeshes(v,S){const m=[];return this._getDescendants(m,v,b=>(!S||S(b))&&b.cullingStrategy!==void 0),m}getChildren(v,S=!0){return this.getDescendants(S,v)}_setReady(v){if(v!==this._nodeDataStorage._isReady){if(!v){this._nodeDataStorage._isReady=!1;return}this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0}}getAnimationByName(v){for(let S=0;S<this.animations.length;S++){const m=this.animations[S];if(m.name===v)return m}return null}createAnimationRange(v,S,m){if(!this._ranges[v]){this._ranges[v]=o._AnimationRangeFactory(v,S,m);for(let b=0,x=this.animations.length;b<x;b++)this.animations[b]&&this.animations[b].createRange(v,S,m)}}deleteAnimationRange(v,S=!0){for(let m=0,b=this.animations.length;m<b;m++)this.animations[m]&&this.animations[m].deleteRange(v,S);this._ranges[v]=null}getAnimationRange(v){return this._ranges[v]||null}clone(v,S,m){const b=Be.Clone(()=>
2new o(v,this.getScene()),this);if(S&&(b.parent=S),!m){const x=this.getDescendants(!0);for(let A=0;A<x.length;A++){const C=x[A];C.clone(v+"."+C.name,b)}}return b}getAnimationRanges(){const v=[];let S;for(S in this._ranges)v.push(this._ranges[S]);return v}beginAnimation(v,S,m,b){const x=this.getAnimationRange(v);return x?this._scene.beginAnimation(this,x.from,x.to,S,m,b):null}serializeAnimationRanges(){const v=[];for(const S in this._ranges){const m=this._ranges[S];if(!m)continue;const b={};b.name=S,b.from=m.from,b.to=m.to,v.push(b)}return v}computeWorldMatrix(v){return this._worldMatrix||(this._worldMatrix=j.Identity()),this._worldMatrix}dispose(v,S=!1){if(this._nodeDataStorage._isDisposed=!0,!v){const m=this.getDescendants(!0);for(const b of m)b.dispose(v,S)}this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onEnabledStateChangedObservable.clear(),this._nodeDataStorage._onEffectiveEnabledStateChangedObservable?.clear(),this.onClonedObservable.clear();for(const m of this._behaviors)m.detach();this._behaviors.length=0,this.metadata=null}static ParseAnimationRanges(v,S,m){if(S.ranges)for(let b=0;b<S.ranges.length;b++){const x=S.ranges[b];v.createAnimationRange(x.name,x.from,x.to)}}getHierarchyBoundingVectors(v=!0,S=null){this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);let m,b;const x=this;if(x.getBoundingInfo&&x.subMeshes){const A=x.getBoundingInfo();m=A.boundingBox.minimumWorld.clone(),b=A.boundingBox.maximumWorld.clone()}else m=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),b=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(v){const A=this.getDescendants(!1);for(const C of A){const B=C;if(B.computeWorldMatrix(!0),S&&!S(B)||!B.getBoundingInfo||B.getTotalVertices()===0)continue;const P=B.getBoundingInfo().boundingBox,Z=P.minimumWorld,Y=P.maximumWorld;T.CheckExtends(Z,m,b),T.CheckExtends(Y,m,b)}}return{min:m,max:b}}},(()=>{const M=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;e=[H()],s=[H()],n=[H()],h=[H()],u=[H()],k(null,null,e,{kind:"field",name:"name",static:!1,private:!1,access:{has:v=>"name"in v,get:v=>v.name,set:(v,S)=>{v.name=S}},metadata:M},t,i),k(null,null,s,{kind:"field",name:"id",static:!1,private:!1,access:{has:v=>"id"in v,get:v=>v.id,set:(v,S)=>{v.id=S}},metadata:M},r,a),k(null,null,n,{kind:"field",name:"uniqueId",static:!1,private:!1,access:{has:v=>"uniqueId"in v,get:v=>v.uniqueId,set:(v,S)=>{v.uniqueId=S}},metadata:M},l,c),k(null,null,h,{kind:"field",name:"state",static:!1,private:!1,access:{has:v=>"state"in v,get:v=>v.state,set:(v,S)=>{v.state=S}},metadata:M},f,d),k(null,null,u,{kind:"field",name:"metadata",static:!1,private:!1,access:{has:v=>"metadata"in v,get:v=>v.metadata,set:(v,S)=>{v.metadata=S}},metadata:M},E,_),M&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:M})})(),o._AnimationRangeFactory=(M,v,S)=>{throw le("AnimationRange")},o._NodeConstructors={},o})();var vs,Is,Ss,Es;let Pe=(()=>{var o;let e=ct,t,i=[],s=[],r,a=[],n=[],l,c=[],h=[],f,d=[],u=[],E,_=[],M=[],v,S=[],m=[],b,x=[],A=[],C,B=[],O=[],P,Z=[],Y=[];return o=class extends e{get billboardMode(){return this._billboardMode}set billboardMode(I){this._billboardMode!==I&&(this._billboardMode=I,this._cache.useBillboardPosition=(this._billboardMode&o.BILLBOARDMODE_USE_POSITION)!==0)}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(I){this._infiniteDistance!==I&&(this._infiniteDistance=I)}constructor(I,R=null,z=!0){super(I,R,!1),this._forward=new T(0,0,1),this._up=new T(0,1,0),this._right=new T(1,0,0),this._position=w(this,i,T.Zero()),this._rotation=(w(this,s),w(this,a,T.Zero())),this._rotationQuaternion=(w(this,n),w(this,c,null)),this._scaling=(w(this,h),w(this,d,T.One())),this._transformToBoneReferal=(w(this,u),null),this._isAbsoluteSynced=!1,this._billboardMode=w(this,_,o.BILLBOARDMODE_NONE),this.scalingDeterminant=(w(this,M),w(this,S,1)),this._infiniteDistance=(w(this,m),w(this,x,!1)),this.ignoreNonUniformScaling=(w(this,A),w(this,B,!1)),this.reIntegrateRotationIntoRotationQuaternion=(w(this,O),w(this,Z,!1)),this._poseMatrix=(w(this,Y),null),this._localMatrix=j.Zero(),this._usePivotMatrix=!1,this._absolutePosition=T.Zero(),this._absoluteScaling=T.Zero(),this._absoluteRotationQuaternion=Ee.Identity(),this._pivotMatrix=j.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new ge,this._nonUniformScaling=!1,z&&this.get
vendor: 9,944 bytes, line 2
2Scene().addTransformNode(this)}getClassName(){return"TransformNode"}get position(){return this._position}set position(I){this._position=I,this._markAsDirtyInternal()}isUsingPivotMatrix(){return this._usePivotMatrix}isUsingPostMultiplyPivotMatrix(){return this._postMultiplyPivotMatrix}get rotation(){return this._rotation}set rotation(I){this._rotation=I,this._rotationQuaternion=null,this._markAsDirtyInternal()}get scaling(){return this._scaling}set scaling(I){this._scaling=I,this._markAsDirtyInternal()}get rotationQuaternion(){return this._rotationQuaternion}set rotationQuaternion(I){this._rotationQuaternion=I,I&&this._rotation.setAll(0),this._markAsDirtyInternal()}_markAsDirtyInternal(){this._isDirty||(this._isDirty=!0,this.customMarkAsDirty&&this.customMarkAsDirty())}get forward(){return T.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return T.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return T.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()}updatePoseMatrix(I){return this._poseMatrix?(this._poseMatrix.copyFrom(I),this):(this._poseMatrix=I.clone(),this)}getPoseMatrix(){return this._poseMatrix||(this._poseMatrix=j.Identity()),this._poseMatrix}_isSynchronized(){const I=this._cache;return!(this._billboardMode!==I.billboardMode||this._billboardMode!==o.BILLBOARDMODE_NONE||I.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)}_initCache(){super._initCache();const I=this._cache;I.localMatrixUpdated=!1,I.billboardMode=-1,I.infiniteDistance=!1,I.useBillboardPosition=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(I){return this.setPivotMatrix(I,!1)}setPivotMatrix(I,R=!0){return this._pivotMatrix.copyFrom(I),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=R,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=j.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(I=null,R,z){const V=this.clone("Clone of "+(this.name||this.id),I||this.parent,!0);V&&z&&z(this,V);for(const q of this.getChildTransformNodes(!0))q.instantiateHierarchy(V,R,z);return V}freezeWorldMatrix(I=null,R=!1){return I?R?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||Ee.Identity(),I.decompose(this._scaling,this._rotationQuaternion,this._position),this.computeWorldMatrix(!0)):(this._worldMatrix=I,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(I){if(!I)return this;let R,z,V;if(I.x===void 0){if(arguments.length<3)return this;R=arguments[0],z=arguments[1],V=arguments[2]}else R=I.x,z=I.y,V=I.z;if(this.parent){const q=N.Matrix[0];this.parent.getWorldMatrix().invertToRef(q),T.TransformCoordinatesFromFloatsToRef(R,z,V,q,this.position)}else this.position.x=R,this.position.y=z,this.position.z=V;return this._absolutePosition.copyFrom(I),this}setPositionWithLocalVector(I){return this.computeWorldMatrix(),this.position=T.TransformNormal(I,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();const I=N.Matrix[0];return this._localMatrix.invertToRef(I),T.TransformNormal(this.position,I)}locallyTranslate(I){return this.computeWorldMatrix(!0),this.position=T.TransformCoordinates(I,this._localMatrix),this}lookAt(I,R=0,z=0,V=0,q=0){const ee=o._LookAtVectorCache,Q=q===0?this.position:this.getAbsolutePosition();if(I.subtractToRef(Q,ee),this.setDirection(ee,R,z,V),q===1&&this.parent)if(this.rotationQuaternion){const te=N.Matrix[0];this.rotationQuaternion.toRotationMatrix(te);const J=N.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(J),J.invert(),te.multiplyToRef(J,te),this.rotationQuaternion.fromRotationMatrix(te)}else{const te=N.Quaternion[0];Ee.FromEulerVectorToRef(this.rotation,te);const J=N.Matrix[0];te.toRotationMatrix(J);const se=N.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(se),se.invert(),J.multiplyToRef(se,J),te.fromRotationMatrix(J),te.toEulerAnglesToRef(this.rotation)}return this}getDirection(I){const R=T.Zero();return this.getDirectionToRef(I,R),R}getDirectionToRef(I,R){return T.TransformNormalToRef(I,this.getWorldMatrix(),R),this}setDirection(I,R=0,z=0,V=0){const q=-Math.atan2(I.z,I.x)+Math.PI/2,ee=Math.sqrt(I.x*I.x+I.z*I.z),Q=-Math.atan2(I.y,ee);return this.rotationQuaternion?Ee.RotationYawPitchRollToRef(q+R,Q+z,V,this.rotationQuaternion):(this.rotation.x=Q+z,this.rotation.y=q+R,this.rotation.z=V),this}setPivotPoint(I,R=0){this.getScene().getRenderId()==0&&this.computeWorldMatrix(!0);const z=this.getWorldMatrix();if(R==1){const V=N.Matrix[0];z.invertToRef(V),I=T.TransformCoordinates(I,V)}return this.setPivotMatrix(j.Translation(-I.x,-I.y,-I.z),!0)}getPivotPoint(){const I=T.Zero();return this.getPivotPointToRef(I),I}getPivotPointToRef(I){return I.x=-this._pivotMatrix.m[12],I.y=-this._pivotMatrix.m[13],I.z=-this._pivotMatrix.m[14],this}getAbsolutePivotPoint(){const I=T.Zero();return this.getAbsolutePivotPointToRef(I),I}getAbsolutePivotPointToRef(I){return this.getPivotPointToRef(I),T.TransformCoordinatesToRef(I,this.getWorldMatrix(),I),this}markAsDirty(I){if(this._isDirty)return this;if(this._children)for(const R of this._children)R.markAsDirty(I);return super.markAsDirty(I)}setParent(I,R=!1,z=!1){if(!I&&!this.parent)return this;const V=N.Quaternion[0],q=N.Vector3[0],ee=N.Vector3[1],Q=N.Matrix[1];j.IdentityToRef(Q);const te=N.Matrix[0];this.computeWorldMatrix(!0);let J=this.rotationQuaternion;return J||(J=o._TmpRotation,Ee.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,J)),j.ComposeToRef(this.scaling,J,this.position,te),this.parent&&te.multiplyToRef(this.parent.computeWorldMatrix(!0),te),I&&(I.computeWorldMatrix(!0).invertToRef(Q),te.multiplyToRef(Q,te)),te.decompose(ee,V,q,R?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(V):V.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(ee),this.position.copyFrom(q),this.parent=I,z&&this.setPivotMatrix(j.Identity()),this}addChild(I,R=!1){return I.setParent(this,R),this}removeChild(I,R=!1){return I.parent!==this?this:(I.setParent(null,R),this)}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(I){return this._nonUniformScaling===I?!1:(this._nonUniformScaling=I,!0)}attachToBone(I,R){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=R,this.parent=I,I.getSkeleton().prepare(!0),I.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(I=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,I?this.parent=this._currentParentWhenAttachingToBone:this.parent=null,this):(I&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(I,R,z){I.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0));let V;if(!z||z===0)V=Ee.RotationAxisToRef(I,R,o._RotationAxisCache),this.rotationQuaternion.multiplyToRef(V,this.rotationQuaternion);else{if(this.parent){const q=this.parent.getWorldMatrix(),ee=N.Matrix[0];q.invertToRef(ee),I=T.TransformNormal(I,ee),q.determinant()<0&&(R*=-1)}V=Ee.RotationAxisToRef(I,R,o._RotationAxisCache),V.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(I,R,z){R.normalize(),this.rotationQuaternion||(this.rotationQuaternion=Ee.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const V=N.Vector3[0],q=N.Vector3[1],ee=N.Vector3[2],Q=N.Quaternion[0],te=N.Matrix[0],J=N.Matrix[1],se=N.Matrix[2],re=N.Matrix[3];return I.subtractToRef(this.position,V),j.TranslationToRef(V.x,V.y,V.z,te),j.TranslationToRef(-V.x,-V.y,-V.z,J),j.RotationAxisToRef(R,z,se),J.multiplyToRef(se,re),re.multiplyToRef(te,re),re.decompose(q,Q,ee),this.position.addInPlace(ee),Q.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(I,R,z){const V=I.scale(R);if(!z||z===0){const q=this.getPositionExpressedInLocalSpace().add(V);this.setPositionWithLocalVector(q)}else this.setAbsolutePosition(this.getAbsolutePosition().add(V));return this}addRotation(I,R,z){let V;this.rotationQuaternion?V=this.rotationQuaternion:(V=N.Quaternion[1],Ee.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,V));const q=N.Quaternion[0];return Ee.RotationYawPitchRollToRef(R,I,z,q),V.multiplyInPlace(q),this.rotationQuaternion||V.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==o.BILLBOARDMODE_NONE}computeWorldMatrix(I=!1,R=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;const z=this.getScene().getRenderId();if(!this._isDirty&&!I&&(this._currentRenderId===z||this.isSynchronized()))return this._currentRenderId=z,this._worldMatrix;
vendor: 6,335 bytes, line 2
2R=R||this.getScene().activeCamera,this._updateCache();const V=this._cache;V.pivotMatrixUpdated=!1,V.billboardMode=this.billboardMode,V.infiniteDistance=this.infiniteDistance,V.parent=this._parentNode,this._currentRenderId=z,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;const q=this._getEffectiveParent(),ee=o._TmpScaling;let Q=this._position;if(this._infiniteDistance&&!this.parent&&R){const se=R.getWorldMatrix().m;Q=o._TmpTranslation,Q.copyFromFloats(this._position.x+se[12],this._position.y+se[13],this._position.z+se[14])}ee.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant);let te;if(this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,te=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(Ee.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(te=o._TmpRotation,Ee.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,te)),this._usePivotMatrix){const J=N.Matrix[1];j.ScalingToRef(ee.x,ee.y,ee.z,J);const se=N.Matrix[0];te.toRotationMatrix(se),this._pivotMatrix.multiplyToRef(J,N.Matrix[4]),N.Matrix[4].multiplyToRef(se,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(Q.x,Q.y,Q.z)}else j.ComposeToRef(ee,te,Q,this._localMatrix);if(q&&q.getWorldMatrix){if(I&&q.computeWorldMatrix(I),this.billboardMode){if(this._transformToBoneReferal){const xe=this.parent;xe.getSkeleton().prepare(),xe.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),N.Matrix[7])}else N.Matrix[7].copyFrom(q.getWorldMatrix());const J=N.Vector3[5],se=N.Vector3[6],re=N.Quaternion[0];N.Matrix[7].decompose(se,re,J),j.ScalingToRef(se.x,se.y,se.z,N.Matrix[7]),N.Matrix[7].setTranslation(J),o.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(re,J),this._localMatrix.setTranslation(J)),this._localMatrix.multiplyToRef(N.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const J=this.parent;J.getSkeleton().prepare(),this._localMatrix.multiplyToRef(J.getFinalMatrix(),N.Matrix[6]),N.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(q.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(R&&this.billboardMode)if(V.useBillboardPosition){const J=N.Vector3[0];this._worldMatrix.getTranslationToRef(J);const se=R.globalPosition;this._worldMatrix.invertToRef(N.Matrix[1]);const re=N.Vector3[1];T.TransformCoordinatesToRef(se,N.Matrix[1],re),re.normalize();const xe=-Math.atan2(re.z,re.x)+Math.PI/2,We=Math.sqrt(re.x*re.x+re.z*re.z),Fe=-Math.atan2(re.y,We);if(Ee.RotationYawPitchRollToRef(xe,Fe,0,N.Quaternion[0]),(this.billboardMode&o.BILLBOARDMODE_ALL)!==o.BILLBOARDMODE_ALL){const pe=N.Vector3[1];N.Quaternion[0].toEulerAnglesToRef(pe),(this.billboardMode&o.BILLBOARDMODE_X)!==o.BILLBOARDMODE_X&&(pe.x=0),(this.billboardMode&o.BILLBOARDMODE_Y)!==o.BILLBOARDMODE_Y&&(pe.y=0),(this.billboardMode&o.BILLBOARDMODE_Z)!==o.BILLBOARDMODE_Z&&(pe.z=0),j.RotationYawPitchRollToRef(pe.y,pe.x,pe.z,N.Matrix[0])}else j.FromQuaternionToRef(N.Quaternion[0],N.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(N.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(N.Vector3[0])}else{const J=N.Vector3[0];this._worldMatrix.getTranslationToRef(J),N.Matrix[1].copyFrom(R.getViewMatrix());const se=this.getScene().useRightHandedSystem;if(se&&N.Matrix[1].multiplyToRef(o._TmpRHRestore,N.Matrix[1]),N.Matrix[1].setTranslationFromFloats(0,0,0),N.Matrix[1].invertToRef(N.Matrix[0]),(this.billboardMode&o.BILLBOARDMODE_ALL)!==o.BILLBOARDMODE_ALL){N.Matrix[0].decompose(void 0,N.Quaternion[0],void 0);const re=N.Vector3[1];N.Quaternion[0].toEulerAnglesToRef(re),(this.billboardMode&o.BILLBOARDMODE_X)!==o.BILLBOARDMODE_X&&(re.x=0),(this.billboardMode&o.BILLBOARDMODE_Y)!==o.BILLBOARDMODE_Y&&(re.y=0),(this.billboardMode&o.BILLBOARDMODE_Z)!==o.BILLBOARDMODE_Z&&(re.z=0),se&&(re.y+=Math.PI),j.RotationYawPitchRollToRef(re.y,re.x,re.z,N.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(N.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(N.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):q&&q._nonUniformScaling?this._updateNonUniformScalingState(q._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=j.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(I=!0){if(this.computeWorldMatrix(),I){const R=this.getChildren();for(let z=0;z<R.length;++z){const V=R[z];if(V){V.computeWorldMatrix();const q=N.Matrix[0];V._localMatrix.multiplyToRef(this._localMatrix,q);const ee=N.Quaternion[0];q.decompose(V.scaling,ee,V.position),V.rotationQuaternion?V.rotationQuaternion.copyFrom(ee):ee.toEulerAnglesToRef(V.rotation)}}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=Ee.Identity()),this._worldMatrix=j.Identity()}_afterComputeWorldMatrix(){}registerAfterWorldMatrixUpdate(I){return this.onAfterWorldMatrixUpdateObservable.add(I),this}unregisterAfterWorldMatrixUpdate(I){return this.onAfterWorldMatrixUpdateObservable.removeCallback(I),this}getPositionInCameraSpace(I=null){return I||(I=this.getScene().activeCamera),T.TransformCoordinates(this.getAbsolutePosition(),I.getViewMatrix())}getDistanceToCamera(I=null){return I||(I=this.getScene().activeCamera),this.getAbsolutePosition().subtract(I.globalPosition).length()}clone(I,R,z){const V=Be.Clone(()=>
2new o(I,this.getScene()),this);if(V.name=I,V.id=I,R&&(V.parent=R),!z){const q=this.getDescendants(!0);for(let ee=0;ee<q.length;ee++){const Q=q[ee];Q.clone&&Q.clone(I+"."+Q.name,V)}}return V}serialize(I){const R=Be.Serialize(this,I);return R.type=this.getClassName(),R.uniqueId=this.uniqueId,this.parent&&this.parent._serializeAsParent(R),R.localMatrix=this.getPivotMatrix().asArray(),R.isEnabled=this.isEnabled(),this._isWorldMatrixFrozen&&(R.freezeWorldMatrix=!0),Be.AppendSerializedAnimations(this,R),R.ranges=this.serializeAnimationRanges(),R}getChildTransformNodes(I,R){const z=[];return this._getDescendants(z,I,V=>(!R||R(V))&&V instanceof o),z}dispose(I,R=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){const z=this._parentContainer.transformNodes.indexOf(this);z>-1&&this._parentContainer.transformNodes.splice(z,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),I){const z=this.getChildTransformNodes(!0);for(const V of z)V.parent=null,V.computeWorldMatrix(!0)}super.dispose(I,R)}normalizeToUnitCube(I=!0,R=!1,z){let V=null,q=null;R&&(this.rotationQuaternion?(q=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(V=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));const ee=this.getHierarchyBoundingVectors(I,z),Q=ee.max.subtract(ee.min),te=Math.max(Q.x,Q.y,Q.z);if(te===0)return this;const J=1/te;return this.scaling.scaleInPlace(J),R&&(this.rotationQuaternion&&q?this.rotationQuaternion.copyFrom(q):this.rotation&&V&&this.rotation.copyFrom(V)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}},(()=>{const W=typeof Symbol=="function"&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;t=[nt("position")],r=[nt("rotation")],l=[Pn("rotationQuaternion")],f=[nt("scaling")],E=[H("billboardMode")],v=[H()],b=[H("infiniteDistance")],C=[H()],P=[H()],k(null,null,t,{kind:"field",name:"_position",static:!1,private:!1,access:{has:I=>"_position"in I,get:I=>I._position,set:(I,R)=>{I._position=R}},metadata:W},i,s),k(null,null,r,{kind:"field",name:"_rotation",static:!1,private:!1,access:{has:I=>"_rotation"in I,get:I=>I._rotation,set:(I,R)=>{I._rotation=R}},metadata:W},a,n),k(null,null,l,{kind:"field",name:"_rotationQuaternion",static:!1,private:!1,access:{has:I=>"_rotationQuaternion"in I,get:I=>I._rotationQuaternion,set:(I,R)=>{I._rotationQuaternion=R}},metadata:W},c,h),k(null,null,f,{kind:"field",name:"_scaling",static:!1,private:!1,access:{has:I=>"_scaling"in I,get:I=>I._scaling,set:(I,R)=>{I._scaling=R}},metadata:W},d,u),k(null,null,E,{kind:"field",name:"_billboardMode",static:!1,private:!1,access:{has:I=>"_billboardMode"in I,get:I=>I._billboardMode,set:(I,R)=>{I._billboardMode=R}},metadata:W},_,M),k(null,null,v,{kind:"field",name:"scalingDeterminant",static:!1,private:!1,access:{has:I=>"scalingDeterminant"in I,get:I=>I.scalingDeterminant,set:(I,R)=>{I.scalingDeterminant=R}},metadata:W},S,m),k(null,null,b,{kind:"field",name:"_infiniteDistance",static:!1,private:!1,access:{has:I=>"_infiniteDistance"in I,get:I=>I._infiniteDistance,set:(I,R)=>{I._infiniteDistance=R}},metadata:W},x,A),k(null,null,C,{kind:"field",name:"ignoreNonUniformScaling",static:!1,private:!1,access:{has:I=>"ignoreNonUniformScaling"in I,get:I=>I.ignoreNonUniformScaling,set:(I,R)=>{I.ignoreNonUniformScaling=R}},metadata:W},B,O),k(null,null,P,{kind:"field",name:"reIntegrateRotationIntoRotationQuaternion",static:!1,private:!1,access:{has:I=>"reIntegrateRotationIntoRotationQuaternion"in I,get:I=>I.reIntegrateRotationIntoRotationQuaternion,set:(I,R)=>{I.reIntegrateRotationIntoRotationQuaternion=R}},metadata:W},Z,Y),W&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:W})})(),o.BILLBOARDMODE_NONE=0,o.BILLBOARDMODE_X=1,o.BILLBOARDMODE_Y=2,o.BILLBOARDMODE_Z=4,o.BILLBOARDMODE_ALL=7,o.BILLBOARDMODE_USE_POSITION=128,o.BillboardUseParentOrientation=!1,o._TmpRotation=Ee.Zero(),o._TmpScaling=T.Zero(),o._TmpTranslation=T.Zero(),o._TmpRHRestore=j.Scaling(1,1,-1),o._LookAtVectorCache=new T(0,0,0),o._RotationAxisCache=new Ee,o})();(vs=Pe.prototype).getPhysicsBody??(vs.getPhysicsBody=Ie("TransformNode","getPhysicsBody"));(Is=Pe.prototype).applyImpulse??(Is.applyImpulse=Ie("TransformNode","applyImpulse"));(Ss=Pe.prototype).applyAngularImpulse??(Ss.applyAngularImpulse=Ie("TransformNode","applyAngularImpulse"));(Es=Pe.prototype).applyTorque??(Es.applyTorque=Ie("TransformNode","applyTorque"));Object.getOwnPropertyDescriptor(Pe.prototype,"physicsBody")||Object.defineProperty(Pe.prototype,"physicsBody",Me("TransformNode","physicsBody"));class Kn{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(g.NormalKind))return null;let i=this.pickedMesh.getIndices();i?.length===0&&(i=null);let s;const r=N.Vector3[0],a=N.Vector3[1],n=N.Vector3[2];if(t){const c=this.pickedMesh.getVerticesData(g.NormalKind);let h=i?T.FromArrayToRef(c,i[this.faceId*3]*3,r):r.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),f=i?T.FromArrayToRef(c,i[this.faceId*3+1]*3,a):a.copyFromFloats(c[(this.faceId*3+1)*3],c[(this.faceId*3+1)*3+1],c[(this.faceId*3+1)*3+2]),d=i?T.FromArrayToRef(c,i[this.faceId*3+2]*3,n):n.copyFromFloats(c[(this.faceId*3+2)*3],c[(this.faceId*3+2)*3+1],c[(this.faceId*3+2)*3+2]);h=h.scale(this.bu),f=f.scale(this.bv),d=d.scale(1-this.bu-this.bv),s=new T(h.x+f.x+d.x,h.y+f.y+d.y,h.z+f.z+d.z)}else{const c=this.pickedMesh.getVerticesData(g.PositionKind),h=i?T.FromArrayToRef(c,i[this.faceId*3]*3,r):r.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),f=i?T.FromArrayToRef(c,i[this.faceId*3+1]*3,a):a.copyFromFloats(c[(this.faceId*3+1)*3],c[(this.faceId*3+1)*3+1],c[(this.faceId*3+1)*3+2]),d=i?T.FromArrayToRef(c,i[this.faceId*3+2]*3,n):n.copyFromFloats(c[(this.faceId*3+2)*3],c[(this.faceId*3+2)*3+1],c[(this.faceId*3+2)*3+2]),u=h.subtract(f),E=d.subtract(f);s=T.Cross(u,E)}const l=(c,h)=>{if(this.thinInstanceIndex!==-1){const d=c._thinInstanceDataStorage.matrixData,u=this.thinInstanceIndex<<4;if(d&&d.length>u){const E=N.Matrix[0];j.FromArrayToRef(d,u,E),T.TransformNormalToRef(h,E,h)}}let f=c.getWorldMatrix();
2c.nonUniformScaling&&(N.Matrix[0].copyFrom(f),f=N.Matrix[0],f.setTranslationFromFloats(0,0,0),f.invert(),f.transposeToRef(N.Matrix[1]),f=N.Matrix[1]),T.TransformNormalToRef(h,f,h)};if(e&&l(this.pickedMesh,s),this.ray){const c=N.Vector3[0].copyFrom(s);e||l(this.pickedMesh,c),T.Dot(c,this.ray.direction)>0&&s.negateInPlace()}return s.normalize(),s}getTextureCoordinates(e=g.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;const t=this.pickedMesh.getIndices();if(!t)return null;const i=this.pickedMesh.getVerticesData(e);if(!i)return null;let s=$e.FromArray(i,t[this.faceId*3]*2),r=$e.FromArray(i,t[this.faceId*3+1]*2),a=$e.FromArray(i,t[this.faceId*3+2]*2);return s=s.scale(this.bu),r=r.scale(this.bv),a=a.scale(1-this.bu-this.bv),new $e(s.x+r.x+a.x,s.y+r.y+a.y)}}class U{constructor(e,t,i=!1,s,r=!1,a){this._uniformNames=[],this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||r,this._dynamic=i,this._name=s??"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._trackUBOsInFrame=!1,(a===void 0&&this._engine._features.trackUbosInFrame||a===!0)&&(this._buffers=[],this._bufferIndex=-1,this._bufferUpdatedLastFrame=!1,this._createBufferOnWrite=!1,this._currentFrameId=0,this._trackUBOsInFrame=!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 this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}getUniformNames(){return this._uniformNames}_fillAlignment(e){let t;if(e<=2?t=e:t=4,this._uniformLocationPointer%t!==0){const i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;const s=this._uniformLocationPointer-i;for(let r=0;r<s;r++)this._data.push(0)}}
2addUniform(e,t,i=0){if(i>0&&typeof t=="number"&&(this._uniformArraySizes[e]={strideSize:t,arraySize:i}),this._uniformLocations[e]!==void 0||(this._uniformNames.push(e),this._noUBO))return;let s;if(i>0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;if(this._fillAlignment(4),t==16)t=t*i;else{const a=(4-t)*i;t=t*i+a}s=[];for(let r=0;r<t;r++)s.push(0)}else{if(t instanceof Array)s=t,t=s.length;else{s=[];for(let r=0;r<t;r++)s.push(0)}this._fillAlignment(t)}this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(let r=0;r<t;r++)this._data.push(s[r]);this._needSync=!0}addMatrix(e,t){this.addUniform(e,Array.prototype.slice.call(t.asArray()))}addFloat2(e,t,i){const s=[t,i];this.addUniform(e,s)}addFloat3(e,t,i,s){const r=[t,i,s];this.addUniform(e,r)}addColor3(e,t){const i=[t.r,t.g,t.b];this.addUniform(e,i)}addColor4(e,t,i){const s=[t.r,t.g,t.b,i];this.addUniform(e,s)}addVector3(e,t){const i=[t.x,t.y,t.z];this.addUniform(e,i)}addMatrix3x3(e){this.addUniform(e,12)}addMatrix2x2(e){this.addUniform(e,8)}create(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)}_getNamesDebug(){const e=[];let t=0;for(const i in this._uniformLocations)if(e.push(i),++t===10)break;return e.join(",")}_rebuild(){this._noUBO||!this._bufferData||(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNamesDebug()):this._buffer=this._engine.createUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNamesDebug()),this._trackUBOsInFrame&&(this._buffers.push([this._buffer,this._engine._features.checkUbosContentBeforeUpload?this._bufferData.slice():void 0]),this._bufferIndex=this._buffers.length-1,this._createBufferOnWrite=!1))}_rebuildAfterContextLost(){this._trackUBOsInFrame&&(this._buffers=[],this._currentFrameId=0),this._rebuild()}get _numBuffers(){return this._buffers.length}get _indexBuffer(){return this._bufferIndex}get name(){return this._name}set name(e){this._name=e}get currentEffect(){return this._currentEffect}_buffersEqual(e,t){for(let i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}_copyBuffer(e,t){for(let i=0;i<e.length;++i)t[i]=e[i]}update(){if(!this._noUBO){if(this.bindUniformBuffer(),!this._buffer){this.create();return}if(!this._dynamic&&!this._needSync){this._createBufferOnWrite=this._trackUBOsInFrame;return}if(this._buffers&&this._buffers.length>1&&this._buffers[this._bufferIndex][1])if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1])){this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame;return}else this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1]);this._bufferUpdatedLastFrame=!0,this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame}}_createNewBuffer(){this._bufferIndex+1<this._buffers.length?(this._bufferIndex++,this._buffer=this._buffers[this._bufferIndex][0],this._createBufferOnWrite=!1,this._needSync=!0):this._rebuild()}_checkNewFrame(){this._trackUBOsInFrame&&this._currentFrameId!==this._engine.frameId&&(this._currentFrameId=this._engine.frameId,this._createBufferOnWrite=!1,this._buffers&&this._buffers.length>0?(this._buffers.length===1?this._needSync=!this._bufferUpdatedLastFrame:this._needSync=this._bufferIndex!==0,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,i){this._checkNewFrame();let s=this._uniformLocations[e];if(s===void 0){if(this._buffer){fe.Error("Cannot add an uniform after UBO has been created. uniformName="+e);return}this.addUniform(e,i),s=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let r=0;r<i;r++)this._bufferData[s+r]=t[r];else{let r=!1;for(let a=0;a<i;a++)(i===16&&!this._engine._features.uniformBufferHardCheckMatrix||this._bufferData[s+a]!==Math.fround(t[a]))&&(r=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+a]=t[a]);this._needSync=this._needSync||r}}updateUniformArray(e,t,i){this._checkNewFrame();const s=this._uniformLocations[e];if(s===void 0){fe.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform and make sure that uniform buffers are supported by the current engine.");return}this._buffer||this.create();const r=this._uniformArraySizes[e];if(this._dynamic)for(let a=0;a<i;a++)this._bufferData[s+a]=t[a];else{let a=!1,n=0,l=0;for(let c=0;c<i;c++)if(this._bufferData[s+l*4+n]!==at.FloatRound(t[c])&&(a=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+l*4+n]=t[c]),n++,n===r.strideSize){for(;n<4;n++)this._bufferData[s+l*4+n]=0;n=0,l++}this._needSync=this._needSync||a}}_cacheMatrix(e,t){this._checkNewFrame();const i=this._valueCache[e],s=t.updateFlag;return i!==void 0&&i===s?!1:(this._valueCache[e]=s,!0)}_updateMatrix3x3ForUniform(e,t){for(let i=0;i<3;i++)U._TempBuffer[i*4]=t[i*3],U._TempBuffer[i*4+1]=t[i*3+1],U._TempBuffer[i*4+2]=t[i*3+2],U._TempBuffer[i*4+3]=0;this.updateUniform(e,U._TempBuffer,12)}
2_updateMatrix3x3ForEffect(e,t){this._currentEffect.setMatrix3x3(e,t)}_updateMatrix2x2ForEffect(e,t){this._currentEffect.setMatrix2x2(e,t)}_updateMatrix2x2ForUniform(e,t){for(let i=0;i<2;i++)U._TempBuffer[i*4]=t[i*2],U._TempBuffer[i*4+1]=t[i*2+1],U._TempBuffer[i*4+2]=0,U._TempBuffer[i*4+3]=0;this.updateUniform(e,U._TempBuffer,8)}_updateFloatForEffect(e,t,i=""){this._currentEffect.setFloat(e+i,t)}_updateFloatForUniform(e,t){U._TempBuffer[0]=t,this.updateUniform(e,U._TempBuffer,1)}_updateFloat2ForEffect(e,t,i,s=""){this._currentEffect.setFloat2(e+s,t,i)}_updateFloat2ForUniform(e,t,i){U._TempBuffer[0]=t,U._TempBuffer[1]=i,this.updateUniform(e,U._TempBuffer,2)}_updateFloat3ForEffect(e,t,i,s,r=""){this._currentEffect.setFloat3(e+r,t,i,s)}_updateFloat3ForUniform(e,t,i,s){U._TempBuffer[0]=t,U._TempBuffer[1]=i,U._TempBuffer[2]=s,this.updateUniform(e,U._TempBuffer,3)}_updateFloat4ForEffect(e,t,i,s,r,a=""){this._currentEffect.setFloat4(e+a,t,i,s,r)}_updateFloat4ForUniform(e,t,i,s,r){U._TempBuffer[0]=t,U._TempBuffer[1]=i,U._TempBuffer[2]=s,U._TempBuffer[3]=r,this.updateUniform(e,U._TempBuffer,4)}_updateFloatArrayForEffect(e,t,i=""){switch(this._uniformArraySizes[e]?.strideSize){case 2:this._currentEffect.setFloatArray2(e+i,t);break;case 3:this._currentEffect.setFloatArray3(e+i,t);break;case 4:this._currentEffect.setFloatArray4(e+i,t);break;default:this._currentEffect.setFloatArray(e+i,t);break}}_updateFloatArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateArrayForEffect(e,t){this._currentEffect.setArray(e,t)}_updateArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateIntArrayForEffect(e,t){this._currentEffect.setIntArray(e,t)}_updateIntArrayForUniform(e,t){U._TempBufferInt32View.set(t),this.updateUniformArray(e,U._TempBuffer,t.length)}_updateUIntArrayForEffect(e,t){this._currentEffect.setUIntArray(e,t)}_updateUIntArrayForUniform(e,t){U._TempBufferUInt32View.set(t),this.updateUniformArray(e,U._TempBuffer,t.length)}_updateMatrixForEffect(e,t){this._currentEffect.setMatrix(e,t)}_updateMatrixForUniform(e,t){this._cacheMatrix(e,t)&&this.updateUniform(e,t.asArray(),16)}_updateMatricesForEffect(e,t){this._currentEffect.setMatrices(e,t)}_updateMatricesForUniform(e,t){this.updateUniform(e,t,t.length)}_updateVector3ForEffect(e,t){this._currentEffect.setVector3(e,t)}_updateVector3ForUniform(e,t){U._TempBuffer[0]=t.x,U._TempBuffer[1]=t.y,U._TempBuffer[2]=t.z,this.updateUniform(e,U._TempBuffer,3)}_updateVector4ForEffect(e,t){this._currentEffect.setVector4(e,t)}_updateVector4ForUniform(e,t){U._TempBuffer[0]=t.x,U._TempBuffer[1]=t.y,U._TempBuffer[2]=t.z,U._TempBuffer[3]=t.w,this.updateUniform(e,U._TempBuffer,4)}_updateColor3ForEffect(e,t,i=""){this._currentEffect.setColor3(e+i,t)}_updateColor3ForUniform(e,t){U._TempBuffer[0]=t.r,U._TempBuffer[1]=t.g,U._TempBuffer[2]=t.b,this.updateUniform(e,U._TempBuffer,3)}_updateColor4ForEffect(e,t,i,s=""){this._currentEffect.setColor4(e+s,t,i)}_updateDirectColor4ForEffect(e,t,i=""){this._currentEffect.setDirectColor4(e+i,t)}_updateColor4ForUniform(e,t,i){U._TempBuffer[0]=t.r,U._TempBuffer[1]=t.g,U._TempBuffer[2]=t.b,U._TempBuffer[3]=i,this.updateUniform(e,U._TempBuffer,4)}_updateDirectColor4ForUniform(e,t){U._TempBuffer[0]=t.r,U._TempBuffer[1]=t.g,U._TempBuffer[2]=t.b,U._TempBuffer[3]=t.a,this.updateUniform(e,U._TempBuffer,4)}_updateIntForEffect(e,t,i=""){this._currentEffect.setInt(e+i,t)}_updateIntForUniform(e,t){U._TempBufferInt32View[0]=t,this.updateUniform(e,U._TempBuffer,1)}_updateInt2ForEffect(e,t,i,s=""){this._currentEffect.setInt2(e+s,t,i)}_updateInt2ForUniform(e,t,i){U._TempBufferInt32View[0]=t,U._TempBufferInt32View[1]=i,this.updateUniform(e,U._TempBuffer,2)}_updateInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setInt3(e+r,t,i,s)}_updateInt3ForUniform(e,t,i,s){U._TempBufferInt32View[0]=t,U._TempBufferInt32View[1]=i,U._TempBufferInt32View[2]=s,this.updateUniform(e,U._TempBuffer,3)}_updateInt4ForEffect(e,t,i,s,r,a=""){this._currentEffect.setInt4(e+a,t,i,s,r)}_updateInt4ForUniform(e,t,i,s,r){U._TempBufferInt32View[0]=t,U._TempBufferInt32View[1]=i,U._TempBufferInt32View[2]=s,U._TempBufferInt32View[3]=r,this.updateUniform(e,U._TempBuffer,4)}_updateUIntForEffect(e,t,i=""){this._currentEffect.setUInt(e+i,t)}_updateUIntForUniform(e,t){U._TempBufferUInt32View[0]=t,this.updateUniform(e,U._TempBuffer,1)}
2_updateUInt2ForEffect(e,t,i,s=""){this._currentEffect.setUInt2(e+s,t,i)}_updateUInt2ForUniform(e,t,i){U._TempBufferUInt32View[0]=t,U._TempBufferUInt32View[1]=i,this.updateUniform(e,U._TempBuffer,2)}_updateUInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setUInt3(e+r,t,i,s)}_updateUInt3ForUniform(e,t,i,s){U._TempBufferUInt32View[0]=t,U._TempBufferUInt32View[1]=i,U._TempBufferUInt32View[2]=s,this.updateUniform(e,U._TempBuffer,3)}_updateUInt4ForEffect(e,t,i,s,r,a=""){this._currentEffect.setUInt4(e+a,t,i,s,r)}_updateUInt4ForUniform(e,t,i,s,r){U._TempBufferUInt32View[0]=t,U._TempBufferUInt32View[1]=i,U._TempBufferUInt32View[2]=s,U._TempBufferUInt32View[3]=r,this.updateUniform(e,U._TempBuffer,4)}setTexture(e,t){this._currentEffect.setTexture(e,t)}setTextureArray(e,t){this._currentEffect.setTextureArray(e,t)}bindTexture(e,t){this._currentEffect._bindTexture(e,t)}updateUniformDirectly(e,t){this.updateUniform(e,t,t.length),this.update()}bindToEffect(e,t){this._currentEffect=e,this._currentEffectName=t}bindUniformBuffer(){!this._noUBO&&this._buffer&&this._currentEffect&&this._currentEffect.bindUniformBuffer(this._buffer,this._currentEffectName)}unbindEffect(){this._currentEffect=void 0,this._currentEffectName=void 0}setDataBuffer(e){if(!this._buffers)return this._buffer===e;for(let t=0;t<this._buffers.length;++t)if(this._buffers[t][0]===e)return this._bufferIndex=t,this._buffer=e,this._createBufferOnWrite=!1,this._currentEffect=void 0,this._buffers.length>1&&this._buffers[t][1]&&this._bufferData.set(this._buffers[t][1]),this._valueCache={},this._currentFrameId=this._engine.frameId,!0;return!1}has(e){return this._uniformLocations[e]!==void 0}dispose(){if(this._noUBO)return;const e=this._engine._uniformBuffers,t=e.indexOf(this);if(t!==-1&&(e[t]=e[e.length-1],e.pop()),this._trackUBOsInFrame&&this._buffers)for(let i=0;i<this._buffers.length;++i){const s=this._buffers[i][0];this._engine._releaseBuffer(s)}else this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}}U._MAX_UNIFORM_SIZE=256;U._TempBuffer=new Float32Array(U._MAX_UNIFORM_SIZE);U._TempBufferInt32View=new Int32Array(U._TempBuffer.buffer);U._TempBufferUInt32View=new Uint32Array(U._TempBuffer.buffer);class Yn{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new T(0,0,0),this._diffPositionForCollisions=new T(0,0,0),this._collisionResponse=!0}}var Ms,xs,Ds;function Zn(o,e,t){let i;switch(e){case g.PositionKind:i=s=>s.getPositions();break;case g.NormalKind:i=s=>s.getNormals();break;case g.TangentKind:i=s=>s.getTangents();break;case g.UVKind:i=s=>s.getUVs();break;case g.UV2Kind:i=s=>s.getUV2s();break;case g.ColorKind:i=s=>s.getColors();break;default:return}for(let s=0;s<o.length;s++){let r=o[s];for(let a=0;a<t.numTargets;a++){const n=t.getTarget(a),l=n.influence;if(l!==0){const c=i(n);c&&(r+=(c[s]-o[s])*l)}}o[s]=r}}function $n(o,e,t,i,s,r,a){const n=N.Vector3[0],l=N.Matrix[0],c=N.Matrix[1],h=e===g.NormalKind?T.TransformNormalFromFloatsToRef:T.TransformCoordinatesFromFloatsToRef;for(let f=0,d=0;f<o.length;f+=3,d+=4){l.reset();let u,E;for(u=0;u<4;u++)E=s[d+u],E>0&&(j.FromFloat32ArrayToRefScaled(t,Math.floor(i[d+u]*16),E,c),l.addToSelf(c));if(r&&a)for(u=0;u<4;u++)E=a[d+u],E>0&&(j.FromFloat32ArrayToRefScaled(t,Math.floor(r[d+u]*16),E,c),l.addToSelf(c));h(o[f],o[f+1],o[f+2],l,n),n.toArray(o,f)}}function As(o,e){return o-Math.floor(o/e)*e}function qn(o,e){const t=o.y-o.x+1,i=e*o.w/t,s=i<1?0:1,r=t-s;let a=As(i-Math.floor(i),1)*r;return a=As(a+o.z,r),Math.floor(a)+o.x+s}function bs(o,e,t){if(o instanceof Float32Array){j.FromArrayToRef(o,e,t);return}t.copyFromFloats(be(o[e]),be(o[e+1]),be(o[e+2]),be(o[e+3]),be(o[e+4]),be(o[e+5]),be(o[e+6]),be(o[e+7]),be(o[e+8]),be(o[e+9]),be(o[e+10]),be(o[e+11]),be(o[e+12]),be(o[e+13]),be(o[e+14]),be(o[e+15]))}function jn(o,e,t,i,s,r,a,n,l){const c=t.texture,f=c?.getInternalTexture()?._bufferView;if(!(f instanceof Float32Array)&&!(f instanceof Uint16Array))return fe.Warn("Baked vertex animation bounding info requires CPU-readable Float32Array or Uint16Array texture data.",1),!1;const d=c.getSize(),u=qn(i,t.time);if(!isFinite(u)||u<0||u>=d.height)return fe.Warn("Baked vertex animation bounding info could not be refreshed because the computed frame is outside the texture.",1),!1;const E=N.Vector3[0],_=N.Matrix[0],M=N.Matrix[1],v=u*d.width*4,S=e===g.NormalKind?T.TransformNormalFromFloatsToRef:T.TransformCoordinatesFromFloatsToRef;for(let m=0,b=0;m<o.length;m+=3,b+=4){_.reset();let x,A;for(x=0;x<4&&x<l;x++)A=r[b+x],A>0&&(bs(f,v+Math.floor(s[b+x])*16,M),M.scaleAndAddToRef(A,_));if(a&&n)for(x=0;x<4&&x+4<l;x++)A=n[b+x],A>0&&(bs(f,v+Math.floor(a[b+x])*16,M),M.scaleAndAddToRef(A,_));S(o[m],o[m+1],o[m+2],_,E),E.toArray(o,m)}return!0}class Qn{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=T.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}class Jn{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new Qn,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=new Map,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new Yn,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._wasActiveLastFrame=!1}}let ce=(()=>{var o;let e=Pe,t=[],i;return o=class extends e{static get BILLBOARDMODE_NONE(){return Pe.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return Pe.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return Pe.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return Pe.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return Pe.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return Pe.BILLBOARDMODE_USE_POSITION}get facetNb(){return this._internalAbstractMeshDataInfo._facetData.facetNb}get partitioningSubdivisions(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions}set partitioningSubdivisions(r){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=r}get partitioningBBoxRatio(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio}set partitioningBBoxRatio(r){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=r}get mustDepthSortFacets(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort}set mustDepthSortFacets(r){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=r}get facetDepthSortFrom(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom}set facetDepthSortFrom(r){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=r}get collisionRetryCount(){return this._internalAbstractMeshDataInfo._collisionRetryCount}set collisionRetryCount(r){this._internalAbstractMeshDataInfo._collisionRetryCount=r}get isFacetDataEnabled(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled}get morphTargetManager(){return this._internalAbstractMeshDataInfo._morphTargetManager}set morphTargetManager(r){this._internalAbstractMeshDataInfo._morphTargetManager!==r&&(this._internalAbstractMeshDataInfo._morphTargetManager=r,this._syncGeometryWithMorphTargetManager())}get bakedVertexAnimationManager(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager}set bakedVertexAnimationManager(r){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==r&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=r,this._markSubMeshesAsAttributesDirty())}_syncGeometryWithMorphTargetManager(){}_updateNonUniformScalingState(r){return super._updateNonUniformScalingState(r)?(this._markSubMeshesAsMiscDirty(),!0):!1}get rawBoundingInfo(){return this._internalAbstractMeshDataInfo._rawBoundingInfo}set rawBoundingInfo(r){this._internalAbstractMeshDataInfo._rawBoundingInfo=r}set onCollide(r){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(r)}set onCollisionPositionChange(r){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(r)}get visibility(){return this._internalAbstractMeshDataInfo._visibility}set visibility(r){if(this._internalAbstractMeshDataInfo._visibility===r)return;const a=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=r,(a===1&&r!==1||a!==1&&r===1)&&this._markSubMeshesAsDirty(n=>
vendor: 24,110 bytes, line 2
2{n.markAsMiscDirty(),n.markAsPrePassDirty()})}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(r){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=r}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(r){this._internalAbstractMeshDataInfo._renderingGroupId=r}get material(){return this._internalAbstractMeshDataInfo._material}set material(r){this._setMaterial(r)}_setMaterial(r){this._internalAbstractMeshDataInfo._material!==r&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=r,r&&r.meshMap&&(r.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(void 0,r==null),this._unBindEffect()))}getMaterialForRenderPass(r){return this._internalAbstractMeshDataInfo._materialForRenderPass?.[r]}setMaterialForRenderPass(r,a){this.resetDrawCache(r),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]);const n=this._internalAbstractMeshDataInfo._materialForRenderPass[r];n?.meshMap?.[this.uniqueId]&&(n.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._materialForRenderPass[r]=a,a&&a.meshMap&&(a.meshMap[this.uniqueId]=this)}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(r){this._internalAbstractMeshDataInfo._receiveShadows!==r&&(this._internalAbstractMeshDataInfo._receiveShadows=r,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(r){this._internalAbstractMeshDataInfo._hasVertexAlpha!==r&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=r,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(r){this._internalAbstractMeshDataInfo._useVertexColors!==r&&(this._internalAbstractMeshDataInfo._useVertexColors=r,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(r){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==r&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=r,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(r){this._internalAbstractMeshDataInfo._numBoneInfluencers!==r&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=r,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(r){this._internalAbstractMeshDataInfo._applyFog!==r&&(this._internalAbstractMeshDataInfo._applyFog=r,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(r){this._internalAbstractMeshDataInfo._enableDistantPicking=r}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(r){r!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=r,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(r){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(r)?-1:r}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(r){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=r}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(r){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(r)?-1:r}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(r){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=r}get lightSources(){return this._lightSources}set skeleton(r){const a=this._internalAbstractMeshDataInfo._skeleton;a&&a.needInitialSkinMatrix&&a._unregisterMeshWithPoseMatrix(this),r&&r.needInitialSkinMatrix&&r._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=r,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()}get skeleton(){return this._internalAbstractMeshDataInfo._skeleton}constructor(r,a=null){switch(super(r,a,!1),this._internalAbstractMeshDataInfo=new Jn,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this._waitingSkeletonId=null,this._waitingSkeletonUniqueId=null,this.cullingStrategy=o.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new ge,this.onCollisionPositionChangeObservable=new ge,this.onMaterialChangedObservable=new ge,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this.isPickable=o.DefaultIsPickable,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=xt.Red(),this.outlineWidth=.02,this.overlayColor=xt.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 T(.5,1,.5),this.ellipsoidOffset=new T(0,0,0),this.edgesWidth=1,this.edgesColor=new Vi(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 ge,this._onCollisionPositionChange=(n,l,c=null)=>{l.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>me.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),c&&this.onCollideObservable.notifyObservers(c),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},a=this.getScene(),this.layerMask=a.defaultRenderableLayerMask,a.addMesh(this),this._resyncLightSources(),this._uniformBuffer=new U(this.getScene().getEngine(),void 0,void 0,r,!this.getScene().getEngine().isWebGPU),this._buildUniformLayout(),a.performancePriority){case 2:this.doNotSyncBoundingInfo=!0;case 1:this.alwaysSelectAsActiveMesh=!0,this.isPickable=!1;break}}_buildUniformLayout(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()}transferToEffect(r){const a=this._uniformBuffer;a.updateMatrix("world",r),a.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),a.update()}getMeshUniformBuffer(){return this._uniformBuffer}getClassName(){return"AbstractMesh"}toString(r){let a="Name: "+this.name+", isInstance: "+(this.getClassName()==="InstancedMesh"?"YES":"NO");a+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);const n=this._internalAbstractMeshDataInfo._skeleton;return n&&(a+=", skeleton: "+n.name),r&&(a+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],a+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),a}_getEffectiveParent(){return this._masterMesh&&this.billboardMode!==Pe.BILLBOARDMODE_NONE?this._masterMesh:super._getEffectiveParent()}_getActionManagerForTrigger(r,a=!0){if(this.actionManager&&(a||this.actionManager.isRecursive))if(r){if(this.actionManager.hasSpecificTrigger(r))return this.actionManager}else return this.actionManager;return this.parent?this.parent._getActionManagerForTrigger(r,!1):null}_releaseRenderPassId(r){}_rebuild(r=!1){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery!==null&&(this._occlusionQuery=null),!!this.subMeshes){for(const a of this.subMeshes)a._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(const r of this.getScene().lights)r.isEnabled()&&r.canAffectMesh(this)&&this._lightSources.push(r);this._markSubMeshesAsLightDirty()}_resyncLightSource(r){const a=r.isEnabled()&&r.canAffectMesh(this),n=this._lightSources.indexOf(r);let l=!1;if(n===-1){if(!a)return;this._lightSources.push(r)}else{if(a)return;l=!0,this._lightSources.splice(n,1)}this._markSubMeshesAsLightDirty(l)}_unBindEffect(){for(const r of this.subMeshes)r.setEffect(null)}_removeLightSource(r,a){const n=this._lightSources.indexOf(r);n!==-1&&(this._lightSources.splice(n,1),this._markSubMeshesAsLightDirty(a))}_markSubMeshesAsDirty(r){if(this.subMeshes)for(const a of this.subMeshes)for(let n=0;n<a._drawWrappers.length;++n){const l=a._drawWrappers[n];!l||!l.defines||!l.defines.markAllAsDirty||r(l.defines)}}_markSubMeshesAsLightDirty(r=!1){this._markSubMeshesAsDirty(a=>a.markAsLightDirty(r))}_markSubMeshesAsAttributesDirty(){this._markSubMeshesAsDirty(r=>r.markAsAttributesDirty())}_markSubMeshesAsMiscDirty(){this._markSubMeshesAsDirty(r=>r.markAsMiscDirty())}markAsDirty(r){return this._currentRenderId=Number.MAX_VALUE,super.markAsDirty(r),this._isDirty=!0,this}resetDrawCache(r,a=!1){if(this.subMeshes)for(const n of this.subMeshes)n.resetDrawCache(r,a)}get isBlocked(){return!1}getLOD(r){return this}getTotalVertices(){return 0}getTotalIndices(){return 0}getIndices(){return null}getVerticesData(r){return null}setVerticesData(r,a,n,l){return this}updateVerticesData(r,a,n,l){return this}setIndices(r,a){return this}isVerticesDataPresent(r){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(r){return this._boundingInfo=r,this}get hasBoundingInfo(){return this._boundingInfo!==null}buildBoundingInfo(r,a,n){return this._boundingInfo=new we(r,a,n),this._boundingInfo}normalizeToUnitCube(r=!0,a=!1,n){return super.normalizeToUnitCube(r,a,n)}get useBones(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(g.MatricesIndicesKind)&&this.isVerticesDataPresent(g.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(r){}_activate(r,a){return this._renderId=r,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===Pe.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(r,a,n){return this.position.addInPlace(this.calcMovePOV(r,a,n)),this}calcMovePOV(r,a,n){const l=new j;(this.rotationQuaternion?this.rotationQuaternion:Ee.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(l);const h=T.Zero(),f=this.definedFacingForward?-1:1;return T.TransformCoordinatesFromFloatsToRef(r*f,a,n*f,l,h),h}rotatePOV(r,a,n){return this.rotation.addInPlace(this.calcRotatePOV(r,a,n)),this}calcRotatePOV(r,a,n){const l=this.definedFacingForward?1:-1;return new T(r*l,a,n*l)}_refreshBoundingInfo(r,a){if(r){const n=sr(r,0,this.getTotalVertices(),a);this._boundingInfo?this._boundingInfo.reConstruct(n.minimum,n.maximum):this._boundingInfo=new we(n.minimum,n.maximum)}if(this.subMeshes)for(let n=0;n<this.subMeshes.length;n++)this.subMeshes[n].refreshBoundingInfo(r);this._updateBoundingInfo()}_refreshBoundingInfoDirect(r){if(this._boundingInfo?this._boundingInfo.reConstruct(r.minimum,r.maximum):this._boundingInfo=new we(r.minimum,r.maximum),this.subMeshes)for(let a=0;a<this.subMeshes.length;a++)this.subMeshes[a].refreshBoundingInfo(null);this._updateBoundingInfo()}static _ApplySkeleton(r,a,n,l,c,h,f){$n(r,a,n,l,c,h,f)}_getData(r,a,n=g.PositionKind){const l=r.cache,c=d=>{if(l){const u=l._vertexData||(l._vertexData={});return u[d]||this.copyVerticesData(d,u),u[d]}return this.getVerticesData(d)};if(a||(a=c(n)),!a)return null;l?(l._outputData?l._outputData.set(a):l._outputData=new Float32Array(a),a=l._outputData):(r.applyMorph&&this.morphTargetManager||r.applySkeleton&&this.skeleton||r.applyBakedVertexAnimation&&this.bakedVertexAnimationManager?.isEnabled)&&(a=a.slice()),r.applyMorph&&this.morphTargetManager&&Zn(a,n,this.morphTargetManager);const h=this.bakedVertexAnimationManager;let f=!1;if(r.applyBakedVertexAnimation&&h?.isEnabled){const d=c(g.MatricesIndicesKind),u=c(g.MatricesWeightsKind);if(u&&d){const E=this.numBoneInfluencers>4,_=E?c(g.MatricesIndicesExtraKind):null,M=E?c(g.MatricesWeightsExtraKind):null;f=jn(a,n,h,r.bakedVertexAnimationSettings??h.animationParameters,d,u,_,M,this.numBoneInfluencers)}}if(!f&&r.applySkeleton&&this.skeleton){const d=c(g.MatricesIndicesKind),u=c(g.MatricesWeightsKind);if(u&&d){const E=this.numBoneInfluencers>4,_=E?c(g.MatricesIndicesExtraKind):null,M=E?c(g.MatricesWeightsExtraKind):null,v=this.skeleton.getTransformMatrices(this);o._ApplySkeleton(a,n,v,d,u,_,M)}}if(r.updatePositionsArray!==!1&&n===g.PositionKind){const d=this._internalAbstractMeshDataInfo._positions||[],u=d.length;if(d.length=a.length/3,u<d.length)for(let E=u;E<d.length;E++)d[E]=new T;for(let E=0,_=0;E<d.length;E++,_+=3)d[E].copyFromFloats(a[_],a[_+1],a[_+2]);this._internalAbstractMeshDataInfo._positions=d}return a}getNormalsData(r=!1,a=!1){return this._getData({applySkeleton:r,applyMorph:a,updatePositionsArray:!1},null,g.NormalKind)}getPositionData(r=!1,a=!1,n=null){return this._getData({applySkeleton:r,applyMorph:a,updatePositionsArray:!1},n,g.PositionKind)}_updateBoundingInfo(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new we(T.Zero(),T.Zero(),this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this}_updateSubMeshesBoundingInfo(r){if(!this.subMeshes)return this;const a=this.subMeshes.length;for(let n=0;n<a;n++){const l=this.subMeshes[n];(a>1||!l.IsGlobal)&&l.updateBoundingInfo(r)}return this}_afterComputeWorldMatrix(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)}isInFrustum(r){return this.getBoundingInfo().isInFrustum(r,this.cullingStrategy)}isCompletelyInFrustum(r){return this.getBoundingInfo().isCompletelyInFrustum(r)}intersectsMesh(r,a=!1,n){const l=this.getBoundingInfo(),c=r.getBoundingInfo();if(l.intersects(c,a))return!0;if(n){for(const h of this.getChildMeshes())if(h.intersectsMesh(r,a,!0))return!0}return!1}intersectsPoint(r){return this.getBoundingInfo().intersectsPoint(r)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(r){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=r}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(r,a=!0){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);const l=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=l.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,l.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,r,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId,a),this}_collideForSubMesh(r,a,n){if(this._generatePointsArray(),!this._positions)return this;if(!r._lastColliderWorldVertices||!r._lastColliderTransformMatrix.equals(a)){r._lastColliderTransformMatrix=a.clone(),r._lastColliderWorldVertices=[],r._trianglePlanes=[];const l=r.verticesStart,c=r.verticesStart+r.verticesCount;for(let h=l;h<c;h++)r._lastColliderWorldVertices.push(T.TransformCoordinates(this._positions[h],a))}return n._collide(r._trianglePlanes,r._lastColliderWorldVertices,this.getIndices(),r.indexStart,r.indexStart+r.indexCount,r.verticesStart,!!r.getMaterial(),this,this._shouldConvertRHS(),r.getMaterial()?.fillMode===7),this}_processCollisionsForSubMeshes(r,a){const n=this._scene.getCollidingSubMeshCandidates(this,r),l=n.length;for(let c=0;c<l;c++){const h=n.data[c];l>1&&!h._checkCollision(r)||this._collideForSubMesh(h,a,r)}return this}_shouldConvertRHS(){return!1}_checkCollision(r){if(!this.getBoundingInfo()._checkCollision(r))return this;const a=N.Matrix[0],n=N.Matrix[1];return j.ScalingToRef(1/r._radius.x,1/r._radius.y,1/r._radius.z,a),this.worldMatrixFromCache.multiplyToRef(a,n),this._processCollisionsForSubMeshes(r,n),this}_generatePointsArray(){return!1}intersects(r,a,n,l=!1,c,h=!1){const f=new Kn,d=this.getClassName(),u=d==="InstancedLinesMesh"||d==="LinesMesh"||d==="GreasedLineMesh"?this.intersectionThreshold:0,E=this.getBoundingInfo();if(!this.subMeshes||!h&&(!r.intersectsSphere(E.boundingSphere,u)||!r.intersectsBox(E.boundingBox,u)))return f;if(l)return f.hit=!h,f.pickedMesh=h?null:this,f.distance=h?0:T.Distance(r.origin,E.boundingSphere.center),f.subMeshId=0,f;if(!this._generatePointsArray())return f;let _=null;const M=this._scene.getIntersectingSubMeshCandidates(this,r),v=M.length;let S=!1;for(let m=0;m<v;m++){const x=M.data[m].getMaterial();if(x&&(x.fillMode==7||x.fillMode==0||x.fillMode==1||x.fillMode==2||x.fillMode==4)){S=!0;break}}if(!S)return f.hit=!0,f.pickedMesh=this,f.distance=T.Distance(r.origin,E.boundingSphere.center),f.subMeshId=-1,f;for(let m=0;m<v;m++){const b=M.data[m];if(v>1&&!h&&!b.canIntersects(r))continue;const x=b.intersects(r,this._positions,this.getIndices(),a,n);if(x&&(a||!_||x.distance<_.distance)&&(_=x,_.subMeshId=b._id,_._internalSubMeshId=m,a))break}if(_){const m=c??this.getWorldMatrix(),b=N.Vector3[0],x=N.Vector3[1];T.TransformCoordinatesToRef(r.origin,m,b),r.direction.scaleToRef(_.distance,x);const C=T.TransformNormal(x,m).addInPlace(b);return f.hit=!0,f.distance=T.Distance(b,C),f.pickedPoint=C,f.pickedMesh=this,f.bu=_.bu||0,f.bv=_.bv||0,f.subMeshFaceId=_.faceId,f.faceId=_.faceId+M.data[_._internalSubMeshId].indexStart/(this.getClassName().indexOf("LinesMesh")!==-1?2:3),f.subMeshId=_.subMeshId,f}return f}clone(r,a,n){return null}releaseSubMeshes(r=!1){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose(r);else this.subMeshes=[];return this}dispose(r,a=!1){let n;const l=this.getScene();for(this._scene.useMaterialMeshMap&&this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),l.freeActiveMeshes(),l.freeRenderingGroups(),l.renderingManager.maintainStateBetweenFrames&&l.renderingManager.restoreDispachedFlags(),this.actionManager!==void 0&&this.actionManager!==null&&(this.actionManager.disposeWhenUnowned&&!this._scene.meshes.some(f=>f!==this&&f.actionManager===this.actionManager)&&this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),n=0;n<this._intersectionsInProgress.length;n++){const f=this._intersectionsInProgress[n],d=f._intersectionsInProgress.indexOf(this);f._intersectionsInProgress.splice(d,1)}this._intersectionsInProgress.length=0;const c=l.lights;for(const f of c){let d=f.includedOnlyMeshes.indexOf(this);d!==-1&&f.includedOnlyMeshes.splice(d,1),d=f.excludedMeshes.indexOf(this),d!==-1&&f.excludedMeshes.splice(d,1);const u=f.getShadowGenerators();if(u){const E=u.values();for(let _=E.next();_.done!==!0;_=E.next()){const v=_.value.getShadowMap();v&&v.renderList&&(d=v.renderList.indexOf(this),d!==-1&&v.renderList.splice(d,1))}}}(this.getClassName()!=="InstancedMesh"||this.getClassName()!=="InstancedLinesMesh")&&this.releaseSubMeshes(!0);const h=l.getEngine();if(this._occlusionQuery!==null&&(this.isOcclusionQueryInProgress=!1,h.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),h.wipeCaches(),l.removeMesh(this),this._parentContainer){const f=this._parentContainer.meshes.indexOf(this);f>-1&&this._parentContainer.meshes.splice(f,1),this._parentContainer=null}if(a&&this.material&&(this.material.getClassName()==="MultiMaterial"?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!r)for(n=0;n<l.particleSystems.length;n++)l.particleSystems[n].emitter===this&&(l.particleSystems[n].dispose(),n--);this._internalAbstractMeshDataInfo._facetData.facetDataEnabled&&this.disableFacetData(),this._uniformBuffer.dispose(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),super.dispose(r,a)}_initFacetData(){const r=this._internalAbstractMeshDataInfo._facetData;r.facetNormals||(r.facetNormals=[]),r.facetPositions||(r.facetPositions=[]),r.facetPartitioning||(r.facetPartitioning=new Array),r.facetNb=this.getIndices().length/3|0,r.partitioningSubdivisions=r.partitioningSubdivisions?r.partitioningSubdivisions:10,r.partitioningBBoxRatio=r.partitioningBBoxRatio?r.partitioningBBoxRatio:1.01;for(let a=0;a<r.facetNb;a++)r.facetNormals[a]=T.Zero(),r.facetPositions[a]=T.Zero();return r.facetDataEnabled=!0,this}updateFacetData(){const r=this._internalAbstractMeshDataInfo._facetData;r.facetDataEnabled||this._initFacetData();const a=this.getVerticesData(g.PositionKind),n=this.getIndices(),l=this.getVerticesData(g.NormalKind)?.slice(),c=this.getBoundingInfo();if(r.facetDepthSort&&!r.facetDepthSortEnabled){if(r.facetDepthSortEnabled=!0,n instanceof Uint16Array)r.depthSortedIndices=new Uint16Array(n);else if(n instanceof Uint32Array)r.depthSortedIndices=new Uint32Array(n);else{let f=!1;for(let d=0;d<n.length;d++)if(n[d]>65535){f=!0;break}f?r.depthSortedIndices=new Uint32Array(n):r.depthSortedIndices=new Uint16Array(n)}if(r.facetDepthSortFunction=function(f,d){return d.sqDistance-f.sqDistance},!r.facetDepthSortFrom){const f=this.getScene().activeCamera;r.facetDepthSortFrom=f?f.position:T.Zero()}r.depthSortedFacets=[];for(let f=0;f<r.facetNb;f++){const d={ind:f*3,sqDistance:0};r.depthSortedFacets.push(d)}r.invertedMatrix=j.Identity(),r.facetDepthSortOrigin=T.Zero()}r.bbSize.x=c.maximum.x-c.minimum.x>et?c.maximum.x-c.minimum.x:et,r.bbSize.y=c.maximum.y-c.minimum.y>et?c.maximum.y-c.minimum.y:et,r.bbSize.z=c.maximum.z-c.minimum.z>et?c.maximum.z-c.minimum.z:et;let h=r.bbSize.x>r.bbSize.y?r.bbSize.x:r.bbSize.y;if(h=h>r.bbSize.z?h:r.bbSize.z,r.subDiv.max=r.partitioningSubdivisions,r.subDiv.X=Math.floor(r.subDiv.max*r.bbSize.x/h),r.subDiv.Y=Math.floor(r.subDiv.max*r.bbSize.y/h),r.subDiv.Z=Math.floor(r.subDiv.max*r.bbSize.z/h),r.subDiv.X=r.subDiv.X<1?1:r.subDiv.X,r.subDiv.Y=r.subDiv.Y<1?1:r.subDiv.Y,r.subDiv.Z=r.subDiv.Z<1?1:r.subDiv.Z,r.facetParameters.facetNormals=this.getFacetLocalNormals(),r.facetParameters.facetPositions=this.getFacetLocalPositions(),r.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),r.facetParameters.bInfo=c,r.facetParameters.bbSize=r.bbSize,r.facetParameters.subDiv=r.subDiv,r.facetParameters.ratio=this.partitioningBBoxRatio,r.facetParameters.depthSort=r.facetDepthSort,r.facetDepthSort&&r.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(r.
2invertedMatrix),T.TransformCoordinatesToRef(r.facetDepthSortFrom,r.invertedMatrix,r.facetDepthSortOrigin),r.facetParameters.distanceTo=r.facetDepthSortOrigin),r.facetParameters.depthSortedFacets=r.depthSortedFacets,l&&Ae.ComputeNormals(a,n,l,r.facetParameters),r.facetDepthSort&&r.facetDepthSortEnabled){r.depthSortedFacets.sort(r.facetDepthSortFunction);const f=r.depthSortedIndices.length/3|0;for(let d=0;d<f;d++){const u=r.depthSortedFacets[d].ind;r.depthSortedIndices[d*3]=n[u],r.depthSortedIndices[d*3+1]=n[u+1],r.depthSortedIndices[d*3+2]=n[u+2]}this.updateIndices(r.depthSortedIndices,void 0,!0)}return this}getFacetLocalNormals(){const r=this._internalAbstractMeshDataInfo._facetData;return r.facetNormals||this.updateFacetData(),r.facetNormals}getFacetLocalPositions(){const r=this._internalAbstractMeshDataInfo._facetData;return r.facetPositions||this.updateFacetData(),r.facetPositions}getFacetLocalPartitioning(){const r=this._internalAbstractMeshDataInfo._facetData;return r.facetPartitioning||this.updateFacetData(),r.facetPartitioning}getFacetPosition(r){const a=T.Zero();return this.getFacetPositionToRef(r,a),a}getFacetPositionToRef(r,a){const n=this.getFacetLocalPositions()[r],l=this.getWorldMatrix();return T.TransformCoordinatesToRef(n,l,a),this}getFacetNormal(r){const a=T.Zero();return this.getFacetNormalToRef(r,a),a}getFacetNormalToRef(r,a){const n=this.getFacetLocalNormals()[r];return T.TransformNormalToRef(n,this.getWorldMatrix(),a),this}getFacetsAtLocalCoordinates(r,a,n){const l=this.getBoundingInfo(),c=this._internalAbstractMeshDataInfo._facetData,h=Math.floor((r-l.minimum.x*c.partitioningBBoxRatio)*c.subDiv.X*c.partitioningBBoxRatio/c.bbSize.x),f=Math.floor((a-l.minimum.y*c.partitioningBBoxRatio)*c.subDiv.Y*c.partitioningBBoxRatio/c.bbSize.y),d=Math.floor((n-l.minimum.z*c.partitioningBBoxRatio)*c.subDiv.Z*c.partitioningBBoxRatio/c.bbSize.z);return h<0||h>c.subDiv.max||f<0||f>c.subDiv.max||d<0||d>c.subDiv.max?null:c.facetPartitioning[h+c.subDiv.max*f+c.subDiv.max*c.subDiv.max*d]}getClosestFacetAtCoordinates(r,a,n,l,c=!1,h=!0){const f=this.getWorldMatrix(),d=N.Matrix[5];f.invertToRef(d);const u=N.Vector3[8];T.TransformCoordinatesFromFloatsToRef(r,a,n,d,u);const E=this.getClosestFacetAtLocalCoordinates(u.x,u.y,u.z,l,c,h);return l&&T.TransformCoordinatesFromFloatsToRef(l.x,l.y,l.z,f,l),E}getClosestFacetAtLocalCoordinates(r,a,n,l,c=!1,h=!0){let f=null,d,u,E,_,M,v,S,m;const b=this.getFacetLocalPositions(),x=this.getFacetLocalNormals(),A=this.getFacetsAtLocalCoordinates(r,a,n);if(!A)return null;let C=Number.MAX_VALUE,B,O,P,Z;for(let Y=0;Y<A.length;Y++)O=A[Y],P=x[O],Z=b[O],_=(r-Z.x)*P.x+(a-Z.y)*P.y+(n-Z.z)*P.z,(!c||c&&h&&_>=0||c&&!h&&_<=0)&&(_=P.x*Z.x+P.y*Z.y+P.z*Z.z,M=-(P.x*r+P.y*a+P.z*n-_)/(P.x*P.x+P.y*P.y+P.z*P.z),v=r+P.x*M,S=a+P.y*M,m=n+P.z*M,d=v-r,u=S-a,E=m-n,B=d*d+u*u+E*E,B<C&&(C=B,f=O,l&&(l.x=v,l.y=S,l.z=m)));return f}getFacetDataParameters(){return this._internalAbstractMeshDataInfo._facetData.facetParameters}disableFacetData(){const r=this._internalAbstractMeshDataInfo._facetData;return r.facetDataEnabled&&(r.facetDataEnabled=!1,r.facetPositions=[],r.facetNormals=[],r.facetPartitioning=new Array,r.facetParameters={},r.depthSortedIndices=new Uint32Array(0)),this}updateIndices(r,a,n=!1){return this}createNormals(r){const a=this.getVerticesData(g.PositionKind),n=this.getIndices();let l;return this.isVerticesDataPresent(g.NormalKind)?l=this.getVerticesData(g.NormalKind):l=[],Ae.ComputeNormals(a,n,l,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(g.NormalKind,l,r),this}async optimizeIndicesAsync(){const r=this.getIndices();if(!r)return this;const{OptimizeIndices:a}=await Ue(async()=>{const{OptimizeIndices:n}=await import("./mesh.vertexData.functions-ayNlGC5K.js");return{OptimizeIndices:n}},[]);return a(r),this.setIndices(r,this.getTotalVertices()),this}alignWithNormal(r,a){a||(a=vt.Y);const n=N.Vector3[0],l=N.Vector3[1];return T.CrossToRef(a,r,l),T.CrossToRef(r,l,n),this.rotationQuaternion?Ee.RotationQuaternionFromAxisToRef(n,r,l,this.rotationQuaternion):T.RotationFromAxisToRef(n,r,l,this.rotation),this}_checkOcclusionQuery(r=!1){return!1}disableEdgesRendering(){throw le("EdgesRenderer")}enableEdgesRendering(r,a,n){throw le("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter(r=>r.emitter===this)}},(()=>{const s=typeof Symbol=="function"&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;i=[tt.filter((...r)=>!Array.isArray(r[0])&&!Array.isArray(r[3])&&!Array.isArray(r[4])&&!Array.isArray(r[5])&&!Array.isArray(r[6]))],k(o,null,i,{kind:"method",name:"_ApplySkeleton",static:!0,private:!1,access:{has:r=>"_ApplySkeleton"in r,get:r=>r._ApplySkeleton},metadata:s},null,t),s&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:s})})(),o.OCCLUSION_TYPE_NONE=(w(o,t),0),o.OCCLUSION_TYPE_OPTIMISTIC=1,o.OCCLUSION_TYPE_STRICT=2,o.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,o.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,o.CULLINGSTRATEGY_STANDARD=0,o.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,o.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,o.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,o.DefaultIsPickable=!0,o})();(Ms=ce.prototype).createOrUpdateSubmeshesOctree??(Ms.createOrUpdateSubmeshesOctree=Ie("AbstractMesh","createOrUpdateSubmeshesOctree"));(xs=ce.prototype).getPhysicsImpostor??(xs.getPhysicsImpostor=Ie("AbstractMesh","getPhysicsImpostor"));(Ds=ce.prototype).setPhysicsLinkWith??(Ds.setPhysicsLinkWith=Ie("AbstractMesh","setPhysicsLinkWith"));Object.getOwnPropertyDescriptor(ce.prototype,"occlusionRetryCount")||Object.defineProperty(ce.prototype,"occlusionRetryCount",Me("AbstractMesh","occlusionRetryCount"));Object.getOwnPropertyDescriptor(ce.prototype,"occlusionType")||Object.defineProperty(ce.prototype,"occlusionType",Me("AbstractMesh","occlusionType"));Object.getOwnPropertyDescriptor(ce.prototype,"occlusionQueryAlgorithmType")||Object.defineProperty(ce.prototype,"occlusionQueryAlgorithmType",Me("AbstractMesh","occlusionQueryAlgorithmType"));Object.getOwnPropertyDescriptor(ce.prototype,"isOccluded")||Object.defineProperty(ce.prototype,"isOccluded",Me("AbstractMesh","isOccluded"));Object.getOwnPropertyDescriptor(ce.prototype,"isOcclusionQueryInProgress")||Object.defineProperty(ce.prototype,"isOcclusionQueryInProgress",Me("AbstractMesh","isOcclusionQueryInProgress"));Object.getOwnPropertyDescriptor(ce.prototype,"forceRenderingWhenOccluded")||Object.defineProperty(ce.prototype,"forceRenderingWhenOccluded",Me("AbstractMesh","forceRenderingWhenOccluded"));Object.getOwnPropertyDescriptor(ce.prototype,"occlusionForRenderPassId")||Object.defineProperty(ce.prototype,"occlusionForRenderPassId",Me("AbstractMesh","occlusionForRenderPassId"));Object.getOwnPropertyDescriptor(ce.prototype,"decalMap")||Object.defineProperty(ce.prototype,"decalMap",Me("AbstractMesh","decalMap"));Object.getOwnPropertyDescriptor(ce.prototype,"instancedBuffers")||Object.defineProperty(ce.prototype,"instancedBuffers",Me("AbstractMesh","instancedBuffers"));Object.getOwnPropertyDescriptor(ce.prototype,"physicsImpostor")||Object.defineProperty(ce.prototype,"physicsImpostor",Me("AbstractMesh","physicsImpostor"));Object.getOwnPropertyDescriptor(ce.prototype,"showBoundingBox")||Object.defineProperty(ce.prototype,"showBoundingBox",Me("AbstractMesh","showBoundingBox"));Object.getOwnPropertyDescriptor(ce.prototype,"edgesRenderer")||Object.defineProperty(ce.prototype,"edgesRenderer",Me("AbstractMesh","edgesRenderer"));Object.getOwnPropertyDescriptor(ce.prototype,"renderOutline")||Object.defineProperty(ce.prototype,"renderOutline",Me("AbstractMesh","renderOutline"));Object.getOwnPropertyDescriptor(ce.prototype,"renderOverlay")||Object.defineProperty(ce.prototype,"renderOverlay",Me("AbstractMesh","renderOverlay"));let ea=(()=>{var o;let e=ct,t=[],i,s=[],r=[],a,n=[],l=[],c,h,f,d,u,E=[],_=[],M,v=[],S=[],m,b=[],x=[],A,C=[],B=[],O,P,Z,Y=[],W=[],I,R=[],z=[],V,q=[],ee=[],Q,te=[],J=[],se,re=[],xe=[],We,Fe=[],pe=[];return o=class extends e{get position(){return this._position}set position(D){this._position=D}set upVector(D){this._upVector=D}get upVector(){return this._upVector}get screenArea(){let D,F;if(this.mode===o.PERSPECTIVE_CAMERA)this.fovMode===o.FOVMODE_VERTICAL_FIXED?(F=this.minZ*2*Math.tan(this.fov/2),D=this.getEngine().getAspectRatio(this)*F):(D=this.minZ*2*Math.tan(this.fov/2),F=D/this.getEngine().getAspectRatio(this));else{const K=this.getEngine().getRenderWidth()/2,ae=this.getEngine().getRenderHeight()/2;D=(this.orthoRight??K)-(this.orthoLeft??-K),F=(this.orthoTop??ae)-(this.orthoBottom??-ae)}return D*F}set orthoLeft(D){this._orthoLeft=D;for(const F of this._rigCameras)F.orthoLeft=D}get orthoLeft(){return this._orthoLeft}
2set orthoRight(D){this._orthoRight=D;for(const F of this._rigCameras)F.orthoRight=D}get orthoRight(){return this._orthoRight}set orthoBottom(D){this._orthoBottom=D;for(const F of this._rigCameras)F.orthoBottom=D}get orthoBottom(){return this._orthoBottom}set orthoTop(D){this._orthoTop=D;for(const F of this._rigCameras)F.orthoTop=D}get orthoTop(){return this._orthoTop}setFocalLength(D,F=36){this.fov=2*Math.atan(F/(2*D))}get inertia(){return this._baseInertia}set inertia(D){this._baseInertia=D}set mode(D){this._mode=D;for(const F of this._rigCameras)F.mode=D}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(D,F,K,ae=!0){yn(),super(D,K,!1),this.inputs=w(this,t),this._position=w(this,s,T.Zero()),this._upVector=(w(this,r),w(this,n,T.Up())),this.oblique=(w(this,l),null),this._orthoLeft=null,this._orthoRight=null,this._orthoBottom=null,this._orthoTop=null,this.fov=w(this,E,.8),this.projectionPlaneTilt=(w(this,_),w(this,v,0)),this.minZ=(w(this,S),w(this,b,1)),this.maxZ=(w(this,x),w(this,C,1e4)),this._baseInertia=(w(this,B),.9),this._mode=o.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new Vn(0,0,1,1),this.layerMask=w(this,Y,268435455),this.fovMode=(w(this,W),w(this,R,o.FOVMODE_VERTICAL_FIXED)),this.cameraRigMode=(w(this,z),w(this,q,o.RIG_MODE_NONE)),this.interaxialDistance=(w(this,ee),w(this,te,void 0)),this.isStereoscopicSideBySide=(w(this,J),w(this,re,void 0)),this.ignoreCameraMaxZ=(w(this,xe),w(this,Fe,!1)),this.customRenderTargets=(w(this,pe),[]),this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new ge,this.onProjectionMatrixChangedObservable=new ge,this.onAfterCheckInputsObservable=new ge,this.onRestoreStateObservable=new ge,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new j,this._postProcesses=new Array,this._activeMeshes=new Un(256),this._globalPosition=T.Zero(),this._computedViewMatrix=j.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=j.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=Ee.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.layerMask=this.getScene().defaultCameraLayerMask,this.getScene().addCamera(this),ae&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=F,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${D}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return this._stateStored?(this.fov=this._storedFov,!0):!1}restoreState(){return this._restoreStateValues()?(this.onRestoreStateObservable.notifyObservers(this),!0):!1}getClassName(){return"Camera"}toString(D){let F="Name: "+this.name;if(F+=", type: "+this.getClassName(),this.animations)for(let K=0;K<this.animations.length;K++)F+=", animation[0]: "+this.animations[K].toString(D);return F}applyVerticalCorrection(){const D=this.absoluteRotation.toEulerAngles();this.projectionPlaneTilt=this._scene.useRightHandedSystem?-D.x:D.x}get globalPosition(){return this._globalPosition}getActiveMeshes(){return this._activeMeshes}isActiveMesh(D){return this._activeMeshes.indexOf(D)!==-1}isReady(D=!1){if(D){for(const F of this._postProcesses)if(F&&!F.isReady())return!1}return super.isReady(D)}_initCache(){super._initCache(),this._cache.position=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.obliqueAngle=void 0,this._cache.obliqueLength=void 0,this._cache.obliqueOffset=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0}_updateCache(D){D||super._updateCache(),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)}_isSynchronized(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()}_isSynchronizedViewMatrix(){return super._isSynchronized()?this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent():!1}_isSynchronizedProjectionMatrix(){const D=this.ignoreCameraMaxZ?0:this.maxZ;let F=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===D;if(!F)return!1;const K=this.getEngine();return this.mode===o.PERSPECTIVE_CAMERA?F=this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===K.getAspectRatio(this)&&this._cache.projectionPlaneTilt===this.projectionPlaneTilt:(F=this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===K.getRenderWidth()&&this._cache.renderHeight===K.getRenderHeight(),this.oblique&&(F=F&&this._cache.obliqueAngle===this.oblique.angle&&this._cache.obliqueLength===this.oblique.length&&this._cache.obliqueOffset===this.oblique.offset)),F}attachControl(D,F){}detachControl(D){}update(){this._hasMoved=!1,this._checkInputs(),this.cameraRigMode!==o.RIG_MODE_NONE&&this._updateRigCameras(),this.getViewMatrix(),this.getProjectionMatrix()}_checkInputs(){this.onAfterCheckInputsObservable.notifyObservers(this)}get rigCameras(){return this._rigCameras}get rigPostProcess(){return this._rigPostProcess}_getFirstPostProcess(){for(let D=0;D<this._postProcesses.length;D++)if(this._postProcesses[D]!==null)return this._postProcesses[D];return null}_cascadePostProcessesToRigCams(){const D=this._getFirstPostProcess();D&&D.markTextureDirty();for(let F=0,K=this._rigCameras.length;F<K;F++){const ae=this._rigCameras[F],ue=ae._rigPostProcess;ue?(ue.getEffectName()==="pass"&&(ae.isIntermediate=this._postProcesses.length===0),ae._postProcesses=this._postProcesses.slice(0).concat(ue),ue.markTextureDirty()):ae._postProcesses=this._postProcesses.slice(0)}}attachPostProcess(D,F=null){return!D.isReusable()&&this._postProcesses.indexOf(D)>-1?(fe.Error("You're trying to reuse a post process not defined as reusable."),0):(F==null||F<0?this._postProcesses.push(D):this._postProcesses[F]===null?this._postProcesses[F]=D:this._postProcesses.splice(F,0,D),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(D))}detachPostProcess(D){const F=this._postProcesses.indexOf(D);F!==-1&&(this._postProcesses[F]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()}getWorldMatrix(){return this._isSynchronizedViewMatrix()?this._worldMatrix:(this.getViewMatrix(),this._worldMatrix)}_getViewMatrix(){return j.Identity()}getViewMatrix(D){return!D&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(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._worldMatrix.getTranslationToRef(this._globalPosition),this._computedViewMatrix)}freezeProjectionMatrix(D){this._doNotComputeProjectionMatrix=!0,D!==void 0&&(this._projectionMatrix=D)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}
vendor: 9,500 bytes, line 2
2getProjectionMatrix(D){if(this._doNotComputeProjectionMatrix||!D&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;const F=this.ignoreCameraMaxZ?0:this.maxZ;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=F,this._refreshFrustumPlanes=!0;const K=this.getEngine(),ae=this.getScene(),ue=K.useReverseDepthBuffer;if(this.mode===o.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=K.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1);let Se;ae.useRightHandedSystem?Se=j.PerspectiveFovRHToRef:Se=j.PerspectiveFovLHToRef,Se(this.fov,K.getAspectRatio(this),ue?F:this.minZ,ue?this.minZ:F,this._projectionMatrix,this.fovMode===o.FOVMODE_VERTICAL_FIXED,K.isNDCHalfZRange,this.projectionPlaneTilt,ue)}else{const Se=K.getRenderWidth()/2,Oe=K.getRenderHeight()/2;ae.useRightHandedSystem?this.oblique?j.ObliqueOffCenterRHToRef(this.orthoLeft??-Se,this.orthoRight??Se,this.orthoBottom??-Oe,this.orthoTop??Oe,ue?F:this.minZ,ue?this.minZ:F,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,K.isNDCHalfZRange):j.OrthoOffCenterRHToRef(this.orthoLeft??-Se,this.orthoRight??Se,this.orthoBottom??-Oe,this.orthoTop??Oe,ue?F:this.minZ,ue?this.minZ:F,this._projectionMatrix,K.isNDCHalfZRange):this.oblique?j.ObliqueOffCenterLHToRef(this.orthoLeft??-Se,this.orthoRight??Se,this.orthoBottom??-Oe,this.orthoTop??Oe,ue?F:this.minZ,ue?this.minZ:F,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,K.isNDCHalfZRange):j.OrthoOffCenterLHToRef(this.orthoLeft??-Se,this.orthoRight??Se,this.orthoBottom??-Oe,this.orthoTop??Oe,ue?F:this.minZ,ue?this.minZ:F,this._projectionMatrix,K.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=K.getRenderWidth(),this._cache.renderHeight=K.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(D){const F=this,K=this;return(F.radius||(K.target?T.Distance(this.position,K.target):this.position.length()))+D}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?Ke.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Ke.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(D,F=!1){if(this._updateFrustumPlanes(),F&&this.rigCameras.length>0){let K=!1;for(const ae of this.rigCameras)ae._updateFrustumPlanes(),K=K||D.isInFrustum(ae._frustumPlanes);return K}else return D.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(D){return this._updateFrustumPlanes(),D.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(D=100,F,K){throw le("Ray")}getForwardRayToRef(D,F=100,K,ae){throw le("Ray")}dispose(D,F=!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 ae=this._rigCameras.pop();ae&&ae.dispose()}if(this._parentContainer){const ae=this._parentContainer.cameras.indexOf(this);ae>-1&&this._parentContainer.cameras.splice(ae,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==o.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let ae=this._postProcesses.length;for(;--ae>=0;){const ue=this._postProcesses[ae];ue&&ue.dispose(this)}}let K=this.customRenderTargets.length;for(;--K>=0;)this.customRenderTargets[K].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),super.dispose(D,F)}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(D,F){if(this.cameraRigMode!==D){for(;this._rigCameras.length>0;){const K=this._rigCameras.pop();K&&K.dispose()}if(this.cameraRigMode=D,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=F.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=this._cameraRigParams.interaxialDistance/.0637*(Math.PI/180),this.cameraRigMode!==o.RIG_MODE_NONE){const K=this.createRigCamera(this.name+"_L",0);K&&(K._isLeftCamera=!0);const ae=this.createRigCamera(this.name+"_R",1);ae&&(ae._isRightCamera=!0),K&&ae&&(this._rigCameras.push(K),this._rigCameras.push(ae))}this._setRigMode(F),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(D){}_getVRProjectionMatrix(){return j.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.ignoreCameraMaxZ?0:this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(D,F){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[D]=F,D==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=F/.0637*(Math.PI/180))}createRigCamera(D,F){return null}_updateRigCameras(){for(let D=0;D<this._rigCameras.length;D++)this._rigCameras[D].minZ=this.minZ,this._rigCameras[D].maxZ=this.ignoreCameraMaxZ?0:this.maxZ,this._rigCameras[D].fov=this.fov,this._rigCameras[D].upVector.copyFrom(this.upVector);this.cameraRigMode===o.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)}_setupInputs(){}serialize(){const D=Be.Serialize(this);return D.uniqueId=this.uniqueId,D.type=this.getClassName(),this.parent&&this.parent._serializeAsParent(D),this.inputs&&this.inputs.serialize(D),Be.AppendSerializedAnimations(this,D),D.ranges=this.serializeAnimationRanges(),D.isEnabled=this.isEnabled(),D}clone(D,F=null){const K=Be.Clone(o.GetConstructorFromName(this.getClassName(),D,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this);return K.name=D,K.parent=F,this.onClonedObservable.notifyObservers(K),K}getDirection(D){const F=T.Zero();return this.getDirectionToRef(D,F),F}get absoluteRotation(){return this.getWorldMatrix().decompose(void 0,this._absoluteRotation),this._absoluteRotation}getDirectionToRef(D,F){T.TransformNormalToRef(D,this.getWorldMatrix(),F)}static GetConstructorFromName(D,F,K,ae=0,ue=!0){const Se=ct.Construct(D,F,K,{interaxial_distance:ae,isStereoscopicSideBySide:ue});return Se||(()=>o._CreateDefaultParsedCamera(F,K))}computeWorldMatrix(){return this.getWorldMatrix()}_calculateHandednessMultiplier(){let D=this.getScene().useRightHandedSystem?-1:1;return this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(D*=-1),D}},(()=>{const he=typeof Symbol=="function"&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;i=[nt("position")],a=[nt("upVector")],c=[H()],h=[H()],f=[H()],d=[H()],u=[H()],M=[H()],m=[H()],A=[H()],O=[H()],P=[H()],Z=[H()],I=[H()],V=[H()],Q=[H()],se=[H()],We=[H()],k(o,null,c,{kind:"getter",name:"orthoLeft",static:!1,private:!1,access:{has:D=>"orthoLeft"in D,get:D=>D.orthoLeft},metadata:he},null,t),k(o,null,h,{kind:"getter",name:"orthoRight",static:!1,private:!1,access:{has:D=>"orthoRight"in D,get:D=>D.orthoRight},metadata:he},null,t),k(o,null,f,{kind:"getter",name:"orthoBottom",static:!1,private:!1,access:{has:D=>"orthoBottom"in D,get:D=>D.orthoBottom},metadata:he},null,t),k(o,null,d,{kind:"getter",name:"orthoTop",static:!1,private:!1,access:{has:D=>"orthoTop"in D,get:D=>D.orthoTop},metadata:he},null,t),k(o,null,O,{kind:"getter",name:"inertia",static:!1,private:!1,access:{has:D=>"inertia"in D,get:D=>D.inertia},metadata:he},null,t),k(o,null,P,{kind:"getter",name:"mode",static:!1,private:!1,access:{has:D=>"mode"in D,get:D=>D.mode},metadata:he},null,t),k(null,null,i,{kind:"field",name:"_position",static:!1,private:!1,access:{has:D=>"_position"in D,get:D=>D._position,set:(D,F)=>{D._position=F}},metadata:he},s,r),k(null,null,a,{kind:"field",name:"_upVector",static:!1,private:!1,access:{has:D=>"_upVector"in D,get:D=>D._upVector,set:(D,F)=>{D._upVector=F}},metadata:he},n,l),k(null,null,u,{kind:"field",name:"fov",static:!1,private:!1,access:{has:D=>"fov"in D,get:D=>D.fov,set:(D,F)=>{D.fov=F}},metadata:he},E,_),k(null,null,M,{kind:"field",name:"projectionPlaneTilt",static:!1,private:!1,access:{has:D=>"projectionPlaneTilt"in D,get:D=>D.projectionPlaneTilt,set:(D,F)=>{D.projectionPlaneTilt=F}},metadata:he},v,S),k(null,null,m,{kind:"field",name:"minZ",static:!1,private:!1,access:{has:D=>"minZ"in D,get:D=>D.minZ,set:(D,F)=>{D.minZ=F}},metadata:he}
2,b,x),k(null,null,A,{kind:"field",name:"maxZ",static:!1,private:!1,access:{has:D=>"maxZ"in D,get:D=>D.maxZ,set:(D,F)=>{D.maxZ=F}},metadata:he},C,B),k(null,null,Z,{kind:"field",name:"layerMask",static:!1,private:!1,access:{has:D=>"layerMask"in D,get:D=>D.layerMask,set:(D,F)=>{D.layerMask=F}},metadata:he},Y,W),k(null,null,I,{kind:"field",name:"fovMode",static:!1,private:!1,access:{has:D=>"fovMode"in D,get:D=>D.fovMode,set:(D,F)=>{D.fovMode=F}},metadata:he},R,z),k(null,null,V,{kind:"field",name:"cameraRigMode",static:!1,private:!1,access:{has:D=>"cameraRigMode"in D,get:D=>D.cameraRigMode,set:(D,F)=>{D.cameraRigMode=F}},metadata:he},q,ee),k(null,null,Q,{kind:"field",name:"interaxialDistance",static:!1,private:!1,access:{has:D=>"interaxialDistance"in D,get:D=>D.interaxialDistance,set:(D,F)=>{D.interaxialDistance=F}},metadata:he},te,J),k(null,null,se,{kind:"field",name:"isStereoscopicSideBySide",static:!1,private:!1,access:{has:D=>"isStereoscopicSideBySide"in D,get:D=>D.isStereoscopicSideBySide,set:(D,F)=>{D.isStereoscopicSideBySide=F}},metadata:he},re,xe),k(null,null,We,{kind:"field",name:"ignoreCameraMaxZ",static:!1,private:!1,access:{has:D=>"ignoreCameraMaxZ"in D,get:D=>D.ignoreCameraMaxZ,set:(D,F)=>{D.ignoreCameraMaxZ=F}},metadata:he},Fe,pe),he&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:he})})(),o._CreateDefaultParsedCamera=(he,D)=>{throw le("UniversalCamera")},o.PERSPECTIVE_CAMERA=0,o.ORTHOGRAPHIC_CAMERA=1,o.FOVMODE_VERTICAL_FIXED=0,o.FOVMODE_HORIZONTAL_FIXED=1,o.RIG_MODE_NONE=0,o.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,o.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,o.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,o.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,o.RIG_MODE_STEREOSCOPIC_INTERLACED=14,o.RIG_MODE_VR=20,o.RIG_MODE_CUSTOM=22,o.ForceAttachControlToAlwaysPreventDefault=!1,o})();class Le{static get ForceFullSceneLoadingForIncremental(){return Le._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){Le._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return Le._ShowLoadingScreen}static set ShowLoadingScreen(e){Le._ShowLoadingScreen=e}static get loggingLevel(){return Le._LoggingLevel}static set loggingLevel(e){Le._LoggingLevel=e}static get CleanBoneMatrixWeights(){return Le._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){Le._CleanBoneMatrixWeights=e}}Le._ForceFullSceneLoadingForIncremental=!1;Le._ShowLoadingScreen=!0;Le._CleanBoneMatrixWeights=!1;Le._LoggingLevel=0;class Ce{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 Ce(Ce.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,s=!1,r=null,a=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._extend={minimum:new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),maximum:new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||ot.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=s,a!==null&&(this._totalVertices=a),i?this.setAllVerticesData(i,s):a===null&&(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 this.delayLoadState===1||this.delayLoadState===0}get doNotSerialize(){for(let e=0;e<this._meshes.length;e++)if(!this._meshes[e].doNotSerialize)return!1;return!0}_rebuild(){this._vertexArrayObjects&&(this._vertexArrayObjects={}),this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer"));const e=new Set;for(const t in this._vertexBuffers)e.add(this._vertexBuffers[t].getWrapperBuffer());e.forEach(t=>{t._rebuild()})}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,i=!1,s){i&&Array.isArray(t)&&(t=new Float32Array(t));const r=new g(this._engine,t,e,{updatable:i,postponeInternalCreation:this._meshes.length===0,stride:s,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,i=!0){const s=e.getKind();this._vertexBuffers[s]&&i&&this._vertexBuffers[s].dispose(),e._buffer&&e._ownsBuffer&&e._buffer._increaseReferences(),this._vertexBuffers[s]=e;const r=this._meshes,a=r.length;if(s===g.PositionKind){this._totalVertices=t??e._maxVerticesCount,this._updateExtend(this.useBoundingInfoFromGeometry&&this._boundingInfo?null:e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();const n=this._extend&&this._extend.minimum||new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=this._extend&&this._extend.maximum||new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let c=0;c<a;c++){const h=r[c];h.buildBoundingInfo(n,l),h._createGlobalSubMesh(h.isUnIndexed),h.computeWorldMatrix(!0),h.synchronizeInstances()}}this._notifyUpdate(s)}updateVerticesDataDirectly(e,t,i,s=!1){const r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i,s),this._notifyUpdate(e))}updateVerticesData(e,t,i=!1){const s=this.getVertexBuffer(e);s&&(s.update(t),e===g.PositionKind&&this._updateBoundingInfo(i,t),this._notifyUpdate(e))}_updateBoundingInfo(e,t){if(e&&this._updateExtend(t),this._resetPointsArrayCache(),e){const i=this._meshes;for(const s of i){s.hasBoundingInfo?s.getBoundingInfo().reConstruct(this._extend.minimum,this._extend.maximum):s.buildBoundingInfo(this._extend.minimum,this._extend.maximum);const r=s.subMeshes;for(const a of r)a.refreshBoundingInfo()}}}_bind(e,t,i,s){if(!e)return;t===void 0&&(t=this._indexBuffer);const r=this.getVertexBuffers();if(!r)return;if(t!=this._indexBuffer||!this._vertexArrayObjects&&!s){this._engine.b
vendor: 13,464 bytes, line 2
2indBuffers(r,t,e,i);return}const a=s||this._vertexArrayObjects,n=this._engine;a[e.key]||(a[e.key]=n.recordVertexArrayObject(r,t,e,i)),n.bindVertexArrayObject(a[e.key],t)}getTotalVertices(){return this.isReady()?this._totalVertices:0}getVerticesData(e,t,i){const s=this.getVertexBuffer(e);return s?s.getFloatData(this._totalVertices,i||t&&this._meshes.length!==1):null}copyVerticesData(e,t){const i=this.getVertexBuffer(e);if(!i)return;t[e]||(t[e]=new Float32Array(this._totalVertices*i.getSize()));const s=i.getData();s&&Rn(s,i.getSize(),i.type,i.byteOffset,i.byteStride,i.normalized,this._totalVertices,t[e])}isVertexBufferUpdatable(e){const t=this._vertexBuffers[e];return t?t.isUpdatable():!1}getVertexBuffer(e){return this.isReady()?this._vertexBuffers[e]:null}getVertexBuffers(){return this.isReady()?this._vertexBuffers:null}isVerticesDataPresent(e){return this._vertexBuffers?this._vertexBuffers[e]!==void 0:this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1}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,i=!1){if(this._indexBuffer)if(!this._indexBufferIsUpdatable)this.setIndices(e,null,!0);else{const s=e.length!==this._indices.length;if(i||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),s)for(const r of this._meshes)r._createGlobalSubMesh(!0)}}setIndexBuffer(e,t,i,s=null){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=e,this._totalVertices=t,this._totalIndices=i,s===null?e.is32Bits=t>65535:e.is32Bits=s;for(const r of this._meshes)r._createGlobalSubMesh(!0),r.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,i=!1,s=!1){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,this._indexBufferIsUpdatable=i,this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,i,"Geometry_"+this.id+"_IndexBuffer")),t!=null&&(this._totalVertices=t);for(const r of this._meshes)r._createGlobalSubMesh(!s),r.synchronizeInstances();this._notifyUpdate()}getTotalIndices(){return this.isReady()?this._totalIndices!==void 0?this._totalIndices:this._indices.length:0}getIndices(e,t){if(!this.isReady())return null;const i=this._indices;return!t&&(!e||this._meshes.length===1)?i:i.slice()}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 i=this._meshes,s=i.indexOf(e);s!==-1&&(i.splice(s,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,i.length===0&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;const t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();const i=this._meshes;e._geometry=this,e._internalAbstractMeshDataInfo._positions=null,this._scene.pushGeometry(this),i.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(g.PositionKind),!e))return;this._extend=sr(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){for(const t in this._vertexBuffers){const i=this._vertexBuffers[t];i._buffer.getBuffer()||i.create(),t===g.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo())}!this._indexBuffer&&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 t of this._meshes)t._markSubMeshesAsAttributesDirty()}load(e,t){if(this.delayLoadState!==2){if(this.isReady()){t&&t();return}this.delayLoadState=2,this._queueLoad(e,t)}}_queueLoad(e,t){this.delayLoadingFile&&(e.addPendingData(this),(async()=>{try{const i=await e._loadDelayedFileAsync(this.delayLoadingFile,!1,!0);if(!this._delayLoadingFunction){e.removePendingData(this);return}this._delayLoadingFunction(JSON.parse(i),this),this.delayLoadState=1,this._delayInfo=[],e.removePendingData(this);const s=this._meshes,r=s.length;for(let a=0;a<r;a++)this._applyToMesh(s[a]);t&&t()}catch(i){e.removePendingData(this),e.isDisposed||fe.Error(`Unable to delay load geometry "${this.id}" from "${this.delayLoadingFile}": ${i}`)}})())}toLeftHanded(){const e=this.getIndices(!1);if(e!=null&&e.length>0){for(let s=0;s<e.length;s+=3){const r=e[s+0];e[s+0]=e[s+2],e[s+2]=r}this.setIndices(e)}const t=this.getVerticesData(g.PositionKind,!1);if(t!=null&&t.length>0){for(let s=0;s<t.length;s+=3)t[s+2]=-t[s+2];this.setVerticesData(g.PositionKind,t,!1)}const i=this.getVerticesData(g.NormalKind,!1);if(i!=null&&i.length>0){for(let s=0;s<i.length;s+=3)i[s+2]=-i[s+2];this.setVerticesData(g.NormalKind,i,!1)}}_resetPointsArrayCache(){this._positions=null}_generatePointsArray(){if(this._positions)return!0;const e=this.getVerticesData(g.PositionKind);if(!e||e.length===0)return!1;for(let t=this._positionsCache.length*3,i=this._positionsCache.length;t<e.length;t+=3,++i)this._positionsCache[i]=T.FromArray(e,t);for(let t=0,i=0;t<e.length;t+=3,++i)this._positionsCache[i].set(e[0+t],e[1+t],e[2+t]);return this._positionsCache.length=e.length/3,this._positions=this._positionsCache,!0}isDisposed(){return this._isDisposed}_disposeVertexArrayObjects(){if(this._vertexArrayObjects){for(const i in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[i]);this._vertexArrayObjects={};const e=this._meshes,t=e.length;for(let i=0;i<t;i++)e[i]._invalidateInstanceVertexArrayObject()}}dispose(){const e=this._meshes,t=e.length;let i;for(i=0;i<t;i++)this.releaseForMesh(e[i]);this._meshes.length=0,this._disposeVertexArrayObjects();for(const s in this._vertexBuffers)this._vertexBuffers[s].dispose();if(this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=0,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._parentContainer){const s=this._parentContainer.geometries.indexOf(this);s>-1&&this._parentContainer.geometries.splice(s,1),this._parentContainer=null}this._isDisposed=!0}copy(e){const t=new Ce(e,this._scene),i=this.getIndices(void 0,!0);i&&t.setIndices(i);let s=!1,r;for(r in this._vertexBuffers){const a=this.getVertexBuffer(r),n=a.getData();if(!n)continue;const l=a.isUpdatable(),c=a.getSize(),{type:h,byteOffset:f,byteStride:d,normalized:u}=a;s=s||l;let E=this._totalVertices;if(a.getIsInstanced()){let v;n instanceof Array?v=n.length*4:v=n.byteLength,E=v/d}const _=Ln(n,c,h,f,d,E,!0),M=new g(this._engine,_,r,{updatable:l,useBytes:!1,stride:c,size:c,offset:0,type:h,normalized:u,takeBufferOwnership:!0,instanced:a.getIsInstanced()});t.setVerticesBuffer(M,E)}t._updatable=s,t.delayLoadState=this.delayLoadState,t.delayLoadingFile=this.delayLoadingFile,t._delayLoadingFunction=this._delayLoadingFunction;for(r in this._delayInfo)t._delayInfo=t._delayInfo||[],t._delayInfo.push(r);return t._boundingInfo=new we(this._extend.minimum,this._extend.maximum),t}serialize(){const e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,De&&De.HasTags(this)&&(e.tags=De.GetTags(this)),e}_toNumberArray(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)}clearCachedData(){this._totalIndices=this._indices.length,this._indices=[],this._resetPointsArrayCache();for(const e in this._vertexBuffers)Object.prototype.hasOwnProperty.call(this._vertexBuffers,e)&&(this._vertexBuffers[e]._buffer._data=null)}serializeVerticeData(){const e=this.serialize();return this.isVerticesDataPresent(g.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(g.PositionKind)),this.isVertexBufferUpdatable(g.PositionKind)&&(e.positionsUpdatable=!0)),this.isVerticesDataPresent(g.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(g.NormalKind)),this.isVertexBufferUpdatable(g.NormalKind)&&(e.normalsUpdatable=!0)),this.isVerticesDataPresent(g.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(g.TangentKind)),this.isVertexBufferUpdatable(g.TangentKind)&&(e.tangentsUpdatable=!0)),this.isVerticesDataPresent(g.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(g.UVKind)),this.isVertexBufferUpdatable(g.UVKind)&&(e.uvsUpdatable=!0)),this.isVerticesDataPresent(g.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(g.UV2Kind)),this.isVertexBufferUpdatable(g.UV2Kind)&&(e.uvs2Updatable=!0)),this.isVerticesDataPresent(g.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(g.UV3Kind)),this.isVertexBufferUpdatable(g.UV3Kind)&&(e.uvs3Updatable=!0)),this.isVerticesDataPresent(g.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(g.UV4Kind)),this.isVertexBufferUpdatable(g.UV4Kind)&&(e.uvs4Updatable=!0)),this.isVerticesDataPresent(g.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(g.UV5Kind)),this.isVertexBufferUpdatable(g.UV5Kind)&&(e.uvs5Updatable=!0)),this.isVerticesDataPresent(g.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(g.UV6Kind)),this.isVertexBufferUpdatable(g.UV6Kind)&&(e.uvs6Updatable=!0)),this.isVerticesDataPresent(g.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(g.ColorKind)),this.isVertexBufferUpdatable(g.ColorKind)&&(e.colorsUpdatable=!0)),this.isVerticesDataPresent(g.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(g.MatricesIndicesKind)),e.matricesIndicesExpanded=!0,this.isVertexBufferUpdatable(g.MatricesIndicesKind)&&(e.matricesIndicesUpdatable=!0)),this.isVerticesDataPresent(g.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(g.MatricesWeightsKind)),this.isVertexBufferUpdatable(g.MatricesWeightsKind)&&(e.matricesWeightsUpdatable=!0)),e.indices=this._toNumberArray(this.getIndices()),e}static ExtractFromMesh(e,t){const i=e._geometry;return i?i.copy(t):null}static RandomId(){return at.RandomId()}static _GetGeometryByLoadedUniqueId(e,t){for(let i=0;i<t.geometries.length;i++)if(t.geometries[i]._loadedUniqueId===e)return t.geometries[i];return null}static _ImportGeometry(e,t){const i=t.getScene(),s=e.geometryUniqueId,r=e.geometryId;if(s||r){const a=s?this._GetGeometryByLoadedUniqueId(s,i):i.getGeometryById(r);a&&a.applyToMesh(t)}else if(e instanceof ArrayBuffer){const a=t._binaryInfo;if(a.positionsAttrDesc&&a.positionsAttrDesc.count>0){const n=new Float32Array(e,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);t.setVerticesData(g.PositionKind,n,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){const n=new Float32Array(e,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);t.setVerticesData(g.NormalKind,n,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){const n=new Float32Array(e,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);t.setVerticesData(g.TangentKind,n,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){const n=new Float32Array(e,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);t.setVerticesData(g.UVKind,n,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){const n=new Float32Array(e,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);t.setVerticesData(g.UV2Kind,n,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){const n=new Float32Array(e,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);t.setVerticesData(g.UV3Kind,n,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){const n=new Float32Array(e,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);t.setVerticesData(g.UV4Kind,n,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){const n=new Float32Array(e,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);t.setVerticesData(g.UV5Kind,n,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){const n=new Float32Array(e,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);t.setVerticesData(g.UV6Kind,n,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){const n=new Float32Array(e,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);t.setVerticesData(g.ColorKind,n,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){const n=new Int32Array(e,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count),l=[];for(let c=0;c<n.length;c++){const h=n[c];l.push(h&255),l.push((h&65280)>>8),l.push((h&16711680)>>16),l.push(h>>24&255)}t.setVerticesData(g.MatricesIndicesKind,l,!1)}if(a.matricesIndicesExtraAttrDesc&&a.matricesIndicesExtraAttrDesc.count>0){const n=new Int32Array(e,a.matricesIndicesExtraAttrDesc.offset,a.matricesIndicesExtraAttrDesc.count),l=[];for(let c=0;c<n.length;c++){const h=n[c];l.push(h&255),l.push((h&65280)>>8),l.push((h&16711680)>>16),l.push(h>>24&255)}t.setVerticesData(g.MatricesIndicesExtraKind,l,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){const n=new Float32Array(e,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);t.setVerticesData(g.MatricesWeightsKind,n,!1)}
2if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){const n=new Int32Array(e,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);t.setIndices(n,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){const n=new Int32Array(e,a.subMeshesAttrDesc.offset,a.subMeshesAttrDesc.count*5);t.subMeshes=[];for(let l=0;l<a.subMeshesAttrDesc.count;l++){const c=n[l*5+0],h=n[l*5+1],f=n[l*5+2],d=n[l*5+3],u=n[l*5+4];Ne.AddToMesh(c,h,f,d,u,t)}}}else if(e.positions&&e.normals&&e.indices){if(t.setVerticesData(g.PositionKind,e.positions,e.positions._updatable||e.positionsUpdatable),t.setVerticesData(g.NormalKind,e.normals,e.normals._updatable||e.normalsUpdatable),e.tangents&&t.setVerticesData(g.TangentKind,e.tangents,e.tangents._updatable||e.tangentsUpdatable),e.uvs&&t.setVerticesData(g.UVKind,e.uvs,e.uvs._updatable||e.uvsUpdatable),e.uvs2&&t.setVerticesData(g.UV2Kind,e.uvs2,e.uvs2._updatable||e.uvs2Updatable),e.uvs3&&t.setVerticesData(g.UV3Kind,e.uvs3,e.uvs3._updatable||e.uvs3Updatable),e.uvs4&&t.setVerticesData(g.UV4Kind,e.uvs4,e.uvs4._updatable||e.uvs4Updatable),e.uvs5&&t.setVerticesData(g.UV5Kind,e.uvs5,e.uvs5._updatable||e.uvs5Updatable),e.uvs6&&t.setVerticesData(g.UV6Kind,e.uvs6,e.uvs6._updatable||e.uvs6Updatable),e.colors&&t.setVerticesData(g.ColorKind,Vi.CheckColors4(e.colors,e.positions.length/3),e.colors._updatable),e.matricesIndices)if(!e.matricesIndices._isExpanded&&!e.matricesIndicesExpanded){const a=[];for(let n=0;n<e.matricesIndices.length;n++){const l=e.matricesIndices[n];a.push(l&255),a.push((l&65280)>>8),a.push((l&16711680)>>16),a.push(l>>24&255)}t.setVerticesData(g.MatricesIndicesKind,a,e.matricesIndices._updatable||e.matricesIndicesUpdatable)}else delete e.matricesIndices._isExpanded,delete e.matricesIndicesExpanded,t.setVerticesData(g.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable||e.matricesIndicesUpdatable);if(e.matricesIndicesExtra)if(e.matricesIndicesExtraExpanded||e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,delete e.matricesIndicesExtraExpanded,t.setVerticesData(g.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable);else{const a=[];for(let n=0;n<e.matricesIndicesExtra.length;n++){const l=e.matricesIndicesExtra[n];a.push(l&255),a.push((l&65280)>>8),a.push((l&16711680)>>16),a.push(l>>24&255)}t.setVerticesData(g.MatricesIndicesExtraKind,a,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable)}e.matricesWeights&&(Ce._CleanMatricesWeights(e,t),t.setVerticesData(g.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(g.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let a=0;a<e.subMeshes.length;a++){const n=e.subMeshes[a];Ne.AddToMesh(n.materialIndex,n.verticesStart,n.verticesCount,n.indexStart,n.indexCount,t)}}t._shouldGenerateFlatShading&&(t.convertToFlatShadedMesh(),t._shouldGenerateFlatShading=!1),t.computeWorldMatrix(!0),i.onMeshImportedObservable.notifyObservers(t)}static _CleanMatricesWeights(e,t){if(!Le.CleanBoneMatrixWeights)return;let s;if(e.skeletonId>-1){const f=t.getScene().getLastSkeletonById(e.skeletonId);if(!f)return;s=f.bones.length}else return;const r=t.getVerticesData(g.MatricesIndicesKind),a=t.getVerticesData(g.MatricesIndicesExtraKind),n=e.matricesWeights,l=e.matricesWeightsExtra,c=e.numBoneInfluencer,h=n.length;for(let f=0;f<h;f+=4){let d=0,u=-1;for(let E=0;E<4;E++){const _=n[f+E];d+=_,_<.001&&u<0&&(u=E)}if(l)for(let E=0;E<4;E++){const _=l[f+E];d+=_,_<.001&&u<0&&(u=E+4)}if((u<0||u>c-1)&&(u=c-1),d>.001){const E=1/d;for(let _=0;_<4;_++)n[f+_]*=E;if(l)for(let _=0;_<4;_++)l[f+_]*=E}else u>=4?(l[f+u-4]=1-d,a[f+u-4]=s):(n[f+u]=1-d,r[f+u]=s)}t.setVerticesData(g.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(g.MatricesIndicesExtraKind,a)}static Parse(e,t,i){const s=new Ce(e.id,t,void 0,e.updatable);return s._loadedUniqueId=e.uniqueId,De&&De.AddTagsTo(s,e.tags),e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s._boundingInfo=new we(T.FromArray(e.boundingBoxMinimum),T.FromArray(e.boundingBoxMaximum)),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(g.UVKind),e.hasUVs2&&s._delayInfo.push(g.UV2Kind),e.hasUVs3&&s._delayInfo.push(g.UV3Kind),e.hasUVs4&&s._delayInfo.push(g.UV4Kind),e.hasUVs5&&s._delayInfo.push(g.UV5Kind),e.hasUVs6&&s._delayInfo.push(g.UV6Kind),e.hasColors&&s._delayInfo.push(g.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(g.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(g.MatricesWeightsKind),s._delayLoadingFunction=Ae.ImportVertexData):Ae.ImportVertexData(e,s),t.pushGeometry(s,!0),s}}let ta=(()=>{var o;let e=[],t,i,s,r,a,n,l,c,h,f,d,u;return o=class{constructor(){this._func=w(this,e),this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=519,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681,this.backFunc=519,this.backOpStencilFail=7680,this.backOpDepthFail=7680,this.backOpStencilDepthPass=7681}get func(){return this._func}set func(_){this._func=_}get backFunc(){return this._backFunc}set backFunc(_){this._backFunc=_}get funcRef(){return this._funcRef}set funcRef(_){this._funcRef=_}get funcMask(){return this._funcMask}set funcMask(_){this._funcMask=_}get opStencilFail(){return this._opStencilFail}set opStencilFail(_){this._opStencilFail=_}get opDepthFail(){return this._opDepthFail}set opDepthFail(_){this._opDepthFail=_}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(_){this._opStencilDepthPass=_}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(_){this._backOpStencilFail=_}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(_){this._backOpDepthFail=_}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(_){this._backOpStencilDepthPass=_}get mask(){return this._mask}set mask(_){this._mask=_}get enabled(){return this._enabled}set enabled(_){this._enabled=_}getClassName(){return"MaterialStencilState"}copyTo(_){Be.Clone(()=>_,this)}serialize(){return Be.Serialize(this)}parse(_,M,v){Be.Parse(()=>this,_,M,v)}},(()=>{const E=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;t=[H()],i=[H()],s=[H()],r=[H()],a=[H()],n=[H()],l=[H()],c=[H()],h=[H()],f=[H()],d=[H()],u=[H()],k(o,null,t,{kind:"getter",name:"func",static:!1,private:!1,access:{has:_=>"func"in _,get:_=>_.func},metadata:E},null,e),k(o,null,i,{kind:"getter",name:"backFunc",static:!1,private:!1,access:{has:_=>"backFunc"in _,get:_=>_.backFunc},metadata:E},null,e),k(o,null,s,{kind:"getter",name:"funcRef",static:!1,private:!1,access:{has:_=>"funcRef"in _,get:_=>_.funcRef},metadata:E},null,e),k(o,null,r,{kind:"getter",name:"funcMask",static:!1,private:!1,access:{has:_=>"funcMask"in _,get:_=>_.funcMask},metadata:E},null,e),k(o,null,a,{kind:"getter",name:"opStencilFail",static:!1,private:!1,access:{has:_=>"opStencilFail"in _,get:_=>_.opStencilFail},metadata:E},null,e),k(o,null,n,{kind:"getter",name:"opDepthFail",static:!1,private:!1,access:{has:_=>"opDepthFail"in _,get:_=>_.opDepthFail},metadata:E},null,e),k(o,null,l,{kind:"getter",name:"opStencilDepthPass",static:!1,private:!1,access:{has:_=>"opStencilDepthPass"in _,get:_=>_.opStencilDepthPass},metadata:E},null,e),k(o,null,c,{kind:"getter",name:"backOpStencilFail",static:!1,private:!1,access:{has:_=>"backOpStencilFail"in _,get:_=>_.backOpStencilFail},metadata:E},null,e),k(o,null,h,{kind:"getter",name:"backOpDepthFail",static:!1,private:!1,access:{has:_=>"backOpDepthFail"in _,get:_=>_.backOpDepthFail},metadata:E},null,e),k(o,null,f,{kind:"getter",name:"backOpStencilDepthPass",static:!1,private:!1,access:{has:_=>"backOpStencilDepthPass"in _,get:_=>_.backOpStencilDepthPass},metadata:E},null,e),k(o,null,d,{kind:"getter",name:"mask",static:!1,private:!1,access:{has:_=>"mask"in _,get:_=>_.mask},metadata:E},null,e),k(o,null,u,{kind:"getter",name:"enabled",static:!1,private:!1,access:{has:_=>"enabled"in _,get:_=>_.enabled},metadata:E},null,e),E&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:E})})(),o})();class _e{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPri
vendor: 2,145 bytes, line 2
2ority-e.renderPriority}}_e.FALLOFF_DEFAULT=0;_e.FALLOFF_PHYSICAL=1;_e.FALLOFF_GLTF=2;_e.FALLOFF_STANDARD=3;_e.LIGHTMAP_DEFAULT=0;_e.LIGHTMAP_SPECULAR=1;_e.LIGHTMAP_SHADOWSONLY=2;_e.INTENSITYMODE_AUTOMATIC=0;_e.INTENSITYMODE_LUMINOUSPOWER=1;_e.INTENSITYMODE_LUMINOUSINTENSITY=2;_e.INTENSITYMODE_ILLUMINANCE=3;_e.INTENSITYMODE_LUMINANCE=4;_e.LIGHTTYPEID_POINTLIGHT=0;_e.LIGHTTYPEID_DIRECTIONALLIGHT=1;_e.LIGHTTYPEID_SPOTLIGHT=2;_e.LIGHTTYPEID_HEMISPHERICLIGHT=3;_e.LIGHTTYPEID_RECT_AREALIGHT=4;_e.LIGHTTYPEID_CLUSTERED_CONTAINER=5;const Ve=new j,Ye=new j,Ze=new j,ki={getScene:()=>{},eyeAtCamera:!0};function ht(o,e,t){const i=t.asArray(),s=e.asArray();for(let r=0;r<16;r++)i[r]=s[r];return i[12]-=o.x,i[13]-=o.y,i[14]-=o.z,t.markAsUpdated(),t}function ia(o,e,t){return pt(e,Ye),ht(o,Ye,Ze),pt(Ze,t),t}function gt(o,e,t){if(!ki.eyeAtCamera)return ia(o,e,t);const i=t.asArray(),s=e.asArray();for(let r=0;r<16;r++)i[r]=s[r];return i[12]=0,i[13]=0,i[14]=0,t.markAsUpdated(),t}function At(o,e,t,i){return lt(gt(o,e,i),t,i),i}function Ts(o,e,t,i){return pt(t,Ye),lt(e,Ye,Ze),ht(o,Ze,Ye),gt(o,t,Ze),lt(Ye,Ze,i),i}function Cs(o,e,t,i,s,r){return pt(t,Ye),lt(e,Ye,Ze),ht(o,Ze,Ye),At(o,i,s,Ze),lt(Ye,Ze,r),r}function Ps(o,e){const t=ki.getScene();if(!t||Ve===e)return e;Ve.updateFlag=e.updateFlag;const i=t.floatingOriginOffset;switch(o){case"world":return ht(i,e,Ve);case"view":return gt(i,e,Ve);case"worldView":return Ts(i,e,t.getViewMatrix(),Ve);case"viewProjection":return At(i,t.getViewMatrix(),t.getProjectionMatrix(),Ve);case"worldViewProjection":return Cs(i,e,t.getTransformMatrix(),t.getViewMatrix(),t.getProjectionMatrix(),Ve);default:if(o.startsWith("u_")){const s=o.toLowerCase();if(s.startsWith("u_worldviewprojection"))return Cs(i,e,t.getTransformMatrix(),t.getViewMatrix(),t.getProjectionMatrix(),Ve);if(s.startsWith("u_viewprojection"))return At(i,t.getViewMatrix(),t.getProjectionMatrix(),Ve);if(s.startsWith("u_worldview"))return Ts(i,e,t.getViewMatrix(),Ve);if(s.startsWith("u_world"))return ht(i,e,Ve);if(s.startsWith("u_view"))return gt(i,e,Ve)}return e}}const ft=U,bt=Ui,rr=ft.prototype._updateMatrixForUniform,nr=Ui.prototype.setMatr
2ix;function Zo(){Ui.prototype.setMatrix=nr,bt._setMatrixOverride=void 0,ft.prototype._updateMatrixForUniform=rr,ft.prototype._updateMatrixForUniformOverride=void 0}function $o(){bt.prototype._setMatrixOverride=nr,bt.prototype.setMatrix=function(o,e){return this._setMatrixOverride(o,Ps(o,e)),this},ft.prototype._updateMatrixForUniformOverride=rr,ft.prototype._updateMatrixForUniform=function(o,e){this._updateMatrixForUniformOverride(o,Ps(o,e))}}function qo(o){o.indexOf("vClipPlane")===-1&&o.push("vClipPlane"),o.indexOf("vClipPlane2")===-1&&o.push("vClipPlane2"),o.indexOf("vClipPlane3")===-1&&o.push("vClipPlane3"),o.indexOf("vClipPlane4")===-1&&o.push("vClipPlane4"),o.indexOf("vClipPlane5")===-1&&o.push("vClipPlane5"),o.indexOf("vClipPlane6")===-1&&o.push("vClipPlane6")}function jo(o,e,t){const i=!!(o.clipPlane??e.clipPlane),s=!!(o.clipPlane2??e.clipPlane2),r=!!(o.clipPlane3??e.clipPlane3),a=!!(o.clipPlane4??e.clipPlane4),n=!!(o.clipPlane5??e.clipPlane5),l=!!(o.clipPlane6??e.clipPlane6);i&&t.push("#define CLIPPLANE"),s&&t.push("#define CLIPPLANE2"),r&&t.push("#define CLIPPLANE3"),a&&t.push("#define CLIPPLANE4"),n&&t.push("#define CLIPPLANE5"),l&&t.push("#define CLIPPLANE6")}function sa(o,e,t){let i=!1;const s=!!(o.clipPlane??e.clipPlane),r=!!(o.clipPlane2??e.clipPlane2),a=!!(o.clipPlane3??e.clipPlane3),n=!!(o.clipPlane4??e.clipPlane4),l=!!(o.clipPlane5??e.clipPlane5),c=!!(o.clipPlane6??e.clipPlane6);return t.CLIPPLANE!==s&&(t.CLIPPLANE=s,i=!0),t.CLIPPLANE2!==r&&(t.CLIPPLANE2=r,i=!0),t.CLIPPLANE3!==a&&(t.CLIPPLANE3=a,i=!0),t.CLIPPLANE4!==n&&(t.CLIPPLANE4=n,i=!0),t.CLIPPLANE5!==l&&(t.CLIPPLANE5=l,i=!0),t.CLIPPLANE6!==c&&(t.CLIPPLANE6=c,i=!0),i}function Qo(o,e,t){let i=e.clipPlane??t.clipPlane;st(o,"vClipPlane",i),i=e.clipPlane2??t.clipPlane2,st(o,"vClipPlane2",i),i=e.clipPlane3??t.clipPlane3,st(o,"vClipPlane3",i),i=e.clipPlane4??t.clipPlane4,st(o,"vClipPlane4",i),i=e.clipPlane5??t.clipPlane5,st(o,"vClipPlane5",i),i=e.clipPlane6??t.clipPlane6,st(o,"vClipPlane6",i)}function st(o,e,t){if(t){const i=ki.getScene()?.floatingOriginOffset||T.ZeroReadOnly;o.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d+T.Dot(t.normal,i))}}class de{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get BaseWeightTextureEnabled(){return this._BaseWeightTextureEnabled}static set BaseWeightTextureEnabled(e){this._BaseWeightTextureEnabled!==e&&(this._BaseWeightTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get BaseDiffuseRoughnessTextureEnabled(){return this._BaseDiffuseRoughnessTextureEnabled}static set BaseDiffuseRoughnessTextureEnabled(e){this._BaseDiffuseRoughnessTextureEnabled!==e&&(this._BaseDiffuseRoughnessTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,me.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,me.MarkAllMaterialsAsDirty(1))}}de._DiffuseTextureEnabled=!0;de._BaseWeightTextureEnabled=!0;de._BaseDiffuseRoughnessTextureEnabled=!0;de._DetailTextureEnabled=!0;de._DecalMapEnabled=!0;de._AmbientTextureEnabled=!0;de._OpacityTextureEnabled=!0;de._ReflectionTextureEnabled=!0;de._EmissiveTextureEnabled=!0;de._SpecularTextureEnabled=!0;de._BumpTextureEnabled=!0;de._LightmapTextureEnabled=!0;de._RefractionTextureEnabled=!0;de._ColorGradingTextureEnabled=!0;de._FresnelEnabled=!0;de._ClearCoatTextureEnabled=!0;de._ClearCoatBumpTextureEnabled=!0;de._ClearCoatTintTextureEnabled=!0;de._SheenTextureEnabled=!0;de._AnisotropicTextureEnabled=!0;de._ThicknessTextureEnabled=!0;de._RefractionIntensityTextureEnabled=!0;de._TranslucencyIntensityTextureEnabled=!0;de._TranslucencyColorTextureEnabled=!0;de._IridescenceTextureEnabled=!0;function Jo(o,e,t){if(!o||o.LOGARITHMICDEPTH||o.indexOf&&o.indexOf("LOGARITHMICDEPTH")>=0){const i=t.activeCamera;i.mode===1&&fe.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}const ys={r:0,g:0,b:0},Je={NUM_MORPH_INFLUENCERS:0,NORMAL:!1,TANGENT:!1,UV:!1,UV2:!1,COLOR:!1};function el(o,e,t,i=!1){t&&o.fogEnabled&&(!e||e.applyFog)&&o.fogMode!==0&&(t.setFloat4("vFogInfos",o.fogMode,o.fogStart,o.fogEnd,o.fogDensity),i?(o.fogColor.toLinearSpaceToRef(ys,o.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",ys)):t.setColor3("vFogColor",o.fogColor))}function tl(o,e,t,i,s,r,a,n,l,c){const h=o.numMaxInfluencers||o.numInfluencers;return h<=0?0:(e.push("#define MORPHTARGETS"),o.hasPositions&&e.push("#define MORPHTARGETTEXTURE_HASPOSITIONS"),o.hasNormals&&e.push("#define MORPHTARGETTEXTURE_HASNORMALS"),o.hasTangents&&e.push("#define MORPHTARGETTEXTURE_HASTANGENTS"),o.hasUVs&&e.push("#define MORPHTARGETTEXTURE_HASUVS"),o.hasUV2s&&e.push("#define MORPHTARGETTEXTURE_HASUV2S"),o.hasColors&&e.push("#define MORPHTARGETTEXTURE_HASCOLORS"),o.supportsPositions&&s&&e.push("#define MORPHTARGETS_POSITION"),o.supportsNormals&&r&&e.push("#define MORPHTARGETS_NORMAL"),o.supportsTangents&&a&&e.push("#define MORPHTARGETS_TANGENT"),o.supportsUVs&&n&&e.push("#define MORPHTARGETS_
2UV"),o.supportsUV2s&&l&&e.push("#define MORPHTARGETS_UV2"),o.supportsColors&&c&&e.push("#define MORPHTARGETS_COLOR"),e.push("#define NUM_MORPH_INFLUENCERS "+h),o.isUsingTextureForTargets&&e.push("#define MORPHTARGETS_TEXTURE"),Je.NUM_MORPH_INFLUENCERS=h,Je.NORMAL=r,Je.TANGENT=a,Je.UV=n,Je.UV2=l,Je.COLOR=c,ra(t,i,Je,s),h)}function ra(o,e,t,i=!0){const s=t.NUM_MORPH_INFLUENCERS;if(s>0&&ot.LastCreatedEngine){const r=ot.LastCreatedEngine.getCaps().maxVertexAttribs,a=e.morphTargetManager;if(a?.isUsingTextureForTargets)return;const n=a&&a.supportsPositions&&i,l=a&&a.supportsNormals&&t.NORMAL,c=a&&a.supportsTangents&&t.TANGENT,h=a&&a.supportsUVs&&t.UV1,f=a&&a.supportsUV2s&&t.UV2,d=a&&a.supportsColors&&t.VERTEXCOLOR;for(let u=0;u<s;u++)n&&o.push("position"+u),l&&o.push("normal"+u),c&&o.push("tangent"+u),h&&o.push("uv_"+u),f&&o.push("uv2_"+u),d&&o.push("color"+u),o.length>r&&fe.Error("Cannot add more vertex attributes for mesh "+e.name)}}function na(o,e=!1){o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"),e&&(o.push("previousWorld0"),o.push("previousWorld1"),o.push("previousWorld2"),o.push("previousWorld3"))}function il(o,e){const t=o.morphTargetManager;!o||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function aa(o,e){e.bindToEffect(o,"Scene")}function sl(o,e,t,i,s=null,r=!1,a=!1,n=!1,l=!1,c=!1,h=!1,f=0){if(o.texturesEnabled&&s&&de.ReflectionTextureEnabled){if(t.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),t.updateFloat2("vReflectionInfos",s.level*o.iblIntensity,f),n&&s.boundingBoxSize){const d=s;t.updateVector3("vReflectionPosition",d.boundingBoxPosition),t.updateVector3("vReflectionSize",d.boundingBoxSize)}if(r){const d=s.getSize().width;t.updateFloat2("vReflectionFilteringInfo",d,Math.log2(d))}if(c&&!e.USEIRRADIANCEMAP){const d=s.sphericalPolynomial;if(e.USESPHERICALFROMREFLECTIONMAP&&d)if(e.SPHERICAL_HARMONICS){const u=d.preScaledHarmonics;t.updateVector3("vSphericalL00",u.l00),t.updateVector3("vSphericalL1_1",u.l1_1),t.updateVector3("vSphericalL10",u.l10),t.updateVector3("vSphericalL11",u.l11),t.updateVector3("vSphericalL2_2",u.l2_2),t.updateVector3("vSphericalL2_1",u.l2_1),t.updateVector3("vSphericalL20",u.l20),t.updateVector3("vSphericalL21",u.l21),t.updateVector3("vSphericalL22",u.l22)}else t.updateFloat3("vSphericalX",d.x.x,d.x.y,d.x.z),t.updateFloat3("vSphericalY",d.y.x,d.y.y,d.y.z),t.updateFloat3("vSphericalZ",d.z.x,d.z.y,d.z.z),t.updateFloat3("vSphericalXX_ZZ",d.xx.x-d.zz.x,d.xx.y-d.zz.y,d.xx.z-d.zz.z),t.updateFloat3("vSphericalYY_ZZ",d.yy.x-d.zz.x,d.yy.y-d.zz.y,d.yy.z-d.zz.z),t.updateFloat3("vSphericalZZ",d.zz.x,d.zz.y,d.zz.z),t.updateFloat3("vSphericalXY",d.xy.x,d.xy.y,d.xy.z),t.updateFloat3("vSphericalYZ",d.yz.x,d.yz.y,d.yz.z),t.updateFloat3("vSphericalZX",d.zx.x,d.zx.y,d.zx.z)}else l&&e.USEIRRADIANCEMAP&&e.USE_IRRADIANCE_DOMINANT_DIRECTION&&s.irradianceTexture&&t.updateVector3("vReflectionDominantDirection",s.irradianceTexture._dominantDirection);a&&t.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset)}h&&t.updateColor3("vReflectionColor",i)}function rl(o,e,t){e._needUVs=!0,e[t]=!0,o.optimizeUVAllocation&&o.getTextureMatrix().isIdentityAs3x2()?(e[t+"DIRECTUV"]=o.coordinatesIndex+1,e["MAINUV"+(o.coordinatesIndex+1)]=!0):e[t+"DIRECTUV"]=0}function nl(o,e,t){const i=o.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function al(o,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&o.push("bakedVertexAnimationSettingsInstanced")}function ol(o,e,t){if(!(!e||!o)&&(o.computeBonesUsingShaders&&e._bonesComputationForcedToCPU&&(o.computeBonesUsingShaders=!1),o.useBones&&o.computeBonesUsingShaders&&o.skeleton)){const i=o.skeleton;if(i.isUsingTextureForMatrices&&e.getUniformIndex("boneTextureInfo")>-1){const s=i.getTransformMatrixTexture(o);e.setTexture("boneSampler",s),e.setFloat2("boneTextureInfo",i._textureWidth,i._textureHeight)}else{const s=i.getTransformMatrices(o);s&&e.setMatrices("mBones",s)}}}function oa(o,e,t,i,s,r=!0){o._bindLight(e,t,i,s,r)}function ll(o,e,t,i,s=4){const r=Math.min(e.lightSources.length,s);for(let a=0;a<r;a++){const n=e.lightSources[a];oa(n,a,o,t,typeof i=="boolean"?i:i.SPECULARTERM,e.receiveShadows)}}function cl(o,e,t,i){t.NUM_BONE_INFLUENCERS>0&&(i.addCPUSkinningFallback(0,e),o.push("matricesIndices"),o.push("matricesWeights"),t.NUM_BONE_INFLUENCERS>4&&(o.push("matricesIndicesExtra"),o.push("matricesWeightsExtra")))}function hl(o,e){(e.INSTANCES||e.THIN_INSTANCES)&&na(o,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&o.push("instanceColor")}function fl(o,e,t=4,i=0){let s=0;for(let r=0;r<t&&o["LIGHT"+r];r++)r>0&&(s=i+r,e.addFallback(s,"LIGHT"+r)),o.SHADOWS||(o["SHADOW"+r]&&e.addFallback(i,"SHADOW"+r),o["SHADOWPCF"+r]&&e.addFallback(i,"SHADOWPCF"+r),o["SHADOWPCSS"+r]&&e.addFallback(i,"SHADOWPCSS"+r),o["SHADOWPOISSON"+r]&&e.addFallback(i,"SHADOWPOISSON"+r),o["SHADOWESM"+r]&&e.addFallback(i,"SHADOWESM"+r),o["SHADOWCLOSEESM"+r]&&e.addFallback(i,"SHADOWCLOSEESM"+r));return s}function la(o,e){return e.fogEnabled&&o.applyFog&&e.fogMode!==0}function dl(o,e,t,i,s,r,a,n=!1,l=!1,c,h){if(a._areMiscDirty){a.LOGARITHMICDEPTH=t,a.POINTSIZE=i,a.FOG=s&&la(o,e),a.NONUNIFORMSCALING=o.nonUniformScaling,a.ALPHATEST=r,a.DECAL_AFTER_DETAIL=n,a.USE_VERTEX_PULLING=l,a.RIGHT_HANDED=e.useRightHandedSystem;const f=c?.geometry?.getIndexBuffer(),d=c?c.isUnIndexed:!1;a.VERTEX_PULLING_USE_INDEX_BUFFER=!!f&&!d,a.VERTEX_PULLING_INDEX_BUFFER_32BITS=f&&!d?f.is32Bits:!1,a.VERTEXOUTPUT_INVARIANT=!!h}}function ul(o,e,t,i=!1){if(!o.lightsEnabled||i)return!0;const s=e.lightSources,r=Math.min(s.length,t);for(let a=0;a<r;a++)if(!s[a].areLightTexturesReady())return!1;return!0}
2function ml(o,e,t,i,s=4,r=!1){if(!t._areLightsDirty)return t._needNormals;let a=0;const n={needNormals:t._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(o.lightsEnabled&&!r){for(const h of e.lightSources)if(ca(o,e,h,a,t,i,n),a++,a===s)break}t.SPECULARTERM=n.specularEnabled,t.SHADOWS=n.shadowEnabled;const l=Math.max(s,t.MAXLIGHTCOUNT||0);for(let h=a;h<l;h++)t["LIGHT"+h]!==void 0&&(t["LIGHT"+h]=!1,t["HEMILIGHT"+h]=!1,t["POINTLIGHT"+h]=!1,t["DIRLIGHT"+h]=!1,t["SPOTLIGHT"+h]=!1,t["AREALIGHT"+h]=!1,t["CLUSTLIGHT"+h]=!1,t["SHADOW"+h]=!1,t["SHADOWCSM"+h]=!1,t["SHADOWCSMDEBUG"+h]=!1,t["SHADOWCSMNUM_CASCADES"+h]=!1,t["SHADOWCSMUSESHADOWMAXZ"+h]=!1,t["SHADOWCSMNOBLEND"+h]=!1,t["SHADOWCSM_RIGHTHANDED"+h]=!1,t["SHADOWPCF"+h]=!1,t["SHADOWPCSS"+h]=!1,t["SHADOWPOISSON"+h]=!1,t["SHADOWESM"+h]=!1,t["SHADOWCLOSEESM"+h]=!1,t["SHADOWCUBE"+h]=!1,t["SHADOWLOWQUALITY"+h]=!1,t["SHADOWMEDIUMQUALITY"+h]=!1);t.LIGHTCOUNT=a,t.MAXLIGHTCOUNT=s;const c=o.getEngine().getCaps();return t.SHADOWFLOAT===void 0&&(n.needRebuild=!0),t.SHADOWFLOAT=n.shadowEnabled&&(c.textureFloatRender&&c.textureFloatLinearFiltering||c.textureHalfFloatRender&&c.textureHalfFloatLinearFiltering),t.LIGHTMAPEXCLUDED=n.lightmapMode,n.needRebuild&&t.rebuild(),n.needNormals}function pl(o,e,t,i=!1,s=8,r=!1){if(e&&de.ReflectionTextureEnabled){if(!e.isReadyOrNotBlocking())return!1;t._needNormals=!0,t.REFLECTION=!0,t.GAMMAREFLECTION=e.gammaSpace,t.RGBDREFLECTION=e.isRGBD,t.LODINREFLECTIONALPHA=e.lodLevelInAlpha,t.LINEARSPECULARREFLECTION=e.linearSpecularLOD,t.USEIRRADIANCEMAP=!1,t.LODBASEDMICROSFURACE=o.getEngine().getCaps().textureLOD;const a=o.getEngine();switch(i&&s>0?(t.NUM_SAMPLES=""+s,a._features.needTypeSuffixInShaderConstants&&(t.NUM_SAMPLES=t.NUM_SAMPLES+"u"),t.REALTIME_FILTERING=!0,o.iblCdfGenerator&&(t.IBL_CDF_FILTERING=!0)):t.REALTIME_FILTERING=!1,t.INVERTCUBICMAP=e.coordinatesMode===6,t.REFLECTIONMAP_3D=e.isCube,t.REFLECTIONMAP_OPPOSITEZ=t.REFLECTIONMAP_3D&&o.useRightHandedSystem?!e.invertZ:e.invertZ,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.coordinatesMode){case 0:t.REFLECTIONMAP_EXPLICIT=!0;break;case 2:t.REFLECTIONMAP_PLANAR=!0;break;case 4:t.REFLECTIONMAP_PROJECTION=!0;break;case 5:t.REFLECTIONMAP_SKYBOX=!0;break;case 1:t.REFLECTIONMAP_SPHERICAL=!0;break;case 7:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case 8:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case 9:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case 3:case 6:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!e.boundingBoxSize;break}e.coordinatesMode!==5&&(e.irradianceTexture?(t.USEIRRADIANCEMAP=!0,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,e.irradianceTexture._dominantDirection?t.USE_IRRADIANCE_DOMINANT_DIRECTION=!0:t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1):e.isCube&&(t.USESPHERICALFROMREFLECTIONMAP=!0,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=r))}else t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1;return!0}function ca(o,e,t,i,s,r,a){switch(a.needNormals=!0,s["LIGHT"+i]===void 0&&(a.needRebuild=!0),s["LIGHT"+i]=!0,s["SPOTLIGHT"+i]=!1,s["HEMILIGHT"+i]=!1,s["POINTLIGHT"+i]=!1,s["DIRLIGHT"+i]=!1,s["AREALIGHT"+i]=!1,s["CLUSTLIGHT"+i]=!1,t.prepareLightSpecificDefines(s,i),s["LIGHT_FALLOFF_PHYSICAL"+i]=!1,s["LIGHT_FALLOFF_GLTF"+i]=!1,s["LIGHT_FALLOFF_STANDARD"+i]=!1,t.falloffType){case _e.FALLOFF_GLTF:s["LIGHT_FALLOFF_GLTF"+i]=!0;break;case _e.FALLOFF_PHYSICAL:s["LIGHT_FALLOFF_PHYSICAL"+i]=!0;break;case _e.FALLOFF_STANDARD:s["LIGHT_FALLOFF_STANDARD"+i]=!0;break}if(t.specular.equalsFloats(0,0,0)||(a.specularEnabled=!0),s["SHADOW"+i]=!1,s["SHADOWCSM"+i]=!1,s["SHADOWCSMDEBUG"+i]=!1,s["SHADOWCSMNUM_CASCADES"+i]=!1,s["SHADOWCSMUSESHADOWMAXZ"+i]=!1,s["SHADOWCSMNOBLEND"+i]=!1,s["SHADOWCSM_RIGHTHANDED"+i]=!1,s["SHADOWPCF"+i]=!1,s["SHADOWPCSS"+i]=!1,s["SHADOWPOISSON"+i]=!1,s["SHADOWESM"+i]=!1,s["SHADOWCLOSEESM"+i]=!1,s["SHADOWCUBE"+i]=!1,s["SHADOWLOWQUALITY"+i]=!1,s["SHADOWMEDIUMQUALITY"+i]=!1,e&&e.receiveShadows&&o.shadowsEnabled&&t.shadowEnabled){const n=t.getShadowGenerator(o.activeCamera)??t.getShadowGenerator();if(n){const l=n.getShadowMap();l&&l.renderList&&l.renderList.length>0&&(a.shadowEnabled=!0,n.prepareDefines(s,i))}}t.lightmapMode!=_e.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,s["LIGHTMAPEXCLUDED"+i]=!0,s["LIGHTMAPNOSPECULAR"
2+i]=t.lightmapMode==_e.LIGHTMAP_SHADOWSONLY):(s["LIGHTMAPEXCLUDED"+i]=!1,s["LIGHTMAPNOSPECULAR"+i]=!1)}function gl(o,e,t,i,s,r=null,a=!1){let n=pa(o,i);r!==!1&&(n=sa(t,o,i)),i.DEPTHPREPASS!==!e.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,n=!0),i.INSTANCES!==s&&(i.INSTANCES=s,n=!0),i.THIN_INSTANCES!==a&&(i.THIN_INSTANCES=a,n=!0),n&&i.markAsUnprocessed()}const ha=40,fa=64,Rs=new WeakMap,Ls=new WeakSet;function da(o,e){if(o.useBones&&o.computeBonesUsingShaders&&o.skeleton){e.NUM_BONE_INFLUENCERS=o.numBoneInfluencers;const t=e.BONETEXTURE!==void 0;if(o.skeleton.isUsingTextureForMatrices&&t)e.BONETEXTURE=!0;else{e.BonesPerMesh=o.skeleton.bones.length+1,e.BONETEXTURE=t?!1:void 0;const i=o.getScene(),s=i.prePassRenderer;if(s&&s.enabled){const n=s.excludedSkinnedMesh.indexOf(o)===-1;e.BONES_VELOCITY_ENABLED=n}const r=e.MULTIVIEW===!0,a=e.BonesPerMesh*2+(r?1:0);if(Rs.get(o.skeleton)!==a){Rs.set(o.skeleton,a);const n=i.getEngine().getCaps().maxVertexUniformVectors;if(n&&!Ls.has(o.skeleton)){const l=e.BonesPerMesh*4,h=Math.max(n-(r?fa:ha),0);(l>h||r&&l*3>n)&&(Ls.add(o.skeleton),fe.Warn(`Skeleton "${o.skeleton.name}": ${o.skeleton.bones.length} bones stored as vertex uniforms use ${l} of ~${h} usable uniform vectors${r?" (multiview)":""} on a device reporting ${n}. This can exceed the GPU vertex-uniform limit and make the mesh silently fail to render. Set skeleton.useTextureToStoreBoneMatrices = true to store bone matrices in a texture.`))}}}}else e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE!==void 0&&(e.BONETEXTURE=!1)}function ua(o,e){const t=o.morphTargetManager;t?(e.MORPHTARGETS_UV=t.supportsUVs&&e.UV1,e.MORPHTARGETS_UV2=t.supportsUV2s&&e.UV2,e.MORPHTARGETS_TANGENT=t.supportsTangents&&e.TANGENT,e.MORPHTARGETS_NORMAL=t.supportsNormals&&e.NORMAL,e.MORPHTARGETS_POSITION=t.supportsPositions,e.MORPHTARGETS_COLOR=t.supportsColors,e.MORPHTARGETTEXTURE_HASUVS=t.hasUVs,e.MORPHTARGETTEXTURE_HASUV2S=t.hasUV2s,e.MORPHTARGETTEXTURE_HASTANGENTS=t.hasTangents,e.MORPHTARGETTEXTURE_HASNORMALS=t.hasNormals,e.MORPHTARGETTEXTURE_HASPOSITIONS=t.hasPositions,e.MORPHTARGETTEXTURE_HASCOLORS=t.hasColors,e.NUM_MORPH_INFLUENCERS=t.numMaxInfluencers||t.numInfluencers,e.MORPHTARGETS=e.NUM_MORPH_INFLUENCERS>0,e.MORPHTARGETS_TEXTURE=t.isUsingTextureForTargets):(e.MORPHTARGETS_UV=!1,e.MORPHTARGETS_UV2=!1,e.MORPHTARGETS_TANGENT=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_POSITION=!1,e.MORPHTARGETS_COLOR=!1,e.MORPHTARGETTEXTURE_HASUVS=!1,e.MORPHTARGETTEXTURE_HASUV2S=!1,e.MORPHTARGETTEXTURE_HASTANGENTS=!1,e.MORPHTARGETTEXTURE_HASNORMALS=!1,e.MORPHTARGETTEXTURE_HASPOSITIONS=!1,e.MORPHTARGETTEXTURE_HAS_COLORS=!1,e.MORPHTARGETS=!1,e.NUM_MORPH_INFLUENCERS=0)}function ma(o,e){const t=o.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function _l(o,e,t,i,s=!1,r=!0,a=!0){if(!e._areAttributesDirty&&e._needNormals===e._normals&&e._needUVs===e._uvs)return!1;e._normals=e._needNormals,e._uvs=e._needUVs,e.NORMAL=e._needNormals&&o.isVerticesDataPresent("normal"),e._needNormals&&o.isVerticesDataPresent("tangent")&&(e.TANGENT=!0);for(let n=1;n<=6;++n)e["UV"+n]=e._needUVs?o.isVerticesDataPresent(`uv${n===1?"":n}`):!1;if(t){const n=o.useVertexColors&&o.isVerticesDataPresent("color");e.VERTEXCOLOR=n,e.VERTEXALPHA=o.hasVertexAlpha&&n&&r}return o.isVerticesDataPresent("instanceColor")&&(o.hasInstances||o.hasThinInstances)&&(e.INSTANCESCOLOR=!0),i&&da(o,e),s&&ua(o,e),a&&ma(o,e),!0}function vl(o,e){if(o.activeCamera){const t=e.MULTIVIEW;e.MULTIVIEW=o.activeCamera.outputRenderTarget!==null&&o.activeCamera.outputRenderTarget.getViewCount()>1,e.MULTIVIEW!=t&&e.markAsUnprocessed()}}function Il(o,e,t){const i=e.ORDER_INDEPENDENT_TRANSPARENCY,s=e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;e.ORDER_INDEPENDENT_TRANSPARENCY=o.useOrderIndependentTransparency&&t,e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!o.getEngine().getCaps().textureFloatLinearFiltering,(i!==e.ORDER_INDEPENDENT_TRANSPARENCY||s!==e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS)&&e.markAsUnprocessed()}function Sl(o,e,t){const i=e.PREPASS;if(!e._arePrePassDirty)return;const s=[{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_LEGACY",index:"PREPASS_IRRADIANCE_LEGACY_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"},{type:14,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"}];if(o.prePassRenderer&&o.prePassRenderer.enabled&&t){e.PREPASS=!0,e.SCENE_MRT_COUNT=o.prePassRenderer.mrtCount,e.PREPASS_NORMAL_WORLDSPACE=o.prePassRenderer.generateNormalsInWorldSpace,e.PREPASS_COLOR=!0,e.PREPASS_COLOR_INDEX=0;for(let r=0;r<s.length;r++){const a=o.prePassRenderer.getIndex(s[r].type);a!==-1?(e[s[r].define]=!0,e[s[r].index]=a):e[s[r].define]=!1}}else{e.PREPASS=!1;for(let r=0;r<s.length;r++)e[s[r].define]=!1}e.PREPASS!=i&&(e.markAsUnprocessed(),e.markAsImageProcessingDirty())}function pa(o,e){let t=!1;if(o.activeCamera){const i=e.CAMERA_ORTHOGRAPHIC?1:0,s=e.CAMERA_PERSPECTIVE?1:0,r=o.activeCamera.mode===1?1:0,a=o.activeCamera.mode===0?1:0;(i^r||s^a)&&(e.CAMERA_ORTHOGRAPHIC=r===1,e.CAMERA_PERSPECTIVE=a===1,t=!0)}return t}function ga(o,e,t,i,s=null,r=!1,a=!1,n=!1,l=!1,c=!1){s&&s.push("Light"+o),!r&&(e.push("vLightData"+o,"vLightDiffuse"+o,"vLightSpecular"+o,"vLightDirection"+o,"vLightWidth"+o,"vLightHeight"+o,"vLightFalloff"+o,"vLightGround"+o,"vSliceData"+o,"vSliceRanges"+o,"lightMatrix"+o,"shadowsInfo"+o,"depthValues"+o),t.push("shadowTexture"+o),t.push("depthTexture"+o),e.push("viewFrustumZ"+o,"cascadeBlendFactor"+o,"lightSizeUVCorrection"+o,"depthCorrection"+o,"penumbraDarkness"+o,"frustumLengths"+o),i&&(t.push("projectionLightTexture"+o),e.push("textureProjectionMatrix"+o)),a&&t.push("iesLightTexture"+o),l&&t.push("rectAreaLightEmissionTexture"+o),n&&(t.push("lightDataTexture"+o),c||t.pu
2sh("tileMaskTexture"+o)))}function El(o,e,t){const i=["vReflectionMicrosurfaceInfos","vReflectionDominantDirection","reflectionMatrix","vReflectionInfos","vReflectionPosition","vReflectionSize","vReflectionColor","vReflectionFilteringInfo"];o.push(...i);const s=["reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","icdfSampler"];e.push(...s)}function Ml(o,e,t,i=4){let s,r,a=null;if(o.uniformsNames){const n=o;s=n.uniformsNames,r=n.uniformBuffersNames,e=n.samplers,t=n.defines,i=n.maxSimultaneousLights||0,a=n.shaderLanguage??null}else s=o,e||(e=[]);for(let n=0;n<i&&t["LIGHT"+n];n++)ga(n,s,e,t["PROJECTEDLIGHTTEXTURE"+n],r,!1,t["IESLIGHTTEXTURE"+n],t["CLUSTLIGHT"+n],t["RECTAREALIGHTEMISSIONTEXTURE"+n],a===1);t.NUM_MORPH_INFLUENCERS&&(s.push("morphTargetInfluences"),s.push("morphTargetCount")),t.BAKED_VERTEX_ANIMATION_TEXTURE&&(s.push("bakedVertexAnimationSettings"),s.push("bakedVertexAnimationTextureSizeInverted"),s.push("bakedVertexAnimationTime"),e.push("bakedVertexAnimationTexture"))}function xl(o,e=!1,t=!1,i=!1,s=!1,r=!1){o.addUniform("vReflectionInfos",2),o.addUniform("reflectionMatrix",16),e&&o.addUniform("vReflectionMicrosurfaceInfos",3),t&&(o.addUniform("vReflectionPosition",3),o.addUniform("vReflectionSize",3)),i&&(o.addUniform("vReflectionFilteringInfo",2),o.addUniform("vReflectionDominantDirection",3)),r&&o.addUniform("vReflectionColor",3),s&&(o.addUniform("vSphericalL00",3),o.addUniform("vSphericalL1_1",3),o.addUniform("vSphericalL10",3),o.addUniform("vSphericalL11",3),o.addUniform("vSphericalL2_2",3),o.addUniform("vSphericalL2_1",3),o.addUniform("vSphericalL20",3),o.addUniform("vSphericalL21",3),o.addUniform("vSphericalL22",3),o.addUniform("vSphericalX",3),o.addUniform("vSphericalY",3),o.addUniform("vSphericalZ",3),o.addUniform("vSphericalXX_ZZ",3),o.addUniform("vSphericalYY_ZZ",3),o.addUniform("vSphericalZZ",3),o.addUniform("vSphericalXY",3),o.addUniform("vSphericalYZ",3),o.addUniform("vSphericalZX",3))}let Te=(()=>{var o;let e=[],t,i=[],s=[],r,a=[],n=[],l,c=[],h=[],f,d=[],u=[],E,_=[],M=[],v,S=[],m=[],b,x=[],A=[],C,B=[],O=[],P,Z=[],Y=[],W,I=[],R=[],z,V=[],q=[],ee,Q=[],te=[],J,se=[],re=[],xe,We=[],Fe=[],pe,he=[],D=[],F,K=[],ae=[],ue,Se=[],Oe=[],dt,ut=[],ke=[],Xe,ze=[],He=[],Xi,zi=[],Hi=[],Gi,Ki=[],Yi=[],Zi,$i=[],qi=[],ji,Qi=[],Ji=[],es,ts=[],is=[],ss,rs,ns,as,os=[],ls=[],cs;return o=class{get useVertexPulling(){return this._useVertexPulling}set useVertexPulling(p){this._useVertexPulling!==p&&(this._useVertexPulling=p,this.markAsDirty(o.MiscDirtyFlag))}get _supportGlowLayer(){return!1}set _glowModeEnabled(p){}get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(p){if(this._alpha===p)return;const L=this._alpha;this._alpha=p,(L===1||p===1)&&this.markAsDirty(o.MiscDirtyFlag+o.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(p){this._backFaceCulling!==p&&(this._backFaceCulling=p,this.markAsDirty(o.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set textureRepetitionMode(p){const L=Math.max(0,Math.min(p|0,4));this._textureRepetitionMode!==L&&(this._textureRepetitionMode=L,this.markAsDirty(o.TextureDirtyFlag))}get textureRepetitionMode(){return this._textureRepetitionMode}set cullBackFaces(p){this._cullBackFaces!==p&&(this._cullBackFaces=p,this.markAsDirty(o.TextureDirtyFlag))}get cullBackFaces(){return this._cullBackFaces}get blockDirtyMechanism(){return this._blockDirtyMechanism}set blockDirtyMechanism(p){this._blockDirtyMechanism!==p&&(this._blockDirtyMechanism=p,p||this.markDirty())}atomicMaterialsUpdate(p){this.blockDirtyMechanism=!0;try{p(this)}finally{this.blockDirtyMechanism=!1}}get hasRenderTargetTextures(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures}set onDispose(p){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(p)}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new ge),this._onBindObservable}set onBind(p){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(p)}get onUnBindObservable(){return this._onUnBindObservable||(this._onUnBindObservable=new ge),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new ge),this._onEffectCreatedObservable}set alphaMode(p){this._alphaMode[0]!==p&&(this._alphaMode[0]=p,this.markAsDirty(o.TextureDirtyFlag))}get alphaMode(){return this._alphaMode[0]}get alphaModes(){return this._alphaMode}setAlphaMode(p,L=0){this._alphaMode[L]!==p&&(this._alphaMode[L]=p,this.markAsDirty(o.TextureDirtyFlag))}set needDepthPrePass(p){this._needDepthPrePass!==p&&(this._needDepthPrePass=p,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(p){this._fogEnabled!==p&&(this._fogEnabled=p,this.markAsDirty(o.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case o.WireFrameFillMode:case o.LineListDrawMode:case o.LineLoopDrawMode:case o.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(p){this.fillMode=p?o.WireFrameFillMode:o.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case o.PointFillMode:case o.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(p){this.fillMode=p?o.PointFillMode:o.TriangleFillMode}get fillMode(){return this._fillMode}
vendor: 5,427 bytes, line 2
2set fillMode(p){this._fillMode!==p&&(this._fillMode=p,this.markAsDirty(o.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(p){const L=this.getScene().getEngine().getCaps().fragmentDepthSupported;p&&!L&&fe.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=p&&L,this._markAllSubMeshesAsMiscDirty()}get isVertexOutputInvariant(){return this._isVertexOutputInvariant}set isVertexOutputInvariant(p){this._isVertexOutputInvariant!==p&&(this._isVertexOutputInvariant=p,this._markAllSubMeshesAsMiscDirty())}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(p){this._drawWrapper=p}constructor(p,L,oe,ie=!1){this.customShaderNameResolve=w(this,e),this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this._useVertexPulling=!1,this.id=w(this,i,void 0),this.uniqueId=(w(this,s),w(this,a,void 0)),this._loadedUniqueId=w(this,n),this.name=w(this,c,void 0),this.metadata=(w(this,h),w(this,d,null)),this._internalMetadata=w(this,u),this.reservedDataStore=null,this.checkReadyOnEveryCall=w(this,_,!1),this.checkReadyOnlyOnce=(w(this,M),w(this,S,!1)),this.state=(w(this,m),w(this,x,"")),this._alpha=(w(this,A),w(this,B,1)),this.inspectableCustomProperties=w(this,O),this._backFaceCulling=w(this,Z,!0),this._textureRepetitionMode=(w(this,Y),w(this,I,0)),this.textureRepetitionHexTilingParams=(w(this,R),w(this,V,[1,.6,7,.5])),this._cullBackFaces=(w(this,q),w(this,Q,!0)),this._blockDirtyMechanism=(w(this,te),!1),this.sideOrientation=w(this,se,null),this.onCompiled=(w(this,re),null),this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new ge,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=w(this,We,[2]),this._needDepthPrePass=(w(this,Fe),w(this,he,!1)),this.disableDepthWrite=(w(this,D),w(this,K,!1)),this.disableColorWrite=(w(this,ae),w(this,Se,!1)),this.forceDepthWrite=(w(this,Oe),w(this,ut,!1)),this.depthFunction=(w(this,ke),w(this,ze,0)),this.separateCullingPass=(w(this,He),w(this,zi,!1)),this._fogEnabled=(w(this,Hi),w(this,Ki,!0)),this.pointSize=(w(this,Yi),w(this,$i,1)),this.zOffset=(w(this,qi),w(this,Qi,0)),this.zOffsetUnits=(w(this,Ji),w(this,ts,0)),this.clipPlane=w(this,is),this.stencil=new ta,this._isVertexOutputInvariant=w(this,os,o.ForceVertexOutputInvariant),this._materialContext=w(this,ls),this._useUBO=!1,this._fillMode=o.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._transparencyMode=null,this.name=p;const ne=L||ot.LastCreatedScene;ne&&(this._scene=ne,this._dirtyCallbacks={},this._forceGLSL=ie,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[127]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=p||at.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new js(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new U(this._scene.getEngine(),void 0,void 0,p),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,this._createUniformBuffer(),oe||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),o.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){const p=this.getScene().getEngine();this._uniformBuffer?.dispose(),p.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new U(p,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new U(this._scene.getEngine(),void 0,void 0,this.name),this._uniformBufferLayoutBuilt=!1}toString(p){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(p,L){return!0}isReadyForSubMesh(p,L,oe){const ie=L.materialDefines;return ie?(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=ie,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh):!1}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(p){return this.sideOrientation!==null?this.sideOrientation:p.sideOrientation}get transparencyMode(){return this._transparencyMode}
vendor: 10,509 bytes, line 2
2set transparencyMode(p){this._transparencyMode!==p&&(this._transparencyMode=p,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _hasTransparencyMode(){return this._transparencyMode!=null}get _transparencyModeIsBlend(){return this._transparencyMode===o.MATERIAL_ALPHABLEND||this._transparencyMode===o.MATERIAL_ALPHATESTANDBLEND}get _transparencyModeIsTest(){return this._transparencyMode===o.MATERIAL_ALPHATEST||this._transparencyMode===o.MATERIAL_ALPHATESTANDBLEND}get _disableAlphaBlending(){return this._transparencyMode===o.MATERIAL_OPAQUE||this._transparencyMode===o.MATERIAL_ALPHATEST}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1}needAlphaBlendingForMesh(p){return this._hasTransparencyMode?this._transparencyModeIsBlend:p.visibility<1?!0:this._disableAlphaBlending?!1:p.hasVertexAlpha||this.needAlphaBlending()}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:!1}needAlphaTestingForMesh(p){return this._hasTransparencyMode?this._transparencyModeIsTest:!this.needAlphaBlendingForMesh(p)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(p=!1){const L=this.getScene().meshes;for(const oe of L)if(oe.subMeshes){for(const ie of oe.subMeshes)if(ie.getMaterial()===this)for(const ne of ie._drawWrappers)ne&&this._materialContext===ne.materialContext&&(ne._wasPreviouslyReady=!1,ne._wasPreviouslyUsingInstances=null,ne._forceRebindOnNextCall=p)}p&&this.markAsDirty(o.AllDirtyFlag)}_preBind(p,L=null){const oe=this._scene.getEngine(),ne=(L??this.sideOrientation)===o.ClockWiseSideOrientation,ve=p||this._getDrawWrapper();return Fn(ve)&&ve.materialContext&&(ve.materialContext.useVertexPulling=this.useVertexPulling),oe.enableEffect(ve),oe.setState(this.backFaceCulling,this.zOffset,!1,ne,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),ne}bind(p,L){}buildUniformLayout(){const p=this._uniformBuffer;this._eventInfo.ubo=p,this._callbackPluginEventGeneric(8,this._eventInfo),p.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(p,L,oe){const ie=oe._drawWrapper;this._eventInfo.subMesh=oe,this._callbackPluginEventBindForSubMesh(this._eventInfo),ie._forceRebindOnNextCall=!1}bindOnlyWorldMatrix(p){}bindView(p){this._useUBO?this._needToBindSceneUbo=!0:p.setMatrix("view",this.getScene().getViewMatrix())}bindViewProjection(p){this._useUBO?this._needToBindSceneUbo=!0:(p.setMatrix("viewProjection",this.getScene().getTransformMatrix()),p.setMatrix("projection",this.getScene().getProjectionMatrix()),p.setMatrix("inverseProjection",this.getScene().getInverseProjectionMatrix()))}bindEyePosition(p,L){this._useUBO?this._needToBindSceneUbo=!0:this._scene.bindEyePosition(p,L)}_afterBind(p,L=null,oe){if(this._scene._cachedMaterial=this,this._needToBindSceneUbo&&L&&(this._needToBindSceneUbo=!1,aa(L,this.getScene().getSceneUniformBuffer()),this._scene.finalizeSceneUbo()),p?this._scene._cachedVisibility=p.visibility:this._scene._cachedVisibility=1,this._onBindObservable&&p&&this._onBindObservable.notifyObservers(p),this.disableDepthWrite){const ie=this._scene.getEngine();this._cachedDepthWriteState=ie.getDepthWrite(),ie.setDepthWrite(!1)}if(this.disableColorWrite){const ie=this._scene.getEngine();this._cachedColorWriteState=ie.getColorWrite(),ie.setColorWrite(!1)}if(this.depthFunction!==0){const ie=this._scene.getEngine();this._cachedDepthFunctionState=ie.getDepthFunction()||0,ie.setDepthFunction(this.depthFunction)}}unbind(){this._scene.getSceneUniformBuffer().unbindEffect(),this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.depthFunction!==0&&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(p){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=p,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(p){return null}_clonePlugins(p,L){const oe={};if(this._serializePlugins(oe),o._ParsePlugins(oe,p,this._scene,L),this.pluginManager)for(const ie of this.pluginManager._plugins){const ne=p.pluginManager.getPlugin(ie.name);ne&&ie.copyTo(ne)}}getBindedMeshes(){if(this.meshMap){const p=[];for(const L in this.meshMap){const oe=this.meshMap[L];oe&&p.push(oe)}return p}else return this._scene.meshes.filter(L=>L.material===this)}forceCompilation(p,L,oe,ie){const ne={clipPlane:!1,useInstances:!1,...oe},ve=this.getScene(),ye=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;const je=()=>{if(!this._scene||!this._scene.getEngine())return;const An=ve.clipPlane;if(ne.clipPlane&&(ve.clipPlane=new Js(0,0,0,1)),this._storeEffectOnSubMeshes){let hs=!0,It=null;if(p.subMeshes){const Qe=new Ne(0,0,0,0,0,p,void 0,!1,!1);Qe.materialDefines&&(Qe.materialDefines._renderId=-1),this.isReadyForSubMesh(p,Qe,ne.useInstances)||(Qe.effect&&Qe.effect.getCompilationError()&&Qe.effect.allFallbacksProcessed()?It=Qe.effect.getCompilationError():(hs=!1,setTimeout(je,16)))}hs&&(this.allowShaderHotSwapping=ye,It&&ie&&ie(It),L&&L(this))}else this.isReady()?(this.allowShaderHotSwapping=ye,L&&L(this)):setTimeout(je,16);ne.clipPlane&&(ve.clipPlane=An)};je()}async forceCompilationAsync(p,L){return await new Promise((oe,ie)=>{this.forceCompilation(p,()=>{oe()},L,ne=>{ie(ne)})})}markAsDirty(p){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(o._DirtyCallbackArray.length=0,p&o.ImageProcessingDirtyFlag&&o._DirtyCallbackArray.push(o._ImageProcessingDirtyCallBack),p&o.TextureDirtyFlag&&o._DirtyCallbackArray.push(o._TextureDirtyCallBack),p&o.LightDirtyFlag&&o._DirtyCallbackArray.push(o._LightsDirtyCallBack),p&o.FresnelDirtyFlag&&o._DirtyCallbackArray.push(o._FresnelDirtyCallBack),p&o.AttributesDirtyFlag&&o._DirtyCallbackArray.push(o._AttributeDirtyCallBack),p&o.MiscDirtyFlag&&o._DirtyCallbackArray.push(o._MiscDirtyCallBack),p&o.PrePassDirtyFlag&&o._DirtyCallbackArray.push(o._PrePassDirtyCallBack),o._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(o._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){const p=this.getScene().meshes;for(const L of p)if(L.subMeshes)for(const oe of L.subMeshes)oe.getMaterial()===this&&oe.resetDrawCache()}_markAllSubMeshesAsDirty(p){const L=this.getScene();if(L.blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const oe=L.meshes;for(const ie of oe)if(ie.subMeshes){for(const ne of ie.subMeshes)if((ne.getMaterial()||(L._hasDefaultMaterial?L.defaultMaterial:null))===this)for(const ye of ne._drawWrappers)!ye||!ye.defines||!ye.defines.markAllAsDirty||this._materialContext===ye.materialContext&&p(ye.defines)}}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const p=this.getScene().enablePrePassRenderer();p&&p.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(o._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(o._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(o._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(o._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(o._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(o._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(o._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(o._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(o._PrePassDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(o._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(this._scene.performancePriority!==0){this.checkReadyOnlyOnce=!0;const p=this._scene.onScenePerformancePriorityChangedObservable.addOnce(()=>{this.checkReadyOnlyOnce=!1});this.onDisposeObservable.add(()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(p)})}}setPrePassRenderer(p){return!1}dispose(p,L,oe){const ie=this.getScene();if(ie.stopAnimation(this),ie.freeProcessedMaterials(),ie.removeMaterial(this),this._eventInfo.forceDisposeTextures=L,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){const ne=this._parentContainer.materials.indexOf(this);ne>-1&&this._parentContainer.materials.splice(ne,1),this._parentContainer=null}if(oe!==!0)if(this.meshMap)for(const ne in this.meshMap){const ve=this.meshMap[ne];this._disposeMeshResources(ve)}else{const ne=ie.meshes;for(const ve of ne)this._disposeMeshResources(ve)}this._uniformBuffer.dispose(),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={})}_disposeMeshResources(p){if(!p)return;const L=p.geometry,oe=p._internalAbstractMeshDataInfo._materialForRenderPass;if(this._storeEffectOnSubMeshes){if(p.subMeshes&&oe)for(const ie of p.subMeshes){const ne=ie._drawWrappers;for(let ve=0;ve<ne.length;ve++){const ye=ne[ve]?.effect;if(!ye)continue;oe[ve]===this&&(L?._releaseVertexArrayObject(ye),ie._removeDrawWrapper(ve,!0,!0))}}}else L?._releaseVertexArrayObject(this._drawWrapper.effect);p.material===this&&!p.sourceMesh&&(p.material=null)}serialize(){const p=Be.Serialize(this);return p.stencil=this.stencil.serialize(),p.uniqueId=this.uniqueId,this._serializePlugins(p),p}_serializePlugins(p){if(p.plugins={},this.pluginManager)for(const L of this.pluginManager._plugins)L.doNotSerialize||(p.plugins[L.getClassName()]=L.serialize())}static ParseAlphaMode(p,L){p._alphaMode!==void 0?L._alphaMode=Array.isArray(p._alphaMode)?p._alphaMode:[p._alphaMode]:p.alphaMode!==void 0?L._alphaMode=Array.isArray(p.alph
2aMode)?p.alphaMode:[p.alphaMode]:L._alphaMode=[2]}static Parse(p,L,oe){if(!p.customType)p.customType="BABYLON.StandardMaterial";else if(p.customType==="BABYLON.PBRMaterial"&&p.overloadedAlbedo&&(p.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return fe.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null;const ne=at.Instantiate(p.customType).Parse(p,L,oe);return ne._loadedUniqueId=p.uniqueId,o.ParseAlphaMode(p,ne),ne}static _ParsePlugins(p,L,oe,ie){if(p.plugins)for(const ne in p.plugins){const ve=p.plugins[ne];let ye=L.pluginManager?.getPlugin(ve.name);if(!ye){const je=at.Instantiate("BABYLON."+ne);je&&(ye=new je(L))}ye?.parse(ve,oe,ie)}}},(()=>{const $=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;t=[H()],r=[H()],l=[H()],f=[H()],E=[H()],v=[H()],b=[H()],C=[H("alpha")],P=[H("backFaceCulling")],W=[H("textureRepetitionMode")],z=[H("textureRepetitionHexTilingParams")],ee=[H("cullBackFaces")],J=[H()],xe=[H()],pe=[H()],F=[H()],ue=[H()],dt=[H()],Xe=[H()],Xi=[H()],Gi=[H("fogEnabled")],Zi=[H()],ji=[H()],es=[H()],ss=[H()],rs=[H()],ns=[H()],as=[H()],cs=[H()],k(o,null,ss,{kind:"getter",name:"pointsCloud",static:!1,private:!1,access:{has:p=>"pointsCloud"in p,get:p=>p.pointsCloud},metadata:$},null,e),k(o,null,rs,{kind:"getter",name:"fillMode",static:!1,private:!1,access:{has:p=>"fillMode"in p,get:p=>p.fillMode},metadata:$},null,e),k(o,null,ns,{kind:"getter",name:"useLogarithmicDepth",static:!1,private:!1,access:{has:p=>"useLogarithmicDepth"in p,get:p=>p.useLogarithmicDepth},metadata:$},null,e),k(o,null,cs,{kind:"getter",name:"transparencyMode",static:!1,private:!1,access:{has:p=>"transparencyMode"in p,get:p=>p.transparencyMode},metadata:$},null,e),k(null,null,t,{kind:"field",name:"id",static:!1,private:!1,access:{has:p=>"id"in p,get:p=>p.id,set:(p,L)=>{p.id=L}},metadata:$},i,s),k(null,null,r,{kind:"field",name:"uniqueId",static:!1,private:!1,access:{has:p=>"uniqueId"in p,get:p=>p.uniqueId,set:(p,L)=>{p.uniqueId=L}},metadata:$},a,n),k(null,null,l,{kind:"field",name:"name",static:!1,private:!1,access:{has:p=>"name"in p,get:p=>p.name,set:(p,L)=>{p.name=L}},metadata:$},c,h),k(null,null,f,{kind:"field",name:"metadata",static:!1,private:!1,access:{has:p=>"metadata"in p,get:p=>p.metadata,set:(p,L)=>{p.metadata=L}},metadata:$},d,u),k(null,null,E,{kind:"field",name:"checkReadyOnEveryCall",static:!1,private:!1,access:{has:p=>"checkReadyOnEveryCall"in p,get:p=>p.checkReadyOnEveryCall,set:(p,L)=>{p.checkReadyOnEveryCall=L}},metadata:$},_,M),k(null,null,v,{kind:"field",name:"checkReadyOnlyOnce",static:!1,private:!1,access:{has:p=>"checkReadyOnlyOnce"in p,get:p=>p.checkReadyOnlyOnce,set:(p,L)=>{p.checkReadyOnlyOnce=L}},metadata:$},S,m),k(null,null,b,{kind:"field",name:"state",static:!1,private:!1,access:{has:p=>"state"in p,get:p=>p.state,set:(p,L)=>{p.state=L}},metadata:$},x,A),k(null,null,C,{kind:"field",name:"_alpha",static:!1,private:!1,access:{has:p=>"_alpha"in p,get:p=>p._alpha,set:(p,L)=>{p._alpha=L}},metadata:$},B,O),k(null,null,P,{kind:"field",name:"_backFaceCulling",static:!1,private:!1,access:{has:p=>"_backFaceCulling"in p,get:p=>p._backFaceCulling,set:(p,L)=>{p._backFaceCulling=L}},metadata:$},Z,Y),k(null,null,W,{kind:"field",name:"_textureRepetitionMode",static:!1,private:!1,access:{has:p=>"_textureRepetitionMode"in p,get:p=>p._textureRepetitionMode,set:(p,L)=>{p._textureRepetitionMode=L}},metadata:$},I,R),k(null,null,z,{kind:"field",name:"textureRepetitionHexTilingParams",static:!1,private:!1,access:{has:p=>"textureRepetitionHexTilingParams"in p,get:p=>p.textureRepetitionHexTilingParams,set:(p,L)=>{p.textureRepetitionHexTilingParams=L}},metadata:$},V,q),k(null,null,ee,{kind:"field",name:"_cullBackFaces",static:!1,private:!1,access:{has:p=>"_cullBackFaces"in p,get:p=>p._cullBackFaces,set:(p,L)=>{p._cullBackFaces=L}},metadata:$},Q,te),k(null,null,J,{kind:"field",name:"sideOrientation",static:!1,private:!1,access:{has:p=>"sideOrientation"in p,get:p=>p.sideOrientation,set:(p,L)=>{p.sideOrientation=L}},metadata:$},se,re),k(null,null,xe,{kind:"field",name:"_alphaMode",static:!1,private:!1,access:{has:p=>"_alphaMode"in p,get:p=>
2p._alphaMode,set:(p,L)=>{p._alphaMode=L}},metadata:$},We,Fe),k(null,null,pe,{kind:"field",name:"_needDepthPrePass",static:!1,private:!1,access:{has:p=>"_needDepthPrePass"in p,get:p=>p._needDepthPrePass,set:(p,L)=>{p._needDepthPrePass=L}},metadata:$},he,D),k(null,null,F,{kind:"field",name:"disableDepthWrite",static:!1,private:!1,access:{has:p=>"disableDepthWrite"in p,get:p=>p.disableDepthWrite,set:(p,L)=>{p.disableDepthWrite=L}},metadata:$},K,ae),k(null,null,ue,{kind:"field",name:"disableColorWrite",static:!1,private:!1,access:{has:p=>"disableColorWrite"in p,get:p=>p.disableColorWrite,set:(p,L)=>{p.disableColorWrite=L}},metadata:$},Se,Oe),k(null,null,dt,{kind:"field",name:"forceDepthWrite",static:!1,private:!1,access:{has:p=>"forceDepthWrite"in p,get:p=>p.forceDepthWrite,set:(p,L)=>{p.forceDepthWrite=L}},metadata:$},ut,ke),k(null,null,Xe,{kind:"field",name:"depthFunction",static:!1,private:!1,access:{has:p=>"depthFunction"in p,get:p=>p.depthFunction,set:(p,L)=>{p.depthFunction=L}},metadata:$},ze,He),k(null,null,Xi,{kind:"field",name:"separateCullingPass",static:!1,private:!1,access:{has:p=>"separateCullingPass"in p,get:p=>p.separateCullingPass,set:(p,L)=>{p.separateCullingPass=L}},metadata:$},zi,Hi),k(null,null,Gi,{kind:"field",name:"_fogEnabled",static:!1,private:!1,access:{has:p=>"_fogEnabled"in p,get:p=>p._fogEnabled,set:(p,L)=>{p._fogEnabled=L}},metadata:$},Ki,Yi),k(null,null,Zi,{kind:"field",name:"pointSize",static:!1,private:!1,access:{has:p=>"pointSize"in p,get:p=>p.pointSize,set:(p,L)=>{p.pointSize=L}},metadata:$},$i,qi),k(null,null,ji,{kind:"field",name:"zOffset",static:!1,private:!1,access:{has:p=>"zOffset"in p,get:p=>p.zOffset,set:(p,L)=>{p.zOffset=L}},metadata:$},Qi,Ji),k(null,null,es,{kind:"field",name:"zOffsetUnits",static:!1,private:!1,access:{has:p=>"zOffsetUnits"in p,get:p=>p.zOffsetUnits,set:(p,L)=>{p.zOffsetUnits=L}},metadata:$},ts,is),k(null,null,as,{kind:"field",name:"_isVertexOutputInvariant",static:!1,private:!1,access:{has:p=>"_isVertexOutputInvariant"in p,get:p=>p._isVertexOutputInvariant,set:(p,L)=>{p._isVertexOutputInvariant=L}},metadata:$}
2,os,ls),$&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:$})})(),o.TriangleFillMode=0,o.WireFrameFillMode=1,o.PointFillMode=2,o.PointListDrawMode=3,o.LineListDrawMode=4,o.LineLoopDrawMode=5,o.LineStripDrawMode=6,o.TriangleStripDrawMode=7,o.TriangleFanDrawMode=8,o.ClockWiseSideOrientation=0,o.CounterClockWiseSideOrientation=1,o.ImageProcessingDirtyFlag=64,o.TextureDirtyFlag=1,o.LightDirtyFlag=2,o.FresnelDirtyFlag=4,o.AttributesDirtyFlag=8,o.MiscDirtyFlag=16,o.PrePassDirtyFlag=32,o.AllDirtyFlag=127,o.MATERIAL_OPAQUE=0,o.MATERIAL_ALPHATEST=1,o.MATERIAL_ALPHABLEND=2,o.MATERIAL_ALPHATESTANDBLEND=3,o.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,o.MATERIAL_NORMALBLENDMETHOD_RNM=1,o.LIGHTFALLOFF_PHYSICAL=0,o.LIGHTFALLOFF_GLTF=1,o.LIGHTFALLOFF_STANDARD=2,o.OnEventObservable=new ge,o.ForceVertexOutputInvariant=!1,o._AllDirtyCallBack=$=>$.markAllAsDirty(),o._ImageProcessingDirtyCallBack=$=>$.markAsImageProcessingDirty(),o._TextureDirtyCallBack=$=>$.markAsTexturesDirty(),o._FresnelDirtyCallBack=$=>$.markAsFresnelDirty(),o._MiscDirtyCallBack=$=>$.markAsMiscDirty(),o._PrePassDirtyCallBack=$=>$.markAsPrePassDirty(),o._LightsDirtyCallBack=$=>$.markAsLightDirty(),o._AttributeDirtyCallBack=$=>$.markAsAttributesDirty(),o._FresnelAndMiscDirtyCallBack=$=>{o._FresnelDirtyCallBack($),o._MiscDirtyCallBack($)},o._TextureAndMiscDirtyCallBack=$=>{o._TextureDirtyCallBack($),o._MiscDirtyCallBack($)},o._DirtyCallbackArray=[],o._RunDirtyCallBacks=$=>{for(const p of o._DirtyCallbackArray)p($)},o})();Object.getOwnPropertyDescriptor(Te.prototype,"pluginManager")||Object.defineProperty(Te.prototype,"pluginManager",Me("Material","pluginManager"));class _t extends Te{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 r=t.apply(e,s);return this._markAllSubMeshesAsTexturesDirty(),r};const i=e.splice;e.splice=(s,r)=>{const a=i.call(e,s,r??e.length);return this._markAllSubMeshesAsTexturesDirty(),a}}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<this.subMaterials.length;t++)if(this.subMaterials[t]?.hasTexture(e))return!0;return!1}getClassName(){return"MultiMaterial"}isReadyForSubMesh(e,t,i){for(let s=0;s<this.subMaterials.length;s++){const r=this.subMaterials[s];if(r){if(r._storeEffectOnSubMeshes){if(!r.isReadyForSubMesh(e,t,i))return!1;continue}if(!r.isReady(e))return!1}}return!0}clone(e,t){const i=new _t(e,this.getScene());for(let s=0;s<this.subMaterials.length;s++){let r;const a=this.subMaterials[s];t&&a?r=a.clone(e+"-"+a.name):r=this.subMaterials[s],i.subMaterials.push(r)}return i}serialize(){const e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,De&&(e.tags=De.GetTags(this)),e.materialsUniqueIds=[],e.materials=[];for(let t=0;t<this.subMaterials.length;t++){const i=this.subMaterials[t];i?(e.materialsUniqueIds.push(i.uniqueId),e.materials.push(i.id)):(e.materialsUniqueIds.push(null),e.materials.push(null))}return e}dispose(e,t,i){const s=this.getScene();if(!s)return;if(i)for(let a=0;a<this.subMaterials.length;a++){const n=this.subMaterials[a];n&&n.dispose(e,t)}const r=s.multiMaterials.indexOf(this);r>=0&&s.multiMaterials.splice(r,1),super.dispose(e,t)}}class G{}G.NAME_EFFECTLAYER="EffectLayer";G.NAME_LAYER="Layer";G.NAME_LENSFLARESYSTEM="LensFlareSystem";G.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";G.NAME_PARTICLESYSTEM="ParticleSystem";G.NAME_GAMEPAD="Gamepad";G.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";
2G.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";G.NAME_PREPASSRENDERER="PrePassRenderer";G.NAME_DEPTHRENDERER="DepthRenderer";G.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";G.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";G.NAME_SPRITE="Sprite";G.NAME_SUBSURFACE="SubSurface";G.NAME_OUTLINERENDERER="Outline";G.NAME_PROCEDURALTEXTURE="ProceduralTexture";G.NAME_SHADOWGENERATOR="ShadowGenerator";G.NAME_OCTREE="Octree";G.NAME_PHYSICSENGINE="PhysicsEngine";G.NAME_AUDIO="Audio";G.NAME_FLUIDRENDERER="FluidRenderer";G.NAME_IBLCDFGENERATOR="iblCDFGenerator";G.NAME_CLUSTEREDLIGHTING="ClusteredLighting";G.STEP_ISREADYFORMESH_EFFECTLAYER=0;G.STEP_ISREADYFORMESH_DEPTHRENDERER=1;G.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;G.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;G.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;G.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;G.STEP_BEFORECAMERADRAW_PREPASS=0;G.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;G.STEP_BEFORECAMERADRAW_LAYER=2;G.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;G.STEP_BEFORERENDERTARGETDRAW_LAYER=1;G.STEP_BEFORERENDERINGMESH_PREPASS=0;G.STEP_BEFORERENDERINGMESH_OUTLINE=1;G.STEP_AFTERRENDERINGMESH_PREPASS=0;G.STEP_AFTERRENDERINGMESH_OUTLINE=1;G.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;G.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;G.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;G.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;G.STEP_BEFORECLEAR_PREPASS=1;G.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;G.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;G.STEP_AFTERRENDERTARGETDRAW_LAYER=1;G.STEP_AFTERCAMERADRAW_PREPASS=0;G.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;G.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;G.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;G.STEP_AFTERCAMERADRAW_LAYER=4;G.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;G.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;G.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;G.STEP_AFTERRENDER_AUDIO=0;G.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;G.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;G.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;G.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;G.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;G.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;G.STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING=2;G.STEP_POINTERMOVE_SPRITE=0;G.STEP_POINTERDOWN_SPRITE=0;G.STEP_POINTERUP_SPRITE=0;class ar extends Array{constructor(e){super(...e)}static Create(){return Object.create(ar.prototype)}registerStep(e,t,i){let s=0,r;for(;s<this.length&&(r=this[s].index,!(e<r));s++);this.splice(s,0,{index:e,component:t,action:i.bind(t)})}clear(){this.length=0}}class _a{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}var Fs,Os,ws,Ns,Bs,Vs,Us,Ws,ks,Xs,zs,Hs,Gs,Ks;class Al{}class Ys{constructor(){this.batchCache=new Zs(this),this.batchCacheReplacementModeInFrozenMode=new Zs(this),this.instancesBufferSize=512*4}}class va{constructor(){this.renderPasses={}}}class Zs{constructor(e){this.parent=e,this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class Ia{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class Sa{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}}const Ge={source:null,parent:null,doNotCloneChildren:!1,clonePhysicsImpostor:!0,cloneThinInstances:!1};class X extends ce{static _GetDefaultSideOrientation(e){return e||X.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(g.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(g.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 ge),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new ge),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new ge),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new ge),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new ge),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.
vendor: 4,281 bytes, line 2
2instancesCount||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&&e===1||!this._scene.useRightHandedSystem&&e===0}get _effectiveSideOrientation(){return this._internalMeshDataInfo._effectiveSideOrientation}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&&this.material.sideOrientation===null||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(){const e=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];return e?e.instancesData:void 0}get previousWorldMatrixInstancedBuffer(){const e=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];return e?e.instancesPreviousData:void 0}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,i=!0,s=!1){const r=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),Qs.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,r.useClonedMeshMap&&(e._internalMeshDataInfo.meshMap||(e._internalMeshDataInfo.meshMap={}),e._internalMeshDataInfo.meshMap[this.uniqueId]=this),this._originalBuilderSideOrientation=e._originalBuilderSideOrientation,this._creationDataStorage=e._creationDataStorage,e._ranges){const a=e._ranges;for(const n in a)Object.prototype.hasOwnProperty.call(a,n)&&a[n]&&this.createAnimationRange(n,a[n].from,a[n].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,De&&De.HasTags(e)&&De.AddTagsTo(this,De.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 a=e.getDescendants(!0);for(let n=0;n<a.length;n++){const l=a[n];l._isMesh?(Ge.parent=this,Ge.doNotCloneChildren=t,Ge.clonePhysicsImpostor=i,Ge.cloneThinInstances=s,l.clone(this.name+"."+l.n
vendor: 8,603 bytes, line 2
2ame,Ge)):l.clone&&l.clone(this.name+"."+l.name,this)}}if(e.morphTargetManager&&(this.morphTargetManager=e.morphTargetManager),On(r.getPhysicsEngine)){const a=r.getPhysicsEngine();if(i&&a)if(a.getPluginVersion()===1){const n=a.getImpostorForPhysicsObject(e);n&&(this.physicsImpostor=n.clone(this))}else a.getPluginVersion()===2&&e.physicsBody&&e.physicsBody.clone(this)}for(let a=0;a<r.particleSystems.length;a++){const n=r.particleSystems[a];n.emitter===e&&n.clone(n.name,this)}if(this.skeleton=e.skeleton,s&&(e._thinInstanceDataStorage.matrixData?(this.thinInstanceSetBuffer("matrix",new Float32Array(e._thinInstanceDataStorage.matrixData),16,!e._thinInstanceDataStorage.matrixBuffer.isUpdatable()),this._thinInstanceDataStorage.matrixBufferSize=e._thinInstanceDataStorage.matrixBufferSize,this._thinInstanceDataStorage.instancesCount=e._thinInstanceDataStorage.instancesCount):this._thinInstanceDataStorage.matrixBufferSize=e._thinInstanceDataStorage.matrixBufferSize,e._userThinInstanceBuffersStorage)){const a=e._userThinInstanceBuffersStorage;for(const n in a.data)this.thinInstanceSetBuffer(n,new Float32Array(a.data[n]),a.strides[n],!a.vertexBuffers?.[n]?.isUpdatable()),this._userThinInstanceBuffersStorage.sizes[n]=a.sizes[n]}this.refreshBoundingInfo(!0,!0),this.computeWorldMatrix(!0)}constructor(e,t=null,i=null,s=null,r,a=!0){super(e,t),this._internalMeshDataInfo=new Sa,this.delayLoadState=0,this.instances=[],this._creationDataStorage=null,this._geometry=null,this._thinInstanceDataStorage=new Ia,this._shouldGenerateFlatShading=!1,this._originalBuilderSideOrientation=X.DEFAULTSIDE,this.ignoreCameraMaxZ=!1,t=this.getScene(),this._instanceDataStorage=new va,this._instanceDataStorage.engine=t.getEngine(),this._instanceDataStorage.useMonoDataStorageRenderPass=!this._instanceDataStorage.engine.isWebGPU,this._instanceDataStorage.useMonoDataStorageRenderPass&&(this._instanceDataStorage.dataStorageRenderPass=new Ys),this._scene.useRightHandedSystem?this.sideOrientation=0:this.sideOrientation=1,this._onBeforeDraw=(c,h,f)=>{c&&f&&(this._uniformBuffer?this.transferToEffect(h):f.bindOnlyWorldMatrix(h))};let n,l=!1;if(i&&i._addToSceneRootNodes===void 0){const c=i;n=c.parent??null,s=c.source??null,r=c.doNotCloneChildren??!1,a=c.clonePhysicsImpostor??!0,l=c.cloneThinInstances??!1}else n=i;s&&this._copySource(s,r,a,l),n!==null&&(this.parent=n),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=c=>{c.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 ge(this._internalMeshDataInfo._onMeshReadyObserverAdded),s&&s.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,i){const s=this.getTotalVertices()===0||t&&t.doNotInstantiate&&(t.doNotInstantiate===!0||t.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));s.parent=e||this.parent,s.position=this.position.clone(),s.scaling=this.scaling.clone(),this.rotationQuaternion?s.rotationQuaternion=this.rotationQuaternion.clone():s.rotation=this.rotation.clone(),i&&i(this,s);for(const r of this.getChildTransformNodes(!0))r.getClassName()==="InstancedMesh"&&s.getClassName()==="Mesh"&&r.sourceMesh===this?r.instantiateHierarchy(s,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:s},i):r.instantiateHierarchy(s,t,i);return s}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 i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);if(e)if(this._geometry){const i=this.getIndices(),s=this.getVerticesData(g.PositionKind);s&&i&&(t+=", flat shading: "+(s.length/3===i.length?"YES":"NO"))}else t+=", flat shading: UNKNOWN";return t}_unBindEffect(){super._unBindEffect();for(const e of this.instances)e._unBindEffect()}get hasLODLevels(){return this._internalMeshDataInfo._LODLevels.length>0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){const e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort((t,i)=>t.distanceOrScreenCoverage<i.distanceOrScreenCoverage?e:t.distanceOrScreenCoverage>i.distanceOrScreenCoverage?-e:0)}addLODLevel(e,t){if(t&&t._masterMesh)return fe.Warn("You cannot use a mesh as LOD level twice"),this;const i=new _a(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++){const s=t._LODLevels[i];if(s.distanceOrScreenCoverage===e)return s.mesh}return null}removeLODLevel(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++)t._LODLevels[i].mesh===e&&(t._LODLevels.splice(i,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this}getLOD(e,t){const i=this._internalMeshDataInfo;if(!i._LODLevels||i._LODLevels.length===0)return this;const s=t||this.getBoundingInfo().boundingSphere,r=e.mode===ea.ORTHOGRAPHIC_CAMERA?e.minZ:s.centerWorld.subtract(e.globalPosition).length();let a=r,n=1;if(i._useLODScreenCoverage){const l=e.screenArea;let c=s.radiusWorld*e.minZ/r;c=c*c*Math.PI,a=c/l,n=-1}if(n*i._LODLevels[i._LODLevels.length-1].distanceOrScreenCoverage>n*a)return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,this),this;for(let l=0;l<i._LODLevels.length;l++){const c=i._LODLevels[l];if(n*c.distanceOrScreenCoverage<n*a){if(c.mesh){if(c.mesh.delayLoadState===4)return c.mesh._checkDelayState(),this;if(c.mesh.delayLoadState===2)return this;c.mesh._preActivate(),c.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,c.mesh),c.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,this),this}get geometry(){return this._geometry}getTotalVertices(){return this._geometry===null||this._geometry===void 0?0:this._geometry.getTotalVertices()}getVerticesData(e,t,i,s){if(!this._geometry)return null;let r=s?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e]?.getFloatData(this.instances.length+1,i||t&&this._geometry.meshes.length!==1);return r||(r=this._geometry.getVerticesData(e,t,i)),r}copyVerticesData(e,t){this._geometry&&this._geometry.copyVerticesData(e,t)}getVertexBuffer(e,t){return this._geometry?(t?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e])??this._geometry.getVertexBuffer(e):null}isVerticesDataPresent(e,t){return this._geometry?!t&&this._userInstancedBuffersStorage?.vertexBuffers[e]!==void 0||this._geometry.isVerticesDataPresent(e):this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1}isVertexBufferUpdatable(e,t){if(!this._geometry)return this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1;if(!t){const i=this._userInstancedBuffersStorage?.vertexBuffers[e];if(i)return i.isUpdatable()}return this._geometry.isVertexBufferUpdatable(e)}getVerticesDataKinds(e){if(!this._geometry){const i=[];if(this._delayInfo)for(const s of this._delayInfo)i.push(s);return i}const t=this._geometry.getVerticesDataKinds();if(!e&&this._userInstancedBuffersStorage)for(const i in this._userInstancedBuffersStorage.vertexBuffers)t.indexOf(i)===-1&&t.push(i);return t}getTotalIndices(){return this._geometry?this._geometry.getTotalIndices():0}getIndices(e,t){return this._geometry?this._geometry.getIndices(e,t):[]}get isBlocked(){return this._masterMesh!==null&&this._masterMesh!==void 0}isReady(e=!1,t=!1){if(this.delayLoadState===2||!super.isReady(e))return!1;if(!this.subMeshes||this.subMeshes.length===0||!e)return!0;const i=this.getEngine(),s=this.getScene(),r=t||i.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();const a=this.material||s.defaultMaterial;if(a){if(a._storeEffectOnSubMeshes)for(const l of this.subMeshes){const c=l.getMaterial();if(c){if(c._storeEffectOnSubMeshes){if(!c.isReadyForSubMesh(this,l,r))return!1}else if(!c.isReady(this,r))return!1}}else if(!a.isReady(this,r))return!1}
2const n=i.currentRenderPassId;for(const l of this.lightSources){const c=l.getShadowGenerators();if(!c)continue;const h=c.values();for(let f=h.next();f.done!==!0;f=h.next()){const d=f.value;if(d&&(!d.getShadowMap()?.renderList||d.getShadowMap()?.renderList&&d.getShadowMap()?.renderList?.indexOf(this)!==-1)){const E=d.getShadowMap().renderPassIds??[i.currentRenderPassId];for(let _=0;_<E.length;++_){i.currentRenderPassId=E[_];for(const M of this.subMeshes)if(!d.isReady(M,r,M.getMaterial()?.needAlphaBlendingForMesh(this)??!1))return i.currentRenderPassId=n,!1}i.currentRenderPassId=n}}}for(const l of this._internalMeshDataInfo._LODLevels)if(l.mesh&&!l.mesh.isReady(r))return!1;return!0}get areNormalsFrozen(){return this._internalMeshDataInfo._areNormalsFrozen}freezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this}unfreezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this}set overridenInstanceCount(e){this._instanceDataStorage.overridenInstanceCount=e}_getInstanceDataStorage(){if(this._instanceDataStorage.useMonoDataStorageRenderPass)return this._instanceDataStorage.dataStorageRenderPass;const e=this._instanceDataStorage.engine.currentRenderPassId;let t=this._instanceDataStorage.renderPasses[e];return t||(t=new Ys,this._instanceDataStorage.renderPasses[e]=t),t}_preActivate(){const e=this._internalMeshDataInfo,t=this.getScene().getRenderId();return e._preActivateId===t?this:(e._preActivateId=t,this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass.visibleInstances=null:this._getInstanceDataStorage().visibleInstances=null,this)}_preActivateForIntermediateRendering(e){const t=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._getInstanceDataStorage();return t.visibleInstances&&(t.visibleInstances.intermediateDefaultRenderId=e),this}_registerInstanceForRenderId(e,t){const i=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._getInstanceDataStorage();return i.visibleInstances||(i.visibleInstances={defaultRenderId:t,selfDefaultRenderId:this._renderId,intermediateDefaultRenderId:-1}),i.visibleInstances[t]||(i.previousRenderId!==void 0&&(!this._instanceDataStorage.useMonoDataStorageRenderPass||this._instanceDataStorage.isFrozen)&&delete i.visibleInstances[i.previousRenderId],i.previousRenderId=t,i.visibleInstances[t]=new Array),i.visibleInstances[t].push(e),this}_afterComputeWorldMatrix(){super._afterComputeWorldMatrix(),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))}_postActivate(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))}refreshBoundingInfo(e=!1,t=!1){if(this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;let i;typeof e=="object"?i=e:i={applySkeleton:e,applyMorph:t};const s=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getData(i,null,g.PositionKind),s),this}_createGlobalSubMesh(e){const t=this.getTotalVertices();if(!t||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){const i=this.getIndices();if(!i)return null;const s=i.length;let r=!1;if(e)r=!0;else for(const a of this.subMeshes){if(a.indexStart+a.indexCount>s){r=!0;break}if(a.verticesStart+a.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new Ne(0,0,t,0,this.getTotalIndices()||(this.isUnIndexed?t:0),this)}subdivide(e){if(e<1)return;const t=this.getTotalIndices();let i=t/e|0,s=0;for(;i%3!==0;)i++;this.releaseSubMeshes();for(let r=0;r<e&&!(s>=t);r++)Ne.CreateFromIndices(0,s,s+i>=t?t-s:i,this,void 0,!1),s+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,i=!1,s){if(this._geometry)this._geometry.setVerticesData(e,t,i,s);else{const r=new Ae;r.set(t,e);const a=this.getScene();new Ce(Ce.RandomId(),a,r,i,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){const i=this.getVertexBuffer(e);!i||i.isUpdatable()===t||this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0,i=null){return this._geometry||(this._geometry=Ce.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,i,t),this}updateVerticesData(e,t,i,s){return this._geometry?(s?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this}updateMeshPositions(e,t=!0){const i=this.getVerticesData(g.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(g.PositionKind,i,!1,!1),t){const s=this.getIndices(),r=this.getVerticesData(g.NormalKind);if(!r)return this;Ae.ComputeNormals(i,s,r),this.updateVerticesData(g.NormalKind,r,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(this._geometry.meshes.length===1)return this;const e=this._geometry,t=this._geometry.copy(Ce.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i,s=null){let r=this._geometry;
2r||(r=new Ce(Ce.RandomId(),this.getScene(),void 0,void 0,this)),r.setIndexBuffer(e,t,i,s)}setIndices(e,t=null,i=!1,s=!1){if(this._geometry)this._geometry.setIndices(e,t,i,s);else{const r=new Ae;r.indices=e;const a=this.getScene();new Ce(Ce.RandomId(),a,r,i,this,t)}return this}updateIndices(e,t,i=!1){return this._geometry?(this._geometry.updateIndices(e,t,i),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,i,s=!0){if(!this._geometry)return this;const r=this.getScene().getEngine();let a;if(this._unIndexed)switch(this._getRenderingFillMode(i)){case Te.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),r);break;default:a=null;break}else switch(this._getRenderingFillMode(i)){case Te.PointFillMode:a=null;break;case Te.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case Te.TriangleFillMode:a=this._geometry.getIndexBuffer();break}return this._bindDirect(t,a,s)}_bindDirect(e,t,i=!0){if(!this._geometry)return this;if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),!i||!this._userInstancedBuffersStorage||this.hasThinInstances)this._geometry._bind(e,t);else{if(!this._instanceDataStorage.useMonoDataStorageRenderPass&&this._userInstancedBuffersStorage.renderPasses&&this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId]){const s=this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];for(const r in s)this._userInstancedBuffersStorage.vertexBuffers[r]=s[r]}this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);const r=this.getScene().getEngine(),a=r._currentMaterialContext,n=a&&a.useVertexPulling;return this._unIndexed&&t!==Te.WireFrameFillMode||t==Te.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==Te.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):n?r.drawArraysType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i):r.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i),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){const i=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._getInstanceDataStorage();if(this._instanceDataStorage.isFrozen){if(t)return i.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,i.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,i.batchCacheReplacementModeInFrozenMode;if(i.previousBatch)return i.previousBatch}const s=this.getScene(),r=s._isInIntermediateRendering(),a=r?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,n=i.batchCache;if(n.mustReturn=!1,n.renderSelf[e]=t||!a&&this.isEnabled()&&this.isVisible,n.visibleInstances[e]=null,i.visibleInstances&&!t){const l=i.visibleInstances,c=s.getRenderId(),h=r?l.intermediateDefaultRenderId:l.defaultRenderId;n.visibleInstances[e]=l[c],!n.visibleInstances[e]&&h&&(n.visibleInstances[e]=l[h])}return n.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&n.visibleInstances[e]!==null&&n.visibleInstances[e]!==void 0,i.previousBatch=n,n}_updateInstancedBuffers(e,t,i,s,r,a){const n=t.visibleInstances[e._id],l=n?n.length:0,c=t.parent,h=this._instanceDataStorage;let f=c.instancesBuffer,d=c.instancesPreviousBuffer,u=0,E=0;
2const _=t.renderSelf[e._id],M=this._scene.floatingOriginOffset,v=!f||i!==c.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!c.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!h.isFrozen||v)){const S=this.getWorldMatrix();if(_){this._scene.needsPreviousWorldMatrices&&(h.masterMeshPreviousWorldMatrix?(h.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u),h.masterMeshPreviousWorldMatrix.copyFrom(S)):(h.masterMeshPreviousWorldMatrix=S.clone(),h.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u))),S.copyToArray(c.instancesData,u);const m=S.asArray();c.instancesData[u+12]=m[12]-M.x,c.instancesData[u+13]=m[13]-M.y,c.instancesData[u+14]=m[14]-M.z,u+=16,E++}if(n){if(X.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&e.getMaterial()?.needAlphaBlendingForMesh(e.getRenderingMesh())){const m=this._scene.activeCamera.globalPosition;for(let b=0;b<n.length;b++){const x=n[b];x._distanceToCamera=T.Distance(x.getBoundingInfo().boundingSphere.centerWorld,m)}n.sort((b,x)=>b._distanceToCamera>x._distanceToCamera?-1:b._distanceToCamera<x._distanceToCamera?1:0)}for(let m=0;m<n.length;m++){const b=n[m],x=b.getWorldMatrix();x.copyToArray(c.instancesData,u),this._scene.needsPreviousWorldMatrices&&(b._previousWorldMatrix?(b._previousWorldMatrix.copyToArray(c.instancesPreviousData,u),b._previousWorldMatrix.copyFrom(x)):(b._previousWorldMatrix=x.clone(),b._previousWorldMatrix.copyToArray(c.instancesPreviousData,u)));const A=x.asArray();c.instancesData[u+12]=A[12]-M.x,c.instancesData[u+13]=A[13]-M.y,c.instancesData[u+14]=A[14]-M.z,u+=16,E++}}}else E=(_?1:0)+l;if(v){f&&f.dispose(),d&&d.dispose(),f=new ds(s,c.instancesData,!0,16,!1,!0),c.instancesBuffer=f,this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0});let S;if(this._instanceDataStorage.useMonoDataStorageRenderPass)S=this._userInstancedBuffersStorage.vertexBuffers;else{this._userInstancedBuffersStorage.renderPasses||(this._userInstancedBuffersStorage.renderPasses={});const m=this._instanceDataStorage.engine.currentRenderPassId;S=this._userInstancedBuffersStorage.renderPasses[m],S||(this._userInstancedBuffersStorage.renderPasses[m]=S={})}S.world0=f.createVertexBuffer("world0",0,4),S.world1=f.createVertexBuffer("world1",4,4),S.world2=f.createVertexBuffer("world2",8,4),S.world3=f.createVertexBuffer("world3",12,4),this._scene.needsPreviousWorldMatrices&&(d=new ds(s,c.instancesPreviousData,!0,16,!1,!0),c.instancesPreviousBuffer=d,S.previousWorld0=d.createVertexBuffer("previousWorld0",0,4),S.previousWorld1=d.createVertexBuffer("previousWorld1",4,4),S.previousWorld2=d.createVertexBuffer("previousWorld2",8,4),S.previousWorld3=d.createVertexBuffer("previousWorld3",12,4)),this._invalidateInstanceVertexArrayObject()}else(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&(f.updateDirectly(c.instancesData,0,E),this._scene.needsPreviousWorldMatrices&&(!this._instanceDataStorage.manualUpdate||this._instanceDataStorage.previousManualUpdate)&&d.updateDirectly(c.instancesPreviousData,0,E));this._processInstancedBuffers(n,_),a&&r!==void 0&&(this.getScene()._activeIndices.addCount(e.indexCount*E,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,a,r),this._draw(e,r,E)),this._scene.needsPreviousWorldMatrices&&!v&&this._instanceDataStorage.manualUpdate&&(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&!this._instanceDataStorage.previousManualUpdate&&d.updateDirectly(c.instancesData,0,E)}_renderWithInstances(e,t,i,s,r){const a=i.visibleInstances[e._id],n=a?a.length:0,l=i.parent,c=l.instancesBufferSize,f=(n+1)*16*4;for(;l.instancesBufferSize<f;)l.instancesBufferSize*=2;return(!l.instancesData||c!=l.instancesBufferSize)&&(l.instancesData=new Float32Array(l.instancesBufferSize/4)),(this._scene.needsPreviousWorldMatrices&&!l.instancesPreviousData||c!=l.instancesBufferSize)&&(l.instancesPreviousData=new Float32Array(l.instancesBufferSize/4)),this._updateInstancedBuffers(e,i,c,r,t,s),r.unbindInstanceAttributes(),this}_renderWithThinInstances(e,t,i,s){const r=this._thinInstanceDataStorage?.instancesCount??0;
vendor: 3,483 bytes, line 2
2this.getScene()._activeIndices.addCount(e.indexCount*r,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,i,t),this._draw(e,t,r),this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&this._thinInstanceDataStorage.matrixData&&(this._thinInstanceDataStorage.previousMatrixBuffer?this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,r):this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",this._thinInstanceDataStorage.matrixData,!1)),s.unbindInstanceAttributes()}_processInstancedBuffers(e,t){}_processRendering(e,t,i,s,r,a,n,l){const c=this.getScene(),h=c.getEngine();if(s=this._getRenderingFillMode(s),a&&t.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(t,s,i,h),this;if(a)this._renderWithInstances(t,s,r,i,h);else{h._currentDrawContext&&(h._currentDrawContext.useInstancing=!1);let f=0;r.renderSelf[t._id]&&(n&&n(!1,e.getWorldMatrix(),l),f++,this._draw(t,s,this._instanceDataStorage.overridenInstanceCount));const d=r.visibleInstances[t._id];if(d){const u=d.length;f+=u;for(let E=0;E<u;E++){const M=d[E].getWorldMatrix();n&&n(!0,M,l),this._draw(t,s)}}c._activeIndices.addCount(t.indexCount*f,!1)}return this}_disposeInstanceDataStorageRenderPass(e,t=!1){e?.instancesBuffer&&(t&&e.instancesBuffer.dispose(),e.instancesBuffer=null),e?.instancesPreviousBuffer&&(t&&e.instancesPreviousBuffer.dispose(),e.instancesPreviousBuffer=null)}_rebuild(e=!1){for(const t in this._instanceDataStorage.renderPasses){const i=this._instanceDataStorage.renderPasses[t];this._disposeInstanceDataStorageRenderPass(i,e)}if(this._disposeInstanceDataStorageRenderPass(this._instanceDataStorage.dataStorageRenderPass,e),this._userInstancedBuffersStorage){for(const t in this._userInstancedBuffersStorage.vertexBuffers){const i=this._userInstancedBuffersStorage.vertexBuffers[t];i&&(e&&i.dispose(),this._userInstancedBuffersStorage.vertexBuffers[t]=null)}this._userInstancedBuffersStorage.vertexArrayObjects&&(this._userInstancedBuffersStorage.vertexArrayObjects={})}this._internalMeshDataInfo._effectiveMaterial=null,super._rebuild(e)}_releaseRenderPassId(e){const t=this._instanceDataStorage.renderPasses[e];if(t&&(this._disposeInstanceDataStorageRenderPass(t,!0),delete this._instanceDataStorage.renderPasses[e]),this._userInstancedBuffersStorage?.renderPasses){const i=this._userInstancedBuffersStorage.renderPasses[e];if(i)for(const s in i)i[s]?.dispose();delete this._userInstancedBuffersStorage.renderPasses[e]}}_freeze(){if(this.subMeshes){for(let e=0;e<this.subMeshes.length;e++)this._getInstancesRenderList(e);this._internalMeshDataInfo._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}}_unFreeze(){this._instanceDataStorage.isFrozen=!1;for(const e in this._instanceDataStorage.renderPasses){const t=this._instanceDataStorage.renderPasses[e];t.previousBatch=null}this._instanceDataStorage.dataStorageRenderPass&&(this._instanceDataStorage.dataStorageRenderPass.previousBatch=null)}renderWithRenderPassId(e,t,i,s,r=!0){const a=this._scene.getEngine(),n=a.currentRenderPassId;if(e!==void 0&&(a.currentRenderPassId=e),s)(!r||r&&s.isInFrustum(this._scene._frustumPlanes))&&this.render(s,!!t,i);else for(let l=0;l<this.subMeshes.length;l++){const c=this.subMeshes[l];(!r||r&&c.isInFrustum(this._scene._frustumPlanes))&&this.render(c,!!t,i)}return e!==void 0&&(a.currentRenderPassId=n),this}
vendor: 6,347 bytes, lines 2-8
2directRender(){if(!this.subMeshes)return this;for(const e of this.subMeshes)this.render(e,!1);return this}render(e,t,i){const s=this.getScene(),r=s.getEngine();this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1;const a=s.activeCameras?.length??0,n=a>1&&s.activeCamera===s.activeCameras[0]||a<=1,l=this._occlusionDataStorage&&this._occlusionDataStorage.occlusionForRenderPassId!==-1&&this._occlusionDataStorage.occlusionForRenderPassId!==r.currentRenderPassId;if(n&&this._checkOcclusionQuery(l)&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;const c=this._getInstancesRenderList(e._id,!!i);if(c.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;let h=0,f=null;this.ignoreCameraMaxZ&&s.activeCamera&&!s._isInIntermediateRendering()&&(h=s.activeCamera.maxZ,f=s.activeCamera,s.activeCamera.maxZ=0,s.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);const d=e.getRenderingMesh(),u=c.hardwareInstancedRendering[e._id]||d.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,E=this._instanceDataStorage,_=e.getMaterial();if(!_)return f&&(f.maxZ=h,s.updateTransformMatrix(!0)),this;if(!E.isFrozen||!this._internalMeshDataInfo._effectiveMaterial||this._internalMeshDataInfo._effectiveMaterial!==_){if(_._storeEffectOnSubMeshes){if(!_.isReadyForSubMesh(this,e,u))return f&&(f.maxZ=h,s.updateTransformMatrix(!0)),this}else if(!_.isReady(this,u))return f&&(f.maxZ=h,s.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=_}else if(_._storeEffectOnSubMeshes&&!e._drawWrapper?._wasPreviouslyReady||!_._storeEffectOnSubMeshes&&!_._getDrawWrapper()._wasPreviouslyReady)return f&&(f.maxZ=h,s.updateTransformMatrix(!0)),this;if(t){const B=this._internalMeshDataInfo._effectiveMaterial;if(B.alphaModes.length===1)r.setAlphaMode(B.alphaMode);else for(let O=0;O<B.alphaModes.length;O++){const P=B.alphaModes[O];r.setAlphaMode(P!==void 0?P:2,!1,O)}}let M;this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?M=e._drawWrapper:M=this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const v=M?.effect??null;for(const B of s._beforeRenderingMeshStage)B.action(this,e,c,v);if(!M||!v)return f&&(f.maxZ=h,s.updateTransformMatrix(!0)),this;const S=i||this;let m;if(!E.isFrozen&&(this._internalMeshDataInfo._effectiveMaterial.backFaceCulling||this._internalMeshDataInfo._effectiveMaterial.sideOrientation!==null||this._internalMeshDataInfo._effectiveMaterial._twoSidedLighting)){const B=S._getWorldMatrixDeterminant();m=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),B<0&&(m=m===Te.ClockWiseSideOrientation?Te.CounterClockWiseSideOrientation:Te.ClockWiseSideOrientation),this._internalMeshDataInfo._effectiveSideOrientation=m}const b=this._internalMeshDataInfo._effectiveMaterial._preBind(M,this._internalMeshDataInfo._effectiveSideOrientation);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&r.setDepthWrite(!0);const x=this._internalMeshDataInfo._effectiveMaterial,A=x.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),u||this._bind(e,v,A,!1);const C=S.getWorldMatrix();x._storeEffectOnSubMeshes?x.bindForSubMesh(C,this,e):x.bind(C,this),!x.backFaceCulling&&x.separateCullingPass&&(r.setState(!0,x.zOffset,!1,!b,x.cullBackFaces,x.stencil,x.zOffsetUnits),this._processRendering(this,e,v,A,c,u,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),r.setState(!0,x.zOffset,!1,b,x.cullBackFaces,x.stencil,x.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,v,A,c,u,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const B of s._afterRenderingMeshStage)B.action(this,e,c,v);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),f&&(f.maxZ=h,s.updateTransformMatrix(!0)),s.performancePriority===2&&!E.isFrozen&&this._freeze(),this}cleanMatrixWeights(){this.isVerticesDataPresent(g.MatricesWeightsKind)&&(this.isVerticesDataPresent(g.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(g.MatricesWeightsKind),t=e.length;for(let i=0;i<t;i+=4){const s=e[i]+e[i+1]+e[i+2]+e[i+3];if(s===0)e[i]=1;else{const r=1/s;e[i]*=r,e[i+1]*=r,e[i+2]*=r,e[i+3]*=r}}this.setVerticesData(g.MatricesWeightsKind,e)}_normalizeSkinWeightsAndExtra(){const e=this.getVerticesData(g.MatricesWeightsExtraKind),t=this.getVerticesData(g.MatricesWeightsKind),i=t.length;for(let s=0;s<i;s+=4){let r=t[s]+t[s+1]+t[s+2]+t[s+3];if(r+=e[s]+e[s+1]+e[s+2]+e[s+3],r===0)t[s]=1;else{const a=1/r;t[s]*=a,t[s+1]*=a,t[s+2]*=a,t[s+3]*=a,e[s]*=a,e[s+1]*=a,e[s+2]*=a,e[s+3]*=a}}this.setVerticesData(g.MatricesWeightsKind,t),this.setVerticesData(g.MatricesWeightsKind,e)}validateSkinning(){const e=this.getVerticesData(g.MatricesWeightsExtraKind),t=this.getVerticesData(g.MatricesWeightsKind);if(t===null||this.skeleton==null)return{skinned:!1,valid:!0,report:"not skinned"};const i=t.length;let s=0,r=0,a=0,n=0;const l=e===null?4:8,c=[];for(let M=0;M<=l;M++)c[M]=0;const h=.001;for(let M=0;M<i;M+=4){let v=t[M],S=v,m=S===0?0:1;for(let b=1;b<l;b++){const x=b<4?t[M+b]:e[M+b-4];x>v&&s++,x!==0&&m++,S+=x,v=x}if(c[m]++,m>a&&(a=m),S===0)r++;else{const b=1/S;let x=0;for(let A=0;A<l;A++)A<4?x+=Math.abs(t[M+A]-t[M+A]*b):x+=Math.abs(e[M+A-4]-e[M+A-4]*b);x>h&&n++}}const f=this.skeleton.bones.length,d=this.getVerticesData(g.MatricesIndicesKind),u=this.getVerticesData(g.MatricesIndicesExtraKind);let E=0;for(let M=0;M<i;M+=4)for(let v=0;v<l;v++){const S=v<4?d[M+v]:u[M+v-4];(S>=f||S<0)&&E++}const _="Number of Weights = "+i/4+`
3Maximum influences = `+a+`
4Missing Weights = `+r+`
5Not Sorted = `+s+`
6Not Normalized = `+n+`
7WeightCounts = [`+c+`]
8Number of bones = `+f+`
9Bad Bone Indices = `+E;return{skinned:!0,valid:r===0&&n===0&&E===0,report:_}}_checkDelayState(){const e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===4&&(this.delayLoadState=2,this._queueLoad(e)),this}_queueLoad(e){e.addPendingData(this);const t=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return(async()=>{try{const i=await e._loadDelayedFileAsync(this.delayLoadingFile,t,!0);i instanceof ArrayBuffer?this._delayLoadingFunction(i,this):this._delayLoadingFunction(JSON.parse(i),this);for(const s of this.instances)s.refreshBoundingInfo(),s._syncSubMeshes();this.delayLoadState=1,e.removePendingData(this)}catch(i){e.removePendingData(this),e.isDisposed||fe.Error(`Unable to delay load geometry data for mesh "${this.name}" from "${this.delayLoadingFile}": ${i}`)}})(),this}isInFrustum(e){return this.delayLoadState===2||!super.isInFrustum(e)?!1:(this._checkDelayState(),!0)}setMaterialById(e){const t=this.getScene().materials;let i;for(i=t.length-1;i>-1;i--)if(t[i].id===e)return this.material=t[i],this;const s=this.getScene().multiMaterials;for(i=s.length-1;i>-1;i--)if(s[i].id===e)return this.material=s[i],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(g.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(g.PositionKind);const s=T.Zero();let r;for(r=0;r<i.length;r+=3)T.TransformCoordinatesFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).toArray(i,r);if(this.setVerticesData(g.PositionKind,i,this.getVertexBuffer(g.PositionKind).isUpdatable()),this.isVerticesDataPresent(g.NormalKind)){for(i=this.getVerticesData(g.NormalKind),r=0;r<i.length;r+=3)T.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(g.NormalKind,i,this.getVertexBuffer(g.NormalKind).isUpdatable())}if(this.isVerticesDataPresent(g.TangentKind)){for(i=this.getVerticesData(g.TangentKind),r=0;r<i.length;r+=4)T.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(g.TangentKind,i,this.getVertexBuffer(g.TangentKind).isUpdatable())}return e.determinant()<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this}bakeCurrentTransformIntoVertices(e=!0,t=!1){return t&&this.makeGeometryUnique(),this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(e),this}get _positions(){return this._internalAbstractMeshDataInfo._positions||this._geometry&&this._geometry._positions||null}_resetPointsArrayCache(){return this._geometry&&this._geometry._resetPointsArrayCache(),this}_generatePointsArray(){return this._geometry?this._geometry._generatePointsArray():!1}clone(e="",t=null,i,s=!0){if(t&&t._addToSceneRootNodes===void 0){const r=t;return Ge.source=this,Ge.doNotCloneChildren=r.doNotCloneChildren,Ge.clonePhysicsImpostor=r.clonePhysicsImpostor,Ge.cloneThinInstances=r.cloneThinInstances,new X(e,this.getScene(),Ge)}return new X(e,this.getScene(),t,this,i,s)}dispose(e,t=!1){this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);const i=this._internalMeshDataInfo;if(i._onBeforeDrawObservable&&i._onBeforeDrawObservable.clear(),i._onBeforeBindObservable&&i._onBeforeBindObservable.clear(),i._onBeforeRenderObservable&&i._onBeforeRenderObservable.clear(),i._onAfterRenderObservable&&i._onAfterRenderObservable.clear(),i._onBetweenPassObservable&&i._onBetweenPassObservable.clear(),this._scene.useClonedMeshMap){if(i.meshMap)for(const s in i.meshMap){const r=i.meshMap[s];r&&(r._internalMeshDataInfo._source=null,i.meshMap[s]=void 0)}i._source&&i._source._internalMeshDataInfo.meshMap&&(i._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else{const s=this.getScene().meshes;for(const r of s){const a=r;a._internalMeshDataInfo&&a._internalMeshDataInfo._source&&a._internalMeshDataInfo._source===this&&(a._internalMeshDataInfo._source=null)}}i._source=null,this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),this._internalMeshDataInfo._checkReadinessObserver&&this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),super.dispose(e,t)}_disposeInstanceSpecificData(){}_disposeThinInstanceSpecificData(){}
vendor: 20,267 bytes, line 9
9_invalidateInstanceVertexArrayObject(){}applyDisplacementMap(e,t,i,s,r,a,n=!1,l){const c=this.getScene();return wn(e,f=>{const d=f.width,u=f.height,_=this.getEngine().createCanvas(d,u).getContext("2d");_.drawImage(f,0,0);const M=_.getImageData(0,0,d,u).data;this.applyDisplacementMapFromBuffer(M,d,u,t,i,r,a,n),s&&s(this)},l||(()=>{}),c.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,s,r,a,n,l=!1){if(!this.isVerticesDataPresent(g.PositionKind)||!this.isVerticesDataPresent(g.NormalKind)||!this.isVerticesDataPresent(g.UVKind))return fe.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const c=this.getVerticesData(g.PositionKind,!0,!0),h=this.getVerticesData(g.NormalKind),f=this.getVerticesData(g.UVKind);let d=T.Zero();const u=T.Zero(),E=$e.Zero();a=a||$e.Zero(),n=n||new $e(1,1);for(let _=0;_<c.length;_+=3){T.FromArrayToRef(c,_,d),T.FromArrayToRef(h,_,u),$e.FromArrayToRef(f,_/3*2,E);const M=Math.abs(E.x*n.x+a.x%1)*(t-1)%t|0,v=Math.abs(E.y*n.y+a.y%1)*(i-1)%i|0,S=(M+v*t)*4,m=e[S]/255,b=e[S+1]/255,x=e[S+2]/255,A=m*.3+b*.59+x*.11;u.normalize(),u.scaleInPlace(s+(r-s)*A),d=d.add(u),d.toArray(c,_)}return Ae.ComputeNormals(c,this.getIndices(),h),l?(this.setVerticesData(g.PositionKind,c),this.setVerticesData(g.NormalKind,h),this.setVerticesData(g.UVKind,f)):(this.updateVerticesData(g.PositionKind,c),this.updateVerticesData(g.NormalKind,h)),this}_getFlattenedNormals(e,t){const i=new Float32Array(e.length*3);let s=0;const r=this.sideOrientation===(this._scene.useRightHandedSystem?1:0);for(let a=0;a<e.length;a+=3){const n=T.FromArray(t,e[a]*3),l=T.FromArray(t,e[a+1]*3),c=T.FromArray(t,e[a+2]*3),h=n.subtract(l),f=c.subtract(l),d=T.Normalize(T.Cross(h,f));r&&d.scaleInPlace(-1);for(let u=0;u<3;u++)i[s++]=d.x,i[s++]=d.y,i[s++]=d.z}return i}_convertToUnIndexedMesh(e=!1){const t=this.getVerticesDataKinds().filter(l=>!this.getVertexBuffer(l)?.getIsInstanced()),i=this.getIndices(!1,!0),s={},r=(l,c)=>{const h=new Float32Array(i.length*c);let f=0;for(let d=0;d<i.length;d++)for(let u=0;u<c;u++)h[f++]=l[i[d]*c+u];return h},a=this.getBoundingInfo(),n=this.geometry?this.subMeshes.slice(0):[];for(const l of t)s[l]=this.getVerticesData(l);for(const l of t){const c=this.getVertexBuffer(l),h=c.getSize();if(e&&l===g.NormalKind){const f=this._getFlattenedNormals(i,s[g.PositionKind]);this.setVerticesData(g.NormalKind,f,c.isUpdatable(),h)}else this.setVerticesData(l,r(s[l],h),c.isUpdatable(),h)}if(this.morphTargetManager){for(let l=0;l<this.morphTargetManager.numTargets;l++){const c=this.morphTargetManager.getTarget(l),h=c.getPositions();c.setPositions(r(h,3));const f=c.getNormals();f&&c.setNormals(e?this._getFlattenedNormals(i,h):r(f,3));const d=c.getTangents();d&&c.setTangents(r(d,3));const u=c.getUVs();u&&c.setUVs(r(u,2));const E=c.getColors();E&&c.setColors(r(E,4))}this.morphTargetManager.synchronize()}for(let l=0;l<i.length;l++)i[l]=l;this.setIndices(i),this._unIndexed=!0,this.releaseSubMeshes();for(const l of n){const c=l.getBoundingInfo();Ne.AddToMesh(l.materialIndex,l.indexStart,l.indexCount,l.indexStart,l.indexCount,this).setBoundingInfo(c)}return this.setBoundingInfo(a),this.synchronizeInstances(),this}convertToFlatShadedMesh(){return this._convertToUnIndexedMesh(!0)}convertToUnIndexedMesh(){return this._convertToUnIndexedMesh()}flipFaces(e=!1){const t=Ae.ExtractFromMesh(this);let i;if(e&&this.isVerticesDataPresent(g.NormalKind)&&t.normals){for(i=0;i<t.normals.length;i++)t.normals[i]*=-1;this.setVerticesData(g.NormalKind,t.normals,this.isVertexBufferUpdatable(g.NormalKind))}if(t.indices){let s;for(i=0;i<t.indices.length;i+=3)s=t.indices[i+1],t.indices[i+1]=t.indices[i+2],t.indices[i+2]=s;this.setIndices(t.indices,null,this.isVertexBufferUpdatable(g.PositionKind),!0)}return this}increaseVertices(e=1){const t=Ae.ExtractFromMesh(this),i=t.indices&&!Array.isArray(t.indices)&&Array.from?Array.from(t.indices):t.indices,s=t.positions&&!Array.isArray(t.positions)&&Array.from?Array.from(t.positions):t.positions,r=t.uvs&&!Array.isArray(t.uvs)&&Array.from?Array.from(t.uvs):t.uvs,a=t.normals&&!Array.isArray(t.normals)&&Array.from?Array.from(t.normals):t.normals;if(!i||!s)fe.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions");else{t.indices=i,t.positions=s,r&&(t.uvs=r),a&&(t.normals=a);const n=e+1,l=[];for(let x=0;x<n+1;x++)l[x]=[];let c,h;const f=new T(0,0,0),d=new T(0,0,0),u=new $e(0,0),E=[],_=[],M=[];let v,S=s.length,m;r&&(m=r.length);let b;a&&(b=a.length);for(let x=0;x<i.length;x+=3){_[0]=i[x],_[1]=i[x+1],_[2]=i[x+2];for(let A=0;A<3;A++)if(c=_[A],h=_[(A+1)%3],M[c]===void 0&&M[h]===void 0?(M[c]=[],M[h]=[]):(M[c]===void 0&&(M[c]=[]),M[h]===void 0&&(M[h]=[])),M[c][h]===void 0&&M[h][c]===void 0){M[c][h]=[],f.x=(s[3*h]-s[3*c])/n,f.y=(s[3*h+1]-s[3*c+1])/n,f.z=(s[3*h+2]-s[3*c+2])/n,a&&(d.x=(a[3*h]-a[3*c])/n,d.y=(a[3*h+1]-a[3*c+1])/n,d.z=(a[3*h+2]-a[3*c+2])/n),r&&(u.x=(r[2*h]-r[2*c])/n,u.y=(r[2*h+1]-r[2*c+1])/n),M[c][h].push(c);for(let C=1;C<n;C++)M[c][h].push(s.length/3),s[S++]=s[3*c]+C*f.x,s[S++]=s[3*c+1]+C*f.y,s[S++]=s[3*c+2]+C*f.z,a&&(a[b++]=a[3*c]+C*d.x,a[b++]=a[3*c+1]+C*d.y,a[b++]=a[3*c+2]+C*d.z),r&&(r[m++]=r[2*c]+C*u.x,r[m++]=r[2*c+1]+C*u.y);M[c][h].push(h),M[h][c]=[],v=M[c][h].length;for(let C=0;C<v;C++)M[h][c][C]=M[c][h][v-1-C]}l[0][0]=i[x],l[1][0]=M[i[x]][i[x+1]][1],l[1][1]=M[i[x]][i[x+2]][1];for(let A=2;A<n;A++){l[A][0]=M[i[x]][i[x+1]][A],l[A][A]=M[i[x]][i[x+2]][A],f.x=(s[3*l[A][A]]-s[3*l[A][0]])/A,f.y=(s[3*l[A][A]+1]-s[3*l[A][0]+1])/A,f.z=(s[3*l[A][A]+2]-s[3*l[A][0]+2])/A,a&&(d.x=(a[3*l[A][A]]-a[3*l[A][0]])/A,d.y=(a[3*l[A][A]+1]-a[3*l[A][0]+1])/A,d.z=(a[3*l[A][A]+2]-a[3*l[A][0]+2])/A),r&&(u.x=(r[2*l[A][A]]-r[2*l[A][0]])/A,u.y=(r[2*l[A][A]+1]-r[2*l[A][0]+1])/A);for(let C=1;C<A;C++)l[A][C]=s.length/3,s[S++]=s[3*l[A][0]]+C*f.x,s[S++]=s[3*l[A][0]+1]+C*f.y,s[S++]=s[3*l[A][0]+2]+C*f.z,a&&(a[b++]=a[3*l[A][0]]+C*d.x,a[b++]=a[3*l[A][0]+1]+C*d.y,a[b++]=a[3*l[A][0]+2]+C*d.z),r&&(r[m++]=r[2*l[A][0]]+C*u.x,r[m++]=r[2*l[A][0]+1]+C*u.y)}l[n]=M[i[x+1]][i[x+2]],E.push(l[0][0],l[1][0],l[1][1]);for(let A=1;A<n;A++){let C;for(C=0;C<A;C++)E.push(l[A][C],l[A+1][C],l[A+1][C+1]),E.push(l[A][C],l[A+1][C+1],l[A][C+1]);E.push(l[A][C],l[A+1][C],l[A+1][C+1])}}t.indices=E,t.applyToMesh(this,this.isVertexBufferUpdatable(g.PositionKind))}}forceSharedVertices(){const e=Ae.ExtractFromMesh(this),t=e.uvs,i=e.indices,s=e.positions,r=e.colors,a=e.matricesIndices,n=e.matricesWeights,l=e.matricesIndicesExtra,c=e.matricesWeightsExtra;if(i===void 0||s===void 0||i===null||s===null)fe.Warn("VertexData contains empty entries");else{const h=[],f=[],d=[],u=[],E=[],_=[],M=[],v=[];let S,m=0;const b={};let x,A;for(let B=0;B<i.length;B+=3){A=[i[B],i[B+1],i[B+2]],S=[];for(let O=0;O<3;O++){S[O]="";for(let P=0;P<3;P++)Math.abs(s[3*A[O]+P])<1e-8&&(s[3*A[O]+P]=0),S[O]+=s[3*A[O]+P]+"|"}if(!(S[0]==S[1]||S[0]==S[2]||S[1]==S[2]))for(let O=0;O<3;O++){if(x=b[S[O]],x===void 0){b[S[O]]=m,x=m++;for(let P=0;P<3;P++)h.push(s[3*A[O]+P]);if(r!=null)for(let P=0;P<4;P++)u.push(r[4*A[O]+P]);if(t!=null)for(let P=0;P<2;P++)d.push(t[2*A[O]+P]);if(a!=null)for(let P=0;P<4;P++)E.push(a[4*A[O]+P]);if(n!=null)for(let P=0;P<4;P++)_.push(n[4*A[O]+P]);if(l!=null)for(let P=0;P<4;P++)M.push(l[4*A[O]+P]);if(c!=null)for(let P=0;P<4;P++)v.push(c[4*A[O]+P])}f.push(x)}}const C=[];Ae.ComputeNormals(h,f,C),e.positions=h,e.indices=f,e.normals=C,t!=null&&(e.uvs=d),r!=null&&(e.colors=u),a!=null&&(e.matricesIndices=E),n!=null&&(e.matricesWeights=_),l!=null&&(e.matricesIndicesExtra=M),n!=null&&(e.matricesWeightsExtra=v),e.applyToMesh(this,this.isVertexBufferUpdatable(g.PositionKind))}}static _instancedMeshFactory(e,t){throw le("InstancedMesh")}static _PhysicsImpostorParser(e,t,i){throw le("PhysicsImpostor")}createInstance(e){const t=X._instancedMeshFactory(e,this);return t.parent=this.parent,t}synchronizeInstances(){for(let e=0;e<this.instances.length;e++)this.instances[e]._syncSubMeshes();return this}optimizeIndices(e){const t=this.getIndices(),i=this.getVerticesData(g.PositionKind);if(!i||!t)return this;const s=[];for(let a=0;a<i.length;a=a+3)s.push(T.FromArray(i,a));const r=[];return Wn.SyncAsyncForLoop(s.length,40,a=>{const n=s.length-1-a,l=s[n];for(let c=0;c<n;++c){const h=s[c];if(l.equals(h)){r[n]=c;break}}},()=>{for(let n=0;n<t.length;++n)t[n]=r[t[n]]||t[n];const a=this.subMeshes.slice(0);this.setIndices(t),this.subMeshes=a,e&&e(this)}),this}serialize(e={}){e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),De&&De.HasTags(this)&&(e.tags=De.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?e.pivotMatrix=this.getPivotMatrix().asArray():e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.alwaysSelectAsActiveMesh=this.alwaysSelectAsActiveMesh,e.checkCollisions=this.checkCollisions,e.ellipsoid=this.ellipsoid.asArray(),e.ellipsoidOffset=this.ellipsoidOffset.asArray(),e.doNotSyncBoundingInfo=this.doNotSyncBoundingInfo,e.isBlocker=this.isBlocker,e.sideOrientation=this.sideOrientation,this._isWorldMatrixFrozen&&(e.freezeWorldMatrix=!0),this.parent&&this.parent._serializeAsParent(e),e.isUnIndexed=this.isUnIndexed;const t=this._geometry;if(t&&this.subMeshes){e.geometryUniqueId=t.uniqueId,e.geometryId=t.id,e.subMeshes=[];for(let i=0;i<this.subMeshes.length;i++){const s=this.subMeshes[i];e.subMeshes.push({materialIndex:s.materialIndex,verticesStart:s.verticesStart,verticesCount:s.verticesCount,indexStart:s.indexStart,indexCount:s.indexCount})}}if(this.material?this.material.doNotSerialize||(e.materialUniqueId=this.material.uniqueId,e.materialId=this.material.id):(this.material=null,e.materialUniqueId=this._scene.defaultMaterial.uniqueId,e.materialId=this._scene.defaultMaterial.id),this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id,e.skeletonUniqueId=this.skeleton.uniqueId,e.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(G.NAME_PHYSICSENGINE)){const i=this.getPhysicsImpostor?.();i&&(e.physicsMass=i.getParam("mass"),e.physicsFriction=i.getParam("friction"),e.physicsRestitution=i.getParam("mass"),e.physicsImpostor=i.type)}this.metadata&&(e.metadata=this.metadata),e.instances=[];for(let i=0;i<this.instances.length;i++){const s=this.instances[i];if(s.doNotSerialize)continue;const r={name:s.name,id:s.id,isEnabled:s.isEnabled(!1),isVisible:s.isVisible,isPickable:s.isPickable,checkCollisions:s.checkCollisions,position:s.position.asArray(),scaling:s.scaling.asArray()};if(s.parent&&s.parent._serializeAsParent(r),s.rotationQuaternion?r.rotationQuaternion=s.rotationQuaternion.asArray():s.rotation&&(r.rotation=s.rotation.asArray()),this.getScene()._getComponent(G.NAME_PHYSICSENGINE)){const a=s.getPhysicsImpostor?.();a&&(r.physicsMass=a.getParam("mass"),r.physicsFriction=a.getParam("friction"),r.physicsRestitution=a.getParam("mass"),r.physicsImpostor=a.type)}s.metadata&&(r.metadata=s.metadata),s.actionManager&&(r.actions=s.actionManager.serialize(s.name)),e.instances.push(r),Be.AppendSerializedAnimations(s,r),r.ranges=s.serializeAnimationRanges()}if(this._thinInstanceDataStorage.instancesCount&&this._thinInstanceDataStorage.matrixData&&(e.thinInstances={instancesCount:this._thinInstanceDataStorage.instancesCount,matrixData:Array.from(this._thinInstanceDataStorage.matrixData),matrixBufferSize:this._thinInstanceDataStorage.matrixBufferSize,enablePicking:this.thinInstanceEnablePicking},this._userThinInstanceBuffersStorage)){const i={data:{},sizes:{},strides:{}};for(const s in this._userThinInstanceBuffersStorage.data)i.data[s]=Array.from(this._userThinInstanceBuffersStorage.data[s]),i.sizes[s]=this._userThinInstanceBuffersStorage.sizes[s],i.strides[s]=this._userThinInstanceBuffersStorage.strides[s];e.thinInstances.userThinInstance=i}return Be.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.layerMask=this.layerMask,e.alphaIndex=this.alphaIndex,e.hasVertexAlpha=this.hasVertexAlpha,e.overlayAlpha=this.overlayAlpha,e.overlayColor=this.overlayColor.asArray(),e.renderOverlay=this.renderOverlay,e.applyFog=this.applyFog,this.actionManager&&(e.actions=this.actionManager.serialize(this.name)),e}_syncGeometryWithMorphTargetManager(){if(!this.geometry)return;this._markSubMeshesAsAttributesDirty();const e=this._internalAbstractMeshDataInfo._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices()){fe.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),this.morphTargetManager=null;return}if(e.isUsingTextureForTargets)return;for(let t=0;t<e.numInfluencers;t++){const i=e.getActiveTarget(t),s=i.getPositions();if(!s){fe.Error("Invalid morph target. Target must have positions.");return}this.geometry.setVerticesData(g.PositionKind+t,s,!1,3);const r=i.getNormals();r&&this.geometry.setVerticesData(g.NormalKind+t,r,!1,3);const a=i.getTangents();a&&this.geometry.setVerticesData(g.TangentKind+t,a,!1,3);const n=i.getUVs();n&&this.geometry.setVerticesData(g.UVKind+"_"+t,n,!1,2);const l=i.getUV2s();l&&this.geometry.setVerticesData(g.UV2Kind+"_"+t,l,!1,2);const c=i.getColors();c&&this.geometry.setVerticesData(g.ColorKind+t,c,!1,4)}}else{let t=0;for(;this.geometry.isVerticesDataPresent(g.PositionKind+t);)this.geometry.removeVerticesData(g.PositionKind+t),this.geometry.isVerticesDataPresent(g.NormalKind+t)&&this.geometry.removeVerticesData(g.NormalKind+t),this.geometry.isVerticesDataPresent(g.TangentKind+t)&&this.geometry.removeVerticesData(g.TangentKind+t),this.geometry.isVerticesDataPresent(g.UVKind+t)&&this.geometry.removeVerticesData(g.UVKind+"_"+t),this.geometry.isVerticesDataPresent(g.UV2Kind+t)&&this.geometry.removeVerticesData(g.UV2Kind+"_"+t),this.geometry.isVerticesDataPresent(g.ColorKind+t)&&this.geometry.removeVerticesData(g.ColorKind+t),t++}}static Parse(e,t,i){let s,r=!1;if(e.type&&e.type==="LinesMesh"?s=X._LinesMeshParser(e,t):e.type&&e.type==="GroundMesh"?s=X._GroundMeshParser(e,t):e.type&&e.type==="GoldbergMesh"?s=X._GoldbergMeshParser(e,t):e.type&&e.type==="GreasedLineMesh"?s=X._GreasedLineMeshParser(e,t):e.type&&e.type==="TrailMesh"?s=X._TrailMeshParser(e,t):e.type&&e.type==="GaussianSplattingMesh"?(e._isCompound?s=X._GaussianSplattingCompoundMeshParser(e,t):s=X._GaussianSplattingMeshParser(e,t),r=!0):e.type&&e.type==="GaussianSplattingPartProxyMesh"?(s=X._GaussianSplattingPartProxyMeshParser(e,t),r=!0):s=new X(e.name,t),s.id=e.id,s._waitingParsedUniqueId=e.uniqueId,De&&De.AddTagsTo(s,e.tags),s.position=T.FromArray(e.position),e.metadata!==void 0&&(s.metadata=e.metadata),e.rotationQuaternion?s.rotationQuaternion=Ee.FromArray(e.rotationQuaternion):e.rotation&&(s.rotation=T.FromArray(e.rotation)),s.scaling=T.FromArray(e.scaling),e.localMatrix?s.setPreTransformMatrix(j.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(j.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),s.isVisible=e.isVisible,s.infiniteDistance=e.infiniteDistance,s.alwaysSelectAsActiveMesh=!!e.alwaysSelectAsActiveMesh,s.showBoundingBox=e.showBoundingBox,s.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,e.applyFog!==void 0&&(s.applyFog=e.applyFog),e.pickable!==void 0&&(s.isPickable=e.pickable),e.alphaIndex!==void 0&&(s.alphaIndex=e.alphaIndex),s.receiveShadows=e.receiveShadows,e.billboardMode!==void 0&&(s.billboardMode=e.billboardMode),e.visibility!==void 0&&(s.visibility=e.visibility),s.checkCollisions=e.checkCollisions,s.doNotSyncBoundingInfo=!!e.doNotSyncBoundingInfo,e.ellipsoid&&(s.ellipsoid=T.FromArray(e.ellipsoid)),e.ellipsoidOffset&&(s.ellipsoidOffset=T.FromArray(e.ellipsoidOffset)),e.overrideMaterialSideOrientation!=null&&(s.sideOrientation=e.overrideMaterialSideOrientation),e.sideOrientation!==void 0&&(s.sideOrientation=e.sideOrientation),e.isBlocker!==void 0&&(s.isBlocker=e.isBlocker),s._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(s._waitingData.freezeWorldMatrix=e.freezeWorldMatrix),e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.actions!==void 0&&(s._waitingData.actions=e.actions),e.overlayAlpha!==void 0&&(s.overlayAlpha=e.overlayAlpha),e.overlayColor!==void 0&&(s.overlayColor=xt.FromArray(e.overlayColor)),e.renderOverlay!==void 0&&(s.renderOverlay=e.renderOverlay),s.isUnIndexed=!!e.isUnIndexed,s.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s.buildBoundingInfo(T.FromArray(e.boundingBoxMinimum),T.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(s._binaryInfo=e._binaryInfo),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(g.UVKind),e.hasUVs2&&s._delayInfo.push(g.UV2Kind),e.hasUVs3&&s._delayInfo.push(g.UV3Kind),e.hasUVs4&&s._delayInfo.push(g.UV4Kind),e.hasUVs5&&s._delayInfo.push(g.UV5Kind),e.hasUVs6&&s._delayInfo.push(g.UV6Kind),e.hasColors&&s._delayInfo.push(g.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(g.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(g.MatricesWeightsKind),s._delayLoadingFunction=Ce._ImportGeometry,Le.ForceFullSceneLoadingForIncremental&&s._checkDelayState()):r||Ce._ImportGeometry(e,s),e.materialUniqueId?s._waitingMaterialId=e.materialUniqueId:e.materialId&&(s._waitingMaterialId=e.materialId),e.morphTargetManagerId>-1&&(s._waitingMorphTargetManagerId=e.morphTargetManagerId),e.skeletonId!==void 0&&e.skeletonId!==null&&(s.skeleton=t.getLastSkeletonById(e.skeletonId),s._waitingSkeletonId=e.skeletonId,e.numBoneInfluencers&&(s.numBoneInfluencers=e.numBoneInfluencers)),e.skeletonUniqueId!==void 0&&e.skeletonUniqueId!==null&&(s._waitingSkeletonUniqueId=e.skeletonUniqueId),e.animations){for(let a=0;a<e.animations.length;a++){const n=e.animations[a],l=fs("BABYLON.Animation");l&&s.animations.push(l.Parse(n))}ct.ParseAnimationRanges(s,e,t)}if(e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?s.layerMask=Math.abs(parseInt(e.layerMask)):s.layerMask=268435455,e.physicsImpostor&&(s.physicsImpostor=X._PhysicsImpostorParser(t,s,e)),e.lodMeshIds&&(s._waitingData.lods={ids:e.lodMeshIds,distances:e.lodDistances?e.lodDistances:null,coverages:e.lodCoverages?e.lodCoverages:null}),e.instances)for(let a=0;a<e.instances.length;a++){const n=e.instances[a],l=s.createInstance(n.name);if(n.id&&(l.id=n.id),De&&(n.tags?De.AddTagsTo(l,n.tags):De.AddTagsTo(l,e.tags)),l.position=T.FromArray(n.position),n.metadata!==void 0&&(l.metadata=n.metadata),n.parentId!==void 0&&(l._waitingParentId=n.parentId),n.parentInstanceIndex!==void 0&&(l._waitingParentInstanceIndex=n.parentInstanceIndex),n.isEnabled!==void 0&&n.isEnabled!==null&&l.setEnabled(n.isEnabled),n.isVisible!==void 0&&n.isVisible!==null&&(l.isVisible=n.isVisible),n.isPickable!==void 0&&n.isPickable!==null&&(l.isPickable=n.isPickable),n.rotationQuaternion?l.rotationQuaternion=Ee.FromArray(n.rotationQuaternion):n.rotation&&(l.rotation=T.FromArray(n.rotation)),l.scaling=T.FromArray(n.scaling),n.checkCollisions!=null&&n.checkCollisions!=null&&(l.checkCollisions=n.checkCollisions),n.pickable!=null&&n.pickable!=null&&(l.isPickable=n.pickable),n.showBoundingBox!=null&&n.showBoundingBox!=null&&(l.showBoundingBox=n.showBoundingBox),n.showSubMeshesBoundingBox!=null&&n.showSubMeshesBoundingBox!=null&&(l.showSubMeshesBoundingBox=n.showSubMeshesBoundingBox),n.alphaIndex!=null&&n.showSubMeshesBoundingBox!=null&&(l.alphaIndex=n.alphaIndex),n.physicsImpostor&&(l.physicsImpostor=X._PhysicsImpostorParser(t,l,n)),n.actions!==void 0&&(l._waitingData.actions=n.actions),n.animations){for(let c=0;c<n.animations.length;c++){const h=n.animations[c],f=fs("BABYLON.Animation");f&&l.animations.push(f.Parse(h))}ct.ParseAnimationRanges(l,n,t),n.autoAnimate&&t.beginAnimation(l,n.autoAnimateFrom,n.autoAnimateTo,n.autoAnimateLoop,n.autoAnimateSpeed||1)}}if(e.thinInstances){const a=e.thinInstances;
vendor: 6,137 bytes, line 9
9if(s.thinInstanceEnablePicking=!!a.enablePicking,a.matrixData?(s.thinInstanceSetBuffer("matrix",new Float32Array(a.matrixData),16,!1),s._thinInstanceDataStorage.matrixBufferSize=a.matrixBufferSize,s._thinInstanceDataStorage.instancesCount=a.instancesCount):s._thinInstanceDataStorage.matrixBufferSize=a.matrixBufferSize,e.thinInstances.userThinInstance){const n=e.thinInstances.userThinInstance;for(const l in n.data)s.thinInstanceSetBuffer(l,new Float32Array(n.data[l]),n.strides[l],!1),s._userThinInstanceBuffersStorage.sizes[l]=n.sizes[l]}}return s}setPositionsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourcePositions){const t=this.getVerticesData(g.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(g.PositionKind)||this.setVerticesData(g.PositionKind,t,!0)}return e._sourcePositions}setNormalsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourceNormals){const t=this.getVerticesData(g.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(g.NormalKind)||this.setVerticesData(g.NormalKind,t,!0)}return e._sourceNormals}applySkeleton(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(g.PositionKind))return this;if(!this.isVerticesDataPresent(g.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(g.MatricesWeightsKind))return this;const t=this.isVerticesDataPresent(g.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){const v=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=v}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();let s=this.getVerticesData(g.PositionKind);if(!s)return this;s instanceof Float32Array||(s=new Float32Array(s));let r=this.getVerticesData(g.NormalKind);if(t){if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r))}const a=this.getVerticesData(g.MatricesIndicesKind),n=this.getVerticesData(g.MatricesWeightsKind);if(!n||!a)return this;const l=this.numBoneInfluencers>4,c=l?this.getVerticesData(g.MatricesIndicesExtraKind):null,h=l?this.getVerticesData(g.MatricesWeightsExtraKind):null,f=e.getTransformMatrices(this),d=T.Zero(),u=new j,E=new j;let _=0,M;for(let v=0;v<s.length;v+=3,_+=4){let S;for(M=0;M<4;M++)S=n[_+M],S>0&&(j.FromFloat32ArrayToRefScaled(f,Math.floor(a[_+M]*16),S,E),u.addToSelf(E));if(l)for(M=0;M<4;M++)S=h[_+M],S>0&&(j.FromFloat32ArrayToRefScaled(f,Math.floor(c[_+M]*16),S,E),u.addToSelf(E));T.TransformCoordinatesFromFloatsToRef(i._sourcePositions[v],i._sourcePositions[v+1],i._sourcePositions[v+2],u,d),d.toArray(s,v),t&&(T.TransformNormalFromFloatsToRef(i._sourceNormals[v],i._sourceNormals[v+1],i._sourceNormals[v+2],u,d),d.toArray(r,v)),u.reset()}return this.updateVerticesData(g.PositionKind,s),t&&this.updateVerticesData(g.NormalKind,r),this}static MinMax(e){let t=null,i=null;for(const s of e){const a=s.getBoundingInfo().boundingBox;!t||!i?(t=a.minimumWorld.clone(),i=a.maximumWorld.clone()):(t.minimizeInPlace(a.minimumWorld),i.maximizeInPlace(a.maximumWorld))}return!t||!i?{min:T.Zero(),max:T.Zero()}:{min:t,max:i}}static Center(e){const t=e instanceof Array?X.MinMax(e):e;return T.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,s,r,a){return Wi(X._MergeMeshesCoroutine(e,t,i,s,r,a,!1))}static async MergeMeshesAsync(e,t=!0,i,s,r,a){return await Xn(X._MergeMeshesCoroutine(e,t,i,s,r,a,!0),kn())}static*_MergeMeshesCoroutine(e,t=!0,i,s,r,a,n){if(e=e.filter(Boolean),e.length===0)return null;let l;if(!i){let C=0;for(l=0;l<e.length;l++)if(C+=e[l].getTotalVertices(),C>=65536)return fe.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}const c=e[0];a&&(r=!1,e.sort((C,B)=>(C.material?.uniqueId??-1)-(B.material?.uniqueId??-1)));const h=new Array,f=new Array,d=new Array,u=e[0].sideOrientation;for(l=0;l<e.length;l++){const C=e[l];if(C.isAnInstance)return fe.Warn("Cannot merge instance meshes."),null;if(u!==C.sideOrientation)return fe.Warn("Cannot merge meshes with different sideOrientation values."),null;if(r||a){const B=d.reduce((O,P)=>Math.max(O,P.start+P.count),0);if(a)if(C.material){const O=C.material;if(O instanceof _t){for(let P=0;P<O.subMaterials.length;P++)h.indexOf(O.subMaterials[P])<0&&h.push(O.subMaterials[P]);for(let P=0;P<C.subMeshes.length;P++)f.push(h.indexOf(O.subMaterials[C.subMeshes[P].materialIndex])),d.push({start:B+C.subMeshes[P].indexStart,count:C.subMeshes[P].indexCount})}else{h.indexOf(O)<0&&h.push(O);for(let P=0;P<C.subMeshes.length;P++)f.push(h.indexOf(O)),d.push({start:B+C.subMeshes[P].indexStart,count:C.subMeshes[P].indexCount})}}else for(let O=0;O<C.subMeshes.length;O++)f.push(0),d.push({start:B+C.subMeshes[O].indexStart,count:C.subMeshes[O].indexCount});else d.push({start:B,count:C.getTotalIndices()})}}if(a&&d.length>1){let C=0;for(let B=1;B<d.length;B++){const O=d[C],P=d[B];f[B]===f[C]&&O.start+O.count===P.start?O.count+=P.count:(C++,d[C]=P,f[C]=f[B])}d.length=C+1,f.length=C+1}const E=C=>{const B=C.computeWorldMatrix(!0);return{vertexData:Ae.ExtractFromMesh(C,!1,!1),transform:B}},{vertexData:_,transform:M}=E(e[0]);n&&(yield);const v=new Array(e.length-1);for(let C=1;C<e.length;C++)v[C-1]=E(e[C]),n&&(yield);const S=_._mergeCoroutine(M,v,i,n,!t);let m=S.next();for(;!m.done;)n&&(yield),m=S.next();const b=m.value;s||(s=new X(c.name+"_merged",c.getScene()));const x=b._applyToCoroutine(s,void 0,n);let A=x.next();for(;!A.done;)n&&(yield),A=x.next();if(s.checkCollisions=c.checkCollisions,s.sideOrientation=c.sideOrientation,t)for(l=0;l<e.length;l++)e[l].dispose();if(r||a){for(s.releaseSubMeshes(),l=0;l<d.length;)Ne.CreateFromIndices(0,d[l].start,d[l].count,s,void 0,!1),l++;for(const C of s.subMeshes)C.refreshBoundingInfo();s.computeWorldMatrix(!0)}if(a){const C=new _t(c.name+"_merged",c.getScene());C.subMaterials=h;for(let B=0;B<s.subMeshes.length;B++)s.subMeshes[B].materialIndex=f[B];s.material=C}else s.material=c.material;return s}
9addInstance(e){e._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(e)}removeInstance(e){const t=e._indexInSourceMeshInstanceArray;if(t!=-1){if(t!==this.instances.length-1){const i=this.instances[this.instances.length-1];this.instances[t]=i,i._indexInSourceMeshInstanceArray=t}e._indexInSourceMeshInstanceArray=-1,this.instances.pop()}}_shouldConvertRHS(){return this._scene.useRightHandedSystem&&this.sideOrientation===Te.CounterClockWiseSideOrientation}_getRenderingFillMode(e){const t=this.getScene();return t.forcePointsCloud?Te.PointFillMode:t.forceWireframe?Te.WireFrameFillMode:this.overrideRenderingFillMode??e}setMaterialByID(e){return this.setMaterialById(e)}static CreateRibbon(e,t,i,s,r,a,n,l,c){throw new Error("Import MeshBuilder to populate this function")}static CreateDisc(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateBox(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateSphere(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateHemisphere(e,t,i,s){throw new Error("Import MeshBuilder to populate this function")}static CreateCylinder(e,t,i,s,r,a,n,l,c){throw new Error("Import MeshBuilder to populate this function")}static CreateTorus(e,t,i,s,r,a,n){throw new Error("Import MeshBuilder to populate this function")}static CreateTorusKnot(e,t,i,s,r,a,n,l,c,h){throw new Error("Import MeshBuilder to populate this function")}static CreateLines(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateDashedLines(e,t,i,s,r,a,n,l){throw new Error("Import MeshBuilder to populate this function")}static CreatePolygon(e,t,i,s,r,a,n){throw new Error("Import MeshBuilder to populate this function")}static ExtrudePolygon(e,t,i,s,r,a,n,l){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShape(e,t,i,s,r,a,n,l,c,h){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShapeCustom(e,t,i,s,r,a,n,l,c,h,f,d){throw new Error("Import MeshBuilder to populate this function")}static CreateLathe(e,t,i,s,r,a,n){throw new Error("Import MeshBuilder to populate this function")}static CreatePlane(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateGround(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateTiledGround(e,t,i,s,r,a,n,l,c){throw new Error("Import MeshBuilder to populate this function")}static CreateGroundFromHeightMap(e,t,i,s,r,a,n,l,c,h,f){throw new Error("Import MeshBuilder to populate this function")}static CreateTube(e,t,i,s,r,a,n,l,c,h){throw new Error("Import MeshBuilder to populate this function")}static CreatePolyhedron(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateIcoSphere(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateDecal(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateCapsule(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static ExtendToGoldberg(e){throw new Error("Import MeshBuilder to populate this function")}}X.FRONTSIDE=Ae.FRONTSIDE;X.BACKSIDE=Ae.BACKSIDE;X.DOUBLESIDE=Ae.DOUBLESIDE;X.DEFAULTSIDE=Ae.DEFAULTSIDE;X.NO_CAP=0;X.CAP_START=1;X.CAP_END=2;X.CAP_ALL=3;X.NO_FLIP=0;X.FLIP_TILE=1;X.ROTATE_TILE=2;X.FLIP_ROW=3;X.ROTATE_ROW=4;X.FLIP_N_ROTATE_TILE=5;X.FLIP_N_ROTATE_ROW=6;X.CENTER=0;X.LEFT=1;X.RIGHT=2;X.TOP=3;X.BOTTOM=4;X.INSTANCEDMESH_SORT_TRANSPARENT=!1;X._GroundMeshParser=(o,e)=>{throw le("GroundMesh")};X._GoldbergMeshParser=(o,e)=>{throw le("GoldbergMesh")};X._LinesMeshParser=(o,e)=>{throw le("LinesMesh")};X._GreasedLineMeshParser=(o,e)=>{throw le("GreasedLineMesh")};X._GreasedLineRibbonMeshParser=(o,e)=>{throw le("GreasedLineRibbonMesh")};X._TrailMeshParser=(o,e)=>{throw le("TrailMesh")};X._GaussianSplattingMeshParser=(o,e)=>{throw le("GaussianSplattingMesh")};X._GaussianSplattingPartProxyMeshParser=(o,e)=>{throw le("GaussianSplattingPartProxyMesh")};X._GaussianSplattingCompoundMeshParser=(o,e)=>{throw le("GaussianSplattingCompoundMesh")};(Fs=X.prototype).registerInstancedBuffer??(Fs.registerInstancedBuffer=Ie("Mesh","registerInstancedBuffer"));(Os=X.prototype).simplify??(Os.simplify=Ie("Mesh","simplify"));(ws=X.prototype).thinInstanceAdd??(ws.thinInstanceAdd=Ie("Mesh","thinInstanceAdd"));(Ns=X.prototype).thinInstanceAddSelf??(Ns.thinInstanceAddSelf=Ie("Mesh","thinInstanceAddSelf"));(Bs=X.prototype).thinInstanceRegisterAttribute??(Bs.thinInstanceRegisterAttribute=Ie("Mesh","thinInstanceRegisterAttribute"));
9(Vs=X.prototype).thinInstanceSetMatrixAt??(Vs.thinInstanceSetMatrixAt=Ie("Mesh","thinInstanceSetMatrixAt"));(Us=X.prototype).thinInstanceSetAttributeAt??(Us.thinInstanceSetAttributeAt=Ie("Mesh","thinInstanceSetAttributeAt"));(Ws=X.prototype).thinInstanceSetBuffer??(Ws.thinInstanceSetBuffer=Ie("Mesh","thinInstanceSetBuffer"));(ks=X.prototype).thinInstanceGetWorldMatrices??(ks.thinInstanceGetWorldMatrices=Ie("Mesh","thinInstanceGetWorldMatrices"));(Xs=X.prototype).thinInstanceBufferUpdated??(Xs.thinInstanceBufferUpdated=Ie("Mesh","thinInstanceBufferUpdated"));(zs=X.prototype).thinInstancePartialBufferUpdate??(zs.thinInstancePartialBufferUpdate=Ie("Mesh","thinInstancePartialBufferUpdate"));(Hs=X.prototype).thinInstanceRefreshBoundingInfo??(Hs.thinInstanceRefreshBoundingInfo=Ie("Mesh","thinInstanceRefreshBoundingInfo"));(Gs=X.prototype).getEmittedParticleSystems??(Gs.getEmittedParticleSystems=Ie("Mesh","getEmittedParticleSystems"));(Ks=X.prototype).getHierarchyEmittedParticleSystems??(Ks.getHierarchyEmittedParticleSystems=Ie("Mesh","getHierarchyEmittedParticleSystems"));Object.getOwnPropertyDescriptor(X.prototype,"edgesShareWithInstances")||Object.defineProperty(X.prototype,"edgesShareWithInstances",Me("Mesh","edgesShareWithInstances"));Object.getOwnPropertyDescriptor(X.prototype,"thinInstanceEnablePicking")||Object.defineProperty(X.prototype,"thinInstanceEnablePicking",Me("Mesh","thinInstanceEnablePicking"));Object.getOwnPropertyDescriptor(X.prototype,"thinInstanceAllowAutomaticStaticBufferRecreation")||Object.defineProperty(X.prototype,"thinInstanceAllowAutomaticStaticBufferRecreation",Me("Mesh","thinInstanceAllowAutomaticStaticBufferRecreation"));Object.getOwnPropertyDescriptor(X.prototype,"thinInstanceCount")||Object.defineProperty(X.prototype,"thinInstanceCount",Me("Mesh","thinInstanceCount"));class $s extends ce{constructor(e,t){super(e,t.getScene()),this._indexInSourceMe
vendor: 6,915 bytes, line 9
9shInstanceArray=-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 i of t.getAnimationRanges())i!=null&&this.createAnimationRange(i.name,i.from,i.to);if(this.infiniteDistance=t.infiniteDistance,this.setPivotMatrix(t.getPivotMatrix()),!t.skeleton&&!t.morphTargetManager&&t.hasBoundingInfo){const i=t.getBoundingInfo();this.buildBoundingInfo(i.minimum,i.maximum)}else 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&&fe.Warn("Setting receiveShadows on an instanced mesh has no effect")}get material(){return this._sourceMesh.material}set material(e){this._sourceMesh?.material!==e&&fe.Warn("Setting material on an instanced mesh has no effect")}get visibility(){return this._sourceMesh.visibility}set visibility(e){this._sourceMesh?.visibility!==e&&fe.Warn("Setting visibility on an instanced mesh has no effect")}get skeleton(){return this._sourceMesh.skeleton}set skeleton(e){this._sourceMesh?.skeleton!==e&&fe.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||fe.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}get geometry(){return this._sourceMesh._geometry}createInstance(e){return this._sourceMesh.createInstance(e)}isReady(e=!1){return this._sourceMesh.isReady(e,!0)}getVerticesData(e,t,i){return this._sourceMesh.getVerticesData(e,t,i)}copyVerticesData(e,t){this._sourceMesh.copyVerticesData(e,t)}getVertexBuffer(e,t){return this._sourceMesh.getVertexBuffer(e,t)}setVerticesData(e,t,i,s){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,s),this.sourceMesh}updateVerticesData(e,t,i,s){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,s),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 i;typeof e=="object"?i=e:i={applySkeleton:e,applyMorph:t};const s=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(i,null,g.PositionKind),s),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||fe.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!==this._sourceMesh&&this._currentLOD.billboardMode!==Pe.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new j);const e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,N.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(N.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||t.length===0)this._currentLOD=this.sourceMesh;else{const i=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,i.boundingSphere)}return this._currentLOD}_preActivateForIntermediateRendering(e){return this.sourceMesh._preActivateForIntermediateRendering(e)}_syncSubMeshes(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(let e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this}_generatePointsArray(){return this._sourceMesh._generatePointsArray()}_updateBoundingInfo(){return this.hasBoundingInfo?this.getBoundingInfo().update(this.worldMatrixFromCache):this.buildBoundingInfo(this.absolutePosition,this.absolutePosition,this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this}clone(e,t=null,i,s){const r=(s||this._sourceMesh).createInstance(e);if(Qs.DeepCopy(this,r,["name","subMeshes","uniqueId","parent","lightSources","receiveShadows","material","visibility","skeleton","sourceMesh","isAnInstance","facetNb","isFacetDataEnabled","isBlocked","useBones","hasInstances","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","hasBoundingInfo","geometry"],[]),t&&(r.parent=t),!i)for(let a=0;a<this.getScene().meshes.length;a++){const n=this.getScene().meshes[a];n.parent===this&&n.clone(n.name,r)}return r.computeWorldMatrix(!0),this.onClonedObservable.notifyObservers(r),r}dispose(e,t=!1){this._sourceMesh.removeInstance(this),super.dispose(e,t)}_serializeAsParent(e){super._serializeAsParent(e),e.parentId=this._sourceMesh.uniqueId,e.parentInstanceIndex=this._indexInSourceMe
vendor: 12,932 bytes, lines 9-184
9shInstanceArray}instantiateHierarchy(e=null,t,i){const s=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0,t&&t.newSourcedMesh);s&&i&&i(this,s);for(const r of this.getChildTransformNodes(!0))r.instantiateHierarchy(s,t,i);return s}}let qs=!1;function Ea(){qs||(qs=!0,X._instancedMeshFactory=(o,e)=>{const t=new $s(o,e);if(e.instancedBuffers){t.instancedBuffers={};for(const i in e.instancedBuffers)t.instancedBuffers[i]=e.instancedBuffers[i]}return t},X.prototype.registerInstancedBuffer=function(o,e){if(this._userInstancedBuffersStorage?.vertexBuffers[o]?.dispose(),this._userInstancedBuffersStorage?.renderPasses)for(const t in this._userInstancedBuffersStorage.renderPasses){const i=this._userInstancedBuffersStorage.renderPasses[t];i[o]?.dispose(),delete i[o]}if(!this.instancedBuffers){this.instancedBuffers={};for(const t of this.instances)t.instancedBuffers={}}this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0}),this.instancedBuffers[o]=null,this._userInstancedBuffersStorage.strides[o]=e,this._userInstancedBuffersStorage.sizes[o]=e*32,this._userInstancedBuffersStorage.data[o]=new Float32Array(this._userInstancedBuffersStorage.sizes[o]),this._userInstancedBuffersStorage.vertexBuffers[o]=this._instanceDataStorage.useMonoDataStorageRenderPass?new g(this.getEngine(),this._userInstancedBuffersStorage.data[o],o,!0,!1,e,!0):null;for(const t of this.instances)t.instancedBuffers[o]=null;this._invalidateInstanceVertexArrayObject(),this._markSubMeshesAsAttributesDirty()},X.prototype._processInstancedBuffers=function(o,e){const t=o?o.length:0,i=!this._instanceDataStorage.useMonoDataStorageRenderPass;let s;if(i){const r=this._instanceDataStorage.engine.currentRenderPassId;this._userInstancedBuffersStorage.renderPasses||(this._userInstancedBuffersStorage.renderPasses={}),this._userInstancedBuffersStorage.renderPasses[r]||(this._userInstancedBuffersStorage.renderPasses[r]={}),s=this._userInstancedBuffersStorage.renderPasses[r]}for(const r in this.instancedBuffers){let a=this._userInstancedBuffersStorage.sizes[r];const n=this._userInstancedBuffersStorage.strides[r],l=(t+1)*n;for(;a<l;)a*=2;this._userInstancedBuffersStorage.data[r].length!=a&&(this._userInstancedBuffersStorage.data[r]=new Float32Array(a),this._userInstancedBuffersStorage.sizes[r]=a,i?s[r]&&(s[r].dispose(),s[r]=null):this._userInstancedBuffersStorage.vertexBuffers[r]&&(this._userInstancedBuffersStorage.vertexBuffers[r].dispose(),this._userInstancedBuffersStorage.vertexBuffers[r]=null));const c=this._userInstancedBuffersStorage.data[r];let h=0;if(e){const f=this.instancedBuffers[r]??0;f.toArray?f.toArray(c,h):f.copyToArray?f.copyToArray(c,h):c[h]=f,h+=n}for(let f=0;f<t;f++){const u=o[f].instancedBuffers[r]??0;u.toArray?u.toArray(c,h):u.copyToArray?u.copyToArray(c,h):c[h]=u,h+=n}i?s[r]?s[r].updateDirectly(c,0):(s[r]=new g(this.getEngine(),this._userInstancedBuffersStorage.data[r],r,!0,!1,n,!0),this._invalidateInstanceVertexArrayObject()):this._userInstancedBuffersStorage.vertexBuffers[r]?this._userInstancedBuffersStorage.vertexBuffers[r].updateDirectly(c,0):(this._userInstancedBuffersStorage.vertexBuffers[r]=new g(this.getEngine(),this._userInstancedBuffersStorage.data[r],r,!0,!1,n,!0),this._invalidateInstanceVertexArrayObject())}},X.prototype._invalidateInstanceVertexArrayObject=function(){if(!(!this._userInstancedBuffersStorage||this._userInstancedBuffersStorage.vertexArrayObjects===void 0)){for(const o in this._userInstancedBuffersStorage.vertexArrayObjects)this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[o]);this._userInstancedBuffersStorage.vertexArrayObjects={}}},X.prototype._disposeInstanceSpecificData=function(){for(const o in this._instanceDataStorage.renderPasses)this._instanceDataStorage.renderPasses[o].instancesBuffer?.dispose();for(this._instanceDataStorage.renderPasses={},this._instanceDataStorage.dataStorageRenderPass?.instancesBuffer?.dispose();this.instances.length;)this.instances[0].dispose();for(const o in this.instancedBuffers)this._userInstancedBuffersStorage.vertexBuffers[o]&&this._userInstancedBuffersStorage.vertexBuffers[o].dispose();this._invalidateInstanceVertexArrayObject(),this.instancedBuffers={}},Nn("BABYLON.InstancedMesh",$s))}Ea();const Tt="decalVertexDeclaration",or=`#ifdef DECAL
10uniform vec4 vDecalInfos;uniform mat4 decalMatrix;
11#endif
12`;y.IncludesShadersStore[Tt]||(y.IncludesShadersStore[Tt]=or);const Ma={name:Tt,shader:or},Ct="defaultVertexDeclaration",lr=`uniform mat4 viewProjection;
13#ifdef MULTIVIEW
14mat4 viewProjectionR;
15#endif 
16uniform mat4 view;
17#ifdef DIFFUSE
18uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;
19#endif
20#ifdef AMBIENT
21uniform mat4 ambientMatrix;uniform vec2 vAmbientInfos;
22#endif
23#ifdef OPACITY
24uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;
25#endif
26#ifdef EMISSIVE
27uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix;
28#endif
29#ifdef LIGHTMAP
30uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix;
31#endif
32#if defined(SPECULAR) && defined(SPECULARTERM)
33uniform vec2 vSpecularInfos;uniform mat4 specularMatrix;
34#endif
35#ifdef BUMP
36uniform vec3 vBumpInfos;uniform mat4 bumpMatrix;
37#endif
38#ifdef REFLECTION
39uniform mat4 reflectionMatrix;
40#endif
41#ifdef POINTSIZE
42uniform float pointSize;
43#endif
44#ifdef DETAIL
45uniform vec4 vDetailInfos;uniform mat4 detailMatrix;
46#endif
47uniform vec4 cameraInfo;uniform vec4 vTextureRepetitionHexTilingParams;
48#include<decalVertexDeclaration>
49#define ADDITIONAL_VERTEX_DECLARATION
50`;y.IncludesShadersStore[Ct]||(y.IncludesShadersStore[Ct]=lr);const xa={name:Ct,shader:lr},Pt="sceneUboDeclaration",cr=`layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;
51#ifdef MULTIVIEW
52mat4 viewProjectionR;
53#endif 
54mat4 view;mat4 projection;vec4 vEyePosition;mat4 inverseProjection;};
55`;y.IncludesShadersStore[Pt]||(y.IncludesShadersStore[Pt]=cr);const hr={name:Pt,shader:cr},yt="meshUboDeclaration",fr=`#ifdef WEBGL2
56uniform mat4 world;uniform float visibility;
57#else
58layout(std140,column_major) uniform;uniform Mesh
59{mat4 world;float visibility;};
60#endif
61#define WORLD_UBO
62`;y.IncludesShadersStore[yt]||(y.IncludesShadersStore[yt]=fr);const dr={name:yt,shader:fr},Rt="defaultUboDeclaration",ur=`layout(std140,column_major) uniform;uniform Material
63{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 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;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;vec4 cameraInfo;vec4 vTextureRepetitionHexTilingParams;vec2 vReflectionInfos;mat4 reflectionMatrix;vec3 vReflectionPosition;vec3 vReflectionSize;
64#define ADDITIONAL_UBO_DECLARATION
65};
66#include<sceneUboDeclaration>
67#include<meshUboDeclaration>
68`;y.IncludesShadersStore[Rt]||(y.IncludesShadersStore[Rt]=ur);const mr={name:Rt,shader:ur},Lt="uvAttributeDeclaration",pr=`#ifdef UV{X}
69attribute vec2 uv{X};
70#endif
71`;y.IncludesShadersStore[Lt]||(y.IncludesShadersStore[Lt]=pr);const Da={name:Lt,shader:pr},Ft="bonesDeclaration",gr=`#if NUM_BONE_INFLUENCERS>0
72attribute vec4 matricesIndices;attribute vec4 matricesWeights;
73#if NUM_BONE_INFLUENCERS>4
74attribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra;
75#endif
76#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
77#ifdef BONETEXTURE
78uniform highp sampler2D boneSampler;uniform vec2 boneTextureInfo;
79#else
80uniform mat4 mBones[BonesPerMesh];
81#endif
82#ifdef BONES_VELOCITY_ENABLED
83uniform mat4 mPreviousBones[BonesPerMesh];
84#endif
85#ifdef BONETEXTURE
86#define inline
87mat4 readMatrixFromRawSampler(sampler2D smp,float index)
88{
89#if defined(WEBGL2) || defined(WEBGPU)
90int offset=int(index)*4; 
91int textureWidth=int(boneTextureInfo.x);int y=int(offset)/textureWidth;int x=int(offset) % textureWidth;vec4 m0=texelFetch(smp,ivec2(x+0,y),0);vec4 m1=texelFetch(smp,ivec2(x+1,y),0);vec4 m2=texelFetch(smp,ivec2(x+2,y),0);vec4 m3=texelFetch(smp,ivec2(x+3,y),0);return mat4(m0,m1,m2,m3);
92#else
93float offset=index*4.0;float y=floor(offset/boneTextureInfo.x);float x=offset-y*boneTextureInfo.x;float dy=1.0/boneTextureInfo.y;float dx=1.0/boneTextureInfo.x;vec4 m0=texture2D(smp,vec2(dx*(x+0.5),dy*(y+0.5)));vec4 m1=texture2D(smp,vec2(dx*(x+1.5),dy*(y+0.5)));vec4 m2=texture2D(smp,vec2(dx*(x+2.5),dy*(y+0.5)));vec4 m3=texture2D(smp,vec2(dx*(x+3.5),dy*(y+0.5))); 
94return mat4(m0,m1,m2,m3);
95#endif
96}
97#endif
98#endif
99#endif
100`;y.IncludesShadersStore[Ft]||(y.IncludesShadersStore[Ft]=gr);const Aa={name:Ft,shader:gr},Ot="bakedVertexAnimationDeclaration",_r=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
101uniform float bakedVertexAnimationTime;
102#if !defined(WEBGL2) && !defined(WEBGPU)
103uniform vec2 bakedVertexAnimationTextureSizeInverted;
104#endif
105uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture;
106#ifdef INSTANCES
107attribute vec4 bakedVertexAnimationSettingsInstanced;
108#endif
109#define inline
110mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
111{
112#if defined(WEBGL2) || defined(WEBGPU)
113int offset=int(index)*4;int frameUV=int(frame);vec4 m0=texelFetch(smp,ivec2(offset+0,frameUV),0);vec4 m1=texelFetch(smp,ivec2(offset+1,frameUV),0);vec4 m2=texelFetch(smp,ivec2(offset+2,frameUV),0);vec4 m3=texelFetch(smp,ivec2(offset+3,frameUV),0);return mat4(m0,m1,m2,m3);
114#else
115float 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);
116#endif
117}
118#endif
119`;y.IncludesShadersStore[Ot]||(y.IncludesShadersStore[Ot]=_r);const ba={name:Ot,shader:_r},wt="instancesDeclaration",vr=`#ifdef INSTANCES
120attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;
121#ifdef INSTANCESCOLOR
122attribute vec4 instanceColor;
123#endif
124#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
125uniform mat4 world;
126#endif
127#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
128attribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;
129#ifdef THIN_INSTANCES
130uniform mat4 previousWorld;
131#endif
132#endif
133#else
134#if !defined(WORLD_UBO)
135uniform mat4 world;
136#endif
137#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
138uniform mat4 previousWorld;
139#endif
140#endif
141`;y.IncludesShadersStore[wt]||(y.IncludesShadersStore[wt]=vr);const Ta={name:wt,shader:vr},Nt="prePassVertexDeclaration",Ir=`#ifdef PREPASS
142#ifdef PREPASS_LOCAL_POSITION
143varying vec3 vPosition;
144#endif
145#ifdef PREPASS_DEPTH
146varying vec3 vViewPos;
147#endif
148#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
149varying float vNormViewDepth;
150#endif
151#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
152uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
153#endif
154#endif
155`;y.IncludesShadersStore[Nt]||(y.IncludesShadersStore[Nt]=Ir);const Ca={name:Nt,shader:Ir},Bt="mainUVVaryingDeclaration",Sr=`#ifdef MAINUV{X}
156varying vec2 vMainUV{X};
157#endif
158`;y.IncludesShadersStore[Bt]||(y.IncludesShadersStore[Bt]=Sr);const Er={name:Bt,shader:Sr},Vt="samplerVertexDeclaration",Mr=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
159varying vec2 v_VARYINGNAME_UV;
160#endif
161`;y.IncludesShadersStore[Vt]||(y.IncludesShadersStore[Vt]=Mr);const Pa={name:Vt,shader:Mr},Ut="bumpVertexDeclaration",xr=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
162#if defined(TANGENT) && defined(NORMAL) 
163varying mat3 vTBN;
164#endif
165#endif
166`;y.IncludesShadersStore[Ut]||(y.IncludesShadersStore[Ut]=xr);const ya={name:Ut,shader:xr},Wt="clipPlaneVertexDeclaration",Dr=`#ifdef CLIPPLANE
167uniform vec4 vClipPlane;varying float fClipDistance;
168#endif
169#ifdef CLIPPLANE2
170uniform vec4 vClipPlane2;varying float fClipDistance2;
171#endif
172#ifdef CLIPPLANE3
173uniform vec4 vClipPlane3;varying float fClipDistance3;
174#endif
175#ifdef CLIPPLANE4
176uniform vec4 vClipPlane4;varying float fClipDistance4;
177#endif
178#ifdef CLIPPLANE5
179uniform vec4 vClipPlane5;varying float fClipDistance5;
180#endif
181#ifdef CLIPPLANE6
182uniform vec4 vClipPlane6;varying float fClipDistance6;
183#endif
184`;y.IncludesShadersStore[Wt]||(y.IncludesShadersStore[Wt]=Dr);
184const Ra={name:Wt,shader:Dr},kt="fogVertexDeclaration",Ar=`#ifdef FOG
185varying vec3 vFogDistance;
186#endif
187`;y.IncludesShadersStore[kt]||(y.IncludesShadersStore[kt]=Ar);const La={name:kt,shader:Ar},Xt="lightVxFragmentDeclaration",br=`#ifdef LIGHT{X}
188uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
189#ifdef SPECULARTERM
190uniform vec4 vLightSpecular{X};
191#else
192vec4 vLightSpecular{X}=vec4(0.);
193#endif
194#ifdef SHADOW{X}
195#ifdef SHADOWCSM{X}
196uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
197#elif defined(SHADOWCUBE{X})
198#else
199varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};
200#endif
201uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
202#endif
203#ifdef SPOTLIGHT{X}
204uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
205#elif defined(POINTLIGHT{X})
206uniform vec4 vLightFalloff{X};
207#elif defined(HEMILIGHT{X})
208uniform vec3 vLightGround{X};
209#endif
210#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
211uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X};
212#endif
213#endif
214`;y.IncludesShadersStore[Xt]||(y.IncludesShadersStore[Xt]=br);const Fa={name:Xt,shader:br},zt="lightVxUboDeclaration",Tr=`#ifdef LIGHT{X}
215uniform Light{X}
216{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
217#ifdef SPOTLIGHT{X}
218vec4 vLightDirection;vec4 vLightFalloff;
219#elif defined(POINTLIGHT{X})
220vec4 vLightFalloff;
221#elif defined(HEMILIGHT{X})
222vec3 vLightGround;
223#elif defined(CLUSTLIGHT{X})
224vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES];
225#endif
226#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
227vec4 vLightWidth;vec4 vLightHeight;
228#endif
229vec4 shadowsInfo;vec2 depthValues;} light{X};
230#ifdef SHADOW{X}
231#ifdef SHADOWCSM{X}
232uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
233#elif defined(SHADOWCUBE{X})
234#else
235varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};
236#endif
237#endif
238#endif
239`;y.IncludesShadersStore[zt]||(y.IncludesShadersStore[zt]=Tr);const Oa={name:zt,shader:Tr},Ht="morphTargetsVertexGlobalDeclaration",Cr=`#ifdef MORPHTARGETS
240uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
241#ifdef MORPHTARGETS_TEXTURE 
242uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)
243{ 
244#if defined(WEBGL2) || defined(WEBGPU)
245int textureWidth=int(morphTargetTextureInfo.y);int y=int(vertexIndex)/textureWidth;int x=int(vertexIndex) % textureWidth;return texelFetch(morphTargets,ivec3(x,y,int(morphTargetTextureIndices[targetIndex])),0).xyz;
246#else
247float 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;
248#endif
249}
250vec4 readVector4FromRawSampler(int targetIndex,float vertexIndex)
251{ 
252#if defined(WEBGL2) || defined(WEBGPU)
253int textureWidth=int(morphTargetTextureInfo.y);int y=int(vertexIndex)/textureWidth;int x=int(vertexIndex) % textureWidth;return texelFetch(morphTargets,ivec3(x,y,int(morphTargetTextureIndices[targetIndex])),0);
254#else
255float 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);
256#endif
257}
258#endif
259#endif
260`;y.IncludesShadersStore[Ht]||(y.IncludesShadersStore[Ht]=Cr);const wa={name:Ht,shader:Cr},Gt="morphTargetsVertexDeclaration",Pr=`#ifdef MORPHTARGETS
261#ifndef MORPHTARGETS_TEXTURE
262#ifdef MORPHTARGETS_POSITION
263attribute vec3 position{X};
264#endif
265#ifdef MORPHTARGETS_NORMAL
266attribute vec3 normal{X};
267#endif
268#ifdef MORPHTARGETS_TANGENT
269attribute vec3 tangent{X};
270#endif
271#ifdef MORPHTARGETS_UV
272attribute vec2 uv_{X};
273#endif
274#ifdef MORPHTARGETS_UV2
275attribute vec2 uv2_{X};
276#endif
277#ifdef MORPHTARGETS_COLOR
278attribute vec4 color{X};
279#endif
280#elif {X}==0
281uniform float morphTargetCount;
282#endif
283#endif
284`;y.IncludesShadersStore[Gt]||(y.IncludesShadersStore[Gt]=Pr);const Na={name:Gt,shader:Pr},Kt="logDepthDeclaration",yr=`#ifdef LOGARITHMICDEPTH
285uniform float logarithmicDepthConstant;varying float vFragmentDepth;
286#endif
287`;y.IncludesShadersStore[Kt]||(y.IncludesShadersStore[Kt]=yr);const Rr={name:Kt,shader:yr},Yt="morphTargetsVertexGlobal",Lr=`#ifdef MORPHTARGETS
288#ifdef MORPHTARGETS_TEXTURE
289float vertexID;
290#endif
291#endif
292`;y.IncludesShadersStore[Yt]||(y.IncludesShadersStore[Yt]=Lr);const Ba={name:Yt,shader:Lr},Zt="morphTargetsVertex",Fr=`#ifdef MORPHTARGETS
293#ifdef MORPHTARGETS_TEXTURE
294#if {X}==0
295for (int i=0; i<NUM_MORPH_INFLUENCERS; i++) {if (float(i)>=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;
296#ifdef MORPHTARGETS_POSITION
297positionUpdated+=(readVector3FromRawSampler(i,vertexID)-position)*morphTargetInfluences[i];
298#endif
299#ifdef MORPHTARGETTEXTURE_HASPOSITIONS
300vertexID+=1.0;
301#endif
302#ifdef MORPHTARGETS_NORMAL
303normalUpdated+=(readVector3FromRawSampler(i,vertexID) -normal)*morphTargetInfluences[i];
304#endif
305#ifdef MORPHTARGETTEXTURE_HASNORMALS
306vertexID+=1.0;
307#endif
308#ifdef MORPHTARGETS_UV
309uvUpdated+=(readVector3FromRawSampler(i,vertexID).xy-uv)*morphTargetInfluences[i];
310#endif
311#ifdef MORPHTARGETTEXTURE_HASUVS
312vertexID+=1.0;
313#endif
314#ifdef MORPHTARGETS_TANGENT
315tangentUpdated.xyz+=(readVector3FromRawSampler(i,vertexID) -tangent.xyz)*morphTargetInfluences[i];
316#endif
317#ifdef MORPHTARGETTEXTURE_HASTANGENTS
318vertexID+=1.0;
319#endif
320#ifdef MORPHTARGETS_UV2
321uv2Updated+=(readVector3FromRawSampler(i,vertexID).xy-uv2)*morphTargetInfluences[i];
322#endif
323#ifdef MORPHTARGETTEXTURE_HASUV2S
324vertexID+=1.0;
325#endif
326#ifdef MORPHTARGETS_COLOR
327colorUpdated+=(readVector4FromRawSampler(i,vertexID)-color)*morphTargetInfluences[i];
328#endif
329}
330#endif
331#else
332#ifdef MORPHTARGETS_POSITION
333positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
334#endif
335#ifdef MORPHTARGETS_NORMAL
336normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
337#endif
338#ifdef MORPHTARGETS_TANGENT
339tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
340#endif
341#ifdef MORPHTARGETS_UV
342uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
343#endif
344#ifdef MORPHTARGETS_UV2
345uv2Updated+=(uv2_{X}-uv2)*morphTargetInfluences[{X}];
346#endif
347#ifdef MORPHTARGETS_COLOR
348colorUpdated+=(color{X}-color)*morphTargetInfluences[{X}];
349#endif
350#endif
351#endif
352`;y.IncludesShadersStore[Zt]||(y.IncludesShadersStore[Zt]=Fr);const Va={name:Zt,shader:Fr},$t="instancesVertex",Or=`#ifdef INSTANCES
353mat4 finalWorld=mat4(world0,world1,world2,world3);
354#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
355mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,
356previousWorld2,previousWorld3);
357#endif
358#ifdef THIN_INSTANCES
359finalWorld=world*finalWorld;
360#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
361finalPreviousWorld=previousWorld*finalPreviousWorld;
362#endif
363#endif
364#else
365mat4 finalWorld=world;
366#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)
367mat4 finalPreviousWorld=previousWorld;
368#endif
369#endif
370`;y.IncludesShadersStore[$t]||(y.IncludesShadersStore[$t]=Or);const Ua={name:$t,shader:Or},qt="bonesVertex",wr=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
371#if NUM_BONE_INFLUENCERS>0
372mat4 influence;
373#ifdef BONETEXTURE
374influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
375#if NUM_BONE_INFLUENCERS>1
376influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
377#endif
378#if NUM_BONE_INFLUENCERS>2
379influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
380#endif
381#if NUM_BONE_INFLUENCERS>3
382influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
383#endif
384#if NUM_BONE_INFLUENCERS>4
385influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
386#endif
387#if NUM_BONE_INFLUENCERS>5
388influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
389#endif
390#if NUM_BONE_INFLUENCERS>6
391influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
392#endif
393#if NUM_BONE_INFLUENCERS>7
394influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
395#endif
396#else
397influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
398#if NUM_BONE_INFLUENCERS>1
399influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
400#endif
401#if NUM_BONE_INFLUENCERS>2
402influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
403#endif
404#if NUM_BONE_INFLUENCERS>3
405influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
406#endif
407#if NUM_BONE_INFLUENCERS>4
408influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
409#endif
410#if NUM_BONE_INFLUENCERS>5
411influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
412#endif
413#if NUM_BONE_INFLUENCERS>6
414influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
415#endif
416#if NUM_BONE_INFLUENCERS>7
417influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
418#endif
419#endif
420finalWorld=finalWorld*influence;
421#endif
422#endif
423`;y.IncludesShadersStore[qt]||(y.IncludesShadersStore[qt]=wr);const Wa={name:qt,shader:wr},jt="bakedVertexAnimation",Nr=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
424{
425#ifdef INSTANCES
426#define BVASNAME bakedVertexAnimationSettingsInstanced
427#else
428#define BVASNAME bakedVertexAnimationSettings
429#endif
430float 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];
431#if NUM_BONE_INFLUENCERS>1
432VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
433#endif
434#if NUM_BONE_INFLUENCERS>2
435VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
436#endif
437#if NUM_BONE_INFLUENCERS>3
438VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
439#endif
440#if NUM_BONE_INFLUENCERS>4
441VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
442#endif
443#if NUM_BONE_INFLUENCERS>5
444VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
445#endif
446#if NUM_BONE_INFLUENCERS>6
447VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
448#endif
449#if NUM_BONE_INFLUENCERS>7
450VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
451#endif
452finalWorld=finalWorld*VATInfluence;}
453#endif
454`;y.IncludesShadersStore[jt]||(y.IncludesShadersStore[jt]=Nr);const ka={name:jt,shader:Nr},Qt="prePassVertex",Br=`#ifdef PREPASS_DEPTH
455vViewPos=(view*worldPos).rgb;
456#endif
457#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
458vNormViewDepth=((view*worldPos).z-cameraInfo.x)/(cameraInfo.y-cameraInfo.x);
459#endif
460#ifdef PREPASS_LOCAL_POSITION
461vPosition=positionUpdated.xyz;
462#endif
463#if (defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED)
464vCurrentPosition=viewProjection*worldPos;
465#if NUM_BONE_INFLUENCERS>0
466mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
467#if NUM_BONE_INFLUENCERS>1
468previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
469#endif 
470#if NUM_BONE_INFLUENCERS>2
471previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
472#endif 
473#if NUM_BONE_INFLUENCERS>3
474previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
475#endif
476#if NUM_BONE_INFLUENCERS>4
477previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
478#endif 
479#if NUM_BONE_INFLUENCERS>5
480previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
481#endif 
482#if NUM_BONE_INFLUENCERS>6
483previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
484#endif 
485#if NUM_BONE_INFLUENCERS>7
486previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
487#endif
488vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,
4881.0);
489#else
490vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
491#endif
492#endif
493`;y.IncludesShadersStore[Qt]||(y.IncludesShadersStore[Qt]=Br);const Xa={name:Qt,shader:Br},Jt="uvVariableDeclaration",Vr=`#if !defined(UV{X}) && defined(MAINUV{X})
494vec2 uv{X}=vec2(0.,0.);
495#endif
496#ifdef MAINUV{X}
497vMainUV{X}=uv{X};
498#endif
499`;y.IncludesShadersStore[Jt]||(y.IncludesShadersStore[Jt]=Vr);const za={name:Jt,shader:Vr},ei="samplerVertexImplementation",Ur=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
500if (v_INFONAME_==0.)
501{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));}
502#ifdef UV2
503else if (v_INFONAME_==1.)
504{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2Updated,1.0,0.0));}
505#endif
506#ifdef UV3
507else if (v_INFONAME_==2.)
508{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));}
509#endif
510#ifdef UV4
511else if (v_INFONAME_==3.)
512{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));}
513#endif
514#ifdef UV5
515else if (v_INFONAME_==4.)
516{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));}
517#endif
518#ifdef UV6
519else if (v_INFONAME_==5.)
520{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));}
521#endif
522#endif
523`;y.IncludesShadersStore[ei]||(y.IncludesShadersStore[ei]=Ur);const Ha={name:ei,shader:Ur},ti="bumpVertex",Wr=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
524#if defined(TANGENT) && defined(NORMAL)
525vec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
526#endif
527#endif
528`;y.IncludesShadersStore[ti]||(y.IncludesShadersStore[ti]=Wr);const Ga={name:ti,shader:Wr},ii="clipPlaneVertex",kr=`#ifdef CLIPPLANE
529fClipDistance=dot(worldPos,vClipPlane);
530#endif
531#ifdef CLIPPLANE2
532fClipDistance2=dot(worldPos,vClipPlane2);
533#endif
534#ifdef CLIPPLANE3
535fClipDistance3=dot(worldPos,vClipPlane3);
536#endif
537#ifdef CLIPPLANE4
538fClipDistance4=dot(worldPos,vClipPlane4);
539#endif
540#ifdef CLIPPLANE5
541fClipDistance5=dot(worldPos,vClipPlane5);
542#endif
543#ifdef CLIPPLANE6
544fClipDistance6=dot(worldPos,vClipPlane6);
545#endif
546`;y.IncludesShadersStore[ii]||(y.IncludesShadersStore[ii]=kr);const Ka={name:ii,shader:kr},si="fogVertex",Xr=`#ifdef FOG
547vFogDistance=(view*worldPos).xyz;
548#endif
549`;y.IncludesShadersStore[si]||(y.IncludesShadersStore[si]=Xr);const Ya={name:si,shader:Xr},ri="shadowsVertex",zr=`#ifdef SHADOWS
550#if defined(SHADOWCSM{X})
551vPositionFromCamera{X}=view*worldPos;for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {vPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;
552#ifdef USE_REVERSE_DEPTHBUFFER
553vDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
554#else
555vDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
556#endif
557}
558#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})
559vPositionFromLight{X}=lightMatrix{X}*worldPos;
560#ifdef USE_REVERSE_DEPTHBUFFER
561vDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
562#else
563vDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
564#endif
565#endif
566#endif
567`;y.IncludesShadersStore[ri]||(y.IncludesShadersStore[ri]=zr);const Za={name:ri,shader:zr},ni="vertexColorMixing",Hr=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
568vColor=vec4(1.0);
569#ifdef VERTEXCOLOR
570#ifdef VERTEXALPHA
571vColor*=colorUpdated;
572#else
573vColor.rgb*=colorUpdated.rgb;
574#endif
575#endif
576#ifdef INSTANCESCOLOR
577vColor*=instanceColor;
578#endif
579#endif
580`;y.IncludesShadersStore[ni]||(y.IncludesShadersStore[ni]=Hr);const $a={name:ni,shader:Hr},ai="pointCloudVertex",Gr=`#if defined(POINTSIZE) && !defined(WEBGPU)
581gl_PointSize=pointSize;
582#endif
583`;y.IncludesShadersStore[ai]||(y.IncludesShadersStore[ai]=Gr);const qa={name:ai,shader:Gr},oi="logDepthVertex",Kr=`#ifdef LOGARITHMICDEPTH
584vFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
585#endif
586`;y.IncludesShadersStore[oi]||(y.IncludesShadersStore[oi]=Kr);const ja={name:oi,shader:Kr},li="defaultVertexShader",Yr=`#define CUSTOM_VERTEX_EXTENSION
587#include<__decl__defaultVertex>
588#define CUSTOM_VERTEX_BEGIN
589attribute vec3 position;
590#ifdef NORMAL
591attribute vec3 normal;
592#endif
593#ifdef TANGENT
594attribute vec4 tangent;
595#endif
596#ifdef UV1
597attribute vec2 uv;
598#endif
599#include<uvAttributeDeclaration>[2..7]
600#ifdef VERTEXCOLOR
601attribute vec4 color;
602#endif
603#include<helperFunctions>
604#include<bonesDeclaration>
605#include<bakedVertexAnimationDeclaration>
606#include<instancesDeclaration>
607#include<prePassVertexDeclaration>
608#include<mainUVVaryingDeclaration>
608[1..7]
609#include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)
610#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
611#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
612#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
613#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
614#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
615#if defined(SPECULARTERM)
616#include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)
617#endif
618#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
619#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
620varying vec3 vPositionW;
621#ifdef NORMAL
622varying vec3 vNormalW;
623#endif
624#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
625varying vec4 vColor;
626#endif
627#include<bumpVertexDeclaration>
628#include<clipPlaneVertexDeclaration>
629#include<fogVertexDeclaration>
630#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
631#include<morphTargetsVertexGlobalDeclaration>
632#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
633#ifdef REFLECTIONMAP_SKYBOX
634varying vec3 vPositionUVW;
635#endif
636#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
637varying vec3 vDirectionW;
638#endif
639#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
640varying float vViewDepth;
641#endif
642#include<logDepthDeclaration>
643#define CUSTOM_VERTEX_DEFINITIONS
644void main(void) {
645#define CUSTOM_VERTEX_MAIN_BEGIN
646vec3 positionUpdated=position;
647#ifdef NORMAL
648vec3 normalUpdated=normal;
649#endif
650#ifdef TANGENT
651vec4 tangentUpdated=tangent;
652#endif
653#ifdef UV1
654vec2 uvUpdated=uv;
655#endif
656#ifdef UV2
657vec2 uv2Updated=uv2;
658#endif
659#ifdef VERTEXCOLOR
660vec4 colorUpdated=color;
661#endif
662#include<morphTargetsVertexGlobal>
663#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
664#ifdef REFLECTIONMAP_SKYBOX
665vPositionUVW=positionUpdated;
666#endif
667#define CUSTOM_VERTEX_UPDATE_POSITION
668#define CUSTOM_VERTEX_UPDATE_NORMAL
669#include<instancesVertex>
670#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED)
671vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
672#endif
673#include<bonesVertex>
674#include<bakedVertexAnimation>
675vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
676#ifdef NORMAL
677mat3 normalWorld=mat3(finalWorld);
678#if defined(INSTANCES) && defined(THIN_INSTANCES)
679vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW);
680#else
681#ifdef NONUNIFORMSCALING
682normalWorld=transposeMat3(inverseMat3(normalWorld));
683#endif
684vNormalW=normalize(normalWorld*normalUpdated);
685#endif
686#endif
687#define CUSTOM_VERTEX_UPDATE_WORLDPOS
688#ifdef MULTIVIEW
689if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
690#else
691gl_Position=viewProjection*worldPos;
692#endif
693vPositionW=vec3(worldPos);
694#ifdef PREPASS
695#include<prePassVertex>
696#endif
697#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
698vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
699#endif
700#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
701#ifdef RIGHT_HANDED
702vViewDepth=-(view*worldPos).z;
703#else
704vViewDepth=(view*worldPos).z;
705#endif
706#endif
707#ifndef UV1
708vec2 uvUpdated=vec2(0.,0.);
709#endif
710#ifndef UV2
711vec2 uv2Updated=vec2(0.,0.);
712#endif
713#ifdef MAINUV1
714vMainUV1=uvUpdated;
715#endif
716#ifdef MAINUV2
717vMainUV2=uv2Updated;
718#endif
719#include<uvVariableDeclaration>[3..7]
720#include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)
721#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
722#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
723#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
724#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
725#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
726#if defined(SPECULARTERM)
727#include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)
728#endif
729#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
730#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
731#include<bumpVertex>
732#include<clipPlaneVertex>
733#include<fogVertex>
734#include<shadowsVertex>[0..maxSimultaneousLights]
735#include<vertexColorMixing>
736#include<pointCloudVertex>
737#include<logDepthVertex>
738#define CUSTOM_VERTEX_MAIN_END
739}
740`;y.ShadersStore[li]||(y.ShadersStore[li]=Yr);const Qa=[Ma,xa,hr,dr,mr,Da,er,Aa,ba,Ta,Ca,Er,Pa,ya,Ra,La,Fa,Oa,wa,Na,Rr,Ba,Va,Ua,Wa,ka,Xa,za,Ha,Ga,Ka,Ya,Za,$a,qa,ja];for(const o of Qa)y.IncludesShadersStore[o.name]||(y.IncludesShadersStore[o.name]=o.shader);const Ja={name:li,shader:Yr},bl=Object.freeze(Object.defineProperty({__proto__:null,defaultVertexShader:Ja},Symbol.toStringTag,{value:"Module"})),ci="decalFragmentDeclaration",Zr=`#ifdef DECAL
741uniform vec4 vDecalInfos;
742#endif
743`;y.IncludesShadersStore[ci]||(y.IncludesShadersStore[ci]=Zr);const eo={name:ci,shader:Zr},hi="defaultFragmentDeclaration",$r=`uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility;
744#ifdef DIFFUSE
745uniform vec2 vDiffuseInfos;
746#endif
747#ifdef AMBIENT
748uniform vec2 vAmbientInfos;
749#endif
750#ifdef OPACITY 
751uniform vec2 vOpacityInfos;
752#endif
753#ifdef EMISSIVE
754uniform vec2 vEmissiveInfos;
755#endif
756#ifdef LIGHTMAP
757uniform vec2 vLightmapInfos;
758#endif
759#ifdef BUMP
760uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
761#endif
762#ifdef ALPHATEST
763uniform float alphaCutOff;
764#endif
765#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)
766uniform mat4 view;
767#endif
768#ifdef REFRACTION
769uniform vec4 vRefractionInfos;
770#ifndef REFRACTIONMAP_3D
771uniform mat4 refractionMatrix;
772#endif
773#ifdef REFRACTIONFRESNEL
774uniform vec4 refractionLeftColor;uniform vec4 refractionRightColor;
775#endif
776#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)
777uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; 
778#endif
779#endif
780#if defined(SPECULAR) && defined(SPECULARTERM)
781uniform vec2 vSpecularInfos;
782#endif
783#ifdef DIFFUSEFRESNEL
784uniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor;
785#endif
786#ifdef OPACITYFRESNEL
787uniform vec4 opacityParts;
788#endif
789#ifdef EMISSIVEFRESNEL
790uniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor;
791#endif
792#if defined(REFLECTION) || (defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED))
793uniform vec2 vReflectionInfos;
794#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
795uniform mat4 reflectionMatrix;
796#endif
797#ifndef REFLECTIONMAP_SKYBOX
798#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
799uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; 
800#endif
801#endif
802#ifdef REFLECTIONFRESNEL
803uniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor;
804#endif
805#endif
806#ifdef DETAIL
807uniform vec4 vDetailInfos;
808#endif
809#include<decalFragmentDeclaration>
810#if TEXTURE_REPETITION_MODE>0
811uniform vec4 vTextureRepetitionHexTilingParams;
812#endif
813#define ADDITIONAL_FRAGMENT_DECLARATION
814`;y.IncludesShadersStore[hi]||(y.IncludesShadersStore[hi]=$r);const to={name:hi,shader:$r},fi="prePassDeclaration",qr=`#ifdef PREPASS
815#extension GL_EXT_draw_buffers : require
816layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;
817#ifdef PREPASS_LOCAL_POSITION
818varying highp vec3 vPosition;
819#endif
820#ifdef PREPASS_DEPTH
821varying highp vec3 vViewPos;
822#endif
823#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
824varying highp float vNormViewDepth;
825#endif
826#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
827varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;
828#endif
829#endif
830`;y.IncludesShadersStore[fi]||(y.IncludesShadersStore[fi]=qr);const io={name:fi,shader:qr},di="oitDeclaration",jr=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
831#extension GL_EXT_draw_buffers : require
832layout(location=0) out vec2 depth; 
833layout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;
834#define MAX_DEPTH 99999.0
835highp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;
836#endif
837`;y.IncludesShadersStore[di]||(y.IncludesShadersStore[di]=jr);const so={name:di,shader:jr},ui="lightFragmentDeclaration",Qr=`#ifdef LIGHT{X}
838uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
839#ifdef SPECULARTERM
840uniform vec4 vLightSpecular{X};
841#else
842vec4 vLightSpecular{X}=vec4(0.);
843#endif
844#ifdef SHADOW{X}
845#ifdef SHADOWCSM{X}
846uniform 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};
847#if defined(SHADOWPCSS{X})
848uniform 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};
849#elif defined(SHADOWPCF{X})
850uniform highp sampler2DArrayShadow shadowTexture{X};
851#else
852uniform highp sampler2DArray shadowTexture{X};
853#endif
854#ifdef SHADOWCSMDEBUG{X}
855const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
856(
857vec3 ( 1.5,0.0,0.0 ),
858vec3 ( 0.0,1.5,0.0 ),
859vec3 ( 0.0,0.0,5.5 ),
860vec3 ( 1.5,0.0,5.5 ),
861vec3 ( 1.5,1.5,0.0 ),
862vec3 ( 1.0,1.0,1.0 ),
863vec3 ( 0.0,1.0,5.5 ),
864vec3 ( 0.5,3.5,0.75 )
865);vec3 shadowDebug{X};
866#endif
867#ifdef SHADOWCSMUSESHADOWMAXZ{X}
868int index{X}=-1;
869#else
870int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
871#endif
872float diff{X}=0.;
873#elif defined(SHADOWCUBE{X})
874uniform samplerCube shadowTexture{X};
875#else
876varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
877#if defined(SHADOWPCSS{X})
878uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
879#elif defined(SHADOWPCF{X})
880uniform highp sampler2DShadow shadowTexture{X};
881#else
882uniform sampler2D shadowTexture{X};
883#endif
884uniform mat4 lightMatrix{X};
885#endif
886uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
887#endif
888#ifdef SPOTLIGHT{X}
889uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
890#elif defined(POINTLIGHT{X})
891uniform vec4 vLightFalloff{X};
892#elif defined(HEMILIGHT{X})
893uniform vec3 vLightGround{X};
894#endif
895#ifdef AREALIGHT{X}
896uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X};
897#ifdef RECTAREALIGHTEMISSIONTEXTURE{X}
898uniform sampler2D rectAreaLightEmissionTexture{X};
899#endif
900#endif
901#ifdef IESLIGHTTEXTURE{X}
902uniform sampler2D iesLightTexture{X};
903#endif
904#ifdef PROJECTEDLIGHTTEXTURE{X}
905uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
906#endif
907#ifdef CLUSTLIGHT{X}
908uniform vec2 vSliceData{X};uniform vec2 vSliceRanges{X}[CLUSTLIGHT_SLICES];uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X};
909#endif
910#endif
911`;y.IncludesShadersStore[ui]||(y.IncludesShadersStore[ui]=Qr);const ro={name:ui,shader:Qr},mi="lightUboDeclaration",Jr=`#ifdef LIGHT{X}
912uniform Light{X}
913{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
914#ifdef SPOTLIGHT{X}
915vec4 vLightDirection;vec4 vLightFalloff;
916#elif defined(POINTLIGHT{X})
917vec4 vLightFalloff;
918#elif defined(HEMILIGHT{X})
919vec3 vLightGround;
920#elif defined(CLUSTLIGHT{X})
921vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES];
922#endif
923#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
924vec4 vLightWidth;vec4 vLightHeight;
925#endif
926vec4 shadowsInfo;vec2 depthValues;} light{X};
927#ifdef IESLIGHTTEXTURE{X}
928uniform sampler2D iesLightTexture{X};
929#endif
930#ifdef RECTAREALIGHTEMISSIONTEXTURE{X}
931uniform sampler2D rectAreaLightEmissionTexture{X};
932#endif
933#ifdef PROJECTEDLIGHTTEXTURE{X}
934uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
935#endif
936#ifdef CLUSTLIGHT{X}
937uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X};
938#endif
939#ifdef SHADOW{X}
940#ifdef SHADOWCSM{X}
941uniform 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};
942#if defined(SHADOWPCSS{X})
943uniform 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};
944#elif defined(SHADOWPCF{X})
945uniform highp sampler2DArrayShadow shadowTexture{X};
946#else
947uniform highp sampler2DArray shadowTexture{X};
948#endif
949#ifdef SHADOWCSMDEBUG{X}
950const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
951(
952vec3 ( 1.5,0.0,0.0 ),
953vec3 ( 0.0,1.5,0.0 ),
954vec3 ( 0.0,0.0,5.5 ),
955vec3 ( 1.5,0.0,5.5 ),
956vec3 ( 1.5,1.5,0.0 ),
957vec3 ( 1.0,1.0,1.0 ),
958vec3 ( 0.0,1.0,5.5 ),
959vec3 ( 0.5,3.5,0.75 )
960);vec3 shadowDebug{X};
961#endif
962#ifdef SHADOWCSMUSESHADOWMAXZ{X}
963int index{X}=-1;
964#else
965int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
966#endif
967float diff{X}=0.;
968#elif defined(SHADOWCUBE{X})
969uniform samplerCube shadowTexture{X}; 
970#else
971varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
972#if defined(SHADOWPCSS{X})
973uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
974#elif defined(SHADOWPCF{X})
975uniform highp sampler2DShadow shadowTexture{X};
976#else
977uniform sampler2D shadowTexture{X};
978#endif
979uniform mat4 lightMatrix{X};
980#endif
981#endif
982#endif
983`;y.IncludesShadersStore[mi]||(y.IncludesShadersStore[mi]=Jr);const no={name:mi,shader:Jr},pi="ltcHelperFunctions",en=`vec2 LTCUv( const in vec3 N,const in vec3 V,const in float roughness ) {const float LUTSIZE=64.0;const float LUTSCALE=( LUTSIZE-1.0 )/LUTSIZE;const float LUTBIAS=0.5/LUTSIZE;float dotNV=saturate( dot( N,V ) );vec2 uv=vec2( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;}
984float LTCClippedSphereFormFactor( const in vec3 f ) {float l=length( f );return max( ( l*l+f.z )/( l+1.0 ),0.0 );}
985vec3 LTCEdgeVectorFormFactor( const in vec3 v1,const in vec3 v2 ) {float x=dot( v1,v2 );float y=abs( x );float a=0.8543985+( 0.4965155+0.0145206*y )*y;float b=3.4175940+( 4.1616724+y )*y;float v=a/b;float thetaSintheta=0.0;if( x>0.0 )
986{thetaSintheta=v;}
987else
988{thetaSintheta=0.5*inversesqrt( max( 1.0-x*x,1e-7 ) )-v;}
989return cross( v1,v2 )*thetaSintheta;}
990vec3 LTCEvaluate( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ] ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 ); 
991mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result );}
992vec3 FetchDiffuseFilteredTexture(sampler2D texLightFiltered,vec3 p1_,vec3 p2_,vec3 p3_,vec3 p4_)
993{vec3 V1=p2_-p1_;vec3 V2=p4_-p1_;vec3 planeOrtho=(cross(V1,V2));float planeAreaSquared=dot(planeOrtho,planeOrtho);float planeDistxPlaneArea=dot(planeOrtho,p1_);vec3 P=planeDistxPlaneArea*planeOrtho/planeAreaSquared-p1_;float dot_V1_V2=dot(V1,V2);float inv_dot_V1_V1=1.0/dot(V1,V1);vec3 V2_=V2-V1*dot_V1_V2*inv_dot_V1_V1;vec2 Puv;Puv.y=dot(V2_,P)/dot(V2_,V2_);Puv.x=dot(V1,P)*inv_dot_V1_V1-dot_V1_V2*inv_dot_V1_V1*Puv.y ;float d=abs(planeDistxPlaneArea)/pow(planeAreaSquared,0.75);float sampleLOD=log(2048.0*d)/log(3.0);vec2 sampleUV=vec2(0.125,0.125)+(vec2(0.75)*Puv);sampleUV.x=1.0-sampleUV.x;return texture2DLodEXT(texLightFiltered,sampleUV,sampleLOD).rgb;}
994vec3 LTCEvaluateWithEmission( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ],const in sampler2D texFilteredMap ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 ); 
995mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );vec3 textureLight=FetchDiffuseFilteredTexture(texFilteredMap,coords[0],coords[1],coords[2],coords[3]);coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result )*textureLight;}
996struct areaLightData
997{vec3 Diffuse;vec3 Specular;vec4 Fresnel;};
998#define inline
999areaLightData computeAreaLightSpecularDiffuseFresnel(const in sampler2D ltc1,const in sampler2D ltc2,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness) 
1000{areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight; 
1001rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;
1001rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight;
1002#ifdef SPECULARTERM
1003vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3(
1004vec3( t1.x,0,t1.y ),
1005vec3( 0,1, 0 ),
1006vec3( t1.z,0,t1.w )
1007);result.Specular=LTCEvaluate( normal,viewDir,position,mInv,rectCoords );result.Fresnel=t2;
1008#endif
1009result.Diffuse=LTCEvaluate( normal,viewDir,position,mat3( 1.0 ),rectCoords );return result;}
1010#define inline
1011areaLightData computeAreaLightSpecularDiffuseFresnelWithEmission(const in sampler2D ltc1,const in sampler2D ltc2,const in sampler2D texFilteredMap,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness) 
1012{areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight; 
1013rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight;
1014#ifdef SPECULARTERM
1015vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3(
1016vec3( t1.x,0,t1.y ),
1017vec3( 0,1, 0 ),
1018vec3( t1.z,0,t1.w )
1019);result.Specular=LTCEvaluateWithEmission( normal,viewDir,position,mInv,rectCoords,texFilteredMap );result.Fresnel=t2;
1020#endif
1021result.Diffuse=LTCEvaluateWithEmission( normal,viewDir,position,mat3( 1.0 ),rectCoords,texFilteredMap );return result;}`;y.IncludesShadersStore[pi]||(y.IncludesShadersStore[pi]=en);const ao={name:pi,shader:en},gi="clusteredLightingFunctions",tn=`struct ClusteredLight {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;vec4 vLightDirection;vec4 vLightFalloff;};
1022#define inline
1023ClusteredLight getClusteredLight(sampler2D lightDataTexture,int index) {return ClusteredLight(
1024texelFetch(lightDataTexture,ivec2(0,index),0),
1025texelFetch(lightDataTexture,ivec2(1,index),0),
1026texelFetch(lightDataTexture,ivec2(2,index),0),
1027texelFetch(lightDataTexture,ivec2(3,index),0),
1028texelFetch(lightDataTexture,ivec2(4,index),0)
1029);}
1030int getClusteredSliceIndex(vec2 sliceData,float viewDepth) {return int(log(viewDepth)*sliceData.x+sliceData.y);}
1031`;y.IncludesShadersStore[gi]||(y.IncludesShadersStore[gi]=tn);const oo={name:gi,shader:tn},_i="lightsFragmentFunctions",sn=`struct lightingInfo
1032{vec3 diffuse;
1033#ifdef SPECULARTERM
1034vec3 specular;
1035#endif
1036#ifdef NDOTL
1037float ndl;
1038#endif
1039};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.)
1040{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
1041else
1042{lightVectorW=normalize(-lightData.xyz);}
1043float ndl=max(0.,dot(vNormal,lightVectorW));
1044#ifdef NDOTL
1045result.ndl=ndl;
1046#endif
1047result.diffuse=ndl*diffuseColor*attenuation;
1048#ifdef SPECULARTERM
1049vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
1050#endif
1051return result;}
1052float getAttenuation(float cosAngle,float exponent) {return max(0.,pow(cosAngle,exponent));}
1053float getIESAttenuation(float cosAngle,sampler2D iesLightSampler) {float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;}
1054lightingInfo basicSpotLighting(vec3 viewDirectionW,vec3 lightVectorW,vec3 vNormal,float attenuation,vec3 diffuseColor,vec3 specularColor,float glossiness) {lightingInfo result; 
1055float ndl=max(0.,dot(vNormal,lightVectorW));
1056#ifdef NDOTL
1057result.ndl=ndl;
1058#endif
1059result.diffuse=ndl*diffuseColor*attenuation;
1060#ifdef SPECULARTERM
1061vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
1062#endif
1063return result;}
1064lightingInfo computeIESSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness,sampler2D iesLightSampler) { 
1065vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float dotProduct=dot(lightDirection.xyz,-lightVectorW);float cosAngle=max(0.,dotProduct);
1065if (cosAngle>=lightDirection.w)
1066{ 
1067attenuation*=getIESAttenuation(dotProduct,iesLightSampler);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
1068lightingInfo result;result.diffuse=vec3(0.);
1069#ifdef SPECULARTERM
1070result.specular=vec3(0.);
1071#endif
1072#ifdef NDOTL
1073result.ndl=0.;
1074#endif
1075return result;}
1076lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {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)
1077{ 
1078attenuation*=getAttenuation(cosAngle,lightData.w);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
1079lightingInfo result;result.diffuse=vec3(0.);
1080#ifdef SPECULARTERM
1081result.specular=vec3(0.);
1082#endif
1083#ifdef NDOTL
1084result.ndl=0.;
1085#endif
1086return result;}
1087lightingInfo 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;
1088#ifdef NDOTL
1089result.ndl=ndl;
1090#endif
1091result.diffuse=mix(groundColor,diffuseColor,ndl);
1092#ifdef SPECULARTERM
1093vec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
1094#endif
1095return result;}
1096#define inline
1097vec3 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;}
1098#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1099#include<ltcHelperFunctions>
1100uniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler;
1101#define inline
1102lightingInfo computeAreaLighting(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness) 
1103{lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);
1104#ifdef SPECULARTERM
1105vec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;
1106#endif
1107result.diffuse+=diffuseColor*data.Diffuse;return result;}
1108lightingInfo computeAreaLightingWithTexture(sampler2D ltc1,sampler2D ltc2,sampler2D emissionTexture,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness) 
1109{lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc2,emissionTexture,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);
1110#ifdef SPECULARTERM
1111vec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;
1112#endif
1113result.diffuse+=diffuseColor*data.Diffuse;return result;}
1114#endif
1115#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1116#include<clusteredLightingFunctions>
1117#define inline
1118lightingInfo computeClusteredLighting(
1119sampler2D lightDataTexture,
1120sampler2D tileMaskTexture,
1121vec3 viewDirectionW,
1122vec3 vNormal,
1123vec4 lightData,
1124ivec2 sliceRange,
1125float glossiness
1126) {lightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);lightingInfo info;if (light.vLightDirection.w<0.0) {info=computeLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} else {info=computeSpotLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDirection,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);}
1127result.diffuse+=info.diffuse;
1128#ifdef SPECULARTERM
1129result.specular+=info.specular;
1130#endif
1131}
1132batchOffset+=CLUSTLIGHT_BATCH;}
1133return result;}
1134#endif
1135`;y.IncludesShadersStore[_i]||(y.IncludesShadersStore[_i]=sn);const lo={name:_i,shader:sn},vi="shadowsFragmentFunctions",rn
vendor: 8,264 bytes, lines 1135-1248
1135=`#ifdef SHADOWS
1136#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
1137#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
1138#else
1139#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
1140#endif
1141#ifndef SHADOWFLOAT
1142float unpack(vec4 color)
1143{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);}
1144#endif
1145float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
1146{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
1147#define inline
1148float computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
1149{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;
1150#ifndef SHADOWFLOAT
1151float shadow=unpack(textureCube(shadowSampler,directionToLight));
1152#else
1153float shadow=textureCube(shadowSampler,directionToLight).x;
1154#endif
1155return depth>shadow ? darkness : 1.0;}
1156#define inline
1157float computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
1158{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);
1159#ifndef SHADOWFLOAT
1160if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;
1161#else
1162if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;
1163#endif
1164return min(1.0,visibility+darkness);}
1165#define inline
1166float computeShadowWithESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
1167{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
1168#ifndef SHADOWFLOAT
1169float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
1170#else
1171float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
1172#endif
1173float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
1174#define inline
1175float computeShadowWithCloseESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
1176{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
1177#ifndef SHADOWFLOAT
1178float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
1179#else
1180float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
1181#endif
1182float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
1183#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
1184#define inline
1185float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
1186{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);vec3 uvLayer=vec3(uv.x,uv.y,layer);float shadowPixelDepth=clamp(depthMetric,0.,1.0);
1187#ifndef SHADOWFLOAT
1188float shadow=unpack(texture2D(shadowSampler,uvLayer));
1189#else
1190float shadow=texture2D(shadowSampler,uvLayer).x;
1191#endif
1192return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}
1193#endif
1194#define inline
1195float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
1196{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)
1197{return 1.0;}
1198else
1199{float shadowPixelDepth=clamp(depthMetric,0.,1.0);
1200#ifndef SHADOWFLOAT
1201float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
1202#else
1203float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;
1204#endif
1205return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}
1206#define inline
1207float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
1208{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)
1209{return 1.0;}
1210else
1211{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);
1212#ifndef SHADOWFLOAT
1213if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;
1214#else
1215if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;
1216#endif
1217return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
1218#define inline
1219float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
1220{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)
1221{return 1.0;}
1222else
1223{float shadowPixelDepth=clamp(depthMetric,0.,1.0);
1224#ifndef SHADOWFLOAT
1225float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
1226#else
1227float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
1228#endif
1229float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
1230#define inline
1231float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
1232{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)
1233{return 1.0;}
1234else
1235{float shadowPixelDepth=clamp(depthMetric,0.,1.0); 
1236#ifndef SHADOWFLOAT
1237float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
1238#else
1239float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
1240#endif
1241float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
1242#ifdef IS_NDC_HALF_ZRANGE
1243#define ZINCLIP clipSpace.z
1244#else
1245#define ZINCLIP uvDepth.z
1246#endif
1247#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
1248#define 
1248SMALLEST_ABOVE_ZERO 1.1754943508e-38
1249#define GREATEST_LESS_THAN_ONE 0.99999994
1250#define DISABLE_UNIFORMITY_ANALYSIS
1251#define inline
1252float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
1253{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
1254#ifdef USE_REVERSE_DEPTHBUFFER
1255uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
1256#else
1257uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
1258#endif
1259vec4 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);}
1260#define inline
1261float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
1262{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
1263#ifdef USE_REVERSE_DEPTHBUFFER
1264uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
1265#else
1266uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
1267#endif
1268vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
1269uv+=0.5; 
1270vec2 st=fract(uv); 
1271vec2 base_uv=floor(uv)-0.5; 
1272base_uv*=shadowMapSizeAndInverse.y; 
1273vec2 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);}
1274#define inline
1275float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
1276{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
1277#ifdef USE_REVERSE_DEPTHBUFFER
1278uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
1279#else
1280uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
1281#endif
1282vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
1283uv+=0.5; 
1284vec2 st=fract(uv); 
1285vec2 base_uv=floor(uv)-0.5; 
1286base_uv*=shadowMapSizeAndInverse.y; 
1287vec2 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);}
1288#define inline
1289float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
1290{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
1291#define inline
1292float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
1293{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
1294uv+=0.5; 
1295vec2 st=fract(uv); 
1296vec2 base_uv=floor(uv)-0.5; 
1297base_uv*=shadowMapSizeAndInverse.y; 
1298vec2 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);}}
1299#define inline
1300float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
1301{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 
1302uv+=0.5; 
1303vec2 st=fract(uv); 
1304vec2 base_uv=floor(uv)-0.5; 
1305base_uv*=shadowMapSizeAndInverse.y; 
1306vec2 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);}}
1307const vec3 PoissonSamplers32[64]=vec3[64](
1308vec3(0.06407013,0.05409927,0.),
1309vec3(0.7366577,0.5789394,0.),
1310vec3(-0.6270542,-0.5320278,0.),
1311vec3(-0.4096107,0.8411095,0.),
1312vec3(0.6849564,-0.4990818,0.),
1313vec3(-0.874181,-0.04579735,0.),
1314vec3(0.9989998,0.0009880066,0.),
1315vec3(-0.004920578,-0.9151649,0.),
1316vec3(0.1805763,0.9747483,0.),
1317vec3(-0.2138451,0.2635818,0.),
1318vec3(0.109845,0.3884785,0.),
1319vec3(0.06876755,-0.3581074,0.),
1320vec3(0.374073,-0.7661266,0.),
1321vec3(0.3079132,-0.1216763,0.),
1322vec3(-0.3794335,-0.8271583,0.),
1323vec3(-0.203878,-0.07715034,0.),
1324vec3(0.5912697,0.1469799,0.),
1325vec3(-0.88069,0.3031784,0.),
1326vec3(0.5040108,0.8283722,0.),
1327vec3(-0.5844124,0.5494877,0.),
1328vec3(0.6017799,-0.1726654,0.),
1329vec3(-0.5554981,0.1559997,0.),
1330vec3(-0.3016369,-0.3900928,0.),
1331vec3(-0.5550632,-0.1723762,0.),
1332vec3(0.925029,0.2995041,0.),
1333vec3(-0.2473137,0.5538505,0.),
1334vec3(0.9183037,-0.2862392,0.),
1335vec3(0.2469421,0.6718712,0.),
1336vec3(0.3916397,-0.4328209,0.),
1337vec3(-0.03576927,-0.6220032,0.),
1338vec3(-0.04661255,0.7995201,0.),
1339vec3(0.4402924,0.3640312,0.),
1340vec3(0.),
1341vec3(0.),
1342vec3(0.),
1343vec3(0.),
1344vec3(0.),
1345vec3(0.),
1346vec3(0.),
1347vec3(0.),
1348vec3(0.),
1349vec3(0.),
1350vec3(0.),
1351vec3(0.),
1352vec3(0.),
1353vec3(0.),
1354vec3(0.),
1355vec3(0.),
1356vec3(0.),
1357vec3(0.),
1358vec3(0.),
1359vec3(0.),
1360vec3(0.),
1361vec3(0.),
1362vec3(0.),
1363vec3(0.),
1364vec3(0.),
1365vec3(0.),
1366vec3(0.),
1367vec3(0.),
1368vec3(0.),
1369vec3(0.),
1370vec3(0.),
1371vec3(0.)
1372);const vec3 PoissonSamplers64[64]=vec3[64](
1373vec3(-0.613392,0.617481,0.),
1374vec3(0.170019,-0.040254,0.),
1375vec3(-0.299417,0.791925,0.),
1376vec3(0.645680,0.493210,0.),
1377vec3(-0.651784,0.717887,0.),
1378vec3(0.421003,0.027070,0.),
1379vec3(-0.817194,-0.271096,0.),
1380vec3(-0.705374,-0.668203,0.),
1381vec3(0.977050,-0.108615,0.),
1382vec3(0.063326,0.142369,0.),
1383vec3(0.203528,0.214331,0.),
1384vec3(-0.667531,0.326090,0.),
1385vec3(-0.098422,-0.295755,0.),
1386vec3(-0.885922,0.215369,0.),
1387vec3(0.566637,0.605213,0.),
1388vec3(0.039766,-0.396100,0.),
1389vec3(0.751946,0.453352,0.),
1390vec3(0.078707,-0.715323,0.),
1391vec3(-0.075838,-0.529344,0.),
1392vec3(0.724479,-0.580798,0.),
1393vec3(0.222999,-0.215125,0.),
1394vec3(-0.467574,-0.405438,0.),
1395vec3(-0.248268,-0.814753,0.),
1396vec3(0.354411,-0.887570,0.),
1397vec3(0.175817,0.382366,0.),
1398vec3(0.487472,-0.063082,0.),
1399vec3(-0.084078,0.898312,0.),
1400vec3(0.488876,-0.783441,0.),
1401vec3(0.470016,0.217933,0.),
1402vec3(-0.696890,-0.549791,0.),
1403vec3(-0.149693,0.605762,0.),
1404vec3(0.034211,0.979980,0.),
1405vec3(0.503098,-0.308878,0.),
1406vec3(-0.016205,-0.872921,0.),
1407vec3(0.385784,-0.393902,0.),
1408vec3(-0.146886,-0.859249,0.),
1409vec3(0.643361,0.164098,0.),
1410vec3(0.634388,-0.049471,0.),
1411vec3(-0.688894,0.007843,0.),
1412vec3(0.464034,-0.188818,0.),
1413vec3(-0.440840,0.137486,0.),
1414vec3(0.364483,0.511704,0.),
1415vec3(0.034028,0.325968,0.),
1416vec3(0.099094,-0.308023,0.),
1417vec3(0.693960,-0.366253,0.),
1418vec3(0.678884,-0.204688,0.),
1419vec3(0.001801,0.780328,0.),
1420vec3(0.145177,-0.898984,0.),
1421vec3(0.062655,-0.611866,0.),
1422vec3(0.315226,-0.604297,0.),
1423vec3(-0.780145,0.486251,0.),
1424vec3(-0.371868,0.882138,0.),
1425vec3(0.200476,0.494430,0.),
1426vec3(-0.494552,-0.711051,0.),
1427vec3(0.612476,0.705252,0.),
1428vec3(-0.578845,-0.768792,0.),
1429vec3(-0.772454,-0.090976,0.),
1430vec3(0.504440,0.372295,0.),
1431vec3(0.155736,0.065157,0.),
1432vec3(0.391522,0.849605,0.),
1433vec3(-0.620106,-0.328104,0.),
1434vec3(0.789239,-0.419965,0.),
1435vec3(-0.545396,0.538133,0.),
1436vec3(-0.178564,-0.596057,0.)
1437);
1438#define inline
1439float 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)
1440{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
1441#ifdef USE_REVERSE_DEPTHBUFFER
1442uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
1443#else
1444uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
1445#endif
1446vec4 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; i<searchTapCount; i ++) {blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
1447float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec4 offset=vec4(poissonSamplers[i],0.);offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);}
1448shadow/=float(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);if (numBlocker<1.0) {return 1.0;}
1449else
1450{return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
1451#define inline
1452float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
1453{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=TEXTUREFUNC(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0.).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
1454if (numBlocker<1.0) {return 1.0;}
1455else
1456{float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec3 offset=poissonSamplers[i];offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);shadow+=TEXTUREFUNC(shadowSampler,uvDepth+offset*filterRadius,0.);}
1457shadow/=float(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}}
1458#define inline
1459float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
1460{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
1461#define inline
1462float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
1463{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
1464#define inline
1465float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
1466{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
1467#define inline
1468float computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
1469{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
1470#define inline
1471float computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
1472{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
1473#define inline
1474float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
1475{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
1476#endif
1477#endif
1478`;y.IncludesShadersStore[vi]||(y.IncludesShadersStore[vi]=rn);const co={name:vi,shader:rn},Ii="samplerFragmentDeclaration",nn=`#ifdef _DEFINENAME_
1479#if _DEFINENAME_DIRECTUV==1
1480#define v_VARYINGNAME_UV vMainUV1
1481#elif _DEFINENAME_DIRECTUV==2
1482#define v_VARYINGNAME_UV vMainUV2
1483#elif _DEFINENAME_DIRECTUV==3
1484#define v_VARYINGNAME_UV vMainUV3
1485#elif _DEFINENAME_DIRECTUV==4
1486#define v_VARYINGNAME_UV vMainUV4
1487#elif _DEFINENAME_DIRECTUV==5
1488#define v_VARYINGNAME_UV vMainUV5
1489#elif _DEFINENAME_DIRECTUV==6
1490#define v_VARYINGNAME_UV vMainUV6
1491#else
1492varying vec2 v_VARYINGNAME_UV;
1493#endif
1494uniform sampler2D _SAMPLERNAME_Sampler;
1495#endif
1496`;y.IncludesShadersStore[Ii]||(y.IncludesShadersStore[Ii]=nn);const ho={name:Ii,shader:nn},Si="fresnelFunction",an=`#ifdef FRESNEL
1497float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)
1498{float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}
1499#endif
1500`;y.IncludesShadersStore[Si]||(y.IncludesShadersStore[Si]=an);const fo={name:Si,shader:an},Ei="reflectionFunction",on=`vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
1501{float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0); }
1502vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
1503{float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(1.0-s,t,0); }
1504vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
1505{vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);vec3 r=normalize(reflect(cameraToVertex,worldNormal));
1505r=vec3(reflectionMatrix*vec4(r,0));float lon=atan(r.z,r.x);float lat=acos(r.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0);}
1506vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)
1507{vec3 viewDir=normalize(vec3(view*worldPos));vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));vec3 r=reflect(viewDir,viewNormal);r=vec3(reflectionMatrix*vec4(r,0));r.z=r.z-1.0;float m=2.0*length(r);return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);}
1508vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
1509{vec3 viewDir=worldPos.xyz-eyePosition;vec3 coords=normalize(reflect(viewDir,worldNormal));return vec3(reflectionMatrix*vec4(coords,1));}
1510vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
1511{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=vec3(reflectionMatrix*vec4(coords,0));
1512#ifdef INVERTCUBICMAP
1513coords.y*=-1.0;
1514#endif
1515return coords;}
1516vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)
1517{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=vec3(reflectionMatrix*vec4(coords,0));
1518#ifdef INVERTCUBICMAP
1519coords.y*=-1.0;
1520#endif
1521return coords;}
1522vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)
1523{return vec3(reflectionMatrix*(view*worldPos));}
1524vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)
1525{return vec3(reflectionMatrix*vec4(positionW,1.));}
1526#ifdef REFLECTION
1527vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)
1528{
1529#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
1530vec3 direction=normalize(vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
1531#endif
1532#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
1533vec3 direction=normalize(vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
1534#endif
1535#ifdef REFLECTIONMAP_EQUIRECTANGULAR
1536return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
1537#endif
1538#ifdef REFLECTIONMAP_SPHERICAL
1539return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);
1540#endif
1541#ifdef REFLECTIONMAP_PLANAR
1542return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
1543#endif
1544#ifdef REFLECTIONMAP_CUBIC
1545#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
1546return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);
1547#else
1548return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
1549#endif
1550#endif
1551#ifdef REFLECTIONMAP_PROJECTION
1552return computeProjectionCoords(worldPos,view,reflectionMatrix);
1553#endif
1554#ifdef REFLECTIONMAP_SKYBOX
1555return computeSkyBoxCoords(vPositionUVW,reflectionMatrix);
1556#endif
1557#ifdef REFLECTIONMAP_EXPLICIT
1558return vec3(0,0,0);
1559#endif
1560}
1561#endif
1562`;y.IncludesShadersStore[Ei]||(y.IncludesShadersStore[Ei]=on);const uo={name:Ei,shader:on},Mi="imageProcessingDeclaration",ln=`#ifdef EXPOSURE
1563uniform float exposureLinear;
1564#endif
1565#ifdef CONTRAST
1566uniform float contrast;
1567#endif
1568#if defined(VIGNETTE) || defined(DITHER)
1569uniform vec2 vInverseScreenSize;
1570#endif
1571#ifdef VIGNETTE
1572uniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2;
1573#endif
1574#ifdef COLORCURVES
1575uniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive;
1576#endif
1577#ifdef COLORGRADING
1578#ifdef COLORGRADING3D
1579uniform highp sampler3D txColorTransform;
1580#else
1581uniform sampler2D txColorTransform;
1582#endif
1583uniform vec4 colorTransformSettings;
1584#endif
1585#ifdef DITHER
1586uniform float ditherIntensity;
1587#endif
1588`;y.IncludesShadersStore[Mi]||(y.IncludesShadersStore[Mi]=ln);const mo={name:Mi,shader:ln},xi="imageProcessingFunctions",cn=`#if defined(COLORGRADING) && !defined(COLORGRADING3D)
1589/** 
1590* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.
1591* sampler3dSetting.x=textureOffset (0.5/textureSize).
1592* sampler3dSetting.y=textureSize.
1593*/
1594#define inline
1595vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
1596{float sliceSize=2.0*sampler3dSetting.x; 
1597#ifdef SAMPLER3DGREENDEPTH
1598float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
1599#else
1600float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
1601#endif
1602float sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger;
1603#ifdef SAMPLER3DGREENDEPTH
1604vec2 sliceUV=color.rb;
1605#else
1606vec2 sliceUV=color.rg;
1607#endif
1608sliceUV.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);
1609#ifdef SAMPLER3DBGRMAP
1610color.rgb=result.rgb;
1611#else
1612color.rgb=result.bgr;
1613#endif
1614return color;}
1615#endif
1616#if TONEMAPPING==3
1617const 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<PBRNeutralStartCompression) return color;float d=1.-PBRNeutralStartCompression;float newPeak=1.-d*d/(peak+d-PBRNeutralStartCompression);color*=newPeak/peak;float g=1.-1./(PBRNeutralDesaturation*(peak-newPeak)+1.);return mix(color,newPeak*vec3(1,1,1),g);}
1618#endif
1619#if TONEMAPPING==2
1620const mat3 ACESInputMat=mat3(
1621vec3(0.59719,0.07600,0.02840),
1622vec3(0.35458,0.90834,0.13383),
1623vec3(0.04823,0.01566,0.83777)
1624);const mat3 ACESOutputMat=mat3(
1625vec3( 1.60475,-0.10208,-0.00327),
1626vec3(-0.53108, 1.10813,-0.07276),
1627vec3(-0.07367,-0.00605, 1.07602)
1628);vec3 RRTAndODTFit(vec3 v)
1629{vec3 a=v*(v+0.0245786)-0.000090537;vec3 b=v*(0.983729*v+0.4329510)+0.238081;return a/b;}
1630vec3 ACESFitted(vec3 color)
1631{color=ACESInputMat*color;color=RRTAndODTFit(color);color=ACESOutputMat*color;color=saturate(color);return color;}
1632#endif
1633#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
1634vec4 applyImageProcessing(vec4 result) {
1635#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
1636#ifdef EXPOSURE
1637result.rgb*=exposureLinear;
1638#endif
1639#ifdef VIGNETTE
1640vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);float vignetteTerm=dot(vignetteXY1,vignetteXY1);float vignette=pow(vignetteTerm,vignetteSettings2.w);vec3 vignetteColor=vignetteSettings2.rgb;
1641#ifdef VIGNETTEBLENDMODEMULTIPLY
1642vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);result.rgb*=vignetteColorMultiplier;
1643#endif
1644#ifdef VIGNETTEBLENDMODEOPAQUE
1645result.rgb=mix(vignetteColor,result.rgb,vignette);
1646#endif
1647#endif
1648#if TONEMAPPING==3
1649result.rgb=PBRNeutralToneMapping(result.rgb);
1650#elif TONEMAPPING==2
1651result.rgb=ACESFitted(result.rgb);
1652#elif TONEMAPPING==1
1653const float tonemappingCalibration=1.590579;result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
1654#endif
1655result.rgb=toGammaSpace(result.rgb);result.rgb=saturate(result.rgb);
1656#ifdef CONTRAST
1657vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);if (contrast<1.0) {result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);} else {result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);}
1658result.rgb=max(result.rgb,0.);
1659#endif
1660#ifdef COLORGRADING
1661vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
1662#ifdef COLORGRADING3D
1663vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
1664#else
1665vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
1666#endif
1667result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
1668#endif
1669#ifdef COLORCURVES
1670float luma=getLuminance(result.rgb);vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;result.rgb*=colorCurve.rgb;result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
1671#endif
1672#ifdef DITHER
1673float rand=getRand(gl_FragCoord.xy*vInverseScreenSize);float dither=mix(-ditherIntensity,ditherIntensity,rand);result.rgb=saturate(result.rgb+vec3(dither));
1674#endif
1675#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
1676return result;}`;y.IncludesShadersStore[xi]||(y.IncludesShadersStore[xi]=cn);const po={name:xi,shader:cn},Di="textureRepetitionFunctions",hn=`#if TEXTURE_REPETITION_MODE>0
1677vec4 _texRepHash4(vec2 p) {return fract(sin(vec4(
16781.0+dot(p,vec2(37.0,17.0)),
16792.0+dot(p,vec2(11.0,47.0)),
16803.0+dot(p,vec2(41.0,29.0)),
16814.0+dot(p,vec2(23.0,31.0))
1682))*103.0);}
1683#endif
1684#if TEXTURE_REPETITION_MODE==1
1685vec4 _texRepSample(sampler2D samp,vec2 uv) {float k=texture2D(samp,0.005*uv).x;float index=k*8.0;float f=fract(index);float i=floor(index+0.5);float ib=floor(index);f=min(f,1.0-f)*2.0;vec2 offa=sin(vec2(3.0,7.0)*i);vec2 offb=sin(vec2(3.0,7.0)*ib);vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);vec4 cola=textureGrad(samp,uv+0.3*offa,dx,dy);vec4 colb=textureGrad(samp,uv+0.3*offb,dx,dy);float colSum=cola.x+cola.y+cola.z-colb.x-colb.y-colb.z;return mix(cola,colb,smoothstep(0.2,0.8,f-0.1*colSum));}
1686#elif TEXTURE_REPETITION_MODE==2
1687#ifndef TEXTURE_REPETITION_M_PI
1688#define TEXTURE_REPETITION_M_PI 3.14159265358979
1689#endif
1690vec2 _texRepHexHash(vec2 p) {vec2 r=mat2(127.1,269.5,311.7,183.3)*p;return fract(sin(r)*43758.5453);}
1691void _texRepTriangleGrid(
1692out float w1,out float w2,out float w3,
1693out ivec2 vertex1,out ivec2 vertex2,out ivec2 vertex3,
1694vec2 st
1695) {st*=2.0*sqrt(3.0);mat2 gridToSkewedGrid=mat2(1.0,0.0,-0.57735027,1.15470054);vec2 skewedCoord=gridToSkewedGrid*st;ivec2 baseId=ivec2(floor(skewedCoord));vec3 temp=vec3(fract(skewedCoord),0.0);temp.z=1.0-temp.x-temp.y;float s=step(0.0,-temp.z);float s2=2.0*s-1.0;w1=-temp.z*s2;w2=s-temp.y*s2;w3=s-temp.x*s2;vertex1=baseId+ivec2(int(s),int(s));vertex2=baseId+ivec2(int(s),int(1.0-s));vertex3=baseId+ivec2(int(1.0-s),int(s));}
1696vec2 _texRepMakeCenST(ivec2 Vertex) {mat2 invSkewMat=mat2(1.0,0.0,0.5,1.0/1.15470054);return (invSkewMat*vec2(Vertex))/(2.0*sqrt(3.0));}
1697mat2 _texRepLoadRot2x2(ivec2 idx,float rotStr) {float angle=float(abs(idx.x*idx.y)+abs(idx.x+idx.y))+TEXTURE_REPETITION_M_PI;angle=mod(angle,2.0*TEXTURE_REPETITION_M_PI);
1697if (angle<0.0) angle+=2.0*TEXTURE_REPETITION_M_PI;if (angle>TEXTURE_REPETITION_M_PI) angle-=TEXTURE_REPETITION_M_PI;angle*=rotStr;float cs=cos(angle);float si=sin(angle);return mat2(cs,si,-si,cs);}
1698vec3 _texRepGain3(vec3 x,float r) {float k=log(1.0-r)/log(0.5);vec3 s=2.0*step(0.5,x);vec3 m=2.0*(1.0-s);vec3 res=0.5*s+0.25*m*pow(max(vec3(0.0),s+x*m),vec3(k));return res/(res.x+res.y+res.z);}
1699vec4 _texRepSample(sampler2D samp,vec2 uv) {float rotStrength=vTextureRepetitionHexTilingParams.x;float fallOffContrast=vTextureRepetitionHexTilingParams.y;float expVal=vTextureRepetitionHexTilingParams.z;float r=vTextureRepetitionHexTilingParams.w;vec2 dSTdx=dFdx(uv);vec2 dSTdy=dFdy(uv);float w1,w2,w3;ivec2 vertex1,vertex2,vertex3;_texRepTriangleGrid(w1,w2,w3,vertex1,vertex2,vertex3,uv);mat2 rot1=_texRepLoadRot2x2(vertex1,rotStrength);mat2 rot2=_texRepLoadRot2x2(vertex2,rotStrength);mat2 rot3=_texRepLoadRot2x2(vertex3,rotStrength);vec2 cen1=_texRepMakeCenST(vertex1);vec2 cen2=_texRepMakeCenST(vertex2);vec2 cen3=_texRepMakeCenST(vertex3);vec2 st1=(uv-cen1)*rot1+cen1+_texRepHexHash(vec2(vertex1));vec2 st2=(uv-cen2)*rot2+cen2+_texRepHexHash(vec2(vertex2));vec2 st3=(uv-cen3)*rot3+cen3+_texRepHexHash(vec2(vertex3));vec4 c1=textureGrad(samp,st1,dSTdx*rot1,dSTdy*rot1);vec4 c2=textureGrad(samp,st2,dSTdx*rot2,dSTdy*rot2);vec4 c3=textureGrad(samp,st3,dSTdx*rot3,dSTdy*rot3);vec3 Lw=vec3(0.299,0.587,0.114);vec3 Dw=vec3(dot(c1.rgb,Lw),dot(c2.rgb,Lw),dot(c3.rgb,Lw));Dw=mix(vec3(1.0),Dw,fallOffContrast);vec3 W=Dw*pow(vec3(w1,w2,w3),vec3(expVal));W/=(W.x+W.y+W.z);if (r != 0.5) {W=_texRepGain3(W,r);}
1700return W.x*c1+W.y*c2+W.z*c3;}
1701#elif TEXTURE_REPETITION_MODE==3
1702vec4 _texRepSample(sampler2D samp,vec2 uv) {vec2 iuv=floor(uv);vec2 fuv=fract(uv);vec4 ofa=_texRepHash4(iuv+vec2(0.0,0.0));vec4 ofb=_texRepHash4(iuv+vec2(1.0,0.0));vec4 ofc=_texRepHash4(iuv+vec2(0.0,1.0));vec4 ofd=_texRepHash4(iuv+vec2(1.0,1.0));vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);ofa.zw=sign(ofa.zw-0.5);ofb.zw=sign(ofb.zw-0.5);ofc.zw=sign(ofc.zw-0.5);ofd.zw=sign(ofd.zw-0.5);vec2 uva=uv*ofa.zw+ofa.xy; vec2 ddxa=dx*ofa.zw; vec2 ddya=dy*ofa.zw;vec2 uvb=uv*ofb.zw+ofb.xy; vec2 ddxb=dx*ofb.zw; vec2 ddyb=dy*ofb.zw;vec2 uvc=uv*ofc.zw+ofc.xy; vec2 ddxc=dx*ofc.zw; vec2 ddyc=dy*ofc.zw;vec2 uvd=uv*ofd.zw+ofd.xy; vec2 ddxd=dx*ofd.zw; vec2 ddyd=dy*ofd.zw;vec2 b=smoothstep(0.25,0.75,fuv);return mix(
1703mix(textureGrad(samp,uva,ddxa,ddya),textureGrad(samp,uvb,ddxb,ddyb),b.x),
1704mix(textureGrad(samp,uvc,ddxc,ddyc),textureGrad(samp,uvd,ddxd,ddyd),b.x),
1705b.y
1706);}
1707#elif TEXTURE_REPETITION_MODE==4
1708vec4 _texRepSample(sampler2D samp,vec2 uv) {vec2 p=floor(uv);vec2 f=fract(uv);vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);vec4 va=vec4(0.0);float wt=0.0;float w2=0.0;for (int j=-1; j<=1; j++) {for (int i=-1; i<=1; i++) {vec2 g=vec2(float(i),float(j));vec4 o=_texRepHash4(p+g);vec2 r=g-f+o.xy;float d=dot(r,r);float w=exp(-5.0*d);vec4 c=textureGrad(samp,uv+o.zw,dx,dy);va+=w*c;wt+=w;w2+=w*w;}}
1709float mean=0.3;vec4 res=mean+(va-wt*mean)/sqrt(w2);return mix(va/wt,res,0.4);}
1710#endif
1711#if TEXTURE_REPETITION_MODE>0
1712#define TEXRD(s,uv) _texRepSample(s,uv)
1713#else
1714#define TEXRD(s,uv) texture2D(s,uv)
1715#endif
1716#define TEXRD_DEFINED
1717`;y.IncludesShadersStore[Di]||(y.IncludesShadersStore[Di]=hn);const go={name:Di,shader:hn},Ai="bumpFragmentMainFunctions",fn=`#ifndef TEXRD_DEFINED
1718#define TEXRD(s,uv) texture2D(s,uv)
1719#define TEXRD_DEFINED
1720#endif
1721#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
1722#if defined(TANGENT) && defined(NORMAL) 
1723varying mat3 vTBN;
1724#endif
1725#ifdef OBJECTSPACE_NORMALMAP
1726uniform mat4 normalMatrix;
1727#if defined(WEBGL2) || defined(WEBGPU)
1728mat4 toNormalMatrix(mat4 wMatrix)
1729{mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;}
1730#else
1731mat4 toNormalMatrix(mat4 m)
1732{float
1733a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],
1734a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],
1735a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],
1736a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],
1737b00=a00*a11-a01*a10,
1738b01=a00*a12-a02*a10,
1739b02=a00*a13-a03*a10,
1740b03=a01*a12-a02*a11,
1741b04=a01*a13-a03*a11,
1742b05=a02*a13-a03*a12,
1743b06=a20*a31-a21*a30,
1744b07=a20*a32-a22*a30,
1745b08=a20*a33-a23*a30,
1746b09=a21*a32-a22*a31,
1747b10=a21*a33-a23*a31,
1748b11=a22*a33-a23*a32,
1749det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4(
1750a11*b11-a12*b10+a13*b09,
1751a02*b10-a01*b11-a03*b09,
1752a31*b05-a32*b04+a33*b03,
1753a22*b04-a21*b05-a23*b03,
1754a12*b08-a10*b11-a13*b07,
1755a00*b11-a02*b08+a03*b07,
1756a32*b02-a30*b05-a33*b01,
1757a20*b05-a22*b02+a23*b01,
1758a10*b10-a11*b08+a13*b06,
1759a01*b08-a00*b10-a03*b06,
1760a30*b04-a31*b02+a33*b00,
1761a21*b02-a20*b04-a23*b00,
1762a11*b07-a10*b09-a12*b06,
1763a00*b09-a01*b07+a02*b06,
1764a31*b01-a30*b03-a32*b00,
1765a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
1766mi[0][1],mi[1][1],mi[2][1],mi[3][1],
1767mi[0][2],mi[1][2],mi[2][2],mi[3][2],
1768mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
1769#endif
1770#endif
1771vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
1772{
1773#ifdef NORMALXYSCALE
1774normal=normalize(normal*vec3(scale,scale,1.0));
1775#endif
1776return normalize(cotangentFrame*normal);}
1777vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
1778{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
1779mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
1780{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);}
1781#endif
1782`;y.IncludesShadersStore[Ai]||(y.IncludesShadersStore[Ai]=fn);const _o={name:Ai,shader:fn},bi="bumpFragmentFunctions",dn=`#if defined(BUMP)
1783#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
1784#endif
1785#if defined(DETAIL)
1786#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
1787#endif
1788#if defined(BUMP) && defined(PARALLAX)
1789const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; i<iMaxSamples; i++)
1790{currSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;if (!keepWorking)
1791{}
1792else if (currSampledHeight>currRayHeight)
1793{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
1794else
1795{currRayHeight-=stepSize;vLastOffset=vCurrOffset;
1796#ifdef PARALLAX_RHS
1797vCurrOffset-=stepSize*vMaxOffset;
1798#else
1799vCurrOffset+=stepSize*vMaxOffset;
1800#endif
1801lastSampledHeight=currSampledHeight;}}
1802return vCurrOffset;}
1803vec2 parallaxOffset(vec3 viewDir,float heightScale)
1804{float height=texture2D(bumpSampler,vBumpUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height;
1805#ifdef PARALLAX_RHS
1806return texCoordOffset;
1807#else
1808return -texCoordOffset;
1809#endif
1810}
1811#endif
1812`;y.IncludesShadersStore[bi]||(y.IncludesShadersStore[bi]=dn);const vo={name:bi,shader:dn},Ti="clipPlaneFragmentDeclaration",un=`#ifdef CLIPPLANE
1813varying float fClipDistance;
1814#endif
1815#ifdef CLIPPLANE2
1816varying float fClipDistance2;
1817#endif
1818#ifdef CLIPPLANE3
1819varying float fClipDistance3;
1820#endif
1821#ifdef CLIPPLANE4
1822varying float fClipDistance4;
1823#endif
1824#ifdef CLIPPLANE5
1825varying float fClipDistance5;
1826#endif
1827#ifdef CLIPPLANE6
1828varying float fClipDistance6;
1829#endif
1830`;y.IncludesShadersStore[Ti]||(y.IncludesShadersStore[Ti]=un);const Io={name:Ti,shader:un},Ci="fogFragmentDeclaration",mn=`#ifdef FOG
1831#define FOGMODE_NONE 0.
1832#define FOGMODE_EXP 1.
1833#define FOGMODE_EXP2 2.
1834#define FOGMODE_LINEAR 3.
1835#define E 2.71828
1836uniform vec4 vFogInfos;uniform vec3 vFogColor;varying vec3 vFogDistance;float CalcFogFactor()
1837{float fogCoeff=1.0;float fogStart=vFogInfos.y;float fogEnd=vFogInfos.z;float fogDensity=vFogInfos.w;float fogDistance=length(vFogDistance);if (FOGMODE_LINEAR==vFogInfos.x)
1838{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);}
1839else if (FOGMODE_EXP==vFogInfos.x)
1840{fogCoeff=1.0/pow(E,fogDistance*fogDensity);}
1841else if (FOGMODE_EXP2==vFogInfos.x)
1842{fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);}
1843return clamp(fogCoeff,0.0,1.0);}
1844#endif
1845`;y.IncludesShadersStore[Ci]||(y.IncludesShadersStore[Ci]=mn);const So={name:Ci,shader:mn},Pi="clipPlaneFragment",pn=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
1846if (false) {}
1847#endif
1848#ifdef CLIPPLANE
1849else if (fClipDistance>0.0)
1850{discard;}
1851#endif
1852#ifdef CLIPPLANE2
1853else if (fClipDistance2>0.0)
1854{discard;}
1855#endif
1856#ifdef CLIPPLANE3
1857else if (fClipDistance3>0.0)
1858{discard;}
1859#endif
1860#ifdef CLIPPLANE4
1861else if (fClipDistance4>0.0)
1862{discard;}
1863#endif
1864#ifdef CLIPPLANE5
1865else if (fClipDistance5>0.0)
1866{discard;}
1867#endif
1868#ifdef CLIPPLANE6
1869else if (fClipDistance6>0.0)
1870{discard;}
1871#endif
1872`;y.IncludesShadersStore[Pi]||(y.IncludesShadersStore[Pi]=pn);const Eo={name:Pi,shader:pn},yi="bumpFragment",gn=`vec2 uvOffset=vec2(0.0,0.0);
1873#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
1874#ifdef NORMALXYSCALE
1875float normalScale=1.0;
1876#elif defined(BUMP)
1877float normalScale=vBumpInfos.y;
1878#else
1879float normalScale=1.0;
1880#endif
1881#if defined(TANGENT) && defined(NORMAL)
1882mat3 TBN=vTBN;
1883#elif defined(BUMP)
1884vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
1885#else
1886vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
1887#endif
1888#elif defined(ANISOTROPIC)
1889#if defined(TANGENT) && defined(NORMAL)
1890mat3 TBN=vTBN;
1891#else
1892vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
1893#endif
1894#endif
1895#ifdef PARALLAX
1896mat3 invTBN=transposeMat3(TBN);
1897#ifdef PARALLAXOCCLUSION
1898uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);
1899#else
1900uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);
1901#endif
1902#endif
1903#ifdef DETAIL
1904vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
1905#endif
1906#ifdef BUMP
1907#ifdef OBJECTSPACE_NORMALMAP
1908#define CUSTOM_FRAGMENT_BUMP_FRAGMENT
1909normalW=normalize(TEXRD(bumpSampler,vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW);
1910#elif !defined(DETAIL)
1911normalW=perturbNormal(TBN,TEXRD(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);
1912#else
1913vec3 bumpNormal=TEXRD(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;
1914#if DETAIL_NORMALBLENDMETHOD==0 
1915detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
1916#elif DETAIL_NORMALBLENDMETHOD==1 
1917detailNormal.xy*=vDetailInfos.z;bumpNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
1918#endif
1919normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);
1920#endif
1921#elif defined(DETAIL)
1922detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
1923#endif
1924`;y.IncludesShadersStore[yi]||(y.IncludesShadersStore[yi]=gn);const Mo={name:yi,shader:gn},Ri="decalFragment",_n=`#ifdef DECAL
1925#ifdef GAMMADECAL
1926decalColor.rgb=toLinearSpace(decalColor.rgb);
1927#endif
1928#ifdef DECAL_SMOOTHALPHA
1929decalColor.a*=decalColor.a;
1930#endif
1931surfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,decalColor.rgb,decalColor.a);
1932#endif
1933`;y.IncludesShadersStore[Ri]||(y.IncludesShadersStore[Ri]=_n);const xo={name:Ri,shader:_n},Li="depthPrePass",vn=`#ifdef DEPTHPREPASS
1934gl_FragColor=vec4(0.,0.,0.,1.0);return;
1935#endif
1936`;y.IncludesShadersStore[Li]||(y.IncludesShadersStore[Li]=vn);const Do={name:Li,shader:vn},Fi="lightFragment",In=`#ifdef LIGHT{X}
1937#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
1938#else
1939vec4 diffuse{X}=light{X}.vLightDiffuse;
1940#define CUSTOM_LIGHT{X}_COLOR 
1941#if defined(PBR) && defined(CLUSTLIGHT{X}) && defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1942{int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(
1943lightDataTexture{X},
1944tileMaskTexture{X},
1945light{X}.vLightData,
1946ivec2(light{X}.vSliceRanges[sliceIndex]),
1947viewDirectionW,
1948normalW,
1949vPositionW,
1950surfaceAlbedo,
1951reflectivityOut
1952#ifdef IRIDESCENCE
1953,iridescenceIntensity
1954#endif
1955#ifdef SS_TRANSLUCENCY
1956,subSurfaceOut
1957#endif
1958#ifdef SPECULARTERM
1959,AARoughnessFactors.x
1960#endif
1961#ifdef ANISOTROPIC
1962,anisotropicOut
1963#endif
1964#ifdef SHEEN
1965,sheenOut
1966#endif
1967#ifdef CLEARCOAT
1968,clearcoatOut
1969#endif
1970);}
1971#elif defined(PBR)
1972#ifdef SPOTLIGHT{X}
1973preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);
1974#elif defined(POINTLIGHT{X})
1975preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);
1976#elif defined(HEMILIGHT{X})
1977preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
1978#elif defined(DIRLIGHT{X})
1979preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
1980#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1981#if defined(RECTAREALIGHTEMISSIONTEXTURE{X})
1982preInfo=computeAreaPreLightingInfoWithTexture(areaLightsLTC1Sampler,areaLightsLTC2Sampler,rectAreaLightEmissionTexture{X},viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness);
1983#else
1984preInfo=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness);
1985#endif
1986#endif
1987preInfo.NdotV=NdotV;
1988#ifdef SPOTLIGHT{X}
1989#ifdef LIGHT_FALLOFF_GLTF{X}
1990preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
1991#ifdef IESLIGHTTEXTURE{X}
1992preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
1993#else
1994preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
1995#endif
1996#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
1997preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
1998#ifdef IESLIGHTTEXTURE{X}
1999preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
2000#else
2001preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
2002#endif
2003#elif defined(LIGHT_FALLOFF_STANDARD{X})
2004preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
2005#ifdef IESLIGHTTEXTURE{X}
2006preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
2007#else
2008preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
2009#endif
2010#else
2011preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
2012#ifdef IESLIGHTTEXTURE{X}
2013preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X});
2014#else
2015preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
2016#endif
2017#endif
2018#elif defined(POINTLIGHT{X})
2019#ifdef LIGHT_FALLOFF_GLTF{X}
2020preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
2021#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
2022preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
2023#elif defined(LIGHT_FALLOFF_STANDARD{X})
2024preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
2025#else
2026preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
2027#endif
2028#else
2029preInfo.attenuation=1.0;
2030#endif
2031#if defined(HEMILIGHT{X})
2032preInfo.roughness=roughness;
2033#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
2034preInfo.roughness=roughness;
2035#else
2036preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
2037#endif
2038preInfo.diffuseRoughness=diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
2039#ifdef IRIDESCENCE
2040preInfo.iridescenceIntensity=iridescenceIntensity;
2041#endif
2042#ifdef SS_TRANSLUCENCY
2043info.diffuseTransmission=vec3(0.0);
2044#endif
2045#ifdef HEMILIGHT{X}
2046info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround);
2047#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
2048info.diffuse=computeAreaDiffuseLighting(preInfo,diffuse{X}.rgb);
2049#elif defined(SS_TRANSLUCENCY)
2050#ifndef SS_TRANSLUCENCY_LEGACY
2051info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); 
2052#else
2053info.diffuse=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
2054#endif
2055#else
2056info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb);
2057#endif
2058#ifdef SPECULARTERM
2059#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
2060info.specular=computeAreaSpecularLighting(preInfo,light{X}.vLightSpecular.rgb,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
2061#else
2062#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
2063{vec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);}
2064#else
2065coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
2066#endif
2067#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
2068{float NdotH=dot(normalW,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);}
2069#endif
2070#ifdef ANISOTROPIC
2071info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
2072#else
2073info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,coloredFresnel,AARoughnessFactors.x,diffuse{X}.rgb);
2074#endif
2075#endif
2076#endif
2077#ifndef AREALIGHT{X}
2078#ifdef SHEEN
2079#ifdef SHEEN_LINKWITHALBEDO
2080preInfo.roughness=sheenOut.sheenIntensity;
2081#else
2082#ifdef HEMILIGHT{X}
2083preInfo.roughness=sheenOut.sheenRoughness;
2084#else
2085preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
2086#endif
2087#endif
2088info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
2089#endif
2090#ifdef CLEARCOAT
2091#ifdef HEMILIGHT{X}
2092preInfo.roughness=clearcoatOut.clearCoatRoughness;
2093#else
2094preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
2095#endif
2096info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb);
2097#ifdef CLEARCOAT_TINT
2098absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
2099#ifdef SS_TRANSLUCENCY
2100info.diffuseTransmission*=absorption;
2101#endif
2102#ifdef SPECULARTERM
2103info.specular*=absorption;
2104#endif
2105#endif
2106info.diffuse*=info.clearCoat.w;
2107#ifdef SS_TRANSLUCENCY
2108info.diffuseTransmission*=info.clearCoat.w;
2109#endif
2110#ifdef SPECULARTERM
2111info.specular*=info.clearCoat.w;
2112#endif
2113#ifdef SHEEN
2114info.sheen*=info.clearCoat.w;
2115#endif
2116#endif
2117#endif
2118#else
2119#ifdef SPOTLIGHT{X}
2120#ifdef IESLIGHTTEXTURE{X}
2121info=computeIESSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness,iesLightTexture{X});
2122#else
2123info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
2124#endif
2125#elif defined(HEMILIGHT{X})
2126info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
2127#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
2128info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
2129#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
2130#if defined(RECTAREALIGHTEMISSIONTEXTURE{X})
2131info=computeAreaLightingWithTexture(areaLightsLTC1Sampler,areaLightsLTC2Sampler,rectAreaLightEmissionTexture{X},viewDirectionW,normalW,vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.rgb,light{X}.vLightHeight.rgb,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,
2132#ifdef AREALIGHTNOROUGHTNESS
21330.5
2134#else
2135vReflectionInfos.y
2136#endif
2137#else
2138info=computeAreaLighting(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.rgb,light{X}.vLightHeight.rgb,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,
2139#ifdef AREALIGHTNOROUGHTNESS
21400.5
2141#else
2142vReflectionInfos.y
2143#endif
2144#endif
2145);
2146#elif defined(CLUSTLIGHT{X}) && CLUSTLIGHT_BATCH>0
2147{int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(lightDataTexture{X},tileMaskTexture{X},viewDirectionW,normalW,light{X}.vLightData,ivec2(light{X}.vSliceRanges[sliceIndex]),glossiness);}
2148#endif
2149#endif
2150#ifdef PROJECTEDLIGHTTEXTURE{X}
2151info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
2152#endif
2153#endif
2154#ifdef SHADOW{X}
2155#ifdef SHADOWCSM{X}
2156for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
2157{
2158#ifdef SHADOWCSM_RIGHTHANDED{X}
2159diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
2160#else
2161diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
2162#endif
2163if (diff{X}>=0.) {index{X}=i;break;}}
2164#ifdef SHADOWCSMUSESHADOWMAXZ{X}
2165if (index{X}>=0)
2166#endif
2167{
2168#if defined(SHADOWPCF{X})
2169#if defined(SHADOWLOWQUALITY{X})
2170shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2171#elif defined(SHADOWMEDIUMQUALITY{X})
2172shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2173#else
2174shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2175#endif
2176#elif defined(SHADOWPCSS{X})
2177#if defined(SHADOWLOWQUALITY{X})
2178shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
2179#elif defined(SHADOWMEDIUMQUALITY{X})
2180shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
2181#else
2182shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
2183#endif
2184#else
2185shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2186#endif
2187#ifdef SHADOWCSMDEBUG{X}
2188shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
2189#endif
2190#ifndef SHADOWCSMNOBLEND{X}
2191float frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
2192{index{X}+=1;float nextShadow=0.;
2193#if defined(SHADOWPCF{X})
2194#if defined(SHADOWLOWQUALITY{X})
2195nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2196#elif defined(SHADOWMEDIUMQUALITY{X})
2197nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2198#else
2199nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2200#endif
2201#elif defined(SHADOWPCSS{X})
2202#if defined(SHADOWLOWQUALITY{X})
2203nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
2204#elif defined(SHADOWMEDIUMQUALITY{X})
2205nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
2206#else
2207nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});
2208#endif
2209#else
2210nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2211#endif
2212shadow=mix(nextShadow,shadow,diffRatio);
2213#ifdef SHADOWCSMDEBUG{X}
2214shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
2215#endif
2216}
2217#endif
2218}
2219#elif defined(SHADOWCLOSEESM{X})
2220#if defined(SHADOWCUBE{X})
2221shadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
2222#else
2223shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
2224#endif
2225#elif defined(SHADOWESM{X})
2226#if defined(SHADOWCUBE{X})
2227shadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
2228#else
2229shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
2230#endif
2231#elif defined(SHADOWPOISSON{X})
2232#if defined(SHADOWCUBE{X})
2233shadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
2234#else
2235shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2236#endif
2237#elif defined(SHADOWPCF{X})
2238#if defined(SHADOWLOWQUALITY{X})
2239shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2240#elif defined(SHADOWMEDIUMQUALITY{X})
2241shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2242#else
2243shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2244#endif
2245#elif defined(SHADOWPCSS{X})
2246#if defined(SHADOWLOWQUALITY{X})
2247shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2248#elif defined(SHADOWMEDIUMQUALITY{X})
2249shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2250#else
2251shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2252#endif
2253#else
2254#if defined(SHADOWCUBE{X})
2255shadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.depthValues);
2256#else
2257shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
2258#endif
2259#endif
2260#ifdef SHADOWONLY
2261#ifndef SHADOWINUSE
2262#define SHADOWINUSE
2263#endif
2264globalShadow+=shadow;shadowLightCount+=1.0;
2265#endif
2266#else
2267shadow=1.;
2268#endif
2269aggShadow+=shadow;numLights+=1.0;
2270#ifndef SHADOWONLY
2271#ifdef CUSTOMUSERLIGHTING
2272diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
2273#ifdef SPECULARTERM
2274specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
2275#endif
2276#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
2277diffuseBase+=lightmapColor.rgb*shadow;
2278#ifdef SPECULARTERM
2279#ifndef LIGHTMAPNOSPECULAR{X}
2280specularBase+=info.specular*shadow*lightmapColor.rgb;
2281#endif
2282#endif
2283#ifdef CLEARCOAT
2284#ifndef LIGHTMAPNOSPECULAR{X}
2285clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
2286#endif
2287#endif
2288#ifdef SHEEN
2289#ifndef LIGHTMAPNOSPECULAR{X}
2290sheenBase+=info.sheen.rgb*shadow;
2291#endif
2292#endif
2293#else
2294#ifdef SHADOWCSMDEBUG{X}
2295diffuseBase+=info.diffuse*shadowDebug{X};
2296#else
2297diffuseBase+=info.diffuse*shadow;
2298#endif
2299#ifdef SS_TRANSLUCENCY
2300diffuseTransmissionBase+=info.diffuseTransmission*shadow;
2301#endif
2302#ifdef SPECULARTERM
2303specularBase+=info.specular*shadow;
2304#endif
2305#ifdef CLEARCOAT
2306clearCoatBase+=info.clearCoat.rgb*shadow;
2307#endif
2308#ifdef SHEEN
2309sheenBase+=info.sheen.rgb*shadow;
2310#endif
2311#endif
2312#endif
2313#endif
2314`;y.IncludesShadersStore[Fi]||(y.IncludesShadersStore[Fi]=In);const Ao={name:Fi,shader:In},Oi="logDepthFragment",Sn=`#ifdef LOGARITHMICDEPTH
2315gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
2316#endif
2317`;y.IncludesShadersStore[Oi]||(y.IncludesShadersStore[Oi]=Sn);const bo={name:Oi,shader:Sn},wi="fogFragment",En=`#ifdef FOG
2318float fog=CalcFogFactor();
2319#ifdef PBR
2320fog=toLinearSpace(fog);
2321#endif
2322color.rgb=mix(vFogColor,color.rgb,fog);
2323#endif
2324`;
2324y.IncludesShadersStore[wi]||(y.IncludesShadersStore[wi]=En);const To={name:wi,shader:En},Ni="oitFragment",Mn=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
2325float fragDepth=gl_FragCoord.z; 
2326#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
2327uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x;
2328#endif
2329ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);depth.rg=vec2(-MAX_DEPTH);frontColor=lastFrontColor;backColor=vec4(0.0);
2330#ifdef USE_REVERSE_DEPTHBUFFER
2331float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y;
2332#else
2333float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y;
2334#endif
2335float alphaMultiplier=1.0-lastFrontColor.a;
2336#ifdef USE_REVERSE_DEPTHBUFFER
2337if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
2338#else
2339if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
2340#endif
2341return;}
2342#ifdef USE_REVERSE_DEPTHBUFFER
2343if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
2344#else
2345if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
2346#endif
2347depth.rg=vec2(-fragDepth,fragDepth);return;}
2348#endif
2349`;y.IncludesShadersStore[Ni]||(y.IncludesShadersStore[Ni]=Mn);const Co={name:Ni,shader:Mn},Bi="defaultPixelShader",xn=`#define CUSTOM_FRAGMENT_EXTENSION
2350#include<__decl__defaultFragment>
2351#if defined(BUMP) || !defined(NORMAL)
2352#extension GL_OES_standard_derivatives : enable
2353#endif
2354#include<prePassDeclaration>[SCENE_MRT_COUNT]
2355#include<oitDeclaration>
2356#define CUSTOM_FRAGMENT_BEGIN
2357#ifdef LOGARITHMICDEPTH
2358#extension GL_EXT_frag_depth : enable
2359#endif
2360varying vec3 vPositionW;
2361#ifdef NORMAL
2362varying vec3 vNormalW;
2363#endif
2364#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
2365varying vec4 vColor;
2366#endif
2367#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
2368varying float vViewDepth;
2369#endif
2370#include<mainUVVaryingDeclaration>[1..7]
2371#include<helperFunctions>
2372#include<__decl__lightFragment>[0..maxSimultaneousLights]
2373#include<lightsFragmentFunctions>
2374#include<shadowsFragmentFunctions>
2375#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
2376#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
2377#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
2378#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
2379#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
2380#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
2381#ifdef REFRACTION
2382#ifdef REFRACTIONMAP_3D
2383uniform samplerCube refractionCubeSampler;
2384#else
2385uniform sampler2D refraction2DSampler;
2386#endif
2387#endif
2388#if defined(SPECULARTERM)
2389#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
2390#endif
2391#include<fresnelFunction>
2392#ifdef REFLECTION
2393#ifdef REFLECTIONMAP_3D
2394uniform samplerCube reflectionCubeSampler;
2395#else
2396uniform sampler2D reflection2DSampler;
2397#endif
2398#ifdef REFLECTIONMAP_SKYBOX
2399varying vec3 vPositionUVW;
2400#else
2401#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
2402varying vec3 vDirectionW;
2403#endif
2404#endif
2405#include<reflectionFunction>
2406#endif
2407#include<imageProcessingDeclaration>
2408#include<imageProcessingFunctions>
2409#include<textureRepetitionFunctions>
2410#include<bumpFragmentMainFunctions>
2411#include<bumpFragmentFunctions>
2412#include<clipPlaneFragmentDeclaration>
2413#include<logDepthDeclaration>
2414#include<fogFragmentDeclaration>
2415#define CUSTOM_FRAGMENT_DEFINITIONS
2416void main(void) {
2417#define CUSTOM_FRAGMENT_MAIN_BEGIN
2418#include<clipPlaneFragment>
2419vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;
2420#ifdef NORMAL
2421vec3 normalW=normalize(vNormalW);
2422#else
2423vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
2424#endif
2425#include<bumpFragment>
2426#ifdef TWOSIDEDLIGHTING
2427normalW=gl_FrontFacing ? normalW : -normalW;
2428#endif
2429#ifdef DIFFUSE
2430baseColor=TEXRD(diffuseSampler,vDiffuseUV+uvOffset);
2431#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
2432if (baseColor.a<alphaCutOff)
2433discard;
2434#endif
2435#ifdef ALPHAFROMDIFFUSE
2436alpha*=baseColor.a;
2437#endif
2438#define CUSTOM_FRAGMENT_UPDATE_ALPHA
2439baseColor.rgb*=vDiffuseInfos.y;
2440#endif
2441#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)
2442vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
2443#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
2444#endif
2445#include<depthPrePass>
2446#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
2447baseColor.rgb*=vColor.rgb;
2448#endif
2449#ifdef DETAIL
2450baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
2451#endif
2452#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)
2453vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
2454#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
2455#endif
2456#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
2457vec3 baseAmbientColor=vec3(1.,1.,1.);
2458#ifdef AMBIENT
2459baseAmbientColor=TEXRD(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
2460#endif
2461#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
2462float glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;
2463#ifdef SPECULARTERM
2464#ifdef SPECULAR
2465vec4 specularMapColor=TEXRD(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;
2466#ifdef GLOSSINESS
2467glossiness=glossiness*specularMapColor.a;
2468#endif
2469#endif
2470#endif
2471vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;
2472#ifdef SPECULARTERM
2473vec3 specularBase=vec3(0.,0.,0.);
2474#endif
2475float shadow=1.;float aggShadow=0.;float numLights=0.;
2476#ifdef LIGHTMAP
2477vec4 lightmapColor=TEXRD(lightmapSampler,vLightmapUV+uvOffset);
2478#ifdef RGBDLIGHTMAP
2479lightmapColor.rgb=fromRGBD(lightmapColor);
2480#endif
2481lightmapColor.rgb*=vLightmapInfos.y;
2482#endif
2483#include<lightFragment>[0..maxSimultaneousLights]
2484aggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.);
2485#ifdef REFRACTION
2486vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
2487#ifdef REFRACTIONMAP_3D
2488#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
2489refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);
2490#endif
2491refractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}
2492#else
2493vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=texture2D(refraction2DSampler,refractionCoords);
2494#endif
2495#ifdef RGBDREFRACTION
2496refractionColor.rgb=fromRGBD(refractionColor);
2497#endif
2498#ifdef IS_REFRACTION_LINEAR
2499refractionColor.rgb=toGammaSpace(refractionColor.rgb);
2500#endif
2501refractionColor.rgb*=vRefractionInfos.x;
2502#endif
2503vec4 reflectionColor=vec4(0.,0.,0.,1.);
2504#ifdef REFLECTION
2505vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
2506#ifdef REFLECTIONMAP_OPPOSITEZ
2507vReflectionUVW.z*=-1.0;
2508#endif
2509#ifdef REFLECTIONMAP_3D
2510#ifdef ROUGHNESS
2511float bias=vReflectionInfos.y;
2512#ifdef SPECULARTERM
2513#ifdef SPECULAR
2514#ifdef GLOSSINESS
2515bias*=(1.0-specularMapColor.a);
2516#endif
2517#endif
2518#endif
2519reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
2520#else
2521reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
2522#endif
2523#else
2524vec2 coords=vReflectionUVW.xy;
2525#ifdef REFLECTIONMAP_PROJECTION
2526coords/=vReflectionUVW.z;
2527#endif
2528coords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords);
2529#endif
2530#ifdef RGBDREFLECTION
2531reflectionColor.rgb=fromRGBD(reflectionColor);
2532#endif
2533#ifdef IS_REFLECTION_LINEAR
2534reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
2535#endif
2536reflectionColor.rgb*=vReflectionInfos.x;
2537#ifdef REFLECTIONFRESNEL
2538float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
2539#ifdef REFLECTIONFRESNELFROMSPECULAR
2540#ifdef SPECULARTERM
2541reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
2542#else
2543reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
2544#endif
2545#else
2546reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
2547#endif
2548#endif
2549#endif
2550#ifdef REFRACTIONFRESNEL
2551float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
2552#endif
2553#ifdef OPACITY
2554vec4 opacityMap=TEXRD(opacitySampler,vOpacityUV+uvOffset);
2555#ifdef OPACITYRGB
2556opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
2557#else
2558alpha*=opacityMap.a*vOpacityInfos.y;
2559#endif
2560#endif
2561#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
2562alpha*=vColor.a;
2563#endif
2564#ifdef OPACITYFRESNEL
2565float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
2566#endif
2567#ifdef ALPHATEST
2568#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
2569if (alpha<alphaCutOff)
2570discard;
2571#endif
2572#ifndef ALPHABLEND
2573alpha=1.0;
2574#endif
2575#endif
2576vec3 emissiveColor=vEmissiveColor;
2577#ifdef EMISSIVE
2578emissiveColor+=TEXRD(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;
2579#endif
2580#ifdef EMISSIVEFRESNEL
2581float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;
2582#endif
2583#ifdef DIFFUSEFRESNEL
2584float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;
2585#endif
2586#ifdef EMISSIVEASILLUMINATION
2587vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
2588#else
2589#ifdef LINKEMISSIVEWITHDIFFUSE
2590vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
2591#else
2592vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
2593#endif
2594#endif
2595#ifdef SPECULARTERM
2596vec3 finalSpecular=specularBase*specularColor;
2597#ifdef SPECULAROVERALPHA
2598alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);
2599#endif
2600#else
2601vec3 finalSpecular=vec3(0.0);
2602#endif
2603#ifdef REFLECTIONOVERALPHA
2604alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);
2605#endif
2606#ifdef EMISSIVEASILLUMINATION
2607vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
2608#else
2609vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
2610#endif
2611#ifdef LIGHTMAP
2612#ifndef LIGHTMAPEXCLUDED
2613#ifdef USELIGHTMAPASSHADOWMAP
2614color.rgb*=lightmapColor.rgb;
2615#else
2616color.rgb+=lightmapColor.rgb;
2617#endif
2618#endif
2619#endif
2620#define CUSTOM_FRAGMENT_BEFORE_FOG
2621color.rgb=max(color.rgb,0.);
2622#include<logDepthFragment>
2623#include<fogFragment>
2624#ifdef IMAGEPROCESSINGPOSTPROCESS
2625color.rgb=toLinearSpace(color.rgb);
2626#else
2627#ifdef IMAGEPROCESSING
2628color.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color);
2629#endif
2630#endif
2631color.a*=visibility;
2632#ifdef PREMULTIPLYALPHA
2633color.rgb*=color.a;
2634#endif
2635#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
2636#ifdef PREPASS
2637#if SCENE_MRT_COUNT>0
2638float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;
2639#ifdef PREPASS_COLOR
2640gl_FragData[PREPASS_COLOR_INDEX]=color; 
2641#endif
2642#ifdef PREPASS_POSITION
2643gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
2644#endif
2645#ifdef PREPASS_LOCAL_POSITION
2646gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo);
2647#endif
2648#if defined(PREPASS_VELOCITY)
2649vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
2650#elif defined(PREPASS_VELOCITY_LINEAR)
2651vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
2652#endif
2653#ifdef PREPASS_IRRADIANCE
2654gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); 
2655#endif
2656#ifdef PREPASS_DEPTH
2657gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); 
2658#endif
2659#ifdef PREPASS_SCREENSPACE_DEPTH
2660gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
2661#endif
2662#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
2663gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo);
2664#endif
2665#ifdef PREPASS_NORMAL
2666#ifdef PREPASS_NORMAL_WORLDSPACE
2667gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
2668#else
2669gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
2670#endif
2671#endif
2672#ifdef PREPASS_WORLD_NORMAL
2673gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo);
2674#endif
2675#ifdef PREPASS_ALBEDO
2676gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(baseColor.rgb,writeGeometryInfo);
2677#endif
2678#ifdef PREPASS_ALBEDO_SQRT
2679gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqrt(baseColor.rgb),writeGeometryInfo);
2680#endif
2681#ifdef PREPASS_REFLECTIVITY
2682#if defined(SPECULAR)
2683gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo; 
2684#else
2685gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo;
2686#endif
2687#endif
2688#endif
2689#endif
2690#if !defined(PREPASS) || defined(WEBGL2)
2691gl_FragColor=color;
2692#endif
2693#include<oitFragment>
2694#if ORDER_INDEPENDENT_TRANSPARENCY
2695if (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;}
2696#endif
2697#define CUSTOM_FRAGMENT_MAIN_END
2698}
2699`;y.ShadersStore[Bi]||(y.ShadersStore[Bi]=xn);const Po=[eo,to,hr,dr,mr,io,so,Er,er,ro,no,ao,oo,lo,co,ho,fo,uo,mo,po,go,_o,vo,Io,Rr,So,Eo,Mo,xo,Do,Ao,bo,To,Co];for(const o of Po)y.IncludesShadersStore[o.name]||(y.IncludesShadersStore[o.name]=o.shader);const yo={name:Bi,shader:xn},Tl=Object.freeze(Object.defineProperty({__proto__:null,defaultPixelShader:yo},Symbol.toStringTag,{value:"Module"})),Ro={city:[.13,.15,.19],canal:[.12,.24,.34],tundra:[.45,.51,.58],coast:[.42,.36,.27],wetland:[.16,.28,.22],highlands:[.26,.25,.3],meadow:[.21,.36,.23]},Lo={grass:[.18,.31,.2],road:[.075,.085,.11],pavement:[.28,.29,.31],water:[.08,.27,.4],tree:[.08,.24,.14],wall:[.28,.2,.2],flowers:[.55,.18,.28],tallGrass:[.18,.38,.19],sand:[.48,.39,.25],snow:[.62,.68,.74],ruin:[.25,.22,.23],house:[.34,.19,.18]},Fo={brick:[.62,.19,.12],sun:[.94,.61,.12],tide:[.12,.43,.72],moss:[.2,.5,.25]};class Dn{constructor(e,t){this.engine=e,this.canvas=t;const i=navigator.deviceMemory,s=window.matchMedia("(max-width: 760px)").matches,r
2699=window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.qualityProfile=s||r||i!==void 0&&i<=4?"balanced":"cinematic"}m=null;scene=null;camera=null;player=null;balloon=null;tether=null;balloonKnot=null;pepeLegs=[];pepeTail=null;pepeScarf=null;pepeEchoTemplates=[];pepeEchoInstances=[];pepeEchoCount=0;pepeEchoKey="";chunks=new Map;doors=new Map;materials=new Map;staticMeshes=[];platformMeshes=[];platformLights=[];platformBeacon=null;northboundMeshes=[];northboundLights=[];northboundBeacon=null;northboundGate=[];lanternSpanMeshes=[];lanternSpanLights=[];lanternSpanBeacon=null;glimmerMeshes=[];glimmerLights=[];glimmerLampGlows=[];glimmerGate=[];kitegardenMeshes=[];kitegardenLights=[];kiteMeshes=[];kiteFerryDock=[];quietFerryMeshes=[];quietFerryLights=[];quietFerryWren=null;activeWorld="platform";skyLight=null;sunLight=null;occluders=new Set;cameraBlockers=new Map;initialized=!1;frames=0;lastSnapshot=null;previousSnapshotTime=null;previousPlayerPosition=null;walkPhase=0;movementSpeed=0;balloonPosition=null;balloonVelocity={x:0,y:0,z:0};cameraTarget=null;cameraFollowLead={x:0,z:0};cameraObstaclePullback=0;cameraObstacleTarget=0;cinematicPhase="idle";doorOpenProgress=0;occludedMeshCount=0;lastOcclusionUpdate=0;qualityProfile;async init(){if(this.initialized)return;const[{Scene:e},{Color3:t,Color4:i},{Vector3:s},{MeshBuilder:r},{StandardMaterial:a},{ShaderMaterial:n},{HemisphericLight:l},{DirectionalLight:c},{PointLight:h},{ArcRotateCamera:f},{DefaultRenderingPipeline:d}]=await Promise.all([Ue(()=>import("./scene-BZpG6kJx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),Ue(()=>import("./math.color-DBdvdSDj.js"),__vite__mapDeps([11,3])),Ue(()=>import("./math.vector-Dx30T4M2.js"),__vite__mapDeps([12,3])),Ue(()=>import("./meshBuilder-g_krcYA6.js"),__vite__mapDeps([13,3,4,1,2,5,6,7,8,14,15,16,17,9,18,19,10])),Ue(()=>import("./standardMaterial-C93UVSXE.js"),__vite__mapDeps([20,7,8,3,4,1,2,5,6,19,18,9,10])),Ue(()=>import("./shaderMaterial-CxFpRvHi.js"),__vite__mapDeps([21,14,3,1,2,4,5,6,15,16,17,9,18,19,7,8,10])),Ue(()=>import("./hemisphericLight-DXitrgl2.js"),__vite__mapDeps([22,3,23,7,8,4,2,9,10])),Ue(()=>import("./directionalLight-CAC3iWIj.js"),__vite__mapDeps([24,3,23,25,7,8,4,2,9,10])),Ue(()=>import("./pointLight-jLSQ-UDJ.js"),__vite__mapDeps([26,3,23,25,7,8,4,2,9,10])),Ue(()=>import("./arcRotateCamera-_1DRbdwW.js"),__vite__mapDeps([27,3,5,17,2,9,7,8,4,10])),Ue(()=>import("./defaultRenderingPipeline-BUzIWdM6.js"),__vite__mapDeps([28,3,15,16,17,2,9,7,8,1,4,5,6,29,18,10]))]);this.m={Scene:e,Color3:t,Color4:i,Vector3:s,MeshBuilder:r,StandardMaterial:a,ShaderMaterial:n,HemisphericLight:l,DirectionalLight:c,PointLight:h,ArcRotateCamera:f,DefaultRenderingPipeline:d};const u=new e(this.engine);this.scene=u,u.clearColor=new i(.055,.065,.105,1),u.fogMode=e.FOGMODE_EXP2,u.fogDensity=.012,u.fogColor=new t(.075,.09,.14),u.ambientColor=new t(.08,.08,.12);const E=new l("dusk-fill",new s(0,1,0),u);this.skyLight=E,E.intensity=.42,E.diffuse=new t(.38,.47,.68),E.groundColor=new t(.08,.045,.07);const _=new c("last-light",new s(-.7,-1,-.32),u);this.sunLight=_,_.intensity=1.05,_.diffuse=new t(1,.47,.25);const M=new f("atlas-camera",-Math.PI*.73,Math.PI*.31,18.5,new s(0,0,0),u);M.fov=.76,M.lowerRadiusLimit=10,M.upperRadiusLimit=25,M.lowerBetaLimit=.54,M.upperBetaLimit=1.32,M.wheelPrecision=55,M.panningSensibility=0,M.attachControl(this.canvas,!0),this.camera=M;const v=this.canvas.ownerDocument?.defaultView?.matchMedia?.("(pointer: coarse)").matches??!1;if(this.qualityProfile==="cinematic"&&this.engine.webGLVersion>=2&&!v){const m=new d("atlas-cinematic",!0,u,[M]);m.fxaaEnabled=!0,m.samples=4,m.bloomEnabled=!0,m.bloomThreshold=.72,m.bloomWeight=.22,m.bloomKernel=48,m.imageProcessingEnabled=!0,m.imageProcessing.contrast=1.28,m.imageProcessing.exposure=1.08}this.buildPepe(),this.buildPepeEchoes(),this.buildLibraryLandmark(),this.buildPlatform(),this.buildNorthboundHalt(),this.buildLanternSpan(),this.buildGlimmerVale(),this.buildKitegarden(),this.buildQuietFerry(),this.setActiveWorld("library"),this.initialized=!0}resetCamera(){this.camera&&(this.camera.alpha=-Math.PI*.73,this.camera.beta=Math.PI*.31,this.camera.radius=18.5,this.cameraTarget=null,this.cameraFollowLead={x:0,z:0},this.cameraObstaclePullback=0,this.cameraObstacleTarget=0)}buildPepe(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t,Color3:i}=this.m,s=e.CreateCapsule("pepe",{radius:.38,height:.82,tessellation:8},this.scene);s.position.y=.44,s.material=this.mat("pepe-cream",[.69,.58,.44]),this.player=s;const r=e.CreateSphere("pepe-head",{diameter:.72,segments:8},this.scene);r.position=new t(0,.83,-.015),r.parent=s,r.material=this.mat("pepe-cream",[.69,.58,.44]);const a=e.CreateCapsule("pepe-ruff",{radius:.42,height:.25,tessellation:8},this.scene);a.position=new t(0,.61,.015),a.scaling.z=.82,a.parent=s,a.material=this.mat("pepe-ruff",[.78,.69,.55]);const n=e.CreateSphere("pepe-mask",{diameter:.49,segments:8},this.scene);n.position=new t(0,.85,-.345),n.scaling.y=.82,n.parent=s,n.material=this.mat("pepe-points",[.16,.105,.085]);for(const d of[-1,1]){const u=e.CreateCylinder(`pepe-ear-${d}`,{diameterTop:0,diameterBottom:.22,height:.34,tessellation:4},this.scene);u.position=new t(d*.22,1.18,-.015),u.parent=s,u.material=this.mat("pepe-points",[.16,.105,.085])}const l=this.mat("pepe-eyes",[.34,.22,.1],!0);for(const d of[-1,1]){const u=e.CreateSphere(`pepe-eye-${d}`,{diameter:.055,segments:6},this.scene);u.position=new t(d*.14,.91,-.405),u.parent=s,u.material=l}for(const d of[-1,1]){const u=e.CreateCapsule(`pepe-leg-${d}`,{radius:.11,height:.42,tessellation:7},this.scene);u.position=new t(d*.22,-.34,0),u.parent=s,u.material=this.mat("pepe-points",[.16,.105,.085]),this.pepeLegs.push(u)}const c=e.CreateCylinder("pepe-tail",{height:.82,diameter:.18,tessellation:7},this.scene);c.position=new t(-.39,.16,.15),c.rotation.z=Math.PI*.34,c.parent=s,c.material=this.mat("pepe-points",[.16,.105,.085]),this.pepeTail=c;for(const d of[-1,1]){const u=e.CreateCylinder(`pepe-whisker-${d}`,{height:.34,diameter:.014,tessellation:4},this.scene);u.position=new t(d*.22,.85,-.41),u.rotation.z=d*Math.PI*.46,u.parent=s,u.material=this.mat("pepe-whiskers",[.92,.86,.72])}const h=e.CreateBox("pepe-scarf",{width:.72,height:.11,depth:.11},this.scene);h.position=new t(0,.62,.04),h.rotation.z=-.08,h.parent=s,h.material=this.mat("pepe-scarf",[.55,.32,.15]),this.pepeScarf=h;const f=e.CreateSphere("red-balloon",{diameter:.72,segments:16},this.scene);f.scaling.y=1.28,f.material=this.mat("balloon-red",[.82,.012,.025],!0),this.balloon=f,this.tether=e.CreateCylinder("balloon-tether",{height:1,diameter:.025,tessellation:4},this.scene),this.tether.material=this.mat("balloon-tether",[.74,.69,.58]),this.balloonKnot=e.CreateCylinder("balloon-knot",{diameterTop:0,diameterBottom:.11,height:.15,tessellation:5},this.scene),this.balloonKnot.material=this.mat("balloon-red",[.82,.012,.025],!0)}buildPepeEchoes(){if(!this.m||!this.scene)return;const{MeshBuilder:e}=this.m,t=[[.64,.53,.4],[.72,.62,.48],[.58,.47,.36]],i=t.map((a,n)=>{const l=e.CreateCapsule(`pepe-echo-body-${n}`,{radius:.2,height:.48,tessellation:6},this.scene);return l.material=this.mat(`pepe-echo-cream-${n}`,a),l.isVisible=!1,l}),s=t.map((a,n)=>{const l=e.CreateSphere(`pepe-echo-head-${n}`,{diameter:.34,segments:6},this.scene);return l.material=this.mat(`pepe-echo-point-${n}`,[.15,.1,.08]),l.isVisible=!1,l}),r=t.map((a,n)=>{const l=e.CreateCylinder(`pepe-echo-tail-${n}`,{height:.4,diameter:.09,tessellation:6},this.scene);return l.material=this.mat(`pepe-echo-point-${n}`,[.15,.1,.08]),l.isVisible=!1,l});this.pepeEchoTemplates=[...i,...s,...r]}updatePepeEchoes(e){if(!this.m||this.pepeEchoTemplates.length===0)return;
2699const t=this.qualityProfile==="cinematic"?16:8,i=`${e.currentWorld}:${e.player.doorsOpened}:${e.player.deliveriesCompleted}:${t}`;if(i===this.pepeEchoKey)return;this.pepeEchoKey=i;const s=bn(e,t);this.pepeEchoInstances.forEach(c=>c.dispose()),this.pepeEchoInstances=[];const r=(c,h,f,d,u,E,_=0)=>{const M=c.createInstance(`pepe-echo-${this.pepeEchoInstances.length}`);M.position.set(h,f,d),M.scaling.setAll(u),M.rotation.y=E,M.rotation.z=_,this.pepeEchoInstances.push(M)},a=this.pepeEchoTemplates.slice(0,3),n=this.pepeEchoTemplates.slice(3,6),l=this.pepeEchoTemplates.slice(6,9);for(const c of s.echoes){const h=c.coatVariant,f=c.phase-Math.PI/2,d=c.scale,u=c.position.x+.5,E=c.position.y+.5;r(a[h],u,.26,E,d,f),r(n[h],u+Math.cos(f)*.08,.54,E+Math.sin(f)*.08,d,f),r(l[h],u-Math.cos(f)*.18,.32,E-Math.sin(f)*.18,d,f+Math.PI*.28,Math.PI*.28)}this.pepeEchoCount=s.echoes.length}buildLibraryLandmark(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t}=this.m,i=(n,l=!1)=>(this.staticMeshes.push(n),l&&this.occluders.add(n),n),s=i(e.CreateBox("north-library-facade",{width:10.8,height:4.7,depth:1.35},this.scene),!0);s.position=new t(4.5,2.35,-10.1),s.material=this.mat("library-stone",[.25,.18,.18]);const r=i(e.CreateCylinder("north-library-pediment",{diameter:6.7,height:.5,tessellation:3},this.scene));r.position=new t(4.5,4.85,-9.36),r.rotation.x=Math.PI/2,r.rotation.z=Math.PI/2,r.material=this.mat("library-trim",[.39,.3,.27]);for(const n of[1.15,2.45,6.55,7.85]){const l=i(e.CreateCylinder(`library-column-${n}`,{height:3.65,diameter:.42,tessellation:8},this.scene));l.position=new t(n,2,-9.25),l.material=this.mat("library-trim",[.39,.3,.27])}for(let n=0;n<3;n++){const l=i(e.CreateBox(`library-step-${n}`,{width:8.8-n*.45,height:.16,depth:.62},this.scene));l.position=new t(4.5,.08+n*.15,-8.55-n*.42),l.material=this.mat("library-step",[.29,.25,.25])}const a=this.mat("window-warm",[1,.43,.12],!0);for(const n of[.4,1.2,2,7,7.8,8.6])for(const l of[1.25,2.45,3.65]){const c=i(e.CreatePlane(`library-window-${n}-${l}`,{width:.52,height:.72},this.scene));c.position=new t(n,l,-9.405),c.material=a}for(const[n,l,c]of[[.45,-5.8,Math.PI/2],[8.55,-5.8,Math.PI/2],[.45,-1.5,Math.PI/2],[8.55,-1.5,Math.PI/2]]){const h=i(e.CreateCylinder(`courtyard-lamp-${n}-${l}`,{height:2.35,diameter:.11,tessellation:8},this.scene));h.position=new t(n,1.17,l),h.rotation.y=c,h.material=this.mat("lamp-iron",[.045,.05,.06]);const f=i(e.CreateSphere(`courtyard-lantern-${n}-${l}`,{diameter:.34,segments:8},this.scene));f.position=new t(n,2.28,l),f.material=this.mat("lamp-warm",[1,.36,.08],!0)}for(const[n,l]of[[1.6,-3.3],[7.4,-3.3]]){const c=i(e.CreateBox(`courtyard-bench-${n}`,{width:1.45,height:.18,depth:.48},this.scene));c.position=new t(n,.48,l),c.material=this.mat("bench-wood",[.28,.14,.08]);for(const h of[-.55,.55]){const f=i(e.CreateBox(`bench-leg-${n}-${h}`,{width:.12,height:.42,depth:.35},this.scene));f.position=new t(n+h,.22,l),f.material=this.mat("lamp-iron",[.045,.05,.06])}}}buildPlatform(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t,PointLight:i}=this.m,s=m=>(this.platformMeshes.push(m),m),r=this.mat("platform-cloud",[.42,.5,.66],!0),a=this.mat("platform-deck",[.11,.15,.2]),n=this.mat("platform-rail",[.05,.07,.1]),l=this.mat("platform-warm",[1,.42,.1],!0),c=this.mat("platform-return-red",[.78,.015,.03],!0),h=this.mat("platform-sign",[.72,.62,.28],!0);for(const[m,b,x]of[[-8,-5,3.1],[-2,4,4.4],[6,-3,3.7],[11,5,5.2]]){const A=s(e.CreateSphere(`platform-cloud-${m}-${b}`,{diameter:2.6,segments:8},this.scene));A.position=new t(m,-1.6,b),A.scaling.set(x,.28,x*.55),A.material=r}const f=s(e.CreateBox("platform-deck",{width:17,height:.32,depth:7},this.scene));f.position=new t(0,-.16,0),f.material=a;for(const m of[-7.5,-4.5,-1.5,1.5,4.5,7.5]){const b=s(e.CreateCylinder(`platform-support-${m}`,{height:4.8,diameter:.22,tessellation:6},this.scene));b.position=new t(m,-2.45,0),b.material=n}for(const m of[-3.2,3.2]){const b=s(e.CreateBox(`platform-rail-${m}`,{width:17,height:.75,depth:.1},this.scene));b.position=new t(0,.38,m),b.material=n}const d=s(e.CreateBox("platform-shelter",{width:3.8,height:2.45,depth:2.1},this.scene));d.position=new t(-2.2,1.15,-1.85),d.material=this.mat("platform-shelter",[.16,.12,.14]);for(const m of[-3.25,-2.2,-1.15]){const b=s(e.CreatePlane(`platform-window-${m}`,{width:.58,height:.88},this.scene));b.position=new t(m,1.28,-2.92),b.material=l}const u=s(e.CreateSphere("platform-shelter-lamp",{diameter:.28,segments:8},this.scene));u.position=new t(-2.2,2.28,-.5),u.material=l;const E=new i("platform-warm-light",new t(-2.2,2.2,-.5),this.scene);E.diffuse=new this.m.Color3(1,.37,.08),E.intensity=1.25,E.range=7,this.platformLights.push(E);const _=s(e.CreateCylinder("platform-sign-pole",{height:2.4,diameter:.11,tessellation:6},this.scene));_.position=new t(6.9,1.2,0),_.material=n;const M=s(e.CreateBox("platform-northbound-sign",{width:1.75,height:.58,depth:.12},this.scene));M.position=new t(6.9,2.15,0),M.material=h,this.platformBeacon=s(e.CreateSphere("platform-route-beacon",{diameter:.22,segments:6},this.scene)),this.platformBeacon.position=new t(6.9,2.7,0),this.platformBeacon.material=c;
2699const v=s(e.CreateBox("platform-return-door",{width:1.15,height:2.45,depth:.18},this.scene));v.position=new t(-6.9,1.22,0),v.material=c;for(const[m,b,x,A]of[[-7.56,1.28,.16,2.7],[-6.24,1.28,.16,2.7],[-6.9,2.56,1.48,.16]]){const C=s(e.CreateBox(`platform-return-frame-${m}-${b}`,{width:x,height:A,depth:.22},this.scene));C.position=new t(m,b,.06),C.material=n}const S=s(e.CreateBox("platform-impossible-rail",{width:22,height:.08,depth:.12},this.scene));S.position=new t(8.5,4.6,-9.5),S.rotation.z=-.16,S.material=h}buildNorthboundHalt(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t,PointLight:i}=this.m,s=W=>(this.northboundMeshes.push(W),W),r=this.mat("northbound-steel",[.055,.085,.14]),a=this.mat("northbound-deck",[.075,.11,.17]),n=this.mat("northbound-cabin",[.12,.1,.16]),l=this.mat("northbound-warm",[1,.34,.08],!0),c=this.mat("northbound-signal",[.05,.42,.96],!0),h=this.mat("northbound-return",[.8,.012,.03],!0),f=this.mat("northbound-cloud",[.2,.31,.55],!0);for(const[W,I,R]of[[-9,-4,3.2],[-2,3.2,4.3],[7.5,-2.8,4.7]]){const z=s(e.CreateSphere(`northbound-cloud-${W}-${I}`,{diameter:2.5,segments:8},this.scene));z.position=new t(W,-1.55,I),z.scaling.set(R,.24,R*.62),z.material=f}const d=s(e.CreateBox("northbound-deck",{width:14,height:.32,depth:5.6},this.scene));d.position=new t(0,-.16,0),d.material=a;for(const W of[-6,-3,0,3,6]){const I=s(e.CreateCylinder(`northbound-support-${W}`,{height:4.4,diameter:.22,tessellation:6},this.scene));I.position=new t(W,-2.35,0),I.material=r}for(const W of[-1.65,1.65]){const I=s(e.CreateBox(`northbound-rail-${W}`,{width:17.5,height:.1,depth:.1},this.scene));I.position=new t(1.3,.34,W),I.rotation.z=-.075,I.material=c}for(const W of[-2.55,2.55]){const I=s(e.CreateBox(`northbound-safety-${W}`,{width:14,height:.72,depth:.1},this.scene));I.position=new t(0,.34,W),I.material=r}const u=s(e.CreateBox("northbound-signal-cabin",{width:3.45,height:2.4,depth:2.05},this.scene));u.position=new t(.9,1.05,-1.4),u.material=n;for(const W of[-.1,.9,1.9]){const I=s(e.CreatePlane(`northbound-window-${W}`,{width:.56,height:.84},this.scene));I.position=new t(W,1.16,-2.45),I.material=l}const E=new i("northbound-cabin-light",new t(.9,1.85,-.55),this.scene);E.diffuse=new this.m.Color3(1,.31,.07),E.intensity=1.25,E.range=6,this.northboundLights.push(E);const _=s(e.CreateCylinder("northbound-signal-post",{height:1.65,diameter:.14,tessellation:6},this.scene));_.position=new t(4.8,.83,0),_.material=r;const M=s(e.CreateBox("northbound-signal-lever",{width:.14,height:.96,depth:.14},this.scene));M.position=new t(4.8,1.47,0),M.rotation.z=-.36,M.material=c,this.northboundBeacon=s(e.CreateSphere("northbound-signal-beacon",{diameter:.27,segments:7},this.scene)),this.northboundBeacon.position=new t(4.8,2.08,0),this.northboundBeacon.material=c;const v=new i("northbound-signal-light",new t(4.8,2.08,0),this.scene);v.diffuse=new this.m.Color3(.06,.4,1),v.intensity=1.1,v.range=5.5,this.northboundLights.push(v);const S=s(e.CreateCapsule("northbound-rook-coat",{radius:.25,height:.78,tessellation:7},this.scene));S.position=new t(2.25,.42,-1.75),S.material=this.mat("northbound-rook-coat",[.12,.16,.25]);const m=s(e.CreateSphere("northbound-rook-head",{diameter:.42,segments:7},this.scene));m.position=new t(2.25,.94,-1.75),m.material=this.mat("northbound-rook-head",[.46,.35,.25]);const b=s(e.CreateCylinder("northbound-rook-cap",{height:.12,diameter:.48,tessellation:7},this.scene));b.position=new t(2.25,1.18,-1.75),b.material=r;const x=s(e.CreateBox("northbound-rook-blue-scarf",{width:.54,height:.09,depth:.11},this.scene));x.position=new t(2.25,.74,-1.75),x.material=c;const A=s(e.CreateCylinder("northbound-lantern-gate-post",{height:2.85,diameter:.14,tessellation:6},this.scene));A.position=new t(6.35,1.42,0),A.material=c;const C=s(e.CreateBox("northbound-lantern-gate-header",{width:.16,height:.16,depth:2.45},this.scene));C.position=new t(6.35,2.72,0),C.material=c;const B=s(e.CreateSphere("northbound-lantern-gate-light",{diameter:.34,segments:7},this.scene));B.position=new t(6.35,2.23,0),B.material=c,this.northboundGate.push(A,C,B),this.northboundGate.forEach(W=>W.setEnabled(!1));
2699const O=s(e.CreateBox("northbound-return-door",{width:1.14,height:2.42,depth:.18},this.scene));O.position=new t(-5.8,1.21,0),O.material=h;for(const[W,I,R,z]of[[-6.44,1.26,.16,2.7],[-5.16,1.26,.16,2.7],[-5.8,2.54,1.45,.16]]){const V=s(e.CreateBox(`northbound-return-frame-${W}-${I}`,{width:R,height:z,depth:.22},this.scene));V.position=new t(W,I,.06),V.material=r}const P=s(e.CreateCylinder("northbound-arch-left",{height:5.2,diameter:.2,tessellation:6},this.scene));P.position=new t(8.1,2.6,-2.45),P.material=r;const Z=s(e.CreateCylinder("northbound-arch-right",{height:5.2,diameter:.2,tessellation:6},this.scene));Z.position=new t(8.1,2.6,2.45),Z.material=r;const Y=s(e.CreateBox("northbound-signal-arch",{width:.2,height:.2,depth:5.1},this.scene));Y.position=new t(8.1,5.15,0),Y.material=c}buildLanternSpan(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t,PointLight:i}=this.m,s=v=>(this.lanternSpanMeshes.push(v),v),r=this.mat("span-deck",[.065,.1,.16]),a=this.mat("span-rail",[.08,.38,.88],!0),n=this.mat("span-warm",[1,.31,.08],!0),l=this.mat("span-return",[.8,.012,.03],!0),c=this.mat("span-cloud",[.16,.23,.46],!0);for(const[v,S,m]of[[-8,-3,3.6],[-1,4,4.2],[8,-2,4.6]]){const b=s(e.CreateSphere(`span-cloud-${v}-${S}`,{diameter:2.5,segments:8},this.scene));b.position=new t(v,-1.55,S),b.scaling.set(m,.22,m*.62),b.material=c}const h=s(e.CreateBox("lantern-span-deck",{width:14.4,height:.3,depth:4.5},this.scene));h.position=new t(.8,-.15,0),h.material=r;for(const v of[-1.95,1.95]){const S=s(e.CreateBox(`span-safety-${v}`,{width:14.4,height:.66,depth:.09},this.scene));S.position=new t(.8,.32,v),S.material=a}const f=s(e.CreateBox("span-impossible-rail",{width:18.5,height:.08,depth:.13},this.scene));f.position=new t(4.7,.34,0),f.rotation.z=-.065,f.material=a;const d=s(e.CreateCylinder("span-lantern-post",{height:2.4,diameter:.12,tessellation:7},this.scene));d.position=new t(3.2,1.2,-1.32),d.material=this.mat("span-steel",[.06,.08,.13]),this.lanternSpanBeacon=s(e.CreateSphere("span-lantern",{diameter:.35,segments:8},this.scene)),this.lanternSpanBeacon.position=new t(3.2,2.45,-1.32),this.lanternSpanBeacon.material=n;const u=new i("span-lantern-light",new t(3.2,2.45,-1.32),this.scene);u.diffuse=new this.m.Color3(1,.3,.08),u.intensity=1.35,u.range=6.5,this.lanternSpanLights.push(u);const E=s(e.CreateBox("span-return-door",{width:1.14,height:2.42,depth:.18},this.scene));E.position=new t(-5.4,1.21,0),E.material=l;const _=s(e.CreateBox("span-return-frame",{width:1.48,height:2.75,depth:.12},this.scene));_.position=new t(-5.4,1.35,.08),_.material=this.mat("span-return-frame",[.055,.05,.08]);const M=s(e.CreateTorus("span-far-arch",{diameter:3.6,thickness:.1,tessellation:12},this.scene));M.position=new t(8,3,0),M.rotation.x=Math.PI/2,M.material=a}buildGlimmerVale(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t,PointLight:i}=this.m,s=S=>(this.glimmerMeshes.push(S),S),r=this.mat("glimmer-meadow",[.11,.16,.18]),a=this.mat("glimmer-violet",[.46,.18,.72],!0),n=this.mat("glimmer-warm",[1,.34,.08],!0),l=this.mat("glimmer-gate-blue",[.04,.46,1],!0),c=this.mat("glimmer-return-red",[.8,.012,.03],!0),h=this.mat("glimmer-stone",[.14,.12,.18]),f=s(e.CreateGround("glimmer-valley-ground",{width:15.2,height:6.4},this.scene));f.material=r;for(const[S,m,b]of[[-6,-2.7,1.2],[-1.4,2.8,1.6],[4.5,-2.6,1.35]]){const x=s(e.CreateSphere(`glimmer-island-${S}`,{diameter:2.2,segments:8},this.scene));x.position=new t(S,-.7,m),x.scaling.set(b,.35,b*.72),x.material=h}[[-2.4,-1.25],[.9,1.2],[3.4,-1.1]].forEach(([S,m],b)=>{const x=s(e.CreateCylinder(`glimmer-lamp-post-${b}`,{height:2.2,diameter:.12,tessellation:7},this.scene));x.position=new t(S,1.1,m),x.material=h;const A=s(e.CreateSphere(`glimmer-memory-lamp-${b}`,{diameter:.34,segments:8},this.scene));A.position=new t(S,2.28,m),A.material=a,this.glimmerLampGlows.push(A);const C=new i(`glimmer-lamp-light-${b}`,new t(S,2.28,m),this.scene);C.diffuse=new this.m.Color3(.74,.28,1),C.intensity=.35,C.range=4.3,this.glimmerLights.push(C)});const u=s(e.CreateCapsule("glimmer-morrow-coat",{radius:.24,height:.76,tessellation:7},this.scene));u.position=new t(-.2,.4,-1.75),u.material=this.mat("glimmer-morrow-coat",[.22,.12,.31]);const E=s(e.CreateSphere("glimmer-morrow-head",{diameter:.4,segments:7},this.scene));E.position=new t(-.2,.92,-1.75),E.material=this.mat("glimmer-morrow-head",[.52,.39,.29]);const _=s(e.CreateSphere("glimmer-morrow-lantern",{diameter:.2,segments:6},this.scene));_.position=new t(.26,.6,-1.75),_.material=n;
2699const M=s(e.CreateBox("glimmer-return-door",{width:1.14,height:2.4,depth:.18},this.scene));M.position=new t(-6.2,1.2,0),M.material=c;const v=s(e.CreateTorus("glimmer-kite-gate",{diameter:2.6,thickness:.12,tessellation:12},this.scene));v.position=new t(6.3,1.85,0),v.rotation.x=Math.PI/2,v.material=l,this.glimmerGate.push(v)}buildKitegarden(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t,PointLight:i}=this.m,s=S=>(this.kitegardenMeshes.push(S),S),r=this.mat("kitegarden-turf",[.08,.25,.18]),a=this.mat("kitegarden-leaf",[.2,.55,.28]),n=this.mat("kitegarden-gold",[.95,.68,.12],!0),l=this.mat("kitegarden-kite",[.1,.62,.95],!0),c=this.mat("kitegarden-return-red",[.8,.012,.03],!0),h=s(e.CreateGround("kitegarden-ground",{width:15.2,height:6.4},this.scene));h.material=r;for(const[S,m,b]of[[-4.5,-1.7,2.7],[-1,1.85,3.4],[3.2,-1.55,3.1],[5.3,1.3,2.4]]){const x=s(e.CreateCylinder(`kite-tree-trunk-${S}`,{height:b,diameter:.22,tessellation:7},this.scene));x.position=new t(S,b/2,m),x.material=this.mat("kitegarden-wood",[.19,.1,.07]);const A=s(e.CreateSphere(`kite-tree-canopy-${S}`,{diameter:1.7,segments:8},this.scene));A.position=new t(S,b+.45,m),A.scaling.y=.62,A.material=a}[[-2.2,-1.2],[1.1,1.25],[3.7,-1.05]].forEach(([S,m],b)=>{const x=s(e.CreateCylinder(`kite-perch-${b}`,{height:1.65,diameter:.1,tessellation:6},this.scene));x.position=new t(S,.82,m),x.material=n;const A=s(e.CreateBox(`kite-loose-${b}`,{width:.46,height:.46,depth:.08},this.scene));A.position=new t(S,2,m),A.rotation.z=Math.PI/4,A.material=l,this.kiteMeshes.push(A)});const d=s(e.CreateCapsule("kite-jun-coat",{radius:.24,height:.76,tessellation:7},this.scene));d.position=new t(-.25,.4,-1.85),d.material=this.mat("kite-jun-coat",[.18,.35,.16]);const u=s(e.CreateCylinder("kite-jun-hat",{height:.12,diameter:.5,tessellation:7},this.scene));u.position=new t(-.25,1.2,-1.85),u.material=n;const E=s(e.CreateBox("kite-return-door",{width:1.14,height:2.4,depth:.18},this.scene));E.position=new t(-6.2,1.2,0),E.material=c;const _=s(e.CreateBox("kite-ferry-dock",{width:2.5,height:.28,depth:2.2},this.scene));_.position=new t(6.35,.04,0),_.material=this.mat("kite-ferry-dock",[.34,.2,.1]);const M=s(e.CreateSphere("kite-dock-lamp",{diameter:.3,segments:7},this.scene));M.position=new t(6.35,1.85,0),M.material=n,this.kiteFerryDock.push(_,M);const v=new i("kite-dock-light",new t(6.35,1.85,0),this.scene);v.diffuse=new this.m.Color3(1,.66,.15),v.intensity=.7,v.range=5.5,this.kitegardenLights.push(v)}
2699buildQuietFerry(){if(!this.m||!this.scene)return;const{MeshBuilder:e,Vector3:t,PointLight:i}=this.m,s=m=>(this.quietFerryMeshes.push(m),m),r=this.mat("ferry-water",[.035,.16,.25],!0),a=this.mat("ferry-dock",[.18,.14,.11]),n=this.mat("ferry-hull",[.09,.26,.34]),l=this.mat("ferry-warm",[1,.38,.08],!0),c=this.mat("ferry-return-red",[.8,.012,.03],!0),h=s(e.CreateGround("quiet-ferry-water",{width:15.4,height:6.4},this.scene));h.position.y=-.22,h.material=r;const f=s(e.CreateBox("quiet-ferry-dock",{width:10.2,height:.32,depth:2.8},this.scene));f.position=new t(1.3,0,0),f.material=a;const d=s(e.CreateBox("quiet-ferry-hull",{width:3.3,height:.64,depth:1.55},this.scene));d.position=new t(4.35,.33,-1.75),d.material=n;const u=s(e.CreateBox("quiet-ferry-cabin",{width:1.5,height:1.35,depth:1.05},this.scene));u.position=new t(4.35,1.3,-1.75),u.material=this.mat("ferry-cabin",[.12,.2,.25]);const E=s(e.CreateSphere("quiet-ferry-lamp",{diameter:.28,segments:7},this.scene));E.position=new t(4.35,2.1,-1.75),E.material=l;const _=new i("quiet-ferry-lamp-light",new t(4.35,2.1,-1.75),this.scene);_.diffuse=new this.m.Color3(1,.34,.08),_.intensity=1,_.range=6,this.quietFerryLights.push(_);const M=s(e.CreateCapsule("quiet-ferry-nia-coat",{radius:.24,height:.76,tessellation:7},this.scene));M.position=new t(-.2,.4,-1.3),M.material=this.mat("quiet-ferry-nia-coat",[.12,.3,.4]);const v=s(e.CreateCylinder("quiet-ferry-nia-hat",{height:.12,diameter:.48,tessellation:7},this.scene));v.position=new t(-.2,1.18,-1.3),v.material=a,this.quietFerryWren=s(e.CreateSphere("quiet-ferry-ticket-wren",{diameter:.28,segments:7},this.scene)),this.quietFerryWren.position=new t(1.8,.72,-.6),this.quietFerryWren.material=l;
2699const S=s(e.CreateBox("quiet-ferry-return-door",{width:1.14,height:2.4,depth:.18},this.scene));S.position=new t(-6.3,1.2,0),S.material=c}setActiveWorld(e){if(!this.m||!this.scene||this.activeWorld===e)return;this.activeWorld=e;const t=e==="library",i=e==="platform",s=e==="northbound",r=e==="lanternSpan",a=e==="glimmerVale",n=e==="kitegarden",l=e==="quietFerry";if(this.staticMeshes.forEach(c=>c.setEnabled(t)),this.platformMeshes.forEach(c=>c.setEnabled(i)),this.platformLights.forEach(c=>c.setEnabled(i)),this.northboundMeshes.forEach(c=>c.setEnabled(s)),this.northboundLights.forEach(c=>c.setEnabled(s)),this.lanternSpanMeshes.forEach(c=>c.setEnabled(r)),this.lanternSpanLights.forEach(c=>c.setEnabled(r)),this.glimmerMeshes.forEach(c=>c.setEnabled(a)),this.glimmerLights.forEach(c=>c.setEnabled(a)),this.kitegardenMeshes.forEach(c=>c.setEnabled(n)),this.kitegardenLights.forEach(c=>c.setEnabled(n)),this.quietFerryMeshes.forEach(c=>c.setEnabled(l)),this.quietFerryLights.forEach(c=>c.setEnabled(l)),t){this.scene.clearColor=new this.m.Color4(.055,.065,.105,1),this.scene.fogColor=new this.m.Color3(.075,.09,.14),this.scene.fogDensity=.012,this.skyLight&&(this.skyLight.diffuse=new this.m.Color3(.38,.47,.68)),this.sunLight&&(this.sunLight.diffuse=new this.m.Color3(1,.47,.25));return}if(i){this.scene.clearColor=new this.m.Color4(.025,.055,.14,1),this.scene.fogColor=new this.m.Color3(.11,.17,.3),this.scene.fogDensity=.006,this.skyLight&&(this.skyLight.diffuse=new this.m.Color3(.28,.44,.82)),this.sunLight&&(this.sunLight.diffuse=new this.m.Color3(.5,.58,.88));return}if(r){this.scene.clearColor=new this.m.Color4(.01,.025,.075,1),this.scene.fogColor=new this.m.Color3(.045,.09,.2),this.scene.fogDensity=.004,this.skyLight&&(this.skyLight.diffuse=new this.m.Color3(.16,.26,.66)),this.sunLight&&(this.sunLight.diffuse=new this.m.Color3(.36,.3,.7));return}if(a){this.scene.clearColor=new this.m.Color4(.055,.025,.11,1),this.scene.fogColor=new this.m.Color3(.15,.07,.26),this.scene.fogDensity=.006,this.skyLight&&(this.skyLight.diffuse=new this.m.Color3(.42,.22,.68)),this.sunLight&&(this.sunLight.diffuse=new this.m.Color3(.75,.3,.98));return}if(n){this.scene.clearColor=new this.m.Color4(.025,.105,.15,1),this.scene.fogColor=new this.m.Color3(.09,.27,.29),this.scene.fogDensity=.005,this.skyLight&&(this.skyLight.diffuse=new this.m.Color3(.25,.68,.62)),this.sunLight&&(this.sunLight.diffuse=new this.m.Color3(.86,.72,.3));return}if(l){this.scene.clearColor=new this.m.Color4(.015,.06,.11,1),this.scene.fogColor=new this.m.Color3(.04,.19,.28),this.scene.fogDensity=.005,this.skyLight&&(this.skyLight.diffuse=new this.m.Color3(.18,.48,.68)),this.sunLight&&(this.sunLight.diffuse=new this.m.Color3(.25,.72,.84));return}this.scene.clearColor=new this.m.Color4(.015,.035,.09,1),this.scene.fogColor=new this.m.Color3(.06,.12,.25),this.scene.fogDensity=.0045,this.skyLight&&(this.skyLight.diffuse=new this.m.Color3(.18,.32,.72)),this.sunLight&&(this.sunLight.diffuse=new this.m.Color3(.25,.46,.98))}upsertChunk(e){if(!this.m||!this.scene)return;const t=`${e.coordinate.x},${e.coordinate.y}`;this.removeChunk(t);const{MeshBuilder:i,Vector3:s}=this.m,r=[],a=i.CreateGround(`ground-${t}`,{width:e.size,height:e.size},this.scene);a.position=new s(e.origin.x+e.size/2,0,e.origin.y+e.size/2),a.material=this.mat(`biome-${e.biome}`,Ro[e.biome]),r.push(a);const n=new Map,l=(x,A,C)=>{const B=`prop-${x}-${t}`;let O=A==="box"?i.CreateBox(B,C,this.scene):i.CreateCylinder(B,{height:C.height,diameter:C.diameter,tessellation:7},this.scene);return O.material=this.mat(`tile-${x}`,Lo[x]),n.set(x,O),r.push(O),O},c=l("road","box",{width:.98,depth:.98,height:.045}),h=l("pavement","box",{width:.98,depth:.98,height:.065}),f=l("water","box",{width:.98,depth:.98,height:.025}),d=l("tree","cylinder",{height:1.8,diameter:.62}),u=l("flowers","cylinder",{height:1.45,diameter:.1}),E=i.CreatePlane(`window-warm-${t}`,{width:.34,height:.42},this.scene);E.material=this.mat("window-warm",[1,.43,.12],!0),r.push(E);const _=i.CreateBox(`library-block-${t}`,{width:2.72,depth:2.72,height:1},this.scene);_.material=this.mat("brick-library",[.25,.13,.13]),r.push(_);const M=i.CreateCylinder(`roof-${t}`,{diameter:3.25,height:.22,tessellation:4},this.scene);M.material=this.mat("roof",[.075,.065,.085]),r.push(M);const v=new Map,S=[],m=(x,A,C,B,O=1,P=1,Z=1,Y=0)=>{const W=v.get(x)??[],I=Math.cos(Y),R=Math.sin(Y);W.push(I*O,0,-R*Z,0,0,P,0,0,R*O,0,I*Z,0,A,C,B,1),v.set(x,W)},b=new Set;for(let x=0;x<e.tiles.length;x++){const A=e.tiles[x],C=x%e.size,B=Math.floor(x/e.size),O=e.origin.x+C+.5,P=e.origin.y+B+.5;if(A.build){const Y=Fo[A.build.color];if(A.build.kind==="nest"){const W=i.CreateBox(`build-nest-${t}-${x}`,{width:.78,depth:.78,height:.62},this.scene);W.position=new s(O,.31,P),W.material=this.mat(`build-nest-${A.build.color}`,Y);const I=i.CreateCylinder(`build-nest-roof-${t}-${x}`,{diameter:1.02,height:.16,tessellation:4},this.scene);I.position=new s(O,.69,P),I.rotation.y=Math.PI/4,I.material=this.mat(`build-nest-roof-${A.build.color}`,Y.map(R=>Math.max(.04,R*.56))),r.push(W,I),S.push({x:O,z:P,radius:.66})}else if(A.build.kind==="garden"){const W=i.CreateCylinder(`build-garden-${t}-${x}`,{diameter:.78,height:.1,tessellation:8},this.scene);W.position=new s(O,.06,P),W.material=this.mat(`build-garden-${A.build.color}`,Y);const I=i.CreateSphere(`build-garden-bloom-${t}-${x}`,{diameter:.26,segments:6},this.scene);I.position=new s(O,.24,P),I.material=this.mat(`build-garden-bloom-${A.build.color}`,[.92,.78,.42],!0),r.push(W,I),S.push({x:O,z:P,radius:.42})}else{const W=i.CreateCylinder(`build-lamp-post-${t}-${x}`,{height:.76,diameter:.07,tessellation:6},this.scene);W.position=new s(O,.38,P),W.material=this.mat("build-lamp-post",[.08,.07,.09]);const I=i.CreateSphere(`build-lamp-glow-${t}-${x}`,{diameter:.25,segments:6},this.scene);I.position=new s(O,.81,P),I.material=this.mat(`build-lamp-${A.build.color}`,Y,!0),r.push(W,I),S.push({x:O,z:P,radius:.22})}continue}A.kind==="road"&&(C+B)%2===0?m(c,O,.025,P):A.kind==="pavement"&&(C+B)%2===0?m(h,O,.04,P):A.kind==="water"&&(C+B)%2===0?m(f,O,.015,P):A.kind==="tree"?m(d,O,.9,P,.7+.08*A.variant,1,.7+.08*A.variant):A.kind==="flowers"&&(C*3+B)%7===0&&m(u,O,.73,P);const Z=O>=-2&&O<=7&&P>=-9&&P<=2;if(A.kind==="wall"&&!Z){const Y=Math.floor(O/3)*3,W=Math.floor(P/3)*3,I=`${Y},${W}`;if(b.has(I))continue;b.add(I);const R=2.15+Math.abs(Y*7+W*11)%4*.46;
2699m(_,Y+1.5,R/2,W+1.5,1,R,1),S.push({x:Y+1.5,z:W+1.5,radius:2.2}),m(M,Y+1.5,R+.1,W+1.5,1,1,1,Math.PI/4);for(let z=.75;z<R-.35;z+=.78)for(const V of[-.78,.78])m(E,Y+1.5+V,z,W+.125)}}for(const[x,A]of v)x.thinInstanceSetBuffer("matrix",new Float32Array(A),16);this.chunks.set(t,r),this.cameraBlockers.set(t,S)}removeChunk(e){const t=this.chunks.get(e);t&&(t.forEach(i=>{this.occluders.delete(i),i.dispose()}),this.cameraBlockers.delete(e),this.chunks.delete(e))}renderSnapshot(e){if(!this.m||!this.player||!this.balloon||!this.tether||!this.balloonKnot||!this.camera)return;const t=Math.min(.08,Math.max(1/240,this.previousSnapshotTime===null?1/60:e.now-this.previousSnapshotTime)),i=this.previousPlayerPosition,s=i?e.player.position.x-i.x:0,r=i?e.player.position.y-i.y:0,a=Math.hypot(s,r);this.movementSpeed=a/t,this.previousSnapshotTime=e.now,this.previousPlayerPosition={...e.player.position},this.lastSnapshot=e,this.setActiveWorld(e.currentWorld),this.updatePepeEchoes(e);const{Vector3:n}=this.m,{x:l,y:c}=e.player.position,h=e.currentWorld==="platform",f=e.currentWorld==="northbound",d=e.currentWorld==="lanternSpan",u=e.currentWorld==="glimmerVale",E=e.currentWorld==="kitegarden",_=e.currentWorld==="quietFerry",M=h||f||d||u||E||_,v=e.now,S=Math.min(1,this.movementSpeed/4.2),m=a>1e-4?{x:s/a,z:r/a}:{x:0,z:0},b=Math.min(.86,this.movementSpeed*.16),x={x:m.x*b,z:m.z*b},A=1-Math.exp(-t*(a>1e-4?10.5:4.8));this.cameraFollowLead.x+=(x.x-this.cameraFollowLead.x)*A,this.cameraFollowLead.z+=(x.z-this.cameraFollowLead.z)*A,this.walkPhase+=t*(3.2+this.movementSpeed*2.15);const C=Math.sin(this.walkPhase)*S;this.player.position=new n(l+.5,.48+Math.abs(Math.sin(this.walkPhase*2))*.045*S,c+.5),this.player.scaling.setAll(1.14),this.player.rotation.y={north:0,south:Math.PI,east:-Math.PI/2,west:Math.PI/2}[e.player.facing],this.pepeLegs.forEach((pe,he)=>{pe.rotation.x=C*(he===0?.78:-.78)}),this.pepeTail&&(this.pepeTail.rotation.z=Math.PI*.34+Math.sin(v*2.5)*.12+C*.08),this.pepeScarf&&(this.pepeScarf.rotation.y=Math.sin(v*3.1)*.08+S*.12),this.balloon.isVisible=e.player.balloonsCarried>0,this.tether.isVisible=this.balloon.isVisible,this.balloonKnot.isVisible=this.balloon.isVisible;const B=1+(e.doorAttention??0)*.09;this.balloon.scaling.x=B,this.balloon.scaling.y=1.28*B,this.balloon.scaling.z=B;const O=new n(l+.72,1,c+.5),P={x:l+.62+Math.sin(v*.71)*.11,y:3.1+Math.sin(v*1.9)*.06,z:c+.48+Math.cos(v*.63)*.08};this.balloonPosition||(this.balloonPosition={...P});const Z=11.5,Y=Math.exp(-3.7*t);this.balloonVelocity.x+=(P.x-this.balloonPosition.x)*Z*t+Math.sin(v*1.37)*.34*t,this.balloonVelocity.y+=(P.y-this.balloonPosition.y)*Z*t,this.balloonVelocity.z+=(P.z-this.balloonPosition.z)*Z*t+Math.cos(v*.91)*.22*t,this.balloonVelocity.x*=Y,this.balloonVelocity.y*=Y,this.balloonVelocity.z*=Y,this.balloonPosition.x+=this.balloonVelocity.x*t,this.balloonPosition.y+=this.balloonVelocity.y*t,this.balloonPosition.z+=this.balloonVelocity.z*t;const W=new n(this.balloonPosition.x,this.balloonPosition.y,this.balloonPosition.z);this.balloon.position=W,this.balloon.rotation.z=-this.balloonVelocity.x*.16,this.balloonKnot.position=new n(W.x,W.y-.48,W.z);const I=new n(W.x,W.y-.48,W.z),R=I.x-O.x,z=I.y-O.y,V=I.z-O.z,q=Math.max(.02,Math.hypot(R,z,V));this.tether.position=new n((O.x+I.x)/2,(O.y+I.y)/2,(O.z+I.z)/2),this.tether.scaling.y=q,this.tether.rotation.z=-Math.atan2(R,z||.001),this.tether.rotation.x=Math.atan2(V,z||.001),M?(this.clearLibraryDoors(),h&&this.updatePlatformMotion(v,e.platformRouteChosen),f&&this.updateNorthboundMotion(v,e.northboundRoutePowered,e.northboundKeeperMet),d&&this.updateLanternSpanMotion(v,e.lanternSpanVisited),u&&this.updateGlimmerValeMotion(v,e.glimmerLampsLit,e.kitegardenUnlocked),E&&this.updateKitegardenMotion(v,e.kiteKitesPerched,e.quietFerryUnlocked),_&&this.updateQu
2699ietFerryMotion(v,e.quietFerryTicketReturned)):this.updateDoors(e,v,t);const ee=M?void 0:e.doors.find(pe=>pe.id===e.visionDoorId)??e.doors.find(pe=>pe.visible&&!pe.opened)??e.doors.find(pe=>pe.visible&&pe.opened),Q=this.cinematicPhase==="manifesting"?.58:this.cinematicPhase==="opening"||e.mode==="doorVision"||e.mode==="doorCommit"?.72:ee?.22+(e.doorAttention??0)*.16:0,te=M?0:ee?.34:1,J=h?{x:.8,y:.56,z:0}:f?{x:.9,y:.62,z:0}:d?{x:1.2,y:.58,z:0}:u?{x:.7,y:.56,z:0}:E?{x:.8,y:.56,z:0}:_?{x:.9,y:.58,z:0}:{x:l+.5+this.cameraFollowLead.x*te+(ee?(ee.position.x-l)*Q:0),y:.42+(this.cinematicPhase==="manifesting"||this.cinematicPhase==="opening"||e.mode==="doorCommit"?.42:0),z:c+.5+this.cameraFollowLead.z*te+(ee?(ee.position.y-c)*Q:0)};this.cameraTarget||(this.cameraTarget={...J});const se=1-Math.exp(-t*(this.movementSpeed>.05?8.2:4.8));this.cameraTarget.x+=(J.x-this.cameraTarget.x)*se,this.cameraTarget.y+=(J.y-this.cameraTarget.y)*se,this.cameraTarget.z+=(J.z-this.cameraTarget.z)*se;const re=this.cinematicPhase==="manifesting"?Math.sin(v*31)*.035:0;this.camera.setTarget(new n(this.cameraTarget.x+re,this.cameraTarget.y,this.cameraTarget.z));const xe=h?17.2:f?16.4:d?16.1:this.cinematicPhase==="opening"||e.mode==="doorVision"||e.mode==="doorCommit"?13.8:this.cinematicPhase==="manifesting"?15.2:18.5;!M&&v-this.lastOcclusionUpdate>=.12?(this.lastOcclusionUpdate=v,this.updateOcclusion(),this.cameraObstacleTarget=this.measureCameraPullback(this.cameraTarget,xe)):M&&(this.cameraObstacleTarget=0);const We=1-Math.exp(-t*(this.cameraObstacleTarget>this.cameraObstaclePullback?15:4.4));this.cameraObstaclePullback+=(this.cameraObstacleTarget-this.cameraObstaclePullback)*We;const Fe=Math.max(6.8,xe-this.cameraObstaclePullback);this.camera.radius+=(Fe-this.camera.radius)*se}updatePlatformMotion(e,t){if(this.cinematicPhase="idle",this.doorOpenProgress=0,this.occludedMeshCount=0,this.platformBeacon){const i=1+Math.sin(e*2.7)*.22;this.platformBeacon.scaling.setAll(t?.82:i),this.platformBeacon.position.y=2.7+Math.sin(e*1.8)*.08}}updateNorthboundMotion(e,t,i){if(this.cinematicPhase="idle",this.doorOpenProgress=0,this.occludedMeshCount=0,this.northboundBeacon){const s=t?.78:1+Math.sin(e*3.1)*.24;this.northboundBeacon.scaling.setAll(s),this.northboundBeacon.position.y=2.08+Math.sin(e*(t?1.2:2.2))*.07}this.northboundGate.forEach((s,r)=>{s.setEnabled(t),t&&s.scaling.setAll(1+Math.sin(e*2.4+r)*.035)}),i&&this.northboundBeacon&&(this.northboundBeacon.visibility=1)}updateLanternSpanMotion(e,t){if(this.cinematicPhase="idle",this.doorOpenProgress=0,this.occludedMeshCount=0,this.lanternSpanBeacon){const i=t?.82+Math.sin(e*1.8)*.08:1;this.lanternSpanBeacon.scaling.setAll(i),this.lanternSpanBeacon.position.y=2.45+Math.sin(e*1.35)*.07}}updateGlimmerValeMotion(e,t,i){this.cinematicPhase="idle",this.doorOpenProgress=0,this.occludedMeshCount=0,this.glimmerLampGlows.forEach((s,r)=>{const a=r<t;s.setEnabled(a),s.scaling.setAll(a?1+Math.sin(e*2.4+r)*.12:.45)}),this.glimmerLights.forEach((s,r)=>{s.intensity=r<t?.9+Math.sin(e*2+r)*.14:.12}),this.glimmerGate.forEach((s,r)=>{s.setEnabled(i),i&&(s.rotation.z=e*.16,s.scaling.setAll(1+Math.sin(e*1.7+r)*.035))})}updateKitegardenMotion(e,t,i){this.cinematicPhase="idle",this.doorOpenProgress=0,this.occludedMeshCount=0,this.kiteMeshes.forEach((s,r)=>{const a=r<t;s.position.y=a?1.86:2.02+Math.sin(e*2.2+r)*.22,s.rotation.z=Math.PI/4+(a?0:Math.sin(e*2.7+r)*.18),s.scaling.setAll(a?.75:1)}),this.kiteFerryDock.forEach(s=>{s.setEnabled(i),i&&s.name.includes("lamp")&&(s.position.y=1.85+Math.sin(e*2.1)*.08)}),this.kitegardenLights.forEach(s=>{s.intensity=i?1.05+Math.sin(e*2.2)*.15:.12})}updateQuietFerryMotion(e,t){this.cinematicPhase="idle",this.doorOpenProgress=0,this.occludedMeshCount=0,this.quietFerryWren&&(this.quietFerryWren.setEnabled(!t),this.quietFerryWren.position.y=.72+Math.sin(e*3.1)*.11),this.quietFerryLights.forEach(i=>{i.intensity=t?1.35+Math.sin(e*2.1)*.12:.78})}clearLibraryDoors(){for(const e of this.doors.values())e.panel.dispose(),e.frame.forEach(t=>t.dispose()),e.glow.dispose(),e.sparks.forEach(t=>t.dispose()),e.light.dispose();this.doors.clear()}updateDoors(e,t,i){if(!this.m||!this.scene)return;const{MeshBuilder:s,Vector3:r,PointLight:a}=this.m,n=new Set;for(const d of e.doors){if(!d.visible)continue;n.add(d.id);let u=this.doors.get(d.id);if(!u){const m=s.CreateBox(`impossible-door-${d.id}`,{width:1.18,height:2.5,depth:.16},this.scene);m.position=new r(d.position.x+.5,1.25,d.position.y+.5),m.material=this.mat("door-vermilion",[.76,.012,.018],!0);const b=[];for(const[P,Z,Y,W]of[[-.69,1.3,.18,2.8],[.69,1.3,.18,2.8],[0,2.66,1.55,.18]]){const I=s.CreateBox(`door-frame-${d.id}`,{width:Y,height:W,depth:.24},this.scene);I.position=new r(d.position.x+.5+P,Z,d.position.y+.52),I.material=this.mat("door-frame",[.055,.04,.045]),b.pu
2699sh(I)}const x=s.CreateGround(`door-spill-${d.id}`,{width:2.8,height:3.8},this.scene);x.position=new r(d.position.x+.5,.018,d.position.y-1.1),x.material=this.mat("door-spill",[.95,.08,.025],!0);const A=new a(`door-light-${d.id}`,new r(d.position.x+.5,.55,d.position.y+.15),this.scene);A.diffuse=new this.m.Color3(1,.07,.025),A.range=7,A.intensity=2.1;const C=[],B=this.mat("door-sparks",[1,.18,.04],!0),O=this.qualityProfile==="cinematic"?12:6;for(let P=0;P<O;P++){const Z=s.CreateSphere(`door-spark-${d.id}-${P}`,{diameter:.065+P%3*.018,segments:5},this.scene);Z.material=B,C.push(Z)}u={panel:m,frame:b,glow:x,light:A,sparks:C,createdAt:t,openProgress:0,baseX:d.position.x+.5,baseZ:d.position.y+.5},this.doors.set(d.id,u)}const E=Math.min(1,Math.max(.025,(t-u.createdAt)/1.65)),_=e.doorAttention??0,M=e.mode==="doorCommit",v=1-Math.pow(1-E,3);u.panel.scaling.y=v,u.panel.position.y=1.25*v,u.frame.forEach(m=>{m.visibility=v}),u.glow.visibility=v,u.openProgress+=((d.opened?1:0)-u.openProgress)*(1-Math.exp(-i*(d.opened?3.1:7)));const S=1-Math.pow(1-u.openProgress,3);u.panel.rotation.y=-Math.PI*.48*S+Math.sin(t*.7)*.012*(1-S),u.panel.position.x=u.baseX-Math.sin(S*Math.PI*.5)*.48,u.panel.position.z=u.baseZ+(1-Math.cos(S*Math.PI*.5))*.44,u.glow.scaling.x=(1+Math.sin(t*2+d.id)*(.07+_*.04))*(1+S*.58+_*.12),u.glow.scaling.z=1+S*.38+_*.08,u.light.intensity=v*(1.8+Math.sin(t*2.2+d.id)*.35+S*1.5+_*.7+(M?1.2:0)),u.sparks.forEach((m,b)=>{const x=(t*(.28+b%4*.035)+b*.173)%1,A=b%2===0?-1:1;m.position=new r(u.baseX+A*(.62+b%3*.11),.18+x*(2.35+b%3*.16),u.baseZ-.12+Math.sin(b*2.7+t)*.12),m.visibility=v*(1-x)*(.38+S*.62+_*.16+(M?.16:0))})}for(const[d,u]of this.doors)n.has(d)||(u.panel.dispose(),u.frame.forEach(E=>E.dispose()),u.glow.dispose(),u.sparks.forEach(E=>E.dispose()),u.light.dispose(),this.doors.delete(d));const l=e.doors.filter(d=>d.visible),c=l.some(d=>{const u=this.doors.get(d.id);return u&&t-u.createdAt<1.65}),h=l.some(d=>{const u=this.doors.get(d.id);return d.opened&&u&&u.openProgress<.985}),f=l.some(d=>d.opened);this.cinematicPhase=h?"opening":c?"manifesting":f?"open":"idle",this.doorOpenProgress=Math.max(0,...[...this.doors.values()].map(d=>d.openProgress)),this.scene.fogDensity+=((this.cinematicPhase==="opening"||e.mode==="doorCommit"?.017:.012)-this.scene.fogDensity)*(1-Math.exp(-i*2.2))}updateOcclusion(){if(!this.camera||!this.player)return;const e=this.camera.position,t=this.player.position,i=t.x-e.x,s=t.z-e.z,r=i*i+s*s;let a=0;for(const n of this.occluders){if(n.isDisposed())continue;const l=n.position.x-e.x,c=n.position.z-e.z,h=r===0?0:Math.max(0,Math.min(1,(l*i+c*s)/r)),f=e.x+h*i,d=e.z+h*s,u=Math.hypot(n.position.x-f,n.position.z-d),E=h>.12&&h<.94&&u<1.95,_=E?.16:1;n.visibility+=(_-n.visibility)*.28,E&&a++}this.occludedMeshCount=a}measureCameraPullback(e,t){if(!this.camera||this.activeWorld!=="library")return 0;const i=this.camera.position.x-e.x,s=this.camera.position.z-e.z,r=Math.hypot(i,s);if(r<.01)return 0;const a=i/r,n=s/r;let l=t;for(const c of this.cameraBlockers.values())for(const h of c){const f=h.x-e.x,d=h.z-e.z,u=f*a+d*n;if(u<=.35||u>=l+h.radius)continue;const E=f*f+d*d-u*u,_=h.radius+.72;if(E>=_*_)continue;const M=u-Math.sqrt(_*_-E);l=Math.min(l,Math.max(6.8,M-.24))}return Math.max(0,t-l)}renderFrame(){this.scene?.isReady()&&(this.scene.render(),this.frames++)}getDiagnostics(){return{initialized:this.initialized,sceneReady:!!this.scene?.isReady(),renderedFrames:this.frames,residentChunkCount:this.chunks.size,chunkMeshCount:[...this.chunks.values()].reduce((e,t)=>e+t.length,0),doorMeshCount:this.doors.size,playerMesh:!!(this.player&&!this.player.isDisposed()),balloonMesh:!!(this.balloon&&!this.balloon.isDisposed()),qualityProfile:this.qualityProfile,cinematicPhase:this.cinematicPhase,movementSpeed:Number(this.movementSpeed.toFixed(3)),doorOpenProgress:Number(this.doorOpenProgress.toFixed(3)),occludedMeshCount:this.occludedMeshCount,pepeEchoCount:this.pepeEchoCount,cameraFollowLead:{x:Number(this.cameraFollowLead.x.toFixed(3)),z:Number(this.cameraFollowLead.z.toFixed(3))},cameraObstaclePullback:Number(this.cameraObstaclePullback.toFixed(3)),cameraBlockerCount:[...this.cameraBlockers.values()].reduce((e,t)=>
2699e+t.length,0)}}dispose(){[...this.chunks.keys()].forEach(e=>this.removeChunk(e));for(const e of this.doors.values())e.panel.dispose(),e.frame.forEach(t=>t.dispose()),e.glow.dispose(),e.sparks.forEach(t=>t.dispose()),e.light.dispose();this.doors.clear(),this.player?.dispose(),this.balloon?.dispose(),this.tether?.dispose(),this.balloonKnot?.dispose(),this.pepeEchoInstances.forEach(e=>e.dispose()),this.pepeEchoInstances=[],this.pepeEchoTemplates.forEach(e=>e.dispose()),this.pepeEchoTemplates=[],this.pepeEchoCount=0,this.pepeEchoKey="",this.staticMeshes.forEach(e=>e.dispose()),this.staticMeshes=[],this.platformMeshes.forEach(e=>e.dispose()),this.platformMeshes=[],this.platformLights.forEach(e=>e.dispose()),this.platformLights=[],this.platformBeacon=null,this.northboundMeshes.forEach(e=>e.dispose()),this.northboundMeshes=[],this.northboundLights.forEach(e=>e.dispose()),this.northboundLights=[],this.northboundBeacon=null,this.northboundGate=[],this.lanternSpanMeshes.forEach(e=>e.dispose()),this.lanternSpanMeshes=[],this.lanternSpanLights.forEach(e=>e.dispose()),this.lanternSpanLights=[],this.lanternSpanBeacon=null,this.glimmerMeshes.forEach(e=>e.dispose()),this.glimmerMeshes=[],this.glimmerLights.forEach(e=>e.dispose()),this.glimmerLights=[],this.glimmerLampGlows=[],this.glimmerGate=[],this.kitegardenMeshes.forEach(e=>e.dispose()),this.kitegardenMeshes=[],this.kitegardenLights.forEach(e=>e.dispose()),this.kitegardenLights=[],this.kiteMeshes=[],this.kiteFerryDock=[],this.quietFerryMeshes.forEach(e=>e.dispose()),this.quietFerryMeshes=[],this.quietFerryLights.forEach(e=>e.dispose()),this.quietFerryLights=[],this.quietFerryWren=null,this.occluders.clear(),this.materials.forEach(e=>e.dispose()),this.materials.clear(),this.camera?.detachControl(),this.scene?.dispose(),this.scene=null,this.initialized=!1}mat(e,t,i=!1){const s=this.materials.get(e);if(s)return s;if(!this.m||!this.scene)throw Error("T-03 scene not initialized");const r=`
2700      precision highp float;
2701      attribute vec3 position;
2702      uniform mat4 worldViewProjection;
2703      void main(void) {
2704        gl_Position = worldViewProjection * vec4(position, 1.0);
2705      }
2706    `,a=`
2707      precision highp float;
2708      uniform vec3 atlasTint;
2709      uniform float atlasGlow;
2710      void main(void) {
2711        vec3 color = atlasTint + atlasTint * atlasGlow;
2712        gl_FragColor = vec4(color, 1.0);
2713      }
2714    `,n=new this.m.ShaderMaterial(e,this.scene,{vertexSource:r,fragmentSource:a,spectorName:"atlas-compat"},{attributes:["position"],uniforms:["worldViewProjection","atlasTint","atlasGlow"]});return n.setColor3("atlasTint",new this.m.Color3(...t)),n.setFloat("atlasGlow",i?.42:0),this.materials.set(e,n),n}}async function Oo(o,e){const t=new Dn(o,e);return await t.init(),t}const Cl=Object.freeze(Object.defineProperty({__proto__:null,Tier3BabylonScene:Dn,createTier3Scene:Oo},Symbol.toStringTag,{value:"Module"}));export{al as $,qo as A,aa as B,Na as C,Ba as D,Va as E,qa as F,de as G,rl as H,nl as I,ml as J,ul as K,_e as L,Te as M,ct as N,vl as O,na as P,Sl as Q,Il as R,pl as S,dl as T,U,gl as V,_l as W,fl as X,cl as Y,hl as Z,ra as _,tl as a,El as a0,Ml as a1,xl as a2,sl as a3,ll as a4,ea as a5,X as a6,Kn as a7,ar as a8,$o as a9,Ke as aa,Zo as ab,ki as ac,G as ad,Ae as ae,Al as af,$s as ag,Pe as ah,bl as ai,Tl as aj,Cl as ak,jo as b,ol as c,Qo as d,Jo as e,el as f,il as g,vt as h,Aa as i,ba as j,Ra as k,La as l,Ta as m,Ua as n,Wa as o,ka as p,Ka as q,Ya as r,Io as s,So as t,Eo as u,$a as v,To as w,mo as x,po as y,wa as z};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.