mirror of
https://github.com/Ladebeze66/projetcbaollm.git
synced 2025-12-18 02:07:50 +01:00
20740 lines
5.9 MiB
20740 lines
5.9 MiB
import{h as Es,g as uL}from"./index-C7PS0jJm.js";import{r as dL}from"./file-url-DgijyRSD.js";/* empty css */import"./svelte/svelte.js";import"./context-TgWPFwN2.js";function hL(vi,mn){for(var Cn=0;Cn<mn.length;Cn++){const Zn=mn[Cn];if(typeof Zn!="string"&&!Array.isArray(Zn)){for(const L in Zn)if(L!=="default"&&!(L in vi)){const Hn=Object.getOwnPropertyDescriptor(Zn,L);Hn&&Object.defineProperty(vi,L,Hn.get?Hn:{enumerable:!0,get:()=>Zn[L]})}}}return Object.freeze(Object.defineProperty(vi,Symbol.toStringTag,{value:"Module"}))}var DS={exports:{}},G1;function z1(){return G1||(G1=1,function(vi,mn){(function(Cn,Zn){vi.exports=Zn()})(typeof self<"u"?self:typeof Es<"u"?Es:Es,()=>(()=>{var Cn={82966:(r,t,e)=>{e.d(t,{G:()=>i});var n=e(81152),i=function(){function o(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}return Object.defineProperty(o,"HasTriggers",{get:function(){for(var a in o.Triggers)if(Object.prototype.hasOwnProperty.call(o.Triggers,a))return!0;return!1},enumerable:!1,configurable:!0}),Object.defineProperty(o,"HasPickTriggers",{get:function(){for(var a in o.Triggers)if(Object.prototype.hasOwnProperty.call(o.Triggers,a)){var s=parseInt(a);if(s>=n.Y.ACTION_OnPickTrigger&&s<=n.Y.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),o.HasSpecificTrigger=function(a){for(var s in o.Triggers)if(Object.prototype.hasOwnProperty.call(o.Triggers,s)&&parseInt(s)===a)return!0;return!1},o.Triggers={},o}()},35747:(r,t,e)=>{e.d(t,{X:()=>n});var n=function(){function i(o,a,s,l,c,u){this.source=o,this.pointerX=a,this.pointerY=s,this.meshUnderPointer=l,this.sourceEvent=c,this.additionalData=u}return i.CreateNew=function(o,a,s){var l=o.getScene();return new i(o,l.pointerX,l.pointerY,l.meshUnderPointer||o,a,s)},i.CreateNewFromSprite=function(o,a,s,l){return new i(o,a.pointerX,a.pointerY,a.meshUnderPointer,s,l)},i.CreateNewFromScene=function(o,a){return new i(null,o.pointerX,o.pointerY,o.meshUnderPointer,a)},i.CreateNewFromPrimitive=function(o,a,s,l){return new i(o,a.x,a.y,null,s,l)},i}()},62623:(r,t,e)=>{e.d(t,{R:()=>s,h:()=>a});var n=e(37943),i=e(7164),o=e(81152),a=function(){function l(c,u,d,h,p,m,v,b,E){h===void 0&&(h=0),p===void 0&&(p=!1),m===void 0&&(m=!1),v===void 0&&(v=!1),this._isAlreadyOwned=!1,this._isDisposed=!1,c&&c.getScene?this._engine=c.getScene().getEngine():this._engine=c,this._updatable=d,this._instanced=m,this._divisor=b||1,this._label=E,u instanceof n.n?(this._data=null,this._buffer=u):(this._data=u,this._buffer=null),this.byteStride=v?h:h*Float32Array.BYTES_PER_ELEMENT,p||this.create()}return Object.defineProperty(l.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),l.prototype.createVertexBuffer=function(c,u,d,h,p,m,v){m===void 0&&(m=!1);var b=m?u:u*Float32Array.BYTES_PER_ELEMENT,E=h?m?h:h*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new s(this._engine,this,c,this._updatable,!0,E,p===void 0?this._instanced:p,b,d,void 0,void 0,!0,this._divisor||v)},l.prototype.isUpdatable=function(){return this._updatable},l.prototype.getData=function(){return this._data},l.prototype.getBuffer=function(){return this._buffer},l.prototype.getStrideSize=function(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT},l.prototype.create=function(c){c===void 0&&(c=null),!c&&this._buffer||(c=c||this._data)&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,c),this._data=c):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(c,this._label),this._data=c):this._buffer=this._engine.createVertexBuffer(c,void 0,this._label))},l.prototype._rebuild=function(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0)return void(this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label));i.V.Warn('Missing data for buffer "'.concat(this._label,'" ').concat(this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":"",". Buffer reconstruction failed.")),this._buffer=null}},l.prototype.update=function(c){this.create(c)},l.prototype.updateDirectly=function(c,u,d,h){h===void 0&&(h=!1),this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,c,h?u:u*Float32Array.BYTES_PER_ELEMENT,d?d*this.byteStride:void 0),this._data=u===0&&d===void 0?c:null)},l.prototype._increaseReferences=function(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)},l.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._isDisposed=!0,this._data=null,this._buffer=null)},l}(),s=function(){function l(c,u,d,h,p,m,v,b,E,C,T,f,g,S){var y,x,R,I,M;T===void 0&&(T=!1),f===void 0&&(f=!1),g===void 0&&(g=1),S===void 0&&(S=!1),this._isDisposed=!1;var D=!1;if(this.engine=c,typeof h=="object"&&h!==null?(D=(y=h.updatable)!==null&&y!==void 0&&y,p=h.postponeInternalCreation,m=h.stride,v=h.instanced,b=h.offset,E=h.size,C=h.type,T=(x=h.normalized)!==null&&x!==void 0&&x,f=(R=h.useBytes)!==null&&R!==void 0&&R,g=(I=h.divisor)!==null&&I!==void 0?I:1,S=(M=h.takeBufferOwnership)!==null&&M!==void 0&&M,this._label=h.label):D=!!h,u instanceof a?(this._buffer=u,this._ownsBuffer=S):(this._buffer=new a(c,u,D,m,p,v,f,g,this._label),this._ownsBuffer=!0),this.uniqueId=l._Counter++,this._kind=d,C===void 0){var B=this.getData();this.type=B?l.GetDataType(B):l.FLOAT}else this.type=C;var F=l.GetTypeByteLength(this.type);f?(this._size=E||(m?m/F:l.DeduceStride(d)),this.byteStride=m||this._buffer.byteStride||this._size*F,this.byteOffset=b||0):(this._size=E||m||l.DeduceStride(d),this.byteStride=m?m*F:this._buffer.byteStride||this._size*F,this.byteOffset=(b||0)*F),this.normalized=T,this._instanced=v!==void 0&&v,this._instanceDivisor=v?g:0,this._alignBuffer(),this._computeHashCode()}return Object.defineProperty(l.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(c){var u=c!=0;this._instanceDivisor=c,u!==this._instanced&&(this._instanced=u,this._computeHashCode())},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"_maxVerticesCount",{get:function(){var c=this.getData();return c?Array.isArray(c)?c.length/(this.byteStride/4)-this.byteOffset/4:(c.byteLength-this.byteOffset)/this.byteStride:0},enumerable:!1,configurable:!0}),l.prototype._computeHashCode=function(){this.hashCode=(this.type-5120|0)+((this.normalized?1:0)<<3)+(this._size<<4)+((this._instanced?1:0)<<6)+(this.byteStride<<12)},l.prototype._rebuild=function(){var c;(c=this._buffer)===null||c===void 0||c._rebuild()},l.prototype.getKind=function(){return this._kind},l.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},l.prototype.getData=function(){return this._buffer.getData()},l.prototype.getFloatData=function(c,u){var d=this.getData();return d?l.GetFloatData(d,this._size,this.type,this.byteOffset,this.byteStride,this.normalized,c,u):null},l.prototype.getBuffer=function(){return this._buffer.getBuffer()},l.prototype.getWrapperBuffer=function(){return this._buffer},l.prototype.getStrideSize=function(){return this.byteStride/l.GetTypeByteLength(this.type)},l.prototype.getOffset=function(){return this.byteOffset/l.GetTypeByteLength(this.type)},l.prototype.getSize=function(c){return c===void 0&&(c=!1),c?this._size*l.GetTypeByteLength(this.type):this._size},l.prototype.getIsInstanced=function(){return this._instanced},l.prototype.getInstanceDivisor=function(){return this._instanceDivisor},l.prototype.create=function(c){this._buffer.create(c),this._alignBuffer()},l.prototype.update=function(c){this._buffer.update(c),this._alignBuffer()},l.prototype.updateDirectly=function(c,u,d){d===void 0&&(d=!1),this._buffer.updateDirectly(c,u,void 0,d),this._alignBuffer()},l.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose(),this._isDisposed=!0},l.prototype.forEach=function(c,u){l.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,c,this.normalized,u)},l.prototype._alignBuffer=function(){},l.DeduceStride=function(c){switch(c){case l.UVKind:case l.UV2Kind:case l.UV3Kind:case l.UV4Kind:case l.UV5Kind:case l.UV6Kind:return 2;case l.NormalKind:case l.PositionKind:return 3;case l.ColorKind:case l.ColorInstanceKind:case l.MatricesIndicesKind:case l.MatricesIndicesExtraKind:case l.MatricesWeightsKind:case l.MatricesWeightsExtraKind:case l.TangentKind:return 4;default:throw new Error("Invalid kind '"+c+"'")}},l.GetDataType=function(c){return c instanceof Int8Array?l.BYTE:c instanceof Uint8Array?l.UNSIGNED_BYTE:c instanceof Int16Array?l.SHORT:c instanceof Uint16Array?l.UNSIGNED_SHORT:c instanceof Int32Array?l.INT:c instanceof Uint32Array?l.UNSIGNED_INT:l.FLOAT},l.GetTypeByteLength=function(c){switch(c){case l.BYTE:case l.UNSIGNED_BYTE:return 1;case l.SHORT:case l.UNSIGNED_SHORT:return 2;case l.INT:case l.UNSIGNED_INT:case l.FLOAT:return 4;default:throw new Error("Invalid type '".concat(c,"'"))}},l.ForEach=function(c,u,d,h,p,m,v,b){if(c instanceof Array)for(var E=u/4,C=d/4,T=0;T<m;T+=h){for(var f=0;f<h;f++)b(c[E+f],T+f);E+=C}else{var g=c instanceof ArrayBuffer?new DataView(c):new DataView(c.buffer,c.byteOffset,c.byteLength),S=l.GetTypeByteLength(p);for(T=0;T<m;T+=h){var y=u;for(f=0;f<h;f++)b(l._GetFloatValue(g,p,y,v),T+f),y+=S;u+=d}}},l._GetFloatValue=function(c,u,d,h){switch(u){case l.BYTE:var p=c.getInt8(d);return h&&(p=Math.max(p/127,-1)),p;case l.UNSIGNED_BYTE:return p=c.getUint8(d),h&&(p/=255),p;case l.SHORT:return p=c.getInt16(d,!0),h&&(p=Math.max(p/32767,-1)),p;case l.UNSIGNED_SHORT:return p=c.getUint16(d,!0),h&&(p/=65535),p;case l.INT:return c.getInt32(d,!0);case l.UNSIGNED_INT:return c.getUint32(d,!0);case l.FLOAT:return c.getFloat32(d,!0);default:throw new Error("Invalid component type ".concat(u))}},l.GetFloatData=function(c,u,d,h,p,m,v,b){var E=u*l.GetTypeByteLength(d),C=v*u;if(d!==l.FLOAT||p!==E){var T=new Float32Array(C);return l.ForEach(c,h,p,u,d,C,m,function(y,x){return T[x]=y}),T}if(!(c instanceof Array||c instanceof Float32Array)||h!==0||c.length!==C){if(c instanceof Array){var f=h/4;return c.slice(f,f+C)}if(c instanceof ArrayBuffer)return new Float32Array(c,h,C);if(3&(f=c.byteOffset+h)&&(i.V.Warn("Float array must be aligned to 4-bytes border"),b=!0),b){var g=new Uint8Array(C*Float32Array.BYTES_PER_ELEMENT),S=new Uint8Array(c.buffer,f,g.length);return g.set(S),new Float32Array(g.buffer)}return new Float32Array(c.buffer,f,C)}return b?c.slice():c},l._Counter=0,l.BYTE=o.Y.BYTE,l.UNSIGNED_BYTE=o.Y.UNSIGNED_BYTE,l.SHORT=o.Y.SHORT,l.UNSIGNED_SHORT=o.Y.UNSIGNED_SHORT,l.INT=o.Y.INT,l.UNSIGNED_INT=o.Y.UNSIGNED_INT,l.FLOAT=o.Y.FLOAT,l.PositionKind=o.Y.PositionKind,l.NormalKind=o.Y.NormalKind,l.TangentKind=o.Y.TangentKind,l.UVKind=o.Y.UVKind,l.UV2Kind=o.Y.UV2Kind,l.UV3Kind=o.Y.UV3Kind,l.UV4Kind=o.Y.UV4Kind,l.UV5Kind=o.Y.UV5Kind,l.UV6Kind=o.Y.UV6Kind,l.ColorKind=o.Y.ColorKind,l.ColorInstanceKind=o.Y.ColorInstanceKind,l.MatricesIndicesKind=o.Y.MatricesIndicesKind,l.MatricesWeightsKind=o.Y.MatricesWeightsKind,l.MatricesIndicesExtraKind=o.Y.MatricesIndicesExtraKind,l.MatricesWeightsExtraKind=o.Y.MatricesWeightsExtraKind,l}()},37943:(r,t,e)=>{e.d(t,{n:()=>n});var n=function(){function i(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=i._Counter++}return Object.defineProperty(i.prototype,"underlyingResource",{get:function(){return null},enumerable:!1,configurable:!0}),i._Counter=0,i}()},1554:(r,t,e)=>{e.d(t,{K:()=>i});var n=e(81152),i=function(){function o(a,s,l,c){l===void 0&&(l=n.Y.BUFFER_CREATIONFLAG_READWRITE),this._engine=a,this._label=c,this._engine._storageBuffers.push(this),this._create(s,l)}return o.prototype._create=function(a,s){this._bufferSize=a,this._creationFlags=s,this._buffer=this._engine.createStorageBuffer(a,s,this._label)},o.prototype._rebuild=function(){this._create(this._bufferSize,this._creationFlags)},o.prototype.getBuffer=function(){return this._buffer},o.prototype.update=function(a,s,l){this._buffer&&this._engine.updateStorageBuffer(this._buffer,a,s,l)},o.prototype.read=function(a,s,l,c){return this._engine.readFromStorageBuffer(this._buffer,a,s,l,c)},o.prototype.dispose=function(){var a=this._engine._storageBuffers,s=a.indexOf(this);s!==-1&&(a[s]=a[a.length-1],a.pop()),this._engine._releaseBuffer(this._buffer),this._buffer=null},o}()},8004:(r,t,e)=>{e.d(t,{G:()=>o});var n=e(8046),i=e(62623),o=function(){function a(){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}return a.prototype.getNormal=function(s,l){if(s===void 0&&(s=!1),l===void 0&&(l=!0),!this.pickedMesh||l&&!this.pickedMesh.isVerticesDataPresent(i.R.NormalKind))return null;var c,u=this.pickedMesh.getIndices();u?.length===0&&(u=null);var d=n.AA.Vector3[0],h=n.AA.Vector3[1],p=n.AA.Vector3[2];if(l){var m=this.pickedMesh.getVerticesData(i.R.NormalKind),v=u?n.Pq.FromArrayToRef(m,3*u[3*this.faceId],d):d.copyFromFloats(m[3*this.faceId*3],m[3*this.faceId*3+1],m[3*this.faceId*3+2]),b=u?n.Pq.FromArrayToRef(m,3*u[3*this.faceId+1],h):h.copyFromFloats(m[3*(3*this.faceId+1)],m[3*(3*this.faceId+1)+1],m[3*(3*this.faceId+1)+2]),E=u?n.Pq.FromArrayToRef(m,3*u[3*this.faceId+2],p):p.copyFromFloats(m[3*(3*this.faceId+2)],m[3*(3*this.faceId+2)+1],m[3*(3*this.faceId+2)+2]);v=v.scale(this.bu),b=b.scale(this.bv),E=E.scale(1-this.bu-this.bv),c=new n.Pq(v.x+b.x+E.x,v.y+b.y+E.y,v.z+b.z+E.z)}else{var C=this.pickedMesh.getVerticesData(i.R.PositionKind),T=u?n.Pq.FromArrayToRef(C,3*u[3*this.faceId],d):d.copyFromFloats(C[3*this.faceId*3],C[3*this.faceId*3+1],C[3*this.faceId*3+2]),f=u?n.Pq.FromArrayToRef(C,3*u[3*this.faceId+1],h):h.copyFromFloats(C[3*(3*this.faceId+1)],C[3*(3*this.faceId+1)+1],C[3*(3*this.faceId+1)+2]),g=u?n.Pq.FromArrayToRef(C,3*u[3*this.faceId+2],p):p.copyFromFloats(C[3*(3*this.faceId+2)],C[3*(3*this.faceId+2)+1],C[3*(3*this.faceId+2)+2]),S=T.subtract(f),y=g.subtract(f);c=n.Pq.Cross(S,y)}var x=function(I,M){var D=I.getWorldMatrix();I.nonUniformScaling&&(n.AA.Matrix[0].copyFrom(D),(D=n.AA.Matrix[0]).setTranslationFromFloats(0,0,0),D.invert(),D.transposeToRef(n.AA.Matrix[1]),D=n.AA.Matrix[1]),n.Pq.TransformNormalToRef(M,D,M)};if(s&&x(this.pickedMesh,c),this.ray){var R=n.AA.Vector3[0].copyFrom(c);s||x(this.pickedMesh,R),n.Pq.Dot(R,this.ray.direction)>0&&c.negateInPlace()}return c.normalize(),c},a.prototype.getTextureCoordinates=function(s){if(s===void 0&&(s=i.R.UVKind),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(s))return null;var l=this.pickedMesh.getIndices();if(!l)return null;var c=this.pickedMesh.getVerticesData(s);if(!c)return null;var u=n.I9.FromArray(c,2*l[3*this.faceId]),d=n.I9.FromArray(c,2*l[3*this.faceId+1]),h=n.I9.FromArray(c,2*l[3*this.faceId+2]);return u=u.scale(this.bu),d=d.scale(this.bv),h=h.scale(1-this.bu-this.bv),new n.I9(u.x+d.x+h.x,u.y+d.y+h.y)},a}()},51956:(r,t,e)=>{e.d(t,{p9:()=>i,rX:()=>n});var n=!1,i={get UseOpenGLOrientationForUV(){return n},set UseOpenGLOrientationForUV(o){n=o}}},75227:(r,t,e)=>{e.d(t,{H:()=>h});var n=e(78322),i=e(6174),o=e(12028),a=e(34623),s=e(50582),l=e(62273),c=e(7164),u=e(55204),d=e(37411),h=function(){function p(m,v,b,E){E===void 0&&(E={}),this._bindings={},this._samplers={},this._contextIsDirty=!1,this.fastMode=!1,this.onCompiled=null,this.onError=null,this.name=m,this._engine=v,this.uniqueId=l.K.UniqueId,v.enableGPUTimingMeasurements&&(this.gpuTimeInFrame=new d.e),this._engine.getCaps().supportComputeShaders?E.bindingsMapping?(this._context=v.createComputeContext(),this._shaderPath=b,this._options=(0,n.Cl)({bindingsMapping:{},defines:[]},E)):c.V.Error("You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!"):c.V.Error("This engine does not support compute shaders!")}return Object.defineProperty(p.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"shaderPath",{get:function(){return this._shaderPath},enumerable:!1,configurable:!0}),p.prototype.getClassName=function(){return"ComputeShader"},p.prototype.setTexture=function(m,v,b){b===void 0&&(b=!0);var E=this._bindings[m];this._bindings[m]={type:b?0:4,object:v,indexInGroupEntries:E?.indexInGroupEntries},this._contextIsDirty||(this._contextIsDirty=!E||E.object!==v||E.type!==this._bindings[m].type)},p.prototype.setStorageTexture=function(m,v){var b=this._bindings[m];this._contextIsDirty||(this._contextIsDirty=!b||b.object!==v),this._bindings[m]={type:1,object:v,indexInGroupEntries:b?.indexInGroupEntries}},p.prototype.setExternalTexture=function(m,v){var b=this._bindings[m];this._contextIsDirty||(this._contextIsDirty=!b||b.object!==v),this._bindings[m]={type:6,object:v,indexInGroupEntries:b?.indexInGroupEntries}},p.prototype.setVideoTexture=function(m,v){return!!v.externalTexture&&(this.setExternalTexture(m,v.externalTexture),!0)},p.prototype.setUniformBuffer=function(m,v){var b=this._bindings[m];this._contextIsDirty||(this._contextIsDirty=!b||b.object!==v),this._bindings[m]={type:p._BufferIsDataBuffer(v)?7:2,object:v,indexInGroupEntries:b?.indexInGroupEntries}},p.prototype.setStorageBuffer=function(m,v){var b=this._bindings[m];this._contextIsDirty||(this._contextIsDirty=!b||b.object!==v),this._bindings[m]={type:p._BufferIsDataBuffer(v)?7:3,object:v,indexInGroupEntries:b?.indexInGroupEntries}},p.prototype.setTextureSampler=function(m,v){var b=this._bindings[m];this._contextIsDirty||(this._contextIsDirty=!b||!v.compareSampler(b.object)),this._bindings[m]={type:5,object:v,indexInGroupEntries:b?.indexInGroupEntries}},p.prototype.isReady=function(){var m=this._effect;for(var v in this._bindings){var b=this._bindings[v],E=b.type,C=b.object;switch(E){case 0:case 4:case 1:case 6:if(!C.isReady())return!1}}var T=[],f=this._shaderPath;if(this._options.defines)for(var g=0;g<this._options.defines.length;g++)T.push(this._options.defines[g]);var S=T.join(`
|
||
`);return this._cachedDefines!==S&&(this._cachedDefines=S,m=this._engine.createComputeEffect(f,{defines:S,entryPoint:this._options.entryPoint,onCompiled:this.onCompiled,onError:this.onError}),this._effect=m),!!m.isReady()},p.prototype.dispatch=function(m,v,b){return!(!this.fastMode&&!this._checkContext()||(this._engine.computeDispatch(this._effect,this._context,this._bindings,m,v,b,this._options.bindingsMapping,this.gpuTimeInFrame),0))},p.prototype.dispatchIndirect=function(m,v){if(v===void 0&&(v=0),!this.fastMode&&!this._checkContext())return!1;var b=p._BufferIsDataBuffer(m)?m:m.getBuffer();return this._engine.computeDispatchIndirect(this._effect,this._context,this._bindings,b,v,this._options.bindingsMapping,this.gpuTimeInFrame),!0},p.prototype._checkContext=function(){var m;if(!this.isReady())return!1;for(var v in this._bindings){var b=this._bindings[v];if(!this._options.bindingsMapping[v])throw new Error("ComputeShader ('"+this.name+"'): No binding mapping has been provided for the property '"+v+"'");switch(b.type){case 0:var E=this._samplers[v],C=b.object;E&&C._texture&&E.compareSampler(C._texture)||(this._samplers[v]=new u.u().setParameters(C.wrapU,C.wrapV,C.wrapR,C.anisotropicFilteringLevel,C._texture.samplingMode,(m=C._texture)===null||m===void 0?void 0:m._comparisonFunction),this._contextIsDirty=!0);break;case 6:this._contextIsDirty=!0;break;case 2:var T=b.object;T.getBuffer()!==b.buffer&&(b.buffer=T.getBuffer(),this._contextIsDirty=!0)}}return this._contextIsDirty&&(this._contextIsDirty=!1,this._context.clear()),!0},p.prototype.dispatchWhenReady=function(m,v,b,E){var C=this;return E===void 0&&(E=10),new Promise(function(T){var f=function(){C.dispatch(m,v,b)?T():setTimeout(f,E)};f()})},p.prototype.serialize=function(){var m=o.p.Serialize(this);for(var v in m.options=this._options,m.shaderPath=this._shaderPath,m.bindings={},m.textures={},this._bindings){var b=this._bindings[v],E=b.object;switch(b.type){case 0:case 4:case 1:var C=E.serialize();C&&(m.textures[v]=C,m.bindings[v]={type:b.type})}}return m},p.Parse=function(m,v,b){var E=o.p.Parse(function(){return new p(m.name,v.getEngine(),m.shaderPath,m.options)},m,v,b);for(var C in m.textures){var T=m.bindings[C],f=s.g.Parse(m.textures[C],v,b);T.type===0?E.setTexture(C,f):T.type===4?E.setTexture(C,f,!1):E.setStorageTexture(C,f)}return E},p._BufferIsDataBuffer=function(m){return m.underlyingResource!==void 0},(0,n.Cg)([(0,i.lK)()],p.prototype,"name",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"fastMode",void 0),p}();(0,a.Y5)("BABYLON.ComputeShader",h)},18149:(r,t,e)=>{e.r(t),e.d(t,{ComputeShaderBoundingHelper:()=>c});var n=e(78322),i=e(75227),o=e(1554),a=e(62623),s=e(8046),l=e(75482);e(98519).l.ShadersStoreWGSL.boundingInfoComputeShader=`struct Results {minX : atomic<i32>,
|
||
minY : atomic<i32>,
|
||
minZ : atomic<i32>,
|
||
maxX : atomic<i32>,
|
||
maxY : atomic<i32>,
|
||
maxZ : atomic<i32>,
|
||
dummy1 : i32,
|
||
dummy2 : i32,};fn floatToBits(value: f32)->i32 {return bitcast<i32>(value);}
|
||
fn bitsToFloat(value: i32)->f32 {return bitcast<f32>(value);}
|
||
fn atomicMinFloat(atomicVar: ptr<storage,atomic<i32>,read_write>,value: f32) {let intValue=floatToBits(value);loop {let oldIntValue=atomicLoad(atomicVar);let oldValue=bitsToFloat(oldIntValue);if (value>=oldValue) {break;}
|
||
if (atomicCompareExchangeWeak(atomicVar,oldIntValue,intValue).old_value==oldIntValue) {break;}}}
|
||
fn atomicMaxFloat(atomicVar: ptr<storage,atomic<i32>,read_write>,value: f32) {let intValue=floatToBits(value);loop {let oldIntValue=atomicLoad(atomicVar);let oldValue=bitsToFloat(oldIntValue);if (value<=oldValue) {break;}
|
||
if (atomicCompareExchangeWeak(atomicVar,oldIntValue,intValue).old_value==oldIntValue) {break;}}}
|
||
fn readMatrixFromRawSampler(smp : texture_2d<f32>,index : f32)->mat4x4<f32>
|
||
{let offset=i32(index) *4;
|
||
let m0=textureLoad(smp,vec2<i32>(offset+0,0),0);let m1=textureLoad(smp,vec2<i32>(offset+1,0),0);let m2=textureLoad(smp,vec2<i32>(offset+2,0),0);let m3=textureLoad(smp,vec2<i32>(offset+3,0),0);return mat4x4<f32>(m0,m1,m2,m3);}
|
||
const identity=mat4x4f(
|
||
vec4f(1.0,0.0,0.0,0.0),
|
||
vec4f(0.0,1.0,0.0,0.0),
|
||
vec4f(0.0,0.0,1.0,0.0),
|
||
vec4f(0.0,0.0,0.0,1.0)
|
||
);struct Settings {morphTargetTextureInfo: vec3f,
|
||
morphTargetCount: i32,
|
||
indexResult : u32,};@group(0) @binding(0) var<storage,read> positionBuffer : array<f32>;@group(0) @binding(1) var<storage,read_write> resultBuffer : array<Results>;@group(0) @binding(7) var<uniform> settings : Settings;
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
@group(0) @binding(2) var boneSampler : texture_2d<f32>;@group(0) @binding(3) var<storage,read> indexBuffer : array<vec4f>;@group(0) @binding(4) var<storage,read> weightBuffer : array<vec4f>;
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
@group(0) @binding(5) var<storage,read> indexExtraBuffer : array<vec4f>;@group(0) @binding(6) var<storage,read> weightExtraBuffer : array<vec4f>;
|
||
#endif
|
||
#endif
|
||
#ifdef MORPHTARGETS
|
||
@group(0) @binding(8) var morphTargets : texture_2d_array<f32>;@group(0) @binding(9) var<storage,read> morphTargetInfluences : array<f32>;@group(0) @binding(10) var<storage,read> morphTargetTextureIndices : array<f32>;
|
||
#endif
|
||
#ifdef MORPHTARGETS
|
||
fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : u32)->vec3f
|
||
{
|
||
let vertexID=f32(vertexIndex)*settings.morphTargetTextureInfo.x;let y=floor(vertexID/settings.morphTargetTextureInfo.y);let x=vertexID-y*settings.morphTargetTextureInfo.y;let textureUV=vec2<i32>(i32(x),i32(y));return textureLoad(morphTargets,textureUV,i32(morphTargetTextureIndices[targetIndex]),0).xyz;}
|
||
#endif
|
||
@compute @workgroup_size(256,1,1)
|
||
fn main(@builtin(global_invocation_id) global_id : vec3<u32>) {let index=global_id.x;if (index>=arrayLength(&positionBuffer)/3) {return;}
|
||
let position=vec3f(positionBuffer[index*3],positionBuffer[index*3+1],positionBuffer[index*3+2]);var finalWorld=identity;var positionUpdated=position;
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
var influence : mat4x4<f32>;let matricesIndices=indexBuffer[index];let matricesWeights=weightBuffer[index];influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
let matricesIndicesExtra=indexExtraBuffer[index];let matricesWeightsExtra=weightExtraBuffer[index];influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra.x)*matricesWeightsExtra.x;
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra.y)*matricesWeightsExtra.y;
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra.z)*matricesWeightsExtra.z;
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra.w)*matricesWeightsExtra.w;
|
||
#endif
|
||
#endif
|
||
finalWorld=finalWorld*influence;
|
||
#endif
|
||
#ifdef MORPHTARGETS
|
||
for (var i=0; i<NUM_MORPH_INFLUENCERS; i=i+1) {if (i>=settings.morphTargetCount) {break;}
|
||
positionUpdated=positionUpdated+(readVector3FromRawSampler(i,index)-position)*morphTargetInfluences[i];}
|
||
#endif
|
||
var worldPos=finalWorld*vec4f(positionUpdated.x,positionUpdated.y,positionUpdated.z,1.0);atomicMinFloat(&resultBuffer[settings.indexResult].minX,worldPos.x);atomicMinFloat(&resultBuffer[settings.indexResult].minY,worldPos.y);atomicMinFloat(&resultBuffer[settings.indexResult].minZ,worldPos.z);atomicMaxFloat(&resultBuffer[settings.indexResult].maxX,worldPos.x);atomicMaxFloat(&resultBuffer[settings.indexResult].maxY,worldPos.y);atomicMaxFloat(&resultBuffer[settings.indexResult].maxZ,worldPos.z);}
|
||
`;var c=function(){function u(d){this._computeShadersCache={},this._positionBuffers={},this._indexBuffers={},this._weightBuffers={},this._indexExtraBuffers={},this._weightExtraBuffers={},this._morphTargetInfluenceBuffers={},this._morphTargetTextureIndexBuffers={},this._ubos=[],this._uboIndex=0,this._processedMeshes=[],this._computeShaders=[],this._uniqueComputeShaders=new Set,this._resultBuffers=[],this._engine=d}return u.prototype._getComputeShader=function(d,h,p){var m,v=d.join(`
|
||
`);if(this._computeShadersCache[v])m=this._computeShadersCache[v];else{var b={positionBuffer:{group:0,binding:0},resultBuffer:{group:0,binding:1},settings:{group:0,binding:7}};h&&(b.boneSampler={group:0,binding:2},b.indexBuffer={group:0,binding:3},b.weightBuffer={group:0,binding:4},b.indexExtraBuffer={group:0,binding:5},b.weightExtraBuffer={group:0,binding:6}),p&&(b.morphTargets={group:0,binding:8},b.morphTargetInfluences={group:0,binding:9},b.morphTargetTextureIndices={group:0,binding:10}),m=new i.H("boundingInfoCompute".concat(h?"_bones":"").concat(p?"_morphs":""),this._engine,"boundingInfo",{bindingsMapping:b,defines:d}),this._computeShadersCache[v]=m}return m},u.prototype._getUBO=function(){if(this._uboIndex>=this._ubos.length){var d=new l.D(this._engine);d.addFloat3("morphTargetTextureInfo",0,0,0),d.addUniform("morphTargetCount",1),d.addUniform("indexResult",1),this._ubos.push(d)}return this._ubos[this._uboIndex++]},u.prototype._extractDataAndLink=function(d,h,p,m,v,b){var E,C,T=h.getTotalVertices();if(b[h.uniqueId])C=b[h.uniqueId];else{var f=(E=h.getVertexBuffer(p))===null||E===void 0?void 0:E.getFloatData(T);(C=new o.K(this._engine,Float32Array.BYTES_PER_ELEMENT*T*m)).update(f),b[h.uniqueId]=C}d.setStorageBuffer(v,C)},u.prototype._prepareStorage=function(d,h,p,m,v,b){var E;m[p]?E=m[p]:(E=new o.K(this._engine,Float32Array.BYTES_PER_ELEMENT*v),m[p]=E),E.update(b),d.setStorageBuffer(h,E)},u.prototype.processAsync=function(d){return(0,n.sH)(this,void 0,void 0,function(){return(0,n.YH)(this,function(h){switch(h.label){case 0:return[4,this.registerMeshListAsync(d)];case 1:return h.sent(),this.processMeshList(),[4,this.fetchResultsForMeshListAsync()];case 2:return h.sent(),[2]}})})},u.prototype.registerMeshListAsync=function(d){var h=this;this._disposeForMeshList(),Array.isArray(d)||(d=[d]);for(var p=0,m=0;m<d.length;m++)(v=d[m]).getTotalVertices()!==0&&v.getVertexBuffer&&v.getVertexBuffer(a.R.PositionKind)&&(this._processedMeshes.push(v),(C=v.morphTargetManager)&&(p=Math.max(p,C.numTargets)));for(m=0;m<this._processedMeshes.length;m++){var v,b=[""],E=!1;(v=this._processedMeshes[m])&&v.useBones&&v.computeBonesUsingShaders&&v.skeleton&&(b.push("#define NUM_BONE_INFLUENCERS "+v.numBoneInfluencers),E=!0);var C,T=this._getComputeShader(b,E,!1);if(this._uniqueComputeShaders.add(T),C=v.morphTargetManager){(b=b.slice()).push("#define MORPHTARGETS"),b.push("#define NUM_MORPH_INFLUENCERS "+p);var f=this._getComputeShader(b,E,!0);this._uniqueComputeShaders.add(f),this._computeShaders.push([T,f])}else this._computeShaders.push([T,T]);var g=this._getUBO();g.updateUInt("indexResult",m),g.update()}return new Promise(function(S){var y=function(){for(var x=h._uniqueComputeShaders.keys(),R=x.next();R.done!==!0;R=x.next())if(!R.value.isReady())return void setTimeout(y,10);S()};y()})},u.prototype.processMeshList=function(){if(this._processedMeshes.length!==0){this._uboIndex=0;var d=8*this._processedMeshes.length,h=new Float32Array(d),p=new o.K(this._engine,Float32Array.BYTES_PER_ELEMENT*d);this._resultBuffers.push(p);for(var m=0;m<this._processedMeshes.length;m++)h[8*m+0]=Number.POSITIVE_INFINITY,h[8*m+1]=Number.POSITIVE_INFINITY,h[8*m+2]=Number.POSITIVE_INFINITY,h[8*m+3]=Number.NEGATIVE_INFINITY,h[8*m+4]=Number.NEGATIVE_INFINITY,h[8*m+5]=Number.NEGATIVE_INFINITY;for(p.update(h),m=0;m<this._processedMeshes.length;m++){var v=this._processedMeshes[m],b=v.getTotalVertices(),E=this._computeShaders[m],C=E[0],T=E[1],f=v.morphTargetManager,g=f&&f.numInfluencers>0,S=g?T:C;if(this._extractDataAndLink(S,v,a.R.PositionKind,3,"positionBuffer",this._positionBuffers),v&&v.useBones&&v.computeBonesUsingShaders&&v.skeleton&&v.skeleton.useTextureToStoreBoneMatrices){this._extractDataAndLink(S,v,a.R.MatricesIndicesKind,4,"indexBuffer",this._indexBuffers),this._extractDataAndLink(S,v,a.R.MatricesWeightsKind,4,"weightBuffer",this._weightBuffers);var y=v.skeleton.getTransformMatrixTexture(v);S.setTexture("boneSampler",y,!1),v.numBoneInfluencers>4&&(this._extractDataAndLink(S,v,a.R.MatricesIndicesExtraKind,4,"indexExtraBuffer",this._indexExtraBuffers),this._extractDataAndLink(S,v,a.R.MatricesWeightsExtraKind,4,"weightExtraBuffer",this._weightExtraBuffers))}var x=this._getUBO();if(g){var R=f._targetStoreTexture;S.setTexture("morphTargets",R,!1),this._prepareStorage(S,"morphTargetInfluences",v.uniqueId,this._morphTargetInfluenceBuffers,f.numInfluencers,f.influences),this._prepareStorage(S,"morphTargetTextureIndices",v.uniqueId,this._morphTargetTextureIndexBuffers,f.numInfluencers,f._morphTargetTextureIndices),x.updateFloat3("morphTargetTextureInfo",f._textureVertexStride,f._textureWidth,f._textureHeight),x.updateInt("morphTargetCount",f.numInfluencers),x.update()}S.setStorageBuffer("resultBuffer",p),S.setUniformBuffer("settings",x),S.dispatch(Math.ceil(b/256)),this._engine.flushFramebuffer()}}},u.prototype.fetchResultsForMeshListAsync=function(){var d=this;return new Promise(function(h){for(var p=[],m=0,v=0;v<d._resultBuffers.length;v++){var b=d._resultBuffers[v].getBuffer();p.push(b),m+=b.capacity}var E=new Float32Array(m/Float32Array.BYTES_PER_ELEMENT),C=s.Pq.Zero(),T=s.Pq.Zero(),f={minimum:C,maximum:T};d._engine.readFromMultipleStorageBuffers(p,0,void 0,E,!0).then(function(){for(var g=0,S=0;S<d._resultBuffers.length;S++){for(var y=0;y<d._processedMeshes.length;y++){var x=d._processedMeshes[y];s.Pq.FromArrayToRef(E,g+8*y,C),s.Pq.FromArrayToRef(E,g+8*y+3,T),S>0&&(C.minimizeInPlace(x.getBoundingInfo().minimum),T.maximizeInPlace(x.getBoundingInfo().maximum)),x._refreshBoundingInfoDirect(f)}g+=8*d._processedMeshes.length}for(var R=0,I=d._resultBuffers;R<I.length;R++)I[R].dispose();d._resultBuffers=[],d._uboIndex=0,h()})})},u.prototype._disposeCache=function(d){for(var h in d)d[h].dispose()},u.prototype._disposeForMeshList=function(){for(var d=0,h=this._resultBuffers;d<h.length;d++)h[d].dispose();this._resultBuffers=[],this._processedMeshes=[],this._computeShaders=[],this._uniqueComputeShaders=new Set},u.prototype.dispose=function(){this._disposeCache(this._positionBuffers),this._positionBuffers={},this._disposeCache(this._indexBuffers),this._indexBuffers={},this._disposeCache(this._weightBuffers),this._weightBuffers={},this._disposeCache(this._morphTargetInfluenceBuffers),this._morphTargetInfluenceBuffers={},this._disposeCache(this._morphTargetTextureIndexBuffers),this._morphTargetTextureIndexBuffers={};for(var d=0,h=this._ubos;d<h.length;d++)h[d].dispose();this._ubos=[],this._computeShadersCache={},this._engine=void 0,this._disposeForMeshList()},u}()},37904:(r,t,e)=>{e.r(t),e.d(t,{TransformFeedbackBoundingHelper:()=>u});var n=e(62623),i=e(81152),o=e(85096),a=e(47424),s=e(8046),l=e(98519),c=(e(36470),e(64400),e(24444),e(67369),e(58266),e(84589),e(76898),e(49334),"gpuTransformVertexShader");l.l.ShadersStore[c]=`attribute vec3 position;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
out vec3 outPosition;const mat4 identity=mat4(
|
||
vec4(1.0,0.0,0.0,0.0),
|
||
vec4(0.0,1.0,0.0,0.0),
|
||
vec4(0.0,0.0,1.0,0.0),
|
||
vec4(0.0,0.0,0.0,1.0)
|
||
);void main(void) {vec3 positionUpdated=position;
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
mat4 finalWorld=identity;
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);outPosition=worldPos.xyz;}`,l.l.ShadersStore.gpuTransformPixelShader=`#version 300 es
|
||
void main() {discard;}
|
||
`;var u=function(){function d(h){this._buffers={},this._effects={},this._meshListCounter=0,this._engine=h}return d.prototype.processAsync=function(h){return Array.isArray(h)||(h=[h]),this._meshListCounter=0,this._processMeshList(h),Promise.resolve()},d.prototype._processMeshList=function(h){var p=this._engine.getCaps().parallelShaderCompile;this._engine.getCaps().parallelShaderCompile=void 0;for(var m=0;m<h.length;++m){var v=h[m];if(v.getTotalVertices()!==0&&v.getVertexBuffer&&v.getVertexBuffer(n.R.PositionKind)){var b=void 0,E=0,C=[],T=[],f=[n.R.PositionKind],g=[];if(v&&v.useBones&&v.computeBonesUsingShaders&&v.skeleton){f.push(n.R.MatricesIndicesKind),f.push(n.R.MatricesWeightsKind),v.numBoneInfluencers>4&&(f.push(n.R.MatricesIndicesExtraKind),f.push(n.R.MatricesWeightsExtraKind));var S=v.skeleton;C.push("#define NUM_BONE_INFLUENCERS "+v.numBoneInfluencers),S.isUsingTextureForMatrices?(C.push("#define BONETEXTURE"),T.indexOf("boneTextureWidth")===-1&&T.push("boneTextureWidth"),g.indexOf("boneSampler")===-1&&g.push("boneSampler")):(C.push("#define BonesPerMesh "+(S.bones.length+1)),T.indexOf("mBones")===-1&&T.push("mBones"))}else C.push("#define NUM_BONE_INFLUENCERS 0");var y=v?v.morphTargetManager:null;if(y){(E=y.numMaxInfluencers||y.numInfluencers)>0&&C.push("#define MORPHTARGETS"),y.isUsingTextureForTargets&&(C.push("#define MORPHTARGETS_TEXTURE"),T.indexOf("morphTargetTextureIndices")===-1&&T.push("morphTargetTextureIndices"),g.indexOf("morphTargets")===-1&&g.push("morphTargets")),C.push("#define NUM_MORPH_INFLUENCERS "+E);for(var x=0;x<E;x++)f.push(n.R.PositionKind+x);E>0&&((T=T.slice()).push("morphTargetInfluences"),T.push("morphTargetCount"),T.push("morphTargetTextureInfo"),T.push("morphTargetTextureIndices"))}var R=v.bakedVertexAnimationManager;R&&R.isEnabled&&(C.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),T.indexOf("bakedVertexAnimationSettings")===-1&&T.push("bakedVertexAnimationSettings"),T.indexOf("bakedVertexAnimationTextureSizeInverted")===-1&&T.push("bakedVertexAnimationTextureSizeInverted"),T.indexOf("bakedVertexAnimationTime")===-1&&T.push("bakedVertexAnimationTime"),g.indexOf("bakedVertexAnimationTexture")===-1&&g.push("bakedVertexAnimationTexture"),(0,o.J2)(f,v,C));var I=C.join(`
|
||
`);if(this._effects[I])b=this._effects[I];else{var M={attributes:f,uniformsNames:T,uniformBuffersNames:[],samplers:g,defines:I,fallbacks:null,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:E},maxSimultaneousLights:0,transformFeedbackVaryings:["outPosition"]};b=this._engine.createEffect("gpuTransform",M,this._engine),this._effects[I]=b}this._compute(v,b)}}this._engine.getCaps().parallelShaderCompile=p},d.prototype._compute=function(h,p){var m,v,b=this._engine,E=h.getTotalVertices();if(this._buffers[h.uniqueId])v=this._buffers[h.uniqueId];else{var C=new Float32Array(3*E);v=new n.h(h.getEngine(),C,!0,3),this._buffers[h.uniqueId]=v}p.getEngine().enableEffect(p),h._bindDirect(p,null,!0),(0,o.f$)(h,p);var T=h.morphTargetManager;T&&T.numInfluencers>0&&(0,o.nR)(h,p);var f=h.bakedVertexAnimationManager;f&&f.isEnabled&&((m=h.bakedVertexAnimationManager)===null||m===void 0||m.bind(p,!1));var g=v.getData();if(b.bindTransformFeedbackBuffer(v.getBuffer()),b.setRasterizerState(!1),b.beginTransformFeedback(!0),b.drawArraysType(i.Y.MATERIAL_PointFillMode,0,E),b.endTransformFeedback(),b.setRasterizerState(!0),b.readTransformFeedbackBuffer(g),b.bindTransformFeedbackBuffer(null),this._meshListCounter===0)h._refreshBoundingInfo(g,null);else{var S=h.getBoundingInfo().boundingBox,y=(0,a.b)(g,0,E);d._Min.copyFrom(S.minimum).minimizeInPlace(y.minimum),d._Max.copyFrom(S.maximum).maximizeInPlace(y.maximum),h._refreshBoundingInfoDirect({minimum:d._Min,maximum:d._Max})}},d.prototype.registerMeshListAsync=function(h){return Array.isArray(h)||(h=[h]),this._meshList=h,this._meshListCounter=0,Promise.resolve()},d.prototype.processMeshList=function(){this._meshList.length!==0&&(this._processMeshList(this._meshList),this._meshListCounter++)},d.prototype.fetchResultsForMeshListAsync=function(){return this._meshListCounter=0,Promise.resolve()},d.prototype.dispose=function(){for(var h in this._buffers)this._buffers[h].dispose();this._buffers={},this._effects={},this._engine=null},d._Min=new s.Pq,d._Max=new s.Pq,d}()},45158:(r,t,e)=>{var n,i,o,a,s,l,c;e.d(t,{ST:()=>i,Ze:()=>o,bq:()=>n,dR:()=>c,h8:()=>a,pI:()=>s,sZ:()=>l}),function(u){u[u.Generic=0]="Generic",u[u.Keyboard=1]="Keyboard",u[u.Mouse=2]="Mouse",u[u.Touch=3]="Touch",u[u.DualShock=4]="DualShock",u[u.Xbox=5]="Xbox",u[u.Switch=6]="Switch",u[u.DualSense=7]="DualSense"}(n||(n={})),function(u){u[u.Horizontal=0]="Horizontal",u[u.Vertical=1]="Vertical",u[u.LeftClick=2]="LeftClick",u[u.MiddleClick=3]="MiddleClick",u[u.RightClick=4]="RightClick",u[u.BrowserBack=5]="BrowserBack",u[u.BrowserForward=6]="BrowserForward",u[u.MouseWheelX=7]="MouseWheelX",u[u.MouseWheelY=8]="MouseWheelY",u[u.MouseWheelZ=9]="MouseWheelZ",u[u.Move=12]="Move"}(i||(i={})),function(u){u[u.Horizontal=0]="Horizontal",u[u.Vertical=1]="Vertical",u[u.LeftClick=2]="LeftClick",u[u.MiddleClick=3]="MiddleClick",u[u.RightClick=4]="RightClick",u[u.BrowserBack=5]="BrowserBack",u[u.BrowserForward=6]="BrowserForward",u[u.MouseWheelX=7]="MouseWheelX",u[u.MouseWheelY=8]="MouseWheelY",u[u.MouseWheelZ=9]="MouseWheelZ",u[u.DeltaHorizontal=10]="DeltaHorizontal",u[u.DeltaVertical=11]="DeltaVertical"}(o||(o={})),function(u){u[u.Cross=0]="Cross",u[u.Circle=1]="Circle",u[u.Square=2]="Square",u[u.Triangle=3]="Triangle",u[u.L1=4]="L1",u[u.R1=5]="R1",u[u.L2=6]="L2",u[u.R2=7]="R2",u[u.Share=8]="Share",u[u.Options=9]="Options",u[u.L3=10]="L3",u[u.R3=11]="R3",u[u.DPadUp=12]="DPadUp",u[u.DPadDown=13]="DPadDown",u[u.DPadLeft=14]="DPadLeft",u[u.DPadRight=15]="DPadRight",u[u.Home=16]="Home",u[u.TouchPad=17]="TouchPad",u[u.LStickXAxis=18]="LStickXAxis",u[u.LStickYAxis=19]="LStickYAxis",u[u.RStickXAxis=20]="RStickXAxis",u[u.RStickYAxis=21]="RStickYAxis"}(a||(a={})),function(u){u[u.Cross=0]="Cross",u[u.Circle=1]="Circle",u[u.Square=2]="Square",u[u.Triangle=3]="Triangle",u[u.L1=4]="L1",u[u.R1=5]="R1",u[u.L2=6]="L2",u[u.R2=7]="R2",u[u.Create=8]="Create",u[u.Options=9]="Options",u[u.L3=10]="L3",u[u.R3=11]="R3",u[u.DPadUp=12]="DPadUp",u[u.DPadDown=13]="DPadDown",u[u.DPadLeft=14]="DPadLeft",u[u.DPadRight=15]="DPadRight",u[u.Home=16]="Home",u[u.TouchPad=17]="TouchPad",u[u.LStickXAxis=18]="LStickXAxis",u[u.LStickYAxis=19]="LStickYAxis",u[u.RStickXAxis=20]="RStickXAxis",u[u.RStickYAxis=21]="RStickYAxis"}(s||(s={})),function(u){u[u.A=0]="A",u[u.B=1]="B",u[u.X=2]="X",u[u.Y=3]="Y",u[u.LB=4]="LB",u[u.RB=5]="RB",u[u.LT=6]="LT",u[u.RT=7]="RT",u[u.Back=8]="Back",u[u.Start=9]="Start",u[u.LS=10]="LS",u[u.RS=11]="RS",u[u.DPadUp=12]="DPadUp",u[u.DPadDown=13]="DPadDown",u[u.DPadLeft=14]="DPadLeft",u[u.DPadRight=15]="DPadRight",u[u.Home=16]="Home",u[u.LStickXAxis=17]="LStickXAxis",u[u.LStickYAxis=18]="LStickYAxis",u[u.RStickXAxis=19]="RStickXAxis",u[u.RStickYAxis=20]="RStickYAxis"}(l||(l={})),function(u){u[u.B=0]="B",u[u.A=1]="A",u[u.Y=2]="Y",u[u.X=3]="X",u[u.L=4]="L",u[u.R=5]="R",u[u.ZL=6]="ZL",u[u.ZR=7]="ZR",u[u.Minus=8]="Minus",u[u.Plus=9]="Plus",u[u.LS=10]="LS",u[u.RS=11]="RS",u[u.DPadUp=12]="DPadUp",u[u.DPadDown=13]="DPadDown",u[u.DPadLeft=14]="DPadLeft",u[u.DPadRight=15]="DPadRight",u[u.Home=16]="Home",u[u.Capture=17]="Capture",u[u.LStickXAxis=18]="LStickXAxis",u[u.LStickYAxis=19]="LStickYAxis",u[u.RStickXAxis=20]="RStickXAxis",u[u.RStickYAxis=21]="RStickYAxis"}(c||(c={}))},84163:(r,t,e)=>{e.d(t,{c:()=>i});var n=e(66377),i=function(){function o(a,s,l){l===void 0&&(l=0),this.deviceType=s,this.deviceSlot=l,this.onInputChangedObservable=new n.cP,this._deviceInputSystem=a}return o.prototype.getInput=function(a){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,a)},o}()},67925:(r,t,e)=>{e.d(t,{Z:()=>v});var n=e(45158),i=e(66377),o=e(81152),a=e(50712),s=function(){function b(){}return b.CreateDeviceEvent=function(E,C,T,f,g,S,y){switch(E){case n.bq.Keyboard:return this._CreateKeyboardEvent(T,f,g,S);case n.bq.Mouse:if(T===n.ST.MouseWheelX||T===n.ST.MouseWheelY||T===n.ST.MouseWheelZ)return this._CreateWheelEvent(E,C,T,f,g,S);case n.bq.Touch:return this._CreatePointerEvent(E,C,T,f,g,S,y);default:throw"Unable to generate event for device ".concat(n.bq[E])}},b._CreatePointerEvent=function(E,C,T,f,g,S,y){var x=this._CreateMouseEvent(E,C,T,f,g,S);E===n.bq.Mouse?(x.deviceType=n.bq.Mouse,x.pointerId=1,x.pointerType="mouse"):(x.deviceType=n.bq.Touch,x.pointerId=y??C,x.pointerType="touch");var R=0;return R+=g.pollInput(E,C,n.ST.LeftClick),R+=2*g.pollInput(E,C,n.ST.RightClick),R+=4*g.pollInput(E,C,n.ST.MiddleClick),x.buttons=R,T===n.ST.Move?x.type="pointermove":T>=n.ST.LeftClick&&T<=n.ST.RightClick&&(x.type=f===1?"pointerdown":"pointerup",x.button=T-2),x},b._CreateWheelEvent=function(E,C,T,f,g,S){var y=this._CreateMouseEvent(E,C,T,f,g,S);switch(y.pointerId=1,y.type="wheel",y.deltaMode=a.s.DOM_DELTA_PIXEL,y.deltaX=0,y.deltaY=0,y.deltaZ=0,T){case n.ST.MouseWheelX:y.deltaX=f;break;case n.ST.MouseWheelY:y.deltaY=f;break;case n.ST.MouseWheelZ:y.deltaZ=f}return y},b._CreateMouseEvent=function(E,C,T,f,g,S){var y=this._CreateEvent(S),x=g.pollInput(E,C,n.ST.Horizontal),R=g.pollInput(E,C,n.ST.Vertical);return S?(y.movementX=0,y.movementY=0,y.offsetX=y.movementX-S.getBoundingClientRect().x,y.offsetY=y.movementY-S.getBoundingClientRect().y):(y.movementX=g.pollInput(E,C,10),y.movementY=g.pollInput(E,C,11),y.offsetX=0,y.offsetY=0),this._CheckNonCharacterKeys(y,g),y.clientX=x,y.clientY=R,y.x=x,y.y=R,y.deviceType=E,y.deviceSlot=C,y.inputIndex=T,y},b._CreateKeyboardEvent=function(E,C,T,f){var g=this._CreateEvent(f);return this._CheckNonCharacterKeys(g,T),g.deviceType=n.bq.Keyboard,g.deviceSlot=0,g.inputIndex=E,g.type=C===1?"keydown":"keyup",g.key=String.fromCharCode(E),g.keyCode=E,g},b._CheckNonCharacterKeys=function(E,C){var T=C.isDeviceAvailable(n.bq.Keyboard),f=T&&C.pollInput(n.bq.Keyboard,0,o.Y.INPUT_ALT_KEY)===1,g=T&&C.pollInput(n.bq.Keyboard,0,o.Y.INPUT_CTRL_KEY)===1,S=T&&(C.pollInput(n.bq.Keyboard,0,o.Y.INPUT_META_KEY1)===1||C.pollInput(n.bq.Keyboard,0,o.Y.INPUT_META_KEY2)===1||C.pollInput(n.bq.Keyboard,0,o.Y.INPUT_META_KEY3)===1),y=T&&C.pollInput(n.bq.Keyboard,0,o.Y.INPUT_SHIFT_KEY)===1;E.altKey=f,E.ctrlKey=g,E.metaKey=S,E.shiftKey=y},b._CreateEvent=function(E){var C={preventDefault:function(){}};return C.target=E,C},b}(),l=function(){function b(E,C,T){var f=this;this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(E,C,function(g,S,y,x){var R=s.CreateDeviceEvent(g,S,y,x,f);T(g,S,R)}):this._createDummyNativeInput()}return b.prototype.pollInput=function(E,C,T){return this._nativeInput.pollInput(E,C,T)},b.prototype.isDeviceAvailable=function(E){return E===n.bq.Mouse||E===n.bq.Touch},b.prototype.dispose=function(){this._nativeInput.dispose()},b.prototype._createDummyNativeInput=function(){return{pollInput:function(){return 0},isDeviceAvailable:function(){return!1},dispose:function(){}}},b}(),c=e(5153),u=e(44957),d=Object.keys(n.ST).length/2,h=function(){function b(E,C,T,f){var g=this;this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=u.S0.IsSafari(),this._usingMacOS=(0,c.XD)()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=function(S){},this._keyboardUpEvent=function(S){},this._keyboardBlurEvent=function(S){},this._pointerMoveEvent=function(S){},this._pointerDownEvent=function(S){},this._pointerUpEvent=function(S){},this._pointerCancelEvent=function(S){},this._pointerWheelEvent=function(S){},this._pointerBlurEvent=function(S){},this._pointerMacOSChromeOutEvent=function(S){},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=(0,c.XD)()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=(0,c.XD)()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=function(S){},this._gamepadDisconnectedEvent=function(S){},this._eventPrefix=u.S0.GetPointerPrefix(E),this._engine=E,this._onDeviceConnected=C,this._onDeviceDisconnected=T,this._onInputChanged=f,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOS&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=function(){g._enableEvents()})}return b.prototype.pollInput=function(E,C,T){var f=this._inputs[E][C];if(!f)throw"Unable to find device ".concat(n.bq[E]);E>=n.bq.DualShock&&E<=n.bq.DualSense&&this._updateDevice(E,C,T);var g=f[T];if(g===void 0)throw"Unable to find input ".concat(T," for device ").concat(n.bq[E]," in slot ").concat(C);return T===n.ST.Move&&u.S0.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),g},b.prototype.isDeviceAvailable=function(E){return this._inputs[E]!==void 0},b.prototype.dispose=function(){this._onDeviceConnected=function(){},this._onDeviceDisconnected=function(){},this._onInputChanged=function(){},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()},b.prototype._enableEvents=function(){var E=this==null?void 0:this._engine.getInputElement();if(E&&(!this._eventsAttached||this._elementToAttachTo!==E)){if(this._disableEvents(),this._inputs)for(var C=0,T=this._inputs;C<T.length;C++){var f=T[C];if(f)for(var g in f){var S=f[+g];if(S)for(var y=0;y<S.length;y++)S[y]=0}}this._elementToAttachTo=E,this._elementToAttachTo.tabIndex=this._elementToAttachTo.tabIndex!==-1?this._elementToAttachTo.tabIndex:this._engine.canvasTabIndex,this._handleKeyActions(),this._handlePointerActions(),this._handleGamepadActions(),this._eventsAttached=!0,this._checkForConnectedDevices()}},b.prototype._disableEvents=function(){this._elementToAttachTo&&(this._elementToAttachTo.removeEventListener("blur",this._keyboardBlurEvent),this._elementToAttachTo.removeEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.removeEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.removeEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.removeEventListener(this._wheelEventName,this._pointerWheelEvent),this._usingMacOS&&this._isUsingChromium&&this._elementToAttachTo.removeEventListener("lostpointercapture",this._pointerMacOSChromeOutEvent),window.removeEventListener("gamepadconnected",this._gamepadConnectedEvent),window.removeEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)),this._pointerInputClearObserver&&this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver),this._eventsAttached=!1},b.prototype._checkForConnectedDevices=function(){if(navigator.getGamepads)for(var E=0,C=navigator.getGamepads();E<C.length;E++){var T=C[E];T&&this._addGamePad(T)}typeof matchMedia=="function"&&matchMedia("(pointer:fine)").matches&&this._addPointerDevice(n.bq.Mouse,0,0,0)},b.prototype._addGamePad=function(E){var C=this._getGamepadDeviceType(E.id),T=E.index;this._gamepads=this._gamepads||new Array(E.index+1),this._registerDevice(C,T,E.buttons.length+E.axes.length),this._gamepads[T]=C},b.prototype._addPointerDevice=function(E,C,T,f){this._pointerActive||(this._pointerActive=!0),this._registerDevice(E,C,d);var g=this._inputs[E][C];g[0]=T,g[1]=f},b.prototype._registerDevice=function(E,C,T){if(C===void 0)throw"Unable to register device ".concat(n.bq[E]," to undefined slot.");if(this._inputs[E]||(this._inputs[E]={}),!this._inputs[E][C]){var f=new Array(T);f.fill(0),this._inputs[E][C]=f,this._onDeviceConnected(E,C)}},b.prototype._unregisterDevice=function(E,C){this._inputs[E][C]&&(delete this._inputs[E][C],this._onDeviceDisconnected(E,C))},b.prototype._handleKeyActions=function(){var E=this;this._keyboardDownEvent=function(C){E._keyboardActive||(E._keyboardActive=!0,E._registerDevice(n.bq.Keyboard,0,255));var T=E._inputs[n.bq.Keyboard][0];if(T){T[C.keyCode]=1;var f=C;f.inputIndex=C.keyCode,E._usingMacOS&&C.metaKey&&C.key!=="Meta"&&(E._metaKeys.includes(C.keyCode)||E._metaKeys.push(C.keyCode)),E._onInputChanged(n.bq.Keyboard,0,f)}},this._keyboardUpEvent=function(C){E._keyboardActive||(E._keyboardActive=!0,E._registerDevice(n.bq.Keyboard,0,255));var T=E._inputs[n.bq.Keyboard][0];if(T){T[C.keyCode]=0;var f=C;if(f.inputIndex=C.keyCode,E._usingMacOS&&C.key==="Meta"&&E._metaKeys.length>0){for(var g=0,S=E._metaKeys;g<S.length;g++){var y=S[g],x=s.CreateDeviceEvent(n.bq.Keyboard,0,y,0,E,E._elementToAttachTo);T[y]=0,E._onInputChanged(n.bq.Keyboard,0,x)}E._metaKeys.splice(0,E._metaKeys.length)}E._onInputChanged(n.bq.Keyboard,0,f)}},this._keyboardBlurEvent=function(){if(E._keyboardActive){for(var C=E._inputs[n.bq.Keyboard][0],T=0;T<C.length;T++)if(C[T]!==0){C[T]=0;var f=s.CreateDeviceEvent(n.bq.Keyboard,0,T,0,E,E._elementToAttachTo);E._onInputChanged(n.bq.Keyboard,0,f)}E._usingMacOS&&E._metaKeys.splice(0,E._metaKeys.length)}},this._elementToAttachTo.addEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.addEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.addEventListener("blur",this._keyboardBlurEvent)},b.prototype._handlePointerActions=function(){var E=this;this._maxTouchPoints=(0,c.XD)()&&navigator.maxTouchPoints||2,this._activeTouchIds||(this._activeTouchIds=new Array(this._maxTouchPoints));for(var C=0;C<this._maxTouchPoints;C++)this._activeTouchIds[C]=-1;this._pointerMoveEvent=function(S){var y=E._getPointerType(S),x=y===n.bq.Mouse?0:E._activeTouchIds.indexOf(S.pointerId);if(y===n.bq.Touch&&x===-1){var R=E._activeTouchIds.indexOf(-1);if(!(R>=0))return void u.S0.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(E._maxTouchPoints));x=R,E._activeTouchIds[R]=S.pointerId,E._onDeviceConnected(y,x)}E._inputs[y]||(E._inputs[y]={}),E._inputs[y][x]||E._addPointerDevice(y,x,S.clientX,S.clientY);var I=E._inputs[y][x];if(I){var M=S;M.inputIndex=n.ST.Move,I[n.ST.Horizontal]=S.clientX,I[n.ST.Vertical]=S.clientY,y===n.bq.Touch&&I[n.ST.LeftClick]===0&&(I[n.ST.LeftClick]=1),S.pointerId===void 0&&(S.pointerId=E._mouseId),E._onInputChanged(y,x,M),E._usingSafari||S.button===-1||(M.inputIndex=S.button+2,I[S.button+2]=I[S.button+2]?0:1,E._onInputChanged(y,x,M))}},this._pointerDownEvent=function(S){var y=E._getPointerType(S),x=y===n.bq.Mouse?0:S.pointerId;if(y===n.bq.Touch){var R=E._activeTouchIds.indexOf(S.pointerId);if(R===-1&&(R=E._activeTouchIds.indexOf(-1)),!(R>=0))return void u.S0.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(E._maxTouchPoints));x=R,E._activeTouchIds[R]=S.pointerId}E._inputs[y]||(E._inputs[y]={}),E._inputs[y][x]?y===n.bq.Touch&&E._onDeviceConnected(y,x):E._addPointerDevice(y,x,S.clientX,S.clientY);var I=E._inputs[y][x];if(I){var M=I[n.ST.Horizontal],D=I[n.ST.Vertical];if(y===n.bq.Mouse){if(S.pointerId===void 0&&(S.pointerId=E._mouseId),!document.pointerLockElement)try{E._elementToAttachTo.setPointerCapture(E._mouseId)}catch{}}else if(S.pointerId&&!document.pointerLockElement)try{E._elementToAttachTo.setPointerCapture(S.pointerId)}catch{}I[n.ST.Horizontal]=S.clientX,I[n.ST.Vertical]=S.clientY,I[S.button+2]=1;var B=S;B.inputIndex=S.button+2,E._onInputChanged(y,x,B),M===S.clientX&&D===S.clientY||(B.inputIndex=n.ST.Move,E._onInputChanged(y,x,B))}},this._pointerUpEvent=function(S){var y,x,R,I,M,D=E._getPointerType(S),B=D===n.bq.Mouse?0:E._activeTouchIds.indexOf(S.pointerId);if(D===n.bq.Touch){if(B===-1)return;E._activeTouchIds[B]=-1}var F=(y=E._inputs[D])===null||y===void 0?void 0:y[B];if(F&&F[S.button+2]!==0){var X=F[n.ST.Horizontal],$=F[n.ST.Vertical];F[n.ST.Horizontal]=S.clientX,F[n.ST.Vertical]=S.clientY,F[S.button+2]=0;var Q=S;S.pointerId===void 0&&(S.pointerId=E._mouseId),X===S.clientX&&$===S.clientY||(Q.inputIndex=n.ST.Move,E._onInputChanged(D,B,Q)),Q.inputIndex=S.button+2,D===n.bq.Mouse&&E._mouseId>=0&&(!((R=(x=E._elementToAttachTo).hasPointerCapture)===null||R===void 0)&&R.call(x,E._mouseId))?E._elementToAttachTo.releasePointerCapture(E._mouseId):S.pointerId&&(!((M=(I=E._elementToAttachTo).hasPointerCapture)===null||M===void 0)&&M.call(I,S.pointerId))&&E._elementToAttachTo.releasePointerCapture(S.pointerId),E._onInputChanged(D,B,Q),D===n.bq.Touch&&E._onDeviceDisconnected(D,B)}},this._pointerCancelEvent=function(S){var y,x,R,I;if(S.pointerType==="mouse"){var M=E._inputs[n.bq.Mouse][0];E._mouseId>=0&&(!((x=(y=E._elementToAttachTo).hasPointerCapture)===null||x===void 0)&&x.call(y,E._mouseId))&&E._elementToAttachTo.releasePointerCapture(E._mouseId);for(var D=n.ST.LeftClick;D<=n.ST.BrowserForward;D++)if(M[D]===1){M[D]=0;var B=s.CreateDeviceEvent(n.bq.Mouse,0,D,0,E,E._elementToAttachTo);E._onInputChanged(n.bq.Mouse,0,B)}}else{var F=E._activeTouchIds.indexOf(S.pointerId);if(F===-1)return;!((I=(R=E._elementToAttachTo).hasPointerCapture)===null||I===void 0)&&I.call(R,S.pointerId)&&E._elementToAttachTo.releasePointerCapture(S.pointerId),E._inputs[n.bq.Touch][F][n.ST.LeftClick]=0,B=s.CreateDeviceEvent(n.bq.Touch,F,n.ST.LeftClick,0,E,E._elementToAttachTo,S.pointerId),E._onInputChanged(n.bq.Touch,F,B),E._activeTouchIds[F]=-1,E._onDeviceDisconnected(n.bq.Touch,F)}},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";var T=!1,f=function(){};try{var g=Object.defineProperty({},"passive",{get:function(){T=!0}});this._elementToAttachTo.addEventListener("test",f,g),this._elementToAttachTo.removeEventListener("test",f,g)}catch{}this._pointerBlurEvent=function(){var S,y,x,R,I;if(E.isDeviceAvailable(n.bq.Mouse)){var M=E._inputs[n.bq.Mouse][0];E._mouseId>=0&&(!((y=(S=E._elementToAttachTo).hasPointerCapture)===null||y===void 0)&&y.call(S,E._mouseId))&&E._elementToAttachTo.releasePointerCapture(E._mouseId);for(var D=n.ST.LeftClick;D<=n.ST.BrowserForward;D++)if(M[D]===1){M[D]=0;var B=s.CreateDeviceEvent(n.bq.Mouse,0,D,0,E,E._elementToAttachTo);E._onInputChanged(n.bq.Mouse,0,B)}}if(E.isDeviceAvailable(n.bq.Touch)){M=E._inputs[n.bq.Touch];for(var F=0;F<E._activeTouchIds.length;F++){var X=E._activeTouchIds[F];!((R=(x=E._elementToAttachTo).hasPointerCapture)===null||R===void 0)&&R.call(x,X)&&E._elementToAttachTo.releasePointerCapture(X),X!==-1&&((I=M[F])===null||I===void 0?void 0:I[n.ST.LeftClick])===1&&(M[F][n.ST.LeftClick]=0,B=s.CreateDeviceEvent(n.bq.Touch,F,n.ST.LeftClick,0,E,E._elementToAttachTo,X),E._onInputChanged(n.bq.Touch,F,B),E._activeTouchIds[F]=-1,E._onDeviceDisconnected(n.bq.Touch,F))}}},this._pointerWheelEvent=function(S){var y=n.bq.Mouse;E._inputs[y]||(E._inputs[y]=[]),E._inputs[y][0]||(E._pointerActive=!0,E._registerDevice(y,0,d));var x=E._inputs[y][0];if(x){x[n.ST.MouseWheelX]=S.deltaX||0,x[n.ST.MouseWheelY]=S.deltaY||S.wheelDelta||0,x[n.ST.MouseWheelZ]=S.deltaZ||0;var R=S;S.pointerId===void 0&&(S.pointerId=E._mouseId),x[n.ST.MouseWheelX]!==0&&(R.inputIndex=n.ST.MouseWheelX,E._onInputChanged(y,0,R)),x[n.ST.MouseWheelY]!==0&&(R.inputIndex=n.ST.MouseWheelY,E._onInputChanged(y,0,R)),x[n.ST.MouseWheelZ]!==0&&(R.inputIndex=n.ST.MouseWheelZ,E._onInputChanged(y,0,R))}},this._usingMacOS&&this._isUsingChromium&&(this._pointerMacOSChromeOutEvent=function(S){S.buttons>1&&E._pointerCancelEvent(S)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOSChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,!!T&&{passive:!1}),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add(function(){if(E.isDeviceAvailable(n.bq.Mouse)){var S=E._inputs[n.bq.Mouse][0];S[n.ST.MouseWheelX]=0,S[n.ST.MouseWheelY]=0,S[n.ST.MouseWheelZ]=0}})},b.prototype._handleGamepadActions=function(){var E=this;this._gamepadConnectedEvent=function(C){E._addGamePad(C.gamepad)},this._gamepadDisconnectedEvent=function(C){if(E._gamepads){var T=E._getGamepadDeviceType(C.gamepad.id),f=C.gamepad.index;E._unregisterDevice(T,f),delete E._gamepads[f]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)},b.prototype._updateDevice=function(E,C,T){var f=navigator.getGamepads()[C];if(f&&E===this._gamepads[C]){var g=this._inputs[E][C];T>=f.buttons.length?g[T]=f.axes[T-f.buttons.length].valueOf():g[T]=f.buttons[T].value}},b.prototype._getGamepadDeviceType=function(E){return E.indexOf("054c")!==-1?E.indexOf("0ce6")!==-1?n.bq.DualSense:n.bq.DualShock:E.indexOf("Xbox One")!==-1||E.search("Xbox 360")!==-1||E.search("xinput")!==-1?n.bq.Xbox:E.indexOf("057e")!==-1?n.bq.Switch:n.bq.Generic},b.prototype._getPointerType=function(E){var C=n.bq.Mouse;return(E.pointerType==="touch"||E.pointerType==="pen"||E.touches)&&(C=n.bq.Touch),C},b}(),p=e(84163),m=function(){function b(E){var C=this;this._registeredManagers=new Array,this._refCount=0,this.registerManager=function(y){for(var x=0;x<C._devices.length;x++){var R=C._devices[x];for(var I in R){var M=+I;y._addDevice(new p.c(C._deviceInputSystem,x,M))}}C._registeredManagers.push(y)},this.unregisterManager=function(y){var x=C._registeredManagers.indexOf(y);x>-1&&C._registeredManagers.splice(x,1)};var T=Object.keys(n.bq).length/2;this._devices=new Array(T);var f=function(y,x){C._devices[y]||(C._devices[y]=new Array),C._devices[y][x]||(C._devices[y][x]=x);for(var R=0,I=C._registeredManagers;R<I.length;R++){var M=I[R],D=new p.c(C._deviceInputSystem,y,x);M._addDevice(D)}},g=function(y,x){var R;!((R=C._devices[y])===null||R===void 0)&&R[x]&&delete C._devices[y][x];for(var I=0,M=C._registeredManagers;I<M.length;I++)M[I]._removeDevice(y,x)},S=function(y,x,R){if(R)for(var I=0,M=C._registeredManagers;I<M.length;I++)M[I]._onInputChanged(y,x,R)};typeof _native<"u"?this._deviceInputSystem=new l(f,g,S):this._deviceInputSystem=new h(E,f,g,S)}return b.prototype.dispose=function(){this._deviceInputSystem.dispose()},b}(),v=function(){function b(E){var C=this,T=Object.keys(n.bq).length/2;this._devices=new Array(T),this._firstDevice=new Array(T),this._engine=E,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new m(E)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new i.cP(function(f){for(var g=0,S=C._devices;g<S.length;g++){var y=S[g];if(y)for(var x=0,R=y;x<R.length;x++){var I=R[x];I&&C.onDeviceConnectedObservable.notifyObserver(f,I)}}}),this.onDeviceDisconnectedObservable=new i.cP,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=E.onDisposeObservable.add(function(){C.dispose()})}return b.prototype.getDeviceSource=function(E,C){if(C===void 0){if(this._firstDevice[E]===void 0)return null;C=this._firstDevice[E]}return this._devices[E]&&this._devices[E][C]!==void 0?this._devices[E][C]:null},b.prototype.getDeviceSources=function(E){return this._devices[E]?this._devices[E].filter(function(C){return!!C}):[]},b.prototype.dispose=function(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)},b.prototype._addDevice=function(E){this._devices[E.deviceType]||(this._devices[E.deviceType]=new Array),this._devices[E.deviceType][E.deviceSlot]||(this._devices[E.deviceType][E.deviceSlot]=E,this._updateFirstDevices(E.deviceType)),this.onDeviceConnectedObservable.notifyObservers(E)},b.prototype._removeDevice=function(E,C){var T,f,g=(T=this._devices[E])===null||T===void 0?void 0:T[C];this.onDeviceDisconnectedObservable.notifyObservers(g),!((f=this._devices[E])===null||f===void 0)&&f[C]&&delete this._devices[E][C],this._updateFirstDevices(E)},b.prototype._onInputChanged=function(E,C,T){var f,g;(g=(f=this._devices[E])===null||f===void 0?void 0:f[C])===null||g===void 0||g.onInputChangedObservable.notifyObservers(T)},b.prototype._updateFirstDevices=function(E){switch(E){case n.bq.Keyboard:case n.bq.Mouse:this._firstDevice[E]=0;break;case n.bq.Touch:case n.bq.DualSense:case n.bq.DualShock:case n.bq.Xbox:case n.bq.Switch:case n.bq.Generic:delete this._firstDevice[E];var C=this._devices[E];if(C){for(var T=0;T<C.length;T++)if(C[T]){this._firstDevice[E]=T;break}}}},b}()},19966:(r,t,e)=>{var n=e(19133),i=e(7164),o=e(17347),a=e(23885),s=e(82673),l=e(1235);s.$.prototype._partialLoadFile=function(c,u,d,h,p){p===void 0&&(p=null),this._loadFile(c,function(m){d[u]=m,d._internalCount++,d._internalCount===6&&h(d)},void 0,void 0,!0,function(m,v){p&&m&&p(m.status+" "+m.statusText,v)})},s.$.prototype._cascadeLoadFiles=function(c,u,d,h){h===void 0&&(h=null);var p=[];p._internalCount=0;for(var m=0;m<6;m++)this._partialLoadFile(d[m],m,p,u,h)},s.$.prototype._cascadeLoadImgs=function(c,u,d,h,p,m){p===void 0&&(p=null);var v=[];v._internalCount=0;for(var b=0;b<6;b++)this._partialLoadImg(h[b],b,v,c,u,d,p,m)},s.$.prototype._partialLoadImg=function(c,u,d,h,p,m,v,b){v===void 0&&(v=null);var E=(0,a.z)();(0,o.W$)(c,function(C){d[u]=C,d._internalCount++,h&&h.removePendingData(E),d._internalCount===6&&m&&m(p,d)},function(C,T){h&&h.removePendingData(E),v&&v(C,T)},h?h.offlineProvider:null,b),h&&h.addPendingData(E)},s.$.prototype.createCubeTextureBase=function(c,u,d,h,p,m,v,b,E,C,T,f,g,S,y,x){var R=this;p===void 0&&(p=null),m===void 0&&(m=null),b===void 0&&(b=null),E===void 0&&(E=!1),C===void 0&&(C=0),T===void 0&&(T=0),f===void 0&&(f=null),g===void 0&&(g=null),S===void 0&&(S=null),y===void 0&&(y=!1),x===void 0&&(x=null);var I=f||new n.h(this,7);I.isCube=!0,I.url=c,I.generateMipMaps=!h,I._lodGenerationScale=C,I._lodGenerationOffset=T,I._useSRGBBuffer=!!y&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!h),I!==f&&(I.label=c.substring(0,60)),this._doNotHandleContextLost||(I._extension=b,I._files=d,I._buffer=x);var M=c;this._transformTextureUrl&&!f&&(c=this._transformTextureUrl(c));var D=c.split("?")[0],B=D.lastIndexOf("."),F=b||(B>-1?D.substring(B).toLowerCase():""),X=(0,l.gT)(F),$=function(Q,ie){c===M?m&&Q&&m(Q.status+" "+Q.statusText,ie):(i.V.Warn("Failed to load ".concat(c,", falling back to the ").concat(M)),R.createCubeTextureBase(M,u,d,!!h,p,m,v,b,E,C,T,I,g,S,y,x))};if(X)X.then(function(Q){var ie=function(q){g&&g(I,q),Q.loadCubeData(q,I,E,p,m)};x?ie(x):d&&d.length===6?Q.supportCascades?R._cascadeLoadFiles(u,function(q){return ie(q.map(function(ee){return new Uint8Array(ee)}))},d,m):m?m("Textures type does not support cascades."):i.V.Warn("Texture loader does not support cascades."):R._loadFile(c,function(q){return ie(new Uint8Array(q))},void 0,void 0,!0,$)});else{if(!d||d.length===0)throw new Error("Cannot load cubemap because files were not defined, or the correct loader was not found.");this._cascadeLoadImgs(u,I,function(Q,ie){S&&S(Q,ie)},d,m)}return this._internalTexturesCache.push(I),I}},20833:(r,t,e)=>{e(82673).$.prototype.createDepthStencilTexture=function(n,i,o){if(i.isCube){var a=n.width||n;return this._createDepthStencilCubeTexture(a,i)}return this._createDepthStencilTexture(n,i,o)}},71974:(r,t,e)=>{var n=e(78322),i=e(96352),o=e(19133),a=e(7164),s=e(81152),l=e(87074);i.w.prototype._createDepthStencilCubeTexture=function(c,u){var d=new o.h(this,12);if(d.isCube=!0,this.webGLVersion===1)return a.V.Error("Depth cube texture is not supported by WebGL 1."),d;var h=(0,n.Cl)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},u),p=this._gl;this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,d,!0),this._setupDepthStencilTexture(d,c,h.bilinearFiltering,h.comparisonFunction);for(var m=0;m<6;m++)h.generateStencil?p.texImage2D(p.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,p.DEPTH24_STENCIL8,c,c,0,p.DEPTH_STENCIL,p.UNSIGNED_INT_24_8,null):p.texImage2D(p.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,p.DEPTH_COMPONENT24,c,c,0,p.DEPTH_COMPONENT,p.UNSIGNED_INT,null);return this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(d),d},i.w.prototype._setCubeMapTextureParams=function(c,u,d){var h=this._gl;h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,u?h.LINEAR_MIPMAP_LINEAR:h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),c.samplingMode=u?s.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:s.Y.TEXTURE_LINEAR_LINEAR,u&&this.getCaps().textureMaxLevel&&d!==void 0&&d>0&&(h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAX_LEVEL,d),c._maxLodLevel=d),this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null)},i.w.prototype.createCubeTexture=function(c,u,d,h,p,m,v,b,E,C,T,f,g,S,y){var x=this;p===void 0&&(p=null),m===void 0&&(m=null),b===void 0&&(b=null),E===void 0&&(E=!1),C===void 0&&(C=0),T===void 0&&(T=0),f===void 0&&(f=null),S===void 0&&(S=!1),y===void 0&&(y=null);var R=this._gl;return this.createCubeTextureBase(c,u,d,!!h,p,m,v,b,E,C,T,f,function(I){return x._bindTextureDirectly(R.TEXTURE_CUBE_MAP,I,!0)},function(I,M){var D=x.needPOTTextures?(0,l.R)(M[0].width,x._caps.maxCubemapTextureSize):M[0].width,B=D,F=[R.TEXTURE_CUBE_MAP_POSITIVE_X,R.TEXTURE_CUBE_MAP_POSITIVE_Y,R.TEXTURE_CUBE_MAP_POSITIVE_Z,R.TEXTURE_CUBE_MAP_NEGATIVE_X,R.TEXTURE_CUBE_MAP_NEGATIVE_Y,R.TEXTURE_CUBE_MAP_NEGATIVE_Z];x._bindTextureDirectly(R.TEXTURE_CUBE_MAP,I,!0),x._unpackFlipY(!1);var X=v?x._getInternalFormat(v,I._useSRGBBuffer):I._useSRGBBuffer?x._glSRGBExtensionValues.SRGB8_ALPHA8:R.RGBA,$=v?x._getInternalFormat(v):R.RGBA;I._useSRGBBuffer&&x.webGLVersion===1&&($=X);for(var Q=0;Q<F.length;Q++)if(M[Q].width!==D||M[Q].height!==B){if(x._prepareWorkingCanvas(),!x._workingCanvas||!x._workingContext)return void a.V.Warn("Cannot create canvas to resize texture.");x._workingCanvas.width=D,x._workingCanvas.height=B,x._workingContext.drawImage(M[Q],0,0,M[Q].width,M[Q].height,0,0,D,B),R.texImage2D(F[Q],0,X,$,R.UNSIGNED_BYTE,x._workingCanvas)}else R.texImage2D(F[Q],0,X,$,R.UNSIGNED_BYTE,M[Q]);h||R.generateMipmap(R.TEXTURE_CUBE_MAP),x._setCubeMapTextureParams(I,!h),I.width=D,I.height=B,I.isReady=!0,v&&(I.format=v),I.onLoadedObservable.notifyObservers(I),I.onLoadedObservable.clear(),p&&p()},!!S,y)},i.w.prototype.generateMipMapsForCubemap=function(c,u){if(u===void 0&&(u=!0),c.generateMipMaps){var d=this._gl;this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,c,!0),d.generateMipmap(d.TEXTURE_CUBE_MAP),u&&this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null)}}},82345:(r,t,e)=>{e.d(t,{k:()=>o});var n=e(96352),i=e(81152);function o(a,s,l,c){switch(l===void 0&&(l=!1),a){case i.Y.TEXTURETYPE_BYTE:var u=new Int8Array(s);return c&&u.set(new Int8Array(c)),u;case i.Y.TEXTURETYPE_UNSIGNED_BYTE:var d=new Uint8Array(s);return c&&d.set(new Uint8Array(c)),d;case i.Y.TEXTURETYPE_SHORT:var h=s instanceof ArrayBuffer?new Int16Array(s):new Int16Array(l?s/2:s);return c&&h.set(new Int16Array(c)),h;case i.Y.TEXTURETYPE_UNSIGNED_SHORT:case i.Y.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:case i.Y.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:case i.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:case i.Y.TEXTURETYPE_HALF_FLOAT:var p=s instanceof ArrayBuffer?new Uint16Array(s):new Uint16Array(l?s/2:s);return c&&p.set(new Uint16Array(c)),p;case i.Y.TEXTURETYPE_INT:var m=s instanceof ArrayBuffer?new Int32Array(s):new Int32Array(l?s/4:s);return c&&m.set(new Int32Array(c)),m;case i.Y.TEXTURETYPE_UNSIGNED_INTEGER:case i.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:case i.Y.TEXTURETYPE_UNSIGNED_INT_24_8:case i.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:case i.Y.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:case i.Y.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:var v=s instanceof ArrayBuffer?new Uint32Array(s):new Uint32Array(l?s/4:s);return c&&v.set(new Uint32Array(c)),v;case i.Y.TEXTURETYPE_FLOAT:var b=s instanceof ArrayBuffer?new Float32Array(s):new Float32Array(l?s/4:s);return c&&b.set(new Float32Array(c)),b}var E=new Uint8Array(s);return c&&E.set(new Uint8Array(c)),E}n.w.prototype._readTexturePixelsSync=function(a,s,l,c,u,d,h,p,m,v){var b,E;c===void 0&&(c=-1),u===void 0&&(u=0),d===void 0&&(d=null),h===void 0&&(h=!0),p===void 0&&(p=!1),m===void 0&&(m=0),v===void 0&&(v=0);var C=this._gl;if(!C)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var T=C.createFramebuffer();if(!T)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=T}C.bindFramebuffer(C.FRAMEBUFFER,this._dummyFramebuffer),c>-1?C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+c,(b=a._hardwareTexture)===null||b===void 0?void 0:b.underlyingResource,u):C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,(E=a._hardwareTexture)===null||E===void 0?void 0:E.underlyingResource,u);var f=a.type!==void 0?this._getWebGLTextureType(a.type):C.UNSIGNED_BYTE;return p?d||(d=o(a.type,4*s*l)):f===C.UNSIGNED_BYTE?(d||(d=new Uint8Array(4*s*l)),f=C.UNSIGNED_BYTE):(d||(d=new Float32Array(4*s*l)),f=C.FLOAT),h&&this.flushFramebuffer(),C.readPixels(m,v,s,l,C.RGBA,f,d),C.bindFramebuffer(C.FRAMEBUFFER,this._currentFramebuffer),d},n.w.prototype._readTexturePixels=function(a,s,l,c,u,d,h,p,m,v){return c===void 0&&(c=-1),u===void 0&&(u=0),d===void 0&&(d=null),h===void 0&&(h=!0),p===void 0&&(p=!1),m===void 0&&(m=0),v===void 0&&(v=0),Promise.resolve(this._readTexturePixelsSync(a,s,l,c,u,d,h,p,m,v))}},71073:(r,t,e)=>{var n=e(78322),i=e(19133),o=e(7164),a=e(96352),s=e(81152),l=function(c){function u(d,h,p,m,v){var b=c.call(this,d,h,p,m)||this;return b._framebuffer=null,b._depthStencilBuffer=null,b._MSAAFramebuffer=null,b._colorTextureArray=null,b._depthStencilTextureArray=null,b._disposeOnlyFramebuffers=!1,b._currentLOD=0,b._context=v,b}return(0,n.C6)(u,c),u.prototype._cloneRenderTargetWrapper=function(){var d=null;return this._colorTextureArray&&this._depthStencilTextureArray?(d=this._engine.createMultiviewRenderTargetTexture(this.width,this.height)).texture.isReady=!0:d=c.prototype._cloneRenderTargetWrapper.call(this),d},u.prototype._swapRenderTargetWrapper=function(d){c.prototype._swapRenderTargetWrapper.call(this,d),d._framebuffer=this._framebuffer,d._depthStencilBuffer=this._depthStencilBuffer,d._MSAAFramebuffer=this._MSAAFramebuffer,d._colorTextureArray=this._colorTextureArray,d._depthStencilTextureArray=this._depthStencilTextureArray,this._framebuffer=this._depthStencilBuffer=this._MSAAFramebuffer=this._colorTextureArray=this._depthStencilTextureArray=null},u.prototype.createDepthStencilTexture=function(d,h,p,m,v,b){if(d===void 0&&(d=0),h===void 0&&(h=!0),p===void 0&&(p=!1),m===void 0&&(m=1),v===void 0&&(v=s.Y.TEXTUREFORMAT_DEPTH32_FLOAT),this._depthStencilBuffer){var E=this._engine,C=E._currentFramebuffer,T=this._context;E._bindUnboundFramebuffer(this._framebuffer),T.framebufferRenderbuffer(T.FRAMEBUFFER,T.DEPTH_STENCIL_ATTACHMENT,T.RENDERBUFFER,null),T.framebufferRenderbuffer(T.FRAMEBUFFER,T.DEPTH_ATTACHMENT,T.RENDERBUFFER,null),T.framebufferRenderbuffer(T.FRAMEBUFFER,T.STENCIL_ATTACHMENT,T.RENDERBUFFER,null),E._bindUnboundFramebuffer(C),T.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return c.prototype.createDepthStencilTexture.call(this,d,h,p,m,v,b)},u.prototype.shareDepth=function(d){c.prototype.shareDepth.call(this,d);var h=this._context,p=this._depthStencilBuffer,m=d._MSAAFramebuffer||d._framebuffer,v=this._engine;d._depthStencilBuffer&&d._depthStencilBuffer!==p&&h.deleteRenderbuffer(d._depthStencilBuffer),d._depthStencilBuffer=p;var b=d._generateStencilBuffer?h.DEPTH_STENCIL_ATTACHMENT:h.DEPTH_ATTACHMENT;v._bindUnboundFramebuffer(m),h.framebufferRenderbuffer(h.FRAMEBUFFER,b,h.RENDERBUFFER,p),v._bindUnboundFramebuffer(null)},u.prototype._bindTextureRenderTarget=function(d,h,p,m){var v,b,E,C;if(h===void 0&&(h=0),m===void 0&&(m=0),d._hardwareTexture){var T=this._framebuffer,f=this._engine,g=f._currentFramebuffer;if(f._bindUnboundFramebuffer(T),f.webGLVersion>1){var S=(y=this._context)["COLOR_ATTACHMENT"+h];d.is2DArray||d.is3D?(p=(b=p??((v=this.layerIndices)===null||v===void 0?void 0:v[h]))!==null&&b!==void 0?b:0,y.framebufferTextureLayer(y.FRAMEBUFFER,S,d._hardwareTexture.underlyingResource,m,p)):d.isCube?(p=(C=p??((E=this.faceIndices)===null||E===void 0?void 0:E[h]))!==null&&C!==void 0?C:0,y.framebufferTexture2D(y.FRAMEBUFFER,S,y.TEXTURE_CUBE_MAP_POSITIVE_X+p,d._hardwareTexture.underlyingResource,m)):y.framebufferTexture2D(y.FRAMEBUFFER,S,y.TEXTURE_2D,d._hardwareTexture.underlyingResource,m)}else{S=(y=this._context)["COLOR_ATTACHMENT"+h+"_WEBGL"];var y,x=p!==void 0?y.TEXTURE_CUBE_MAP_POSITIVE_X+p:y.TEXTURE_2D;y.framebufferTexture2D(y.FRAMEBUFFER,S,x,d._hardwareTexture.underlyingResource,m)}f._bindUnboundFramebuffer(g)}},u.prototype.setTexture=function(d,h,p){h===void 0&&(h=0),p===void 0&&(p=!0),c.prototype.setTexture.call(this,d,h,p),this._bindTextureRenderTarget(d,h)},u.prototype.setLayerAndFaceIndices=function(d,h){var p,m;if(c.prototype.setLayerAndFaceIndices.call(this,d,h),this.textures&&this.layerIndices&&this.faceIndices)for(var v=(m=(p=this._attachments)===null||p===void 0?void 0:p.length)!==null&&m!==void 0?m:this.textures.length,b=0;b<v;b++){var E=this.textures[b];E&&(E.is2DArray||E.is3D?this._bindTextureRenderTarget(E,b,this.layerIndices[b]):E.isCube?this._bindTextureRenderTarget(E,b,this.faceIndices[b]):this._bindTextureRenderTarget(E,b))}},u.prototype.setLayerAndFaceIndex=function(d,h,p){if(d===void 0&&(d=0),c.prototype.setLayerAndFaceIndex.call(this,d,h,p),this.textures&&this.layerIndices&&this.faceIndices){var m=this.textures[d];m.is2DArray||m.is3D?this._bindTextureRenderTarget(this.textures[d],d,this.layerIndices[d]):m.isCube&&this._bindTextureRenderTarget(this.textures[d],d,this.faceIndices[d])}},u.prototype.dispose=function(d){d===void 0&&(d=this._disposeOnlyFramebuffers);var h=this._context;d||(this._colorTextureArray&&(this._context.deleteTexture(this._colorTextureArray),this._colorTextureArray=null),this._depthStencilTextureArray&&(this._context.deleteTexture(this._depthStencilTextureArray),this._depthStencilTextureArray=null)),this._framebuffer&&(h.deleteFramebuffer(this._framebuffer),this._framebuffer=null),this._depthStencilBuffer&&(h.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null),this._MSAAFramebuffer&&(h.deleteFramebuffer(this._MSAAFramebuffer),this._MSAAFramebuffer=null),c.prototype.dispose.call(this,d)},u}(e(96925).v);e(20833),a.w.prototype._createHardwareRenderTargetWrapper=function(c,u,d){var h=new l(c,u,d,this,this._gl);return this._renderTargetWrapperCache.push(h),h},a.w.prototype.createRenderTargetTexture=function(c,u){var d,h,p=this._createHardwareRenderTargetWrapper(!1,!1,c),m=!0,v=!1,b=!1,E=void 0,C=1,T=void 0;u!==void 0&&typeof u=="object"&&(m=(d=u.generateDepthBuffer)===null||d===void 0||d,v=!!u.generateStencilBuffer,b=!!u.noColorAttachment,E=u.colorAttachment,C=(h=u.samples)!==null&&h!==void 0?h:1,T=u.label);var f=E||(b?null:this._createInternalTexture(c,u,!0,5)),g=c.width||c,S=c.height||c,y=this._currentFramebuffer,x=this._gl,R=x.createFramebuffer();return this._bindUnboundFramebuffer(R),p._depthStencilBuffer=this._setupFramebufferDepthAttachments(v,m,g,S),!f||f.is2DArray||f.is3D||x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,f._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(y),p.label=T??"RenderTargetWrapper",p._framebuffer=R,p._generateDepthBuffer=m,p._generateStencilBuffer=v,p.setTextures(f),this.updateRenderTargetTextureSampleCount(p,C),p},a.w.prototype._createDepthStencilTexture=function(c,u,d){var h,p=this._gl,m=c.layers||0,v=c.depth||0,b=p.TEXTURE_2D;m!==0?b=p.TEXTURE_2D_ARRAY:v!==0&&(b=p.TEXTURE_3D);var E=new i.h(this,12);if(E.label=u.label,!this._caps.depthTextureExtension)return o.V.Error("Depth texture is not supported by your browser or hardware."),E;var C=(0,n.Cl)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},u);if(this._bindTextureDirectly(b,E,!0),this._setupDepthStencilTexture(E,c,C.comparisonFunction!==0&&C.bilinearFiltering,C.comparisonFunction,C.samples),C.depthTextureFormat!==void 0){if(C.depthTextureFormat!==s.Y.TEXTUREFORMAT_DEPTH16&&C.depthTextureFormat!==s.Y.TEXTUREFORMAT_DEPTH24&&C.depthTextureFormat!==s.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8&&C.depthTextureFormat!==s.Y.TEXTUREFORMAT_DEPTH24_STENCIL8&&C.depthTextureFormat!==s.Y.TEXTUREFORMAT_DEPTH32_FLOAT&&C.depthTextureFormat!==s.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8)return o.V.Error("Depth texture ".concat(C.depthTextureFormat," format is not supported.")),E;E.format=C.depthTextureFormat}else E.format=C.generateStencil?s.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:s.Y.TEXTUREFORMAT_DEPTH24;var T=E.format===s.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||E.format===s.Y.TEXTUREFORMAT_DEPTH24_STENCIL8||E.format===s.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8,f=p.UNSIGNED_INT;E.format===s.Y.TEXTUREFORMAT_DEPTH16?f=p.UNSIGNED_SHORT:E.format===s.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||E.format===s.Y.TEXTUREFORMAT_DEPTH24_STENCIL8?f=p.UNSIGNED_INT_24_8:E.format===s.Y.TEXTUREFORMAT_DEPTH32_FLOAT?f=p.FLOAT:E.format===s.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8&&(f=p.FLOAT_32_UNSIGNED_INT_24_8_REV);var g=T?p.DEPTH_STENCIL:p.DEPTH_COMPONENT,S=this._getInternalFormatFromDepthTextureFormat(E.format,!0,T);return E.is2DArray?p.texImage3D(b,0,S,E.width,E.height,m,0,g,f,null):E.is3D?p.texImage3D(b,0,S,E.width,E.height,v,0,g,f,null):p.texImage2D(b,0,S,E.width,E.height,0,g,f,null),this._bindTextureDirectly(b,null),this._internalTexturesCache.push(E),d._depthStencilBuffer&&(p.deleteRenderbuffer(d._depthStencilBuffer),d._depthStencilBuffer=null),this._bindUnboundFramebuffer((h=d._MSAAFramebuffer)!==null&&h!==void 0?h:d._framebuffer),d._generateStencilBuffer=T,d._depthStencilTextureWithStencil=T,d._depthStencilBuffer=this._setupFramebufferDepthAttachments(d._generateStencilBuffer,d._generateDepthBuffer,d.width,d.height,d.samples,E.format),this._bindUnboundFramebuffer(null),E},a.w.prototype.updateRenderTargetTextureSampleCount=function(c,u){var d,h;if(this.webGLVersion<2||!c)return 1;if(c.samples===u)return u;var p=this._gl;u=Math.min(u,this.getCaps().maxMSAASamples),c._depthStencilBuffer&&(p.deleteRenderbuffer(c._depthStencilBuffer),c._depthStencilBuffer=null),c._MSAAFramebuffer&&(p.deleteFramebuffer(c._MSAAFramebuffer),c._MSAAFramebuffer=null);var m=(d=c.texture)===null||d===void 0?void 0:d._hardwareTexture;m?.releaseMSAARenderBuffers();var v=p.createFramebuffer();if(!v)throw new Error("Unable to create multi sampled framebuffer");if(c._MSAAFramebuffer=v,c.texture&&u>1&&typeof p.renderbufferStorageMultisample=="function"){this._bindUnboundFramebuffer(c._MSAAFramebuffer);var b=this._createRenderBuffer(c.texture.width,c.texture.height,u,-1,this._getRGBABufferInternalSizedFormat(c.texture.type,c.texture.format,c.texture._useSRGBBuffer),p.COLOR_ATTACHMENT0,!1);if(!b)throw new Error("Unable to create multi sampled framebuffer");m?.addMSAARenderBuffer(b)}this._bindUnboundFramebuffer((h=c._MSAAFramebuffer)!==null&&h!==void 0?h:c._framebuffer),c.texture&&(c.texture.samples=u),c._samples=u;var E=c._depthStencilTexture?c._depthStencilTexture.format:void 0;return c._depthStencilBuffer=this._setupFramebufferDepthAttachments(c._generateStencilBuffer,c._generateDepthBuffer,c.width,c.height,u,E),this._bindUnboundFramebuffer(null),u},a.w.prototype._setupDepthStencilTexture=function(c,u,d,h,p){p===void 0&&(p=1);var m=u.width||u,v=u.height||u,b=u.layers||0,E=u.depth||0;c.baseWidth=m,c.baseHeight=v,c.width=m,c.height=v,c.is2DArray=b>0,c.depth=b||E,c.isReady=!0,c.samples=p,c.generateMipMaps=!1,c.samplingMode=d?s.Y.TEXTURE_BILINEAR_SAMPLINGMODE:s.Y.TEXTURE_NEAREST_SAMPLINGMODE,c.type=s.Y.TEXTURETYPE_UNSIGNED_INT,c._comparisonFunction=h;var C=this._gl,T=this._getTextureTarget(c),f=this._getSamplingParameters(c.samplingMode,!1);C.texParameteri(T,C.TEXTURE_MAG_FILTER,f.mag),C.texParameteri(T,C.TEXTURE_MIN_FILTER,f.min),C.texParameteri(T,C.TEXTURE_WRAP_S,C.CLAMP_TO_EDGE),C.texParameteri(T,C.TEXTURE_WRAP_T,C.CLAMP_TO_EDGE),this.webGLVersion>1&&(h===0?(C.texParameteri(T,C.TEXTURE_COMPARE_FUNC,s.Y.LEQUAL),C.texParameteri(T,C.TEXTURE_COMPARE_MODE,C.NONE)):(C.texParameteri(T,C.TEXTURE_COMPARE_FUNC,h),C.texParameteri(T,C.TEXTURE_COMPARE_MODE,C.COMPARE_REF_TO_TEXTURE)))}},8864:(r,t,e)=>{var n=e(78322),i=e(19133),o=e(7164),a=e(81152);e(96352).w.prototype.createRenderTargetCubeTexture=function(s,l){var c=this._createHardwareRenderTargetWrapper(!1,!0,s),u=(0,n.Cl)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:a.Y.TEXTURETYPE_UNSIGNED_INT,samplingMode:a.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,format:a.Y.TEXTUREFORMAT_RGBA},l);u.generateStencilBuffer=u.generateDepthBuffer&&u.generateStencilBuffer,(u.type!==a.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(u.type!==a.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(u.samplingMode=a.Y.TEXTURE_NEAREST_SAMPLINGMODE);var d=this._gl,h=new i.h(this,5);this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,h,!0);var p=this._getSamplingParameters(u.samplingMode,u.generateMipMaps);u.type!==a.Y.TEXTURETYPE_FLOAT||this._caps.textureFloat||(u.type=a.Y.TEXTURETYPE_UNSIGNED_INT,o.V.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,p.mag),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,p.min),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);for(var m=0;m<6;m++)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,this._getRGBABufferInternalSizedFormat(u.type,u.format),s,s,0,this._getInternalFormat(u.format),this._getWebGLTextureType(u.type),null);var v=d.createFramebuffer();return this._bindUnboundFramebuffer(v),c._depthStencilBuffer=this._setupFramebufferDepthAttachments(u.generateStencilBuffer,u.generateDepthBuffer,s,s),u.generateMipMaps&&d.generateMipmap(d.TEXTURE_CUBE_MAP),this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),c._framebuffer=v,c._generateDepthBuffer=u.generateDepthBuffer,c._generateStencilBuffer=u.generateStencilBuffer,h.width=s,h.height=s,h.isReady=!0,h.isCube=!0,h.samples=1,h.generateMipMaps=u.generateMipMaps,h.samplingMode=u.samplingMode,h.type=u.type,h.format=u.format,this._internalTexturesCache.push(h),c.setTextures(h),c}},64838:(r,t,e)=>{e(96352).w.prototype.setDepthStencilTexture=function(n,i,o,a){n!==void 0&&(i&&(this._boundUniforms[n]=i),o&&o.depthStencilTexture?this._setTexture(n,o,!1,!0,a):this._setTexture(n,null,void 0,void 0,a))}},59012:(r,t,e)=>{var n=e(96352),i=e(26218);n.w.prototype.createUniformBuffer=function(o,a){var s=this._gl.createBuffer();if(!s)throw new Error("Unable to create uniform buffer");var l=new i.A(s);return this.bindUniformBuffer(l),o instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,o,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(o),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),l.references=1,l},n.w.prototype.createDynamicUniformBuffer=function(o,a){var s=this._gl.createBuffer();if(!s)throw new Error("Unable to create dynamic uniform buffer");var l=new i.A(s);return this.bindUniformBuffer(l),o instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,o,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(o),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),l.references=1,l},n.w.prototype.updateUniformBuffer=function(o,a,s,l){this.bindUniformBuffer(o),s===void 0&&(s=0),l===void 0?a instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,s,a):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,s,new Float32Array(a)):a instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,a.subarray(s,s+l)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(a).subarray(s,s+l)),this.bindUniformBuffer(null)},n.w.prototype.bindUniformBuffer=function(o){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,o?o.underlyingResource:null)},n.w.prototype.bindUniformBufferBase=function(o,a,s){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,a,o?o.underlyingResource:null)},n.w.prototype.bindUniformBlock=function(o,a,s){var l=o.program,c=this._gl.getUniformBlockIndex(l,a);c!==4294967295&&this._gl.uniformBlockBinding(l,c,s)}},35930:(r,t,e)=>{e.d(t,{nO:()=>I,pB:()=>y,jC:()=>R,M0:()=>x,Iq:()=>Q,J:()=>ie});var n=function(){function q(){this.children=[]}return q.prototype.isValid=function(ee){return!0},q.prototype.process=function(ee,te){var ce,fe,de,Te,ue,U,N,w="";if(this.line){var k=this.line,J=te.processor;if(J){J.lineProcessor&&(k=J.lineProcessor(k,te.isFragment,te.processingContext));var le=(fe=(ce=te.processor)===null||ce===void 0?void 0:ce.attributeKeywordName)!==null&&fe!==void 0?fe:"attribute",be=te.isFragment&&(!((de=te.processor)===null||de===void 0)&&de.varyingFragmentKeywordName)?(Te=te.processor)===null||Te===void 0?void 0:Te.varyingFragmentKeywordName:!te.isFragment&&(!((ue=te.processor)===null||ue===void 0)&&ue.varyingVertexKeywordName)?(U=te.processor)===null||U===void 0?void 0:U.varyingVertexKeywordName:"varying";!te.isFragment&&J.attributeProcessor&&this.line.startsWith(le)?k=J.attributeProcessor(this.line,ee,te.processingContext):J.varyingProcessor&&(!((N=J.varyingCheck)===null||N===void 0)&&N.call(J,this.line,te.isFragment)||!J.varyingCheck&&this.line.startsWith(be))?k=J.varyingProcessor(this.line,te.isFragment,ee,te.processingContext):J.uniformProcessor&&J.uniformRegexp&&J.uniformRegexp.test(this.line)?te.lookForClosingBracketForUniformBuffer||(k=J.uniformProcessor(this.line,te.isFragment,ee,te.processingContext)):J.uniformBufferProcessor&&J.uniformBufferRegexp&&J.uniformBufferRegexp.test(this.line)?te.lookForClosingBracketForUniformBuffer||(k=J.uniformBufferProcessor(this.line,te.isFragment,te.processingContext),te.lookForClosingBracketForUniformBuffer=!0):J.textureProcessor&&J.textureRegexp&&J.textureRegexp.test(this.line)?k=J.textureProcessor(this.line,te.isFragment,ee,te.processingContext):(J.uniformProcessor||J.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!te.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?J.uniformProcessor&&(k=J.uniformProcessor(this.line,te.isFragment,ee,te.processingContext)):J.uniformBufferProcessor&&(k=J.uniformBufferProcessor(this.line,te.isFragment,te.processingContext),te.lookForClosingBracketForUniformBuffer=!0)),te.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(te.lookForClosingBracketForUniformBuffer=!1,J.endOfUniformBufferProcessor&&(k=J.endOfUniformBufferProcessor(this.line,te.isFragment,te.processingContext)))}w+=k+`
|
||
`}return this.children.forEach(function(ve){w+=ve.process(ee,te)}),this.additionalDefineKey&&(ee[this.additionalDefineKey]=this.additionalDefineValue||"true"),w},q}(),i=function(){function q(){this._lines=[]}return Object.defineProperty(q.prototype,"currentLine",{get:function(){return this._lines[this.lineIndex]},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"canRead",{get:function(){return this.lineIndex<this._lines.length-1},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"lines",{set:function(ee){this._lines.length=0;for(var te=0,ce=ee;te<ce.length;te++){var fe=ce[te];if(fe&&fe!=="\r")if(fe[0]!=="#"){var de=fe.trim();if(de)if(de.startsWith("//"))this._lines.push(fe);else{var Te=de.indexOf(";");if(Te===-1)this._lines.push(de);else if(Te===de.length-1)de.length>1&&this._lines.push(de);else for(var ue=fe.split(";"),U=0;U<ue.length;U++){var N=ue[U];N&&(N=N.trim())&&this._lines.push(N+(U!==ue.length-1?";":""))}}}else this._lines.push(fe)}},enumerable:!1,configurable:!0}),q}(),o=e(78322),a=function(q){function ee(){return q!==null&&q.apply(this,arguments)||this}return(0,o.C6)(ee,q),ee.prototype.process=function(te,ce){for(var fe=0;fe<this.children.length;fe++){var de=this.children[fe];if(de.isValid(te))return de.process(te,ce)}return""},ee}(n),s=function(q){function ee(){return q!==null&&q.apply(this,arguments)||this}return(0,o.C6)(ee,q),ee.prototype.isValid=function(te){return this.testExpression.isTrue(te)},ee}(n),l=function(){function q(){}return q.prototype.isTrue=function(ee){return!0},q.postfixToInfix=function(ee){for(var te=[],ce=0,fe=ee;ce<fe.length;ce++){var de=fe[ce];if(q._OperatorPriority[de]===void 0)te.push(de);else{var Te=te[te.length-1],ue=te[te.length-2];te.length-=2,te.push("(".concat(ue).concat(de).concat(Te,")"))}}return te[te.length-1]},q.infixToPostfix=function(ee){var te=q._InfixToPostfixCache.get(ee);if(te)return te.accessTime=Date.now(),te.result;if(!(ee.includes("&&")||ee.includes("||")||ee.includes(")")||ee.includes("(")))return[ee];for(var ce=[],fe=-1,de=function(){(w=w.trim())!==""&&(ce.push(w),w="")},Te=function(le){fe<q._Stack.length-1&&(q._Stack[++fe]=le)},ue=function(){return q._Stack[fe]},U=function(){return fe===-1?"!!INVALID EXPRESSION!!":q._Stack[fe--]},N=0,w="";N<ee.length;){var k=ee.charAt(N),J=N<ee.length-1?ee.substring(N,2+N):"";if(k==="(")w="",Te(k);else if(k===")"){for(de();fe!==-1&&ue()!=="(";)ce.push(U());U()}else if(q._OperatorPriority[J]>1){for(de();fe!==-1&&q._OperatorPriority[ue()]>=q._OperatorPriority[J];)ce.push(U());Te(J),N++}else w+=k;N++}for(de();fe!==-1;)ue()==="("?U():ce.push(U());return q._InfixToPostfixCache.size>=q.InfixToPostfixCacheLimitSize&&q.ClearCache(),q._InfixToPostfixCache.set(ee,{result:ce,accessTime:Date.now()}),ce},q.ClearCache=function(){for(var ee=Array.from(q._InfixToPostfixCache.entries()).sort(function(ce,fe){return ce[1].accessTime-fe[1].accessTime}),te=0;te<q.InfixToPostfixCacheCleanupSize;te++)q._InfixToPostfixCache.delete(ee[te][0])},q.InfixToPostfixCacheLimitSize=5e4,q.InfixToPostfixCacheCleanupSize=25e3,q._InfixToPostfixCache=new Map,q._OperatorPriority={")":0,"(":1,"||":2,"&&":3},q._Stack=["","","","","","","","","","","","","","","","","","","",""],q}(),c=function(q){function ee(te,ce){ce===void 0&&(ce=!1);var fe=q.call(this)||this;return fe.define=te,fe.not=ce,fe}return(0,o.C6)(ee,q),ee.prototype.isTrue=function(te){var ce=te[this.define]!==void 0;return this.not&&(ce=!ce),ce},ee}(l),u=function(q){function ee(){return q!==null&&q.apply(this,arguments)||this}return(0,o.C6)(ee,q),ee.prototype.isTrue=function(te){return this.leftOperand.isTrue(te)||this.rightOperand.isTrue(te)},ee}(l),d=function(q){function ee(){return q!==null&&q.apply(this,arguments)||this}return(0,o.C6)(ee,q),ee.prototype.isTrue=function(te){return this.leftOperand.isTrue(te)&&this.rightOperand.isTrue(te)},ee}(l),h=function(q){function ee(te,ce,fe){var de=q.call(this)||this;return de.define=te,de.operand=ce,de.testValue=fe,de}return(0,o.C6)(ee,q),ee.prototype.isTrue=function(te){var ce=te[this.define];ce===void 0&&(ce=this.define);var fe=!1,de=parseInt(ce),Te=parseInt(this.testValue);switch(this.operand){case">":fe=de>Te;break;case"<":fe=de<Te;break;case"<=":fe=de<=Te;break;case">=":fe=de>=Te;break;case"==":fe=de===Te;break;case"!=":fe=de!==Te}return fe},ee}(l),p=e(41190),m=e(24894),v=/defined\s*?\((.+?)\)/g,b=/defined\s*?\[(.+?)\]/g,E=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,C=/__decl__/,T=/light\{X\}.(\w*)/g,f=/\{X\}/g,g=[],S=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function y(q){q.processor&&q.processor.initializeShaders&&q.processor.initializeShaders(q.processingContext)}function x(q,ee,te,ce){var fe;!((fe=ee.processor)===null||fe===void 0)&&fe.preProcessShaderCode&&(q=ee.processor.preProcessShaderCode(q,ee.isFragment)),Q(q,ee,function(de){ee.processCodeAfterIncludes&&(de=ee.processCodeAfterIncludes(ee.isFragment?"fragment":"vertex",de,ee.defines));var Te=function(ue,U,N){var w=function(le,be){var ve;if(!((ve=be.processor)===null||ve===void 0)&&ve.noPrecision)return le;var ye=be.shouldUseHighPrecisionShader;return le.indexOf("precision highp float")===-1?le=ye?`precision highp float;
|
||
`+le:`precision mediump float;
|
||
`+le:ye||(le=le.replace("precision highp float","precision mediump float")),le}(ue,U);if(!U.processor||U.processor.shaderLanguage===0&&w.indexOf("#version 3")!==-1&&(w=w.replace("#version 300 es",""),!U.processor.parseGLES3))return w;var k=U.defines,J=$(U,N);return U.processor.preProcessor&&(w=U.processor.preProcessor(w,k,J,U.isFragment,U.processingContext)),w=X(w,J,U),U.processor.postProcessor&&(w=U.processor.postProcessor(w,k,U.isFragment,U.processingContext,N?{drawBuffersExtensionDisabled:!N.getCaps().drawBuffersExtension}:{})),N?._features.needShaderCodeInlining&&(w=N.inlineShaderCode(w)),w}(de,ee,ce);te(Te,de)})}function R(q,ee,te,ce){var fe;!((fe=ee.processor)===null||fe===void 0)&&fe.preProcessShaderCode&&(q=ee.processor.preProcessShaderCode(q,ee.isFragment)),Q(q,ee,function(de){ee.processCodeAfterIncludes&&(de=ee.processCodeAfterIncludes(ee.isFragment?"fragment":"vertex",de,ee.defines));var Te=function(ue,U,N){var w,k,J=ue,le=U.defines,be=$(U,N);return!((w=U.processor)===null||w===void 0)&&w.preProcessor&&(J=U.processor.preProcessor(J,le,be,U.isFragment,U.processingContext)),J=X(J,be,U),!((k=U.processor)===null||k===void 0)&&k.postProcessor&&(J=U.processor.postProcessor(J,le,U.isFragment,U.processingContext,N?{drawBuffersExtensionDisabled:!N.getCaps().drawBuffersExtension}:{})),N._features.needShaderCodeInlining&&(J=N.inlineShaderCode(J)),J}(de,ee,ce);te(Te,de)})}function I(q,ee,te){return te.processor&&te.processor.finalizeShaders?te.processor.finalizeShaders(q,ee,te.processingContext):{vertexCode:q,fragmentCode:ee}}function M(q){var ee=/defined\((.+)\)/.exec(q);if(ee&&ee.length)return new c(ee[1].trim(),q[0]==="!");for(var te="",ce=0,fe=0,de=["==","!=",">=","<=","<",">"];fe<de.length&&(te=de[fe],!((ce=q.indexOf(te))>-1));fe++);if(ce===-1)return new c(q);var Te=q.substring(0,ce).trim(),ue=q.substring(ce+te.length).trim();return new h(Te,te,ue)}function D(q,ee){var te=new s,ce=q.substring(0,ee),fe=q.substring(ee);return fe=fe.substring(0,(fe.indexOf("//")+1||fe.length+1)-1).trim(),te.testExpression=ce==="#ifdef"?new c(fe):ce==="#ifndef"?new c(fe,!0):function(de){de=de.replace(v,"defined[$1]");for(var Te=[],ue=0,U=l.infixToPostfix(de);ue<U.length;ue++){var N=U[ue];if(N!=="||"&&N!=="&&")Te.push(N);else if(Te.length>=2){var w=Te[Te.length-1],k=Te[Te.length-2];Te.length-=2;var J=N=="&&"?new d:new u;typeof w=="string"&&(w=w.replace(b,"defined($1)")),typeof k=="string"&&(k=k.replace(b,"defined($1)")),J.leftOperand=typeof k=="string"?M(k):k,J.rightOperand=typeof w=="string"?M(w):w,Te.push(J)}}var le=Te[Te.length-1];return typeof le=="string"&&(le=le.replace(b,"defined($1)")),typeof le=="string"?M(le):le}(fe),te}function B(q,ee,te){for(var ce=q.currentLine;F(q,te);){var fe=(ce=q.currentLine).substring(0,5).toLowerCase();if(fe==="#else"){var de=new n;return ee.children.push(de),void F(q,de)}if(fe==="#elif"){var Te=D(ce,5);ee.children.push(Te),te=Te}}}function F(q,ee){for(;q.canRead;){q.lineIndex++;var te=q.currentLine;if(te.indexOf("#")>=0){var ce=S.exec(te);if(ce&&ce.length){switch(ce[0]){case"#ifdef":var fe=new a;ee.children.push(fe);var de=D(te,6);fe.children.push(de),B(q,fe,de);break;case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":fe=new a,ee.children.push(fe),de=D(te,7),fe.children.push(de),B(q,fe,de);break;case"#if":fe=new a,de=D(te,3),ee.children.push(fe),fe.children.push(de),B(q,fe,de)}continue}}var Te=new n;if(Te.line=te,ee.children.push(Te),te[0]==="#"&&te[1]==="d"){var ue=te.replace(";","").split(" ");Te.additionalDefineKey=ue[1],ue.length===3&&(Te.additionalDefineValue=ue[2])}}return!1}function X(q,ee,te){var ce=new n,fe=new i;return fe.lineIndex=-1,fe.lines=q.split(`
|
||
`),F(fe,ce),ce.process(ee,te)}function $(q,ee){for(var te,ce={},fe=0,de=q.defines;fe<de.length;fe++){var Te=de[fe].replace("#define","").replace(";","").trim().split(" ");ce[Te[0]]=Te.length>1?Te[1]:""}return((te=q.processor)===null||te===void 0?void 0:te.shaderLanguage)===0&&(ce.GL_ES="true"),ce.__VERSION__=q.version,ce[q.platformName]="true",(0,m.xt)(ce,ee?.isNDCHalfZRange,ee?.useReverseDepthBuffer,ee?.useExactSrgbConversions),ce}function Q(q,ee,te){var ce;for(g.length=0;(ce=E.exec(q))!==null;)g.push(ce);for(var fe=String(q),de=[q],Te=!1,ue=function(k){var J=k[1];if(J.indexOf("__decl__")!==-1&&(J=J.replace(C,""),ee.supportsUniformBuffers&&(J=J.replace("Vertex","Ubo").replace("Fragment","Ubo")),J+="Declaration"),!ee.includesShadersStore[J]){var le=ee.shadersRepository+"ShadersInclude/"+J+".fx";return ie.loadFile(le,function(Ot){ee.includesShadersStore[J]=Ot,Q(de.join(""),ee,te)}),{value:void 0}}var be=ee.includesShadersStore[J];if(k[2])for(var ve=k[3].split(","),ye=0;ye<ve.length;ye+=2){var Me=new RegExp(ve[ye],"g"),we=ve[ye+1];be=be.replace(Me,we)}if(k[4]){var He=k[5];if(He.indexOf("..")!==-1){var Ke=He.split(".."),Qe=parseInt(Ke[0]),Je=parseInt(Ke[1]),ht=be.slice(0);be="",isNaN(Je)&&(Je=ee.indexParameters[Ke[1]]);for(var mt=Qe;mt<Je;mt++)ee.supportsUniformBuffers||(ht=ht.replace(T,function(Ot,Et){return Et+"{X}"})),be+=ht.replace(f,mt.toString())+`
|
||
`}else ee.supportsUniformBuffers||(be=be.replace(T,function(Ot,Et){return Et+"{X}"})),be=be.replace(f,He)}for(var yt=[],zt=0,$t=de;zt<$t.length;zt++){var St=$t[zt].split(k[0]);for(mt=0;mt<St.length-1;mt++)yt.push(St[mt]),yt.push(be);yt.push(St[St.length-1])}de=yt,Te=Te||be.indexOf("#include<")>=0||be.indexOf("#include <")>=0},U=0,N=g;U<N.length;U++){var w=ue(N[U]);if(typeof w=="object")return w.value}g.length=0,fe=de.join(""),Te?Q(fe.toString(),ee,te):te(fe)}var ie={loadFile:function(q,ee,te,ce,fe,de){throw(0,p.n)("FileTools")}}},24054:(r,t,e)=>{e.d(t,{B:()=>i});var n=/(flat\s)?\s*varying\s*.*/,i=function(){function o(){this.shaderLanguage=0}return o.prototype.attributeProcessor=function(a){return a.replace("attribute","in")},o.prototype.varyingCheck=function(a,s){return n.test(a)},o.prototype.varyingProcessor=function(a,s){return a.replace("varying",s?"in":"out")},o.prototype.postProcessor=function(a,s,l){var c=a.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1;if(a=(a=a.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"")).replace(/texture2D\s*\(/g,"texture("),l){var u=a.search(/layout *\(location *= *0\) *out/g)!==-1;a=(a=(a=(a=(a=(a=(a=a.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(c||u?"":`layout(location = 0) out vec4 glFragColor;
|
||
`)+"void main(")}else if(s.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require
|
||
layout (num_views = 2) in;
|
||
`+a;return a},o}()},90519:(r,t,e)=>{e.d(t,{d:()=>n});var n=function(){function i(o,a){if(o===void 0&&(o=null),this._MSAARenderBuffers=null,this._context=a,!o&&!(o=a.createTexture()))throw new Error("Unable to create webGL texture");this.set(o)}return Object.defineProperty(i.prototype,"underlyingResource",{get:function(){return this._webGLTexture},enumerable:!1,configurable:!0}),i.prototype.setUsage=function(){},i.prototype.set=function(o){this._webGLTexture=o},i.prototype.reset=function(){this._webGLTexture=null,this._MSAARenderBuffers=null},i.prototype.addMSAARenderBuffer=function(o){this._MSAARenderBuffers||(this._MSAARenderBuffers=[]),this._MSAARenderBuffers.push(o)},i.prototype.releaseMSAARenderBuffers=function(){if(this._MSAARenderBuffers){for(var o=0,a=this._MSAARenderBuffers;o<a.length;o++){var s=a[o];this._context.deleteRenderbuffer(s)}this._MSAARenderBuffers=null}},i.prototype.getMSAARenderBuffer=function(o){var a,s;return o===void 0&&(o=0),(s=(a=this._MSAARenderBuffers)===null||a===void 0?void 0:a[o])!==null&&s!==void 0?s:null},i.prototype.release=function(){this.releaseMSAARenderBuffers(),this._webGLTexture&&this._context.deleteTexture(this._webGLTexture),this.reset()},i}()},14737:(r,t,e)=>{e.d(t,{x:()=>n});var n=function(){function i(){this._valueCache={},this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null,this._isDisposed=!1}return Object.defineProperty(i.prototype,"isAsync",{get:function(){return this.isParallelCompiled},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isReady",{get:function(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))},enumerable:!1,configurable:!0}),i.prototype._handlesSpectorRebuildCallback=function(o){o&&this.program&&o(this.program)},i.prototype.setEngine=function(o){this.engine=o},i.prototype._fillEffectInformation=function(o,a,s,l,c,u,d,h){var p,m=this.engine;if(m.supportsUniformBuffers)for(var v in a)o.bindUniformBlock(v,a[v]);for(this.engine.getUniforms(this,s).forEach(function(T,f){l[s[f]]=T}),this._uniforms=l,p=0;p<c.length;p++)o.getUniform(c[p])==null&&(c.splice(p,1),p--);c.forEach(function(T,f){u[T]=f});for(var b=0,E=m.getAttributes(this,d);b<E.length;b++){var C=E[b];h.push(C)}},i.prototype.dispose=function(){this._uniforms={},this._isDisposed=!0},i.prototype._cacheMatrix=function(o,a){var s=this._valueCache[o],l=a.updateFlag;return(s===void 0||s!==l)&&(this._valueCache[o]=l,!0)},i.prototype._cacheFloat2=function(o,a,s){var l=this._valueCache[o];if(!l||l.length!==2)return l=[a,s],this._valueCache[o]=l,!0;var c=!1;return l[0]!==a&&(l[0]=a,c=!0),l[1]!==s&&(l[1]=s,c=!0),c},i.prototype._cacheFloat3=function(o,a,s,l){var c=this._valueCache[o];if(!c||c.length!==3)return c=[a,s,l],this._valueCache[o]=c,!0;var u=!1;return c[0]!==a&&(c[0]=a,u=!0),c[1]!==s&&(c[1]=s,u=!0),c[2]!==l&&(c[2]=l,u=!0),u},i.prototype._cacheFloat4=function(o,a,s,l,c){var u=this._valueCache[o];if(!u||u.length!==4)return u=[a,s,l,c],this._valueCache[o]=u,!0;var d=!1;return u[0]!==a&&(u[0]=a,d=!0),u[1]!==s&&(u[1]=s,d=!0),u[2]!==l&&(u[2]=l,d=!0),u[3]!==c&&(u[3]=c,d=!0),d},i.prototype.setInt=function(o,a){var s=this._valueCache[o];s!==void 0&&s===a||this.engine.setInt(this._uniforms[o],a)&&(this._valueCache[o]=a)},i.prototype.setInt2=function(o,a,s){this._cacheFloat2(o,a,s)&&(this.engine.setInt2(this._uniforms[o],a,s)||(this._valueCache[o]=null))},i.prototype.setInt3=function(o,a,s,l){this._cacheFloat3(o,a,s,l)&&(this.engine.setInt3(this._uniforms[o],a,s,l)||(this._valueCache[o]=null))},i.prototype.setInt4=function(o,a,s,l,c){this._cacheFloat4(o,a,s,l,c)&&(this.engine.setInt4(this._uniforms[o],a,s,l,c)||(this._valueCache[o]=null))},i.prototype.setIntArray=function(o,a){this._valueCache[o]=null,this.engine.setIntArray(this._uniforms[o],a)},i.prototype.setIntArray2=function(o,a){this._valueCache[o]=null,this.engine.setIntArray2(this._uniforms[o],a)},i.prototype.setIntArray3=function(o,a){this._valueCache[o]=null,this.engine.setIntArray3(this._uniforms[o],a)},i.prototype.setIntArray4=function(o,a){this._valueCache[o]=null,this.engine.setIntArray4(this._uniforms[o],a)},i.prototype.setUInt=function(o,a){var s=this._valueCache[o];s!==void 0&&s===a||this.engine.setUInt(this._uniforms[o],a)&&(this._valueCache[o]=a)},i.prototype.setUInt2=function(o,a,s){this._cacheFloat2(o,a,s)&&(this.engine.setUInt2(this._uniforms[o],a,s)||(this._valueCache[o]=null))},i.prototype.setUInt3=function(o,a,s,l){this._cacheFloat3(o,a,s,l)&&(this.engine.setUInt3(this._uniforms[o],a,s,l)||(this._valueCache[o]=null))},i.prototype.setUInt4=function(o,a,s,l,c){this._cacheFloat4(o,a,s,l,c)&&(this.engine.setUInt4(this._uniforms[o],a,s,l,c)||(this._valueCache[o]=null))},i.prototype.setUIntArray=function(o,a){this._valueCache[o]=null,this.engine.setUIntArray(this._uniforms[o],a)},i.prototype.setUIntArray2=function(o,a){this._valueCache[o]=null,this.engine.setUIntArray2(this._uniforms[o],a)},i.prototype.setUIntArray3=function(o,a){this._valueCache[o]=null,this.engine.setUIntArray3(this._uniforms[o],a)},i.prototype.setUIntArray4=function(o,a){this._valueCache[o]=null,this.engine.setUIntArray4(this._uniforms[o],a)},i.prototype.setArray=function(o,a){this._valueCache[o]=null,this.engine.setArray(this._uniforms[o],a)},i.prototype.setArray2=function(o,a){this._valueCache[o]=null,this.engine.setArray2(this._uniforms[o],a)},i.prototype.setArray3=function(o,a){this._valueCache[o]=null,this.engine.setArray3(this._uniforms[o],a)},i.prototype.setArray4=function(o,a){this._valueCache[o]=null,this.engine.setArray4(this._uniforms[o],a)},i.prototype.setMatrices=function(o,a){a&&(this._valueCache[o]=null,this.engine.setMatrices(this._uniforms[o],a))},i.prototype.setMatrix=function(o,a){this._cacheMatrix(o,a)&&(this.engine.setMatrices(this._uniforms[o],a.asArray())||(this._valueCache[o]=null))},i.prototype.setMatrix3x3=function(o,a){this._valueCache[o]=null,this.engine.setMatrix3x3(this._uniforms[o],a)},i.prototype.setMatrix2x2=function(o,a){this._valueCache[o]=null,this.engine.setMatrix2x2(this._uniforms[o],a)},i.prototype.setFloat=function(o,a){var s=this._valueCache[o];s!==void 0&&s===a||this.engine.setFloat(this._uniforms[o],a)&&(this._valueCache[o]=a)},i.prototype.setVector2=function(o,a){this._cacheFloat2(o,a.x,a.y)&&(this.engine.setFloat2(this._uniforms[o],a.x,a.y)||(this._valueCache[o]=null))},i.prototype.setFloat2=function(o,a,s){this._cacheFloat2(o,a,s)&&(this.engine.setFloat2(this._uniforms[o],a,s)||(this._valueCache[o]=null))},i.prototype.setVector3=function(o,a){this._cacheFloat3(o,a.x,a.y,a.z)&&(this.engine.setFloat3(this._uniforms[o],a.x,a.y,a.z)||(this._valueCache[o]=null))},i.prototype.setFloat3=function(o,a,s,l){this._cacheFloat3(o,a,s,l)&&(this.engine.setFloat3(this._uniforms[o],a,s,l)||(this._valueCache[o]=null))},i.prototype.setVector4=function(o,a){this._cacheFloat4(o,a.x,a.y,a.z,a.w)&&(this.engine.setFloat4(this._uniforms[o],a.x,a.y,a.z,a.w)||(this._valueCache[o]=null))},i.prototype.setQuaternion=function(o,a){this._cacheFloat4(o,a.x,a.y,a.z,a.w)&&(this.engine.setFloat4(this._uniforms[o],a.x,a.y,a.z,a.w)||(this._valueCache[o]=null))},i.prototype.setFloat4=function(o,a,s,l,c){this._cacheFloat4(o,a,s,l,c)&&(this.engine.setFloat4(this._uniforms[o],a,s,l,c)||(this._valueCache[o]=null))},i.prototype.setColor3=function(o,a){this._cacheFloat3(o,a.r,a.g,a.b)&&(this.engine.setFloat3(this._uniforms[o],a.r,a.g,a.b)||(this._valueCache[o]=null))},i.prototype.setColor4=function(o,a,s){this._cacheFloat4(o,a.r,a.g,a.b,s)&&(this.engine.setFloat4(this._uniforms[o],a.r,a.g,a.b,s)||(this._valueCache[o]=null))},i.prototype.setDirectColor4=function(o,a){this._cacheFloat4(o,a.r,a.g,a.b,a.a)&&(this.engine.setFloat4(this._uniforms[o],a.r,a.g,a.b,a.a)||(this._valueCache[o]=null))},i.prototype._getVertexShaderCode=function(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null},i.prototype._getFragmentShaderCode=function(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null},i}()},37411:(r,t,e)=>{e.d(t,{e:()=>i});var n=e(70511),i=function(){function o(){this._gpuTimeInFrameId=-1,this.counter=new n.A}return o.prototype._addDuration=function(a,s){a<this._gpuTimeInFrameId||(this._gpuTimeInFrameId!==a?(this.counter._fetchResult(),this.counter.fetchNewFrame(),this.counter.addCount(s,!1),this._gpuTimeInFrameId=a):this.counter.addCount(s,!1))},o}()},24894:(r,t,e)=>{e.d(t,{W0:()=>a,iL:()=>o,sg:()=>i,xt:()=>s});var n=e(41190),i=(e(5153),{});function o(l,c,u){return u===void 0&&(u=""),u+(c?c+`
|
||
`:"")+l}function a(l,c,u,d,h,p,m){var v=m||i.loadFile;if(v)return v(l,c,u,d,h,p);throw(0,n.n)("FileTools")}function s(l,c,u,d){if(l)return c?l.IS_NDC_HALF_ZRANGE="":delete l.IS_NDC_HALF_ZRANGE,u?l.USE_REVERSE_DEPTHBUFFER="":delete l.USE_REVERSE_DEPTHBUFFER,void(d?l.USE_EXACT_SRGB_CONVERSIONS="":delete l.USE_EXACT_SRGB_CONVERSIONS);var h="";return c&&(h+="#define IS_NDC_HALF_ZRANGE"),u&&(h&&(h+=`
|
||
`),h+="#define USE_REVERSE_DEPTHBUFFER"),d&&(h&&(h+=`
|
||
`),h+="#define USE_EXACT_SRGB_CONVERSIONS"),h}},82673:(r,t,e)=>{e.d(t,{$:()=>g,r:()=>f});var n=e(78322),i=e(66614),o=e(7164),a=e(74239),s=e(16106),l=e(85258),c=e(48424),u=e(75781),d=e(3911),h=e(69329),p=e(41190),m=e(19133),v=e(5153),b=e(81152),E=e(66377),C=e(24894),T=e(1235);function f(S,y){if((0,v.BA)()){var x=(y||window).requestAnimationFrame;if(typeof x=="function")return x(S)}else if(typeof requestAnimationFrame=="function")return requestAnimationFrame(S);return setTimeout(S,16)}var g=function(){function S(y,x,R){var I,M,D,B,F,X,$,Q,ie,q,ee,te=this;this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new c.N,this._stencilStateComposer=new u.u,this._stencilState=new d.K,this._alphaState=new h.i,this._alphaMode=b.Y.ALPHA_ADD,this._alphaEquation=b.Y.ALPHA_DISABLE,this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this.onCanvasBlurObservable=new E.cP,this.onCanvasFocusObservable=new E.cP,this.onNewSceneAddedObservable=new E.cP,this.onResizeObservable=new E.cP,this.onCanvasPointerOutObservable=new E.cP,this.disablePerformanceMonitorInBackground=!1,this.disableVertexArrayObjects=!1,this._frameId=0,this.hostInformation={isMobile:!1},this.isFullscreen=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.disableContextMenu=!0,this.currentRenderPassId=b.Y.RENDERPASS_MAIN,this.isPointerLock=!1,this.postProcesses=[],this.canvasTabIndex=1,this._contextWasLost=!1,this._useReverseDepthBuffer=!1,this.isNDCHalfZRange=!1,this.hasOriginBottomLeft=!0,this._renderTargetWrapperCache=new Array,this._compiledEffects={},this._isDisposed=!1,this.scenes=[],this._virtualScenes=new Array,this.onBeforeTextureInitObservable=new E.cP,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=function(){return te._renderLoop()},this.onBeforeShaderCompilationObservable=new E.cP,this.onAfterShaderCompilationObservable=new E.cP,this.onBeginFrameObservable=new E.cP,this.onEndFrameObservable=new E.cP,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new E.cP,this.onContextRestoredObservable=new E.cP,this._name="",this.premultipliedAlpha=!0,this.adaptToDeviceRatio=!1,this._lastDevicePixelRatio=1,this._doNotHandleContextLost=!1,this.cullBackFaces=null,this._renderPassNames=["main"],this._fps=60,this._deltaTime=0,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this._timeStep=1/60,this.onDisposeObservable=new E.cP,i.q.Instances.push(this),this.startTime=l.j.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,s.I.SetMatrixPrecision(!!x.useHighPrecisionMatrix),(0,v.XD)()&&navigator.userAgent&&(this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),this.adaptToDeviceRatio=R!=null&&R,x.antialias=y??x.antialias,x.deterministicLockstep=(I=x.deterministicLockstep)!==null&&I!==void 0&&I,x.lockstepMaxSteps=(M=x.lockstepMaxSteps)!==null&&M!==void 0?M:4,x.timeStep=(D=x.timeStep)!==null&&D!==void 0?D:1/60,x.audioEngine=(B=x.audioEngine)===null||B===void 0||B,x.stencil=(F=x.stencil)===null||F===void 0||F,this._audioContext=($=(X=x.audioEngineOptions)===null||X===void 0?void 0:X.audioContext)!==null&&$!==void 0?$:null,this._audioDestination=(ie=(Q=x.audioEngineOptions)===null||Q===void 0?void 0:Q.audioDestination)!==null&&ie!==void 0?ie:null,this.premultipliedAlpha=(q=x.premultipliedAlpha)===null||q===void 0||q,this._doNotHandleContextLost=!!x.doNotHandleContextLost,this._isStencilEnable=!!x.stencil,this.useExactSrgbConversions=(ee=x.useExactSrgbConversions)!==null&&ee!==void 0&ⅇvar ce=(0,v.BA)()&&window.devicePixelRatio||1,fe=x.limitDeviceRatio||ce;R=R||x.adaptToDeviceRatio||!1,this._hardwareScalingLevel=R?1/Math.min(fe,ce):1,this._lastDevicePixelRatio=ce,this._creationOptions=x}return Object.defineProperty(S.prototype,"frameId",{get:function(){return this._frameId},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isWebGPU",{get:function(){return this._isWebGPU},enumerable:!1,configurable:!0}),S.prototype._getShaderProcessor=function(y){return this._shaderProcessor},Object.defineProperty(S.prototype,"shaderPlatformName",{get:function(){return this._shaderPlatformName},enumerable:!1,configurable:!0}),S.prototype._clearEmptyResources=function(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null},Object.defineProperty(S.prototype,"useReverseDepthBuffer",{get:function(){return this._useReverseDepthBuffer},set:function(y){y!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=y,this._depthCullingState.depthFunc=y?b.Y.GEQUAL:b.Y.LEQUAL)},enumerable:!1,configurable:!0}),S.prototype.setColorWrite=function(y){y!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=y)},S.prototype.getColorWrite=function(){return this._colorWrite},Object.defineProperty(S.prototype,"depthCullingState",{get:function(){return this._depthCullingState},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"alphaState",{get:function(){return this._alphaState},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"stencilState",{get:function(){return this._stencilState},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"stencilStateComposer",{get:function(){return this._stencilStateComposer},enumerable:!1,configurable:!0}),S.prototype._getGlobalDefines=function(y){if(y)return this.isNDCHalfZRange?y.IS_NDC_HALF_ZRANGE="":delete y.IS_NDC_HALF_ZRANGE,this.useReverseDepthBuffer?y.USE_REVERSE_DEPTHBUFFER="":delete y.USE_REVERSE_DEPTHBUFFER,void(this.useExactSrgbConversions?y.USE_EXACT_SRGB_CONVERSIONS="":delete y.USE_EXACT_SRGB_CONVERSIONS);var x="";return this.isNDCHalfZRange&&(x+="#define IS_NDC_HALF_ZRANGE"),this.useReverseDepthBuffer&&(x&&(x+=`
|
||
`),x+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(x&&(x+=`
|
||
`),x+="#define USE_EXACT_SRGB_CONVERSIONS"),x},S.prototype._rebuildInternalTextures=function(){for(var y=0,x=this._internalTexturesCache.slice();y<x.length;y++)x[y]._rebuild()},S.prototype._rebuildRenderTargetWrappers=function(){for(var y=0,x=this._renderTargetWrapperCache.slice();y<x.length;y++)x[y]._rebuild()},S.prototype._rebuildEffects=function(){for(var y in this._compiledEffects){var x=this._compiledEffects[y];x._pipelineContext=null,x._prepareEffect()}a.M.ResetCache()},S.prototype._rebuildGraphicsResources=function(){var y;this.wipeCaches(!0),this._rebuildEffects(),(y=this._rebuildComputeEffects)===null||y===void 0||y.call(this),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)},S.prototype._flagContextRestored=function(){o.V.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1},S.prototype._restoreEngineAfterContextLost=function(y){var x=this;setTimeout(function(){return(0,n.sH)(x,void 0,void 0,function(){var R,I,M,D;return(0,n.YH)(this,function(B){switch(B.label){case 0:return this._clearEmptyResources(),R=this._depthCullingState.depthTest,I=this._depthCullingState.depthFunc,M=this._depthCullingState.depthMask,D=this._stencilState.stencilTest,[4,y()];case 1:return B.sent(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=R,this._depthCullingState.depthFunc=I,this._depthCullingState.depthMask=M,this._stencilState.stencilTest=D,this._flagContextRestored(),[2]}})})},0)},Object.defineProperty(S.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"snapshotRendering",{get:function(){return!1},set:function(y){},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"snapshotRenderingMode",{get:function(){return b.Y.SNAPSHOTRENDERING_STANDARD},set:function(y){},enumerable:!1,configurable:!0}),S.prototype.getClassName=function(){return"AbstractEngine"},Object.defineProperty(S.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,b.Y.TEXTUREFORMAT_RGBA,!1,!1,b.Y.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,b.Y.TEXTUREFORMAT_RGBA,!1,!1,b.Y.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"emptyTexture2DArray",{get:function(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,b.Y.TEXTUREFORMAT_RGBA,!1,!1,b.Y.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture2DArray},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var y=new Uint8Array(4),x=[y,y,y,y,y,y];this._emptyCubeTexture=this.createRawCubeTexture(x,1,b.Y.TEXTUREFORMAT_RGBA,b.Y.TEXTURETYPE_UNSIGNED_INT,!1,!1,b.Y.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"activeRenderLoops",{get:function(){return this._activeRenderLoops},enumerable:!1,configurable:!0}),S.prototype.stopRenderLoop=function(y){if(!y)return this._activeRenderLoops.length=0,void this._cancelFrame();var x=this._activeRenderLoops.indexOf(y);x>=0&&(this._activeRenderLoops.splice(x,1),this._activeRenderLoops.length==0&&this._cancelFrame())},S.prototype._cancelFrame=function(){if(this._frameHandler!==0){var y=this._frameHandler;if(this._frameHandler=0,(0,v.BA)()){var x=(this.getHostWindow()||window).cancelAnimationFrame;if(typeof x=="function")return x(y)}else if(typeof cancelAnimationFrame=="function")return cancelAnimationFrame(y);return clearTimeout(y)}},S.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this)},S.prototype.endFrame=function(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)},S.prototype._renderLoop=function(){if(this._frameHandler=0,!this._contextWasLost){var y=!0;(this._isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(y=!1),y&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))},S.prototype._renderFrame=function(){for(var y=0;y<this._activeRenderLoops.length;y++)(0,this._activeRenderLoops[y])()},S.prototype._renderViews=function(){return!1},S.prototype._queueNewFrame=function(y,x){return f(y,x)},S.prototype.runRenderLoop=function(y){this._activeRenderLoops.indexOf(y)===-1&&(this._activeRenderLoops.push(y),this._activeRenderLoops.length===1&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},S.prototype.getDepthBuffer=function(){return this._depthCullingState.depthTest},S.prototype.setDepthBuffer=function(y){this._depthCullingState.depthTest=y},S.prototype.setZOffset=function(y){this._depthCullingState.zOffset=this.useReverseDepthBuffer?-y:y},S.prototype.getZOffset=function(){var y=this._depthCullingState.zOffset;return this.useReverseDepthBuffer?-y:y},S.prototype.setZOffsetUnits=function(y){this._depthCullingState.zOffsetUnits=this.useReverseDepthBuffer?-y:y},S.prototype.getZOffsetUnits=function(){var y=this._depthCullingState.zOffsetUnits;return this.useReverseDepthBuffer?-y:y},S.prototype.getHostWindow=function(){return(0,v.BA)()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},Object.defineProperty(S.prototype,"compatibilityMode",{get:function(){return this._compatibilityMode},set:function(y){this._compatibilityMode=!0},enumerable:!1,configurable:!0}),S.prototype._rebuildTextures=function(){for(var y=0,x=this.scenes;y<x.length;y++)x[y]._rebuildTextures();for(var R=0,I=this._virtualScenes;R<I.length;R++)I[R]._rebuildTextures()},S.prototype._releaseRenderTargetWrapper=function(y){var x=this._renderTargetWrapperCache.indexOf(y);x!==-1&&this._renderTargetWrapperCache.splice(x,1)},Object.defineProperty(S.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!1,configurable:!0}),S.prototype.setViewport=function(y,x,R){var I=x||this.getRenderWidth(),M=R||this.getRenderHeight(),D=y.x||0,B=y.y||0;this._cachedViewport=y,this._viewport(D*I,B*M,I*y.width,M*y.height)},S.prototype.createCanvasImage=function(){return document.createElement("img")},Object.defineProperty(S.prototype,"description",{get:function(){var y=this.name+this.version;return this._caps.parallelShaderCompile&&(y+=" - Parallel shader compilation"),y},enumerable:!1,configurable:!0}),S.prototype._createTextureBase=function(y,x,R,I,M,D,B,F,X,$,Q,ie,q,ee,te,ce){var fe=this;M===void 0&&(M=b.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),D===void 0&&(D=null),B===void 0&&(B=null),$===void 0&&($=null),Q===void 0&&(Q=null),ie===void 0&&(ie=null),q===void 0&&(q=null);var de=(y=y||"").substr(0,5)==="data:",Te=y.substr(0,5)==="blob:",ue=de&&y.indexOf(";base64,")!==-1,U=Q||new m.h(this,1);U!==Q&&(U.label=y.substring(0,60));var N=y;!this._transformTextureUrl||ue||Q||$||(y=this._transformTextureUrl(y)),N!==y&&(U._originalUrl=N);var w=y.lastIndexOf("."),k=q||(w>-1?y.substring(w).toLowerCase():"");k.indexOf("?")>-1&&(k=k.split("?")[0]);var J=(0,T.gT)(k,ee);I&&I.addPendingData(U),U.url=y,U.generateMipMaps=!x,U.samplingMode=M,U.invertY=R,U._useSRGBBuffer=this._getUseSRGBBuffer(!!ce,x),this._doNotHandleContextLost||(U._buffer=$);var le=null;D&&!Q&&(le=U.onLoadedObservable.add(D)),Q||this._internalTexturesCache.push(U);var be=function(Me,we){I&&I.removePendingData(U),y===N?(le&&U.onLoadedObservable.remove(le),i.q.UseFallbackTexture&&y!==i.q.FallbackTexture&&fe._createTextureBase(i.q.FallbackTexture,x,U.invertY,I,M,null,B,F,X,$,U),Me=(Me||"Unknown error")+(i.q.UseFallbackTexture?" - Fallback texture was used":""),U.onErrorObservable.notifyObservers({message:Me,exception:we}),B&&B(Me,we)):(o.V.Warn("Failed to load ".concat(y,", falling back to ").concat(N)),fe._createTextureBase(N,x,U.invertY,I,M,D,B,F,X,$,U,ie,q,ee,te,ce))};if(J){var ve=function(Me){return(0,n.sH)(fe,void 0,void 0,function(){return(0,n.YH)(this,function(we){switch(we.label){case 0:return[4,J];case 1:return we.sent().loadData(Me,U,function(He,Ke,Qe,Je,ht,mt){mt?be("TextureLoader failed to load data"):F(U,k,I,{width:He,height:Ke},U.invertY,!Qe,Je,function(){return ht(),!1},M)},te),[2]}})})};$?$ instanceof ArrayBuffer?ve(new Uint8Array($)):ArrayBuffer.isView($)?ve($):B&&B("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(y,function(Me){return ve(new Uint8Array(Me))},void 0,I?I.offlineProvider:void 0,!0,function(Me,we){be("Unable to load "+(Me&&Me.responseURL,we))})}else{var ye=function(Me){Te&&!fe._doNotHandleContextLost&&(U._buffer=Me),F(U,k,I,Me,U.invertY,x,!1,X,M)};!de||ue?$&&(typeof $.decoding=="string"||$.close)?ye($):S._FileToolsLoadImage(y||"",ye,be,I?I.offlineProvider:null,ee,U.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):typeof $=="string"||$ instanceof ArrayBuffer||ArrayBuffer.isView($)||$ instanceof Blob?S._FileToolsLoadImage($,ye,be,I?I.offlineProvider:null,ee,U.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):$&&ye($)}return U},S.prototype._rebuildBuffers=function(){for(var y=0,x=this._uniformBuffers;y<x.length;y++)x[y]._rebuildAfterContextLost()},Object.defineProperty(S.prototype,"_shouldUseHighPrecisionShader",{get:function(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)},enumerable:!1,configurable:!0}),S.prototype.getHostDocument=function(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:(0,v.Nf)()?document:null},S.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},S.prototype.clearInternalTexturesCache=function(){this._internalTexturesCache.length=0},S.prototype.getCaps=function(){return this._caps},S.prototype.resetTextureCache=function(){for(var y in this._boundTexturesCache)Object.prototype.hasOwnProperty.call(this._boundTexturesCache,y)&&(this._boundTexturesCache[y]=null);this._currentTextureChannel=-1},Object.defineProperty(S.prototype,"name",{get:function(){return this._name},set:function(y){this._name=y},enumerable:!1,configurable:!0}),Object.defineProperty(S,"NpmPackage",{get:function(){return"babylonjs@7.25.2"},enumerable:!1,configurable:!0}),Object.defineProperty(S,"Version",{get:function(){return"7.25.2"},enumerable:!1,configurable:!0}),S.prototype.getRenderingCanvas=function(){return this._renderingCanvas},S.prototype.getAudioContext=function(){return this._audioContext},S.prototype.getAudioDestination=function(){return this._audioDestination},S.prototype.setHardwareScalingLevel=function(y){this._hardwareScalingLevel=y,this.resize()},S.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},Object.defineProperty(S.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(y){this._doNotHandleContextLost=y},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!1,configurable:!0}),S.prototype.getCreationOptions=function(){return this._creationOptions},S.prototype.resize=function(y){var x,R;if(y===void 0&&(y=!1),this.adaptToDeviceRatio){var I=(0,v.BA)()&&window.devicePixelRatio||1,M=this._lastDevicePixelRatio/I;this._lastDevicePixelRatio=I,this._hardwareScalingLevel*=M}if((0,v.BA)()&&(0,v.Nf)())if(this._renderingCanvas){var D=this._renderingCanvas.getBoundingClientRect?this._renderingCanvas.getBoundingClientRect():{width:this._renderingCanvas.width*this._hardwareScalingLevel,height:this._renderingCanvas.height*this._hardwareScalingLevel};x=this._renderingCanvas.clientWidth||D.width||this._renderingCanvas.width||100,R=this._renderingCanvas.clientHeight||D.height||this._renderingCanvas.height||100}else x=window.innerWidth,R=window.innerHeight;else x=this._renderingCanvas?this._renderingCanvas.width:100,R=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(x/this._hardwareScalingLevel,R/this._hardwareScalingLevel,y)},S.prototype.setSize=function(y,x,R){if(R===void 0&&(R=!1),!this._renderingCanvas||(y|=0,x|=0,!R&&this._renderingCanvas.width===y&&this._renderingCanvas.height===x))return!1;if(this._renderingCanvas.width=y,this._renderingCanvas.height=x,this.scenes){for(var I=0;I<this.scenes.length;I++)for(var M=this.scenes[I],D=0;D<M.cameras.length;D++)M.cameras[D]._currentRenderId=0;this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0},S.prototype.createRawTexture=function(y,x,R,I,M,D,B,F,X,$,Q){throw(0,p.n)("engine.rawTexture")},S.prototype.createRawCubeTexture=function(y,x,R,I,M,D,B,F){throw(0,p.n)("engine.rawTexture")},S.prototype.createRawTexture3D=function(y,x,R,I,M,D,B,F,X,$,Q){throw(0,p.n)("engine.rawTexture")},S.prototype.createRawTexture2DArray=function(y,x,R,I,M,D,B,F,X,$,Q){throw(0,p.n)("engine.rawTexture")},S.prototype._sharedInit=function(y){this._renderingCanvas=y},S.prototype._setupMobileChecks=function(){var y=this;navigator&&navigator.userAgent&&(this._checkForMobile=function(){var x=navigator.userAgent;y.hostInformation.isMobile=x.indexOf("Mobile")!==-1||x.indexOf("Mac")!==-1&&(0,v.Nf)()&&"ontouchend"in document},this._checkForMobile(),(0,v.BA)()&&window.addEventListener("resize",this._checkForMobile))},S.prototype.createVideoElement=function(y){return document.createElement("video")},S.prototype._reportDrawCall=function(y){var x;y===void 0&&(y=1),(x=this._drawCalls)===null||x===void 0||x.addCount(y,!1)},S.prototype.getFps=function(){return this._fps},S.prototype.getDeltaTime=function(){return this._deltaTime},S.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},S.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},S.prototype.getTimeStep=function(){return 1e3*this._timeStep},S.prototype._createImageBitmapFromSource=function(y,x){throw new Error("createImageBitmapFromSource is not implemented")},S.prototype.createImageBitmap=function(y,x){return createImageBitmap(y,x)},S.prototype.resizeImageBitmap=function(y,x,R){throw new Error("resizeImageBitmap is not implemented")},S.prototype.getFontOffset=function(y){throw new Error("getFontOffset is not implemented")},S._CreateCanvas=function(y,x){if(typeof document>"u")return new OffscreenCanvas(y,x);var R=document.createElement("canvas");return R.width=y,R.height=x,R},S.prototype.createCanvas=function(y,x){return S._CreateCanvas(y,x)},S._FileToolsLoadImage=function(y,x,R,I,M,D){throw(0,p.n)("FileTools")},S.prototype._loadFile=function(y,x,R,I,M,D){var B=this,F=(0,C.W0)(y,x,R,I,M,D);return this._activeRequests.push(F),F.onCompleteObservable.add(function(){var X=B._activeRequests.indexOf(F);X!==-1&&B._activeRequests.splice(X,1)}),F},S._FileToolsLoadFile=function(y,x,R,I,M,D){if(C.sg.loadFile)return C.sg.loadFile(y,x,R,I,M,D);throw(0,p.n)("FileTools")},S.prototype.dispose=function(){var y;for(this.releaseEffects(),this._isDisposed=!0,this.stopRenderLoop(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._renderingCanvas=null,this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.scenes.length;)this.scenes[0].dispose();for(;this._virtualScenes.length;)this._virtualScenes[0].dispose();(y=this.releaseComputeEffects)===null||y===void 0||y.call(this),a.M.ResetCache();for(var x=0,R=this._activeRequests;x<R.length;x++)R[x].abort();this._boundRenderFunction=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onNewSceneAddedObservable.clear(),(0,v.BA)()&&window.removeEventListener("resize",this._checkForMobile);var I=i.q.Instances.indexOf(this);I>=0&&i.q.Instances.splice(I,1),i.q.Instances.length||(i.q.OnEnginesDisposedObservable.notifyObservers(this),i.q.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},S.DefaultLoadingScreenFactory=function(y){throw(0,p.n)("LoadingScreen")},S.MarkAllMaterialsAsDirty=function(y,x){for(var R=0;R<i.q.Instances.length;R++)for(var I=i.q.Instances[R],M=0;M<I.scenes.length;M++)I.scenes[M].markAllMaterialsAsDirty(y,x)},S._RenderPassIdCounter=0,S._RescalePostProcessFactory=null,S.CollisionsEpsilon=.001,S.QueueNewFrame=f,S}()},81152:(r,t,e)=>{e.d(t,{Y:()=>n});var n=function(){function i(){}return i.AUTOSAMPLERSUFFIX="Sampler",i.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS",i.ALPHA_DISABLE=0,i.ALPHA_ADD=1,i.ALPHA_COMBINE=2,i.ALPHA_SUBTRACT=3,i.ALPHA_MULTIPLY=4,i.ALPHA_MAXIMIZED=5,i.ALPHA_ONEONE=6,i.ALPHA_PREMULTIPLIED=7,i.ALPHA_PREMULTIPLIED_PORTERDUFF=8,i.ALPHA_INTERPOLATE=9,i.ALPHA_SCREENMODE=10,i.ALPHA_ONEONE_ONEONE=11,i.ALPHA_ALPHATOCOLOR=12,i.ALPHA_REVERSEONEMINUS=13,i.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,i.ALPHA_ONEONE_ONEZERO=15,i.ALPHA_EXCLUSION=16,i.ALPHA_LAYER_ACCUMULATE=17,i.ALPHA_EQUATION_ADD=0,i.ALPHA_EQUATION_SUBSTRACT=1,i.ALPHA_EQUATION_REVERSE_SUBTRACT=2,i.ALPHA_EQUATION_MAX=3,i.ALPHA_EQUATION_MIN=4,i.ALPHA_EQUATION_DARKEN=5,i.DELAYLOADSTATE_NONE=0,i.DELAYLOADSTATE_LOADED=1,i.DELAYLOADSTATE_LOADING=2,i.DELAYLOADSTATE_NOTLOADED=4,i.NEVER=512,i.ALWAYS=519,i.LESS=513,i.EQUAL=514,i.LEQUAL=515,i.GREATER=516,i.GEQUAL=518,i.NOTEQUAL=517,i.KEEP=7680,i.ZERO=0,i.REPLACE=7681,i.INCR=7682,i.DECR=7683,i.INVERT=5386,i.INCR_WRAP=34055,i.DECR_WRAP=34056,i.TEXTURE_CLAMP_ADDRESSMODE=0,i.TEXTURE_WRAP_ADDRESSMODE=1,i.TEXTURE_MIRROR_ADDRESSMODE=2,i.TEXTURE_CREATIONFLAG_STORAGE=1,i.TEXTUREFORMAT_ALPHA=0,i.TEXTUREFORMAT_LUMINANCE=1,i.TEXTUREFORMAT_LUMINANCE_ALPHA=2,i.TEXTUREFORMAT_RGB=4,i.TEXTUREFORMAT_RGBA=5,i.TEXTUREFORMAT_RED=6,i.TEXTUREFORMAT_R=6,i.TEXTUREFORMAT_RG=7,i.TEXTUREFORMAT_RED_INTEGER=8,i.TEXTUREFORMAT_R_INTEGER=8,i.TEXTUREFORMAT_RG_INTEGER=9,i.TEXTUREFORMAT_RGB_INTEGER=10,i.TEXTUREFORMAT_RGBA_INTEGER=11,i.TEXTUREFORMAT_BGRA=12,i.TEXTUREFORMAT_DEPTH24_STENCIL8=13,i.TEXTUREFORMAT_DEPTH32_FLOAT=14,i.TEXTUREFORMAT_DEPTH16=15,i.TEXTUREFORMAT_DEPTH24=16,i.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17,i.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18,i.TEXTUREFORMAT_STENCIL8=19,i.TEXTUREFORMAT_UNDEFINED=4294967295,i.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493,i.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495,i.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777,i.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917,i.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916,i.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840,i.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196,i.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493,i.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494,i.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495,i.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497,i.TEXTURETYPE_UNSIGNED_BYTE=0,i.TEXTURETYPE_UNSIGNED_INT=0,i.TEXTURETYPE_FLOAT=1,i.TEXTURETYPE_HALF_FLOAT=2,i.TEXTURETYPE_BYTE=3,i.TEXTURETYPE_SHORT=4,i.TEXTURETYPE_UNSIGNED_SHORT=5,i.TEXTURETYPE_INT=6,i.TEXTURETYPE_UNSIGNED_INTEGER=7,i.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,i.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,i.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,i.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,i.TEXTURETYPE_UNSIGNED_INT_24_8=12,i.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,i.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,i.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,i.TEXTURETYPE_UNDEFINED=16,i.TEXTURE_2D=3553,i.TEXTURE_2D_ARRAY=35866,i.TEXTURE_CUBE_MAP=34067,i.TEXTURE_CUBE_MAP_ARRAY=3735928559,i.TEXTURE_3D=32879,i.TEXTURE_NEAREST_SAMPLINGMODE=1,i.TEXTURE_NEAREST_NEAREST=1,i.TEXTURE_BILINEAR_SAMPLINGMODE=2,i.TEXTURE_LINEAR_LINEAR=2,i.TEXTURE_TRILINEAR_SAMPLINGMODE=3,i.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,i.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,i.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,i.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,i.TEXTURE_NEAREST_LINEAR=7,i.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,i.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,i.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,i.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,i.TEXTURE_LINEAR_NEAREST=12,i.TEXTURE_EXPLICIT_MODE=0,i.TEXTURE_SPHERICAL_MODE=1,i.TEXTURE_PLANAR_MODE=2,i.TEXTURE_CUBIC_MODE=3,i.TEXTURE_PROJECTION_MODE=4,i.TEXTURE_SKYBOX_MODE=5,i.TEXTURE_INVCUBIC_MODE=6,i.TEXTURE_EQUIRECTANGULAR_MODE=7,i.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,i.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,i.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,i.TEXTURE_FILTERING_QUALITY_HIGH=64,i.TEXTURE_FILTERING_QUALITY_MEDIUM=16,i.TEXTURE_FILTERING_QUALITY_LOW=8,i.SCALEMODE_FLOOR=1,i.SCALEMODE_NEAREST=2,i.SCALEMODE_CEILING=3,i.MATERIAL_TextureDirtyFlag=1,i.MATERIAL_LightDirtyFlag=2,i.MATERIAL_FresnelDirtyFlag=4,i.MATERIAL_AttributesDirtyFlag=8,i.MATERIAL_MiscDirtyFlag=16,i.MATERIAL_PrePassDirtyFlag=32,i.MATERIAL_AllDirtyFlag=63,i.MATERIAL_TriangleFillMode=0,i.MATERIAL_WireFrameFillMode=1,i.MATERIAL_PointFillMode=2,i.MATERIAL_PointListDrawMode=3,i.MATERIAL_LineListDrawMode=4,i.MATERIAL_LineLoopDrawMode=5,i.MATERIAL_LineStripDrawMode=6,i.MATERIAL_TriangleStripDrawMode=7,i.MATERIAL_TriangleFanDrawMode=8,i.MATERIAL_ClockWiseSideOrientation=0,i.MATERIAL_CounterClockWiseSideOrientation=1,i.ACTION_NothingTrigger=0,i.ACTION_OnPickTrigger=1,i.ACTION_OnLeftPickTrigger=2,i.ACTION_OnRightPickTrigger=3,i.ACTION_OnCenterPickTrigger=4,i.ACTION_OnPickDownTrigger=5,i.ACTION_OnDoublePickTrigger=6,i.ACTION_OnPickUpTrigger=7,i.ACTION_OnPickOutTrigger=16,i.ACTION_OnLongPressTrigger=8,i.ACTION_OnPointerOverTrigger=9,i.ACTION_OnPointerOutTrigger=10,i.ACTION_OnEveryFrameTrigger=11,i.ACTION_OnIntersectionEnterTrigger=12,i.ACTION_OnIntersectionExitTrigger=13,i.ACTION_OnKeyDownTrigger=14,i.ACTION_OnKeyUpTrigger=15,i.PARTICLES_BILLBOARDMODE_Y=2,i.PARTICLES_BILLBOARDMODE_ALL=7,i.PARTICLES_BILLBOARDMODE_STRETCHED=8,i.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9,i.MESHES_CULLINGSTRATEGY_STANDARD=0,i.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,i.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,i.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,i.SCENELOADER_NO_LOGGING=0,i.SCENELOADER_MINIMAL_LOGGING=1,i.SCENELOADER_SUMMARY_LOGGING=2,i.SCENELOADER_DETAILED_LOGGING=3,i.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,i.PREPASS_POSITION_TEXTURE_TYPE=1,i.PREPASS_VELOCITY_TEXTURE_TYPE=2,i.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,i.PREPASS_COLOR_TEXTURE_TYPE=4,i.PREPASS_DEPTH_TEXTURE_TYPE=5,i.PREPASS_NORMAL_TEXTURE_TYPE=6,i.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7,i.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8,i.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9,i.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10,i.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11,i.BUFFER_CREATIONFLAG_READ=1,i.BUFFER_CREATIONFLAG_WRITE=2,i.BUFFER_CREATIONFLAG_READWRITE=3,i.BUFFER_CREATIONFLAG_UNIFORM=4,i.BUFFER_CREATIONFLAG_VERTEX=8,i.BUFFER_CREATIONFLAG_INDEX=16,i.BUFFER_CREATIONFLAG_STORAGE=32,i.BUFFER_CREATIONFLAG_INDIRECT=64,i.RENDERPASS_MAIN=0,i.INPUT_ALT_KEY=18,i.INPUT_CTRL_KEY=17,i.INPUT_META_KEY1=91,i.INPUT_META_KEY2=92,i.INPUT_META_KEY3=93,i.INPUT_SHIFT_KEY=16,i.SNAPSHOTRENDERING_STANDARD=0,i.SNAPSHOTRENDERING_FAST=1,i.PERSPECTIVE_CAMERA=0,i.ORTHOGRAPHIC_CAMERA=1,i.FOVMODE_VERTICAL_FIXED=0,i.FOVMODE_HORIZONTAL_FIXED=1,i.RIG_MODE_NONE=0,i.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,i.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,i.RIG_MODE_STEREOSCOPIC_INTERLACED=14,i.RIG_MODE_VR=20,i.RIG_MODE_CUSTOM=22,i.MAX_SUPPORTED_UV_SETS=6,i.GL_ALPHA_EQUATION_ADD=32774,i.GL_ALPHA_EQUATION_MIN=32775,i.GL_ALPHA_EQUATION_MAX=32776,i.GL_ALPHA_EQUATION_SUBTRACT=32778,i.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779,i.GL_ALPHA_FUNCTION_SRC=768,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769,i.GL_ALPHA_FUNCTION_SRC_ALPHA=770,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771,i.GL_ALPHA_FUNCTION_DST_ALPHA=772,i.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773,i.GL_ALPHA_FUNCTION_DST_COLOR=774,i.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775,i.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776,i.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769,i.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770,i.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771,i.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772,i.SnippetUrl="https://snippet.babylonjs.com",i.FOGMODE_NONE=0,i.FOGMODE_EXP=1,i.FOGMODE_EXP2=2,i.FOGMODE_LINEAR=3,i.BYTE=5120,i.UNSIGNED_BYTE=5121,i.SHORT=5122,i.UNSIGNED_SHORT=5123,i.INT=5124,i.UNSIGNED_INT=5125,i.FLOAT=5126,i.PositionKind="position",i.NormalKind="normal",i.TangentKind="tangent",i.UVKind="uv",i.UV2Kind="uv2",i.UV3Kind="uv3",i.UV4Kind="uv4",i.UV5Kind="uv5",i.UV6Kind="uv6",i.ColorKind="color",i.ColorInstanceKind="instanceColor",i.MatricesIndicesKind="matricesIndices",i.MatricesWeightsKind="matricesWeights",i.MatricesIndicesExtraKind="matricesIndicesExtra",i.MatricesWeightsExtraKind="matricesWeightsExtra",i}()},66614:(r,t,e)=>{e.d(t,{q:()=>i});var n=e(66377),i=function(){function o(){}return Object.defineProperty(o,"LastCreatedEngine",{get:function(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(o,"LastCreatedScene",{get:function(){return this._LastCreatedScene},enumerable:!1,configurable:!0}),o.Instances=[],o.OnEnginesDisposedObservable=new n.cP,o._LastCreatedScene=null,o.UseFallbackTexture=!0,o.FallbackTexture="",o}()},16106:(r,t,e)=>{e.d(t,{I:()=>n});var n=function(){function i(){}return i.SetMatrixPrecision=function(o){if(i.MatrixTrackPrecisionChange=!1,o&&!i.MatrixUse64Bits&&i.MatrixTrackedMatrices)for(var a=0;a<i.MatrixTrackedMatrices.length;++a){var s=i.MatrixTrackedMatrices[a],l=s._m;s._m=new Array(16);for(var c=0;c<16;++c)s._m[c]=l[c]}i.MatrixUse64Bits=o,i.MatrixCurrentType=i.MatrixUse64Bits?Array:Float32Array,i.MatrixTrackedMatrices=null},i.MatrixUse64Bits=!1,i.MatrixTrackPrecisionChange=!0,i.MatrixCurrentType=Float32Array,i.MatrixTrackedMatrices=[],i}()},96925:(r,t,e)=>{e.d(t,{v:()=>i});var n=e(81152),i=function(){function o(a,s,l,c,u){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this._isMulti=a,this._isCube=s,this._size=l,this._engine=c,this._depthStencilTexture=null,this.label=u}return Object.defineProperty(o.prototype,"depthStencilTexture",{get:function(){return this._depthStencilTexture},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"depthStencilTextureWithStencil",{get:function(){return this._depthStencilTextureWithStencil},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"isCube",{get:function(){return this._isCube},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"isMulti",{get:function(){return this._isMulti},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"is2DArray",{get:function(){return this.layers>0},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"is3D",{get:function(){return this.depth>0},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"size",{get:function(){return this.width},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"width",{get:function(){return this._size.width||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"height",{get:function(){return this._size.height||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"layers",{get:function(){return this._size.layers||0},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"depth",{get:function(){return this._size.depth||0},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"texture",{get:function(){var a,s;return(s=(a=this._textures)===null||a===void 0?void 0:a[0])!==null&&s!==void 0?s:null},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"faceIndices",{get:function(){return this._faceIndices},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"layerIndices",{get:function(){return this._layerIndices},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"samples",{get:function(){return this._samples},enumerable:!1,configurable:!0}),o.prototype.setSamples=function(a,s,l){if(s===void 0&&(s=!0),l===void 0&&(l=!1),this.samples===a&&!l)return a;var c=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,a,s):this._engine.updateRenderTargetTextureSampleCount(this,a);return this._samples=a,c},o.prototype.setTextures=function(a){Array.isArray(a)?this._textures=a:this._textures=a?[a]:null},o.prototype.setTexture=function(a,s,l){s===void 0&&(s=0),l===void 0&&(l=!0),this._textures||(this._textures=[]),this._textures[s]!==a&&(this._textures[s]&&l&&this._textures[s].dispose(),this._textures[s]=a)},o.prototype.setLayerAndFaceIndices=function(a,s){this._layerIndices=a,this._faceIndices=s},o.prototype.setLayerAndFaceIndex=function(a,s,l){a===void 0&&(a=0),this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),s!==void 0&&s>=0&&(this._layerIndices[a]=s),l!==void 0&&l>=0&&(this._faceIndices[a]=l)},o.prototype.createDepthStencilTexture=function(a,s,l,c,u,d){var h;return a===void 0&&(a=0),s===void 0&&(s=!0),l===void 0&&(l=!1),c===void 0&&(c=1),u===void 0&&(u=n.Y.TEXTUREFORMAT_DEPTH32_FLOAT),(h=this._depthStencilTexture)===null||h===void 0||h.dispose(),this._depthStencilTextureWithStencil=l,this._depthStencilTextureLabel=d,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:s,comparisonFunction:a,generateStencil:l,isCube:this._isCube,samples:c,depthTextureFormat:u,label:d},this),this._depthStencilTexture},o.prototype._shareDepth=function(a){this.shareDepth(a)},o.prototype.shareDepth=function(a){this._depthStencilTexture&&(a._depthStencilTexture&&a._depthStencilTexture.dispose(),a._depthStencilTexture=this._depthStencilTexture,a._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())},o.prototype._swapAndDie=function(a){this.texture&&this.texture._swapAndDie(a),this._textures=null,this.dispose(!0)},o.prototype._cloneRenderTargetWrapper=function(){var a,s,l,c,u,d,h,p,m=null;if(this._isMulti){var v=this.textures;if(v&&v.length>0){var b=!1,E=v.length,C=-1,T=v[v.length-1]._source;T!==14&&T!==12||(b=!0,C=v[v.length-1].format,E--);for(var f=[],g=[],S=[],y=[],x=[],R=[],I=[],M={},D=0;D<E;++D){var B=v[D];f.push(B.samplingMode),g.push(B.type),S.push(B.format),($=M[B.uniqueId])!==void 0?(y.push(-1),I.push(0)):(M[B.uniqueId]=D,B.is2DArray?(y.push(n.Y.TEXTURE_2D_ARRAY),I.push(B.depth)):B.isCube?(y.push(n.Y.TEXTURE_CUBE_MAP),I.push(0)):B.is3D?(y.push(n.Y.TEXTURE_3D),I.push(B.depth)):(y.push(n.Y.TEXTURE_2D),I.push(0))),this._faceIndices&&x.push((a=this._faceIndices[D])!==null&&a!==void 0?a:0),this._layerIndices&&R.push((s=this._layerIndices[D])!==null&&s!==void 0?s:0)}var F={samplingModes:f,generateMipMaps:v[0].generateMipMaps,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:this._generateStencilBuffer,generateDepthTexture:b,depthTextureFormat:C,types:g,formats:S,textureCount:E,targetTypes:y,faceIndex:x,layerIndex:R,layerCounts:I,label:this.label},X={width:this.width,height:this.height,depth:this.depth};for(m=this._engine.createMultipleRenderTarget(X,F),D=0;D<E;++D)if(y[D]===-1){var $=M[v[D].uniqueId];m.setTexture(m.textures[$],D)}}}else{var Q={};Q.generateDepthBuffer=this._generateDepthBuffer,Q.generateMipMaps=(c=(l=this.texture)===null||l===void 0?void 0:l.generateMipMaps)!==null&&c!==void 0&&c,Q.generateStencilBuffer=this._generateStencilBuffer,Q.samplingMode=(u=this.texture)===null||u===void 0?void 0:u.samplingMode,Q.type=(d=this.texture)===null||d===void 0?void 0:d.type,Q.format=(h=this.texture)===null||h===void 0?void 0:h.format,Q.noColorAttachment=!this._textures,Q.label=this.label,this.isCube?m=this._engine.createRenderTargetCubeTexture(this.width,Q):(X={width:this.width,height:this.height,layers:this.is2DArray||this.is3D?(p=this.texture)===null||p===void 0?void 0:p.depth:void 0},m=this._engine.createRenderTargetTexture(X,Q)),m.texture&&(m.texture.isReady=!0)}return m},o.prototype._swapRenderTargetWrapper=function(a){if(this._textures&&a._textures)for(var s=0;s<this._textures.length;++s)this._textures[s]._swapAndDie(a._textures[s],!1),a._textures[s].isReady=!0;this._depthStencilTexture&&a._depthStencilTexture&&(this._depthStencilTexture._swapAndDie(a._depthStencilTexture),a._depthStencilTexture.isReady=!0),this._textures=null,this._depthStencilTexture=null},o.prototype._rebuild=function(){var a=this._cloneRenderTargetWrapper();if(a){if(this._depthStencilTexture){var s=this._depthStencilTexture.samplingMode,l=this._depthStencilTexture.format,c=s===n.Y.TEXTURE_BILINEAR_SAMPLINGMODE||s===n.Y.TEXTURE_TRILINEAR_SAMPLINGMODE||s===n.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST;a.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction,c,this._depthStencilTextureWithStencil,this._depthStencilTexture.samples,l,this._depthStencilTextureLabel)}this.samples>1&&a.setSamples(this.samples),a._swapRenderTargetWrapper(this),a.dispose()}},o.prototype.releaseTextures=function(){var a,s;if(this._textures)for(var l=0;(s=l<((a=this._textures)===null||a===void 0?void 0:a.length))!==null&&s!==void 0&&s;++l)this._textures[l].dispose();this._textures=null},o.prototype.dispose=function(a){var s;a===void 0&&(a=!1),a||((s=this._depthStencilTexture)===null||s===void 0||s.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)},o}()},98519:(r,t,e)=>{e.d(t,{l:()=>n});var n=function(){function i(){}return i.GetShadersRepository=function(o){return o===void 0&&(o=0),o===0?i.ShadersRepository:i.ShadersRepositoryWGSL},i.GetShadersStore=function(o){return o===void 0&&(o=0),o===0?i.ShadersStore:i.ShadersStoreWGSL},i.GetIncludesShadersStore=function(o){return o===void 0&&(o=0),o===0?i.IncludesShadersStore:i.IncludesShadersStoreWGSL},i.ShadersRepository="src/Shaders/",i.ShadersStore={},i.IncludesShadersStore={},i.ShadersRepositoryWGSL="src/ShadersWGSL/",i.ShadersStoreWGSL={},i.IncludesShadersStoreWGSL={},i}()},53399:(r,t,e)=>{e.d(t,{C5:()=>E,Cm:()=>l,EX:()=>u,GX:()=>d,N5:()=>s,YM:()=>m,bS:()=>C,kf:()=>c,tI:()=>h,tg:()=>p});var n=e(14737),i=e(24894),o=new WeakMap,a={_webGLVersion:2,cachedPipelines:{}};function s(T){var f=o.get(T);if(!f){if(!T)return a;f={_webGLVersion:T.TEXTURE_BINDING_3D?2:1,_context:T,cachedPipelines:{}},o.set(T,f)}return f}function l(T){o.delete(T)}function c(T,f,g,S,y,x){var R,I=s(S);return x||(x=(R=I._createShaderProgramInjection)!==null&&R!==void 0?R:h),x(T,b(f,"vertex",S,I._contextWasLost),b(g,"fragment",S,I._contextWasLost),S,y,I.validateShaderPrograms)}function u(T,f,g,S,y,x,R){var I;x===void 0&&(x=null);var M=s(y);R||(R=(I=M._createShaderProgramInjection)!==null&&I!==void 0?I:h);var D=M._webGLVersion>1?`#version 300 es
|
||
#define WEBGL2
|
||
`:"";return R(T,v(f,"vertex",S,D,y,M._contextWasLost),v(g,"fragment",S,D,y,M._contextWasLost),y,x,M.validateShaderPrograms)}function d(T,f){var g=new n.x,S=s(T);return S.parallelShaderCompile&&(g.isParallelCompiled=!0),g.context=S._context,g}function h(T,f,g,S,y,x){var R=S.createProgram();if(T.program=R,!R)throw new Error("Unable to create program");return S.attachShader(R,f),S.attachShader(R,g),S.linkProgram(R),T.context=S,T.vertexShader=f,T.fragmentShader=g,T.isParallelCompiled||p(T,S,x),R}function p(T,f,g){var S=T.context,y=T.vertexShader,x=T.fragmentShader,R=T.program;if(!S.getProgramParameter(R,S.LINK_STATUS)){var I,M;if(!f.getShaderParameter(y,f.COMPILE_STATUS)&&(I=f.getShaderInfoLog(y)))throw T.vertexCompilationError=I,new Error("VERTEX SHADER "+I);if(!f.getShaderParameter(x,f.COMPILE_STATUS)&&(I=f.getShaderInfoLog(x)))throw T.fragmentCompilationError=I,new Error("FRAGMENT SHADER "+I);if(M=S.getProgramInfoLog(R))throw T.programLinkError=M,new Error(M)}if(g&&(S.validateProgram(R),!S.getProgramParameter(R,S.VALIDATE_STATUS)&&(M=S.getProgramInfoLog(R))))throw T.programValidationError=M,new Error(M);S.deleteShader(y),S.deleteShader(x),T.vertexShader=void 0,T.fragmentShader=void 0,T.onCompiled&&(T.onCompiled(),T.onCompiled=void 0)}function m(T,f,g,S,y,x,R,I,M,D,B,F,X){var $,Q,ie=s(T.context);F||(F=($=ie.createRawShaderProgramInjection)!==null&&$!==void 0?$:c),X||(X=(Q=ie.createShaderProgramInjection)!==null&&Q!==void 0?Q:u);var q=T;q.program=S?F(q,f,g,q.context,M):X(q,f,g,I,q.context,M),q.program.__SPECTOR_rebuildProgram=R,B()}function v(T,f,g,S,y,x){return b((0,i.iL)(T,g,S),f,y,x)}function b(T,f,g,S){var y=g.createShader(f==="vertex"?g.VERTEX_SHADER:g.FRAGMENT_SHADER);if(!y){for(var x=g.NO_ERROR,R=g.NO_ERROR;(R=g.getError())!==g.NO_ERROR;)x=R;throw new Error("Something went wrong while creating a gl ".concat(f," shader object. gl error=").concat(x,", gl isContextLost=").concat(g.isContextLost(),", _contextWasLost=").concat(S))}return g.shaderSource(y,T),g.compileShader(y),y}function E(T,f){f.useProgram(T)}function C(T,f){var g=T;if(g.isParallelCompiled){var S=g.onCompiled;g.onCompiled=function(){S?.(),f(T)}}else f(T)}},96352:(r,t,e)=>{e.d(t,{w:()=>f});var n=e(78322),i=e(53399),o=e(92118),a=e(7164),s=e(5153),l=function(){function g(){this.shaderLanguage=0}return g.prototype.postProcessor=function(S,y,x,R,I){return I.drawBuffersExtensionDisabled&&(S=S.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g,"")),S},g}(),c=e(24054),u=e(26218),d=e(87074),h=e(82673),p=e(81152),m=e(90519),v=e(19133),b=e(74239),E=e(24894),C=e(76320),T=function(){},f=function(g){function S(y,x,R,I){var M=this;if(R=R||{},(M=g.call(this,x??R.antialias,R,I)||this)._name="WebGL",M.forcePOTTextures=!1,M.validateShaderPrograms=!1,M.disableUniformBuffers=!1,M._webGLVersion=1,M._vertexAttribArraysEnabled=[],M._uintIndicesCurrentlySet=!1,M._currentBoundBuffer=new Array,M._currentFramebuffer=null,M._dummyFramebuffer=null,M._currentBufferPointers=new Array,M._currentInstanceLocations=new Array,M._currentInstanceBuffers=new Array,M._vaoRecordInProgress=!1,M._mustWipeVertexAttributes=!1,M._nextFreeTextureSlots=new Array,M._maxSimultaneousTextures=0,M._maxMSAASamplesOverride=null,M._unpackFlipYCached=null,M.enableUnpackFlipYCached=!0,M._boundUniforms={},!y)return M;var D=null;if(y.getContext){if(D=y,M._renderingCanvas=D,R.preserveDrawingBuffer===void 0&&(R.preserveDrawingBuffer=!1),R.xrCompatible===void 0&&(R.xrCompatible=!1),navigator&&navigator.userAgent){M._setupMobileChecks();for(var B=navigator.userAgent,F=0,X=S.ExceptionList;F<X.length;F++){var $=X[F],Q=$.key,ie=$.targets;if(new RegExp(Q).test(B)){if($.capture&&$.captureConstraint){var q=$.capture,ee=$.captureConstraint,te=new RegExp(q).exec(B);if(te&&te.length>0&&parseInt(te[te.length-1])>=ee)continue}for(var ce=0,fe=ie;ce<fe.length;ce++)switch(fe[ce]){case"uniformBuffer":M.disableUniformBuffers=!0;break;case"vao":M.disableVertexArrayObjects=!0;break;case"antialias":R.antialias=!1;break;case"maxMSAASamples":M._maxMSAASamplesOverride=1}}}}if(M._doNotHandleContextLost||(M._onContextLost=function(N){N.preventDefault(),M._contextWasLost=!0,a.V.Warn("WebGL context lost."),M.onContextLostObservable.notifyObservers(M)},M._onContextRestored=function(){M._restoreEngineAfterContextLost(function(){return M._initGLContext()})},D.addEventListener("webglcontextlost",M._onContextLost,!1),D.addEventListener("webglcontextrestored",M._onContextRestored,!1),R.powerPreference=R.powerPreference||"high-performance"),M._badDesktopOS&&(R.xrCompatible=!1),!R.disableWebGL2Support)try{M._gl=D.getContext("webgl2",R)||D.getContext("experimental-webgl2",R),M._gl&&(M._webGLVersion=2,M._shaderPlatformName="WEBGL2",M._gl.deleteQuery||(M._webGLVersion=1,M._shaderPlatformName="WEBGL1"))}catch{}if(!M._gl){if(!D)throw new Error("The provided canvas is null or undefined.");try{M._gl=D.getContext("webgl",R)||D.getContext("experimental-webgl",R)}catch{throw new Error("WebGL not supported")}}if(!M._gl)throw new Error("WebGL not supported")}else{M._gl=y,M._renderingCanvas=M._gl.canvas,M._gl.renderbufferStorageMultisample?(M._webGLVersion=2,M._shaderPlatformName="WEBGL2"):M._shaderPlatformName="WEBGL1";var de=M._gl.getContextAttributes();de&&(R.stencil=de.stencil)}M._gl.pixelStorei(M._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,M._gl.NONE),R.useHighPrecisionFloats!==void 0&&(M._highPrecisionShadersAllowed=R.useHighPrecisionFloats),M.resize(),M._initGLContext(),M._initFeatures();for(var Te=0;Te<M._caps.maxVertexAttribs;Te++)M._currentBufferPointers[Te]=new T;M._shaderProcessor=M.webGLVersion>1?new c.B:new l;var ue="Babylon.js v".concat(S.Version);a.V.Log(ue+" - ".concat(M.description)),M._renderingCanvas&&M._renderingCanvas.setAttribute&&M._renderingCanvas.setAttribute("data-engine",ue);var U=(0,i.N5)(M._gl);return U.validateShaderPrograms=M.validateShaderPrograms,U.parallelShaderCompile=M._caps.parallelShaderCompile,M}return(0,n.C6)(S,g),Object.defineProperty(S.prototype,"name",{get:function(){return this._name},set:function(y){this._name=y},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"version",{get:function(){return this._webGLVersion},enumerable:!1,configurable:!0}),Object.defineProperty(S,"ShadersRepository",{get:function(){return b.M.ShadersRepository},set:function(y){b.M.ShadersRepository=y},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"framebufferDimensionsObject",{set:function(y){this._framebufferDimensionsObject=y},enumerable:!1,configurable:!0}),S.prototype.snapshotRenderingReset=function(){this.snapshotRendering=!1},S.prototype._clearEmptyResources=function(){this._dummyFramebuffer=null,g.prototype._clearEmptyResources.call(this)},S.prototype._getShaderProcessingContext=function(y){return null},S.prototype.areAllEffectsReady=function(){for(var y in this._compiledEffects)if(!this._compiledEffects[y].isReady())return!1;return!0},S.prototype._initGLContext=function(){var y;this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||this._gl.getExtension("OES_standard_derivatives")!==null,maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||this._gl.getExtension("OES_element_index_uint")!==null,fragmentDepthSupported:this._webGLVersion>1||this._gl.getExtension("EXT_frag_depth")!==null,highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:this._webGLVersion!==1,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);var x=this._gl.getExtension("WEBGL_debug_renderer_info");if(x!=null&&(this._glRenderer=this._gl.getParameter(x.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(x.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),this._gl.HALF_FLOAT_OES!==36193&&(this._gl.HALF_FLOAT_OES=36193),this._gl.RGBA16F!==34842&&(this._gl.RGBA16F=34842),this._gl.RGBA32F!==34836&&(this._gl.RGBA32F=34836),this._gl.DEPTH24_STENCIL8!==35056&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(this._webGLVersion===1&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=((y=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT))!==null&&y!==void 0?y:0)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),this._caps.bptc&&(this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),this._caps.s3tc_srgb&&(this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),this._caps.etc2&&(this._gl.COMPRESSED_SRGB8_ETC2=this._caps.etc2.COMPRESSED_SRGB8_ETC2,this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC),this._webGLVersion>1&&this._gl.HALF_FLOAT_OES!==5131&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=this._maxMSAASamplesOverride!==null?this._maxMSAASamplesOverride:this._gl.getParameter(this._gl.MAX_SAMPLES),this._caps.maxDrawBuffers=this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);else{var R=this._gl.getExtension("WEBGL_draw_buffers");if(R!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=R.drawBuffersWEBGL.bind(R),this._caps.maxDrawBuffers=this._gl.getParameter(R.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var I=0;I<16;I++)this._gl["COLOR_ATTACHMENT"+I+"_WEBGL"]=R["COLOR_ATTACHMENT"+I+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var M=this._gl.getExtension("WEBGL_depth_texture");M!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=M.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var D=this._gl.getExtension("OES_vertex_array_object");D!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=D.createVertexArrayOES.bind(D),this._gl.bindVertexArray=D.bindVertexArrayOES.bind(D),this._gl.deleteVertexArray=D.deleteVertexArrayOES.bind(D))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var B=this._gl.getExtension("ANGLE_instanced_arrays");B!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=B.drawArraysInstancedANGLE.bind(B),this._gl.drawElementsInstanced=B.drawElementsInstancedANGLE.bind(B),this._gl.vertexAttribDivisor=B.vertexAttribDivisorANGLE.bind(B)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){var F=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),X=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);F&&X&&(this._caps.highPrecisionShaderSupported=F.precision!==0&&X.precision!==0)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{var $=this._gl.getExtension("EXT_blend_minmax");$!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=$.MAX_EXT,this._gl.MIN=$.MIN_EXT)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:WebGL2RenderingContext.SRGB,SRGB8:WebGL2RenderingContext.SRGB8,SRGB8_ALPHA8:WebGL2RenderingContext.SRGB8_ALPHA8};else{var Q=this._gl.getExtension("EXT_sRGB");Q!=null&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:Q.SRGB_EXT,SRGB8:Q.SRGB_ALPHA_EXT,SRGB8_ALPHA8:Q.SRGB_ALPHA_EXT})}if(this._creationOptions){var ie=this._creationOptions.forceSRGBBufferSupportState;ie!==void 0&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&ie)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var q=0;q<this._maxSimultaneousTextures;q++)this._nextFreeTextureSlots.push(q);this._glRenderer==="Mali-G72"&&(this._caps.disableMorphTargetTexture=!0)},S.prototype._initFeatures=function(){this._features={forceBitmapOverHTMLImageElement:typeof HTMLImageElement>"u",supportRenderAndCopyToLodForFloatTextures:this._webGLVersion!==1,supportDepthStencilTexture:this._webGLVersion!==1,supportShadowSamplers:this._webGLVersion!==1,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:this._webGLVersion!==1,trackUbosInFrame:!1,checkUbosContentBeforeUpload:!1,supportCSM:this._webGLVersion!==1,basisNeedsPOT:this._webGLVersion===1,support3DTextures:this._webGLVersion!==1,needTypeSuffixInShaderConstants:this._webGLVersion!==1,supportMSAA:this._webGLVersion!==1,supportSSAO2:this._webGLVersion!==1,supportIBLShadows:this._webGLVersion!==1,supportExtendedTextureFormats:this._webGLVersion!==1,supportSwitchCaseInShader:this._webGLVersion!==1,supportSyncTextureRead:!0,needsInvertingBitmap:!0,useUBOBindingCache:!0,needShaderCodeInlining:!1,needToAlwaysBindUniformBuffers:!1,supportRenderPasses:!1,supportSpriteInstancing:!0,forceVertexBufferStrideAndOffsetMultiple4Bytes:!1,_checkNonFloatVertexBuffersDontRecreatePipelineContext:!1,_collectUbosUpdatedInFrame:!1}},Object.defineProperty(S.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!1,configurable:!0}),S.prototype.getClassName=function(){return"ThinEngine"},S.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=this.createCanvas(1,1);var y=this._workingCanvas.getContext("2d");y&&(this._workingContext=y)}},S.prototype.getInfo=function(){return this.getGlInfo()},S.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},S.prototype.extractDriverInfo=function(){var y=this.getGlInfo();return y&&y.renderer?y.renderer:""},S.prototype.getRenderWidth=function(y){return y===void 0&&(y=!1),!y&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth},S.prototype.getRenderHeight=function(y){return y===void 0&&(y=!1),!y&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight},S.prototype.clear=function(y,x,R,I){var M,D;I===void 0&&(I=!1);var B=this.stencilStateComposer.useStencilGlobalOnly;this.stencilStateComposer.useStencilGlobalOnly=!0,this.applyStates(),this.stencilStateComposer.useStencilGlobalOnly=B;var F=0;if(x&&y){var X=!0;if(this._currentRenderTarget){var $=(M=this._currentRenderTarget.texture)===null||M===void 0?void 0:M.format;if($===p.Y.TEXTUREFORMAT_RED_INTEGER||$===p.Y.TEXTUREFORMAT_RG_INTEGER||$===p.Y.TEXTUREFORMAT_RGB_INTEGER||$===p.Y.TEXTUREFORMAT_RGBA_INTEGER){var Q=(D=this._currentRenderTarget.texture)===null||D===void 0?void 0:D.type;Q===p.Y.TEXTURETYPE_UNSIGNED_INTEGER||Q===p.Y.TEXTURETYPE_UNSIGNED_SHORT?(S._TempClearColorUint32[0]=255*y.r,S._TempClearColorUint32[1]=255*y.g,S._TempClearColorUint32[2]=255*y.b,S._TempClearColorUint32[3]=255*y.a,this._gl.clearBufferuiv(this._gl.COLOR,0,S._TempClearColorUint32),X=!1):(S._TempClearColorInt32[0]=255*y.r,S._TempClearColorInt32[1]=255*y.g,S._TempClearColorInt32[2]=255*y.b,S._TempClearColorInt32[3]=255*y.a,this._gl.clearBufferiv(this._gl.COLOR,0,S._TempClearColorInt32),X=!1)}}X&&(this._gl.clearColor(y.r,y.g,y.b,y.a!==void 0?y.a:1),F|=this._gl.COLOR_BUFFER_BIT)}R&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GEQUAL,this._gl.clearDepth(0)):this._gl.clearDepth(1),F|=this._gl.DEPTH_BUFFER_BIT),I&&(this._gl.clearStencil(0),F|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(F)},S.prototype._viewport=function(y,x,R,I){y===this._viewportCached.x&&x===this._viewportCached.y&&R===this._viewportCached.z&&I===this._viewportCached.w||(this._viewportCached.x=y,this._viewportCached.y=x,this._viewportCached.z=R,this._viewportCached.w=I,this._gl.viewport(y,x,R,I))},S.prototype.endFrame=function(){g.prototype.endFrame.call(this),this._badOS&&this.flushFramebuffer()},Object.defineProperty(S.prototype,"performanceMonitor",{get:function(){throw new Error("Not Supported by ThinEngine")},enumerable:!1,configurable:!0}),S.prototype.bindFramebuffer=function(y,x,R,I,M,D,B){var F,X,$,Q,ie,q;x===void 0&&(x=0),D===void 0&&(D=0),B===void 0&&(B=0);var ee=y;this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=y,this._bindUnboundFramebuffer(ee._framebuffer);var te=this._gl;y.isMulti||(y.is2DArray||y.is3D?(te.framebufferTextureLayer(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,(F=y.texture._hardwareTexture)===null||F===void 0?void 0:F.underlyingResource,D,B),ee._currentLOD=D):y.isCube?te.framebufferTexture2D(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,te.TEXTURE_CUBE_MAP_POSITIVE_X+x,(X=y.texture._hardwareTexture)===null||X===void 0?void 0:X.underlyingResource,D):ee._currentLOD!==D&&(te.framebufferTexture2D(te.FRAMEBUFFER,te.COLOR_ATTACHMENT0,te.TEXTURE_2D,($=y.texture._hardwareTexture)===null||$===void 0?void 0:$.underlyingResource,D),ee._currentLOD=D));var ce=y._depthStencilTexture;if(ce){y.is3D&&(y.texture.width===ce.width&&y.texture.height===ce.height&&y.texture.depth===ce.depth||a.V.Warn("Depth/Stencil attachment for 3D target must have same dimensions as color attachment"));var fe=y._depthStencilTextureWithStencil?te.DEPTH_STENCIL_ATTACHMENT:te.DEPTH_ATTACHMENT;y.is2DArray||y.is3D?te.framebufferTextureLayer(te.FRAMEBUFFER,fe,(Q=ce._hardwareTexture)===null||Q===void 0?void 0:Q.underlyingResource,D,B):y.isCube?te.framebufferTexture2D(te.FRAMEBUFFER,fe,te.TEXTURE_CUBE_MAP_POSITIVE_X+x,(ie=ce._hardwareTexture)===null||ie===void 0?void 0:ie.underlyingResource,D):te.framebufferTexture2D(te.FRAMEBUFFER,fe,te.TEXTURE_2D,(q=ce._hardwareTexture)===null||q===void 0?void 0:q.underlyingResource,D)}ee._MSAAFramebuffer&&this._bindUnboundFramebuffer(ee._MSAAFramebuffer),this._cachedViewport&&!M?this.setViewport(this._cachedViewport,R,I):(R||(R=y.width,D&&(R/=Math.pow(2,D))),I||(I=y.height,D&&(I/=Math.pow(2,D))),this._viewport(0,0,R,I)),this.wipeCaches()},S.prototype.setState=function(y,x,R,I,M,D,B){var F,X;x===void 0&&(x=0),I===void 0&&(I=!1),B===void 0&&(B=0),(this._depthCullingState.cull!==y||R)&&(this._depthCullingState.cull=y);var $=(X=(F=this.cullBackFaces)!==null&&F!==void 0?F:M)===null||X===void 0||X?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==$||R)&&(this._depthCullingState.cullFace=$),this.setZOffset(x),this.setZOffsetUnits(B);var Q=I?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==Q||R)&&(this._depthCullingState.frontFace=Q),this._stencilStateComposer.stencilMaterial=D},S.prototype._bindUnboundFramebuffer=function(y){this._currentFramebuffer!==y&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,y),this._currentFramebuffer=y)},S.prototype._currentFrameBufferIsDefaultFrameBuffer=function(){return this._currentFramebuffer===null},S.prototype.generateMipmaps=function(y){var x=this._getTextureTarget(y);this._bindTextureDirectly(x,y,!0),this._gl.generateMipmap(x),this._bindTextureDirectly(x,null)},S.prototype.unBindFramebuffer=function(y,x,R){var I;x===void 0&&(x=!1);var M=y;this._currentRenderTarget=null;var D=this._gl;if(M._MSAAFramebuffer){if(y.isMulti)return void this.unBindMultiColorAttachmentFramebuffer(y,x,R);D.bindFramebuffer(D.READ_FRAMEBUFFER,M._MSAAFramebuffer),D.bindFramebuffer(D.DRAW_FRAMEBUFFER,M._framebuffer),D.blitFramebuffer(0,0,y.width,y.height,0,0,y.width,y.height,D.COLOR_BUFFER_BIT,D.NEAREST)}!(!((I=y.texture)===null||I===void 0)&&I.generateMipMaps)||x||y.isCube||this.generateMipmaps(y.texture),R&&(M._MSAAFramebuffer&&this._bindUnboundFramebuffer(M._framebuffer),R()),this._bindUnboundFramebuffer(null)},S.prototype.flushFramebuffer=function(){this._gl.flush()},S.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},S.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},S.prototype.createVertexBuffer=function(y,x,R){return this._createVertexBuffer(y,this._gl.STATIC_DRAW)},S.prototype._createVertexBuffer=function(y,x){var R=this._gl.createBuffer();if(!R)throw new Error("Unable to create vertex buffer");var I=new u.A(R);return this.bindArrayBuffer(I),typeof y!="number"?y instanceof Array?(this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(y),x),I.capacity=4*y.length):(this._gl.bufferData(this._gl.ARRAY_BUFFER,y,x),I.capacity=y.byteLength):(this._gl.bufferData(this._gl.ARRAY_BUFFER,new Uint8Array(y),x),I.capacity=y),this._resetVertexBufferBinding(),I.references=1,I},S.prototype.createDynamicVertexBuffer=function(y,x){return this._createVertexBuffer(y,this._gl.DYNAMIC_DRAW)},S.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},S.prototype.createIndexBuffer=function(y,x,R){var I=this._gl.createBuffer(),M=new u.A(I);if(!I)throw new Error("Unable to create index buffer");this.bindIndexBuffer(M);var D=this._normalizeIndexData(y);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,D,x?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),M.references=1,M.is32Bits=D.BYTES_PER_ELEMENT===4,M},S.prototype._normalizeIndexData=function(y){if(y.BYTES_PER_ELEMENT===2)return y;if(this._caps.uintIndices){if(y instanceof Uint32Array)return y;for(var x=0;x<y.length;x++)if(y[x]>=65535)return new Uint32Array(y);return new Uint16Array(y)}return new Uint16Array(y)},S.prototype.bindArrayBuffer=function(y){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(y,this._gl.ARRAY_BUFFER)},S.prototype.bindUniformBlock=function(y,x,R){var I=y.program,M=this._gl.getUniformBlockIndex(I,x);this._gl.uniformBlockBinding(I,M,R)},S.prototype.bindIndexBuffer=function(y){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(y,this._gl.ELEMENT_ARRAY_BUFFER)},S.prototype._bindBuffer=function(y,x){(this._vaoRecordInProgress||this._currentBoundBuffer[x]!==y)&&(this._gl.bindBuffer(x,y?y.underlyingResource:null),this._currentBoundBuffer[x]=y)},S.prototype.updateArrayBuffer=function(y){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,y)},S.prototype._vertexAttribPointer=function(y,x,R,I,M,D,B){var F=this._currentBufferPointers[x];if(F){var X=!1;F.active?(F.buffer!==y&&(F.buffer=y,X=!0),F.size!==R&&(F.size=R,X=!0),F.type!==I&&(F.type=I,X=!0),F.normalized!==M&&(F.normalized=M,X=!0),F.stride!==D&&(F.stride=D,X=!0),F.offset!==B&&(F.offset=B,X=!0)):(X=!0,F.active=!0,F.index=x,F.size=R,F.type=I,F.normalized=M,F.stride=D,F.offset=B,F.buffer=y),(X||this._vaoRecordInProgress)&&(this.bindArrayBuffer(y),I===this._gl.UNSIGNED_INT||I===this._gl.INT?this._gl.vertexAttribIPointer(x,R,I,D,B):this._gl.vertexAttribPointer(x,R,I,M,D,B))}},S.prototype._bindIndexBufferWithCache=function(y){y!=null&&this._cachedIndexBuffer!==y&&(this._cachedIndexBuffer=y,this.bindIndexBuffer(y),this._uintIndicesCurrentlySet=y.is32Bits)},S.prototype._bindVertexBuffersAttributes=function(y,x,R){var I=x.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var M=0;M<I.length;M++){var D=x.getAttributeLocation(M);if(D>=0){var B=I[M],F=null;if(R&&(F=R[B]),F||(F=y[B]),!F)continue;this._gl.enableVertexAttribArray(D),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[D]=!0);var X=F.getBuffer();X&&(this._vertexAttribPointer(X,D,F.getSize(),F.type,F.normalized,F.byteStride,F.byteOffset),F.getIsInstanced()&&(this._gl.vertexAttribDivisor(D,F.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(D),this._currentInstanceBuffers.push(X))))}}},S.prototype.recordVertexArrayObject=function(y,x,R,I){var M=this._gl.createVertexArray();if(!M)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(M),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(y,R,I),this.bindIndexBuffer(x),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),M},S.prototype.bindVertexArrayObject=function(y,x){this._cachedVertexArrayObject!==y&&(this._cachedVertexArrayObject=y,this._gl.bindVertexArray(y),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=x!=null&&x.is32Bits,this._mustWipeVertexAttributes=!0)},S.prototype.bindBuffersDirectly=function(y,x,R,I,M){if(this._cachedVertexBuffers!==y||this._cachedEffectForVertexBuffers!==M){this._cachedVertexBuffers=y,this._cachedEffectForVertexBuffers=M;var D=M.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var B=0,F=0;F<D;F++)if(F<R.length){var X=M.getAttributeLocation(F);X>=0&&(this._gl.enableVertexAttribArray(X),this._vertexAttribArraysEnabled[X]=!0,this._vertexAttribPointer(y,X,R[F],this._gl.FLOAT,!1,I,B)),B+=4*R[F]}}this._bindIndexBufferWithCache(x)},S.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},S.prototype.bindBuffers=function(y,x,R,I){this._cachedVertexBuffers===y&&this._cachedEffectForVertexBuffers===R||(this._cachedVertexBuffers=y,this._cachedEffectForVertexBuffers=R,this._bindVertexBuffersAttributes(y,R,I)),this._bindIndexBufferWithCache(x)},S.prototype.unbindInstanceAttributes=function(){for(var y,x=0,R=this._currentInstanceLocations.length;x<R;x++){var I=this._currentInstanceBuffers[x];y!=I&&I.references&&(y=I,this.bindArrayBuffer(I));var M=this._currentInstanceLocations[x];this._gl.vertexAttribDivisor(M,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0},S.prototype.releaseVertexArrayObject=function(y){this._gl.deleteVertexArray(y)},S.prototype._releaseBuffer=function(y){return y.references--,y.references===0&&(this._deleteBuffer(y),!0)},S.prototype._deleteBuffer=function(y){this._gl.deleteBuffer(y.underlyingResource)},S.prototype.updateAndBindInstancesBuffer=function(y,x,R){if(this.bindArrayBuffer(y),x&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,x),R[0].index!==void 0)this.bindInstancesBuffer(y,R,!0);else for(var I=0;I<4;I++){var M=R[I];this._vertexAttribArraysEnabled[M]||(this._gl.enableVertexAttribArray(M),this._vertexAttribArraysEnabled[M]=!0),this._vertexAttribPointer(y,M,4,this._gl.FLOAT,!1,64,16*I),this._gl.vertexAttribDivisor(M,1),this._currentInstanceLocations.push(M),this._currentInstanceBuffers.push(y)}},S.prototype.bindInstancesBuffer=function(y,x,R){R===void 0&&(R=!0),this.bindArrayBuffer(y);var I=0;if(R)for(var M=0;M<x.length;M++)I+=4*(D=x[M]).attributeSize;for(M=0;M<x.length;M++){var D;(D=x[M]).index===void 0&&(D.index=this._currentEffect.getAttributeLocationByName(D.attributeName)),D.index<0||(this._vertexAttribArraysEnabled[D.index]||(this._gl.enableVertexAttribArray(D.index),this._vertexAttribArraysEnabled[D.index]=!0),this._vertexAttribPointer(y,D.index,D.attributeSize,D.attributeType||this._gl.FLOAT,D.normalized||!1,I,D.offset),this._gl.vertexAttribDivisor(D.index,D.divisor===void 0?1:D.divisor),this._currentInstanceLocations.push(D.index),this._currentInstanceBuffers.push(y))}},S.prototype.disableInstanceAttributeByName=function(y){if(this._currentEffect){var x=this._currentEffect.getAttributeLocationByName(y);this.disableInstanceAttribute(x)}},S.prototype.disableInstanceAttribute=function(y){for(var x,R=!1;(x=this._currentInstanceLocations.indexOf(y))!==-1;)this._currentInstanceLocations.splice(x,1),this._currentInstanceBuffers.splice(x,1),R=!0,x=this._currentInstanceLocations.indexOf(y);R&&(this._gl.vertexAttribDivisor(y,0),this.disableAttributeByIndex(y))},S.prototype.disableAttributeByIndex=function(y){this._gl.disableVertexAttribArray(y),this._vertexAttribArraysEnabled[y]=!1,this._currentBufferPointers[y].active=!1},S.prototype.draw=function(y,x,R,I){this.drawElementsType(y?p.Y.MATERIAL_TriangleFillMode:p.Y.MATERIAL_WireFrameFillMode,x,R,I)},S.prototype.drawPointClouds=function(y,x,R){this.drawArraysType(p.Y.MATERIAL_PointFillMode,y,x,R)},S.prototype.drawUnIndexed=function(y,x,R,I){this.drawArraysType(y?p.Y.MATERIAL_TriangleFillMode:p.Y.MATERIAL_WireFrameFillMode,x,R,I)},S.prototype.drawElementsType=function(y,x,R,I){this.applyStates(),this._reportDrawCall();var M=this._drawMode(y),D=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,B=this._uintIndicesCurrentlySet?4:2;I?this._gl.drawElementsInstanced(M,R,D,x*B,I):this._gl.drawElements(M,R,D,x*B)},S.prototype.drawArraysType=function(y,x,R,I){this.applyStates(),this._reportDrawCall();var M=this._drawMode(y);I?this._gl.drawArraysInstanced(M,x,R,I):this._gl.drawArrays(M,x,R)},S.prototype._drawMode=function(y){switch(y){case p.Y.MATERIAL_TriangleFillMode:return this._gl.TRIANGLES;case p.Y.MATERIAL_PointFillMode:return this._gl.POINTS;case p.Y.MATERIAL_WireFrameFillMode:return this._gl.LINES;case p.Y.MATERIAL_PointListDrawMode:return this._gl.POINTS;case p.Y.MATERIAL_LineListDrawMode:return this._gl.LINES;case p.Y.MATERIAL_LineLoopDrawMode:return this._gl.LINE_LOOP;case p.Y.MATERIAL_LineStripDrawMode:return this._gl.LINE_STRIP;case p.Y.MATERIAL_TriangleStripDrawMode:return this._gl.TRIANGLE_STRIP;case p.Y.MATERIAL_TriangleFanDrawMode:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}},S.prototype._releaseEffect=function(y){this._compiledEffects[y._key]&&delete this._compiledEffects[y._key];var x=y.getPipelineContext();x&&this._deletePipelineContext(x)},S.prototype._deletePipelineContext=function(y){var x=y;x&&x.program&&(x.program.__SPECTOR_rebuildProgram=null,(0,C.mO)(x),this._gl.deleteProgram(x.program))},S.prototype._getGlobalDefines=function(y){return(0,E.xt)(y,this.isNDCHalfZRange,this.useReverseDepthBuffer,this.useExactSrgbConversions)},S.prototype.createEffect=function(y,x,R,I,M,D,B,F,X,$,Q){var ie,q,ee;$===void 0&&($=0);var te=typeof y=="string"?y:y.vertexToken||y.vertexSource||y.vertexElement||y.vertex,ce=typeof y=="string"?y:y.fragmentToken||y.fragmentSource||y.fragmentElement||y.fragment,fe=this._getGlobalDefines(),de=(ie=M??x.defines)!==null&&ie!==void 0?ie:"";fe&&(de+=fe);var Te=te+"+"+ce+"@"+de;if(this._compiledEffects[Te]){var ue=this._compiledEffects[Te];return B&&ue.isReady()&&B(ue),ue._refCount++,ue}this._gl&&(0,i.N5)(this._gl);var U=new b.M(y,x,R,I,this,M,D,B,F,X,Te,(q=x.shaderLanguage)!==null&&q!==void 0?q:$,(ee=x.extraInitializationsAsync)!==null&&ee!==void 0?ee:Q);return this._compiledEffects[Te]=U,U},S.prototype._getShaderSource=function(y){return this._gl.getShaderSource(y)},S.prototype.createRawShaderProgram=function(y,x,R,I,M){M===void 0&&(M=null);var D=(0,i.N5)(this._gl);return D._contextWasLost=this._contextWasLost,D.validateShaderPrograms=this.validateShaderPrograms,(0,i.kf)(y,x,R,I||this._gl,M)},S.prototype.createShaderProgram=function(y,x,R,I,M,D){D===void 0&&(D=null);var B=(0,i.N5)(this._gl);return B._contextWasLost=this._contextWasLost,B.validateShaderPrograms=this.validateShaderPrograms,(0,i.EX)(y,x,R,I,M||this._gl,D)},S.prototype.inlineShaderCode=function(y){return y},S.prototype.createPipelineContext=function(y){this._gl&&((0,i.N5)(this._gl).parallelShaderCompile=this._caps.parallelShaderCompile);var x=(0,i.GX)(this._gl,y);return x.engine=this,x},S.prototype.createMaterialContext=function(){},S.prototype.createDrawContext=function(){},S.prototype._finalizePipelineContext=function(y){return(0,i.tg)(y,this._gl,this.validateShaderPrograms)},S.prototype._preparePipelineContext=function(y,x,R,I,M,D,B,F,X,$,Q){var ie=(0,i.N5)(this._gl);return ie._contextWasLost=this._contextWasLost,ie.validateShaderPrograms=this.validateShaderPrograms,ie._createShaderProgramInjection=this._createShaderProgram.bind(this),ie.createRawShaderProgramInjection=this.createRawShaderProgram.bind(this),ie.createShaderProgramInjection=this.createShaderProgram.bind(this),ie.loadFileInjection=this._loadFile.bind(this),(0,i.YM)(y,x,R,I,M,D,B,F,X,$,Q)},S.prototype._createShaderProgram=function(y,x,R,I,M){return M===void 0&&(M=null),(0,i.tI)(y,x,R,I,M)},S.prototype._isRenderingStateCompiled=function(y){var x=y;return!(this._isDisposed||x._isDisposed||!this._gl.getProgramParameter(x.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)||(this._finalizePipelineContext(x),0))},S.prototype._executeWhenRenderingStateIsCompiled=function(y,x){(0,i.bS)(y,x)},S.prototype.getUniforms=function(y,x){for(var R=new Array,I=y,M=0;M<x.length;M++)R.push(this._gl.getUniformLocation(I.program,x[M]));return R},S.prototype.getAttributes=function(y,x){for(var R=[],I=y,M=0;M<x.length;M++)try{R.push(this._gl.getAttribLocation(I.program,x[M]))}catch{R.push(-1)}return R},S.prototype.enableEffect=function(y){(y=y!==null&&(0,o.E)(y)?y.effect:y)&&y!==this._currentEffect&&(this._stencilStateComposer.stencilMaterial=void 0,this.bindSamplers(y),this._currentEffect=y,y.onBind&&y.onBind(y),y._onBindObservable&&y._onBindObservable.notifyObservers(y))},S.prototype.setInt=function(y,x){return!!y&&(this._gl.uniform1i(y,x),!0)},S.prototype.setInt2=function(y,x,R){return!!y&&(this._gl.uniform2i(y,x,R),!0)},S.prototype.setInt3=function(y,x,R,I){return!!y&&(this._gl.uniform3i(y,x,R,I),!0)},S.prototype.setInt4=function(y,x,R,I,M){return!!y&&(this._gl.uniform4i(y,x,R,I,M),!0)},S.prototype.setIntArray=function(y,x){return!!y&&(this._gl.uniform1iv(y,x),!0)},S.prototype.setIntArray2=function(y,x){return!(!y||x.length%2!=0||(this._gl.uniform2iv(y,x),0))},S.prototype.setIntArray3=function(y,x){return!(!y||x.length%3!=0||(this._gl.uniform3iv(y,x),0))},S.prototype.setIntArray4=function(y,x){return!(!y||x.length%4!=0||(this._gl.uniform4iv(y,x),0))},S.prototype.setUInt=function(y,x){return!!y&&(this._gl.uniform1ui(y,x),!0)},S.prototype.setUInt2=function(y,x,R){return!!y&&(this._gl.uniform2ui(y,x,R),!0)},S.prototype.setUInt3=function(y,x,R,I){return!!y&&(this._gl.uniform3ui(y,x,R,I),!0)},S.prototype.setUInt4=function(y,x,R,I,M){return!!y&&(this._gl.uniform4ui(y,x,R,I,M),!0)},S.prototype.setUIntArray=function(y,x){return!!y&&(this._gl.uniform1uiv(y,x),!0)},S.prototype.setUIntArray2=function(y,x){return!(!y||x.length%2!=0||(this._gl.uniform2uiv(y,x),0))},S.prototype.setUIntArray3=function(y,x){return!(!y||x.length%3!=0||(this._gl.uniform3uiv(y,x),0))},S.prototype.setUIntArray4=function(y,x){return!(!y||x.length%4!=0||(this._gl.uniform4uiv(y,x),0))},S.prototype.setArray=function(y,x){return!(!y||x.length<1||(this._gl.uniform1fv(y,x),0))},S.prototype.setArray2=function(y,x){return!(!y||x.length%2!=0||(this._gl.uniform2fv(y,x),0))},S.prototype.setArray3=function(y,x){return!(!y||x.length%3!=0||(this._gl.uniform3fv(y,x),0))},S.prototype.setArray4=function(y,x){return!(!y||x.length%4!=0||(this._gl.uniform4fv(y,x),0))},S.prototype.setMatrices=function(y,x){return!!y&&(this._gl.uniformMatrix4fv(y,!1,x),!0)},S.prototype.setMatrix3x3=function(y,x){return!!y&&(this._gl.uniformMatrix3fv(y,!1,x),!0)},S.prototype.setMatrix2x2=function(y,x){return!!y&&(this._gl.uniformMatrix2fv(y,!1,x),!0)},S.prototype.setFloat=function(y,x){return!!y&&(this._gl.uniform1f(y,x),!0)},S.prototype.setFloat2=function(y,x,R){return!!y&&(this._gl.uniform2f(y,x,R),!0)},S.prototype.setFloat3=function(y,x,R,I){return!!y&&(this._gl.uniform3f(y,x,R,I),!0)},S.prototype.setFloat4=function(y,x,R,I,M){return!!y&&(this._gl.uniform4f(y,x,R,I,M),!0)},S.prototype.applyStates=function(){if(this._depthCullingState.apply(this._gl),this._stencilStateComposer.apply(this._gl),this._alphaState.apply(this._gl),this._colorWriteChanged){this._colorWriteChanged=!1;var y=this._colorWrite;this._gl.colorMask(y,y,y,y)}},S.prototype.wipeCaches=function(y){this.preventCacheWipeBetweenFrames&&!y||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,this._unbindVertexArrayObject(),y&&(this._currentProgram=null,this.resetTextureCache(),this._stencilStateComposer.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=this._gl.LEQUAL,this._alphaState.reset(),this._alphaMode=p.Y.ALPHA_ADD,this._alphaEquation=p.Y.ALPHA_DISABLE,this._colorWrite=!0,this._colorWriteChanged=!0,this._unpackFlipYCached=null,this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this._mustWipeVertexAttributes=!0,this.unbindAllAttributes()),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this.bindIndexBuffer(null))},S.prototype._getSamplingParameters=function(y,x){var R=this._gl,I=R.NEAREST,M=R.NEAREST;switch(y){case p.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST:I=R.LINEAR,M=x?R.LINEAR_MIPMAP_NEAREST:R.LINEAR;break;case p.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR:I=R.LINEAR,M=x?R.LINEAR_MIPMAP_LINEAR:R.LINEAR;break;case p.Y.TEXTURE_NEAREST_NEAREST_MIPLINEAR:I=R.NEAREST,M=x?R.NEAREST_MIPMAP_LINEAR:R.NEAREST;break;case p.Y.TEXTURE_NEAREST_NEAREST_MIPNEAREST:I=R.NEAREST,M=x?R.NEAREST_MIPMAP_NEAREST:R.NEAREST;break;case p.Y.TEXTURE_NEAREST_LINEAR_MIPNEAREST:I=R.NEAREST,M=x?R.LINEAR_MIPMAP_NEAREST:R.LINEAR;break;case p.Y.TEXTURE_NEAREST_LINEAR_MIPLINEAR:I=R.NEAREST,M=x?R.LINEAR_MIPMAP_LINEAR:R.LINEAR;break;case p.Y.TEXTURE_NEAREST_LINEAR:I=R.NEAREST,M=R.LINEAR;break;case p.Y.TEXTURE_NEAREST_NEAREST:I=R.NEAREST,M=R.NEAREST;break;case p.Y.TEXTURE_LINEAR_NEAREST_MIPNEAREST:I=R.LINEAR,M=x?R.NEAREST_MIPMAP_NEAREST:R.NEAREST;break;case p.Y.TEXTURE_LINEAR_NEAREST_MIPLINEAR:I=R.LINEAR,M=x?R.NEAREST_MIPMAP_LINEAR:R.NEAREST;break;case p.Y.TEXTURE_LINEAR_LINEAR:I=R.LINEAR,M=R.LINEAR;break;case p.Y.TEXTURE_LINEAR_NEAREST:I=R.LINEAR,M=R.NEAREST}return{min:M,mag:I}},S.prototype._createTexture=function(){var y=this._gl.createTexture();if(!y)throw new Error("Unable to create texture");return y},S.prototype._createHardwareTexture=function(){return new m.d(this._createTexture(),this._gl)},S.prototype._createInternalTexture=function(y,x,R,I){var M;I===void 0&&(I=0);var D,B=!1,F=p.Y.TEXTURETYPE_UNSIGNED_INT,X=p.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,$=p.Y.TEXTUREFORMAT_RGBA,Q=!1,ie=1;x!==void 0&&typeof x=="object"?(B=!!x.generateMipMaps,F=x.type===void 0?p.Y.TEXTURETYPE_UNSIGNED_INT:x.type,X=x.samplingMode===void 0?p.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:x.samplingMode,$=x.format===void 0?p.Y.TEXTUREFORMAT_RGBA:x.format,Q=x.useSRGBBuffer!==void 0&&x.useSRGBBuffer,ie=(M=x.samples)!==null&&M!==void 0?M:1,D=x.label):B=!!x,Q&&(Q=this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU)),(F!==p.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(F!==p.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(X=p.Y.TEXTURE_NEAREST_SAMPLINGMODE),F!==p.Y.TEXTURETYPE_FLOAT||this._caps.textureFloat||(F=p.Y.TEXTURETYPE_UNSIGNED_INT,a.V.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));var q=this._gl,ee=new v.h(this,I),te=y.width||y,ce=y.height||y,fe=y.depth||0,de=y.layers||0,Te=this._getSamplingParameters(X,B),ue=de!==0?q.TEXTURE_2D_ARRAY:fe!==0?q.TEXTURE_3D:q.TEXTURE_2D,U=this._getRGBABufferInternalSizedFormat(F,$,Q),N=this._getInternalFormat($),w=this._getWebGLTextureType(F);return this._bindTextureDirectly(ue,ee),de!==0?(ee.is2DArray=!0,q.texImage3D(ue,0,U,te,ce,de,0,N,w,null)):fe!==0?(ee.is3D=!0,q.texImage3D(ue,0,U,te,ce,fe,0,N,w,null)):q.texImage2D(ue,0,U,te,ce,0,N,w,null),q.texParameteri(ue,q.TEXTURE_MAG_FILTER,Te.mag),q.texParameteri(ue,q.TEXTURE_MIN_FILTER,Te.min),q.texParameteri(ue,q.TEXTURE_WRAP_S,q.CLAMP_TO_EDGE),q.texParameteri(ue,q.TEXTURE_WRAP_T,q.CLAMP_TO_EDGE),B&&this._gl.generateMipmap(ue),this._bindTextureDirectly(ue,null),ee._useSRGBBuffer=Q,ee.baseWidth=te,ee.baseHeight=ce,ee.width=te,ee.height=ce,ee.depth=de,ee.isReady=!0,ee.samples=ie,ee.generateMipMaps=B,ee.samplingMode=X,ee.type=F,ee.format=$,ee.label=D,this._internalTexturesCache.push(ee),ee},S.prototype._getUseSRGBBuffer=function(y,x){return y&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||x)},S.prototype.createTexture=function(y,x,R,I,M,D,B,F,X,$,Q,ie,q,ee,te){var ce=this;return M===void 0&&(M=p.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),D===void 0&&(D=null),B===void 0&&(B=null),F===void 0&&(F=null),X===void 0&&(X=null),$===void 0&&($=null),Q===void 0&&(Q=null),this._createTextureBase(y,x,R,I,M,D,B,function(){for(var fe=[],de=0;de<arguments.length;de++)fe[de]=arguments[de];return ce._prepareWebGLTexture.apply(ce,(0,n.fX)((0,n.fX)([],fe,!1),[$],!1))},function(fe,de,Te,ue,U,N){var w=ce._gl,k=Te.width===fe&&Te.height===de;U._creationFlags=ee??0;var J=ce._getTexImageParametersForCreateTexture(U.format,U._useSRGBBuffer);if(k)return w.texImage2D(w.TEXTURE_2D,0,J.internalFormat,J.format,J.type,Te),!1;var le=ce._caps.maxTextureSize;if(Te.width>le||Te.height>le||!ce._supportsHardwareTextureRescaling)return ce._prepareWorkingCanvas(),!(!ce._workingCanvas||!ce._workingContext||(ce._workingCanvas.width=fe,ce._workingCanvas.height=de,ce._workingContext.drawImage(Te,0,0,Te.width,Te.height,0,0,fe,de),w.texImage2D(w.TEXTURE_2D,0,J.internalFormat,J.format,J.type,ce._workingCanvas),U.width=fe,U.height=de,1));var be=new v.h(ce,2);return ce._bindTextureDirectly(w.TEXTURE_2D,be,!0),w.texImage2D(w.TEXTURE_2D,0,J.internalFormat,J.format,J.type,Te),ce._rescaleTexture(be,U,I,J.format,function(){ce._releaseTexture(be),ce._bindTextureDirectly(w.TEXTURE_2D,U,!0),N()}),!0},F,X,$,Q,ie,q,te)},S.prototype._getTexImageParametersForCreateTexture=function(y,x){var R,I;return this.webGLVersion===1?I=R=this._getInternalFormat(y,x):(R=this._getInternalFormat(y,!1),I=this._getRGBABufferInternalSizedFormat(p.Y.TEXTURETYPE_UNSIGNED_BYTE,y,x)),{internalFormat:I,format:R,type:this._gl.UNSIGNED_BYTE}},S.prototype._rescaleTexture=function(y,x,R,I,M){},S.prototype._unpackFlipY=function(y){this._unpackFlipYCached!==y&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,y?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=y))},S.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},S.prototype._getTextureTarget=function(y){return y.isCube?this._gl.TEXTURE_CUBE_MAP:y.is3D?this._gl.TEXTURE_3D:y.is2DArray||y.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D},S.prototype.updateTextureSamplingMode=function(y,x,R){R===void 0&&(R=!1);var I=this._getTextureTarget(x),M=this._getSamplingParameters(y,x.useMipMaps||R);this._setTextureParameterInteger(I,this._gl.TEXTURE_MAG_FILTER,M.mag,x),this._setTextureParameterInteger(I,this._gl.TEXTURE_MIN_FILTER,M.min),R&&(x.generateMipMaps=!0,this._gl.generateMipmap(I)),this._bindTextureDirectly(I,null),x.samplingMode=y},S.prototype.updateTextureDimensions=function(y,x,R,I){},S.prototype.updateTextureWrappingMode=function(y,x,R,I){R===void 0&&(R=null),I===void 0&&(I=null);var M=this._getTextureTarget(y);x!==null&&(this._setTextureParameterInteger(M,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(x),y),y._cachedWrapU=x),R!==null&&(this._setTextureParameterInteger(M,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(R),y),y._cachedWrapV=R),(y.is2DArray||y.is3D)&&I!==null&&(this._setTextureParameterInteger(M,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(I),y),y._cachedWrapR=I),this._bindTextureDirectly(M,null)},S.prototype._uploadCompressedDataToTextureDirectly=function(y,x,R,I,M,D,B){D===void 0&&(D=0),B===void 0&&(B=0);var F=this._gl,X=F.TEXTURE_2D;if(y.isCube&&(X=F.TEXTURE_CUBE_MAP_POSITIVE_X+D),y._useSRGBBuffer)switch(x){case p.Y.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:case p.Y.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:this._caps.etc2?x=F.COMPRESSED_SRGB8_ETC2:y._useSRGBBuffer=!1;break;case p.Y.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:this._caps.etc2?x=F.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:y._useSRGBBuffer=!1;break;case p.Y.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:x=F.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case p.Y.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:x=F.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case p.Y.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:this._caps.s3tc_srgb?x=F.COMPRESSED_SRGB_S3TC_DXT1_EXT:y._useSRGBBuffer=!1;break;case p.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:this._caps.s3tc_srgb?x=F.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:y._useSRGBBuffer=!1;break;case p.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:this._caps.s3tc_srgb?x=F.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:y._useSRGBBuffer=!1;break;default:y._useSRGBBuffer=!1}this._gl.compressedTexImage2D(X,B,x,R,I,0,M)},S.prototype._uploadDataToTextureDirectly=function(y,x,R,I,M,D){R===void 0&&(R=0),I===void 0&&(I=0),D===void 0&&(D=!1);var B=this._gl,F=this._getWebGLTextureType(y.type),X=this._getInternalFormat(y.format),$=M===void 0?this._getRGBABufferInternalSizedFormat(y.type,y.format,y._useSRGBBuffer):this._getInternalFormat(M,y._useSRGBBuffer);this._unpackFlipY(y.invertY);var Q=B.TEXTURE_2D;y.isCube&&(Q=B.TEXTURE_CUBE_MAP_POSITIVE_X+R);var ie=Math.round(Math.log(y.width)*Math.LOG2E),q=Math.round(Math.log(y.height)*Math.LOG2E),ee=D?y.width:Math.pow(2,Math.max(ie-I,0)),te=D?y.height:Math.pow(2,Math.max(q-I,0));B.texImage2D(Q,I,$,ee,te,0,X,F,x)},S.prototype.updateTextureData=function(y,x,R,I,M,D,B,F,X){B===void 0&&(B=0),F===void 0&&(F=0),X===void 0&&(X=!1);var $=this._gl,Q=this._getWebGLTextureType(y.type),ie=this._getInternalFormat(y.format);this._unpackFlipY(y.invertY);var q=$.TEXTURE_2D,ee=$.TEXTURE_2D;y.isCube&&(ee=$.TEXTURE_CUBE_MAP_POSITIVE_X+B,q=$.TEXTURE_CUBE_MAP),this._bindTextureDirectly(q,y,!0),$.texSubImage2D(ee,F,R,I,M,D,ie,Q,x),X&&this._gl.generateMipmap(ee),this._bindTextureDirectly(q,null)},S.prototype._uploadArrayBufferViewToTexture=function(y,x,R,I){R===void 0&&(R=0),I===void 0&&(I=0);var M=this._gl,D=y.isCube?M.TEXTURE_CUBE_MAP:M.TEXTURE_2D;this._bindTextureDirectly(D,y,!0),this._uploadDataToTextureDirectly(y,x,R,I),this._bindTextureDirectly(D,null,!0)},S.prototype._prepareWebGLTextureContinuation=function(y,x,R,I,M){var D=this._gl;if(D){var B=this._getSamplingParameters(M,!R);D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MAG_FILTER,B.mag),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MIN_FILTER,B.min),R||I||D.generateMipmap(D.TEXTURE_2D),this._bindTextureDirectly(D.TEXTURE_2D,null),x&&x.removePendingData(y),y.onLoadedObservable.notifyObservers(y),y.onLoadedObservable.clear()}},S.prototype._prepareWebGLTexture=function(y,x,R,I,M,D,B,F,X,$){var Q=this,ie=this.getCaps().maxTextureSize,q=Math.min(ie,this.needPOTTextures?(0,d.R)(I.width,ie):I.width),ee=Math.min(ie,this.needPOTTextures?(0,d.R)(I.height,ie):I.height),te=this._gl;te&&(y._hardwareTexture?(this._bindTextureDirectly(te.TEXTURE_2D,y,!0),this._unpackFlipY(M===void 0||!!M),y.baseWidth=I.width,y.baseHeight=I.height,y.width=q,y.height=ee,y.isReady=!0,y.type=y.type!==-1?y.type:p.Y.TEXTURETYPE_UNSIGNED_BYTE,y.format=y.format!==-1?y.format:$??(x!==".jpg"||y._useSRGBBuffer?p.Y.TEXTUREFORMAT_RGBA:p.Y.TEXTUREFORMAT_RGB),F(q,ee,I,x,y,function(){Q._prepareWebGLTextureContinuation(y,R,D,B,X)})||this._prepareWebGLTextureContinuation(y,R,D,B,X)):R&&R.removePendingData(y))},S.prototype._getInternalFormatFromDepthTextureFormat=function(y,x,R){var I=this._gl;if(!x)return I.STENCIL_INDEX8;var M=R?I.DEPTH_STENCIL:I.DEPTH_COMPONENT;return this.webGLVersion>1?y===p.Y.TEXTUREFORMAT_DEPTH16?M=I.DEPTH_COMPONENT16:y===p.Y.TEXTUREFORMAT_DEPTH24?M=I.DEPTH_COMPONENT24:y===p.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||y===p.Y.TEXTUREFORMAT_DEPTH24_STENCIL8?M=R?I.DEPTH24_STENCIL8:I.DEPTH_COMPONENT24:y===p.Y.TEXTUREFORMAT_DEPTH32_FLOAT?M=I.DEPTH_COMPONENT32F:y===p.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8&&(M=R?I.DEPTH32F_STENCIL8:I.DEPTH_COMPONENT32F):M=I.DEPTH_COMPONENT16,M},S.prototype._setupFramebufferDepthAttachments=function(y,x,R,I,M,D){M===void 0&&(M=1);var B=this._gl;D=D??(y?p.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:p.Y.TEXTUREFORMAT_DEPTH32_FLOAT);var F=this._getInternalFormatFromDepthTextureFormat(D,x,y);return y&&x?this._createRenderBuffer(R,I,M,B.DEPTH_STENCIL,F,B.DEPTH_STENCIL_ATTACHMENT):x?this._createRenderBuffer(R,I,M,F,F,B.DEPTH_ATTACHMENT):y?this._createRenderBuffer(R,I,M,F,F,B.STENCIL_ATTACHMENT):null},S.prototype._createRenderBuffer=function(y,x,R,I,M,D,B){B===void 0&&(B=!0);var F=this._gl.createRenderbuffer();return this._updateRenderBuffer(F,y,x,R,I,M,D,B)},S.prototype._updateRenderBuffer=function(y,x,R,I,M,D,B,F){F===void 0&&(F=!0);var X=this._gl;return X.bindRenderbuffer(X.RENDERBUFFER,y),I>1&&X.renderbufferStorageMultisample?X.renderbufferStorageMultisample(X.RENDERBUFFER,I,D,x,R):X.renderbufferStorage(X.RENDERBUFFER,M,x,R),X.framebufferRenderbuffer(X.FRAMEBUFFER,B,X.RENDERBUFFER,y),F&&X.bindRenderbuffer(X.RENDERBUFFER,null),y},S.prototype._releaseTexture=function(y){this._deleteTexture(y._hardwareTexture),this.unbindAllTextures();var x=this._internalTexturesCache.indexOf(y);x!==-1&&this._internalTexturesCache.splice(x,1),y._lodTextureHigh&&y._lodTextureHigh.dispose(),y._lodTextureMid&&y._lodTextureMid.dispose(),y._lodTextureLow&&y._lodTextureLow.dispose(),y._irradianceTexture&&y._irradianceTexture.dispose()},S.prototype._deleteTexture=function(y){y?.release()},S.prototype._setProgram=function(y){this._currentProgram!==y&&((0,i.C5)(y,this._gl),this._currentProgram=y)},S.prototype.bindSamplers=function(y){var x=y.getPipelineContext();this._setProgram(x.program);for(var R=y.getSamplers(),I=0;I<R.length;I++){var M=y.getUniform(R[I]);M&&(this._boundUniforms[I]=M)}this._currentEffect=null},S.prototype._activateCurrentTexture=function(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)},S.prototype._bindTextureDirectly=function(y,x,R,I){var M,D;R===void 0&&(R=!1),I===void 0&&(I=!1);var B=!1,F=x&&x._associatedChannel>-1;if(R&&F&&(this._activeChannel=x._associatedChannel),this._boundTexturesCache[this._activeChannel]!==x||I){if(this._activateCurrentTexture(),x&&x.isMultiview)throw a.V.Error(["_bindTextureDirectly called with a multiview texture!",y,x]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(y,(D=(M=x?._hardwareTexture)===null||M===void 0?void 0:M.underlyingResource)!==null&&D!==void 0?D:null),this._boundTexturesCache[this._activeChannel]=x,x&&(x._associatedChannel=this._activeChannel)}else R&&(B=!0,this._activateCurrentTexture());return F&&!R&&this._bindSamplerUniformToChannel(x._associatedChannel,this._activeChannel),B},S.prototype._bindTexture=function(y,x,R){if(y!==void 0){x&&(x._associatedChannel=y),this._activeChannel=y;var I=x?this._getTextureTarget(x):this._gl.TEXTURE_2D;this._bindTextureDirectly(I,x)}},S.prototype.unbindAllTextures=function(){for(var y=0;y<this._maxSimultaneousTextures;y++)this._activeChannel=y,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},S.prototype.setTexture=function(y,x,R,I){y!==void 0&&(x&&(this._boundUniforms[y]=x),this._setTexture(y,R))},S.prototype._bindSamplerUniformToChannel=function(y,x){var R=this._boundUniforms[y];R&&R._currentState!==x&&(this._gl.uniform1i(R,x),R._currentState=x)},S.prototype._getTextureWrapMode=function(y){switch(y){case p.Y.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case p.Y.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case p.Y.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},S.prototype._setTexture=function(y,x,R,I,M){if(R===void 0&&(R=!1),I===void 0&&(I=!1),!x)return this._boundTexturesCache[y]!=null&&(this._activeChannel=y,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(x.video){this._activeChannel=y;var D=x.getInternalTexture();D&&(D._associatedChannel=y),x.update()}else if(x.delayLoadState===p.Y.DELAYLOADSTATE_NOTLOADED)return x.delayLoad(),!1;var B;B=I?x.depthStencilTexture:x.isReady()?x.getInternalTexture():x.isCube?this.emptyCubeTexture:x.is3D?this.emptyTexture3D:x.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!R&&B&&(B._associatedChannel=y);var F=!0;this._boundTexturesCache[y]===B&&(R||this._bindSamplerUniformToChannel(B._associatedChannel,y),F=!1),this._activeChannel=y;var X=this._getTextureTarget(B);if(F&&this._bindTextureDirectly(X,B,R),B&&!B.isMultiview){if(B.isCube&&B._cachedCoordinatesMode!==x.coordinatesMode){B._cachedCoordinatesMode=x.coordinatesMode;var $=x.coordinatesMode!==p.Y.TEXTURE_CUBIC_MODE&&x.coordinatesMode!==p.Y.TEXTURE_SKYBOX_MODE?p.Y.TEXTURE_WRAP_ADDRESSMODE:p.Y.TEXTURE_CLAMP_ADDRESSMODE;x.wrapU=$,x.wrapV=$}B._cachedWrapU!==x.wrapU&&(B._cachedWrapU=x.wrapU,this._setTextureParameterInteger(X,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(x.wrapU),B)),B._cachedWrapV!==x.wrapV&&(B._cachedWrapV=x.wrapV,this._setTextureParameterInteger(X,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(x.wrapV),B)),B.is3D&&B._cachedWrapR!==x.wrapR&&(B._cachedWrapR=x.wrapR,this._setTextureParameterInteger(X,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(x.wrapR),B)),this._setAnisotropicLevel(X,B,x.anisotropicFilteringLevel)}return!0},S.prototype.setTextureArray=function(y,x,R,I){if(y!==void 0&&x){this._textureUnits&&this._textureUnits.length===R.length||(this._textureUnits=new Int32Array(R.length));for(var M=0;M<R.length;M++){var D=R[M].getInternalTexture();D?(this._textureUnits[M]=y+M,D._associatedChannel=y+M):this._textureUnits[M]=-1}this._gl.uniform1iv(x,this._textureUnits);for(var B=0;B<R.length;B++)this._setTexture(this._textureUnits[B],R[B],!0)}},S.prototype._setAnisotropicLevel=function(y,x,R){var I=this._caps.textureAnisotropicFilterExtension;x.samplingMode!==p.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST&&x.samplingMode!==p.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR&&x.samplingMode!==p.Y.TEXTURE_LINEAR_LINEAR&&(R=1),I&&x._cachedAnisotropicFilteringLevel!==R&&(this._setTextureParameterFloat(y,I.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(R,this._caps.maxAnisotropy),x),x._cachedAnisotropicFilteringLevel=R)},S.prototype._setTextureParameterFloat=function(y,x,R,I){this._bindTextureDirectly(y,I,!0,!0),this._gl.texParameterf(y,x,R)},S.prototype._setTextureParameterInteger=function(y,x,R,I){I&&this._bindTextureDirectly(y,I,!0,!0),this._gl.texParameteri(y,x,R)},S.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var y=0;y<this._caps.maxVertexAttribs;y++)this.disableAttributeByIndex(y)}else{y=0;for(var x=this._vertexAttribArraysEnabled.length;y<x;y++)y>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[y]||this.disableAttributeByIndex(y)}},S.prototype.releaseEffects=function(){for(var y=0,x=Object.keys(this._compiledEffects);y<x.length;y++){var R=x[y];this._compiledEffects[R].dispose()}this._compiledEffects={}},S.prototype.dispose=function(){var y;(0,s.BA)()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),g.prototype.dispose.call(this),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&((y=this._gl.getExtension("WEBGL_lose_context"))===null||y===void 0||y.loseContext()),(0,i.Cm)(this._gl)},S.prototype.attachContextLostEvent=function(y){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",y,!1)},S.prototype.attachContextRestoredEvent=function(y){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",y,!1)},S.prototype.getError=function(){return this._gl.getError()},S.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(p.Y.TEXTURETYPE_FLOAT)},S.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(p.Y.TEXTURETYPE_HALF_FLOAT)},S.prototype._canRenderToFramebuffer=function(y){for(var x=this._gl;x.getError()!==x.NO_ERROR;);var R=!0,I=x.createTexture();x.bindTexture(x.TEXTURE_2D,I),x.texImage2D(x.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(y),1,1,0,x.RGBA,this._getWebGLTextureType(y),null),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,x.NEAREST),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,x.NEAREST);var M=x.createFramebuffer();x.bindFramebuffer(x.FRAMEBUFFER,M),x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,I,0);var D=x.checkFramebufferStatus(x.FRAMEBUFFER);if((R=(R=R&&D===x.FRAMEBUFFER_COMPLETE)&&x.getError()===x.NO_ERROR)&&(x.clear(x.COLOR_BUFFER_BIT),R=R&&x.getError()===x.NO_ERROR),R){x.bindFramebuffer(x.FRAMEBUFFER,null);var B=x.RGBA,F=x.UNSIGNED_BYTE,X=new Uint8Array(4);x.readPixels(0,0,1,1,B,F,X),R=R&&x.getError()===x.NO_ERROR}for(x.deleteTexture(I),x.deleteFramebuffer(M),x.bindFramebuffer(x.FRAMEBUFFER,null);!R&&x.getError()!==x.NO_ERROR;);return R},S.prototype._getWebGLTextureType=function(y){if(this._webGLVersion===1){switch(y){case p.Y.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case p.Y.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case p.Y.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(y){case p.Y.TEXTURETYPE_BYTE:return this._gl.BYTE;case p.Y.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case p.Y.TEXTURETYPE_SHORT:return this._gl.SHORT;case p.Y.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case p.Y.TEXTURETYPE_INT:return this._gl.INT;case p.Y.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case p.Y.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case p.Y.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case p.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case p.Y.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case p.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case p.Y.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case p.Y.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},S.prototype._getInternalFormat=function(y,x){x===void 0&&(x=!1);var R=x?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(y){case p.Y.TEXTUREFORMAT_ALPHA:R=this._gl.ALPHA;break;case p.Y.TEXTUREFORMAT_LUMINANCE:R=this._gl.LUMINANCE;break;case p.Y.TEXTUREFORMAT_LUMINANCE_ALPHA:R=this._gl.LUMINANCE_ALPHA;break;case p.Y.TEXTUREFORMAT_RED:R=this._gl.RED;break;case p.Y.TEXTUREFORMAT_RG:R=this._gl.RG;break;case p.Y.TEXTUREFORMAT_RGB:R=x?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case p.Y.TEXTUREFORMAT_RGBA:R=x?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA}if(this._webGLVersion>1)switch(y){case p.Y.TEXTUREFORMAT_RED_INTEGER:R=this._gl.RED_INTEGER;break;case p.Y.TEXTUREFORMAT_RG_INTEGER:R=this._gl.RG_INTEGER;break;case p.Y.TEXTUREFORMAT_RGB_INTEGER:R=this._gl.RGB_INTEGER;break;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:R=this._gl.RGBA_INTEGER}return R},S.prototype._getRGBABufferInternalSizedFormat=function(y,x,R){if(R===void 0&&(R=!1),this._webGLVersion===1){if(x!==void 0)switch(x){case p.Y.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case p.Y.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case p.Y.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case p.Y.TEXTUREFORMAT_RGB:return R?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(y){case p.Y.TEXTURETYPE_BYTE:switch(x){case p.Y.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case p.Y.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case p.Y.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case p.Y.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case p.Y.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case p.Y.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case p.Y.TEXTURETYPE_UNSIGNED_BYTE:switch(x){case p.Y.TEXTUREFORMAT_RED:return this._gl.R8;case p.Y.TEXTUREFORMAT_RG:return this._gl.RG8;case p.Y.TEXTUREFORMAT_RGB:return R?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case p.Y.TEXTUREFORMAT_RGBA:return R?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case p.Y.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case p.Y.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case p.Y.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case p.Y.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case p.Y.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case p.Y.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case p.Y.TEXTURETYPE_SHORT:switch(x){case p.Y.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case p.Y.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case p.Y.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case p.Y.TEXTURETYPE_UNSIGNED_SHORT:switch(x){case p.Y.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case p.Y.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case p.Y.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case p.Y.TEXTURETYPE_INT:switch(x){case p.Y.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case p.Y.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case p.Y.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case p.Y.TEXTURETYPE_UNSIGNED_INTEGER:switch(x){case p.Y.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case p.Y.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case p.Y.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case p.Y.TEXTURETYPE_FLOAT:switch(x){case p.Y.TEXTUREFORMAT_RED:return this._gl.R32F;case p.Y.TEXTUREFORMAT_RG:return this._gl.RG32F;case p.Y.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case p.Y.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case p.Y.TEXTURETYPE_HALF_FLOAT:switch(x){case p.Y.TEXTUREFORMAT_RED:return this._gl.R16F;case p.Y.TEXTUREFORMAT_RG:return this._gl.RG16F;case p.Y.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case p.Y.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case p.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case p.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case p.Y.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case p.Y.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case p.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(x){case p.Y.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case p.Y.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return R?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8},S.prototype.readPixels=function(y,x,R,I,M,D){M===void 0&&(M=!0),D===void 0&&(D=!0);var B=M?4:3,F=M?this._gl.RGBA:this._gl.RGB,X=new Uint8Array(I*R*B);return D&&this.flushFramebuffer(),this._gl.readPixels(y,x,R,I,F,this._gl.UNSIGNED_BYTE,X),Promise.resolve(X)},Object.defineProperty(S,"IsSupportedAsync",{get:function(){return Promise.resolve(this.isSupported())},enumerable:!1,configurable:!0}),Object.defineProperty(S,"IsSupported",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),S.isSupported=function(){if(this._HasMajorPerformanceCaveat!==null)return!this._HasMajorPerformanceCaveat;if(this._IsSupported===null)try{var y=h.$._CreateCanvas(1,1),x=y.getContext("webgl")||y.getContext("experimental-webgl");this._IsSupported=x!=null&&!!window.WebGLRenderingContext}catch{this._IsSupported=!1}return this._IsSupported},Object.defineProperty(S,"HasMajorPerformanceCaveat",{get:function(){if(this._HasMajorPerformanceCaveat===null)try{var y=h.$._CreateCanvas(1,1),x=y.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||y.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!x}catch{this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat},enumerable:!1,configurable:!0}),S._TempClearColorUint32=new Uint32Array(4),S._TempClearColorInt32=new Int32Array(4),S.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/12\\d\\..+?Mobile",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:".*AppleWebKit.*(15.4).*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]},{key:".*(15.4).*AppleWebKit.*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]}],S._ConcatenateShader=E.iL,S._IsSupported=null,S._HasMajorPerformanceCaveat=null,S}(h.$)},50712:(r,t,e)=>{var n;e.d(t,{b:()=>n,s:()=>i}),function(o){o[o.PointerMove=0]="PointerMove",o[o.PointerDown=1]="PointerDown",o[o.PointerUp=2]="PointerUp"}(n||(n={}));var i=function(){function o(){}return o.DOM_DELTA_PIXEL=0,o.DOM_DELTA_LINE=1,o.DOM_DELTA_PAGE=2,o}()},6451:(r,t,e)=>{e.d(t,{Bu:()=>a,TB:()=>i,W0:()=>o});var n=e(78322),i=function(){function s(){}return s.KEYDOWN=1,s.KEYUP=2,s}(),o=function(s,l){this.type=s,this.event=l},a=function(s){function l(c,u){var d=s.call(this,c,u)||this;return d.type=c,d.event=u,d.skipOnKeyboardObservable=!1,d}return(0,n.C6)(l,s),Object.defineProperty(l.prototype,"skipOnPointerObservable",{get:function(){return this.skipOnKeyboardObservable},set:function(c){this.skipOnKeyboardObservable=c},enumerable:!1,configurable:!0}),l}(o)},64391:(r,t,e)=>{e.d(t,{Vn:()=>a,Zp:()=>o,mx:()=>l,tT:()=>s});var n=e(78322),i=e(8046),o=function(){function c(){}return c.POINTERDOWN=1,c.POINTERUP=2,c.POINTERMOVE=4,c.POINTERWHEEL=8,c.POINTERPICK=16,c.POINTERTAP=32,c.POINTERDOUBLETAP=64,c}(),a=function(c,u){this.type=c,this.event=u},s=function(c){function u(d,h,p,m){var v=c.call(this,d,h)||this;return v.ray=null,v.originalPickingInfo=null,v.skipOnPointerObservable=!1,v.localPosition=new i.I9(p,m),v}return(0,n.C6)(u,c),u}(a),l=function(c){function u(d,h,p,m){m===void 0&&(m=null);var v=c.call(this,d,h)||this;return v._pickInfo=p,v._inputManager=m,v}return(0,n.C6)(u,c),Object.defineProperty(u.prototype,"pickInfo",{get:function(){return this._pickInfo||this._generatePickInfo(),this._pickInfo},enumerable:!1,configurable:!0}),u.prototype._generatePickInfo=function(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)},u}(a)},91946:(r,t,e)=>{e.d(t,{c:()=>n});var n=function(){function i(){}return i.CompareLightsPriority=function(o,a){return o.shadowEnabled!==a.shadowEnabled?(a.shadowEnabled?1:0)-(o.shadowEnabled?1:0):a.renderPriority-o.renderPriority},i.FALLOFF_DEFAULT=0,i.FALLOFF_PHYSICAL=1,i.FALLOFF_GLTF=2,i.FALLOFF_STANDARD=3,i.LIGHTMAP_DEFAULT=0,i.LIGHTMAP_SPECULAR=1,i.LIGHTMAP_SHADOWSONLY=2,i.INTENSITYMODE_AUTOMATIC=0,i.INTENSITYMODE_LUMINOUSPOWER=1,i.INTENSITYMODE_LUMINOUSINTENSITY=2,i.INTENSITYMODE_ILLUMINANCE=3,i.INTENSITYMODE_LUMINANCE=4,i.LIGHTTYPEID_POINTLIGHT=0,i.LIGHTTYPEID_DIRECTIONALLIGHT=1,i.LIGHTTYPEID_SPOTLIGHT=2,i.LIGHTTYPEID_HEMISPHERICLIGHT=3,i}()},50919:(r,t,e)=>{e.d(t,{FG:()=>s,Kq:()=>f,ZR:()=>m,tb:()=>T});var n=e(45109),i=e(25598),o=32768,a=65535;function s(g,S){for(var y=0,x=0;x<i.Ez;++x)(x==0||g[x>>3]&1<<(7&x))&&(S[y++]=x);for(var R=y-1;y<i.Ez;)S[y++]=0;return R}function l(g,S,y,x,R){for(;y<g;)S=S<<8|(0,n.fz)(x,R),y+=8;return{l:S>>(y-=g)&(1<<g)-1,c:S,lc:y}}function c(g,S,y,x){return{c:g=g<<8|(0,n.fz)(y,x),lc:S+=8}}function u(g,S,y,x,R,I,M,D,B){if(g==S){if(x<8){var F=c(y,x,R,I);y=F.c,x=F.lc}var X=y>>(x-=8);if(X=new Uint8Array([X])[0],D.value+X>B)return null;for(var $=M[D.value-1];X-- >0;)M[D.value++]=$}else{if(!(D.value<B))return null;M[D.value++]=g}return{c:y,lc:x}}var d=new Array(59);function h(g){return 63&g}function p(g){return g>>6}function m(g,S,y,x,R,I){var M=y.value,D=(0,n.PX)(S,y),B=(0,n.PX)(S,y);y.value+=4;var F=(0,n.PX)(S,y);if(y.value+=4,D<0||D>=i.U0||B<0||B>=i.U0)throw new Error("Wrong HUF_ENCSIZE");var X=new Array(i.U0),$=new Array(i.A_);if(function(Q){for(var ie=0;ie<i.A_;ie++)Q[ie]={},Q[ie].len=0,Q[ie].lit=0,Q[ie].p=null}($),function(Q,ie,q,ee,te,ce){for(var fe=ie,de=0,Te=0;ee<=te;ee++){if(fe.value-ie.value>q)return;var ue=l(6,de,Te,Q,fe),U=ue.l;if(de=ue.c,Te=ue.lc,ce[ee]=U,U==i.Hh){if(fe.value-ie.value>q)throw new Error("Error in HufUnpackEncTable");var N=(ue=l(8,de,Te,Q,fe)).l+i.gn;if(de=ue.c,Te=ue.lc,ee+N>te+1)throw new Error("Error in HufUnpackEncTable");for(;N--;)ce[ee++]=0;ee--}else if(U>=i.LU){if(ee+(N=U-i.LU+2)>te+1)throw new Error("Error in HufUnpackEncTable");for(;N--;)ce[ee++]=0;ee--}}(function(w){for(var k=0;k<=58;++k)d[k]=0;for(k=0;k<i.U0;++k)d[w[k]]+=1;var J=0;for(k=58;k>0;--k){var le=J+d[k]>>1;d[k]=J,J=le}for(k=0;k<i.U0;++k){var be=w[k];be>0&&(w[k]=be|d[be]++<<6)}})(ce)}(g,y,x-(y.value-M),D,B,X),F>8*(x-(y.value-M)))throw new Error("Wrong hufUncompress");(function(Q,ie,q,ee){for(;ie<=q;ie++){var te=p(Q[ie]),ce=h(Q[ie]);if(te>>ce)throw new Error("Invalid table entry");if(ce>i.LK){if((ue=ee[te>>ce-i.LK]).len)throw new Error("Invalid table entry");if(ue.lit++,ue.p){var fe=ue.p;ue.p=new Array(ue.lit);for(var de=0;de<ue.lit-1;++de)ue.p[de]=fe[de]}else ue.p=new Array(1);ue.p[ue.lit-1]=ie}else if(ce){var Te=0;for(de=1<<i.LK-ce;de>0;de--){var ue;if((ue=ee[(te<<i.LK-ce)+Te]).len||ue.p)throw new Error("Invalid table entry");ue.len=ce,ue.lit=ie,Te++}}}})(X,D,B,$),function(Q,ie,q,ee,te,ce,fe,de,Te){for(var ue=0,U=0,N=fe,w=Math.trunc(ee.value+(te+7)/8);ee.value<w;){var k=c(ue,U,q,ee);for(ue=k.c,U=k.lc;U>=i.LK;)if((ve=ie[ue>>U-i.LK&i.lR]).len)U-=ve.len,(ye=u(ve.lit,ce,ue,U,q,ee,de,Te,N))&&(ue=ye.c,U=ye.lc);else{if(!ve.p)throw new Error("hufDecode issues");var J=void 0;for(J=0;J<ve.lit;J++){for(var le=h(Q[ve.p[J]]);U<le&&ee.value<w;)ue=(k=c(ue,U,q,ee)).c,U=k.lc;if(U>=le&&p(Q[ve.p[J]])==(ue>>U-le&(1<<le)-1)){U-=le,(ye=u(ve.p[J],ce,ue,U,q,ee,de,Te,N))&&(ue=ye.c,U=ye.lc);break}}if(J==ve.lit)throw new Error("HufDecode issues")}}var be=8-te&7;for(ue>>=be,U-=be;U>0;){var ve,ye;if(!(ve=ie[ue<<i.LK-U&i.lR]).len)throw new Error("HufDecode issues");U-=ve.len,(ye=u(ve.lit,ce,ue,U,q,ee,de,Te,N))&&(ue=ye.c,U=ye.lc)}}(X,$,g,y,F,B,I,R,{value:0})}function v(g){return 65535&g}function b(g){var S=v(g);return S>32767?S-65536:S}function E(g,S){var y=b(g),x=b(S),R=y+(1&x)+(x>>1);return{a:R,b:R-x}}function C(g,S){var y=v(g),x=v(S),R=y-(x>>1)&a;return{a:x+R-o&a,b:R}}function T(g,S,y,x,R,I,M){for(var D,B,F=M<16384,X=y>R?R:y,$=1;$<=X;)$<<=1;for(D=$>>=1,$>>=1;$>=1;){for(var Q=(B=0)+I*(R-D),ie=I*$,q=I*D,ee=x*$,te=x*D,ce=void 0,fe=void 0,de=void 0,Te=void 0;B<=Q;B+=q){for(var ue=B,U=B+x*(y-D);ue<=U;ue+=te){var N=ue+ee,w=(k=ue+ie)+ee;F?(ce=(J=E(g[ue+S],g[k+S])).a,de=J.b,fe=(J=E(g[N+S],g[w+S])).a,Te=J.b,J=E(ce,fe),g[ue+S]=J.a,g[N+S]=J.b,J=E(de,Te),g[k+S]=J.a,g[w+S]=J.b):(ce=(J=C(g[ue+S],g[k+S])).a,de=J.b,fe=(J=C(g[N+S],g[w+S])).a,Te=J.b,J=C(ce,fe),g[ue+S]=J.a,g[N+S]=J.b,J=C(de,Te),g[k+S]=J.a,g[w+S]=J.b)}if(y&$){var k=ue+ie,J=void 0;ce=(J=F?E(g[ue+S],g[k+S]):C(g[ue+S],g[k+S])).a,g[k+S]=J.b,g[ue+S]=ce}}if(R&$)for(ue=B,U=B+x*(y-D);ue<=U;ue+=te)N=ue+ee,J=void 0,ce=(J=F?E(g[ue+S],g[N+S]):C(g[ue+S],g[N+S])).a,g[N+S]=J.b,g[ue+S]=ce;D=$,$>>=1}return B}function f(g,S,y){for(var x=0;x<y;++x)S[x]=g[S[x]]}},51289:(r,t,e)=>{function n(i){for(var o=i.byteLength,a=new Array,s=0,l=new DataView(i);o>0;){var c=l.getInt8(s++);if(c<0){o-=1+(d=-c);for(var u=0;u<d;u++)a.push(l.getUint8(s++))}else{var d=c;o-=2;var h=l.getUint8(s++);for(u=0;u<d+1;u++)a.push(h)}}return a}e.d(t,{_:()=>n})},8102:(r,t,e)=>{e.d(t,{S4:()=>s,VE:()=>c,_k:()=>u,r:()=>l,tg:()=>d});var n=e(50919),i=e(51289),o=e(45109),a=e(25598);function s(h){return new DataView(h.array.buffer,h.offset.value,h.size)}function l(h){var p=h.viewer.buffer.slice(h.offset.value,h.offset.value+h.size),m=new Uint8Array((0,i._)(p)),v=new Uint8Array(m.length);return(0,o.XE)(m),(0,o.KA)(m,v),new DataView(v.buffer)}function c(h){var p=h.array.slice(h.offset.value,h.offset.value+h.size),m=fflate.unzlibSync(p),v=new Uint8Array(m.length);return(0,o.XE)(m),(0,o.KA)(m,v),new DataView(v.buffer)}function u(h){for(var p=h.array.slice(h.offset.value,h.offset.value+h.size),m=fflate.unzlibSync(p),v=h.lines*h.channels*h.width,b=h.type==1?new Uint16Array(v):new Uint32Array(v),E=0,C=0,T=new Array(4),f=0;f<h.lines;f++)for(var g=0;g<h.channels;g++){var S=0;switch(h.type){case 1:T[0]=E,T[1]=T[0]+h.width,E=T[1]+h.width;for(var y=0;y<h.width;++y)S+=m[T[0]++]<<8|m[T[1]++],b[C]=S,C++;break;case 2:for(T[0]=E,T[1]=T[0]+h.width,T[2]=T[1]+h.width,E=T[2]+h.width,y=0;y<h.width;++y)S+=m[T[0]++]<<24|m[T[1]++]<<16|m[T[2]++]<<8,b[C]=S,C++}}return new DataView(b.buffer)}function d(h){for(var p=h.viewer,m={value:h.offset.value},v=new Uint16Array(h.width*h.scanlineBlockSize*(h.channels*h.type)),b=new Uint8Array(a.cQ),E=0,C=new Array(h.channels),T=0;T<h.channels;T++)C[T]={},C[T].start=E,C[T].end=C[T].start,C[T].nx=h.width,C[T].ny=h.lines,C[T].size=h.type,E+=C[T].nx*C[T].ny*C[T].size;var f=(0,o.Jn)(p,m),g=(0,o.Jn)(p,m);if(g>=a.cQ)throw new Error("Wrong PIZ_COMPRESSION BITMAP_SIZE");if(f<=g)for(T=0;T<g-f+1;T++)b[T+f]=(0,o._S)(p,m);var S=new Uint16Array(a.Ez),y=(0,n.FG)(b,S),x=(0,o.PX)(p,m);for((0,n.ZR)(h.array,p,m,x,v,E),T=0;T<h.channels;++T)for(var R=C[T],I=0;I<C[T].size;++I)(0,n.tb)(v,R.start+I,R.nx,R.size,R.ny,R.nx*R.size,y);(0,n.Kq)(S,v,E);for(var M=0,D=new Uint8Array(v.buffer.byteLength),B=0;B<h.lines;B++)for(var F=0;F<h.channels;F++){var X=(R=C[F]).nx*R.size,$=new Uint8Array(v.buffer,R.end*a.JH,X*a.JH);D.set($,M),M+=X*a.JH,R.end+=X}return new DataView(D.buffer)}},54646:(r,t,e)=>{var n;e.d(t,{V:()=>n,u:()=>i}),function(o){o[o.Float=0]="Float",o[o.HalfFloat=1]="HalfFloat"}(n||(n={}));var i=function(){function o(){}return o.DefaultOutputType=n.HalfFloat,o.FFLATEUrl="https://unpkg.com/fflate@0.8.2",o}()},45109:(r,t,e)=>{e.d(t,{Ff:()=>v,Jn:()=>h,KA:()=>f,LD:()=>b,PX:()=>u,Sn:()=>E,T$:()=>l,XE:()=>T,_S:()=>d,cL:()=>c,fz:()=>p,he:()=>n,tB:()=>m,zX:()=>C});var n,i,o=e(48810),a=e(25598);(function(g){g[g.NO_COMPRESSION=0]="NO_COMPRESSION",g[g.RLE_COMPRESSION=1]="RLE_COMPRESSION",g[g.ZIPS_COMPRESSION=2]="ZIPS_COMPRESSION",g[g.ZIP_COMPRESSION=3]="ZIP_COMPRESSION",g[g.PIZ_COMPRESSION=4]="PIZ_COMPRESSION",g[g.PXR24_COMPRESSION=5]="PXR24_COMPRESSION"})(n||(n={})),function(g){g[g.INCREASING_Y=0]="INCREASING_Y",g[g.DECREASING_Y=1]="DECREASING_Y"}(i||(i={}));var s=function(){for(var g=new ArrayBuffer(4),S=new Float32Array(g),y=new Uint32Array(g),x=new Uint32Array(512),R=new Uint32Array(512),I=0;I<256;++I)(X=I-127)<-27?(x[I]=0,x[256|I]=32768,R[I]=24,R[256|I]=24):X<-14?(x[I]=1024>>-X-14,x[256|I]=1024>>-X-14|32768,R[I]=-X-1,R[256|I]=-X-1):X<=15?(x[I]=X+15<<10,x[256|I]=X+15<<10|32768,R[I]=13,R[256|I]=13):X<128?(x[I]=31744,x[256|I]=64512,R[I]=24,R[256|I]=24):(x[I]=31744,x[256|I]=64512,R[I]=13,R[256|I]=13);var M=new Uint32Array(2048),D=new Uint32Array(64),B=new Uint32Array(64);for(I=1;I<1024;++I){for(var F=I<<13,X=0;!(8388608&F);)F<<=1,X-=8388608;F&=-8388609,X+=947912704,M[I]=F|X}for(I=1024;I<2048;++I)M[I]=939524096+(I-1024<<13);for(I=1;I<31;++I)D[I]=I<<23;for(D[31]=1199570944,D[32]=2147483648,I=33;I<63;++I)D[I]=2147483648+(I-32<<23);for(D[63]=3347054592,I=1;I<64;++I)I!==32&&(B[I]=1024);return{floatView:S,uint32View:y,baseTable:x,shiftTable:R,mantissaTable:M,exponentTable:D,offsetTable:B}}();function l(g,S){for(var y=new Uint8Array(g),x=0;y[S.value+x]!=0;)x+=1;var R=new TextDecoder().decode(y.slice(S.value,S.value+x));return S.value=S.value+x+1,R}function c(g,S){var y=g.getInt32(S.value,!0);return S.value+=a.b7,y}function u(g,S){var y=g.getUint32(S.value,!0);return S.value+=a.b7,y}function d(g,S){var y=g.getUint8(S.value);return S.value+=a.aN,y}function h(g,S){var y=g.getUint16(S.value,!0);return S.value+=a.JH,y}function p(g,S){var y=g[S.value];return S.value+=a.aN,y}function m(g,S){var y;return y="getBigInt64"in DataView.prototype?Number(g.getBigInt64(S.value,!0)):g.getUint32(S.value+4,!0)+Number(g.getUint32(S.value,!0)<<32),S.value+=a.Kl,y}function v(g,S){var y=g.getFloat32(S.value,!0);return S.value+=a.Y3,y}function b(g,S){return R=1023&(y=h(g,S)),(y>>15?-1:1)*((x=(31744&y)>>10)?x===31?R?NaN:1/0:Math.pow(2,x-15)*(1+R/1024):R/1024*6103515625e-14);var y,x,R}function E(g,S){return function(y){if(Math.abs(y)>65504)throw new Error("Value out of range.Consider using float instead of half-float.");y=(0,o.Clamp)(y,-65504,65504),s.floatView[0]=y;var x=s.uint32View[0],R=x>>23&511;return s.baseTable[R]+((8388607&x)>>s.shiftTable[R])}(v(g,S))}function C(g,S,y,x){switch(y){case"string":case"stringvector":case"iccProfile":return function(R,I,M){var D=new TextDecoder().decode(new Uint8Array(R).slice(I.value,I.value+M));return I.value=I.value+M,D}(g.buffer,S,x);case"chlist":return function(R,I,M){for(var D=I.value,B=[];I.value<D+M-1;){var F=l(R.buffer,I),X=c(R,I),$=d(R,I);I.value+=3;var Q=c(R,I),ie=c(R,I);B.push({name:F,pixelType:X,pLinear:$,xSampling:Q,ySampling:ie})}return I.value+=1,B}(g,S,x);case"chromaticities":return function(R,I){return{redX:v(R,I),redY:v(R,I),greenX:v(R,I),greenY:v(R,I),blueX:v(R,I),blueY:v(R,I),whiteX:v(R,I),whiteY:v(R,I)}}(g,S);case"compression":return function(R,I){return d(R,I)}(g,S);case"box2i":return function(R,I){return{xMin:c(R,I),yMin:c(R,I),xMax:c(R,I),yMax:c(R,I)}}(g,S);case"lineOrder":return function(R,I){var M=d(R,I);return i[M]}(g,S);case"float":return v(g,S);case"v2f":return function(R,I){return[v(R,I),v(R,I)]}(g,S);case"v3f":return function(R,I){return[v(R,I),v(R,I),v(R,I)]}(g,S);case"int":return c(g,S);case"rational":return function(R,I){return[c(R,I),u(R,I)]}(g,S);case"timecode":return function(R,I){return[u(R,I),u(R,I)]}(g,S);case"preview":return S.value+=x,"skipped";default:return void(S.value+=x)}}function T(g){for(var S=1;S<g.length;S++){var y=g[S-1]+g[S]-128;g[S]=y}}function f(g,S){for(var y=0,x=Math.floor((g.length+1)/2),R=0,I=g.length-1;!(R>I||(S[R++]=g[y++],R>I));)S[R++]=g[x++]}},99448:(r,t,e)=>{e.d(t,{d:()=>u,u:()=>d});var n=e(78322),i=e(45109),o=e(8102),a=e(25598),s=e(81152),l=e(44957),c=e(54646);function u(h,p,m,v){return(0,n.sH)(this,void 0,void 0,function(){var b,E,C,T,f,g,S,y,x,R,I;return(0,n.YH)(this,function(M){switch(M.label){case 0:switch(b={size:0,viewer:p,array:new Uint8Array(p.buffer),offset:m,width:h.dataWindow.xMax-h.dataWindow.xMin+1,height:h.dataWindow.yMax-h.dataWindow.yMin+1,channels:h.channels.length,channelLineOffsets:{},scanOrder:function(){return 0},bytesPerLine:0,outLineWidth:0,lines:0,scanlineBlockSize:0,inputSize:null,type:0,uncompress:null,getter:function(){return 0},format:s.Y.TEXTUREFORMAT_RGBA,outputChannels:0,decodeChannels:{},blockCount:null,byteArray:null,linearSpace:!1,textureType:0},h.compression){case i.he.NO_COMPRESSION:return[3,1];case i.he.RLE_COMPRESSION:return[3,2];case i.he.ZIPS_COMPRESSION:return[3,3];case i.he.ZIP_COMPRESSION:return[3,5];case i.he.PIZ_COMPRESSION:return[3,7];case i.he.PXR24_COMPRESSION:return[3,8]}return[3,10];case 1:return b.lines=1,b.uncompress=o.S4,[3,11];case 2:return b.lines=1,b.uncompress=o.r,[3,11];case 3:return b.lines=1,b.uncompress=o.VE,[4,l.S0.LoadScriptAsync(c.u.FFLATEUrl)];case 4:case 6:case 9:return M.sent(),[3,11];case 5:return b.lines=16,b.uncompress=o.VE,[4,l.S0.LoadScriptAsync(c.u.FFLATEUrl)];case 7:return b.lines=32,b.uncompress=o.tg,[3,11];case 8:return b.lines=16,b.uncompress=o._k,[4,l.S0.LoadScriptAsync(c.u.FFLATEUrl)];case 10:throw new Error(i.he[h.compression]+" is unsupported");case 11:for(b.scanlineBlockSize=b.lines,E={},C=0,T=h.channels;C<T.length;C++)switch((I=T[C]).name){case"Y":case"R":case"G":case"B":case"A":E[I.name]=!0,b.type=I.pixelType}if(f=!1,E.R&&E.G&&E.B)f=!E.A,b.outputChannels=4,b.decodeChannels={R:0,G:1,B:2,A:3};else{if(!E.Y)throw new Error("EXRLoader.parse: file contains unsupported data channels.");b.outputChannels=1,b.decodeChannels={Y:0}}if(b.type===1)switch(v){case c.V.Float:b.getter=i.LD,b.inputSize=a.JH;break;case c.V.HalfFloat:b.getter=i.Jn,b.inputSize=a.JH}else{if(b.type!==2)throw new Error("Unsupported pixelType "+b.type+" for "+h.compression);switch(v){case c.V.Float:b.getter=i.Ff,b.inputSize=a.Y3;break;case c.V.HalfFloat:b.getter=i.Sn,b.inputSize=a.Y3}}for(b.blockCount=b.height/b.scanlineBlockSize,g=0;g<b.blockCount;g++)(0,i.tB)(p,m);switch(S=b.width*b.height*b.outputChannels,v){case c.V.Float:b.byteArray=new Float32Array(S),b.textureType=s.Y.TEXTURETYPE_FLOAT,f&&b.byteArray.fill(1,0,S);break;case c.V.HalfFloat:b.byteArray=new Uint16Array(S),b.textureType=s.Y.TEXTURETYPE_HALF_FLOAT,f&&b.byteArray.fill(15360,0,S);break;default:throw new Error("Unsupported type: "+v)}for(y=0,x=0,R=h.channels;x<R.length;x++)I=R[x],b.decodeChannels[I.name]!==void 0&&(b.channelLineOffsets[I.name]=y*b.width),y+=2*I.pixelType;return b.bytesPerLine=b.width*y,b.outLineWidth=b.width*b.outputChannels,h.lineOrder==="INCREASING_Y"?b.scanOrder=function(D){return D}:b.scanOrder=function(D){return b.height-1-D},b.outputChannels==4?(b.format=s.Y.TEXTUREFORMAT_RGBA,b.linearSpace=!0):(b.format=s.Y.TEXTUREFORMAT_R,b.linearSpace=!1),[2,b]}})})}function d(h,p,m,v){for(var b={value:0},E=0;E<h.height/h.scanlineBlockSize;E++){var C=(0,i.cL)(m,v)-p.dataWindow.yMin;h.size=(0,i.PX)(m,v),h.lines=C+h.scanlineBlockSize>h.height?h.height-C:h.scanlineBlockSize;var T=h.size<h.lines*h.bytesPerLine&&h.uncompress?h.uncompress(h):(0,o.S4)(h);v.value+=h.size;for(var f=0;f<h.scanlineBlockSize;f++){var g=E*h.scanlineBlockSize,S=f+h.scanOrder(g);if(!(S>=h.height))for(var y=f*h.bytesPerLine,x=(h.height-1-S)*h.outLineWidth,R=0;R<h.channels;R++){var I=p.channels[R].name,M=h.channelLineOffsets[I],D=h.decodeChannels[I];if(D!==void 0){b.value=y+M;for(var B=0;B<h.width;B++){var F=x+B*h.outputChannels+D;h.byteArray&&(h.byteArray[F]=h.getter(T,b))}}}}}}},95487:(r,t,e)=>{e.d(t,{V:()=>s});var n=e(78322),i=e(7164),o=e(45109),a=20000630;function s(l,c){if(l.getUint32(0,!0)!=a)throw new Error("Incorrect OpenEXR format");var u=l.getUint8(4),d=l.getUint8(5),h={singleTile:!!(2&d),longName:!!(4&d),deepFormat:!!(8&d),multiPart:!!(16&d)};c.value=8;for(var p={},m=!0;m;){var v=(0,o.T$)(l.buffer,c);if(v){var b=(0,o.T$)(l.buffer,c),E=(0,o.PX)(l,c),C=(0,o.zX)(l,c,b,E);C===void 0?i.V.Warn("Unknown header attribute type ".concat(b,"'.")):p[v]=C}else m=!1}if(-5&d)throw new Error("Unsupported file format");return(0,n.Cl)({version:u,spec:h},p)}},25598:(r,t,e)=>{e.d(t,{A_:()=>h,Ez:()=>l,Hh:()=>v,JH:()=>a,Kl:()=>s,LK:()=>u,LU:()=>m,U0:()=>d,Y3:()=>i,aN:()=>o,b7:()=>n,cQ:()=>c,gn:()=>b,lR:()=>p});var n=4,i=4,o=1,a=2,s=8,l=65536,c=l>>3,u=14,d=65537,h=1<<u,p=h-1,m=59,v=63,b=2+v-m},23586:(r,t,e)=>{e.r(t),e.d(t,{_BasisTextureLoader:()=>o});var n=e(82941),i=e(44957),o=(e(71974),function(){function a(){this.supportCascades=!1}return a.prototype.loadCubeData=function(s,l,c,u,d){if(!Array.isArray(s)){var h=l.getEngine().getCaps(),p={supportedCompressionFormats:{etc1:!!h.etc1,s3tc:!!h.s3tc,pvrtc:!!h.pvrtc,etc2:!!h.etc2,astc:!!h.astc,bc7:!!h.bptc}};(0,n.yk)(s,p).then(function(m){var v=m.fileInfo.images[0].levels.length>1&&l.generateMipMaps;(0,n.aB)(l,m),l.getEngine()._setCubeMapTextureParams(l,v),l.isReady=!0,l.onLoadedObservable.notifyObservers(l),l.onLoadedObservable.clear(),u&&u()}).catch(function(m){i.S0.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),l.isReady=!0,d&&d(m)})}},a.prototype.loadData=function(s,l,c){var u=l.getEngine().getCaps(),d={supportedCompressionFormats:{etc1:!!u.etc1,s3tc:!!u.s3tc,pvrtc:!!u.pvrtc,etc2:!!u.etc2,astc:!!u.astc,bc7:!!u.bptc}};(0,n.yk)(s,d).then(function(h){var p=h.fileInfo.images[0].levels[0],m=h.fileInfo.images[0].levels.length>1&&l.generateMipMaps;c(p.width,p.height,m,h.format!==-1,function(){(0,n.aB)(l,h)})}).catch(function(h){i.S0.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),i.S0.Warn("Failed to transcode Basis file: ".concat(h)),c(0,0,!1,!1,function(){},!0)})},a}())},19135:(r,t,e)=>{e.r(t),e.d(t,{_DDSTextureLoader:()=>o});var n=e(51428),i=e(49611),o=(e(71974),function(){function a(){this.supportCascades=!0}return a.prototype.loadCubeData=function(s,l,c,u){var d,h=l.getEngine(),p=!1,m=1e3;if(Array.isArray(s))for(var v=0;v<s.length;v++){var b=s[v];d=i.D.GetDDSInfo(b),l.width=d.width,l.height=d.height,p=(d.isRGB||d.isLuminance||d.mipmapCount>1)&&l.generateMipMaps,h._unpackFlipY(d.isCompressed),i.D.UploadDDSLevels(h,l,b,d,p,6,-1,v),d.isFourCC||d.mipmapCount!==1?m=d.mipmapCount-1:h.generateMipMapsForCubemap(l)}else b=s,d=i.D.GetDDSInfo(b),l.width=d.width,l.height=d.height,c&&(d.sphericalPolynomial=new n.Q),p=(d.isRGB||d.isLuminance||d.mipmapCount>1)&&l.generateMipMaps,h._unpackFlipY(d.isCompressed),i.D.UploadDDSLevels(h,l,b,d,p,6),d.isFourCC||d.mipmapCount!==1?m=d.mipmapCount-1:h.generateMipMapsForCubemap(l,!1);h._setCubeMapTextureParams(l,p,m),l.isReady=!0,l.onLoadedObservable.notifyObservers(l),l.onLoadedObservable.clear(),u&&u({isDDS:!0,width:l.width,info:d,data:s,texture:l})},a.prototype.loadData=function(s,l,c){var u=i.D.GetDDSInfo(s),d=(u.isRGB||u.isLuminance||u.mipmapCount>1)&&l.generateMipMaps&&Math.max(u.width,u.height)>>u.mipmapCount-1==1;c(u.width,u.height,d,u.isFourCC,function(){i.D.UploadDDSLevels(l.getEngine(),l,s,u,d,1)})},a}())},71545:(r,t,e)=>{e.r(t),e.d(t,{_ENVTextureLoader:()=>i});var n=e(88309),i=function(){function o(){this.supportCascades=!1}return o.prototype.loadCubeData=function(a,s,l,c,u){if(!Array.isArray(a)){var d=(0,n.cU)(a);if(d){s.width=d.width,s.height=d.width;try{(0,n.ow)(s,d),(0,n.o5)(s,a,d).then(function(){s.isReady=!0,s.onLoadedObservable.notifyObservers(s),s.onLoadedObservable.clear(),c&&c()},function(h){u?.("Can not upload environment levels",h)})}catch(h){u?.("Can not upload environment file",h)}}else u&&u("Can not parse the environment file",null)}},o.prototype.loadData=function(){throw".env not supported in 2d."},o}()},93747:(r,t,e)=>{e.r(t),e.d(t,{_ExrTextureLoader:()=>s});var n=e(78322),i=e(95487),o=e(99448),a=e(54646),s=function(){function l(){this.supportCascades=!1}return l.prototype.loadCubeData=function(c,u,d,h,p){throw".exr not supported in Cube."},l.prototype.loadData=function(c,u,d){return(0,n.sH)(this,void 0,void 0,function(){var h,p,m,v,b,E;return(0,n.YH)(this,function(C){switch(C.label){case 0:return h=new DataView(c.buffer),p={value:0},m=(0,i.V)(h,p),[4,(0,o.d)(m,h,p,a.u.DefaultOutputType)];case 1:return v=C.sent(),(0,o.u)(v,m,h,p),b=m.dataWindow.xMax-m.dataWindow.xMin+1,E=m.dataWindow.yMax-m.dataWindow.yMin+1,d(b,E,u.generateMipMaps,!1,function(){var T=u.getEngine();u.format=m.format,u.type=v.textureType,u.invertY=!1,u._gammaSpace=!m.linearSpace,v.byteArray&&T._uploadDataToTextureDirectly(u,v.byteArray,0,0,void 0,!0)}),[2]}})})},l}()},78750:(r,t,e)=>{e.r(t),e.d(t,{_HDRTextureLoader:()=>o});var n=e(51967),i=e(81152),o=function(){function a(){this.supportCascades=!1}return a.prototype.loadCubeData=function(){throw".env not supported in Cube."},a.prototype.loadData=function(s,l,c){for(var u=new Uint8Array(s.buffer,s.byteOffset,s.byteLength),d=(0,n.NK)(u),h=(0,n.LT)(u,d),p=d.width*d.height,m=new Float32Array(4*p),v=0;v<p;v+=1)m[4*v]=h[3*v],m[4*v+1]=h[3*v+1],m[4*v+2]=h[3*v+2],m[4*v+3]=1;c(d.width,d.height,l.generateMipMaps,!1,function(){var b=l.getEngine();l.type=i.Y.TEXTURETYPE_FLOAT,l.format=i.Y.TEXTUREFORMAT_RGBA,l._gammaSpace=!1,b._uploadDataToTextureDirectly(l,m)})},a}()},81867:(r,t,e)=>{e.r(t),e.d(t,{_KTXTextureLoader:()=>s});var n=e(88188),i=e(47347),o=e(7164),a=e(81152);e(71974);var s=function(){function l(){this.supportCascades=!1}return l.prototype.loadCubeData=function(c,u,d,h){if(!Array.isArray(c)){u._invertVScale=!u.invertY;var p=u.getEngine(),m=new n.H(c,6),v=m.numberOfMipmapLevels>1&&u.generateMipMaps;p._unpackFlipY(!0),m.uploadLevels(u,u.generateMipMaps),u.width=m.pixelWidth,u.height=m.pixelHeight,p._setCubeMapTextureParams(u,v,m.numberOfMipmapLevels-1),u.isReady=!0,u.onLoadedObservable.notifyObservers(u),u.onLoadedObservable.clear(),h&&h()}},l.prototype.loadData=function(c,u,d,h){if(n.H.IsValid(c)){u._invertVScale=!u.invertY;var p=new n.H(c,1),m=function(v){switch(v){case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT:return a.Y.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:return a.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:return a.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2:return a.Y.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2;case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return a.Y.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return a.Y.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:return a.Y.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;case a.Y.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:return a.Y.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM}return null}(p.glInternalFormat);m?(u.format=m,u._useSRGBBuffer=u.getEngine()._getUseSRGBBuffer(!0,u.generateMipMaps),u._gammaSpace=!0):u.format=p.glInternalFormat,d(p.pixelWidth,p.pixelHeight,u.generateMipMaps,!0,function(){p.uploadLevels(u,u.generateMipMaps)},p.isInvalid)}else i.Z.IsValid(c)?new i.Z(u.getEngine())._uploadAsync(c,u,h).then(function(){d(u.width,u.height,u.generateMipMaps,!0,function(){},!1)},function(v){o.V.Warn("Failed to load KTX2 texture data: ".concat(v.message)),d(0,0,!1,!1,function(){},!0)}):(o.V.Error("texture missing KTX identifier"),d(0,0,!1,!1,function(){},!0))},l}()},1235:(r,t,e)=>{e.d(t,{gT:()=>s,hy:()=>a,kf:()=>o});var n=e(7164),i=new Map;function o(l,c){a(l)&&n.V.Warn("Extension with the name '".concat(name,"' already exists")),i.set(l,c)}function a(l){return i.delete(l)}function s(l,c){c!=="image/ktx"&&c!=="image/ktx2"||(l=".ktx"),i.has(l)||(l.endsWith(".dds")&&o(".dds",function(){return Promise.resolve().then(e.bind(e,19135)).then(function(d){return new d._DDSTextureLoader})}),l.endsWith(".basis")&&o(".basis",function(){return Promise.resolve().then(e.bind(e,23586)).then(function(d){return new d._BasisTextureLoader})}),l.endsWith(".env")&&o(".env",function(){return Promise.resolve().then(e.bind(e,71545)).then(function(d){return new d._ENVTextureLoader})}),l.endsWith(".hdr")&&o(".hdr",function(){return Promise.resolve().then(e.bind(e,78750)).then(function(d){return new d._HDRTextureLoader})}),(l.endsWith(".ktx")||l.endsWith(".ktx2"))&&(o(".ktx",function(){return Promise.resolve().then(e.bind(e,81867)).then(function(d){return new d._KTXTextureLoader})}),o(".ktx2",function(){return Promise.resolve().then(e.bind(e,81867)).then(function(d){return new d._KTXTextureLoader})})),l.endsWith(".tga")&&o(".tga",function(){return Promise.resolve().then(e.bind(e,5996)).then(function(d){return new d._TGATextureLoader})}),l.endsWith(".exr")&&o(".exr",function(){return Promise.resolve().then(e.bind(e,93747)).then(function(d){return new d._ExrTextureLoader})}));var u=i.get(l);return u?Promise.resolve(u(c)):null}},5996:(r,t,e)=>{e.r(t),e.d(t,{_TGATextureLoader:()=>i});var n=e(65054),i=function(){function o(){this.supportCascades=!1}return o.prototype.loadCubeData=function(){throw".env not supported in Cube."},o.prototype.loadData=function(a,s,l){var c=new Uint8Array(a.buffer,a.byteOffset,a.byteLength),u=(0,n.O_)(c);l(u.width,u.height,s.generateMipMaps,!1,function(){(0,n.FA)(s,c)})},o}()},39813:(r,t,e)=>{var n=e(75768),i=e(28081);i.t.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)},Object.defineProperty(i.t.prototype,"sphericalPolynomial",{get:function(){var o=this;if(this._texture){if(this._texture._sphericalPolynomial||this._texture._sphericalPolynomialComputed)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomialPromise||(this._texture._sphericalPolynomialPromise=n.d.ConvertCubeMapTextureToSphericalPolynomial(this),this._texture._sphericalPolynomialPromise===null?this._texture._sphericalPolynomialComputed=!0:this._texture._sphericalPolynomialPromise.then(function(a){o._texture._sphericalPolynomial=a,o._texture._sphericalPolynomialComputed=!0})),null}return null},set:function(o){this._texture&&(this._texture._sphericalPolynomial=o)},enumerable:!0,configurable:!0})},28081:(r,t,e)=>{e.d(t,{t:()=>h});var n=e(78322),i=e(6174),o=e(66377),a=e(8046),s=e(66614),l=e(81152),c=e(23885),u=(e(17347),e(63919)),d=e(12028),h=(e(82345),function(p){function m(v,b){b===void 0&&(b=null);var E=p.call(this,null)||this;return E.metadata=null,E.reservedDataStore=null,E._hasAlpha=!1,E._getAlphaFromRGB=!1,E.level=1,E._coordinatesIndex=0,E.optimizeUVAllocation=!0,E._coordinatesMode=l.Y.TEXTURE_EXPLICIT_MODE,E.wrapR=l.Y.TEXTURE_WRAP_ADDRESSMODE,E.anisotropicFilteringLevel=m.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,E._isCube=!1,E._gammaSpace=!0,E.invertZ=!1,E.lodLevelInAlpha=!1,E.isRenderTarget=!1,E._prefiltered=!1,E._forceSerialize=!1,E.animations=[],E.onDisposeObservable=new o.cP,E._onDisposeObserver=null,E._scene=null,E._uid=null,E._parentContainer=null,E._loadingError=!1,v?m._IsScene(v)?E._scene=v:E._engine=v:E._scene=s.q.LastCreatedScene,E._scene&&(E.uniqueId=E._scene.getUniqueId(),E._scene.addTexture(E),E._engine=E._scene.getEngine()),E._texture=b,E._uid=null,E}return(0,n.C6)(m,p),Object.defineProperty(m.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(v){var b=this;this._hasAlpha!==v&&(this._hasAlpha=v,this._scene&&this._scene.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(E){return E.hasTexture(b)}))},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"getAlphaFromRGB",{get:function(){return this._getAlphaFromRGB},set:function(v){var b=this;this._getAlphaFromRGB!==v&&(this._getAlphaFromRGB=v,this._scene&&this._scene.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(E){return E.hasTexture(b)}))},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"coordinatesIndex",{get:function(){return this._coordinatesIndex},set:function(v){var b=this;this._coordinatesIndex!==v&&(this._coordinatesIndex=v,this._scene&&this._scene.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(E){return E.hasTexture(b)}))},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(v){var b=this;this._coordinatesMode!==v&&(this._coordinatesMode=v,this._scene&&this._scene.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(E){return E.hasTexture(b)}))},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"wrapU",{get:function(){return this._wrapU},set:function(v){this._wrapU=v},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"wrapV",{get:function(){return this._wrapV},set:function(v){this._wrapV=v},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"isCube",{get:function(){return this._texture?this._texture.isCube:this._isCube},set:function(v){this._texture?this._texture.isCube=v:this._isCube=v},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(v){this._texture&&(this._texture.is3D=v)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"is2DArray",{get:function(){return!!this._texture&&this._texture.is2DArray},set:function(v){this._texture&&(this._texture.is2DArray=v)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"gammaSpace",{get:function(){return this._texture?(this._texture._gammaSpace===null&&(this._texture._gammaSpace=this._gammaSpace),this._texture._gammaSpace&&!this._texture._useSRGBBuffer):this._gammaSpace},set:function(v){var b,E=this;if(this._texture){if(this._texture._gammaSpace===v)return;this._texture._gammaSpace=v}else{if(this._gammaSpace===v)return;this._gammaSpace=v}(b=this.getScene())===null||b===void 0||b.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(C){return C.hasTexture(E)})},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"isRGBD",{get:function(){return this._texture!=null&&this._texture._isRGBD},set:function(v){var b,E=this;v!==this.isRGBD&&(this._texture&&(this._texture._isRGBD=v),(b=this.getScene())===null||b===void 0||b.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(C){return C.hasTexture(E)}))},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"noMipmap",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(v){this._texture&&(this._texture._lodGenerationOffset=v)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0},set:function(v){this._texture&&(this._texture._lodGenerationScale=v)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"linearSpecularLOD",{get:function(){return!!this._texture&&this._texture._linearSpecularLOD},set:function(v){this._texture&&(this._texture._linearSpecularLOD=v)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"irradianceTexture",{get:function(){return this._texture?this._texture._irradianceTexture:null},set:function(v){this._texture&&(this._texture._irradianceTexture=v)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"uid",{get:function(){return this._uid||(this._uid=(0,c.z)()),this._uid},enumerable:!1,configurable:!0}),m.prototype.toString=function(){return this.name},m.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(m.prototype,"onDispose",{set:function(v){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(v)},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"isBlocking",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"loadingError",{get:function(){return this._loadingError},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!1,configurable:!0}),m.prototype.getScene=function(){return this._scene},m.prototype._getEngine=function(){return this._engine},m.prototype.getTextureMatrix=function(){return a.uq.IdentityReadOnly},m.prototype.getReflectionTextureMatrix=function(){return a.uq.IdentityReadOnly},m.prototype.getRefractionTextureMatrix=function(){return this.getReflectionTextureMatrix()},m.prototype.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()||this.loadingError},m.prototype.scale=function(v){},Object.defineProperty(m.prototype,"canRescale",{get:function(){return!1},enumerable:!1,configurable:!0}),m.prototype._getFromCache=function(v,b,E,C,T,f){var g=this._getEngine();if(!g)return null;for(var S=g._getUseSRGBBuffer(!!T,b),y=g.getLoadedTexturesCache(),x=0;x<y.length;x++){var R=y[x];if(!(T!==void 0&&S!==R._useSRGBBuffer||C!==void 0&&C!==R.invertY||R.url!==v||R.generateMipMaps!==!b||E&&E!==R.samplingMode||f!==void 0&&f!==R.isCube))return R.incrementReferences(),R}return null},m.prototype._rebuild=function(v){},m.prototype.clone=function(){return null},Object.defineProperty(m.prototype,"textureType",{get:function(){return this._texture&&this._texture.type!==void 0?this._texture.type:l.Y.TEXTURETYPE_UNSIGNED_INT},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"textureFormat",{get:function(){return this._texture&&this._texture.format!==void 0?this._texture.format:l.Y.TEXTUREFORMAT_RGBA},enumerable:!1,configurable:!0}),m.prototype._markAllSubMeshesAsTexturesDirty=function(){var v=this.getScene();v&&v.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag)},m.prototype.readPixels=function(v,b,E,C,T,f,g,S,y){if(v===void 0&&(v=0),b===void 0&&(b=0),E===void 0&&(E=null),C===void 0&&(C=!0),T===void 0&&(T=!1),f===void 0&&(f=0),g===void 0&&(g=0),S===void 0&&(S=Number.MAX_VALUE),y===void 0&&(y=Number.MAX_VALUE),!this._texture)return null;var x=this._getEngine();if(!x)return null;var R=this.getSize(),I=R.width,M=R.height;b!==0&&(I/=Math.pow(2,b),M/=Math.pow(2,b),I=Math.round(I),M=Math.round(M)),S=Math.min(I,S),y=Math.min(M,y);try{return this._texture.isCube?x._readTexturePixels(this._texture,S,y,v,b,E,C,T,f,g):x._readTexturePixels(this._texture,S,y,-1,b,E,C,T,f,g)}catch{return null}},m.prototype._readPixelsSync=function(v,b,E,C,T){if(v===void 0&&(v=0),b===void 0&&(b=0),E===void 0&&(E=null),C===void 0&&(C=!0),T===void 0&&(T=!1),!this._texture)return null;var f=this.getSize(),g=f.width,S=f.height,y=this._getEngine();if(!y)return null;b!=0&&(g/=Math.pow(2,b),S/=Math.pow(2,b),g=Math.round(g),S=Math.round(S));try{return this._texture.isCube?y._readTexturePixelsSync(this._texture,g,S,v,b,E,C,T):y._readTexturePixelsSync(this._texture,g,S,-1,b,E,C,T)}catch{return null}},Object.defineProperty(m.prototype,"_lodTextureHigh",{get:function(){return this._texture?this._texture._lodTextureHigh:null},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"_lodTextureMid",{get:function(){return this._texture?this._texture._lodTextureMid:null},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"_lodTextureLow",{get:function(){return this._texture?this._texture._lodTextureLow:null},enumerable:!1,configurable:!0}),m.prototype.dispose=function(){if(this._scene){this._scene.stopAnimation&&this._scene.stopAnimation(this),this._scene.removePendingData(this);var v=this._scene.textures.indexOf(this);if(v>=0&&this._scene.textures.splice(v,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){var b=this._parentContainer.textures.indexOf(this);b>-1&&this._parentContainer.textures.splice(b,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,p.prototype.dispose.call(this)},m.prototype.serialize=function(v){if(v===void 0&&(v=!1),!this.name&&!v)return null;var b=d.p.Serialize(this);return d.p.AppendSerializedAnimations(this,b),b},m.WhenAllReady=function(v,b){var E=v.length;if(E!==0)for(var C=0;C<v.length;C++){var T=v[C];if(T.isReady())--E==0&&b();else{var f=T.onLoadObservable;f?f.addOnce(function(){--E==0&&b()}):--E==0&&b()}}else b()},m._IsScene=function(v){return v.getClassName()==="Scene"},m.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,(0,n.Cg)([(0,i.lK)()],m.prototype,"uniqueId",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"name",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"metadata",void 0),(0,n.Cg)([(0,i.lK)("hasAlpha")],m.prototype,"_hasAlpha",void 0),(0,n.Cg)([(0,i.lK)("getAlphaFromRGB")],m.prototype,"_getAlphaFromRGB",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"level",void 0),(0,n.Cg)([(0,i.lK)("coordinatesIndex")],m.prototype,"_coordinatesIndex",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"optimizeUVAllocation",void 0),(0,n.Cg)([(0,i.lK)("coordinatesMode")],m.prototype,"_coordinatesMode",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"wrapU",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"wrapV",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"wrapR",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"anisotropicFilteringLevel",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"isCube",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"is3D",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"is2DArray",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"gammaSpace",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"invertZ",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"lodLevelInAlpha",void 0),(0,n.Cg)([(0,i.lK)()],m.prototype,"lodGenerationOffset",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"lodGenerationScale",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"linearSpecularLOD",null),(0,n.Cg)([(0,i.uM)()],m.prototype,"irradianceTexture",null),(0,n.Cg)([(0,i.lK)()],m.prototype,"isRenderTarget",void 0),m}(u.D))},19133:(r,t,e)=>{e.d(t,{G:()=>n,h:()=>s});var n,i=e(78322),o=e(66377),a=e(55204);(function(l){l[l.Unknown=0]="Unknown",l[l.Url=1]="Url",l[l.Temp=2]="Temp",l[l.Raw=3]="Raw",l[l.Dynamic=4]="Dynamic",l[l.RenderTarget=5]="RenderTarget",l[l.MultiRenderTarget=6]="MultiRenderTarget",l[l.Cube=7]="Cube",l[l.CubeRaw=8]="CubeRaw",l[l.CubePrefiltered=9]="CubePrefiltered",l[l.Raw3D=10]="Raw3D",l[l.Raw2DArray=11]="Raw2DArray",l[l.DepthStencil=12]="DepthStencil",l[l.CubeRawRGBD=13]="CubeRawRGBD",l[l.Depth=14]="Depth"})(n||(n={}));var s=function(l){function c(u,d,h){h===void 0&&(h=!1);var p=l.call(this)||this;return p.isReady=!1,p.isCube=!1,p.is3D=!1,p.is2DArray=!1,p.isMultiview=!1,p.url="",p.generateMipMaps=!1,p.samples=0,p.type=-1,p.format=-1,p.onLoadedObservable=new o.cP,p.onErrorObservable=new o.cP,p.onRebuildCallback=null,p.width=0,p.height=0,p.depth=0,p.baseWidth=0,p.baseHeight=0,p.baseDepth=0,p.invertY=!1,p._invertVScale=!1,p._associatedChannel=-1,p._source=0,p._buffer=null,p._bufferView=null,p._bufferViewArray=null,p._bufferViewArrayArray=null,p._size=0,p._extension="",p._files=null,p._workingCanvas=null,p._workingContext=null,p._cachedCoordinatesMode=null,p._isDisabled=!1,p._compression=null,p._sphericalPolynomial=null,p._sphericalPolynomialPromise=null,p._sphericalPolynomialComputed=!1,p._lodGenerationScale=0,p._lodGenerationOffset=0,p._useSRGBBuffer=!1,p._creationFlags=0,p._lodTextureHigh=null,p._lodTextureMid=null,p._lodTextureLow=null,p._isRGBD=!1,p._linearSpecularLOD=!1,p._irradianceTexture=null,p._hardwareTexture=null,p._maxLodLevel=null,p._references=1,p._gammaSpace=null,p._premulAlpha=!1,p._dynamicTextureSource=null,p._engine=u,p._source=d,p._uniqueId=c._Counter++,h||(p._hardwareTexture=u._createHardwareTexture()),p}return(0,i.C6)(c,l),Object.defineProperty(c.prototype,"useMipMaps",{get:function(){return this.generateMipMaps},set:function(u){this.generateMipMaps=u},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),c.prototype._setUniqueId=function(u){this._uniqueId=u},c.prototype.getEngine=function(){return this._engine},Object.defineProperty(c.prototype,"source",{get:function(){return this._source},enumerable:!1,configurable:!0}),c.prototype.incrementReferences=function(){this._references++},c.prototype.updateSize=function(u,d,h){h===void 0&&(h=1),this._engine.updateTextureDimensions(this,u,d,h),this.width=u,this.height=d,this.depth=h,this.baseWidth=u,this.baseHeight=d,this.baseDepth=h,this._size=u*d*h},c.prototype._rebuild=function(){var u,d,h=this;if(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this.onRebuildCallback){var p=this.onRebuildCallback(this),m=function(b){b._swapAndDie(h,!1),h.isReady=p.isReady};p.isAsync?p.proxy.then(m):m(p.proxy)}else{var v;switch(this.source){case 2:case 12:case 14:break;case 1:return void(v=this._engine.createTexture((u=this._originalUrl)!==null&&u!==void 0?u:this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,function(b){b._swapAndDie(h,!1),h.isReady=!0},null,this._buffer,void 0,this.format,this._extension,void 0,void 0,void 0,this._useSRGBBuffer));case 3:(v=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type,this._creationFlags,this._useSRGBBuffer))._swapAndDie(this,!1),this.isReady=!0;break;case 10:(v=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type))._swapAndDie(this,!1),this.isReady=!0;break;case 11:(v=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type))._swapAndDie(this,!1),this.isReady=!0;break;case 4:(v=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode))._swapAndDie(this,!1),this._dynamicTextureSource&&this._engine.updateDynamicTexture(this,this._dynamicTextureSource,this.invertY,this._premulAlpha,this.format,!0);break;case 7:return void(v=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,function(){v._swapAndDie(h,!1),h.isReady=!0},null,this.format,this._extension,!1,0,0,null,void 0,this._useSRGBBuffer,ArrayBuffer.isView(this._buffer)?this._buffer:null));case 8:(v=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,(d=this._originalFormat)!==null&&d!==void 0?d:this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this,!1),this.isReady=!0;break;case 13:return;case 9:return void((v=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,function(b){b&&b._swapAndDie(h,!1),h.isReady=!0},null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}}},c.prototype._swapAndDie=function(u,d){var h;d===void 0&&(d=!0),(h=this._hardwareTexture)===null||h===void 0||h.setUsage(u._source,this.generateMipMaps,this.is2DArray,this.isCube,this.is3D,this.width,this.height,this.depth),u._hardwareTexture=this._hardwareTexture,d&&(u._isRGBD=this._isRGBD),this._lodTextureHigh&&(u._lodTextureHigh&&u._lodTextureHigh.dispose(),u._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(u._lodTextureMid&&u._lodTextureMid.dispose(),u._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(u._lodTextureLow&&u._lodTextureLow.dispose(),u._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(u._irradianceTexture&&u._irradianceTexture.dispose(),u._irradianceTexture=this._irradianceTexture);var p=this._engine.getLoadedTexturesCache(),m=p.indexOf(this);m!==-1&&p.splice(m,1),(m=p.indexOf(u))===-1&&p.push(u)},c.prototype.dispose=function(){this._references--,this.onLoadedObservable.clear(),this.onErrorObservable.clear(),this._references===0&&(this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)},c._Counter=0,c}(a.u)},54665:(r,t,e)=>{var n,i,o;e.d(t,{GQ:()=>o,Ok:()=>n,Xl:()=>i}),function(a){a[a.ETC1S=0]="ETC1S",a[a.UASTC4x4=1]="UASTC4x4"}(n||(n={})),function(a){a[a.ASTC_4X4_RGBA=0]="ASTC_4X4_RGBA",a[a.BC7_RGBA=1]="BC7_RGBA",a[a.BC3_RGBA=2]="BC3_RGBA",a[a.BC1_RGB=3]="BC1_RGB",a[a.PVRTC1_4_RGBA=4]="PVRTC1_4_RGBA",a[a.PVRTC1_4_RGB=5]="PVRTC1_4_RGB",a[a.ETC2_RGBA=6]="ETC2_RGBA",a[a.ETC1_RGB=7]="ETC1_RGB",a[a.RGBA32=8]="RGBA32",a[a.R8=9]="R8",a[a.RG8=10]="RG8"}(i||(i={})),function(a){a[a.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",a[a.COMPRESSED_RGBA_ASTC_4X4_KHR=37808]="COMPRESSED_RGBA_ASTC_4X4_KHR",a[a.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",a[a.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",a[a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",a[a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",a[a.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",a[a.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",a[a.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",a[a.RGBA8Format=32856]="RGBA8Format",a[a.R8Format=33321]="R8Format",a[a.RG8Format=33323]="RG8Format"}(o||(o={}))},41085:(r,t,e)=>{e.d(t,{$:()=>p});var n=e(78322),i=e(66377),o=e(8046),a=e(50582),s=e(63639),l=e(7931),c=e(81152),u=(e(71073),e(8864),e(64838),e(11296)),d=e(24687),h=e(87074);e(74239).M.prototype.setDepthStencilTexture=function(m,v){this._engine.setDepthStencilTexture(this._samplers[m],this._uniforms[m],v,m)};var p=function(m){function v(b,E,C,T,f,g,S,y,x,R,I,M,D,B,F,X,$){T===void 0&&(T=!1),f===void 0&&(f=!0),g===void 0&&(g=c.Y.TEXTURETYPE_UNSIGNED_INT),S===void 0&&(S=!1),y===void 0&&(y=a.g.TRILINEAR_SAMPLINGMODE),x===void 0&&(x=!0),R===void 0&&(R=!1),I===void 0&&(I=!1),M===void 0&&(M=c.Y.TEXTUREFORMAT_RGBA),D===void 0&&(D=!1),X===void 0&&(X=!1),$===void 0&&($=!1);var Q,ie,q,ee,te,ce,fe,de=this,Te=void 0,ue=!0;if(typeof T=="object"){var U=T;T=!!U.generateMipMaps,f=(Q=U.doNotChangeAspectRatio)===null||Q===void 0||Q,g=(ie=U.type)!==null&&ie!==void 0?ie:c.Y.TEXTURETYPE_UNSIGNED_BYTE,S=!!U.isCube,y=(q=U.samplingMode)!==null&&q!==void 0?q:a.g.TRILINEAR_SAMPLINGMODE,x=(ee=U.generateDepthBuffer)===null||ee===void 0||ee,R=!!U.generateStencilBuffer,I=!!U.isMulti,M=(te=U.format)!==null&&te!==void 0?te:c.Y.TEXTUREFORMAT_RGBA,D=!!U.delayAllocation,B=U.samples,F=U.creationFlags,X=!!U.noColorAttachment,$=!!U.useSRGBBuffer,Te=U.colorAttachment,ue=(ce=U.gammaSpace)!==null&&ce!==void 0?ce:ue}if((de=m.call(this,null,C,!T,void 0,y,void 0,void 0,void 0,void 0,M)||this)._unObserveRenderList=null,de._renderListHasChanged=function(w,k){var J,le=de._renderList?de._renderList.length:0;(k===0&&le>0||le===0)&&((J=de.getScene())===null||J===void 0||J.meshes.forEach(function(be){be._markSubMeshesAsLightDirty()}))},de.renderParticles=!0,de.renderSprites=!1,de.forceLayerMaskCheck=!1,de.ignoreCameraViewport=!1,de.onBeforeBindObservable=new i.cP,de.onAfterUnbindObservable=new i.cP,de.onBeforeRenderObservable=new i.cP,de.onAfterRenderObservable=new i.cP,de.onClearObservable=new i.cP,de.onResizeObservable=new i.cP,de._cleared=!1,de.skipInitialClear=!1,de._currentRefreshId=-1,de._refreshRate=1,de._samples=1,de._canRescale=!0,de._renderTarget=null,de.boundingBoxPosition=o.Pq.Zero(),!(C=de.getScene()))return de;var N=de.getScene().getEngine();return de._gammaSpace=ue,de._coordinatesMode=a.g.PROJECTION_MODE,de.renderList=[],de.name=b,de.isRenderTarget=!0,de._initialSizeParameter=E,de._renderPassIds=[],de._isCubeData=S,de._processSizeParameter(E),de.renderPassId=de._renderPassIds[0],de._resizeObserver=N.onResizeObservable.add(function(){}),de._generateMipMaps=!!T,de._doNotChangeAspectRatio=f,de._renderingManager=new l.m(C),de._renderingManager._useSceneAutoClearSetup=!0,I||(de._renderTargetOptions={generateMipMaps:T,type:g,format:(fe=de._format)!==null&&fe!==void 0?fe:void 0,samplingMode:de.samplingMode,generateDepthBuffer:x,generateStencilBuffer:R,samples:B,creationFlags:F,noColorAttachment:X,useSRGBBuffer:$,colorAttachment:Te,label:de.name},de.samplingMode===a.g.NEAREST_SAMPLINGMODE&&(de.wrapU=a.g.CLAMP_ADDRESSMODE,de.wrapV=a.g.CLAMP_ADDRESSMODE),D||(S?(de._renderTarget=C.getEngine().createRenderTargetCubeTexture(de.getRenderSize(),de._renderTargetOptions),de.coordinatesMode=a.g.INVCUBIC_MODE,de._textureMatrix=o.uq.Identity()):de._renderTarget=C.getEngine().createRenderTargetTexture(de._size,de._renderTargetOptions),de._texture=de._renderTarget.texture,B!==void 0&&(de.samples=B))),de}return(0,n.C6)(v,m),Object.defineProperty(v.prototype,"renderList",{get:function(){return this._renderList},set:function(b){this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),b&&(this._unObserveRenderList=(0,u.lL)(b,this._renderListHasChanged)),this._renderList=b},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"postProcesses",{get:function(){return this._postProcesses},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"_prePassEnabled",{get:function(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"onAfterUnbind",{set:function(b){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(b)},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"onBeforeRender",{set:function(b){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(b)},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"onAfterRender",{set:function(b){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(b)},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"onClear",{set:function(b){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(b)},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"renderPassIds",{get:function(){return this._renderPassIds},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"currentRefreshId",{get:function(){return this._currentRefreshId},enumerable:!1,configurable:!0}),v.prototype.setMaterialForRendering=function(b,E){var C;C=Array.isArray(b)?b:[b];for(var T=0;T<C.length;++T)for(var f=0;f<this._renderPassIds.length;++f)C[T].setMaterialForRenderPass(this._renderPassIds[f],E!==void 0?Array.isArray(E)?E[f]:E:void 0)},Object.defineProperty(v.prototype,"isMulti",{get:function(){var b,E;return(E=(b=this._renderTarget)===null||b===void 0?void 0:b.isMulti)!==null&&E!==void 0&&E},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"renderTarget",{get:function(){return this._renderTarget},enumerable:!1,configurable:!0}),v.prototype._onRatioRescale=function(){this._sizeRatio&&this.resize(this._initialSizeParameter)},Object.defineProperty(v.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(b){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(b)){this._boundingBoxSize=b;var E=this.getScene();E&&E.markAllMaterialsAsDirty(c.Y.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"depthStencilTexture",{get:function(){var b,E;return(E=(b=this._renderTarget)===null||b===void 0?void 0:b._depthStencilTexture)!==null&&E!==void 0?E:null},enumerable:!1,configurable:!0}),v.prototype.createDepthStencilTexture=function(b,E,C,T,f,g){var S;b===void 0&&(b=0),E===void 0&&(E=!0),C===void 0&&(C=!1),T===void 0&&(T=1),f===void 0&&(f=c.Y.TEXTUREFORMAT_DEPTH32_FLOAT),(S=this._renderTarget)===null||S===void 0||S.createDepthStencilTexture(b,E,C,T,f,g)},v.prototype._releaseRenderPassId=function(){if(this._scene)for(var b=this._scene.getEngine(),E=0;E<this._renderPassIds.length;++E)b.releaseRenderPassId(this._renderPassIds[E]);this._renderPassIds=[]},v.prototype._createRenderPassId=function(){this._releaseRenderPassId();for(var b=this._scene.getEngine(),E=this._isCubeData?6:this.getRenderLayers()||1,C=0;C<E;++C)this._renderPassIds[C]=b.createRenderPassId("RenderTargetTexture - ".concat(this.name,"#").concat(C))},v.prototype._processSizeParameter=function(b,E){if(E===void 0&&(E=!0),b.ratio){this._sizeRatio=b.ratio;var C=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(C.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(C.getRenderHeight(),this._sizeRatio)}}else this._size=b;E&&this._createRenderPassId()},Object.defineProperty(v.prototype,"samples",{get:function(){var b,E;return(E=(b=this._renderTarget)===null||b===void 0?void 0:b.samples)!==null&&E!==void 0?E:this._samples},set:function(b){this._renderTarget&&(this._samples=this._renderTarget.setSamples(b))},enumerable:!1,configurable:!0}),v.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(v.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(b){this._refreshRate=b,this.resetRefreshCounter()},enumerable:!1,configurable:!0}),v.prototype.addPostProcess=function(b){if(!this._postProcessManager){var E=this.getScene();if(!E)return;this._postProcessManager=new s.X(E),this._postProcesses=new Array}this._postProcesses.push(b),this._postProcesses[0].autoClear=!1},v.prototype.clearPostProcesses=function(b){if(b===void 0&&(b=!1),this._postProcesses){if(b)for(var E=0,C=this._postProcesses;E<C.length;E++)C[E].dispose();this._postProcesses=[]}},v.prototype.removePostProcess=function(b){if(this._postProcesses){var E=this._postProcesses.indexOf(b);E!==-1&&(this._postProcesses.splice(E,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}},v.prototype._shouldRender=function(){return this._currentRefreshId===-1||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},v.prototype.getRenderSize=function(){return this.getRenderWidth()},v.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},v.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},v.prototype.getRenderLayers=function(){var b=this._size.layers;return b||this._size.depth||0},v.prototype.disableRescaling=function(){this._canRescale=!1},Object.defineProperty(v.prototype,"canRescale",{get:function(){return this._canRescale},enumerable:!1,configurable:!0}),v.prototype.scale=function(b){var E=Math.max(1,this.getRenderSize()*b);this.resize(E)},v.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:m.prototype.getReflectionTextureMatrix.call(this)},v.prototype.resize=function(b){var E,C=this.isCube;(E=this._renderTarget)===null||E===void 0||E.dispose(),this._renderTarget=null;var T=this.getScene();T&&(this._processSizeParameter(b,!1),this._renderTarget=C?T.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):T.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,this._renderTargetOptions.samples!==void 0&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},v.prototype.render=function(b,E){b===void 0&&(b=!1),E===void 0&&(E=!1),this._render(b,E)},v.prototype.isReadyForRendering=function(){return this._render(!1,!1,!0)},v.prototype._render=function(b,E,C){var T;b===void 0&&(b=!1),E===void 0&&(E=!1),C===void 0&&(C=!1);var f=this.getScene();if(!f)return C;var g=f.getEngine();if(this.useCameraPostProcesses!==void 0&&(b=this.useCameraPostProcesses),this._waitingRenderList){if(!this.renderListPredicate){this.renderList=[];for(var S=0;S<this._waitingRenderList.length;S++){var y=this._waitingRenderList[S];(I=f.getMeshById(y))&&this.renderList.push(I)}}this._waitingRenderList=void 0}if(this.renderListPredicate){this.renderList?this.renderList.length=0:this.renderList=[];var x=this.getScene();if(!x)return C;var R=x.meshes;for(S=0;S<R.length;S++){var I=R[S];this.renderListPredicate(I)&&this.renderList.push(I)}}var M=g.currentRenderPassId;this.onBeforeBindObservable.notifyObservers(this);var D=(T=this.activeCamera)!==null&&T!==void 0?T:f.activeCamera,B=f.activeCamera;D&&(D!==f.activeCamera&&(f.setTransformMatrix(D.getViewMatrix(),D.getProjectionMatrix(!0)),f.activeCamera=D),g.setViewport(D.rigParent?D.rigParent.viewport:D.viewport,this.getRenderWidth(),this.getRenderHeight())),this._defaultRenderListPrepared=!1;var F=C;if(C){f.getViewMatrix()||f.updateTransformMatrix();var X=this.is2DArray||this.is3D?this.getRenderLayers():this.isCube?6:1;for(te=0;te<X&&F;te++){var $=null,Q=this.renderList?this.renderList:f.getActiveMeshes().data,ie=this.renderList?this.renderList.length:f.getActiveMeshes().length;g.currentRenderPassId=this._renderPassIds[te],this.onBeforeRenderObservable.notifyObservers(te),this.getCustomRenderList&&($=this.getCustomRenderList(te,Q,ie)),$||($=Q),this._doNotChangeAspectRatio||f.updateTransformMatrix(!0);for(var q=0;q<$.length&&F;++q)if((I=$[q]).isEnabled()&&!I.isBlocked&&I.isVisible&&I.subMeshes){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(I,this.refreshRate,C)){F=!1;continue}}else if(!I.isReady(!0)){F=!1;continue}}this.onAfterRenderObservable.notifyObservers(te),(this.is2DArray||this.is3D||this.isCube)&&(f.incrementRenderId(),f.resetCachedMaterial())}}else if(!this.is2DArray&&!this.is3D||this.isMulti)if(this.isCube&&!this.isMulti)for(var ee=0;ee<6;ee++)this._renderToTarget(ee,b,E,void 0,D),f.incrementRenderId(),f.resetCachedMaterial();else this._renderToTarget(0,b,E,void 0,D);else for(var te=0;te<this.getRenderLayers();te++)this._renderToTarget(0,b,E,te,D),f.incrementRenderId(),f.resetCachedMaterial();return this.onAfterUnbindObservable.notifyObservers(this),g.currentRenderPassId=M,B&&(f.activeCamera=B,this.activeCamera&&this.activeCamera!==f.activeCamera&&f.setTransformMatrix(f.activeCamera.getViewMatrix(),f.activeCamera.getProjectionMatrix(!0)),g.setViewport(f.activeCamera.viewport)),f.resetCachedMaterial(),F},v.prototype._bestReflectionRenderTargetDimension=function(b,E){var C=b*E,T=(0,h.OG)(C+16384/(128+C));return Math.min((0,h.C4)(b),T)},v.prototype._prepareRenderingManager=function(b,E,C,T){var f=this.getScene();if(f){this._renderingManager.reset();for(var g=f.getRenderId(),S=0;S<E;S++){var y=b[S];if(y&&!y.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(y,this.refreshRate,!1)){this.resetRefreshCounter();continue}}else if(!y.isReady(this.refreshRate===0)){this.resetRefreshCounter();continue}if(!y._internalAbstractMeshDataInfo._currentLODIsUpToDate&&f.activeCamera&&(y._internalAbstractMeshDataInfo._currentLOD=f.customLODSelector?f.customLODSelector(y,this.activeCamera||f.activeCamera):y.getLOD(this.activeCamera||f.activeCamera),y._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0),!y._internalAbstractMeshDataInfo._currentLOD)continue;var x=y._internalAbstractMeshDataInfo._currentLOD;x._preActivateForIntermediateRendering(g);var R;if(R=!(!T||!C||y.layerMask&C.layerMask),y.isEnabled()&&y.isVisible&&y.subMeshes&&!R){if(x!==y&&x._activate(g,!0),y._activate(g,!0)&&y.subMeshes.length){y.isAnInstance?y._internalAbstractMeshDataInfo._actAsRegularMesh&&(x=y):x._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,x._internalAbstractMeshDataInfo._isActiveIntermediate=!0;for(var I=0;I<x.subMeshes.length;I++){var M=x.subMeshes[I];this._renderingManager.dispatch(M,x)}}y._postActivate()}}}for(var D=0;D<f.particleSystems.length;D++){var B=f.particleSystems[D],F=B.emitter;B.isStarted()&&F&&(!F.position||F.isEnabled())&&this._renderingManager.dispatchParticles(B)}}},v.prototype._bindFrameBuffer=function(b,E){b===void 0&&(b=0),E===void 0&&(E=0);var C=this.getScene();if(C){var T=C.getEngine();this._renderTarget&&T.bindFramebuffer(this._renderTarget,this.isCube?b:void 0,void 0,void 0,this.ignoreCameraViewport,0,E)}},v.prototype._unbindFrameBuffer=function(b,E){var C=this;this._renderTarget&&b.unBindFramebuffer(this._renderTarget,this.isCube,function(){C.onAfterRenderObservable.notifyObservers(E)})},v.prototype._prepareFrame=function(b,E,C,T){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses):T&&b.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(E,C)},v.prototype._renderToTarget=function(b,E,C,T,f){var g,S,y,x,R,I;T===void 0&&(T=0),f===void 0&&(f=null);var M=this.getScene();if(M){var D=M.getEngine();if((g=D._debugPushGroup)===null||g===void 0||g.call(D,"render to face #".concat(b," layer #").concat(T),1),this._prepareFrame(M,b,T,E),this.is2DArray||this.is3D?(D.currentRenderPassId=this._renderPassIds[T],this.onBeforeRenderObservable.notifyObservers(T)):(D.currentRenderPassId=this._renderPassIds[b],this.onBeforeRenderObservable.notifyObservers(b)),D.snapshotRendering&&D.snapshotRenderingMode===c.Y.SNAPSHOTRENDERING_FAST)this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(D):this.skipInitialClear||D.clear(this.clearColor||M.clearColor,!0,!0,!0);else{var B=null,F=this.renderList?this.renderList:M.getActiveMeshes().data,X=this.renderList?this.renderList.length:M.getActiveMeshes().length;this.getCustomRenderList&&(B=this.getCustomRenderList(this.is2DArray||this.is3D?T:b,F,X)),B?this._prepareRenderingManager(B,B.length,f,this.forceLayerMaskCheck):(this._defaultRenderListPrepared||(this._prepareRenderingManager(F,X,f,!this.renderList||this.forceLayerMaskCheck),this._defaultRenderListPrepared=!0),B=F);for(var $=0,Q=M._beforeRenderTargetClearStage;$<Q.length;$++)Q[$].action(this,b,T);this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(D):this.skipInitialClear||D.clear(this.clearColor||M.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||M.updateTransformMatrix(!0);for(var ie=0,q=M._beforeRenderTargetDrawStage;ie<q.length;ie++)q[ie].action(this,b,T);this._renderingManager.render(this.customRenderFunction,B,this.renderParticles,this.renderSprites);for(var ee=0,te=M._afterRenderTargetDrawStage;ee<te.length;ee++)te[ee].action(this,b,T);var ce=(y=(S=this._texture)===null||S===void 0?void 0:S.generateMipMaps)!==null&&y!==void 0&&y;this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,(x=this._renderTarget)!==null&&x!==void 0?x:void 0,b,this._postProcesses,this.ignoreCameraViewport):E&&M.postProcessManager._finalizeFrame(!1,(R=this._renderTarget)!==null&&R!==void 0?R:void 0,b);for(var fe=0,de=M._afterRenderTargetPostProcessStage;fe<de.length;fe++)de[fe].action(this,b,T);this._texture&&(this._texture.generateMipMaps=ce),this._doNotChangeAspectRatio||M.updateTransformMatrix(!0),C&&(0,d.yp)(this.getRenderWidth(),this.getRenderHeight(),D)}this._unbindFrameBuffer(D,b),this._texture&&this.isCube&&b===5&&D.generateMipMapsForCubemap(this._texture,!0),(I=D._debugPopGroup)===null||I===void 0||I.call(D,1)}},v.prototype.setRenderingOrder=function(b,E,C,T){E===void 0&&(E=null),C===void 0&&(C=null),T===void 0&&(T=null),this._renderingManager.setRenderingOrder(b,E,C,T)},v.prototype.setRenderingAutoClearDepthStencil=function(b,E){this._renderingManager.setRenderingAutoClearDepthStencil(b,E),this._renderingManager._useSceneAutoClearSetup=!1},v.prototype.clone=function(){var b=this.getSize(),E=new v(this.name,b,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);return E.hasAlpha=this.hasAlpha,E.level=this.level,E.coordinatesMode=this.coordinatesMode,this.renderList&&(E.renderList=this.renderList.slice(0)),E},v.prototype.serialize=function(){if(!this.name)return null;var b=m.prototype.serialize.call(this);if(b.renderTargetSize=this.getRenderSize(),b.renderList=[],this.renderList)for(var E=0;E<this.renderList.length;E++)b.renderList.push(this.renderList[E].id);return b},v.prototype.disposeFramebufferObjects=function(){var b;(b=this._renderTarget)===null||b===void 0||b.dispose(!0)},v.prototype.releaseInternalTexture=function(){var b;(b=this._renderTarget)===null||b===void 0||b.releaseTextures(),this._texture=null},v.prototype.dispose=function(){var b;this.onResizeObservable.clear(),this.onClearObservable.clear(),this.onAfterRenderObservable.clear(),this.onAfterUnbindObservable.clear(),this.onBeforeBindObservable.clear(),this.onBeforeRenderObservable.clear(),this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this._prePassRenderTarget&&this._prePassRenderTarget.dispose(),this._releaseRenderPassId(),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.renderList=null;var E=this.getScene();if(E){var C=E.customRenderTargets.indexOf(this);C>=0&&E.customRenderTargets.splice(C,1);for(var T=0,f=E.cameras;T<f.length;T++){var g=f[T];(C=g.customRenderTargets.indexOf(this))>=0&&g.customRenderTargets.splice(C,1)}(b=this._renderTarget)===null||b===void 0||b.dispose(),this._renderTarget=null,this._texture=null,m.prototype.dispose.call(this)}},v.prototype._rebuild=function(){this.refreshRate===v.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=v.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},v.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},v.prototype.getViewCount=function(){return 1},v.REFRESHRATE_RENDER_ONCE=0,v.REFRESHRATE_RENDER_ONEVERYFRAME=1,v.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,v}(a.g);a.g._CreateRenderTargetTexture=function(m,v,b,E,C){return new p(m,v,b,E)}},50582:(r,t,e)=>{e.d(t,{g:()=>C});var n=e(78322),i=e(6174),o=e(66377),a=e(8046),s=e(28081),l=e(81152),c=e(34623),u=e(41190),d=e(53695),h=e(252),p=e(43939),m=e(37530),v=e(75838),b=e(51956),E=e(12028),C=function(T){function f(g,S,y,x,R,I,M,D,B,F,X,$,Q,ie){R===void 0&&(R=f.TRILINEAR_SAMPLINGMODE),I===void 0&&(I=null),M===void 0&&(M=null),D===void 0&&(D=null),B===void 0&&(B=!1);var q,ee,te,ce,fe,de,Te,ue,U,N,w,k=this;(k=T.call(this,S)||this).url=null,k.uOffset=0,k.vOffset=0,k.uScale=1,k.vScale=1,k.uAng=0,k.vAng=0,k.wAng=0,k.uRotationCenter=.5,k.vRotationCenter=.5,k.wRotationCenter=.5,k.homogeneousRotationInUVTransform=!1,k.inspectableCustomProperties=null,k._noMipmap=!1,k._invertY=!1,k._rowGenerationMatrix=null,k._cachedTextureMatrix=null,k._projectionModeMatrix=null,k._t0=null,k._t1=null,k._t2=null,k._cachedUOffset=-1,k._cachedVOffset=-1,k._cachedUScale=0,k._cachedVScale=0,k._cachedUAng=-1,k._cachedVAng=-1,k._cachedWAng=-1,k._cachedReflectionProjectionMatrixId=-1,k._cachedURotationCenter=-1,k._cachedVRotationCenter=-1,k._cachedWRotationCenter=-1,k._cachedHomogeneousRotationInUVTransform=!1,k._cachedIdentity3x2=!0,k._cachedReflectionTextureMatrix=null,k._cachedReflectionUOffset=-1,k._cachedReflectionVOffset=-1,k._cachedReflectionUScale=0,k._cachedReflectionVScale=0,k._cachedReflectionCoordinatesMode=-1,k._buffer=null,k._deleteBuffer=!1,k._format=null,k._delayedOnLoad=null,k._delayedOnError=null,k.onLoadObservable=new o.cP,k._isBlocking=!0,k.name=g||"",k.url=g;var J=!1,le=null,be=!0;typeof y=="object"&&y!==null?(w=(q=y.noMipmap)!==null&&q!==void 0&&q,x=(ee=y.invertY)!==null&&ee!==void 0?ee:!b.rX,R=(te=y.samplingMode)!==null&&te!==void 0?te:f.TRILINEAR_SAMPLINGMODE,I=(ce=y.onLoad)!==null&&ce!==void 0?ce:null,M=(fe=y.onError)!==null&&fe!==void 0?fe:null,D=(de=y.buffer)!==null&&de!==void 0?de:null,B=(Te=y.deleteBuffer)!==null&&Te!==void 0&&Te,F=y.format,X=y.mimeType,$=y.loaderOptions,Q=y.creationFlags,J=(ue=y.useSRGBBuffer)!==null&&ue!==void 0&&ue,le=(U=y.internalTexture)!==null&&U!==void 0?U:null,be=(N=y.gammaSpace)!==null&&N!==void 0?N:be):w=!!y,k._gammaSpace=be,k._noMipmap=w,k._invertY=x===void 0?!b.rX:x,k._initialSamplingMode=R,k._buffer=D,k._deleteBuffer=B,k._mimeType=X,k._loaderOptions=$,k._creationFlags=Q,k._useSRGBBuffer=J,k._forcedExtension=ie,F&&(k._format=F);var ve=k.getScene(),ye=k._getEngine();if(!ye)return k;ye.onBeforeTextureInitObservable.notifyObservers(k);var Me=function(){k._texture&&(k._texture._invertVScale&&(k.vScale*=-1,k.vOffset+=1),k._texture._cachedWrapU!==null&&(k.wrapU=k._texture._cachedWrapU,k._texture._cachedWrapU=null),k._texture._cachedWrapV!==null&&(k.wrapV=k._texture._cachedWrapV,k._texture._cachedWrapV=null),k._texture._cachedWrapR!==null&&(k.wrapR=k._texture._cachedWrapR,k._texture._cachedWrapR=null)),k.onLoadObservable.hasObservers()&&k.onLoadObservable.notifyObservers(k),I&&I(),!k.isBlocking&&ve&&ve.resetCachedMaterial()},we=function(Ke,Qe){k._loadingError=!0,k._errorObject={message:Ke,exception:Qe},M&&M(Ke,Qe),f.OnTextureLoadErrorObservable.notifyObservers(k)};if(!k.url&&!le)return k._delayedOnLoad=Me,k._delayedOnError=we,k;if(k._texture=le??k._getFromCache(k.url,w,R,k._invertY,J,k.isCube),k._texture)if(k._texture.isReady)d._.SetImmediate(function(){return Me()});else{var He=k._texture.onLoadedObservable.add(Me);k._texture.onErrorObservable.add(function(Ke){var Qe;we(Ke.message,Ke.exception),(Qe=k._texture)===null||Qe===void 0||Qe.onLoadedObservable.remove(He)})}else if(ve&&ve.useDelayedTextureLoading)k.delayLoadState=l.Y.DELAYLOADSTATE_NOTLOADED,k._delayedOnLoad=Me,k._delayedOnError=we;else{try{k._texture=ye.createTexture(k.url,w,k._invertY,ve,R,Me,we,k._buffer,void 0,k._format,k._forcedExtension,X,$,Q,J)}catch(Ke){throw we("error loading",Ke),Ke}B&&(k._buffer=null)}return k}return(0,n.C6)(f,T),f._CreateVideoTexture=function(g,S,y,x,R,I,M,D,B){throw I===void 0&&(I=f.TRILINEAR_SAMPLINGMODE),B===void 0&&(B=l.Y.TEXTUREFORMAT_RGBA),(0,u.n)("VideoTexture")},Object.defineProperty(f.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"mimeType",{get:function(){return this._mimeType},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(g){this._isBlocking=g},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"invertY",{get:function(){return this._invertY},enumerable:!1,configurable:!0}),f.prototype.updateURL=function(g,S,y,x){var R=this;S===void 0&&(S=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(I){return I.hasTexture(R)})),this.name&&!this.name.startsWith("data:")||(this.name=g),this.url=g,this._buffer=S,this._forcedExtension=x,this.delayLoadState=l.Y.DELAYLOADSTATE_NOTLOADED,y&&(this._delayedOnLoad=y),this.delayLoad()},f.prototype.delayLoad=function(){if(this.delayLoadState===l.Y.DELAYLOADSTATE_NOTLOADED){var g=this.getScene();g&&(this.delayLoadState=l.Y.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?d._.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=g.getEngine().createTexture(this.url,this._noMipmap,this._invertY,g,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}},f.prototype._prepareRowForTextureGeneration=function(g,S,y,x){g*=this._cachedUScale,S*=this._cachedVScale,g-=this.uRotationCenter*this._cachedUScale,S-=this.vRotationCenter*this._cachedVScale,y-=this.wRotationCenter,a.Pq.TransformCoordinatesFromFloatsToRef(g,S,y,this._rowGenerationMatrix,x),x.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,x.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,x.z+=this.wRotationCenter},f.prototype.getTextureMatrix=function(g){var S=this;if(g===void 0&&(g=1),this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*g===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*g,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=a.uq.Zero(),this._rowGenerationMatrix=new a.uq,this._t0=a.Pq.Zero(),this._t1=a.Pq.Zero(),this._t2=a.Pq.Zero()),a.uq.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(a.uq.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,a.AA.Matrix[0]),a.uq.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,a.AA.Matrix[1]),a.uq.ScalingToRef(this._cachedUScale,this._cachedVScale,0,a.AA.Matrix[2]),a.uq.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,a.AA.Matrix[3]),a.AA.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),a.uq.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));var y=this.getScene();if(!y)return this._cachedTextureMatrix;var x=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&x!==this._cachedIdentity3x2&&y.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(R){return R.hasTexture(S)}),this._cachedTextureMatrix},f.prototype.getReflectionTextureMatrix=function(){var g=this,S=this.getScene();if(!S)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode){if(this.coordinatesMode!==f.PROJECTION_MODE)return this._cachedReflectionTextureMatrix;if(this._cachedReflectionProjectionMatrixId===S.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=a.uq.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=a.uq.Zero());var y=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case f.PLANAR_MODE:a.uq.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break;case f.PROJECTION_MODE:a.uq.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var x=S.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=x.updateFlag,x.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break;default:a.uq.IdentityToRef(this._cachedReflectionTextureMatrix)}return y&&S.markAllMaterialsAsDirty(l.Y.MATERIAL_TextureDirtyFlag,function(R){return R.hasTexture(g)}),this._cachedReflectionTextureMatrix},f.prototype.clone=function(){var g=this,S={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return E.p.Clone(function(){return new f(g._texture?g._texture.url:null,g.getScene(),S)},this)},f.prototype.serialize=function(){var g,S,y=this.name;f.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");var x=T.prototype.serialize.call(this,f._SerializeInternalTextureUniqueId);return x?((f.SerializeBuffers||f.ForceSerializeBuffers)&&(typeof this._buffer=="string"&&this._buffer.substring(0,5)==="data:"?(x.base64String=this._buffer,x.name=x.name.replace("data:","")):this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array?x.base64String="data:image/png;base64,"+(0,m.EL)(this._buffer):(f.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(x.base64String=!this._engine||this._engine._features.supportSyncTextureRead?(0,v.lP)(this):(0,v.nh)(this))),x.invertY=this._invertY,x.samplingMode=this.samplingMode,x._creationFlags=this._creationFlags,x._useSRGBBuffer=this._useSRGBBuffer,f._SerializeInternalTextureUniqueId&&(x.internalTextureUniqueId=(S=(g=this._texture)===null||g===void 0?void 0:g.uniqueId)!==null&&S!==void 0?S:void 0),x.noMipmap=this._noMipmap,this.name=y,x):null},f.prototype.getClassName=function(){return"Texture"},f.prototype.dispose=function(){T.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null},f.Parse=function(g,S,y){if(g.customType){var x=h.n.Instantiate(g.customType).Parse(g,S,y);return g.samplingMode&&x.updateSamplingMode&&x._samplingMode&&x._samplingMode!==g.samplingMode&&x.updateSamplingMode(g.samplingMode),x}if(g.isCube&&!g.isRenderTarget)return f._CubeTextureParser(g,S,y);var R,I=g.internalTextureUniqueId!==void 0;if(!g.name&&!g.isRenderTarget&&!I)return null;if(I)for(var M=0,D=S.getEngine().getLoadedTexturesCache();M<D.length;M++){var B=D[M];if(B.uniqueId===g.internalTextureUniqueId){R=B;break}}var F=function($){var Q;if($&&$._texture&&($._texture._cachedWrapU=null,$._texture._cachedWrapV=null,$._texture._cachedWrapR=null),g.samplingMode){var ie=g.samplingMode;$&&$.samplingMode!==ie&&$.updateSamplingMode(ie)}if($&&g.animations)for(var q=0;q<g.animations.length;q++){var ee=g.animations[q],te=(0,c.n9)("BABYLON.Animation");te&&$.animations.push(te.Parse(ee))}I&&!R&&((Q=$?._texture)===null||Q===void 0||Q._setUniqueId(g.internalTextureUniqueId))},X=E.p.Parse(function(){var $,Q,ie,q,ee=!0;if(g.noMipmap&&(ee=!1),g.mirrorPlane){var te=f._CreateMirror(g.name,g.renderTargetSize,S,ee);return te._waitingRenderList=g.renderList,te.mirrorPlane=p.Z.FromArray(g.mirrorPlane),F(te),te}if(g.isRenderTarget){var ce=null;if(g.isCube){if(S.reflectionProbes)for(var fe=0;fe<S.reflectionProbes.length;fe++){var de=S.reflectionProbes[fe];if(de.name===g.name)return de.cubeTexture}}else(ce=f._CreateRenderTargetTexture(g.name,g.renderTargetSize,S,ee,($=g._creationFlags)!==null&&$!==void 0?$:0))._waitingRenderList=g.renderList;return F(ce),ce}if(g.isVideo){var Te=f._CreateVideoTexture(y+(g.url||g.name),y+(g.src||g.url),S,ee,g.invertY,g.samplingMode,g.settings||{});return F(Te),Te}if(g.base64String&&!R)(q=f.CreateFromBase64String(g.base64String,g.base64String,S,!ee,g.invertY,g.samplingMode,function(){F(q)},(Q=g._creationFlags)!==null&&Q!==void 0?Q:0,(ie=g._useSRGBBuffer)!==null&&ie!==void 0&&ie)).name=g.name;else{var ue=void 0;ue=g.name&&(g.name.indexOf("://")>0||g.name.startsWith("data:"))?g.name:y+g.name,g.url&&(g.url.startsWith("data:")||f.UseSerializedUrlIfAny)&&(ue=g.url);var U={noMipmap:!ee,invertY:g.invertY,samplingMode:g.samplingMode,onLoad:function(){F(q)},internalTexture:R};q=new f(ue,S,U)}return q},g,S);return X},f.CreateFromBase64String=function(g,S,y,x,R,I,M,D,B,F,X){return I===void 0&&(I=f.TRILINEAR_SAMPLINGMODE),M===void 0&&(M=null),D===void 0&&(D=null),B===void 0&&(B=l.Y.TEXTUREFORMAT_RGBA),new f("data:"+S,y,x,R,I,M,D,g,!1,B,void 0,void 0,F,X)},f.LoadFromDataString=function(g,S,y,x,R,I,M,D,B,F,X,$){return x===void 0&&(x=!1),I===void 0&&(I=!0),M===void 0&&(M=f.TRILINEAR_SAMPLINGMODE),D===void 0&&(D=null),B===void 0&&(B=null),F===void 0&&(F=l.Y.TEXTUREFORMAT_RGBA),g.substring(0,5)!=="data:"&&(g="data:"+g),new f(g,y,R,I,M,D,B,S,x,F,void 0,void 0,X,$)},f.SerializeBuffers=!0,f.ForceSerializeBuffers=!1,f.OnTextureLoadErrorObservable=new o.cP,f._SerializeInternalTextureUniqueId=!1,f._CubeTextureParser=function(g,S,y){throw(0,u.n)("CubeTexture")},f._CreateMirror=function(g,S,y,x){throw(0,u.n)("MirrorTexture")},f._CreateRenderTargetTexture=function(g,S,y,x,R){throw(0,u.n)("RenderTargetTexture")},f.NEAREST_SAMPLINGMODE=l.Y.TEXTURE_NEAREST_SAMPLINGMODE,f.NEAREST_NEAREST_MIPLINEAR=l.Y.TEXTURE_NEAREST_NEAREST_MIPLINEAR,f.BILINEAR_SAMPLINGMODE=l.Y.TEXTURE_BILINEAR_SAMPLINGMODE,f.LINEAR_LINEAR_MIPNEAREST=l.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST,f.TRILINEAR_SAMPLINGMODE=l.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,f.LINEAR_LINEAR_MIPLINEAR=l.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR,f.NEAREST_NEAREST_MIPNEAREST=l.Y.TEXTURE_NEAREST_NEAREST_MIPNEAREST,f.NEAREST_LINEAR_MIPNEAREST=l.Y.TEXTURE_NEAREST_LINEAR_MIPNEAREST,f.NEAREST_LINEAR_MIPLINEAR=l.Y.TEXTURE_NEAREST_LINEAR_MIPLINEAR,f.NEAREST_LINEAR=l.Y.TEXTURE_NEAREST_LINEAR,f.NEAREST_NEAREST=l.Y.TEXTURE_NEAREST_NEAREST,f.LINEAR_NEAREST_MIPNEAREST=l.Y.TEXTURE_LINEAR_NEAREST_MIPNEAREST,f.LINEAR_NEAREST_MIPLINEAR=l.Y.TEXTURE_LINEAR_NEAREST_MIPLINEAR,f.LINEAR_LINEAR=l.Y.TEXTURE_LINEAR_LINEAR,f.LINEAR_NEAREST=l.Y.TEXTURE_LINEAR_NEAREST,f.EXPLICIT_MODE=l.Y.TEXTURE_EXPLICIT_MODE,f.SPHERICAL_MODE=l.Y.TEXTURE_SPHERICAL_MODE,f.PLANAR_MODE=l.Y.TEXTURE_PLANAR_MODE,f.CUBIC_MODE=l.Y.TEXTURE_CUBIC_MODE,f.PROJECTION_MODE=l.Y.TEXTURE_PROJECTION_MODE,f.SKYBOX_MODE=l.Y.TEXTURE_SKYBOX_MODE,f.INVCUBIC_MODE=l.Y.TEXTURE_INVCUBIC_MODE,f.EQUIRECTANGULAR_MODE=l.Y.TEXTURE_EQUIRECTANGULAR_MODE,f.FIXED_EQUIRECTANGULAR_MODE=l.Y.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,f.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=l.Y.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,f.CLAMP_ADDRESSMODE=l.Y.TEXTURE_CLAMP_ADDRESSMODE,f.WRAP_ADDRESSMODE=l.Y.TEXTURE_WRAP_ADDRESSMODE,f.MIRROR_ADDRESSMODE=l.Y.TEXTURE_MIRROR_ADDRESSMODE,f.UseSerializedUrlIfAny=!1,(0,n.Cg)([(0,i.lK)()],f.prototype,"url",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"uOffset",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"vOffset",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"uScale",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"vScale",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"uAng",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"vAng",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"wAng",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"uRotationCenter",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"vRotationCenter",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"wRotationCenter",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"homogeneousRotationInUVTransform",void 0),(0,n.Cg)([(0,i.lK)()],f.prototype,"isBlocking",null),f}(s.t);(0,c.Y5)("BABYLON.Texture",C),E.p._TextureParser=C.Parse},55204:(r,t,e)=>{e.d(t,{u:()=>i});var n=e(81152),i=function(){function o(){this.samplingMode=-1,this._useMipMaps=!0,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._comparisonFunction=0}return Object.defineProperty(o.prototype,"wrapU",{get:function(){return this._cachedWrapU},set:function(a){this._cachedWrapU=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"wrapV",{get:function(){return this._cachedWrapV},set:function(a){this._cachedWrapV=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"wrapR",{get:function(){return this._cachedWrapR},set:function(a){this._cachedWrapR=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"anisotropicFilteringLevel",{get:function(){return this._cachedAnisotropicFilteringLevel},set:function(a){this._cachedAnisotropicFilteringLevel=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"comparisonFunction",{get:function(){return this._comparisonFunction},set:function(a){this._comparisonFunction=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"useMipMaps",{get:function(){return this._useMipMaps},set:function(a){this._useMipMaps=a},enumerable:!1,configurable:!0}),o.prototype.setParameters=function(a,s,l,c,u,d){return a===void 0&&(a=n.Y.TEXTURE_WRAP_ADDRESSMODE),s===void 0&&(s=n.Y.TEXTURE_WRAP_ADDRESSMODE),l===void 0&&(l=n.Y.TEXTURE_WRAP_ADDRESSMODE),c===void 0&&(c=1),u===void 0&&(u=n.Y.TEXTURE_BILINEAR_SAMPLINGMODE),d===void 0&&(d=0),this._cachedWrapU=a,this._cachedWrapV=s,this._cachedWrapR=l,this._cachedAnisotropicFilteringLevel=c,this.samplingMode=u,this._comparisonFunction=d,this},o.prototype.compareSampler=function(a){return this._cachedWrapU===a._cachedWrapU&&this._cachedWrapV===a._cachedWrapV&&this._cachedWrapR===a._cachedWrapR&&this._cachedAnisotropicFilteringLevel===a._cachedAnisotropicFilteringLevel&&this.samplingMode===a.samplingMode&&this._comparisonFunction===a._comparisonFunction&&this._useMipMaps===a._useMipMaps},o}()},63919:(r,t,e)=>{e.d(t,{D:()=>o});var n=e(81152),i=e(73152),o=function(){function a(s){this._wrapU=n.Y.TEXTURE_WRAP_ADDRESSMODE,this._wrapV=n.Y.TEXTURE_WRAP_ADDRESSMODE,this.wrapR=n.Y.TEXTURE_WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=4,this.delayLoadState=n.Y.DELAYLOADSTATE_NONE,this._texture=null,this._engine=null,this._cachedSize=i.o.Zero(),this._cachedBaseSize=i.o.Zero(),this._initialSamplingMode=n.Y.TEXTURE_BILINEAR_SAMPLINGMODE,this._texture=a._IsRenderTargetWrapper(s)?s.texture:s,this._texture&&(this._engine=this._texture.getEngine())}return Object.defineProperty(a.prototype,"wrapU",{get:function(){return this._wrapU},set:function(s){this._wrapU=s},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"wrapV",{get:function(){return this._wrapV},set:function(s){this._wrapV=s},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"coordinatesMode",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isCube",{get:function(){return!!this._texture&&this._texture.isCube},set:function(s){this._texture&&(this._texture.isCube=s)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(s){this._texture&&(this._texture.is3D=s)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"is2DArray",{get:function(){return!!this._texture&&this._texture.is2DArray},set:function(s){this._texture&&(this._texture.is2DArray=s)},enumerable:!1,configurable:!0}),a.prototype.getClassName=function(){return"ThinTexture"},a._IsRenderTargetWrapper=function(s){return s?.shareDepth!==void 0},a.prototype.isReady=function(){return this.delayLoadState===n.Y.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},a.prototype.delayLoad=function(){},a.prototype.getInternalTexture=function(){return this._texture},a.prototype.getSize=function(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize},a.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize):(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize)},Object.defineProperty(a.prototype,"samplingMode",{get:function(){return this._texture?this._texture.samplingMode:this._initialSamplingMode},enumerable:!1,configurable:!0}),a.prototype.updateSamplingMode=function(s){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(s,this._texture)},a.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},a.prototype.dispose=function(){this._texture&&(this.releaseInternalTexture(),this._engine=null)},a}()},34561:(r,t,e)=>{function n(l){l.indexOf("vClipPlane")===-1&&l.push("vClipPlane"),l.indexOf("vClipPlane2")===-1&&l.push("vClipPlane2"),l.indexOf("vClipPlane3")===-1&&l.push("vClipPlane3"),l.indexOf("vClipPlane4")===-1&&l.push("vClipPlane4"),l.indexOf("vClipPlane5")===-1&&l.push("vClipPlane5"),l.indexOf("vClipPlane6")===-1&&l.push("vClipPlane6")}function i(l,c,u){var d,h,p,m,v,b,E=!!((d=l.clipPlane)!==null&&d!==void 0?d:c.clipPlane),C=!!((h=l.clipPlane2)!==null&&h!==void 0?h:c.clipPlane2),T=!!((p=l.clipPlane3)!==null&&p!==void 0?p:c.clipPlane3),f=!!((m=l.clipPlane4)!==null&&m!==void 0?m:c.clipPlane4),g=!!((v=l.clipPlane5)!==null&&v!==void 0?v:c.clipPlane5),S=!!((b=l.clipPlane6)!==null&&b!==void 0?b:c.clipPlane6);E&&u.push("#define CLIPPLANE"),C&&u.push("#define CLIPPLANE2"),T&&u.push("#define CLIPPLANE3"),f&&u.push("#define CLIPPLANE4"),g&&u.push("#define CLIPPLANE5"),S&&u.push("#define CLIPPLANE6")}function o(l,c,u){var d,h,p,m,v,b,E=!1,C=!!((d=l.clipPlane)!==null&&d!==void 0?d:c.clipPlane),T=!!((h=l.clipPlane2)!==null&&h!==void 0?h:c.clipPlane2),f=!!((p=l.clipPlane3)!==null&&p!==void 0?p:c.clipPlane3),g=!!((m=l.clipPlane4)!==null&&m!==void 0?m:c.clipPlane4),S=!!((v=l.clipPlane5)!==null&&v!==void 0?v:c.clipPlane5),y=!!((b=l.clipPlane6)!==null&&b!==void 0?b:c.clipPlane6);return u.CLIPPLANE!==C&&(u.CLIPPLANE=C,E=!0),u.CLIPPLANE2!==T&&(u.CLIPPLANE2=T,E=!0),u.CLIPPLANE3!==f&&(u.CLIPPLANE3=f,E=!0),u.CLIPPLANE4!==g&&(u.CLIPPLANE4=g,E=!0),u.CLIPPLANE5!==S&&(u.CLIPPLANE5=S,E=!0),u.CLIPPLANE6!==y&&(u.CLIPPLANE6=y,E=!0),E}function a(l,c,u){var d,h,p,m,v,b,E=(d=c.clipPlane)!==null&&d!==void 0?d:u.clipPlane;s(l,"vClipPlane",E),s(l,"vClipPlane2",E=(h=c.clipPlane2)!==null&&h!==void 0?h:u.clipPlane2),s(l,"vClipPlane3",E=(p=c.clipPlane3)!==null&&p!==void 0?p:u.clipPlane3),s(l,"vClipPlane4",E=(m=c.clipPlane4)!==null&&m!==void 0?m:u.clipPlane4),s(l,"vClipPlane5",E=(v=c.clipPlane5)!==null&&v!==void 0?v:u.clipPlane5),s(l,"vClipPlane6",E=(b=c.clipPlane6)!==null&&b!==void 0?b:u.clipPlane6)}function s(l,c,u){u&&l.setFloat4(c,u.normal.x,u.normal.y,u.normal.z,u.d)}e.d(t,{Eq:()=>o,TV:()=>n,gS:()=>a,tv:()=>i})},10740:(r,t,e)=>{function n(i){i.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}e.d(t,{B:()=>n})},76331:(r,t,e)=>{e.d(t,{Q:()=>l});var n=e(78322),i=e(6174),o=e(64726),a=e(12028),s=e(10740),l=function(){function c(){this._dirty=!0,this._tempColor=new o.ov(0,0,0,0),this._globalCurve=new o.ov(0,0,0,0),this._highlightsCurve=new o.ov(0,0,0,0),this._midtonesCurve=new o.ov(0,0,0,0),this._shadowsCurve=new o.ov(0,0,0,0),this._positiveCurve=new o.ov(0,0,0,0),this._negativeCurve=new o.ov(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(c.prototype,"globalHue",{get:function(){return this._globalHue},set:function(u){this._globalHue=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(u){this._globalDensity=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(u){this._globalSaturation=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"globalExposure",{get:function(){return this._globalExposure},set:function(u){this._globalExposure=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(u){this._highlightsHue=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(u){this._highlightsDensity=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(u){this._highlightsSaturation=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(u){this._highlightsExposure=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(u){this._midtonesHue=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(u){this._midtonesDensity=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(u){this._midtonesSaturation=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(u){this._midtonesExposure=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(u){this._shadowsHue=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(u){this._shadowsDensity=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(u){this._shadowsSaturation=u,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(u){this._shadowsExposure=u,this._dirty=!0},enumerable:!1,configurable:!0}),c.prototype.getClassName=function(){return"ColorCurves"},c.Bind=function(u,d,h,p,m){h===void 0&&(h="vCameraColorCurvePositive"),p===void 0&&(p="vCameraColorCurveNeutral"),m===void 0&&(m="vCameraColorCurveNegative"),u._dirty&&(u._dirty=!1,u._getColorGradingDataToRef(u._globalHue,u._globalDensity,u._globalSaturation,u._globalExposure,u._globalCurve),u._getColorGradingDataToRef(u._highlightsHue,u._highlightsDensity,u._highlightsSaturation,u._highlightsExposure,u._tempColor),u._tempColor.multiplyToRef(u._globalCurve,u._highlightsCurve),u._getColorGradingDataToRef(u._midtonesHue,u._midtonesDensity,u._midtonesSaturation,u._midtonesExposure,u._tempColor),u._tempColor.multiplyToRef(u._globalCurve,u._midtonesCurve),u._getColorGradingDataToRef(u._shadowsHue,u._shadowsDensity,u._shadowsSaturation,u._shadowsExposure,u._tempColor),u._tempColor.multiplyToRef(u._globalCurve,u._shadowsCurve),u._highlightsCurve.subtractToRef(u._midtonesCurve,u._positiveCurve),u._midtonesCurve.subtractToRef(u._shadowsCurve,u._negativeCurve)),d&&(d.setFloat4(h,u._positiveCurve.r,u._positiveCurve.g,u._positiveCurve.b,u._positiveCurve.a),d.setFloat4(p,u._midtonesCurve.r,u._midtonesCurve.g,u._midtonesCurve.b,u._midtonesCurve.a),d.setFloat4(m,u._negativeCurve.r,u._negativeCurve.g,u._negativeCurve.b,u._negativeCurve.a))},c.prototype._getColorGradingDataToRef=function(u,d,h,p,m){u!=null&&(u=c._Clamp(u,0,360),d=c._Clamp(d,-100,100),h=c._Clamp(h,-100,100),p=c._Clamp(p,-100,100),d=c._ApplyColorGradingSliderNonlinear(d),d*=.5,p=c._ApplyColorGradingSliderNonlinear(p),d<0&&(d*=-1,u=(u+180)%360),c._FromHSBToRef(u,d,50+.25*p,m),m.scaleToRef(2,m),m.a=1+.01*h)},c._ApplyColorGradingSliderNonlinear=function(u){u/=100;var d=Math.abs(u);return d=Math.pow(d,2),u<0&&(d*=-1),100*d},c._FromHSBToRef=function(u,d,h,p){var m=c._Clamp(u,0,360),v=c._Clamp(d/100,0,1),b=c._Clamp(h/100,0,1);if(v===0)p.r=b,p.g=b,p.b=b;else{m/=60;var E=Math.floor(m),C=m-E,T=b*(1-v),f=b*(1-v*C),g=b*(1-v*(1-C));switch(E){case 0:p.r=b,p.g=g,p.b=T;break;case 1:p.r=f,p.g=b,p.b=T;break;case 2:p.r=T,p.g=b,p.b=g;break;case 3:p.r=T,p.g=f,p.b=b;break;case 4:p.r=g,p.g=T,p.b=b;break;default:p.r=b,p.g=T,p.b=f}}p.a=1},c._Clamp=function(u,d,h){return Math.min(Math.max(u,d),h)},c.prototype.clone=function(){return a.p.Clone(function(){return new c},this)},c.prototype.serialize=function(){return a.p.Serialize(this)},c.Parse=function(u){return a.p.Parse(function(){return new c},u,null,null)},c.PrepareUniforms=s.B,(0,n.Cg)([(0,i.lK)()],c.prototype,"_globalHue",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_globalDensity",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_globalSaturation",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_globalExposure",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_highlightsHue",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_highlightsDensity",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_highlightsSaturation",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_highlightsExposure",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_midtonesHue",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_midtonesDensity",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_midtonesSaturation",void 0),(0,n.Cg)([(0,i.lK)()],c.prototype,"_midtonesExposure",void 0),c}();a.p._ColorCurvesParser=l.Parse},92118:(r,t,e)=>{function n(i){return i.getPipelineContext===void 0}e.d(t,{E:()=>n})},14777:(r,t,e)=>{e.d(t,{E:()=>n});var n=function(){function i(o,a){a===void 0&&(a=!0),this._wasPreviouslyReady=!1,this._forceRebindOnNextCall=!0,this._wasPreviouslyUsingInstances=null,this.effect=null,this.defines=null,this.drawContext=o.createDrawContext(),a&&(this.materialContext=o.createMaterialContext())}return i.GetEffect=function(o){return o.getPipelineContext===void 0?o.effect:o},i.prototype.setEffect=function(o,a,s){var l;s===void 0&&(s=!0),this.effect=o,a!==void 0&&(this.defines=a),s&&((l=this.drawContext)===null||l===void 0||l.reset())},i.prototype.dispose=function(){var o;(o=this.drawContext)===null||o===void 0||o.dispose()},i}()},76320:(r,t,e)=>{e.d(t,{b4:()=>c,bu:()=>d,mO:()=>u,uR:()=>p});var n=e(5153),i=e(53399),o=e(98519),a=e(7164),s=e(35930),l=e(24894);function c(m,v){return(0,i.N5)(v).cachedPipelines[m]}function u(m){var v=m._name,b=m.context;if(v&&b){var E=(0,i.N5)(b),C=E.cachedPipelines[v];C?.dispose(),delete E.cachedPipelines[v]}}function d(m,v,b,E,C,T,f){var g,S,y=(0,n.BA)()?T?.getHostDocument():null;g=typeof v=="string"?v:v.vertexSource?"source:"+v.vertexSource:v.vertexElement?y?.getElementById(v.vertexElement)||v.vertexElement:v.vertex||v,S=typeof v=="string"?v:v.fragmentSource?"source:"+v.fragmentSource:v.fragmentElement?y?.getElementById(v.fragmentElement)||v.fragmentElement:v.fragment||v;var x=[void 0,void 0],R=function(){if(x[0]&&x[1]){m.isFragment=!0;var I=x[0],M=x[1];(0,s.M0)(M,m,function(D,B){f&&(f._fragmentSourceCodeBeforeMigration=B),b&&(D=b("fragment",D));var F=(0,s.nO)(I,D,m);m=null;var X=function($,Q,ie,q){return ie?{vertexSourceCode:(q===1?"//":"")+"#define SHADER_NAME vertex:"+(ie.vertexElement||ie.vertex||ie.spectorName||ie)+`
|
||
`+$,fragmentSourceCode:(q===1?"//":"")+"#define SHADER_NAME fragment:"+(ie.fragmentElement||ie.fragment||ie.spectorName||ie)+`
|
||
`+Q}:{vertexSourceCode:$,fragmentSourceCode:Q}}(F.vertexCode,F.fragmentCode,v,C);E?.(X.vertexSourceCode,X.fragmentSourceCode)},T)}};h(g,"Vertex","",function(I){(0,s.pB)(m),(0,s.M0)(I,m,function(M,D){f&&(f._rawVertexSourceCode=I,f._vertexSourceCodeBeforeMigration=D),b&&(M=b("vertex",M)),x[0]=M,R()},T)},C),h(S,"Fragment","Pixel",function(I){f&&(f._rawFragmentSourceCode=I),x[1]=I,R()},C)}function h(m,v,b,E,C,T){if(typeof HTMLElement<"u"&&m instanceof HTMLElement)E((0,n.Zl)(m));else if(m.substring(0,7)!=="source:")if(m.substring(0,7)!=="base64:"){var f=o.l.GetShadersStore(C);if(f[m+v+"Shader"])E(f[m+v+"Shader"]);else if(b&&f[m+b+"Shader"])E(f[m+b+"Shader"]);else{var g;if(g=m[0]==="."||m[0]==="/"||m.indexOf("http")>-1?m:o.l.GetShadersRepository(C)+m,!(T=T||l.W0))throw new Error("loadFileInjection is not defined");T(g+"."+v.toLowerCase()+".fx",E)}}else E(window.atob(m.substring(7)));else E(m.substring(7))}var p=function(m,v,b,E){try{var C=m.existingPipelineContext||v(m.shaderProcessingContext);return C._name=m.name,m.name&&m.context&&((0,i.N5)(m.context).cachedPipelines[m.name]=C),b(C,m.vertex,m.fragment,!!m.createAsRaw,"","",m.rebuildRebind,m.defines,m.transformFeedbackVaryings,"",function(){E(C,function(){var T;(T=m.onRenderingStateCompiled)===null||T===void 0||T.call(m,C)})}),C}catch(T){throw a.V.Error("Error compiling effect"),T}}},74239:(r,t,e)=>{e.d(t,{M:()=>c});var n=e(78322),i=e(66377),o=e(81152),a=e(7164),s=e(98519),l=e(76320),c=function(){function u(d,h,p,m,v,b,E,C,T,f,g,S,y){var x,R,I,M;m===void 0&&(m=null),b===void 0&&(b=null),E===void 0&&(E=null),C===void 0&&(C=null),T===void 0&&(T=null),g===void 0&&(g=""),S===void 0&&(S=0),this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new i.cP,this.onErrorObservable=new i.cP,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this.name=d,this._key=g;var D=this._key.replace(/\r/g,"").replace(/\n/g,"|"),B=void 0;if(h.attributes){var F=h;if(this._engine=p,this._attributesNames=F.attributes,this._uniformsNames=F.uniformsNames.concat(F.samplers),this._samplerList=F.samplers.slice(),this.defines=F.defines,this.onError=F.onError,this.onCompiled=F.onCompiled,this._fallbacks=F.fallbacks,this._indexParameters=F.indexParameters,this._transformFeedbackVaryings=F.transformFeedbackVaryings||null,this._multiTarget=!!F.multiTarget,this._shaderLanguage=(x=F.shaderLanguage)!==null&&x!==void 0?x:0,F.uniformBuffersNames){this._uniformBuffersNamesList=F.uniformBuffersNames.slice();for(var X=0;X<F.uniformBuffersNames.length;X++)this._uniformBuffersNames[F.uniformBuffersNames[X]]=X}this._processFinalCode=(R=F.processFinalCode)!==null&&R!==void 0?R:null,this._processCodeAfterIncludes=(I=F.processCodeAfterIncludes)!==null&&I!==void 0?I:void 0,B=F.existingPipelineContext}else this._engine=v,this.defines=b??"",this._uniformsNames=p.concat(m),this._samplerList=m?m.slice():[],this._attributesNames=h,this._uniformBuffersNamesList=[],this._shaderLanguage=S,this.onError=T,this.onCompiled=C,this._indexParameters=f,this._fallbacks=E;this._engine.shaderPlatformName==="WEBGL2"&&(B=(M=(0,l.b4)(D,this._engine._gl))!==null&&M!==void 0?M:B),this._attributeLocationByName={},this.uniqueId=u._UniqueIdSeed++,B?(this._pipelineContext=B,this._pipelineContext.setEngine(this._engine),this._onRenderingStateCompiled(this._pipelineContext),this._pipelineContext.program&&(this._pipelineContext.program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this))):this._processShaderCodeAsync(null,!1,null,y)}return Object.defineProperty(u,"ShadersRepository",{get:function(){return s.l.ShadersRepository},set:function(d){s.l.ShadersRepository=d},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new i.cP),this._onBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),u.prototype._processShaderCodeAsync=function(d,h,p,m){return d===void 0&&(d=null),h===void 0&&(h=!1),p===void 0&&(p=null),(0,n.sH)(this,void 0,void 0,function(){var v,b=this;return(0,n.YH)(this,function(E){switch(E.label){case 0:return m?[4,m()]:[3,2];case 1:E.sent(),E.label=2;case 2:return this._processingContext=p||this._engine._getShaderProcessingContext(this._shaderLanguage,!1),v={defines:this.defines.split(`
|
||
`),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:d??this._engine._getShaderProcessor(this._shaderLanguage),supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:s.l.GetShadersRepository(this._shaderLanguage),includesShadersStore:s.l.GetIncludesShadersStore(this._shaderLanguage),version:(100*this._engine.version).toString(),platformName:this._engine.shaderPlatformName,processingContext:this._processingContext,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:this._processCodeAfterIncludes},(0,l.bu)(v,this.name,this._processFinalCode,function(C,T){b._vertexSourceCode=C,b._fragmentSourceCode=T,b._prepareEffect(h)},this._shaderLanguage,this._engine,this),[2]}})})},Object.defineProperty(u.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),u.prototype.isReady=function(){try{return this._isReadyInternal()}catch{return!1}},u.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},u.prototype.getEngine=function(){return this._engine},u.prototype.getPipelineContext=function(){return this._pipelineContext},u.prototype.getAttributesNames=function(){return this._attributesNames},u.prototype.getAttributeLocation=function(d){return this._attributes[d]},u.prototype.getAttributeLocationByName=function(d){return this._attributeLocationByName[d]},u.prototype.getAttributesCount=function(){return this._attributes.length},u.prototype.getUniformIndex=function(d){return this._uniformsNames.indexOf(d)},u.prototype.getUniform=function(d){return this._uniforms[d]},u.prototype.getSamplers=function(){return this._samplerList},u.prototype.getUniformNames=function(){return this._uniformsNames},u.prototype.getUniformBuffersNames=function(){return this._uniformBuffersNamesList},u.prototype.getIndexParameters=function(){return this._indexParameters},u.prototype.getCompilationError=function(){return this._compilationError},u.prototype.allFallbacksProcessed=function(){return this._allFallbacksProcessed},u.prototype.executeWhenCompiled=function(d){var h=this;this.isReady()?d(this):(this.onCompileObservable.add(function(p){d(p)}),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout(function(){h._checkIsReady(null)},16))},u.prototype._checkIsReady=function(d){var h=this;try{if(this._isReadyInternal())return}catch(p){return void this._processCompilationErrors(p,d)}this._isDisposed||setTimeout(function(){h._checkIsReady(d)},16)},Object.defineProperty(u.prototype,"vertexSourceCode",{get:function(){var d,h;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:(h=(d=this._pipelineContext)===null||d===void 0?void 0:d._getVertexShaderCode())!==null&&h!==void 0?h:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"fragmentSourceCode",{get:function(){var d,h;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:(h=(d=this._pipelineContext)===null||d===void 0?void 0:d._getFragmentShaderCode())!==null&&h!==void 0?h:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"vertexSourceCodeBeforeMigration",{get:function(){return this._vertexSourceCodeBeforeMigration},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"fragmentSourceCodeBeforeMigration",{get:function(){return this._fragmentSourceCodeBeforeMigration},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"rawVertexSourceCode",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"rawFragmentSourceCode",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),u.prototype.getPipelineGenerationOptions=function(){return{platformName:this._engine.shaderPlatformName,shaderLanguage:this._shaderLanguage,shaderNameOrContent:this.name,key:this._key,defines:this.defines.split(`
|
||
`),addGlobalDefines:!1,extendedProcessingOptions:{indexParameters:this._indexParameters,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,supportsUniformBuffers:this._engine.supportsUniformBuffers},extendedCreatePipelineOptions:{transformFeedbackVaryings:this._transformFeedbackVaryings,createAsRaw:!(!this._vertexSourceCodeOverride||!this._fragmentSourceCodeOverride)}}},u.prototype._rebuildProgram=function(d,h,p,m){var v=this;this._isReady=!1,this._vertexSourceCodeOverride=d,this._fragmentSourceCodeOverride=h,this.onError=function(b,E){m&&m(E)},this.onCompiled=function(){var b,E,C=v.getEngine().scenes;if(C)for(var T=0;T<C.length;T++)C[T].markAllMaterialsAsDirty(o.Y.MATERIAL_AllDirtyFlag);(E=(b=v._pipelineContext)._handlesSpectorRebuildCallback)===null||E===void 0||E.call(b,p)},this._fallbacks=null,this._prepareEffect()},u.prototype._onRenderingStateCompiled=function(d){if(this._pipelineContext=d,this._pipelineContext.setEngine(this._engine),this._attributes=[],this._pipelineContext._fillEffectInformation(this,this._uniformBuffersNames,this._uniformsNames,this._uniforms,this._samplerList,this._samplers,this._attributesNames,this._attributes),this._attributesNames)for(var h=0;h<this._attributesNames.length;h++){var p=this._attributesNames[h];this._attributeLocationByName[p]=this._attributes[h]}this._engine.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this),this.onCompileObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh()},u.prototype._prepareEffect=function(d){var h=this;d===void 0&&(d=!1);var p=this._pipelineContext;this._isReady=!1;try{var m=!(!this._vertexSourceCodeOverride||!this._fragmentSourceCodeOverride),v=m?null:this.defines,b=m?this._vertexSourceCodeOverride:this._vertexSourceCode,E=m?this._fragmentSourceCodeOverride:this._fragmentSourceCode,C=this._engine;this._pipelineContext=(0,l.uR)({existingPipelineContext:d?p:null,vertex:b,fragment:E,context:C.shaderPlatformName==="WEBGL2"?C._gl:void 0,rebuildRebind:function(T,f,g,S){return h._rebuildProgram(T,f,g,S)},defines:v,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:m,parallelShaderCompile:C._caps.parallelShaderCompile,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:function(T){p&&!d&&h._engine._deletePipelineContext(p),T&&h._onRenderingStateCompiled(T)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContext.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(p)}catch(T){this._processCompilationErrors(T,p)}},u.prototype._getShaderCodeAndErrorLine=function(d,h,p){var m=p?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/,v=null;if(h&&d){var b=h.match(m);if(b&&b.length===2){var E=parseInt(b[1]),C=d.split(`
|
||
`,-1);C.length>=E&&(v="Offending line [".concat(E,"] in ").concat(p?"fragment":"vertex"," code: ").concat(C[E-1]))}}return[d,v]},u.prototype._processCompilationErrors=function(d,h){var p,m,v,b,E,C=this;h===void 0&&(h=null),this._compilationError=d.message;var T=this._attributesNames,f=this._fallbacks;if(a.V.Error("Unable to compile effect:"),a.V.Error("Uniforms: "+this._uniformsNames.map(function(R){return" "+R})),a.V.Error("Attributes: "+T.map(function(R){return" "+R})),a.V.Error(`Defines:
|
||
`+this.defines),u.LogShaderCodeOnCompilationError){var g=null,S=null,y=null;!((v=this._pipelineContext)===null||v===void 0)&&v._getVertexShaderCode()&&(y=(p=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],g=p[1],y&&(a.V.Error("Vertex code:"),a.V.Error(y))),!((b=this._pipelineContext)===null||b===void 0)&&b._getFragmentShaderCode()&&(y=(m=this._getShaderCodeAndErrorLine((E=this._pipelineContext)===null||E===void 0?void 0:E._getFragmentShaderCode(),this._compilationError,!0))[0],S=m[1],y&&(a.V.Error("Fragment code:"),a.V.Error(y))),g&&a.V.Error(g),S&&a.V.Error(S)}a.V.Error("Error: "+this._compilationError);var x=function(){C.onError&&C.onError(C,C._compilationError),C.onErrorObservable.notifyObservers(C)};h&&(this._pipelineContext=h,this._isReady=!0,x()),f?(this._pipelineContext=null,f.hasMoreFallbacks?(this._allFallbacksProcessed=!1,a.V.Error("Trying next fallback."),this.defines=f.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,x(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,h||x())},Object.defineProperty(u.prototype,"isSupported",{get:function(){return this._compilationError===""},enumerable:!1,configurable:!0}),u.prototype._bindTexture=function(d,h){this._engine._bindTexture(this._samplers[d],h,d)},u.prototype.setTexture=function(d,h){this._engine.setTexture(this._samplers[d],this._uniforms[d],h,d)},u.prototype.setTextureArray=function(d,h){var p=d+"Ex";if(this._samplerList.indexOf(p+"0")===-1){for(var m=this._samplerList.indexOf(d),v=1;v<h.length;v++){var b=p+(v-1).toString();this._samplerList.splice(m+v,0,b)}for(var E=0,C=0,T=this._samplerList;C<T.length;C++){var f=T[C];this._samplers[f]=E,E+=1}}this._engine.setTextureArray(this._samplers[d],this._uniforms[d],h,d)},u.prototype.bindUniformBuffer=function(d,h){var p=this._uniformBuffersNames[h];p===void 0||u._BaseCache[p]===d&&this._engine._features.useUBOBindingCache||(u._BaseCache[p]=d,this._engine.bindUniformBufferBase(d,p,h))},u.prototype.bindUniformBlock=function(d,h){this._engine.bindUniformBlock(this._pipelineContext,d,h)},u.prototype.setInt=function(d,h){return this._pipelineContext.setInt(d,h),this},u.prototype.setInt2=function(d,h,p){return this._pipelineContext.setInt2(d,h,p),this},u.prototype.setInt3=function(d,h,p,m){return this._pipelineContext.setInt3(d,h,p,m),this},u.prototype.setInt4=function(d,h,p,m,v){return this._pipelineContext.setInt4(d,h,p,m,v),this},u.prototype.setIntArray=function(d,h){return this._pipelineContext.setIntArray(d,h),this},u.prototype.setIntArray2=function(d,h){return this._pipelineContext.setIntArray2(d,h),this},u.prototype.setIntArray3=function(d,h){return this._pipelineContext.setIntArray3(d,h),this},u.prototype.setIntArray4=function(d,h){return this._pipelineContext.setIntArray4(d,h),this},u.prototype.setUInt=function(d,h){return this._pipelineContext.setUInt(d,h),this},u.prototype.setUInt2=function(d,h,p){return this._pipelineContext.setUInt2(d,h,p),this},u.prototype.setUInt3=function(d,h,p,m){return this._pipelineContext.setUInt3(d,h,p,m),this},u.prototype.setUInt4=function(d,h,p,m,v){return this._pipelineContext.setUInt4(d,h,p,m,v),this},u.prototype.setUIntArray=function(d,h){return this._pipelineContext.setUIntArray(d,h),this},u.prototype.setUIntArray2=function(d,h){return this._pipelineContext.setUIntArray2(d,h),this},u.prototype.setUIntArray3=function(d,h){return this._pipelineContext.setUIntArray3(d,h),this},u.prototype.setUIntArray4=function(d,h){return this._pipelineContext.setUIntArray4(d,h),this},u.prototype.setFloatArray=function(d,h){return this._pipelineContext.setArray(d,h),this},u.prototype.setFloatArray2=function(d,h){return this._pipelineContext.setArray2(d,h),this},u.prototype.setFloatArray3=function(d,h){return this._pipelineContext.setArray3(d,h),this},u.prototype.setFloatArray4=function(d,h){return this._pipelineContext.setArray4(d,h),this},u.prototype.setArray=function(d,h){return this._pipelineContext.setArray(d,h),this},u.prototype.setArray2=function(d,h){return this._pipelineContext.setArray2(d,h),this},u.prototype.setArray3=function(d,h){return this._pipelineContext.setArray3(d,h),this},u.prototype.setArray4=function(d,h){return this._pipelineContext.setArray4(d,h),this},u.prototype.setMatrices=function(d,h){return this._pipelineContext.setMatrices(d,h),this},u.prototype.setMatrix=function(d,h){return this._pipelineContext.setMatrix(d,h),this},u.prototype.setMatrix3x3=function(d,h){return this._pipelineContext.setMatrix3x3(d,h),this},u.prototype.setMatrix2x2=function(d,h){return this._pipelineContext.setMatrix2x2(d,h),this},u.prototype.setFloat=function(d,h){return this._pipelineContext.setFloat(d,h),this},u.prototype.setBool=function(d,h){return this._pipelineContext.setInt(d,h?1:0),this},u.prototype.setVector2=function(d,h){return this._pipelineContext.setVector2(d,h),this},u.prototype.setFloat2=function(d,h,p){return this._pipelineContext.setFloat2(d,h,p),this},u.prototype.setVector3=function(d,h){return this._pipelineContext.setVector3(d,h),this},u.prototype.setFloat3=function(d,h,p,m){return this._pipelineContext.setFloat3(d,h,p,m),this},u.prototype.setVector4=function(d,h){return this._pipelineContext.setVector4(d,h),this},u.prototype.setQuaternion=function(d,h){return this._pipelineContext.setQuaternion(d,h),this},u.prototype.setFloat4=function(d,h,p,m,v){return this._pipelineContext.setFloat4(d,h,p,m,v),this},u.prototype.setColor3=function(d,h){return this._pipelineContext.setColor3(d,h),this},u.prototype.setColor4=function(d,h,p){return this._pipelineContext.setColor4(d,h,p),this},u.prototype.setDirectColor4=function(d,h){return this._pipelineContext.setDirectColor4(d,h),this},u.prototype.dispose=function(){this._refCount--,this._refCount>0||(this._pipelineContext&&(0,l.mO)(this._pipelineContext),this._engine._releaseEffect(this),this._isDisposed=!0)},u.RegisterShader=function(d,h,p,m){m===void 0&&(m=0),h&&(s.l.GetShadersStore(m)["".concat(d,"PixelShader")]=h),p&&(s.l.GetShadersStore(m)["".concat(d,"VertexShader")]=p)},u.ResetCache=function(){u._BaseCache={}},u.LogShaderCodeOnCompilationError=!0,u._UniqueIdSeed=0,u._BaseCache={},u.ShadersStore=s.l.ShadersStore,u.IncludesShadersStore=s.l.IncludesShadersStore,u}()},93540:(r,t,e)=>{e.d(t,{$:()=>d,J:()=>u});var n=e(62623),i=e(25187),o=e(81152),a=e(66377),s=e(74239),l=e(14777),c=(e(96795),{positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]}),u=function(){function h(p,m){var v;m===void 0&&(m=c);var b,E,C=this;this._fullscreenViewport=new i.L(0,0,1,1);var T=(b=m.positions)!==null&&b!==void 0?b:c.positions,f=(E=m.indices)!==null&&E!==void 0?E:c.indices;this.engine=p,this._vertexBuffers=((v={})[n.R.PositionKind]=new n.R(p,T,n.R.PositionKind,!1,!1,2),v),this._indexBuffer=p.createIndexBuffer(f),this._onContextRestoredObserver=p.onContextRestoredObservable.add(function(){for(var g in C._indexBuffer=p.createIndexBuffer(f),C._vertexBuffers)C._vertexBuffers[g]._rebuild()})}return h.prototype.setViewport=function(p){p===void 0&&(p=this._fullscreenViewport),this.engine.setViewport(p)},h.prototype.bindBuffers=function(p){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,p)},h.prototype.applyEffectWrapper=function(p){this.engine.setState(!0),this.engine.depthCullingState.depthTest=!1,this.engine.stencilState.stencilTest=!1,this.engine.enableEffect(p._drawWrapper),this.bindBuffers(p.effect),p.onApplyObservable.notifyObservers({})},h.prototype.saveStates=function(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest},h.prototype.restoreStates=function(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest},h.prototype.draw=function(){this.engine.drawElementsType(o.Y.MATERIAL_TriangleFillMode,0,6)},h.prototype._isRenderTargetTexture=function(p){return p.renderTarget!==void 0},h.prototype.render=function(p,m){if(m===void 0&&(m=null),p.effect.isReady()){this.saveStates(),this.setViewport();var v=m===null?null:this._isRenderTargetTexture(m)?m.renderTarget:m;v&&this.engine.bindFramebuffer(v),this.applyEffectWrapper(p),this.draw(),v&&this.engine.unBindFramebuffer(v),this.restoreStates()}},h.prototype.dispose=function(){var p=this._vertexBuffers[n.R.PositionKind];p&&(p.dispose(),delete this._vertexBuffers[n.R.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)},h}(),d=function(){function h(p){var m,v=this;this.onApplyObservable=new a.cP;var b=p.uniformNames||[];p.vertexShader?m={fragmentSource:p.fragmentShader,vertexSource:p.vertexShader,spectorName:p.name||"effectWrapper"}:(b.push("scale"),m={fragmentSource:p.fragmentShader,vertex:"postprocess",spectorName:p.name||"effectWrapper"},this.onApplyObservable.add(function(){v.effect.setFloat2("scale",1,1)}));var E=p.defines?p.defines.join(`
|
||
`):"";this._drawWrapper=new l.E(p.engine),p.useShaderStore?(m.fragment=m.fragmentSource,m.vertex||(m.vertex=m.vertexSource),delete m.fragmentSource,delete m.vertexSource,this.effect=p.engine.createEffect(m,p.attributeNames||["position"],b,p.samplerNames,E,void 0,p.onCompiled,void 0,void 0,p.shaderLanguage,p.extraInitializationsAsync)):(this.effect=new s.M(m,p.attributeNames||["position"],b,p.samplerNames,p.engine,E,void 0,p.onCompiled,void 0,void 0,void 0,p.shaderLanguage,p.extraInitializationsAsync),this._onContextRestoredObserver=p.engine.onContextRestoredObservable.add(function(){v.effect._pipelineContext=null,v.effect._prepareEffect()}))}return Object.defineProperty(h.prototype,"effect",{get:function(){return this._drawWrapper.effect},set:function(p){this._drawWrapper.effect=p},enumerable:!1,configurable:!0}),h.prototype.dispose=function(p){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.effect.dispose()},h}()},27181:(r,t,e)=>{e.d(t,{C:()=>o,_:()=>i});var n=e(10740);function i(a,s){s.EXPOSURE&&a.push("exposureLinear"),s.CONTRAST&&a.push("contrast"),s.COLORGRADING&&a.push("colorTransformSettings"),(s.VIGNETTE||s.DITHER)&&a.push("vInverseScreenSize"),s.VIGNETTE&&(a.push("vignetteSettings1"),a.push("vignetteSettings2")),s.COLORCURVES&&(0,n.B)(a),s.DITHER&&a.push("ditherIntensity")}function o(a,s){s.COLORGRADING&&a.push("txColorTransform")}},81914:(r,t,e)=>{e.d(t,{p:()=>h});var n=e(78322),i=e(6174),o=e(66377),a=e(64726),s=e(76331),l=e(87074),c=e(12028),u=e(27181),d=e(34623),h=function(){function p(){this.colorCurves=new s.Q,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=p.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new a.ov(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=p.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new o.cP}return Object.defineProperty(p.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(m){this._colorCurvesEnabled!==m&&(this._colorCurvesEnabled=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(m){this._colorGradingTexture!==m&&(this._colorGradingTexture=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(m){this._colorGradingEnabled!==m&&(this._colorGradingEnabled=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(m){this._colorGradingWithGreenDepth!==m&&(this._colorGradingWithGreenDepth=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(m){this._colorGradingBGR!==m&&(this._colorGradingBGR=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"exposure",{get:function(){return this._exposure},set:function(m){this._exposure!==m&&(this._exposure=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(m){this._toneMappingEnabled!==m&&(this._toneMappingEnabled=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"toneMappingType",{get:function(){return this._toneMappingType},set:function(m){this._toneMappingType!==m&&(this._toneMappingType=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"contrast",{get:function(){return this._contrast},set:function(m){this._contrast!==m&&(this._contrast=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"vignetteCentreY",{get:function(){return this.vignetteCenterY},set:function(m){this.vignetteCenterY=m},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"vignetteCentreX",{get:function(){return this.vignetteCenterX},set:function(m){this.vignetteCenterX=m},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(m){this._vignetteBlendMode!==m&&(this._vignetteBlendMode=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(m){this._vignetteEnabled!==m&&(this._vignetteEnabled=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"ditheringEnabled",{get:function(){return this._ditheringEnabled},set:function(m){this._ditheringEnabled!==m&&(this._ditheringEnabled=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"ditheringIntensity",{get:function(){return this._ditheringIntensity},set:function(m){this._ditheringIntensity!==m&&(this._ditheringIntensity=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"skipFinalColorClamp",{get:function(){return this._skipFinalColorClamp},set:function(m){this._skipFinalColorClamp!==m&&(this._skipFinalColorClamp=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(m){this._applyByPostProcess!==m&&(this._applyByPostProcess=m,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(m){this._isEnabled!==m&&(this._isEnabled=m,this._updateParameters())},enumerable:!1,configurable:!0}),p.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},p.prototype.getClassName=function(){return"ImageProcessingConfiguration"},p.prototype.prepareDefines=function(m,v){if(v===void 0&&(v=!1),v!==this.applyByPostProcess||!this._isEnabled)return m.VIGNETTE=!1,m.TONEMAPPING=0,m.CONTRAST=!1,m.EXPOSURE=!1,m.COLORCURVES=!1,m.COLORGRADING=!1,m.COLORGRADING3D=!1,m.DITHER=!1,m.IMAGEPROCESSING=!1,m.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,void(m.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);if(m.VIGNETTE=this.vignetteEnabled,m.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===p._VIGNETTEMODE_MULTIPLY,m.VIGNETTEBLENDMODEOPAQUE=!m.VIGNETTEBLENDMODEMULTIPLY,this._toneMappingEnabled)switch(this._toneMappingType){case p.TONEMAPPING_KHR_PBR_NEUTRAL:m.TONEMAPPING=3;break;case p.TONEMAPPING_ACES:m.TONEMAPPING=2;break;default:m.TONEMAPPING=1}else m.TONEMAPPING=0;m.CONTRAST=this.contrast!==1,m.EXPOSURE=this.exposure!==1,m.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,m.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,m.COLORGRADING?m.COLORGRADING3D=this.colorGradingTexture.is3D:m.COLORGRADING3D=!1,m.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,m.SAMPLER3DBGRMAP=this.colorGradingBGR,m.DITHER=this._ditheringEnabled,m.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,m.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,m.IMAGEPROCESSING=m.VIGNETTE||!!m.TONEMAPPING||m.CONTRAST||m.EXPOSURE||m.COLORCURVES||m.COLORGRADING||m.DITHER},p.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},p.prototype.bind=function(m,v){if(this._colorCurvesEnabled&&this.colorCurves&&s.Q.Bind(this.colorCurves,m),this._vignetteEnabled||this._ditheringEnabled){var b=1/m.getEngine().getRenderWidth(),E=1/m.getEngine().getRenderHeight();if(m.setFloat2("vInverseScreenSize",b,E),this._ditheringEnabled&&m.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){var C=v??E/b,T=Math.tan(.5*this.vignetteCameraFov),f=T*C,g=Math.sqrt(f*T);f=(0,l.zF)(f,g,this.vignetteStretch),T=(0,l.zF)(T,g,this.vignetteStretch),m.setFloat4("vignetteSettings1",f,T,-f*this.vignetteCenterX,-T*this.vignetteCenterY);var S=-2*this.vignetteWeight;m.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,S)}}if(m.setFloat("exposureLinear",this.exposure),m.setFloat("contrast",this.contrast),this.colorGradingTexture){m.setTexture("txColorTransform",this.colorGradingTexture);var y=this.colorGradingTexture.getSize().height;m.setFloat4("colorTransformSettings",(y-1)/y,.5/y,y,this.colorGradingTexture.level)}},p.prototype.clone=function(){return c.p.Clone(function(){return new p},this)},p.prototype.serialize=function(){return c.p.Serialize(this)},p.Parse=function(m){var v=c.p.Parse(function(){return new p},m,null,null);return m.vignetteCentreX!==void 0&&(v.vignetteCenterX=m.vignetteCentreX),m.vignetteCentreY!==void 0&&(v.vignetteCenterY=m.vignetteCentreY),v},Object.defineProperty(p,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!1,configurable:!0}),Object.defineProperty(p,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!1,configurable:!0}),p.TONEMAPPING_STANDARD=0,p.TONEMAPPING_ACES=1,p.TONEMAPPING_KHR_PBR_NEUTRAL=2,p.PrepareUniforms=u._,p.PrepareSamplers=u.C,p._VIGNETTEMODE_MULTIPLY=0,p._VIGNETTEMODE_OPAQUE=1,(0,n.Cg)([(0,i.wL)()],p.prototype,"colorCurves",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_colorCurvesEnabled",void 0),(0,n.Cg)([(0,i.uM)("colorGradingTexture")],p.prototype,"_colorGradingTexture",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_colorGradingEnabled",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_colorGradingWithGreenDepth",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_colorGradingBGR",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_exposure",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_toneMappingEnabled",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_toneMappingType",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_contrast",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"vignetteStretch",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"vignetteCenterX",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"vignetteCenterY",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"vignetteWeight",void 0),(0,n.Cg)([(0,i.qK)()],p.prototype,"vignetteColor",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"vignetteCameraFov",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_vignetteBlendMode",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_vignetteEnabled",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_ditheringEnabled",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_ditheringIntensity",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_skipFinalColorClamp",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_applyByPostProcess",void 0),(0,n.Cg)([(0,i.lK)()],p.prototype,"_isEnabled",void 0),p}();c.p._ImageProcessingConfigurationParser=h.Parse,(0,d.Y5)("BABYLON.ImageProcessingConfiguration",h)},85096:(r,t,e)=>{e.d(t,{Bb:()=>ue,DL:()=>d,ER:()=>I,GD:()=>Te,IC:()=>Q,IF:()=>m,J2:()=>f,Jz:()=>ie,Kd:()=>y,L0:()=>S,MF:()=>p,N4:()=>fe,Nc:()=>ce,OR:()=>$,RL:()=>x,VO:()=>te,Y7:()=>de,YT:()=>C,Yy:()=>h,_8:()=>E,az:()=>F,c4:()=>M,f$:()=>g,fm:()=>B,lo:()=>X,mA:()=>T,nR:()=>b,ni:()=>R,qB:()=>ee,qL:()=>D,te:()=>v,wu:()=>q});var n=e(7164),i=e(81152),o=e(64726),a=e(66614),s=e(91946),l=e(34561),c=o.v9.Black(),u={NUM_MORPH_INFLUENCERS:0};function d(U,N,w){if(!U||U.LOGARITHMICDEPTH||U.indexOf&&U.indexOf("LOGARITHMICDEPTH")>=0){var k=w.activeCamera;k.mode===i.Y.ORTHOGRAPHIC_CAMERA&&n.V.Error("Logarithmic depth is not compatible with orthographic cameras!",20),N.setFloat("logarithmicDepthConstant",2/(Math.log(k.maxZ+1)/Math.LN2))}}function h(U,N,w,k){k===void 0&&(k=!1),w&&U.fogEnabled&&(!N||N.applyFog)&&U.fogMode!==i.Y.FOGMODE_NONE&&(w.setFloat4("vFogInfos",U.fogMode,U.fogStart,U.fogEnd,U.fogDensity),k?(U.fogColor.toLinearSpaceToRef(c,U.getEngine().useExactSrgbConversions),w.setColor3("vFogColor",c)):w.setColor3("vFogColor",U.fogColor))}function p(U,N,w){u.NUM_MORPH_INFLUENCERS=w,m(U,N,u)}function m(U,N,w){var k=w.NUM_MORPH_INFLUENCERS;if(k>0&&a.q.LastCreatedEngine){var J=a.q.LastCreatedEngine.getCaps().maxVertexAttribs,le=N.morphTargetManager;if(le?.isUsingTextureForTargets)return;for(var be=le&&le.supportsNormals&&w.NORMAL,ve=le&&le.supportsTangents&&w.TANGENT,ye=le&&le.supportsUVs&&w.UV1,Me=0;Me<k;Me++)U.push(i.Y.PositionKind+Me),be&&U.push(i.Y.NormalKind+Me),ve&&U.push(i.Y.TangentKind+Me),ye&&U.push(i.Y.UVKind+"_"+Me),U.length>J&&n.V.Error("Cannot add more vertex attributes for mesh "+N.name)}}function v(U,N){N===void 0&&(N=!1),U.push("world0"),U.push("world1"),U.push("world2"),U.push("world3"),N&&(U.push("previousWorld0"),U.push("previousWorld1"),U.push("previousWorld2"),U.push("previousWorld3"))}function b(U,N){var w=U.morphTargetManager;U&&w&&N.setFloatArray("morphTargetInfluences",w.influences)}function E(U,N){N.bindToEffect(U,"Scene")}function C(U,N,w){N._needUVs=!0,N[w]=!0,U.optimizeUVAllocation&&U.getTextureMatrix().isIdentityAs3x2()?(N[w+"DIRECTUV"]=U.coordinatesIndex+1,N["MAINUV"+(U.coordinatesIndex+1)]=!0):N[w+"DIRECTUV"]=0}function T(U,N,w){var k=U.getTextureMatrix();N.updateMatrix(w+"Matrix",k)}function f(U,N,w){w.BAKED_VERTEX_ANIMATION_TEXTURE&&w.INSTANCES&&U.push("bakedVertexAnimationSettingsInstanced")}function g(U,N,w){var k;if(N&&U&&(U.computeBonesUsingShaders&&N._bonesComputationForcedToCPU&&(U.computeBonesUsingShaders=!1),U.useBones&&U.computeBonesUsingShaders&&U.skeleton)){var J=U.skeleton;if(J.isUsingTextureForMatrices&&N.getUniformIndex("boneTextureWidth")>-1){var le=J.getTransformMatrixTexture(U);N.setTexture("boneSampler",le),N.setFloat("boneTextureWidth",4*(J.bones.length+1))}else{var be=J.getTransformMatrices(U);be&&(N.setMatrices("mBones",be),w&&U.getScene().prePassRenderer&&U.getScene().prePassRenderer.getIndex(i.Y.PREPASS_VELOCITY_TEXTURE_TYPE)&&(w.previousBones[U.uniqueId]||(w.previousBones[U.uniqueId]=be.slice()),N.setMatrices("mPreviousBones",w.previousBones[U.uniqueId]),k=be,w.previousBones[U.uniqueId].set(k)))}}}function S(U,N,w){U.transferToEffect(N,w+"")}function y(U,N,w,k,J,le){le===void 0&&(le=!0),U._bindLight(N,w,k,J,le)}function x(U,N,w,k,J){J===void 0&&(J=4);for(var le=Math.min(N.lightSources.length,J),be=0;be<le;be++)y(N.lightSources[be],be,U,w,typeof k=="boolean"?k:k.SPECULARTERM,N.receiveShadows)}function R(U,N,w,k){w.NUM_BONE_INFLUENCERS>0&&(k.addCPUSkinningFallback(0,N),U.push(i.Y.MatricesIndicesKind),U.push(i.Y.MatricesWeightsKind),w.NUM_BONE_INFLUENCERS>4&&(U.push(i.Y.MatricesIndicesExtraKind),U.push(i.Y.MatricesWeightsExtraKind)))}function I(U,N){(N.INSTANCES||N.THIN_INSTANCES)&&v(U,!!N.PREPASS_VELOCITY),N.INSTANCESCOLOR&&U.push(i.Y.ColorInstanceKind)}function M(U,N,w,k){w===void 0&&(w=4),k===void 0&&(k=0);for(var J=0,le=0;le<w&&U["LIGHT"+le];le++)le>0&&(J=k+le,N.addFallback(J,"LIGHT"+le)),U.SHADOWS||(U["SHADOW"+le]&&N.addFallback(k,"SHADOW"+le),U["SHADOWPCF"+le]&&N.addFallback(k,"SHADOWPCF"+le),U["SHADOWPCSS"+le]&&N.addFallback(k,"SHADOWPCSS"+le),U["SHADOWPOISSON"+le]&&N.addFallback(k,"SHADOWPOISSON"+le),U["SHADOWESM"+le]&&N.addFallback(k,"SHADOWESM"+le),U["SHADOWCLOSEESM"+le]&&N.addFallback(k,"SHADOWCLOSEESM"+le));return J++}function D(U,N){return N.fogEnabled&&U.applyFog&&N.fogMode!==i.Y.FOGMODE_NONE}function B(U,N,w,k,J,le,be,ve){ve===void 0&&(ve=!1),be._areMiscDirty&&(be.LOGARITHMICDEPTH=w,be.POINTSIZE=k,be.FOG=J&&D(U,N),be.NONUNIFORMSCALING=U.nonUniformScaling,be.ALPHATEST=le,be.DECAL_AFTER_DETAIL=ve)}function F(U,N,w,k,J,le){if(J===void 0&&(J=4),le===void 0&&(le=!1),!w._areLightsDirty)return w._needNormals;var be=0,ve={needNormals:w._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(U.lightsEnabled&&!le)for(var ye=0,Me=N.lightSources;ye<Me.length&&(X(U,N,Me[ye],be,w,k,ve),++be!==J);ye++);w.SPECULARTERM=ve.specularEnabled,w.SHADOWS=ve.shadowEnabled;for(var we=be;we<J;we++)w["LIGHT"+we]!==void 0&&(w["LIGHT"+we]=!1,w["HEMILIGHT"+we]=!1,w["POINTLIGHT"+we]=!1,w["DIRLIGHT"+we]=!1,w["SPOTLIGHT"+we]=!1,w["SHADOW"+we]=!1,w["SHADOWCSM"+we]=!1,w["SHADOWCSMDEBUG"+we]=!1,w["SHADOWCSMNUM_CASCADES"+we]=!1,w["SHADOWCSMUSESHADOWMAXZ"+we]=!1,w["SHADOWCSMNOBLEND"+we]=!1,w["SHADOWCSM_RIGHTHANDED"+we]=!1,w["SHADOWPCF"+we]=!1,w["SHADOWPCSS"+we]=!1,w["SHADOWPOISSON"+we]=!1,w["SHADOWESM"+we]=!1,w["SHADOWCLOSEESM"+we]=!1,w["SHADOWCUBE"+we]=!1,w["SHADOWLOWQUALITY"+we]=!1,w["SHADOWMEDIUMQUALITY"+we]=!1);var He=U.getEngine().getCaps();return w.SHADOWFLOAT===void 0&&(ve.needRebuild=!0),w.SHADOWFLOAT=ve.shadowEnabled&&(He.textureFloatRender&&He.textureFloatLinearFiltering||He.textureHalfFloatRender&&He.textureHalfFloatLinearFiltering),w.LIGHTMAPEXCLUDED=ve.lightmapMode,ve.needRebuild&&w.rebuild(),ve.needNormals}function X(U,N,w,k,J,le,be){var ve;switch(be.needNormals=!0,J["LIGHT"+k]===void 0&&(be.needRebuild=!0),J["LIGHT"+k]=!0,J["SPOTLIGHT"+k]=!1,J["HEMILIGHT"+k]=!1,J["POINTLIGHT"+k]=!1,J["DIRLIGHT"+k]=!1,w.prepareLightSpecificDefines(J,k),J["LIGHT_FALLOFF_PHYSICAL"+k]=!1,J["LIGHT_FALLOFF_GLTF"+k]=!1,J["LIGHT_FALLOFF_STANDARD"+k]=!1,w.falloffType){case s.c.FALLOFF_GLTF:J["LIGHT_FALLOFF_GLTF"+k]=!0;break;case s.c.FALLOFF_PHYSICAL:J["LIGHT_FALLOFF_PHYSICAL"+k]=!0;break;case s.c.FALLOFF_STANDARD:J["LIGHT_FALLOFF_STANDARD"+k]=!0}if(le&&!w.specular.equalsFloats(0,0,0)&&(be.specularEnabled=!0),J["SHADOW"+k]=!1,J["SHADOWCSM"+k]=!1,J["SHADOWCSMDEBUG"+k]=!1,J["SHADOWCSMNUM_CASCADES"+k]=!1,J["SHADOWCSMUSESHADOWMAXZ"+k]=!1,J["SHADOWCSMNOBLEND"+k]=!1,J["SHADOWCSM_RIGHTHANDED"+k]=!1,J["SHADOWPCF"+k]=!1,J["SHADOWPCSS"+k]=!1,J["SHADOWPOISSON"+k]=!1,J["SHADOWESM"+k]=!1,J["SHADOWCLOSEESM"+k]=!1,J["SHADOWCUBE"+k]=!1,J["SHADOWLOWQUALITY"+k]=!1,J["SHADOWMEDIUMQUALITY"+k]=!1,N&&N.receiveShadows&&U.shadowsEnabled&&w.shadowEnabled){var ye=(ve=w.getShadowGenerator(U.activeCamera))!==null&&ve!==void 0?ve:w.getShadowGenerator();if(ye){var Me=ye.getShadowMap();Me&&Me.renderList&&Me.renderList.length>0&&(be.shadowEnabled=!0,ye.prepareDefines(J,k))}}w.lightmapMode!=s.c.LIGHTMAP_DEFAULT?(be.lightmapMode=!0,J["LIGHTMAPEXCLUDED"+k]=!0,J["LIGHTMAPNOSPECULAR"+k]=w.lightmapMode==s.c.LIGHTMAP_SHADOWSONLY):(J["LIGHTMAPEXCLUDED"+k]=!1,J["LIGHTMAPNOSPECULAR"+k]=!1)}function $(U,N,w,k,J,le,be){le===void 0&&(le=null),be===void 0&&(be=!1);var ve=de(U,k);le!==!1&&(ve=(0,l.Eq)(w,U,k)),k.DEPTHPREPASS!==!N.getColorWrite()&&(k.DEPTHPREPASS=!k.DEPTHPREPASS,ve=!0),k.INSTANCES!==J&&(k.INSTANCES=J,ve=!0),k.THIN_INSTANCES!==be&&(k.THIN_INSTANCES=be,ve=!0),ve&&k.markAsUnprocessed()}function Q(U,N){if(U.useBones&&U.computeBonesUsingShaders&&U.skeleton){N.NUM_BONE_INFLUENCERS=U.numBoneInfluencers;var w=N.BONETEXTURE!==void 0;if(U.skeleton.isUsingTextureForMatrices&&w)N.BONETEXTURE=!0;else{N.BonesPerMesh=U.skeleton.bones.length+1,N.BONETEXTURE=!w&&void 0;var k=U.getScene().prePassRenderer;if(k&&k.enabled){var J=k.excludedSkinnedMesh.indexOf(U)===-1;N.BONES_VELOCITY_ENABLED=J}}}else N.NUM_BONE_INFLUENCERS=0,N.BonesPerMesh=0,N.BONETEXTURE!==void 0&&(N.BONETEXTURE=!1)}function ie(U,N){var w=U.morphTargetManager;w?(N.MORPHTARGETS_UV=w.supportsUVs&&N.UV1,N.MORPHTARGETS_TANGENT=w.supportsTangents&&N.TANGENT,N.MORPHTARGETS_NORMAL=w.supportsNormals&&N.NORMAL,N.NUM_MORPH_INFLUENCERS=w.numMaxInfluencers||w.numInfluencers,N.MORPHTARGETS=N.NUM_MORPH_INFLUENCERS>0,N.MORPHTARGETS_TEXTURE=w.isUsingTextureForTargets):(N.MORPHTARGETS_UV=!1,N.MORPHTARGETS_TANGENT=!1,N.MORPHTARGETS_NORMAL=!1,N.MORPHTARGETS=!1,N.NUM_MORPH_INFLUENCERS=0)}function q(U,N){var w=U.bakedVertexAnimationManager;N.BAKED_VERTEX_ANIMATION_TEXTURE=!(!w||!w.isEnabled)}function ee(U,N,w,k,J,le,be){if(J===void 0&&(J=!1),le===void 0&&(le=!0),be===void 0&&(be=!0),!N._areAttributesDirty&&N._needNormals===N._normals&&N._needUVs===N._uvs)return!1;N._normals=N._needNormals,N._uvs=N._needUVs,N.NORMAL=N._needNormals&&U.isVerticesDataPresent(i.Y.NormalKind),N._needNormals&&U.isVerticesDataPresent(i.Y.TangentKind)&&(N.TANGENT=!0);for(var ve=1;ve<=i.Y.MAX_SUPPORTED_UV_SETS;++ve)N["UV"+ve]=!!N._needUVs&&U.isVerticesDataPresent("uv".concat(ve===1?"":ve));if(w){var ye=U.useVertexColors&&U.isVerticesDataPresent(i.Y.ColorKind);N.VERTEXCOLOR=ye,N.VERTEXALPHA=U.hasVertexAlpha&&ye&&le}return U.isVerticesDataPresent(i.Y.ColorInstanceKind)&&(U.hasInstances||U.hasThinInstances)&&(N.INSTANCESCOLOR=!0),k&&Q(U,N),J&&ie(U,N),be&&q(U,N),!0}function te(U,N){if(U.activeCamera){var w=N.MULTIVIEW;N.MULTIVIEW=U.activeCamera.outputRenderTarget!==null&&U.activeCamera.outputRenderTarget.getViewCount()>1,N.MULTIVIEW!=w&&N.markAsUnprocessed()}}function ce(U,N,w){var k=N.ORDER_INDEPENDENT_TRANSPARENCY,J=N.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;N.ORDER_INDEPENDENT_TRANSPARENCY=U.useOrderIndependentTransparency&&w,N.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!U.getEngine().getCaps().textureFloatLinearFiltering,k===N.ORDER_INDEPENDENT_TRANSPARENCY&&J===N.ORDER_INDEPENDENT_TRANSPARENCY_16BITS||N.markAsUnprocessed()}function fe(U,N,w){var k=N.PREPASS;if(N._arePrePassDirty){var J=[{type:i.Y.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:i.Y.PREPASS_LOCAL_POSITION_TEXTURE_TYPE,define:"PREPASS_LOCAL_POSITION",index:"PREPASS_LOCAL_POSITION_INDEX"},{type:i.Y.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:i.Y.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE,define:"PREPASS_VELOCITY_LINEAR",index:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:i.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:i.Y.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:i.Y.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:i.Y.PREPASS_DEPTH_TEXTURE_TYPE,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:i.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE,define:"PREPASS_SCREENSPACE_DEPTH",index:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:i.Y.PREPASS_NORMAL_TEXTURE_TYPE,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"},{type:i.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE,define:"PREPASS_WORLD_NORMAL",index:"PREPASS_WORLD_NORMAL_INDEX"}];if(U.prePassRenderer&&U.prePassRenderer.enabled&&w){N.PREPASS=!0,N.SCENE_MRT_COUNT=U.prePassRenderer.mrtCount,N.PREPASS_NORMAL_WORLDSPACE=U.prePassRenderer.generateNormalsInWorldSpace;for(var le=0;le<J.length;le++){var be=U.prePassRenderer.getIndex(J[le].type);be!==-1?(N[J[le].define]=!0,N[J[le].index]=be):N[J[le].define]=!1}}else for(N.PREPASS=!1,le=0;le<J.length;le++)N[J[le].define]=!1;N.PREPASS!=k&&(N.markAsUnprocessed(),N.markAsImageProcessingDirty())}}function de(U,N){var w=!1;if(U.activeCamera){var k=N.CAMERA_ORTHOGRAPHIC?1:0,J=N.CAMERA_PERSPECTIVE?1:0,le=U.activeCamera.mode===i.Y.ORTHOGRAPHIC_CAMERA?1:0,be=U.activeCamera.mode===i.Y.PERSPECTIVE_CAMERA?1:0;(k^le||J^be)&&(N.CAMERA_ORTHOGRAPHIC=le===1,N.CAMERA_PERSPECTIVE=be===1,w=!0)}return w}function Te(U,N,w,k,J,le){J===void 0&&(J=null),le===void 0&&(le=!1),J&&J.push("Light"+U),le||(N.push("vLightData"+U,"vLightDiffuse"+U,"vLightSpecular"+U,"vLightDirection"+U,"vLightFalloff"+U,"vLightGround"+U,"lightMatrix"+U,"shadowsInfo"+U,"depthValues"+U),w.push("shadowTexture"+U),w.push("depthTexture"+U),N.push("viewFrustumZ"+U,"cascadeBlendFactor"+U,"lightSizeUVCorrection"+U,"depthCorrection"+U,"penumbraDarkness"+U,"frustumLengths"+U),k&&(w.push("projectionLightTexture"+U),N.push("textureProjectionMatrix"+U)))}function ue(U,N,w,k){var J;k===void 0&&(k=4);var le=null;if(U.uniformsNames){var be=U;J=be.uniformsNames,le=be.uniformBuffersNames,N=be.samplers,w=be.defines,k=be.maxSimultaneousLights||0}else J=U,N||(N=[]);for(var ve=0;ve<k&&w["LIGHT"+ve];ve++)Te(ve,J,N,w["PROJECTEDLIGHTTEXTURE"+ve],le);w.NUM_MORPH_INFLUENCERS&&(J.push("morphTargetInfluences"),J.push("morphTargetCount")),w.BAKED_VERTEX_ANIMATION_TEXTURE&&(J.push("bakedVertexAnimationSettings"),J.push("bakedVertexAnimationTextureSizeInverted"),J.push("bakedVertexAnimationTime"),N.push("bakedVertexAnimationTexture"))}},75482:(r,t,e)=>{e.d(t,{D:()=>o});var n=e(7164),i=e(44957),o=(e(59012),function(){function a(s,l,c,u,d){d===void 0&&(d=!1),this._valueCache={},this._engine=s,this._noUBO=!s.supportsUniformBuffers||d,this._dynamic=c,this._name=u??"no-name",this._data=l||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._engine._features.trackUbosInFrame&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}return Object.defineProperty(a.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!1,configurable:!0}),a.prototype.isDynamic=function(){return this._dynamic!==void 0},a.prototype.getData=function(){return this._bufferData},a.prototype.getBuffer=function(){return this._buffer},a.prototype._fillAlignment=function(s){var l;if(l=s<=2?s:4,this._uniformLocationPointer%l!=0){var c=this._uniformLocationPointer;this._uniformLocationPointer+=l-this._uniformLocationPointer%l;for(var u=this._uniformLocationPointer-c,d=0;d<u;d++)this._data.push(0)}},a.prototype.addUniform=function(s,l,c){if(c===void 0&&(c=0),!this._noUBO&&this._uniformLocations[s]===void 0){var u;if(c>0){if(l instanceof Array)throw"addUniform should not be use with Array in UBO: "+s;this._fillAlignment(4),this._uniformArraySizes[s]={strideSize:l,arraySize:c},l==16?l*=c:l=l*c+(4-l)*c,u=[];for(var d=0;d<l;d++)u.push(0)}else{if(l instanceof Array)l=(u=l).length;else for(u=[],d=0;d<l;d++)u.push(0);this._fillAlignment(l)}for(this._uniformSizes[s]=l,this._uniformLocations[s]=this._uniformLocationPointer,this._uniformLocationPointer+=l,d=0;d<l;d++)this._data.push(u[d]);this._needSync=!0}},a.prototype.addMatrix=function(s,l){this.addUniform(s,Array.prototype.slice.call(l.asArray()))},a.prototype.addFloat2=function(s,l,c){var u=[l,c];this.addUniform(s,u)},a.prototype.addFloat3=function(s,l,c,u){var d=[l,c,u];this.addUniform(s,d)},a.prototype.addColor3=function(s,l){var c=[l.r,l.g,l.b];this.addUniform(s,c)},a.prototype.addColor4=function(s,l,c){var u=[l.r,l.g,l.b,c];this.addUniform(s,u)},a.prototype.addVector3=function(s,l){var c=[l.x,l.y,l.z];this.addUniform(s,c)},a.prototype.addMatrix3x3=function(s){this.addUniform(s,12)},a.prototype.addMatrix2x2=function(s){this.addUniform(s,8)},a.prototype.create=function(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)},a.prototype._getNames=function(){var s=[],l=0;for(var c in this._uniformLocations)if(s.push(c),++l==10)break;return s.join(",")},a.prototype._rebuild=function(){!this._noUBO&&this._bufferData&&(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNames()):this._buffer=this._engine.createUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNames()),this._engine._features.trackUbosInFrame&&(this._buffers.push([this._buffer,this._engine._features.checkUbosContentBeforeUpload?this._bufferData.slice():void 0]),this._bufferIndex=this._buffers.length-1,this._createBufferOnWrite=!1))},a.prototype._rebuildAfterContextLost=function(){this._engine._features.trackUbosInFrame&&(this._buffers=[],this._currentFrameId=0),this._rebuild()},Object.defineProperty(a.prototype,"_numBuffers",{get:function(){return this._buffers.length},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"_indexBuffer",{get:function(){return this._bufferIndex},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"currentEffect",{get:function(){return this._currentEffect},enumerable:!1,configurable:!0}),a.prototype._buffersEqual=function(s,l){for(var c=0;c<s.length;++c)if(s[c]!==l[c])return!1;return!0},a.prototype._copyBuffer=function(s,l){for(var c=0;c<s.length;++c)l[c]=s[c]},a.prototype.update=function(){if(!this._noUBO)if(this.bindUniformBuffer(),this._buffer)if(this._dynamic||this._needSync){if(this._buffers&&this._buffers.length>1&&this._buffers[this._bufferIndex][1]){if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1]))return this._needSync=!1,void(this._createBufferOnWrite=this._engine._features.trackUbosInFrame);this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1])}this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(a._UpdatedUbosInFrame[this._name]||(a._UpdatedUbosInFrame[this._name]=0),a._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._engine._features.trackUbosInFrame}else this._createBufferOnWrite=this._engine._features.trackUbosInFrame;else this.create()},a.prototype._createNewBuffer=function(){this._bufferIndex+1<this._buffers.length?(this._bufferIndex++,this._buffer=this._buffers[this._bufferIndex][0],this._createBufferOnWrite=!1,this._needSync=!0):this._rebuild()},a.prototype._checkNewFrame=function(){this._engine._features.trackUbosInFrame&&this._currentFrameId!==this._engine.frameId&&(this._currentFrameId=this._engine.frameId,this._createBufferOnWrite=!1,this._buffers&&this._buffers.length>0?(this._needSync=this._bufferIndex!==0,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)},a.prototype.updateUniform=function(s,l,c){this._checkNewFrame();var u=this._uniformLocations[s];if(u===void 0){if(this._buffer)return void n.V.Error("Cannot add an uniform after UBO has been created. uniformName="+s);this.addUniform(s,c),u=this._uniformLocations[s]}if(this._buffer||this.create(),this._dynamic)for(h=0;h<c;h++)this._bufferData[u+h]=l[h];else{for(var d=!1,h=0;h<c;h++)(c===16&&!this._engine._features.uniformBufferHardCheckMatrix||this._bufferData[u+h]!==Math.fround(l[h]))&&(d=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[u+h]=l[h]);this._needSync=this._needSync||d}},a.prototype.updateUniformArray=function(s,l,c){this._checkNewFrame();var u=this._uniformLocations[s];if(u!==void 0){this._buffer||this.create();var d=this._uniformArraySizes[s];if(this._dynamic)for(v=0;v<c;v++)this._bufferData[u+v]=l[v];else{for(var h=!1,p=0,m=0,v=0;v<c;v++)if(this._bufferData[u+4*m+p]!==i.S0.FloatRound(l[v])&&(h=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[u+4*m+p]=l[v]),++p===d.strideSize){for(;p<4;p++)this._bufferData[u+4*m+p]=0;p=0,m++}this._needSync=this._needSync||h}}else n.V.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform and make sure that uniform buffers are supported by the current engine.")},a.prototype._cacheMatrix=function(s,l){this._checkNewFrame();var c=this._valueCache[s],u=l.updateFlag;return(c===void 0||c!==u)&&(this._valueCache[s]=u,!0)},a.prototype._updateMatrix3x3ForUniform=function(s,l){for(var c=0;c<3;c++)a._TempBuffer[4*c]=l[3*c],a._TempBuffer[4*c+1]=l[3*c+1],a._TempBuffer[4*c+2]=l[3*c+2],a._TempBuffer[4*c+3]=0;this.updateUniform(s,a._TempBuffer,12)},a.prototype._updateMatrix3x3ForEffect=function(s,l){this._currentEffect.setMatrix3x3(s,l)},a.prototype._updateMatrix2x2ForEffect=function(s,l){this._currentEffect.setMatrix2x2(s,l)},a.prototype._updateMatrix2x2ForUniform=function(s,l){for(var c=0;c<2;c++)a._TempBuffer[4*c]=l[2*c],a._TempBuffer[4*c+1]=l[2*c+1],a._TempBuffer[4*c+2]=0,a._TempBuffer[4*c+3]=0;this.updateUniform(s,a._TempBuffer,8)},a.prototype._updateFloatForEffect=function(s,l){this._currentEffect.setFloat(s,l)},a.prototype._updateFloatForUniform=function(s,l){a._TempBuffer[0]=l,this.updateUniform(s,a._TempBuffer,1)},a.prototype._updateFloat2ForEffect=function(s,l,c,u){u===void 0&&(u=""),this._currentEffect.setFloat2(s+u,l,c)},a.prototype._updateFloat2ForUniform=function(s,l,c){a._TempBuffer[0]=l,a._TempBuffer[1]=c,this.updateUniform(s,a._TempBuffer,2)},a.prototype._updateFloat3ForEffect=function(s,l,c,u,d){d===void 0&&(d=""),this._currentEffect.setFloat3(s+d,l,c,u)},a.prototype._updateFloat3ForUniform=function(s,l,c,u){a._TempBuffer[0]=l,a._TempBuffer[1]=c,a._TempBuffer[2]=u,this.updateUniform(s,a._TempBuffer,3)},a.prototype._updateFloat4ForEffect=function(s,l,c,u,d,h){h===void 0&&(h=""),this._currentEffect.setFloat4(s+h,l,c,u,d)},a.prototype._updateFloat4ForUniform=function(s,l,c,u,d){a._TempBuffer[0]=l,a._TempBuffer[1]=c,a._TempBuffer[2]=u,a._TempBuffer[3]=d,this.updateUniform(s,a._TempBuffer,4)},a.prototype._updateFloatArrayForEffect=function(s,l){this._currentEffect.setFloatArray(s,l)},a.prototype._updateFloatArrayForUniform=function(s,l){this.updateUniformArray(s,l,l.length)},a.prototype._updateArrayForEffect=function(s,l){this._currentEffect.setArray(s,l)},a.prototype._updateArrayForUniform=function(s,l){this.updateUniformArray(s,l,l.length)},a.prototype._updateIntArrayForEffect=function(s,l){this._currentEffect.setIntArray(s,l)},a.prototype._updateIntArrayForUniform=function(s,l){a._TempBufferInt32View.set(l),this.updateUniformArray(s,a._TempBuffer,l.length)},a.prototype._updateUIntArrayForEffect=function(s,l){this._currentEffect.setUIntArray(s,l)},a.prototype._updateUIntArrayForUniform=function(s,l){a._TempBufferUInt32View.set(l),this.updateUniformArray(s,a._TempBuffer,l.length)},a.prototype._updateMatrixForEffect=function(s,l){this._currentEffect.setMatrix(s,l)},a.prototype._updateMatrixForUniform=function(s,l){this._cacheMatrix(s,l)&&this.updateUniform(s,l.asArray(),16)},a.prototype._updateMatricesForEffect=function(s,l){this._currentEffect.setMatrices(s,l)},a.prototype._updateMatricesForUniform=function(s,l){this.updateUniform(s,l,l.length)},a.prototype._updateVector3ForEffect=function(s,l){this._currentEffect.setVector3(s,l)},a.prototype._updateVector3ForUniform=function(s,l){a._TempBuffer[0]=l.x,a._TempBuffer[1]=l.y,a._TempBuffer[2]=l.z,this.updateUniform(s,a._TempBuffer,3)},a.prototype._updateVector4ForEffect=function(s,l){this._currentEffect.setVector4(s,l)},a.prototype._updateVector4ForUniform=function(s,l){a._TempBuffer[0]=l.x,a._TempBuffer[1]=l.y,a._TempBuffer[2]=l.z,a._TempBuffer[3]=l.w,this.updateUniform(s,a._TempBuffer,4)},a.prototype._updateColor3ForEffect=function(s,l,c){c===void 0&&(c=""),this._currentEffect.setColor3(s+c,l)},a.prototype._updateColor3ForUniform=function(s,l){a._TempBuffer[0]=l.r,a._TempBuffer[1]=l.g,a._TempBuffer[2]=l.b,this.updateUniform(s,a._TempBuffer,3)},a.prototype._updateColor4ForEffect=function(s,l,c,u){u===void 0&&(u=""),this._currentEffect.setColor4(s+u,l,c)},a.prototype._updateDirectColor4ForEffect=function(s,l,c){c===void 0&&(c=""),this._currentEffect.setDirectColor4(s+c,l)},a.prototype._updateColor4ForUniform=function(s,l,c){a._TempBuffer[0]=l.r,a._TempBuffer[1]=l.g,a._TempBuffer[2]=l.b,a._TempBuffer[3]=c,this.updateUniform(s,a._TempBuffer,4)},a.prototype._updateDirectColor4ForUniform=function(s,l){a._TempBuffer[0]=l.r,a._TempBuffer[1]=l.g,a._TempBuffer[2]=l.b,a._TempBuffer[3]=l.a,this.updateUniform(s,a._TempBuffer,4)},a.prototype._updateIntForEffect=function(s,l,c){c===void 0&&(c=""),this._currentEffect.setInt(s+c,l)},a.prototype._updateIntForUniform=function(s,l){a._TempBufferInt32View[0]=l,this.updateUniform(s,a._TempBuffer,1)},a.prototype._updateInt2ForEffect=function(s,l,c,u){u===void 0&&(u=""),this._currentEffect.setInt2(s+u,l,c)},a.prototype._updateInt2ForUniform=function(s,l,c){a._TempBufferInt32View[0]=l,a._TempBufferInt32View[1]=c,this.updateUniform(s,a._TempBuffer,2)},a.prototype._updateInt3ForEffect=function(s,l,c,u,d){d===void 0&&(d=""),this._currentEffect.setInt3(s+d,l,c,u)},a.prototype._updateInt3ForUniform=function(s,l,c,u){a._TempBufferInt32View[0]=l,a._TempBufferInt32View[1]=c,a._TempBufferInt32View[2]=u,this.updateUniform(s,a._TempBuffer,3)},a.prototype._updateInt4ForEffect=function(s,l,c,u,d,h){h===void 0&&(h=""),this._currentEffect.setInt4(s+h,l,c,u,d)},a.prototype._updateInt4ForUniform=function(s,l,c,u,d){a._TempBufferInt32View[0]=l,a._TempBufferInt32View[1]=c,a._TempBufferInt32View[2]=u,a._TempBufferInt32View[3]=d,this.updateUniform(s,a._TempBuffer,4)},a.prototype._updateUIntForEffect=function(s,l,c){c===void 0&&(c=""),this._currentEffect.setUInt(s+c,l)},a.prototype._updateUIntForUniform=function(s,l){a._TempBufferUInt32View[0]=l,this.updateUniform(s,a._TempBuffer,1)},a.prototype._updateUInt2ForEffect=function(s,l,c,u){u===void 0&&(u=""),this._currentEffect.setUInt2(s+u,l,c)},a.prototype._updateUInt2ForUniform=function(s,l,c){a._TempBufferUInt32View[0]=l,a._TempBufferUInt32View[1]=c,this.updateUniform(s,a._TempBuffer,2)},a.prototype._updateUInt3ForEffect=function(s,l,c,u,d){d===void 0&&(d=""),this._currentEffect.setUInt3(s+d,l,c,u)},a.prototype._updateUInt3ForUniform=function(s,l,c,u){a._TempBufferUInt32View[0]=l,a._TempBufferUInt32View[1]=c,a._TempBufferUInt32View[2]=u,this.updateUniform(s,a._TempBuffer,3)},a.prototype._updateUInt4ForEffect=function(s,l,c,u,d,h){h===void 0&&(h=""),this._currentEffect.setUInt4(s+h,l,c,u,d)},a.prototype._updateUInt4ForUniform=function(s,l,c,u,d){a._TempBufferUInt32View[0]=l,a._TempBufferUInt32View[1]=c,a._TempBufferUInt32View[2]=u,a._TempBufferUInt32View[3]=d,this.updateUniform(s,a._TempBuffer,4)},a.prototype.setTexture=function(s,l){this._currentEffect.setTexture(s,l)},a.prototype.setTextureArray=function(s,l){this._currentEffect.setTextureArray(s,l)},a.prototype.bindTexture=function(s,l){this._currentEffect._bindTexture(s,l)},a.prototype.updateUniformDirectly=function(s,l){this.updateUniform(s,l,l.length),this.update()},a.prototype.bindToEffect=function(s,l){this._currentEffect=s,this._currentEffectName=l},a.prototype.bindUniformBuffer=function(){!this._noUBO&&this._buffer&&this._currentEffect&&this._currentEffect.bindUniformBuffer(this._buffer,this._currentEffectName)},a.prototype.unbindEffect=function(){this._currentEffect=void 0,this._currentEffectName=void 0},a.prototype.setDataBuffer=function(s){if(!this._buffers)return this._buffer===s;for(var l=0;l<this._buffers.length;++l)if(this._buffers[l][0]===s)return this._bufferIndex=l,this._buffer=s,this._createBufferOnWrite=!1,this._currentEffect=void 0,!0;return!1},a.prototype.dispose=function(){if(!this._noUBO){var s=this._engine._uniformBuffers,l=s.indexOf(this);if(l!==-1&&(s[l]=s[s.length-1],s.pop()),this._engine._features.trackUbosInFrame&&this._buffers)for(var c=0;c<this._buffers.length;++c){var u=this._buffers[c][0];this._engine._releaseBuffer(u)}else this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}},a._UpdatedUbosInFrame={},a._MAX_UNIFORM_SIZE=256,a._TempBuffer=new Float32Array(a._MAX_UNIFORM_SIZE),a._TempBufferInt32View=new Int32Array(a._TempBuffer.buffer),a._TempBufferUInt32View=new Uint32Array(a._TempBuffer.buffer),a}())},13424:(r,t,e)=>{e.d(t,{$x:()=>n,_0:()=>a,xp:()=>o});var n,i=e(8046);(function(s){s[s.LOCAL=0]="LOCAL",s[s.WORLD=1]="WORLD",s[s.BONE=2]="BONE"})(n||(n={}));var o,a=function(){function s(){}return s.X=new i.Pq(1,0,0),s.Y=new i.Pq(0,1,0),s.Z=new i.Pq(0,0,1),s}();(function(s){s[s.X=0]="X",s[s.Y=1]="Y",s[s.Z=2]="Z"})(o||(o={}))},64726:(r,t,e)=>{e.d(t,{IG:()=>p,ov:()=>h,v9:()=>d});var n=e(11296),i=e(34623),o=e(56740),a=e(48810);function s(m){return Math.pow(m,o.tk)}function l(m){return m<=.04045?.0773993808*m:Math.pow(.947867299*(m+.055),2.4)}function c(m){return Math.pow(m,o.rv)}function u(m){return m<=.0031308?12.92*m:1.055*Math.pow(m,.41666)-.055}var d=function(){function m(v,b,E){v===void 0&&(v=0),b===void 0&&(b=0),E===void 0&&(E=0),this.r=v,this.g=b,this.b=E}return m.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},m.prototype.getClassName=function(){return"Color3"},m.prototype.getHashCode=function(){var v=255*this.r|0;return 397*(v=397*v^255*this.g)^255*this.b},m.prototype.toArray=function(v,b){return b===void 0&&(b=0),v[b]=this.r,v[b+1]=this.g,v[b+2]=this.b,this},m.prototype.fromArray=function(v,b){return b===void 0&&(b=0),m.FromArrayToRef(v,b,this),this},m.prototype.toColor4=function(v){return v===void 0&&(v=1),new h(this.r,this.g,this.b,v)},m.prototype.asArray=function(){return[this.r,this.g,this.b]},m.prototype.toLuminance=function(){return .3*this.r+.59*this.g+.11*this.b},m.prototype.multiply=function(v){return new m(this.r*v.r,this.g*v.g,this.b*v.b)},m.prototype.multiplyToRef=function(v,b){return b.r=this.r*v.r,b.g=this.g*v.g,b.b=this.b*v.b,b},m.prototype.multiplyInPlace=function(v){return this.r*=v.r,this.g*=v.g,this.b*=v.b,this},m.prototype.multiplyByFloats=function(v,b,E){return new m(this.r*v,this.g*b,this.b*E)},m.prototype.divide=function(v){throw new ReferenceError("Can not divide a color")},m.prototype.divideToRef=function(v,b){throw new ReferenceError("Can not divide a color")},m.prototype.divideInPlace=function(v){throw new ReferenceError("Can not divide a color")},m.prototype.minimizeInPlace=function(v){return this.minimizeInPlaceFromFloats(v.r,v.g,v.b)},m.prototype.maximizeInPlace=function(v){return this.maximizeInPlaceFromFloats(v.r,v.g,v.b)},m.prototype.minimizeInPlaceFromFloats=function(v,b,E){return this.r=Math.min(v,this.r),this.g=Math.min(b,this.g),this.b=Math.min(E,this.b),this},m.prototype.maximizeInPlaceFromFloats=function(v,b,E){return this.r=Math.max(v,this.r),this.g=Math.max(b,this.g),this.b=Math.max(E,this.b),this},m.prototype.floorToRef=function(v){throw new ReferenceError("Can not floor a color")},m.prototype.floor=function(){throw new ReferenceError("Can not floor a color")},m.prototype.fractToRef=function(v){throw new ReferenceError("Can not fract a color")},m.prototype.fract=function(){throw new ReferenceError("Can not fract a color")},m.prototype.equals=function(v){return v&&this.r===v.r&&this.g===v.g&&this.b===v.b},m.prototype.equalsFloats=function(v,b,E){return this.equalsToFloats(v,b,E)},m.prototype.equalsToFloats=function(v,b,E){return this.r===v&&this.g===b&&this.b===E},m.prototype.equalsWithEpsilon=function(v,b){return b===void 0&&(b=o.bH),(0,a.WithinEpsilon)(this.r,v.r,b)&&(0,a.WithinEpsilon)(this.g,v.g,b)&&(0,a.WithinEpsilon)(this.b,v.b,b)},m.prototype.negate=function(){throw new ReferenceError("Can not negate a color")},m.prototype.negateInPlace=function(){throw new ReferenceError("Can not negate a color")},m.prototype.negateToRef=function(v){throw new ReferenceError("Can not negate a color")},m.prototype.scale=function(v){return new m(this.r*v,this.g*v,this.b*v)},m.prototype.scaleInPlace=function(v){return this.r*=v,this.g*=v,this.b*=v,this},m.prototype.scaleToRef=function(v,b){return b.r=this.r*v,b.g=this.g*v,b.b=this.b*v,b},m.prototype.scaleAndAddToRef=function(v,b){return b.r+=this.r*v,b.g+=this.g*v,b.b+=this.b*v,b},m.prototype.clampToRef=function(v,b,E){return v===void 0&&(v=0),b===void 0&&(b=1),E.r=(0,a.Clamp)(this.r,v,b),E.g=(0,a.Clamp)(this.g,v,b),E.b=(0,a.Clamp)(this.b,v,b),E},m.prototype.add=function(v){return new m(this.r+v.r,this.g+v.g,this.b+v.b)},m.prototype.addInPlace=function(v){return this.r+=v.r,this.g+=v.g,this.b+=v.b,this},m.prototype.addInPlaceFromFloats=function(v,b,E){return this.r+=v,this.g+=b,this.b+=E,this},m.prototype.addToRef=function(v,b){return b.r=this.r+v.r,b.g=this.g+v.g,b.b=this.b+v.b,b},m.prototype.subtract=function(v){return new m(this.r-v.r,this.g-v.g,this.b-v.b)},m.prototype.subtractToRef=function(v,b){return b.r=this.r-v.r,b.g=this.g-v.g,b.b=this.b-v.b,b},m.prototype.subtractInPlace=function(v){return this.r-=v.r,this.g-=v.g,this.b-=v.b,this},m.prototype.subtractFromFloats=function(v,b,E){return new m(this.r-v,this.g-b,this.b-E)},m.prototype.subtractFromFloatsToRef=function(v,b,E,C){return C.r=this.r-v,C.g=this.g-b,C.b=this.b-E,C},m.prototype.clone=function(){return new m(this.r,this.g,this.b)},m.prototype.copyFrom=function(v){return this.r=v.r,this.g=v.g,this.b=v.b,this},m.prototype.copyFromFloats=function(v,b,E){return this.r=v,this.g=b,this.b=E,this},m.prototype.set=function(v,b,E){return this.copyFromFloats(v,b,E)},m.prototype.setAll=function(v){return this.r=this.g=this.b=v,this},m.prototype.toHexString=function(){var v=Math.round(255*this.r),b=Math.round(255*this.g),E=Math.round(255*this.b);return"#"+(0,a.ToHex)(v)+(0,a.ToHex)(b)+(0,a.ToHex)(E)},m.prototype.toHSV=function(){return this.toHSVToRef(new m)},m.prototype.toHSVToRef=function(v){var b=this.r,E=this.g,C=this.b,T=Math.max(b,E,C),f=Math.min(b,E,C),g=0,S=0,y=T,x=T-f;return T!==0&&(S=x/T),T!=f&&(T==b?(g=(E-C)/x,E<C&&(g+=6)):T==E?g=(C-b)/x+2:T==C&&(g=(b-E)/x+4),g*=60),v.r=g,v.g=S,v.b=y,v},m.prototype.toLinearSpace=function(v){v===void 0&&(v=!1);var b=new m;return this.toLinearSpaceToRef(b,v),b},m.prototype.toLinearSpaceToRef=function(v,b){return b===void 0&&(b=!1),b?(v.r=l(this.r),v.g=l(this.g),v.b=l(this.b)):(v.r=s(this.r),v.g=s(this.g),v.b=s(this.b)),this},m.prototype.toGammaSpace=function(v){v===void 0&&(v=!1);var b=new m;return this.toGammaSpaceToRef(b,v),b},m.prototype.toGammaSpaceToRef=function(v,b){return b===void 0&&(b=!1),b?(v.r=u(this.r),v.g=u(this.g),v.b=u(this.b)):(v.r=c(this.r),v.g=c(this.g),v.b=c(this.b)),this},m.HSVtoRGBToRef=function(v,b,E,C){var T=E*b,f=v/60,g=T*(1-Math.abs(f%2-1)),S=0,y=0,x=0;f>=0&&f<=1?(S=T,y=g):f>=1&&f<=2?(S=g,y=T):f>=2&&f<=3?(y=T,x=g):f>=3&&f<=4?(y=g,x=T):f>=4&&f<=5?(S=g,x=T):f>=5&&f<=6&&(S=T,x=g);var R=E-T;return C.r=S+R,C.g=y+R,C.b=x+R,C},m.FromHSV=function(v,b,E){var C=new m(0,0,0);return m.HSVtoRGBToRef(v,b,E,C),C},m.FromHexString=function(v){if(v.substring(0,1)!=="#"||v.length!==7)return new m(0,0,0);var b=parseInt(v.substring(1,3),16),E=parseInt(v.substring(3,5),16),C=parseInt(v.substring(5,7),16);return m.FromInts(b,E,C)},m.FromArray=function(v,b){return b===void 0&&(b=0),new m(v[b],v[b+1],v[b+2])},m.FromArrayToRef=function(v,b,E){b===void 0&&(b=0),E.r=v[b],E.g=v[b+1],E.b=v[b+2]},m.FromInts=function(v,b,E){return new m(v/255,b/255,E/255)},m.Lerp=function(v,b,E){var C=new m(0,0,0);return m.LerpToRef(v,b,E,C),C},m.LerpToRef=function(v,b,E,C){C.r=v.r+(b.r-v.r)*E,C.g=v.g+(b.g-v.g)*E,C.b=v.b+(b.b-v.b)*E},m.Hermite=function(v,b,E,C,T){var f=T*T,g=T*f,S=2*g-3*f+1,y=-2*g+3*f,x=g-2*f+T,R=g-f;return new m(v.r*S+E.r*y+b.r*x+C.r*R,v.g*S+E.g*y+b.g*x+C.g*R,v.b*S+E.b*y+b.b*x+C.b*R)},m.Hermite1stDerivative=function(v,b,E,C,T){var f=m.Black();return this.Hermite1stDerivativeToRef(v,b,E,C,T,f),f},m.Hermite1stDerivativeToRef=function(v,b,E,C,T,f){var g=T*T;f.r=6*(g-T)*v.r+(3*g-4*T+1)*b.r+6*(-g+T)*E.r+(3*g-2*T)*C.r,f.g=6*(g-T)*v.g+(3*g-4*T+1)*b.g+6*(-g+T)*E.g+(3*g-2*T)*C.g,f.b=6*(g-T)*v.b+(3*g-4*T+1)*b.b+6*(-g+T)*E.b+(3*g-2*T)*C.b},m.Red=function(){return new m(1,0,0)},m.Green=function(){return new m(0,1,0)},m.Blue=function(){return new m(0,0,1)},m.Black=function(){return new m(0,0,0)},Object.defineProperty(m,"BlackReadOnly",{get:function(){return m._BlackReadOnly},enumerable:!1,configurable:!0}),m.White=function(){return new m(1,1,1)},m.Purple=function(){return new m(.5,0,.5)},m.Magenta=function(){return new m(1,0,1)},m.Yellow=function(){return new m(1,1,0)},m.Gray=function(){return new m(.5,.5,.5)},m.Teal=function(){return new m(0,1,1)},m.Random=function(){return new m(Math.random(),Math.random(),Math.random())},m._BlackReadOnly=m.Black(),m}();Object.defineProperties(d.prototype,{dimension:{value:[3]},rank:{value:1}});var h=function(){function m(v,b,E,C){v===void 0&&(v=0),b===void 0&&(b=0),E===void 0&&(E=0),C===void 0&&(C=1),this.r=v,this.g=b,this.b=E,this.a=C}return m.prototype.asArray=function(){return[this.r,this.g,this.b,this.a]},m.prototype.toArray=function(v,b){return b===void 0&&(b=0),v[b]=this.r,v[b+1]=this.g,v[b+2]=this.b,v[b+3]=this.a,this},m.prototype.fromArray=function(v,b){return b===void 0&&(b=0),this.r=v[b],this.g=v[b+1],this.b=v[b+2],this.a=v[b+3],this},m.prototype.equals=function(v){return v&&this.r===v.r&&this.g===v.g&&this.b===v.b&&this.a===v.a},m.prototype.add=function(v){return new m(this.r+v.r,this.g+v.g,this.b+v.b,this.a+v.a)},m.prototype.addToRef=function(v,b){return b.r=this.r+v.r,b.g=this.g+v.g,b.b=this.b+v.b,b.a=this.a+v.a,b},m.prototype.addInPlace=function(v){return this.r+=v.r,this.g+=v.g,this.b+=v.b,this.a+=v.a,this},m.prototype.addInPlaceFromFloats=function(v,b,E,C){return this.r+=v,this.g+=b,this.b+=E,this.a+=C,this},m.prototype.subtract=function(v){return new m(this.r-v.r,this.g-v.g,this.b-v.b,this.a-v.a)},m.prototype.subtractToRef=function(v,b){return b.r=this.r-v.r,b.g=this.g-v.g,b.b=this.b-v.b,b.a=this.a-v.a,b},m.prototype.subtractInPlace=function(v){return this.r-=v.r,this.g-=v.g,this.b-=v.b,this.a-=v.a,this},m.prototype.subtractFromFloats=function(v,b,E,C){return new m(this.r-v,this.g-b,this.b-E,this.a-C)},m.prototype.subtractFromFloatsToRef=function(v,b,E,C,T){return T.r=this.r-v,T.g=this.g-b,T.b=this.b-E,T.a=this.a-C,T},m.prototype.scale=function(v){return new m(this.r*v,this.g*v,this.b*v,this.a*v)},m.prototype.scaleInPlace=function(v){return this.r*=v,this.g*=v,this.b*=v,this.a*=v,this},m.prototype.scaleToRef=function(v,b){return b.r=this.r*v,b.g=this.g*v,b.b=this.b*v,b.a=this.a*v,b},m.prototype.scaleAndAddToRef=function(v,b){return b.r+=this.r*v,b.g+=this.g*v,b.b+=this.b*v,b.a+=this.a*v,b},m.prototype.clampToRef=function(v,b,E){return v===void 0&&(v=0),b===void 0&&(b=1),E.r=(0,a.Clamp)(this.r,v,b),E.g=(0,a.Clamp)(this.g,v,b),E.b=(0,a.Clamp)(this.b,v,b),E.a=(0,a.Clamp)(this.a,v,b),E},m.prototype.multiply=function(v){return new m(this.r*v.r,this.g*v.g,this.b*v.b,this.a*v.a)},m.prototype.multiplyToRef=function(v,b){return b.r=this.r*v.r,b.g=this.g*v.g,b.b=this.b*v.b,b.a=this.a*v.a,b},m.prototype.multiplyInPlace=function(v){return this.r*=v.r,this.g*=v.g,this.b*=v.b,this.a*=v.a,this},m.prototype.multiplyByFloats=function(v,b,E,C){return new m(this.r*v,this.g*b,this.b*E,this.a*C)},m.prototype.divide=function(v){throw new ReferenceError("Can not divide a color")},m.prototype.divideToRef=function(v,b){throw new ReferenceError("Can not divide a color")},m.prototype.divideInPlace=function(v){throw new ReferenceError("Can not divide a color")},m.prototype.minimizeInPlace=function(v){return this.r=Math.min(this.r,v.r),this.g=Math.min(this.g,v.g),this.b=Math.min(this.b,v.b),this.a=Math.min(this.a,v.a),this},m.prototype.maximizeInPlace=function(v){return this.r=Math.max(this.r,v.r),this.g=Math.max(this.g,v.g),this.b=Math.max(this.b,v.b),this.a=Math.max(this.a,v.a),this},m.prototype.minimizeInPlaceFromFloats=function(v,b,E,C){return this.r=Math.min(v,this.r),this.g=Math.min(b,this.g),this.b=Math.min(E,this.b),this.a=Math.min(C,this.a),this},m.prototype.maximizeInPlaceFromFloats=function(v,b,E,C){return this.r=Math.max(v,this.r),this.g=Math.max(b,this.g),this.b=Math.max(E,this.b),this.a=Math.max(C,this.a),this},m.prototype.floorToRef=function(v){throw new ReferenceError("Can not floor a color")},m.prototype.floor=function(){throw new ReferenceError("Can not floor a color")},m.prototype.fractToRef=function(v){throw new ReferenceError("Can not fract a color")},m.prototype.fract=function(){throw new ReferenceError("Can not fract a color")},m.prototype.negate=function(){throw new ReferenceError("Can not negate a color")},m.prototype.negateInPlace=function(){throw new ReferenceError("Can not negate a color")},m.prototype.negateToRef=function(v){throw new ReferenceError("Can not negate a color")},m.prototype.equalsWithEpsilon=function(v,b){return b===void 0&&(b=o.bH),(0,a.WithinEpsilon)(this.r,v.r,b)&&(0,a.WithinEpsilon)(this.g,v.g,b)&&(0,a.WithinEpsilon)(this.b,v.b,b)&&(0,a.WithinEpsilon)(this.a,v.a,b)},m.prototype.equalsToFloats=function(v,b,E,C){return this.r===v&&this.g===b&&this.b===E&&this.a===C},m.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},m.prototype.getClassName=function(){return"Color4"},m.prototype.getHashCode=function(){var v=255*this.r|0;return 397*(v=397*(v=397*v^255*this.g)^255*this.b)^255*this.a},m.prototype.clone=function(){return new m().copyFrom(this)},m.prototype.copyFrom=function(v){return this.r=v.r,this.g=v.g,this.b=v.b,this.a=v.a,this},m.prototype.copyFromFloats=function(v,b,E,C){return this.r=v,this.g=b,this.b=E,this.a=C,this},m.prototype.set=function(v,b,E,C){return this.copyFromFloats(v,b,E,C)},m.prototype.setAll=function(v){return this.r=this.g=this.b=this.a=v,this},m.prototype.toHexString=function(v){v===void 0&&(v=!1);var b=Math.round(255*this.r),E=Math.round(255*this.g),C=Math.round(255*this.b);if(v)return"#"+(0,a.ToHex)(b)+(0,a.ToHex)(E)+(0,a.ToHex)(C);var T=Math.round(255*this.a);return"#"+(0,a.ToHex)(b)+(0,a.ToHex)(E)+(0,a.ToHex)(C)+(0,a.ToHex)(T)},m.prototype.toLinearSpace=function(v){v===void 0&&(v=!1);var b=new m;return this.toLinearSpaceToRef(b,v),b},m.prototype.toLinearSpaceToRef=function(v,b){return b===void 0&&(b=!1),b?(v.r=l(this.r),v.g=l(this.g),v.b=l(this.b)):(v.r=s(this.r),v.g=s(this.g),v.b=s(this.b)),v.a=this.a,this},m.prototype.toGammaSpace=function(v){v===void 0&&(v=!1);var b=new m;return this.toGammaSpaceToRef(b,v),b},m.prototype.toGammaSpaceToRef=function(v,b){return b===void 0&&(b=!1),b?(v.r=u(this.r),v.g=u(this.g),v.b=u(this.b)):(v.r=c(this.r),v.g=c(this.g),v.b=c(this.b)),v.a=this.a,this},m.FromHexString=function(v){if(v.substring(0,1)!=="#"||v.length!==9&&v.length!==7)return new m(0,0,0,0);var b=parseInt(v.substring(1,3),16),E=parseInt(v.substring(3,5),16),C=parseInt(v.substring(5,7),16),T=v.length===9?parseInt(v.substring(7,9),16):255;return m.FromInts(b,E,C,T)},m.Lerp=function(v,b,E){return m.LerpToRef(v,b,E,new m)},m.LerpToRef=function(v,b,E,C){return C.r=v.r+(b.r-v.r)*E,C.g=v.g+(b.g-v.g)*E,C.b=v.b+(b.b-v.b)*E,C.a=v.a+(b.a-v.a)*E,C},m.Hermite=function(v,b,E,C,T){var f=T*T,g=T*f,S=2*g-3*f+1,y=-2*g+3*f,x=g-2*f+T,R=g-f;return new m(v.r*S+E.r*y+b.r*x+C.r*R,v.g*S+E.g*y+b.g*x+C.g*R,v.b*S+E.b*y+b.b*x+C.b*R,v.a*S+E.a*y+b.a*x+C.a*R)},m.Hermite1stDerivative=function(v,b,E,C,T){var f=new m;return this.Hermite1stDerivativeToRef(v,b,E,C,T,f),f},m.Hermite1stDerivativeToRef=function(v,b,E,C,T,f){var g=T*T;f.r=6*(g-T)*v.r+(3*g-4*T+1)*b.r+6*(-g+T)*E.r+(3*g-2*T)*C.r,f.g=6*(g-T)*v.g+(3*g-4*T+1)*b.g+6*(-g+T)*E.g+(3*g-2*T)*C.g,f.b=6*(g-T)*v.b+(3*g-4*T+1)*b.b+6*(-g+T)*E.b+(3*g-2*T)*C.b,f.a=6*(g-T)*v.a+(3*g-4*T+1)*b.a+6*(-g+T)*E.a+(3*g-2*T)*C.a},m.FromColor3=function(v,b){return b===void 0&&(b=1),new m(v.r,v.g,v.b,b)},m.FromArray=function(v,b){return b===void 0&&(b=0),new m(v[b],v[b+1],v[b+2],v[b+3])},m.FromArrayToRef=function(v,b,E){b===void 0&&(b=0),E.r=v[b],E.g=v[b+1],E.b=v[b+2],E.a=v[b+3]},m.FromInts=function(v,b,E,C){return new m(v/255,b/255,E/255,C/255)},m.CheckColors4=function(v,b){if(v.length===3*b){for(var E=[],C=0;C<v.length;C+=3){var T=C/3*4;E[T]=v[C],E[T+1]=v[C+1],E[T+2]=v[C+2],E[T+3]=1}return E}return v},m}();Object.defineProperties(h.prototype,{dimension:{value:[4]},rank:{value:1}});var p=function(){function m(){}return m.Color3=(0,n.mI)(3,d.Black),m.Color4=(0,n.mI)(3,function(){return new h(0,0,0,0)}),m}();(0,i.Y5)("BABYLON.Color3",d),(0,i.Y5)("BABYLON.Color4",h)},56740:(r,t,e)=>{e.d(t,{a6:()=>o,bH:()=>a,rv:()=>n,tk:()=>i});var n=1/2.2,i=2.2,o=(1+Math.sqrt(5))/2,a=.001},36359:(r,t,e)=>{e.d(t,{P:()=>i});var n=e(43939),i=function(){function o(){}return o.GetPlanes=function(a){for(var s=[],l=0;l<6;l++)s.push(new n.Z(0,0,0,0));return o.GetPlanesToRef(a,s),s},o.GetNearPlaneToRef=function(a,s){var l=a.m;s.normal.x=l[3]+l[2],s.normal.y=l[7]+l[6],s.normal.z=l[11]+l[10],s.d=l[15]+l[14],s.normalize()},o.GetFarPlaneToRef=function(a,s){var l=a.m;s.normal.x=l[3]-l[2],s.normal.y=l[7]-l[6],s.normal.z=l[11]-l[10],s.d=l[15]-l[14],s.normalize()},o.GetLeftPlaneToRef=function(a,s){var l=a.m;s.normal.x=l[3]+l[0],s.normal.y=l[7]+l[4],s.normal.z=l[11]+l[8],s.d=l[15]+l[12],s.normalize()},o.GetRightPlaneToRef=function(a,s){var l=a.m;s.normal.x=l[3]-l[0],s.normal.y=l[7]-l[4],s.normal.z=l[11]-l[8],s.d=l[15]-l[12],s.normalize()},o.GetTopPlaneToRef=function(a,s){var l=a.m;s.normal.x=l[3]-l[1],s.normal.y=l[7]-l[5],s.normal.z=l[11]-l[9],s.d=l[15]-l[13],s.normalize()},o.GetBottomPlaneToRef=function(a,s){var l=a.m;s.normal.x=l[3]+l[1],s.normal.y=l[7]+l[5],s.normal.z=l[11]+l[9],s.d=l[15]+l[13],s.normalize()},o.GetPlanesToRef=function(a,s){o.GetNearPlaneToRef(a,s[0]),o.GetFarPlaneToRef(a,s[1]),o.GetLeftPlaneToRef(a,s[2]),o.GetRightPlaneToRef(a,s[3]),o.GetTopPlaneToRef(a,s[4]),o.GetBottomPlaneToRef(a,s[5])},o.IsPointInFrustum=function(a,s){for(var l=0;l<6;l++)if(s[l].dotCoordinate(a)<0)return!1;return!0},o}()},47424:(r,t,e)=>{e.d(t,{b:()=>l,c:()=>s});var n=e(78322),i=e(8046),o=e(6174),a=function(){function c(){}return c.extractMinAndMaxIndexed=function(u,d,h,p,m,v){for(var b=h;b<h+p;b++){var E=3*d[b],C=u[E],T=u[E+1],f=u[E+2];m.minimizeInPlaceFromFloats(C,T,f),v.maximizeInPlaceFromFloats(C,T,f)}},c.extractMinAndMax=function(u,d,h,p,m,v){for(var b=d,E=d*p;b<d+h;b++,E+=p){var C=u[E],T=u[E+1],f=u[E+2];m.minimizeInPlaceFromFloats(C,T,f),v.maximizeInPlaceFromFloats(C,T,f)}},(0,n.Cg)([o.Cx.filter(function(){for(var u=[],d=0;d<arguments.length;d++)u[d]=arguments[d];var h=u[0],p=u[1];return!Array.isArray(h)&&!Array.isArray(p)})],c,"extractMinAndMaxIndexed",null),(0,n.Cg)([o.Cx.filter(function(){for(var u=[],d=0;d<arguments.length;d++)u[d]=arguments[d];var h=u[0];return!Array.isArray(h)})],c,"extractMinAndMax",null),c}();function s(c,u,d,h,p){p===void 0&&(p=null);var m=new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),v=new i.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return a.extractMinAndMaxIndexed(c,u,d,h,m,v),p&&(m.x-=m.x*p.x+p.y,m.y-=m.y*p.x+p.y,m.z-=m.z*p.x+p.y,v.x+=v.x*p.x+p.y,v.y+=v.y*p.x+p.y,v.z+=v.z*p.x+p.y),{minimum:m,maximum:v}}function l(c,u,d,h,p){h===void 0&&(h=null);var m=new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),v=new i.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return p||(p=3),a.extractMinAndMax(c,u,d,p,m,v),h&&(m.x-=m.x*h.x+h.y,m.y-=m.y*h.x+h.y,m.z-=m.z*h.x+h.y,v.x+=v.x*h.x+h.y,v.y+=v.y*h.x+h.y,v.z+=v.z*h.x+h.y),{minimum:m,maximum:v}}},95318:(r,t,e)=>{e.d(t,{Cu:()=>u,Xy:()=>c,jj:()=>h,t4:()=>n,tO:()=>d,uM:()=>l,vr:()=>s});var n,i=e(48810),o=e(8046),a=e(56740);(function(p){p[p.CW=0]="CW",p[p.CCW=1]="CCW"})(n||(n={}));var s=function(){function p(){}return p.Interpolate=function(m,v,b,E,C){for(var T=1-3*E+3*v,f=3*E-6*v,g=3*v,S=m,y=0;y<5;y++){var x=S*S;S-=1/(3*T*x+2*f*S+g)*(T*(x*S)+f*x+g*S-m),S=Math.min(1,Math.max(0,S))}return 3*Math.pow(1-S,2)*S*b+3*(1-S)*Math.pow(S,2)*C+Math.pow(S,3)},p}(),l=function(){function p(m){this._radians=m,this._radians<0&&(this._radians+=2*Math.PI)}return p.prototype.degrees=function(){return 180*this._radians/Math.PI},p.prototype.radians=function(){return this._radians},p.BetweenTwoPoints=function(m,v){var b=v.subtract(m);return new p(Math.atan2(b.y,b.x))},p.BetweenTwoVectors=function(m,v){var b=m.lengthSquared()*v.lengthSquared();if(b===0)return new p(Math.PI/2);b=Math.sqrt(b);var E=m.dot(v)/b;return E=(0,i.Clamp)(E,-1,1),new p(Math.acos(E))},p.FromRadians=function(m){return new p(m)},p.FromDegrees=function(m){return new p(m*Math.PI/180)},p}(),c=function(p,m,v){this.startPoint=p,this.midPoint=m,this.endPoint=v;var b=Math.pow(m.x,2)+Math.pow(m.y,2),E=(Math.pow(p.x,2)+Math.pow(p.y,2)-b)/2,C=(b-Math.pow(v.x,2)-Math.pow(v.y,2))/2,T=(p.x-m.x)*(m.y-v.y)-(m.x-v.x)*(p.y-m.y);this.centerPoint=new o.I9((E*(m.y-v.y)-C*(p.y-m.y))/T,((p.x-m.x)*C-(m.x-v.x)*E)/T),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=l.BetweenTwoPoints(this.centerPoint,this.startPoint);var f=this.startAngle.degrees(),g=l.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),S=l.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();g-f>180&&(g-=360),g-f<-180&&(g+=360),S-g>180&&(S-=360),S-g<-180&&(S+=360),this.orientation=g-f<0?0:1,this.angle=l.FromDegrees(this.orientation===0?f-S:S-f)},u=function(){function p(m,v){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new o.I9(m,v))}return p.prototype.addLineTo=function(m,v){if(this.closed)return this;var b=new o.I9(m,v),E=this._points[this._points.length-1];return this._points.push(b),this._length+=b.subtract(E).length(),this},p.prototype.addArcTo=function(m,v,b,E,C){if(C===void 0&&(C=36),this.closed)return this;var T=this._points[this._points.length-1],f=new o.I9(m,v),g=new o.I9(b,E),S=new c(T,f,g),y=S.angle.radians()/C;S.orientation===0&&(y*=-1);for(var x=S.startAngle.radians()+y,R=0;R<C;R++){var I=Math.cos(x)*S.radius+S.centerPoint.x,M=Math.sin(x)*S.radius+S.centerPoint.y;this.addLineTo(I,M),x+=y}return this},p.prototype.addQuadraticCurveTo=function(m,v,b,E,C){if(C===void 0&&(C=36),this.closed)return this;for(var T=function(R,I,M,D){return(1-R)*(1-R)*I+2*R*(1-R)*M+R*R*D},f=this._points[this._points.length-1],g=0;g<=C;g++){var S=g/C,y=T(S,f.x,m,b),x=T(S,f.y,v,E);this.addLineTo(y,x)}return this},p.prototype.addBezierCurveTo=function(m,v,b,E,C,T,f){if(f===void 0&&(f=36),this.closed)return this;for(var g=function(M,D,B,F,X){return(1-M)*(1-M)*(1-M)*D+3*M*(1-M)*(1-M)*B+3*M*M*(1-M)*F+M*M*M*X},S=this._points[this._points.length-1],y=0;y<=f;y++){var x=y/f,R=g(x,S.x,m,b,C),I=g(x,S.y,v,E,T);this.addLineTo(R,I)}return this},p.prototype.isPointInside=function(m){for(var v=!1,b=this._points.length,E=b-1,C=0;C<b;E=C++){var T=this._points[E],f=this._points[C],g=f.x-T.x,S=f.y-T.y;if(Math.abs(S)>Number.EPSILON){if(S<0&&(T=this._points[C],g=-g,f=this._points[E],S=-S),m.y<T.y||m.y>f.y)continue;if(m.y===T.y&&m.x===T.x)return!0;var y=S*(m.x-T.x)-g*(m.y-T.y);if(y===0)return!0;if(y<0)continue;v=!v}else{if(m.y!==T.y)continue;if(f.x<=m.x&&m.x<=T.x||T.x<=m.x&&m.x<=f.x)return!0}}return v},p.prototype.close=function(){return this.closed=!0,this},p.prototype.length=function(){var m=this._length;if(this.closed){var v=this._points[this._points.length-1];m+=this._points[0].subtract(v).length()}return m},p.prototype.area=function(){for(var m=this._points.length,v=0,b=m-1,E=0;E<m;b=E++)v+=this._points[b].x*this._points[E].y-this._points[E].x*this._points[b].y;return .5*v},p.prototype.getPoints=function(){return this._points},p.prototype.getPointAtLengthPosition=function(m){if(m<0||m>1)return o.I9.Zero();for(var v=m*this.length(),b=0,E=0;E<this._points.length;E++){var C=(E+1)%this._points.length,T=this._points[E],f=this._points[C].subtract(T),g=f.length()+b;if(v>=b&&v<=g){var S=f.normalize(),y=v-b;return new o.I9(T.x+S.x*y,T.y+S.y*y)}b=g}return o.I9.Zero()},p.StartingAt=function(m,v){return new p(m,v)},p}(),d=function(){function p(m,v,b,E){v===void 0&&(v=null),E===void 0&&(E=!1),this.path=m,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array,this._pointAtData={id:0,point:o.Pq.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:o.uq.Identity()};for(var C=0;C<m.length;C++)this._curve[C]=m[C].clone();this._raw=b||!1,this._alignTangentsWithPath=E,this._compute(v,E)}return p.prototype.getCurve=function(){return this._curve},p.prototype.getPoints=function(){return this._curve},p.prototype.length=function(){return this._distances[this._distances.length-1]},p.prototype.getTangents=function(){return this._tangents},p.prototype.getNormals=function(){return this._normals},p.prototype.getBinormals=function(){return this._binormals},p.prototype.getDistances=function(){return this._distances},p.prototype.getPointAt=function(m){return this._updatePointAtData(m).point},p.prototype.getTangentAt=function(m,v){return v===void 0&&(v=!1),this._updatePointAtData(m,v),v?o.Pq.TransformCoordinates(o.Pq.Forward(),this._pointAtData.interpolationMatrix):this._tangents[this._pointAtData.previousPointArrayIndex]},p.prototype.getNormalAt=function(m,v){return v===void 0&&(v=!1),this._updatePointAtData(m,v),v?o.Pq.TransformCoordinates(o.Pq.Right(),this._pointAtData.interpolationMatrix):this._normals[this._pointAtData.previousPointArrayIndex]},p.prototype.getBinormalAt=function(m,v){return v===void 0&&(v=!1),this._updatePointAtData(m,v),v?o.Pq.TransformCoordinates(o.Pq.UpReadOnly,this._pointAtData.interpolationMatrix):this._binormals[this._pointAtData.previousPointArrayIndex]},p.prototype.getDistanceAt=function(m){return this.length()*m},p.prototype.getPreviousPointIndexAt=function(m){return this._updatePointAtData(m),this._pointAtData.previousPointArrayIndex},p.prototype.getSubPositionAt=function(m){return this._updatePointAtData(m),this._pointAtData.subPosition},p.prototype.getClosestPositionTo=function(m){for(var v=Number.MAX_VALUE,b=0,E=0;E<this._curve.length-1;E++){var C=this._curve[E+0],T=this._curve[E+1].subtract(C).normalize(),f=this._distances[E+1]-this._distances[E+0],g=Math.min(Math.max(o.Pq.Dot(T,m.subtract(C).normalize()),0)*o.Pq.Distance(C,m)/f,1),S=o.Pq.Distance(C.add(T.scale(g*f)),m);S<v&&(v=S,b=(this._distances[E+0]+f*g)/this.length())}return b},p.prototype.slice=function(m,v){if(m===void 0&&(m=0),v===void 0&&(v=1),m<0&&(m=1- -1*m%1),v<0&&(v=1- -1*v%1),m>v){var b=m;m=v,v=b}var E=this.getCurve(),C=this.getPointAt(m),T=this.getPreviousPointIndexAt(m),f=this.getPointAt(v),g=this.getPreviousPointIndexAt(v)+1,S=[];return m!==0&&(T++,S.push(C)),S.push.apply(S,E.slice(T,g)),v===1&&m!==1||S.push(f),new p(S,this.getNormalAt(m),this._raw,this._alignTangentsWithPath)},p.prototype.update=function(m,v,b){v===void 0&&(v=null),b===void 0&&(b=!1);for(var E=0;E<m.length;E++)this._curve[E].x=m[E].x,this._curve[E].y=m[E].y,this._curve[E].z=m[E].z;return this._compute(v,b),this},p.prototype._compute=function(m,v){v===void 0&&(v=!1);var b=this._curve.length;if(!(b<2)){this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[b-1]=this._curve[b-1].subtract(this._curve[b-2]),this._raw||this._tangents[b-1].normalize();var E,C,T,f,g,S=this._tangents[0],y=this._normalVector(S,m);this._normals[0]=y,this._raw||this._normals[0].normalize(),this._binormals[0]=o.Pq.Cross(S,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var x=1;x<b;x++)E=this._getLastNonNullVector(x),x<b-1&&(C=this._getFirstNonNullVector(x),this._tangents[x]=v?C:E.add(C),this._tangents[x].normalize()),this._distances[x]=this._distances[x-1]+this._curve[x].subtract(this._curve[x-1]).length(),T=this._tangents[x],g=this._binormals[x-1],this._normals[x]=o.Pq.Cross(g,T),this._raw||(this._normals[x].length()===0?(f=this._normals[x-1],this._normals[x]=f.clone()):this._normals[x].normalize()),this._binormals[x]=o.Pq.Cross(T,this._normals[x]),this._raw||this._binormals[x].normalize();this._pointAtData.id=NaN}},p.prototype._getFirstNonNullVector=function(m){for(var v=1,b=this._curve[m+v].subtract(this._curve[m]);b.length()===0&&m+v+1<this._curve.length;)v++,b=this._curve[m+v].subtract(this._curve[m]);return b},p.prototype._getLastNonNullVector=function(m){for(var v=1,b=this._curve[m].subtract(this._curve[m-v]);b.length()===0&&m>v+1;)v++,b=this._curve[m].subtract(this._curve[m-v]);return b},p.prototype._normalVector=function(m,v){var b,E=m.length();if(E===0&&(E=1),v==null){var C;C=(0,i.WithinEpsilon)(Math.abs(m.y)/E,1,a.bH)?(0,i.WithinEpsilon)(Math.abs(m.x)/E,1,a.bH)?(0,i.WithinEpsilon)(Math.abs(m.z)/E,1,a.bH)?o.Pq.Zero():new o.Pq(0,0,1):new o.Pq(1,0,0):new o.Pq(0,-1,0),b=o.Pq.Cross(m,C)}else b=o.Pq.Cross(m,v),o.Pq.CrossToRef(b,m,b);return b.normalize(),b},p.prototype._updatePointAtData=function(m,v){if(v===void 0&&(v=!1),this._pointAtData.id===m)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=m;var b=this.getPoints();if(m<=0)return this._setPointAtData(0,0,b[0],0,v);if(m>=1)return this._setPointAtData(1,1,b[b.length-1],b.length-1,v);for(var E,C=b[0],T=0,f=m*this.length(),g=1;g<b.length;g++){E=b[g];var S=o.Pq.Distance(C,E);if((T+=S)===f)return this._setPointAtData(m,1,E,g,v);if(T>f){var y=(T-f)/S,x=C.subtract(E),R=E.add(x.scaleInPlace(y));return this._setPointAtData(m,1-y,R,g-1,v)}C=E}return this._pointAtData},p.prototype._setPointAtData=function(m,v,b,E,C){return this._pointAtData.point=b,this._pointAtData.position=m,this._pointAtData.subPosition=v,this._pointAtData.previousPointArrayIndex=E,this._pointAtData.interpolateReady=C,C&&this._updateInterpolationMatrix(),this._pointAtData},p.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=o.uq.Identity();var m=this._pointAtData.previousPointArrayIndex;if(m!==this._tangents.length-1){var v=m+1,b=this._tangents[m].clone(),E=this._normals[m].clone(),C=this._binormals[m].clone(),T=this._tangents[v].clone(),f=this._normals[v].clone(),g=this._binormals[v].clone(),S=o.PT.RotationQuaternionFromAxis(E,C,b),y=o.PT.RotationQuaternionFromAxis(f,g,T);o.PT.Slerp(S,y,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},p}(),h=function(){function p(m){this._length=0,this._points=m,this._length=this._computeLength(m)}return p.CreateQuadraticBezier=function(m,v,b,E){E=E>2?E:3;for(var C=[],T=function(g,S,y,x){return(1-g)*(1-g)*S+2*g*(1-g)*y+g*g*x},f=0;f<=E;f++)C.push(new o.Pq(T(f/E,m.x,v.x,b.x),T(f/E,m.y,v.y,b.y),T(f/E,m.z,v.z,b.z)));return new p(C)},p.CreateCubicBezier=function(m,v,b,E,C){C=C>3?C:4;for(var T=[],f=function(S,y,x,R,I){return(1-S)*(1-S)*(1-S)*y+3*S*(1-S)*(1-S)*x+3*S*S*(1-S)*R+S*S*S*I},g=0;g<=C;g++)T.push(new o.Pq(f(g/C,m.x,v.x,b.x,E.x),f(g/C,m.y,v.y,b.y,E.y),f(g/C,m.z,v.z,b.z,E.z)));return new p(T)},p.CreateHermiteSpline=function(m,v,b,E,C){for(var T=[],f=1/C,g=0;g<=C;g++)T.push(o.Pq.Hermite(m,v,b,E,g*f));return new p(T)},p.CreateCatmullRomSpline=function(m,v,b){var E=[],C=1/v,T=0;if(b){for(var f=m.length,g=0;g<f;g++){T=0;for(var S=0;S<v;S++)E.push(o.Pq.CatmullRom(m[g%f],m[(g+1)%f],m[(g+2)%f],m[(g+3)%f],T)),T+=C}E.push(E[0])}else{var y=[];for(y.push(m[0].clone()),Array.prototype.push.apply(y,m),y.push(m[m.length-1].clone()),g=0;g<y.length-3;g++)for(T=0,S=0;S<v;S++)E.push(o.Pq.CatmullRom(y[g],y[g+1],y[g+2],y[g+3],T)),T+=C;g--,E.push(o.Pq.CatmullRom(y[g],y[g+1],y[g+2],y[g+3],T))}return new p(E)},p.ArcThru3Points=function(m,v,b,E,C,T){E===void 0&&(E=32),C===void 0&&(C=!1),T===void 0&&(T=!1);var f=[],g=v.subtract(m),S=b.subtract(v),y=m.subtract(b),x=o.Pq.Cross(g,S),R=x.length();if(R<Math.pow(10,-8))return new p(f);var I=g.lengthSquared(),M=S.lengthSquared(),D=y.lengthSquared(),B=x.lengthSquared(),F=.5*g.length()*S.length()*y.length()/R,X=-.5*M*o.Pq.Dot(g,y)/B,$=-.5*D*o.Pq.Dot(g,S)/B,Q=-.5*I*o.Pq.Dot(S,y)/B,ie=m.scale(X).add(v.scale($)).add(b.scale(Q)),q=m.subtract(ie).normalize(),ee=o.Pq.Cross(x,q).normalize();if(T){for(var te=2*Math.PI/E,ce=0;ce<=2*Math.PI;ce+=te)f.push(ie.add(q.scale(F*Math.cos(ce)).add(ee.scale(F*Math.sin(ce)))));f.push(m)}else{te=1/E,ce=0;var fe=o.Pq.Zero();do fe=ie.add(q.scale(F*Math.cos(ce)).add(ee.scale(F*Math.sin(ce)))),f.push(fe),ce+=te;while(!fe.equalsWithEpsilon(b,F*te*1.1));f.push(b),C&&f.push(m)}return new p(f)},p.prototype.getPoints=function(){return this._points},p.prototype.length=function(){return this._length},p.prototype.continue=function(m){for(var v=this._points[this._points.length-1],b=this._points.slice(),E=m.getPoints(),C=1;C<E.length;C++)b.push(E[C].subtract(E[0]).add(v));return new p(b)},p.prototype._computeLength=function(m){for(var v=0,b=1;b<m.length;b++)v+=m[b].subtract(m[b-1]).length();return v},p}()},43939:(r,t,e)=>{e.d(t,{Z:()=>i});var n=e(8046),i=function(){function o(a,s,l,c){this.normal=new n.Pq(a,s,l),this.d=c}return o.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},o.prototype.clone=function(){return new o(this.normal.x,this.normal.y,this.normal.z,this.d)},o.prototype.getClassName=function(){return"Plane"},o.prototype.getHashCode=function(){var a=this.normal.getHashCode();return 397*a^this.d},o.prototype.normalize=function(){var a=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),s=0;return a!==0&&(s=1/a),this.normal.x*=s,this.normal.y*=s,this.normal.z*=s,this.d*=s,this},o.prototype.transform=function(a){var s=o._TmpMatrix;a.invertToRef(s);var l=s.m,c=this.normal.x,u=this.normal.y,d=this.normal.z,h=this.d;return new o(c*l[0]+u*l[1]+d*l[2]+h*l[3],c*l[4]+u*l[5]+d*l[6]+h*l[7],c*l[8]+u*l[9]+d*l[10]+h*l[11],c*l[12]+u*l[13]+d*l[14]+h*l[15])},o.prototype.dotCoordinate=function(a){return this.normal.x*a.x+this.normal.y*a.y+this.normal.z*a.z+this.d},o.prototype.copyFromPoints=function(a,s,l){var c,u=s.x-a.x,d=s.y-a.y,h=s.z-a.z,p=l.x-a.x,m=l.y-a.y,v=l.z-a.z,b=d*v-h*m,E=h*p-u*v,C=u*m-d*p,T=Math.sqrt(b*b+E*E+C*C);return c=T!==0?1/T:0,this.normal.x=b*c,this.normal.y=E*c,this.normal.z=C*c,this.d=-(this.normal.x*a.x+this.normal.y*a.y+this.normal.z*a.z),this},o.prototype.isFrontFacingTo=function(a,s){return n.Pq.Dot(this.normal,a)<=s},o.prototype.signedDistanceTo=function(a){return n.Pq.Dot(a,this.normal)+this.d},o.FromArray=function(a){return new o(a[0],a[1],a[2],a[3])},o.FromPoints=function(a,s,l){var c=new o(0,0,0,0);return c.copyFromPoints(a,s,l),c},o.FromPositionAndNormal=function(a,s){var l=new o(0,0,0,0);return this.FromPositionAndNormalToRef(a,s,l)},o.FromPositionAndNormalToRef=function(a,s,l){return l.normal.copyFrom(s),l.normal.normalize(),l.d=-a.dot(l.normal),l},o.SignedDistanceToPlaneFromPositionAndNormal=function(a,s,l){var c=-(s.x*a.x+s.y*a.y+s.z*a.z);return n.Pq.Dot(l,s)+c},o._TmpMatrix=n.uq.Identity(),o}()},48810:(r,t,e)=>{function n(I){return parseInt(I.toString().replace(/\W/g,""))}function i(I,M,D){return D===void 0&&(D=1401298e-51),Math.abs(I-M)<=D}function o(I,M){return I===M?I:Math.random()*(M-I)+I}function a(I,M,D){return I+(M-I)*D}function s(I,M,D){var B=v(M-I,360);return B>180&&(B-=360),I+B*d(D)}function l(I,M,D){return I!=M?d((D-I)/(M-I)):0}function c(I,M,D,B,F){var X=F*F,$=F*X;return I*(2*$-3*X+1)+D*(-2*$+3*X)+M*($-2*X+F)+B*($-X)}function u(I,M,D,B,F){var X=F*F;return 6*(X-F)*I+(3*X-4*F+1)*M+6*(-X+F)*D+(3*X-2*F)*B}function d(I,M,D){return M===void 0&&(M=0),D===void 0&&(D=1),Math.min(D,Math.max(M,I))}function h(I){return I-2*Math.PI*Math.floor((I+Math.PI)/(2*Math.PI))}function p(I){var M=I.toString(16);return I<=15?("0"+M).toUpperCase():M.toUpperCase()}function m(I){if(Math.log2)return Math.floor(Math.log2(I));if(I<0)return NaN;if(I===0)return-1/0;var M=0;if(I<1){for(;I<1;)M++,I*=2;M=-M}else if(I>1)for(;I>1;)M++,I=Math.floor(I/2);return M}function v(I,M){return I-Math.floor(I/M)*M}function b(I,M,D){return(I-M)/(D-M)}function E(I,M,D){return I*(D-M)+M}function C(I,M){var D=v(M-I,360);return D>180&&(D-=360),D}function T(I,M){var D=v(I,2*M);return M-Math.abs(D-M)}function f(I,M,D){var B=d(D);return M*(B=-2*B*B*B+3*B*B)+I*(1-B)}function g(I,M,D){return Math.abs(M-I)<=D?M:I+Math.sign(M-I)*D}function S(I,M,D){var B=C(I,M);return-D<B&&B<D?M:g(I,M=I+B,D)}function y(I,M,D){return(I-M)/(D-M)}function x(I,M,D){return(D-M)*I+M}function R(I,M){var D=I%M;return D===0?M:R(M,D)}e.r(t),e.d(t,{Clamp:()=>d,DeltaAngle:()=>C,Denormalize:()=>E,ExtractAsInt:()=>n,Hermite:()=>c,Hermite1stDerivative:()=>u,HighestCommonFactor:()=>R,ILog2:()=>m,InverseLerp:()=>l,Lerp:()=>a,LerpAngle:()=>s,MoveTowards:()=>g,MoveTowardsAngle:()=>S,Normalize:()=>b,NormalizeRadians:()=>h,PercentToRange:()=>x,PingPong:()=>T,RandomRange:()=>o,RangeToPercent:()=>y,Repeat:()=>v,SmoothStep:()=>f,ToHex:()=>p,WithinEpsilon:()=>i})},73152:(r,t,e)=>{e.d(t,{o:()=>n});var n=function(){function i(o,a){this.width=o,this.height=a}return i.prototype.toString=function(){return"{W: ".concat(this.width,", H: ").concat(this.height,"}")},i.prototype.getClassName=function(){return"Size"},i.prototype.getHashCode=function(){var o=0|this.width;return 397*o^this.height},i.prototype.copyFrom=function(o){this.width=o.width,this.height=o.height},i.prototype.copyFromFloats=function(o,a){return this.width=o,this.height=a,this},i.prototype.set=function(o,a){return this.copyFromFloats(o,a)},i.prototype.multiplyByFloats=function(o,a){return new i(this.width*o,this.height*a)},i.prototype.clone=function(){return new i(this.width,this.height)},i.prototype.equals=function(o){return!!o&&this.width===o.width&&this.height===o.height},Object.defineProperty(i.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!1,configurable:!0}),i.Zero=function(){return new i(0,0)},i.prototype.add=function(o){return new i(this.width+o.width,this.height+o.height)},i.prototype.subtract=function(o){return new i(this.width-o.width,this.height-o.height)},i.prototype.scale=function(o){return new i(this.width*o,this.height*o)},i.Lerp=function(o,a,s){return new i(o.width+(a.width-o.width)*s,o.height+(a.height-o.height)*s)},i}()},51322:(r,t,e)=>{e.d(t,{uM:()=>s.uM,Xy:()=>s.Xy,_0:()=>n._0,vr:()=>s.vr,v9:()=>i.v9,ov:()=>i.ov,xp:()=>n.xp,jj:()=>s.jj,bH:()=>o.bH,PP:()=>a.P,uq:()=>u.uq,t4:()=>s.t4,a6:()=>o.a6,Cu:()=>s.Cu,tO:()=>s.tO,Zc:()=>l.Z,k0:()=>h,B5:()=>d,PT:()=>u.PT,or:()=>c.o,$x:()=>n.$x,IG:()=>i.IG,AA:()=>u.AA,rv:()=>o.rv,tk:()=>o.tk,I9:()=>u.I9,Pq:()=>u.Pq,IU:()=>u.IU,LM:()=>p.L});var n=e(13424),i=e(64726),o=e(56740),a=e(36359),s=e(95318),l=e(43939),c=e(73152),u=e(8046),d=function(){function m(v,b){v===void 0&&(v=u.Pq.Zero()),b===void 0&&(b=u.Pq.Up()),this.position=v,this.normal=b}return m.prototype.clone=function(){return new m(this.position.clone(),this.normal.clone())},m}(),h=function(){function m(v,b,E){v===void 0&&(v=u.Pq.Zero()),b===void 0&&(b=u.Pq.Up()),E===void 0&&(E=u.I9.Zero()),this.position=v,this.normal=b,this.uv=E}return m.prototype.clone=function(){return new m(this.position.clone(),this.normal.clone(),this.uv.clone())},m}(),p=e(25187)},8046:(r,t,e)=>{e.d(t,{AA:()=>E,I9:()=>d,IU:()=>p,PT:()=>m,Pq:()=>h,uq:()=>v});var n=e(78322),i=e(56740),o=e(11296),a=e(34623),s=e(16106),l=e(66614),c=e(48810),u=function(T){return parseInt(T.toString().replace(/\W/g,""))},d=function(){function T(f,g){f===void 0&&(f=0),g===void 0&&(g=0),this.x=f,this.y=g}return T.prototype.toString=function(){return"{X: ".concat(this.x," Y: ").concat(this.y,"}")},T.prototype.getClassName=function(){return"Vector2"},T.prototype.getHashCode=function(){var f=u(this.x);return 397*f^u(this.y)},T.prototype.toArray=function(f,g){return g===void 0&&(g=0),f[g]=this.x,f[g+1]=this.y,this},T.prototype.fromArray=function(f,g){return g===void 0&&(g=0),T.FromArrayToRef(f,g,this),this},T.prototype.asArray=function(){return[this.x,this.y]},T.prototype.copyFrom=function(f){return this.x=f.x,this.y=f.y,this},T.prototype.copyFromFloats=function(f,g){return this.x=f,this.y=g,this},T.prototype.set=function(f,g){return this.copyFromFloats(f,g)},T.prototype.setAll=function(f){return this.copyFromFloats(f,f)},T.prototype.add=function(f){return new T(this.x+f.x,this.y+f.y)},T.prototype.addToRef=function(f,g){return g.x=this.x+f.x,g.y=this.y+f.y,g},T.prototype.addInPlace=function(f){return this.x+=f.x,this.y+=f.y,this},T.prototype.addInPlaceFromFloats=function(f,g){return this.x+=f,this.y+=g,this},T.prototype.addVector3=function(f){return new T(this.x+f.x,this.y+f.y)},T.prototype.subtract=function(f){return new T(this.x-f.x,this.y-f.y)},T.prototype.subtractToRef=function(f,g){return g.x=this.x-f.x,g.y=this.y-f.y,g},T.prototype.subtractInPlace=function(f){return this.x-=f.x,this.y-=f.y,this},T.prototype.multiplyInPlace=function(f){return this.x*=f.x,this.y*=f.y,this},T.prototype.multiply=function(f){return new T(this.x*f.x,this.y*f.y)},T.prototype.multiplyToRef=function(f,g){return g.x=this.x*f.x,g.y=this.y*f.y,g},T.prototype.multiplyByFloats=function(f,g){return new T(this.x*f,this.y*g)},T.prototype.divide=function(f){return new T(this.x/f.x,this.y/f.y)},T.prototype.divideToRef=function(f,g){return g.x=this.x/f.x,g.y=this.y/f.y,g},T.prototype.divideInPlace=function(f){return this.x=this.x/f.x,this.y=this.y/f.y,this},T.prototype.minimizeInPlace=function(f){return this.minimizeInPlaceFromFloats(f.x,f.y)},T.prototype.maximizeInPlace=function(f){return this.maximizeInPlaceFromFloats(f.x,f.y)},T.prototype.minimizeInPlaceFromFloats=function(f,g){return this.x=Math.min(f,this.x),this.y=Math.min(g,this.y),this},T.prototype.maximizeInPlaceFromFloats=function(f,g){return this.x=Math.max(f,this.x),this.y=Math.max(g,this.y),this},T.prototype.subtractFromFloats=function(f,g){return new T(this.x-f,this.y-g)},T.prototype.subtractFromFloatsToRef=function(f,g,S){return S.x=this.x-f,S.y=this.y-g,S},T.prototype.negate=function(){return new T(-this.x,-this.y)},T.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this},T.prototype.negateToRef=function(f){return f.x=-this.x,f.y=-this.y,f},T.prototype.scaleInPlace=function(f){return this.x*=f,this.y*=f,this},T.prototype.scale=function(f){return new T(this.x*f,this.y*f)},T.prototype.scaleToRef=function(f,g){return g.x=this.x*f,g.y=this.y*f,g},T.prototype.scaleAndAddToRef=function(f,g){return g.x+=this.x*f,g.y+=this.y*f,g},T.prototype.equals=function(f){return f&&this.x===f.x&&this.y===f.y},T.prototype.equalsWithEpsilon=function(f,g){return g===void 0&&(g=i.bH),f&&(0,c.WithinEpsilon)(this.x,f.x,g)&&(0,c.WithinEpsilon)(this.y,f.y,g)},T.prototype.equalsToFloats=function(f,g){return this.x===f&&this.y===g},T.prototype.floor=function(){return new T(Math.floor(this.x),Math.floor(this.y))},T.prototype.floorToRef=function(f){return f.x=Math.floor(this.x),f.y=Math.floor(this.y),f},T.prototype.fract=function(){return new T(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},T.prototype.fractToRef=function(f){return f.x=this.x-Math.floor(this.x),f.y=this.y-Math.floor(this.y),f},T.prototype.rotateToRef=function(f,g){var S=Math.cos(f),y=Math.sin(f),x=S*this.x-y*this.y,R=y*this.x+S*this.y;return g.x=x,g.y=R,g},T.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},T.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},T.prototype.normalize=function(){return this.normalizeFromLength(this.length())},T.prototype.normalizeFromLength=function(f){return f===0||f===1?this:this.scaleInPlace(1/f)},T.prototype.normalizeToNew=function(){var f=new T;return this.normalizeToRef(f),f},T.prototype.normalizeToRef=function(f){var g=this.length();return g===0&&(f.x=this.x,f.y=this.y),this.scaleToRef(1/g,f)},T.prototype.clone=function(){return new T(this.x,this.y)},T.prototype.dot=function(f){return this.x*f.x+this.y*f.y},T.Zero=function(){return new T(0,0)},T.One=function(){return new T(1,1)},T.Random=function(f,g){return f===void 0&&(f=0),g===void 0&&(g=1),new T((0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g))},T.RandomToRef=function(f,g,S){return f===void 0&&(f=0),g===void 0&&(g=1),S.copyFromFloats((0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g))},Object.defineProperty(T,"ZeroReadOnly",{get:function(){return T._ZeroReadOnly},enumerable:!1,configurable:!0}),T.FromArray=function(f,g){return g===void 0&&(g=0),new T(f[g],f[g+1])},T.FromArrayToRef=function(f,g,S){return S.x=f[g],S.y=f[g+1],S},T.FromFloatsToRef=function(f,g,S){return S.copyFromFloats(f,g),S},T.CatmullRom=function(f,g,S,y,x){var R=x*x,I=x*R;return new T(.5*(2*g.x+(-f.x+S.x)*x+(2*f.x-5*g.x+4*S.x-y.x)*R+(-f.x+3*g.x-3*S.x+y.x)*I),.5*(2*g.y+(-f.y+S.y)*x+(2*f.y-5*g.y+4*S.y-y.y)*R+(-f.y+3*g.y-3*S.y+y.y)*I))},T.ClampToRef=function(f,g,S,y){return y.x=(0,c.Clamp)(f.x,g.x,S.x),y.y=(0,c.Clamp)(f.y,g.y,S.y),y},T.Clamp=function(f,g,S){return new T((0,c.Clamp)(f.x,g.x,S.x),(0,c.Clamp)(f.y,g.y,S.y))},T.Hermite=function(f,g,S,y,x){var R=x*x,I=x*R,M=2*I-3*R+1,D=-2*I+3*R,B=I-2*R+x,F=I-R;return new T(f.x*M+S.x*D+g.x*B+y.x*F,f.y*M+S.y*D+g.y*B+y.y*F)},T.Hermite1stDerivative=function(f,g,S,y,x){return this.Hermite1stDerivativeToRef(f,g,S,y,x,new T)},T.Hermite1stDerivativeToRef=function(f,g,S,y,x,R){var I=x*x;return R.x=6*(I-x)*f.x+(3*I-4*x+1)*g.x+6*(-I+x)*S.x+(3*I-2*x)*y.x,R.y=6*(I-x)*f.y+(3*I-4*x+1)*g.y+6*(-I+x)*S.y+(3*I-2*x)*y.y,R},T.Lerp=function(f,g,S){return T.LerpToRef(f,g,S,new T)},T.LerpToRef=function(f,g,S,y){return y.x=f.x+(g.x-f.x)*S,y.y=f.y+(g.y-f.y)*S,y},T.Dot=function(f,g){return f.x*g.x+f.y*g.y},T.Normalize=function(f){return T.NormalizeToRef(f,new T)},T.NormalizeToRef=function(f,g){return f.normalizeToRef(g),g},T.Minimize=function(f,g){return new T(f.x<g.x?f.x:g.x,f.y<g.y?f.y:g.y)},T.Maximize=function(f,g){return new T(f.x>g.x?f.x:g.x,f.y>g.y?f.y:g.y)},T.Transform=function(f,g){return T.TransformToRef(f,g,new T)},T.TransformToRef=function(f,g,S){var y=g.m,x=f.x*y[0]+f.y*y[4]+y[12],R=f.x*y[1]+f.y*y[5]+y[13];return S.x=x,S.y=R,S},T.PointInTriangle=function(f,g,S,y){var x=.5*(-S.y*y.x+g.y*(-S.x+y.x)+g.x*(S.y-y.y)+S.x*y.y),R=x<0?-1:1,I=(g.y*y.x-g.x*y.y+(y.y-g.y)*f.x+(g.x-y.x)*f.y)*R,M=(g.x*S.y-g.y*S.x+(g.y-S.y)*f.x+(S.x-g.x)*f.y)*R;return I>0&&M>0&&I+M<2*x*R},T.Distance=function(f,g){return Math.sqrt(T.DistanceSquared(f,g))},T.DistanceSquared=function(f,g){var S=f.x-g.x,y=f.y-g.y;return S*S+y*y},T.Center=function(f,g){return T.CenterToRef(f,g,new T)},T.CenterToRef=function(f,g,S){return S.copyFromFloats((f.x+g.x)/2,(f.y+g.y)/2)},T.DistanceOfPointFromSegment=function(f,g,S){var y=T.DistanceSquared(g,S);if(y===0)return T.Distance(f,g);var x=S.subtract(g),R=Math.max(0,Math.min(1,T.Dot(f.subtract(g),x)/y)),I=g.add(x.multiplyByFloats(R,R));return T.Distance(f,I)},T._ZeroReadOnly=T.Zero(),T}();Object.defineProperties(d.prototype,{dimension:{value:[2]},rank:{value:1}});var h=function(){function T(f,g,S){f===void 0&&(f=0),g===void 0&&(g=0),S===void 0&&(S=0),this._isDirty=!0,this._x=f,this._y=g,this._z=S}return Object.defineProperty(T.prototype,"x",{get:function(){return this._x},set:function(f){this._x=f,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"y",{get:function(){return this._y},set:function(f){this._y=f,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"z",{get:function(){return this._z},set:function(f){this._z=f,this._isDirty=!0},enumerable:!1,configurable:!0}),T.prototype.toString=function(){return"{X: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(this._z,"}")},T.prototype.getClassName=function(){return"Vector3"},T.prototype.getHashCode=function(){var f=u(this._x);return 397*(f=397*f^u(this._y))^u(this._z)},T.prototype.asArray=function(){return[this._x,this._y,this._z]},T.prototype.toArray=function(f,g){return g===void 0&&(g=0),f[g]=this._x,f[g+1]=this._y,f[g+2]=this._z,this},T.prototype.fromArray=function(f,g){return g===void 0&&(g=0),T.FromArrayToRef(f,g,this),this},T.prototype.toQuaternion=function(){return m.RotationYawPitchRoll(this._y,this._x,this._z)},T.prototype.addInPlace=function(f){return this._x+=f._x,this._y+=f._y,this._z+=f._z,this._isDirty=!0,this},T.prototype.addInPlaceFromFloats=function(f,g,S){return this._x+=f,this._y+=g,this._z+=S,this._isDirty=!0,this},T.prototype.add=function(f){return new T(this._x+f._x,this._y+f._y,this._z+f._z)},T.prototype.addToRef=function(f,g){return g._x=this._x+f._x,g._y=this._y+f._y,g._z=this._z+f._z,g._isDirty=!0,g},T.prototype.subtractInPlace=function(f){return this._x-=f._x,this._y-=f._y,this._z-=f._z,this._isDirty=!0,this},T.prototype.subtract=function(f){return new T(this._x-f._x,this._y-f._y,this._z-f._z)},T.prototype.subtractToRef=function(f,g){return this.subtractFromFloatsToRef(f._x,f._y,f._z,g)},T.prototype.subtractFromFloats=function(f,g,S){return new T(this._x-f,this._y-g,this._z-S)},T.prototype.subtractFromFloatsToRef=function(f,g,S,y){return y._x=this._x-f,y._y=this._y-g,y._z=this._z-S,y._isDirty=!0,y},T.prototype.negate=function(){return new T(-this._x,-this._y,-this._z)},T.prototype.negateInPlace=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this},T.prototype.negateToRef=function(f){return f._x=-1*this._x,f._y=-1*this._y,f._z=-1*this._z,f._isDirty=!0,f},T.prototype.scaleInPlace=function(f){return this._x*=f,this._y*=f,this._z*=f,this._isDirty=!0,this},T.prototype.scale=function(f){return new T(this._x*f,this._y*f,this._z*f)},T.prototype.scaleToRef=function(f,g){return g._x=this._x*f,g._y=this._y*f,g._z=this._z*f,g._isDirty=!0,g},T.prototype.getNormalToRef=function(f){var g=this.length(),S=Math.acos(this.y/g),y=Math.atan2(this.z,this.x);S>Math.PI/2?S-=Math.PI/2:S+=Math.PI/2;var x=g*Math.sin(S)*Math.cos(y),R=g*Math.cos(S),I=g*Math.sin(S)*Math.sin(y);return f.set(x,R,I),f},T.prototype.applyRotationQuaternionToRef=function(f,g){var S=this._x,y=this._y,x=this._z,R=f._x,I=f._y,M=f._z,D=f._w,B=2*(I*x-M*y),F=2*(M*S-R*x),X=2*(R*y-I*S);return g._x=S+D*B+I*X-M*F,g._y=y+D*F+M*B-R*X,g._z=x+D*X+R*F-I*B,g._isDirty=!0,g},T.prototype.applyRotationQuaternionInPlace=function(f){return this.applyRotationQuaternionToRef(f,this)},T.prototype.applyRotationQuaternion=function(f){return this.applyRotationQuaternionToRef(f,new T)},T.prototype.scaleAndAddToRef=function(f,g){return g._x+=this._x*f,g._y+=this._y*f,g._z+=this._z*f,g._isDirty=!0,g},T.prototype.projectOnPlane=function(f,g){return this.projectOnPlaneToRef(f,g,new T)},T.prototype.projectOnPlaneToRef=function(f,g,S){var y=f.normal,x=f.d,R=b.Vector3[0];this.subtractToRef(g,R),R.normalize();var I=T.Dot(R,y);if(Math.abs(I)<1e-10)S.setAll(1/0);else{var M=-(T.Dot(g,y)+x)/I,D=R.scaleInPlace(M);g.addToRef(D,S)}return S},T.prototype.equals=function(f){return f&&this._x===f._x&&this._y===f._y&&this._z===f._z},T.prototype.equalsWithEpsilon=function(f,g){return g===void 0&&(g=i.bH),f&&(0,c.WithinEpsilon)(this._x,f._x,g)&&(0,c.WithinEpsilon)(this._y,f._y,g)&&(0,c.WithinEpsilon)(this._z,f._z,g)},T.prototype.equalsToFloats=function(f,g,S){return this._x===f&&this._y===g&&this._z===S},T.prototype.multiplyInPlace=function(f){return this._x*=f._x,this._y*=f._y,this._z*=f._z,this._isDirty=!0,this},T.prototype.multiply=function(f){return this.multiplyByFloats(f._x,f._y,f._z)},T.prototype.multiplyToRef=function(f,g){return g._x=this._x*f._x,g._y=this._y*f._y,g._z=this._z*f._z,g._isDirty=!0,g},T.prototype.multiplyByFloats=function(f,g,S){return new T(this._x*f,this._y*g,this._z*S)},T.prototype.divide=function(f){return new T(this._x/f._x,this._y/f._y,this._z/f._z)},T.prototype.divideToRef=function(f,g){return g._x=this._x/f._x,g._y=this._y/f._y,g._z=this._z/f._z,g._isDirty=!0,g},T.prototype.divideInPlace=function(f){return this._x=this._x/f._x,this._y=this._y/f._y,this._z=this._z/f._z,this._isDirty=!0,this},T.prototype.minimizeInPlace=function(f){return this.minimizeInPlaceFromFloats(f._x,f._y,f._z)},T.prototype.maximizeInPlace=function(f){return this.maximizeInPlaceFromFloats(f._x,f._y,f._z)},T.prototype.minimizeInPlaceFromFloats=function(f,g,S){return f<this._x&&(this.x=f),g<this._y&&(this.y=g),S<this._z&&(this.z=S),this},T.prototype.maximizeInPlaceFromFloats=function(f,g,S){return f>this._x&&(this.x=f),g>this._y&&(this.y=g),S>this._z&&(this.z=S),this},T.prototype.isNonUniformWithinEpsilon=function(f){var g=Math.abs(this._x),S=Math.abs(this._y);if(!(0,c.WithinEpsilon)(g,S,f))return!0;var y=Math.abs(this._z);return!(0,c.WithinEpsilon)(g,y,f)||!(0,c.WithinEpsilon)(S,y,f)},Object.defineProperty(T.prototype,"isNonUniform",{get:function(){var f=Math.abs(this._x);return f!==Math.abs(this._y)||f!==Math.abs(this._z)},enumerable:!1,configurable:!0}),T.prototype.floorToRef=function(f){return f._x=Math.floor(this._x),f._y=Math.floor(this._y),f._z=Math.floor(this._z),f._isDirty=!0,f},T.prototype.floor=function(){return new T(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},T.prototype.fractToRef=function(f){return f._x=this.x-Math.floor(this._x),f._y=this.y-Math.floor(this._y),f._z=this.z-Math.floor(this._z),f._isDirty=!0,f},T.prototype.fract=function(){return new T(this.x-Math.floor(this._x),this.y-Math.floor(this._y),this.z-Math.floor(this._z))},T.prototype.length=function(){return Math.sqrt(this.lengthSquared())},T.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z},Object.defineProperty(T.prototype,"hasAZeroComponent",{get:function(){return this._x*this._y*this._z==0},enumerable:!1,configurable:!0}),T.prototype.normalize=function(){return this.normalizeFromLength(this.length())},T.prototype.reorderInPlace=function(f){if((f=f.toLowerCase())==="xyz")return this;var g=b.Vector3[0].copyFrom(this);return this.x=g[f[0]],this.y=g[f[1]],this.z=g[f[2]],this},T.prototype.rotateByQuaternionToRef=function(f,g){return f.toRotationMatrix(b.Matrix[0]),T.TransformCoordinatesToRef(this,b.Matrix[0],g),g},T.prototype.rotateByQuaternionAroundPointToRef=function(f,g,S){return this.subtractToRef(g,b.Vector3[0]),b.Vector3[0].rotateByQuaternionToRef(f,b.Vector3[0]),g.addToRef(b.Vector3[0],S),S},T.prototype.cross=function(f){return T.CrossToRef(this,f,new T)},T.prototype.normalizeFromLength=function(f){return f===0||f===1?this:this.scaleInPlace(1/f)},T.prototype.normalizeToNew=function(){return this.normalizeToRef(new T)},T.prototype.normalizeToRef=function(f){var g=this.length();return g===0||g===1?(f._x=this._x,f._y=this._y,f._z=this._z,f._isDirty=!0,f):this.scaleToRef(1/g,f)},T.prototype.clone=function(){return new T(this._x,this._y,this._z)},T.prototype.copyFrom=function(f){return this.copyFromFloats(f._x,f._y,f._z)},T.prototype.copyFromFloats=function(f,g,S){return this._x=f,this._y=g,this._z=S,this._isDirty=!0,this},T.prototype.set=function(f,g,S){return this.copyFromFloats(f,g,S)},T.prototype.setAll=function(f){return this._x=this._y=this._z=f,this._isDirty=!0,this},T.GetClipFactor=function(f,g,S,y){var x=T.Dot(f,S);return(x-y)/(x-T.Dot(g,S))},T.GetAngleBetweenVectors=function(f,g,S){var y=f.normalizeToRef(b.Vector3[1]),x=g.normalizeToRef(b.Vector3[2]),R=T.Dot(y,x);R=(0,c.Clamp)(R,-1,1);var I=Math.acos(R),M=b.Vector3[3];return T.CrossToRef(y,x,M),T.Dot(M,S)>0?isNaN(I)?0:I:isNaN(I)?-Math.PI:-Math.acos(R)},T.GetAngleBetweenVectorsOnPlane=function(f,g,S){b.Vector3[0].copyFrom(f);var y=b.Vector3[0];b.Vector3[1].copyFrom(g);var x=b.Vector3[1];b.Vector3[2].copyFrom(S);var R=b.Vector3[2],I=b.Vector3[3],M=b.Vector3[4];y.normalize(),x.normalize(),R.normalize(),T.CrossToRef(R,y,I),T.CrossToRef(I,R,M);var D=Math.atan2(T.Dot(x,I),T.Dot(x,M));return(0,c.NormalizeRadians)(D)},T.PitchYawRollToMoveBetweenPointsToRef=function(f,g,S){var y=E.Vector3[0];return g.subtractToRef(f,y),S._y=Math.atan2(y.x,y.z)||0,S._x=Math.atan2(Math.sqrt(Math.pow(y.x,2)+Math.pow(y.z,2)),y.y)||0,S._z=0,S._isDirty=!0,S},T.PitchYawRollToMoveBetweenPoints=function(f,g){var S=T.Zero();return T.PitchYawRollToMoveBetweenPointsToRef(f,g,S)},T.SlerpToRef=function(f,g,S,y){S=(0,c.Clamp)(S,0,1);var x=b.Vector3[0],R=b.Vector3[1];x.copyFrom(f);var I=x.length();x.normalizeFromLength(I),R.copyFrom(g);var M=R.length();R.normalizeFromLength(M);var D,B,F=T.Dot(x,R);if(F<1-i.bH){var X=Math.acos(F),$=1/Math.sin(X);D=Math.sin((1-S)*X)*$,B=Math.sin(S*X)*$}else D=1-S,B=S;return x.scaleInPlace(D),R.scaleInPlace(B),y.copyFrom(x).addInPlace(R),y.scaleInPlace((0,c.Lerp)(I,M,S)),y},T.SmoothToRef=function(f,g,S,y,x){return T.SlerpToRef(f,g,y===0?1:S/y,x),x},T.FromArray=function(f,g){return g===void 0&&(g=0),new T(f[g],f[g+1],f[g+2])},T.FromFloatArray=function(f,g){return T.FromArray(f,g)},T.FromArrayToRef=function(f,g,S){return S._x=f[g],S._y=f[g+1],S._z=f[g+2],S._isDirty=!0,S},T.FromFloatArrayToRef=function(f,g,S){return T.FromArrayToRef(f,g,S)},T.FromFloatsToRef=function(f,g,S,y){return y.copyFromFloats(f,g,S),y},T.Zero=function(){return new T(0,0,0)},T.One=function(){return new T(1,1,1)},T.Up=function(){return new T(0,1,0)},Object.defineProperty(T,"UpReadOnly",{get:function(){return T._UpReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"DownReadOnly",{get:function(){return T._DownReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"RightReadOnly",{get:function(){return T._RightReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"LeftReadOnly",{get:function(){return T._LeftReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"LeftHandedForwardReadOnly",{get:function(){return T._LeftHandedForwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"RightHandedForwardReadOnly",{get:function(){return T._RightHandedForwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"LeftHandedBackwardReadOnly",{get:function(){return T._LeftHandedBackwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"RightHandedBackwardReadOnly",{get:function(){return T._RightHandedBackwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"ZeroReadOnly",{get:function(){return T._ZeroReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(T,"OneReadOnly",{get:function(){return T._OneReadOnly},enumerable:!1,configurable:!0}),T.Down=function(){return new T(0,-1,0)},T.Forward=function(f){return f===void 0&&(f=!1),new T(0,0,f?-1:1)},T.Backward=function(f){return f===void 0&&(f=!1),new T(0,0,f?1:-1)},T.Right=function(){return new T(1,0,0)},T.Left=function(){return new T(-1,0,0)},T.Random=function(f,g){return f===void 0&&(f=0),g===void 0&&(g=1),new T((0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g))},T.RandomToRef=function(f,g,S){return f===void 0&&(f=0),g===void 0&&(g=1),S.copyFromFloats((0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g))},T.TransformCoordinates=function(f,g){var S=T.Zero();return T.TransformCoordinatesToRef(f,g,S),S},T.TransformCoordinatesToRef=function(f,g,S){return T.TransformCoordinatesFromFloatsToRef(f._x,f._y,f._z,g,S),S},T.TransformCoordinatesFromFloatsToRef=function(f,g,S,y,x){var R=y.m,I=f*R[0]+g*R[4]+S*R[8]+R[12],M=f*R[1]+g*R[5]+S*R[9]+R[13],D=f*R[2]+g*R[6]+S*R[10]+R[14],B=1/(f*R[3]+g*R[7]+S*R[11]+R[15]);return x._x=I*B,x._y=M*B,x._z=D*B,x._isDirty=!0,x},T.TransformNormal=function(f,g){var S=T.Zero();return T.TransformNormalToRef(f,g,S),S},T.TransformNormalToRef=function(f,g,S){return this.TransformNormalFromFloatsToRef(f._x,f._y,f._z,g,S),S},T.TransformNormalFromFloatsToRef=function(f,g,S,y,x){var R=y.m;return x._x=f*R[0]+g*R[4]+S*R[8],x._y=f*R[1]+g*R[5]+S*R[9],x._z=f*R[2]+g*R[6]+S*R[10],x._isDirty=!0,x},T.CatmullRom=function(f,g,S,y,x){var R=x*x,I=x*R;return new T(.5*(2*g._x+(-f._x+S._x)*x+(2*f._x-5*g._x+4*S._x-y._x)*R+(-f._x+3*g._x-3*S._x+y._x)*I),.5*(2*g._y+(-f._y+S._y)*x+(2*f._y-5*g._y+4*S._y-y._y)*R+(-f._y+3*g._y-3*S._y+y._y)*I),.5*(2*g._z+(-f._z+S._z)*x+(2*f._z-5*g._z+4*S._z-y._z)*R+(-f._z+3*g._z-3*S._z+y._z)*I))},T.Clamp=function(f,g,S){var y=new T;return T.ClampToRef(f,g,S,y),y},T.ClampToRef=function(f,g,S,y){var x=f._x;x=(x=x>S._x?S._x:x)<g._x?g._x:x;var R=f._y;R=(R=R>S._y?S._y:R)<g._y?g._y:R;var I=f._z;return I=(I=I>S._z?S._z:I)<g._z?g._z:I,y.copyFromFloats(x,R,I),y},T.CheckExtends=function(f,g,S){g.minimizeInPlace(f),S.maximizeInPlace(f)},T.Hermite=function(f,g,S,y,x){var R=x*x,I=x*R,M=2*I-3*R+1,D=-2*I+3*R,B=I-2*R+x,F=I-R;return new T(f._x*M+S._x*D+g._x*B+y._x*F,f._y*M+S._y*D+g._y*B+y._y*F,f._z*M+S._z*D+g._z*B+y._z*F)},T.Hermite1stDerivative=function(f,g,S,y,x){var R=new T;return this.Hermite1stDerivativeToRef(f,g,S,y,x,R),R},T.Hermite1stDerivativeToRef=function(f,g,S,y,x,R){var I=x*x;return R._x=6*(I-x)*f._x+(3*I-4*x+1)*g._x+6*(-I+x)*S._x+(3*I-2*x)*y._x,R._y=6*(I-x)*f._y+(3*I-4*x+1)*g._y+6*(-I+x)*S._y+(3*I-2*x)*y._y,R._z=6*(I-x)*f._z+(3*I-4*x+1)*g._z+6*(-I+x)*S._z+(3*I-2*x)*y._z,R._isDirty=!0,R},T.Lerp=function(f,g,S){var y=new T(0,0,0);return T.LerpToRef(f,g,S,y),y},T.LerpToRef=function(f,g,S,y){return y._x=f._x+(g._x-f._x)*S,y._y=f._y+(g._y-f._y)*S,y._z=f._z+(g._z-f._z)*S,y._isDirty=!0,y},T.Dot=function(f,g){return f._x*g._x+f._y*g._y+f._z*g._z},T.prototype.dot=function(f){return this._x*f._x+this._y*f._y+this._z*f._z},T.Cross=function(f,g){var S=new T;return T.CrossToRef(f,g,S),S},T.CrossToRef=function(f,g,S){var y=f._y*g._z-f._z*g._y,x=f._z*g._x-f._x*g._z,R=f._x*g._y-f._y*g._x;return S.copyFromFloats(y,x,R),S},T.Normalize=function(f){var g=T.Zero();return T.NormalizeToRef(f,g),g},T.NormalizeToRef=function(f,g){return f.normalizeToRef(g),g},T.Project=function(f,g,S,y){var x=new T;return T.ProjectToRef(f,g,S,y,x),x},T.ProjectToRef=function(f,g,S,y,x){var R,I=y.width,M=y.height,D=y.x,B=y.y,F=b.Matrix[1],X=(R=l.q.LastCreatedEngine)===null||R===void 0?void 0:R.isNDCHalfZRange,$=X?1:.5,Q=X?0:.5;v.FromValuesToRef(I/2,0,0,0,0,-M/2,0,0,0,0,$,0,D+I/2,M/2+B,Q,1,F);var ie=b.Matrix[0];return g.multiplyToRef(S,ie),ie.multiplyToRef(F,ie),T.TransformCoordinatesToRef(f,ie,x),x},T.Reflect=function(f,g){return this.ReflectToRef(f,g,new T)},T.ReflectToRef=function(f,g,S){var y=E.Vector3[0];return y.copyFrom(g).scaleInPlace(2*T.Dot(f,g)),S.copyFrom(f).subtractInPlace(y)},T._UnprojectFromInvertedMatrixToRef=function(f,g,S){T.TransformCoordinatesToRef(f,g,S);var y=g.m,x=f._x*y[3]+f._y*y[7]+f._z*y[11]+y[15];return(0,c.WithinEpsilon)(x,1)&&S.scaleInPlace(1/x),S},T.UnprojectFromTransform=function(f,g,S,y,x){return this.Unproject(f,g,S,y,x,v.IdentityReadOnly)},T.Unproject=function(f,g,S,y,x,R){var I=new T;return T.UnprojectToRef(f,g,S,y,x,R,I),I},T.UnprojectToRef=function(f,g,S,y,x,R,I){return T.UnprojectFloatsToRef(f._x,f._y,f._z,g,S,y,x,R,I),I},T.UnprojectFloatsToRef=function(f,g,S,y,x,R,I,M,D){var B,F=b.Matrix[0];R.multiplyToRef(I,F),F.multiplyToRef(M,F),F.invert();var X=b.Vector3[0];return X.x=f/y*2-1,X.y=-(g/x*2-1),!((B=l.q.LastCreatedEngine)===null||B===void 0)&&B.isNDCHalfZRange?X.z=S:X.z=2*S-1,T._UnprojectFromInvertedMatrixToRef(X,F,D),D},T.Minimize=function(f,g){var S=new T;return S.copyFrom(f),S.minimizeInPlace(g),S},T.Maximize=function(f,g){var S=new T;return S.copyFrom(f),S.maximizeInPlace(g),S},T.Distance=function(f,g){return Math.sqrt(T.DistanceSquared(f,g))},T.DistanceSquared=function(f,g){var S=f._x-g._x,y=f._y-g._y,x=f._z-g._z;return S*S+y*y+x*x},T.ProjectOnTriangleToRef=function(f,g,S,y,x){var R=b.Vector3[0],I=b.Vector3[1],M=b.Vector3[2],D=b.Vector3[3],B=b.Vector3[4];S.subtractToRef(g,R),y.subtractToRef(g,I),y.subtractToRef(S,M);var F=R.length(),X=I.length(),$=M.length();if(F<i.bH||X<i.bH||$<i.bH)return x.copyFrom(g),T.Distance(f,g);f.subtractToRef(g,B),T.CrossToRef(R,I,D);var Q=D.length();if(Q<i.bH)return x.copyFrom(g),T.Distance(f,g);D.normalizeFromLength(Q);var ie=B.length();if(ie<i.bH)return x.copyFrom(g),0;B.normalizeFromLength(ie);var q=T.Dot(D,B),ee=b.Vector3[5],te=b.Vector3[6];ee.copyFrom(D).scaleInPlace(-ie*q),te.copyFrom(f).addInPlace(ee);var ce=b.Vector3[4],fe=b.Vector3[5],de=b.Vector3[7],Te=b.Vector3[8];ce.copyFrom(R).scaleInPlace(1/F),Te.copyFrom(I).scaleInPlace(1/X),ce.addInPlace(Te).scaleInPlace(-1),fe.copyFrom(R).scaleInPlace(-1/F),Te.copyFrom(M).scaleInPlace(1/$),fe.addInPlace(Te).scaleInPlace(-1),de.copyFrom(M).scaleInPlace(-1/$),Te.copyFrom(I).scaleInPlace(-1/X),de.addInPlace(Te).scaleInPlace(-1);var ue=b.Vector3[9];ue.copyFrom(te).subtractInPlace(g),T.CrossToRef(ce,ue,Te);var U=T.Dot(Te,D);ue.copyFrom(te).subtractInPlace(S),T.CrossToRef(fe,ue,Te);var N=T.Dot(Te,D);ue.copyFrom(te).subtractInPlace(y),T.CrossToRef(de,ue,Te);var w,k,J=T.Dot(Te,D),le=b.Vector3[10];U>0&&N<0?(le.copyFrom(R),w=g,k=S):N>0&&J<0?(le.copyFrom(M),w=S,k=y):(le.copyFrom(I).scaleInPlace(-1),w=y,k=g);var be=b.Vector3[9],ve=b.Vector3[4];if(w.subtractToRef(te,Te),k.subtractToRef(te,be),T.CrossToRef(Te,be,ve),!(T.Dot(ve,D)<0))return x.copyFrom(te),Math.abs(ie*q);var ye=b.Vector3[5];T.CrossToRef(le,ve,ye),ye.normalize();var Me=b.Vector3[9];Me.copyFrom(w).subtractInPlace(te);var we=Me.length();if(we<i.bH)return x.copyFrom(w),T.Distance(f,w);Me.normalizeFromLength(we);var He=T.Dot(ye,Me),Ke=b.Vector3[7];Ke.copyFrom(te).addInPlace(ye.scaleInPlace(we*He)),Te.copyFrom(Ke).subtractInPlace(w),ie=le.length(),le.normalizeFromLength(ie);var Qe=T.Dot(Te,le)/Math.max(ie,i.bH);return Qe=(0,c.Clamp)(Qe,0,1),Ke.copyFrom(w).addInPlace(le.scaleInPlace(Qe*ie)),x.copyFrom(Ke),T.Distance(f,Ke)},T.Center=function(f,g){return T.CenterToRef(f,g,T.Zero())},T.CenterToRef=function(f,g,S){return S.copyFromFloats((f._x+g._x)/2,(f._y+g._y)/2,(f._z+g._z)/2)},T.RotationFromAxis=function(f,g,S){var y=new T;return T.RotationFromAxisToRef(f,g,S,y),y},T.RotationFromAxisToRef=function(f,g,S,y){var x=b.Quaternion[0];return m.RotationQuaternionFromAxisToRef(f,g,S,x),x.toEulerAnglesToRef(y),y},T._UpReadOnly=T.Up(),T._DownReadOnly=T.Down(),T._LeftHandedForwardReadOnly=T.Forward(!1),T._RightHandedForwardReadOnly=T.Forward(!0),T._LeftHandedBackwardReadOnly=T.Backward(!1),T._RightHandedBackwardReadOnly=T.Backward(!0),T._RightReadOnly=T.Right(),T._LeftReadOnly=T.Left(),T._ZeroReadOnly=T.Zero(),T._OneReadOnly=T.One(),T}();Object.defineProperties(h.prototype,{dimension:{value:[3]},rank:{value:1}});var p=function(){function T(f,g,S,y){f===void 0&&(f=0),g===void 0&&(g=0),S===void 0&&(S=0),y===void 0&&(y=0),this.x=f,this.y=g,this.z=S,this.w=y}return T.prototype.toString=function(){return"{X: ".concat(this.x," Y: ").concat(this.y," Z: ").concat(this.z," W: ").concat(this.w,"}")},T.prototype.getClassName=function(){return"Vector4"},T.prototype.getHashCode=function(){var f=u(this.x);return 397*(f=397*(f=397*f^u(this.y))^u(this.z))^u(this.w)},T.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},T.prototype.toArray=function(f,g){return g===void 0&&(g=0),f[g]=this.x,f[g+1]=this.y,f[g+2]=this.z,f[g+3]=this.w,this},T.prototype.fromArray=function(f,g){return g===void 0&&(g=0),T.FromArrayToRef(f,g,this),this},T.prototype.addInPlace=function(f){return this.x+=f.x,this.y+=f.y,this.z+=f.z,this.w+=f.w,this},T.prototype.addInPlaceFromFloats=function(f,g,S,y){return this.x+=f,this.y+=g,this.z+=S,this.w+=y,this},T.prototype.add=function(f){return new T(this.x+f.x,this.y+f.y,this.z+f.z,this.w+f.w)},T.prototype.addToRef=function(f,g){return g.x=this.x+f.x,g.y=this.y+f.y,g.z=this.z+f.z,g.w=this.w+f.w,g},T.prototype.subtractInPlace=function(f){return this.x-=f.x,this.y-=f.y,this.z-=f.z,this.w-=f.w,this},T.prototype.subtract=function(f){return new T(this.x-f.x,this.y-f.y,this.z-f.z,this.w-f.w)},T.prototype.subtractToRef=function(f,g){return g.x=this.x-f.x,g.y=this.y-f.y,g.z=this.z-f.z,g.w=this.w-f.w,g},T.prototype.subtractFromFloats=function(f,g,S,y){return new T(this.x-f,this.y-g,this.z-S,this.w-y)},T.prototype.subtractFromFloatsToRef=function(f,g,S,y,x){return x.x=this.x-f,x.y=this.y-g,x.z=this.z-S,x.w=this.w-y,x},T.prototype.negate=function(){return new T(-this.x,-this.y,-this.z,-this.w)},T.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this},T.prototype.negateToRef=function(f){return f.x=-this.x,f.y=-this.y,f.z=-this.z,f.w=-this.w,f},T.prototype.scaleInPlace=function(f){return this.x*=f,this.y*=f,this.z*=f,this.w*=f,this},T.prototype.scale=function(f){return new T(this.x*f,this.y*f,this.z*f,this.w*f)},T.prototype.scaleToRef=function(f,g){return g.x=this.x*f,g.y=this.y*f,g.z=this.z*f,g.w=this.w*f,g},T.prototype.scaleAndAddToRef=function(f,g){return g.x+=this.x*f,g.y+=this.y*f,g.z+=this.z*f,g.w+=this.w*f,g},T.prototype.equals=function(f){return f&&this.x===f.x&&this.y===f.y&&this.z===f.z&&this.w===f.w},T.prototype.equalsWithEpsilon=function(f,g){return g===void 0&&(g=i.bH),f&&(0,c.WithinEpsilon)(this.x,f.x,g)&&(0,c.WithinEpsilon)(this.y,f.y,g)&&(0,c.WithinEpsilon)(this.z,f.z,g)&&(0,c.WithinEpsilon)(this.w,f.w,g)},T.prototype.equalsToFloats=function(f,g,S,y){return this.x===f&&this.y===g&&this.z===S&&this.w===y},T.prototype.multiplyInPlace=function(f){return this.x*=f.x,this.y*=f.y,this.z*=f.z,this.w*=f.w,this},T.prototype.multiply=function(f){return new T(this.x*f.x,this.y*f.y,this.z*f.z,this.w*f.w)},T.prototype.multiplyToRef=function(f,g){return g.x=this.x*f.x,g.y=this.y*f.y,g.z=this.z*f.z,g.w=this.w*f.w,g},T.prototype.multiplyByFloats=function(f,g,S,y){return new T(this.x*f,this.y*g,this.z*S,this.w*y)},T.prototype.divide=function(f){return new T(this.x/f.x,this.y/f.y,this.z/f.z,this.w/f.w)},T.prototype.divideToRef=function(f,g){return g.x=this.x/f.x,g.y=this.y/f.y,g.z=this.z/f.z,g.w=this.w/f.w,g},T.prototype.divideInPlace=function(f){return this.divideToRef(f,this)},T.prototype.minimizeInPlace=function(f){return f.x<this.x&&(this.x=f.x),f.y<this.y&&(this.y=f.y),f.z<this.z&&(this.z=f.z),f.w<this.w&&(this.w=f.w),this},T.prototype.maximizeInPlace=function(f){return f.x>this.x&&(this.x=f.x),f.y>this.y&&(this.y=f.y),f.z>this.z&&(this.z=f.z),f.w>this.w&&(this.w=f.w),this},T.prototype.minimizeInPlaceFromFloats=function(f,g,S,y){return this.x=Math.min(f,this.x),this.y=Math.min(g,this.y),this.z=Math.min(S,this.z),this.w=Math.min(y,this.w),this},T.prototype.maximizeInPlaceFromFloats=function(f,g,S,y){return this.x=Math.max(f,this.x),this.y=Math.max(g,this.y),this.z=Math.max(S,this.z),this.w=Math.max(y,this.w),this},T.prototype.floorToRef=function(f){return f.x=Math.floor(this.x),f.y=Math.floor(this.y),f.z=Math.floor(this.z),f.w=Math.floor(this.w),f},T.prototype.floor=function(){return new T(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},T.prototype.fractToRef=function(f){return f.x=this.x-Math.floor(this.x),f.y=this.y-Math.floor(this.y),f.z=this.z-Math.floor(this.z),f.w=this.w-Math.floor(this.w),f},T.prototype.fract=function(){return new T(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},T.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},T.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},T.prototype.normalize=function(){return this.normalizeFromLength(this.length())},T.prototype.normalizeFromLength=function(f){return f===0||f===1?this:this.scaleInPlace(1/f)},T.prototype.normalizeToNew=function(){return this.normalizeToRef(new T)},T.prototype.normalizeToRef=function(f){var g=this.length();return g===0||g===1?(f.x=this.x,f.y=this.y,f.z=this.z,f.w=this.w,f):this.scaleToRef(1/g,f)},T.prototype.toVector3=function(){return new h(this.x,this.y,this.z)},T.prototype.clone=function(){return new T(this.x,this.y,this.z,this.w)},T.prototype.copyFrom=function(f){return this.x=f.x,this.y=f.y,this.z=f.z,this.w=f.w,this},T.prototype.copyFromFloats=function(f,g,S,y){return this.x=f,this.y=g,this.z=S,this.w=y,this},T.prototype.set=function(f,g,S,y){return this.copyFromFloats(f,g,S,y)},T.prototype.setAll=function(f){return this.x=this.y=this.z=this.w=f,this},T.prototype.dot=function(f){return this.x*f.x+this.y*f.y+this.z*f.z+this.w*f.w},T.FromArray=function(f,g){return g||(g=0),new T(f[g],f[g+1],f[g+2],f[g+3])},T.FromArrayToRef=function(f,g,S){return S.x=f[g],S.y=f[g+1],S.z=f[g+2],S.w=f[g+3],S},T.FromFloatArrayToRef=function(f,g,S){return T.FromArrayToRef(f,g,S),S},T.FromFloatsToRef=function(f,g,S,y,x){return x.x=f,x.y=g,x.z=S,x.w=y,x},T.Zero=function(){return new T(0,0,0,0)},T.One=function(){return new T(1,1,1,1)},T.Random=function(f,g){return f===void 0&&(f=0),g===void 0&&(g=1),new T((0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g))},T.RandomToRef=function(f,g,S){return f===void 0&&(f=0),g===void 0&&(g=1),S.x=(0,c.RandomRange)(f,g),S.y=(0,c.RandomRange)(f,g),S.z=(0,c.RandomRange)(f,g),S.w=(0,c.RandomRange)(f,g),S},T.Clamp=function(f,g,S){return T.ClampToRef(f,g,S,new T)},T.ClampToRef=function(f,g,S,y){return y.x=(0,c.Clamp)(f.x,g.x,S.x),y.y=(0,c.Clamp)(f.y,g.y,S.y),y.z=(0,c.Clamp)(f.z,g.z,S.z),y.w=(0,c.Clamp)(f.w,g.w,S.w),y},T.CheckExtends=function(f,g,S){g.minimizeInPlace(f),S.maximizeInPlace(f)},Object.defineProperty(T,"ZeroReadOnly",{get:function(){return T._ZeroReadOnly},enumerable:!1,configurable:!0}),T.Normalize=function(f){return T.NormalizeToRef(f,new T)},T.NormalizeToRef=function(f,g){return f.normalizeToRef(g),g},T.Minimize=function(f,g){var S=new T;return S.copyFrom(f),S.minimizeInPlace(g),S},T.Maximize=function(f,g){var S=new T;return S.copyFrom(f),S.maximizeInPlace(g),S},T.Distance=function(f,g){return Math.sqrt(T.DistanceSquared(f,g))},T.DistanceSquared=function(f,g){var S=f.x-g.x,y=f.y-g.y,x=f.z-g.z,R=f.w-g.w;return S*S+y*y+x*x+R*R},T.Center=function(f,g){return T.CenterToRef(f,g,new T)},T.CenterToRef=function(f,g,S){return S.x=(f.x+g.x)/2,S.y=(f.y+g.y)/2,S.z=(f.z+g.z)/2,S.w=(f.w+g.w)/2,S},T.TransformCoordinates=function(f,g){return T.TransformCoordinatesToRef(f,g,new T)},T.TransformCoordinatesToRef=function(f,g,S){return T.TransformCoordinatesFromFloatsToRef(f._x,f._y,f._z,g,S),S},T.TransformCoordinatesFromFloatsToRef=function(f,g,S,y,x){var R=y.m,I=f*R[0]+g*R[4]+S*R[8]+R[12],M=f*R[1]+g*R[5]+S*R[9]+R[13],D=f*R[2]+g*R[6]+S*R[10]+R[14],B=f*R[3]+g*R[7]+S*R[11]+R[15];return x.x=I,x.y=M,x.z=D,x.w=B,x},T.TransformNormal=function(f,g){return T.TransformNormalToRef(f,g,new T)},T.TransformNormalToRef=function(f,g,S){var y=g.m,x=f.x*y[0]+f.y*y[4]+f.z*y[8],R=f.x*y[1]+f.y*y[5]+f.z*y[9],I=f.x*y[2]+f.y*y[6]+f.z*y[10];return S.x=x,S.y=R,S.z=I,S.w=f.w,S},T.TransformNormalFromFloatsToRef=function(f,g,S,y,x,R){var I=x.m;return R.x=f*I[0]+g*I[4]+S*I[8],R.y=f*I[1]+g*I[5]+S*I[9],R.z=f*I[2]+g*I[6]+S*I[10],R.w=y,R},T.FromVector3=function(f,g){return g===void 0&&(g=0),new T(f._x,f._y,f._z,g)},T.Dot=function(f,g){return f.x*g.x+f.y*g.y+f.z*g.z+f.w*g.w},T._ZeroReadOnly=T.Zero(),T}();Object.defineProperties(p.prototype,{dimension:{value:[4]},rank:{value:1}});var m=function(){function T(f,g,S,y){f===void 0&&(f=0),g===void 0&&(g=0),S===void 0&&(S=0),y===void 0&&(y=1),this._isDirty=!0,this._x=f,this._y=g,this._z=S,this._w=y}return Object.defineProperty(T.prototype,"x",{get:function(){return this._x},set:function(f){this._x=f,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"y",{get:function(){return this._y},set:function(f){this._y=f,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"z",{get:function(){return this._z},set:function(f){this._z=f,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"w",{get:function(){return this._w},set:function(f){this._w=f,this._isDirty=!0},enumerable:!1,configurable:!0}),T.prototype.toString=function(){return"{X: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(this._z," W: ").concat(this._w,"}")},T.prototype.getClassName=function(){return"Quaternion"},T.prototype.getHashCode=function(){var f=u(this._x);return 397*(f=397*(f=397*f^u(this._y))^u(this._z))^u(this._w)},T.prototype.asArray=function(){return[this._x,this._y,this._z,this._w]},T.prototype.toArray=function(f,g){return g===void 0&&(g=0),f[g]=this._x,f[g+1]=this._y,f[g+2]=this._z,f[g+3]=this._w,this},T.prototype.fromArray=function(f,g){return g===void 0&&(g=0),T.FromArrayToRef(f,g,this)},T.prototype.equals=function(f){return f&&this._x===f._x&&this._y===f._y&&this._z===f._z&&this._w===f._w},T.prototype.equalsWithEpsilon=function(f,g){return g===void 0&&(g=i.bH),f&&(0,c.WithinEpsilon)(this._x,f._x,g)&&(0,c.WithinEpsilon)(this._y,f._y,g)&&(0,c.WithinEpsilon)(this._z,f._z,g)&&(0,c.WithinEpsilon)(this._w,f._w,g)},T.prototype.clone=function(){return new T(this._x,this._y,this._z,this._w)},T.prototype.copyFrom=function(f){return this._x=f._x,this._y=f._y,this._z=f._z,this._w=f._w,this._isDirty=!0,this},T.prototype.copyFromFloats=function(f,g,S,y){return this._x=f,this._y=g,this._z=S,this._w=y,this._isDirty=!0,this},T.prototype.set=function(f,g,S,y){return this.copyFromFloats(f,g,S,y)},T.prototype.setAll=function(f){return this.copyFromFloats(f,f,f,f)},T.prototype.add=function(f){return new T(this._x+f._x,this._y+f._y,this._z+f._z,this._w+f._w)},T.prototype.addInPlace=function(f){return this._x+=f._x,this._y+=f._y,this._z+=f._z,this._w+=f._w,this._isDirty=!0,this},T.prototype.addToRef=function(f,g){return g._x=this._x+f._x,g._y=this._y+f._y,g._z=this._z+f._z,g._w=this._w+f._w,g._isDirty=!0,g},T.prototype.addInPlaceFromFloats=function(f,g,S,y){return this._x+=f,this._y+=g,this._z+=S,this._w+=y,this._isDirty=!0,this},T.prototype.subtractToRef=function(f,g){return g._x=this._x-f._x,g._y=this._y-f._y,g._z=this._z-f._z,g._w=this._w-f._w,g._isDirty=!0,g},T.prototype.subtractFromFloats=function(f,g,S,y){return this.subtractFromFloatsToRef(f,g,S,y,new T)},T.prototype.subtractFromFloatsToRef=function(f,g,S,y,x){return x._x=this._x-f,x._y=this._y-g,x._z=this._z-S,x._w=this._w-y,x._isDirty=!0,x},T.prototype.subtract=function(f){return new T(this._x-f._x,this._y-f._y,this._z-f._z,this._w-f._w)},T.prototype.subtractInPlace=function(f){return this._x-=f._x,this._y-=f._y,this._z-=f._z,this._w-=f._w,this._isDirty=!0,this},T.prototype.scale=function(f){return new T(this._x*f,this._y*f,this._z*f,this._w*f)},T.prototype.scaleToRef=function(f,g){return g._x=this._x*f,g._y=this._y*f,g._z=this._z*f,g._w=this._w*f,g._isDirty=!0,g},T.prototype.scaleInPlace=function(f){return this._x*=f,this._y*=f,this._z*=f,this._w*=f,this._isDirty=!0,this},T.prototype.scaleAndAddToRef=function(f,g){return g._x+=this._x*f,g._y+=this._y*f,g._z+=this._z*f,g._w+=this._w*f,g._isDirty=!0,g},T.prototype.multiply=function(f){var g=new T(0,0,0,1);return this.multiplyToRef(f,g),g},T.prototype.multiplyToRef=function(f,g){var S=this._x*f._w+this._y*f._z-this._z*f._y+this._w*f._x,y=-this._x*f._z+this._y*f._w+this._z*f._x+this._w*f._y,x=this._x*f._y-this._y*f._x+this._z*f._w+this._w*f._z,R=-this._x*f._x-this._y*f._y-this._z*f._z+this._w*f._w;return g.copyFromFloats(S,y,x,R),g},T.prototype.multiplyInPlace=function(f){return this.multiplyToRef(f,this)},T.prototype.multiplyByFloats=function(f,g,S,y){return this._x*=f,this._y*=g,this._z*=S,this._w*=y,this._isDirty=!0,this},T.prototype.divide=function(f){throw new ReferenceError("Can not divide a quaternion")},T.prototype.divideToRef=function(f,g){throw new ReferenceError("Can not divide a quaternion")},T.prototype.divideInPlace=function(f){throw new ReferenceError("Can not divide a quaternion")},T.prototype.minimizeInPlace=function(){throw new ReferenceError("Can not minimize a quaternion")},T.prototype.minimizeInPlaceFromFloats=function(){throw new ReferenceError("Can not minimize a quaternion")},T.prototype.maximizeInPlace=function(){throw new ReferenceError("Can not maximize a quaternion")},T.prototype.maximizeInPlaceFromFloats=function(){throw new ReferenceError("Can not maximize a quaternion")},T.prototype.negate=function(){return this.negateToRef(new T)},T.prototype.negateInPlace=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this},T.prototype.negateToRef=function(f){return f._x=-this._x,f._y=-this._y,f._z=-this._z,f._w=-this._w,f._isDirty=!0,f},T.prototype.equalsToFloats=function(f,g,S,y){return this._x===f&&this._y===g&&this._z===S&&this._w===y},T.prototype.floorToRef=function(f){throw new ReferenceError("Can not floor a quaternion")},T.prototype.floor=function(){throw new ReferenceError("Can not floor a quaternion")},T.prototype.fractToRef=function(f){throw new ReferenceError("Can not fract a quaternion")},T.prototype.fract=function(){throw new ReferenceError("Can not fract a quaternion")},T.prototype.conjugateToRef=function(f){return f.copyFromFloats(-this._x,-this._y,-this._z,this._w),f},T.prototype.conjugateInPlace=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this},T.prototype.conjugate=function(){return new T(-this._x,-this._y,-this._z,this._w)},T.prototype.invert=function(){var f=this.conjugate(),g=this.lengthSquared();return g==0||g==1||f.scaleInPlace(1/g),f},T.prototype.invertInPlace=function(){this.conjugateInPlace();var f=this.lengthSquared();return f==0||f==1||this.scaleInPlace(1/f),this},T.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},T.prototype.length=function(){return Math.sqrt(this.lengthSquared())},T.prototype.normalize=function(){return this.normalizeFromLength(this.length())},T.prototype.normalizeFromLength=function(f){return f===0||f===1?this:this.scaleInPlace(1/f)},T.prototype.normalizeToNew=function(){var f=new T(0,0,0,1);return this.normalizeToRef(f),f},T.prototype.normalizeToRef=function(f){var g=this.length();return g===0||g===1?f.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/g,f)},T.prototype.toEulerAngles=function(){var f=h.Zero();return this.toEulerAnglesToRef(f),f},T.prototype.toEulerAnglesToRef=function(f){var g=this._z,S=this._x,y=this._y,x=this._w,R=y*g-S*x,I=.4999999;if(R<-I)f._y=2*Math.atan2(y,x),f._x=Math.PI/2,f._z=0,f._isDirty=!0;else if(R>I)f._y=2*Math.atan2(y,x),f._x=-Math.PI/2,f._z=0,f._isDirty=!0;else{var M=x*x,D=g*g,B=S*S,F=y*y;f._z=Math.atan2(2*(S*y+g*x),-D-B+F+M),f._x=Math.asin(-2*R),f._y=Math.atan2(2*(g*S+y*x),D-B-F+M),f._isDirty=!0}return f},T.prototype.toAlphaBetaGammaToRef=function(f){var g=this._z,S=this._x,y=this._y,x=this._w,R=Math.sqrt(S*S+y*y),I=Math.sqrt(g*g+x*x),M=2*Math.atan2(R,I),D=2*Math.atan2(g,x),B=2*Math.atan2(y,S),F=(D+B)/2,X=(D-B)/2;return f.set(X,M,F),f},T.prototype.toRotationMatrix=function(f){return v.FromQuaternionToRef(this,f),f},T.prototype.fromRotationMatrix=function(f){return T.FromRotationMatrixToRef(f,this),this},T.prototype.dot=function(f){return this._x*f._x+this._y*f._y+this._z*f._z+this._w*f._w},T.FromRotationMatrix=function(f){var g=new T;return T.FromRotationMatrixToRef(f,g),g},T.FromRotationMatrixToRef=function(f,g){var S,y=f.m,x=y[0],R=y[4],I=y[8],M=y[1],D=y[5],B=y[9],F=y[2],X=y[6],$=y[10],Q=x+D+$;return Q>0?(S=.5/Math.sqrt(Q+1),g._w=.25/S,g._x=(X-B)*S,g._y=(I-F)*S,g._z=(M-R)*S,g._isDirty=!0):x>D&&x>$?(S=2*Math.sqrt(1+x-D-$),g._w=(X-B)/S,g._x=.25*S,g._y=(R+M)/S,g._z=(I+F)/S,g._isDirty=!0):D>$?(S=2*Math.sqrt(1+D-x-$),g._w=(I-F)/S,g._x=(R+M)/S,g._y=.25*S,g._z=(B+X)/S,g._isDirty=!0):(S=2*Math.sqrt(1+$-x-D),g._w=(M-R)/S,g._x=(I+F)/S,g._y=(B+X)/S,g._z=.25*S,g._isDirty=!0),g},T.Dot=function(f,g){return f._x*g._x+f._y*g._y+f._z*g._z+f._w*g._w},T.AreClose=function(f,g,S){S===void 0&&(S=.1);var y=T.Dot(f,g);return 1-y*y<=S},T.SmoothToRef=function(f,g,S,y,x){var R=y===0?1:S/y;return R=(0,c.Clamp)(R,0,1),T.SlerpToRef(f,g,R,x),x},T.Zero=function(){return new T(0,0,0,0)},T.Inverse=function(f){return new T(-f._x,-f._y,-f._z,f._w)},T.InverseToRef=function(f,g){return g.set(-f._x,-f._y,-f._z,f._w),g},T.Identity=function(){return new T(0,0,0,1)},T.IsIdentity=function(f){return f&&f._x===0&&f._y===0&&f._z===0&&f._w===1},T.RotationAxis=function(f,g){return T.RotationAxisToRef(f,g,new T)},T.RotationAxisToRef=function(f,g,S){S._w=Math.cos(g/2);var y=Math.sin(g/2)/f.length();return S._x=f._x*y,S._y=f._y*y,S._z=f._z*y,S._isDirty=!0,S},T.FromArray=function(f,g){return g||(g=0),new T(f[g],f[g+1],f[g+2],f[g+3])},T.FromArrayToRef=function(f,g,S){return S._x=f[g],S._y=f[g+1],S._z=f[g+2],S._w=f[g+3],S._isDirty=!0,S},T.FromFloatsToRef=function(f,g,S,y,x){return x.copyFromFloats(f,g,S,y),x},T.FromEulerAngles=function(f,g,S){var y=new T;return T.RotationYawPitchRollToRef(g,f,S,y),y},T.FromEulerAnglesToRef=function(f,g,S,y){return T.RotationYawPitchRollToRef(g,f,S,y),y},T.FromEulerVector=function(f){var g=new T;return T.RotationYawPitchRollToRef(f._y,f._x,f._z,g),g},T.FromEulerVectorToRef=function(f,g){return T.RotationYawPitchRollToRef(f._y,f._x,f._z,g),g},T.FromUnitVectorsToRef=function(f,g,S,y){y===void 0&&(y=i.bH);var x=h.Dot(f,g)+1;return x<y?Math.abs(f.x)>Math.abs(f.z)?S.set(-f.y,f.x,0,0):S.set(0,-f.z,f.y,0):(h.CrossToRef(f,g,E.Vector3[0]),S.set(E.Vector3[0].x,E.Vector3[0].y,E.Vector3[0].z,x)),S.normalize()},T.RotationYawPitchRoll=function(f,g,S){var y=new T;return T.RotationYawPitchRollToRef(f,g,S,y),y},T.RotationYawPitchRollToRef=function(f,g,S,y){var x=.5*S,R=.5*g,I=.5*f,M=Math.sin(x),D=Math.cos(x),B=Math.sin(R),F=Math.cos(R),X=Math.sin(I),$=Math.cos(I);return y._x=$*B*D+X*F*M,y._y=X*F*D-$*B*M,y._z=$*F*M-X*B*D,y._w=$*F*D+X*B*M,y._isDirty=!0,y},T.RotationAlphaBetaGamma=function(f,g,S){var y=new T;return T.RotationAlphaBetaGammaToRef(f,g,S,y),y},T.RotationAlphaBetaGammaToRef=function(f,g,S,y){var x=.5*(S+f),R=.5*(S-f),I=.5*g;return y._x=Math.cos(R)*Math.sin(I),y._y=Math.sin(R)*Math.sin(I),y._z=Math.sin(x)*Math.cos(I),y._w=Math.cos(x)*Math.cos(I),y._isDirty=!0,y},T.RotationQuaternionFromAxis=function(f,g,S){var y=new T(0,0,0,0);return T.RotationQuaternionFromAxisToRef(f,g,S,y),y},T.RotationQuaternionFromAxisToRef=function(f,g,S,y){var x=b.Matrix[0];return f=f.normalizeToRef(b.Vector3[0]),g=g.normalizeToRef(b.Vector3[1]),S=S.normalizeToRef(b.Vector3[2]),v.FromXYZAxesToRef(f,g,S,x),T.FromRotationMatrixToRef(x,y),y},T.FromLookDirectionLH=function(f,g){var S=new T;return T.FromLookDirectionLHToRef(f,g,S),S},T.FromLookDirectionLHToRef=function(f,g,S){var y=b.Matrix[0];return v.LookDirectionLHToRef(f,g,y),T.FromRotationMatrixToRef(y,S),S},T.FromLookDirectionRH=function(f,g){var S=new T;return T.FromLookDirectionRHToRef(f,g,S),S},T.FromLookDirectionRHToRef=function(f,g,S){var y=b.Matrix[0];return v.LookDirectionRHToRef(f,g,y),T.FromRotationMatrixToRef(y,S)},T.Slerp=function(f,g,S){var y=T.Identity();return T.SlerpToRef(f,g,S,y),y},T.SlerpToRef=function(f,g,S,y){var x,R,I=f._x*g._x+f._y*g._y+f._z*g._z+f._w*g._w,M=!1;if(I<0&&(M=!0,I=-I),I>.999999)R=1-S,x=M?-S:S;else{var D=Math.acos(I),B=1/Math.sin(D);R=Math.sin((1-S)*D)*B,x=M?-Math.sin(S*D)*B:Math.sin(S*D)*B}return y._x=R*f._x+x*g._x,y._y=R*f._y+x*g._y,y._z=R*f._z+x*g._z,y._w=R*f._w+x*g._w,y._isDirty=!0,y},T.Hermite=function(f,g,S,y,x){var R=x*x,I=x*R,M=2*I-3*R+1,D=-2*I+3*R,B=I-2*R+x,F=I-R;return new T(f._x*M+S._x*D+g._x*B+y._x*F,f._y*M+S._y*D+g._y*B+y._y*F,f._z*M+S._z*D+g._z*B+y._z*F,f._w*M+S._w*D+g._w*B+y._w*F)},T.Hermite1stDerivative=function(f,g,S,y,x){var R=new T;return this.Hermite1stDerivativeToRef(f,g,S,y,x,R),R},T.Hermite1stDerivativeToRef=function(f,g,S,y,x,R){var I=x*x;return R._x=6*(I-x)*f._x+(3*I-4*x+1)*g._x+6*(-I+x)*S._x+(3*I-2*x)*y._x,R._y=6*(I-x)*f._y+(3*I-4*x+1)*g._y+6*(-I+x)*S._y+(3*I-2*x)*y._y,R._z=6*(I-x)*f._z+(3*I-4*x+1)*g._z+6*(-I+x)*S._z+(3*I-2*x)*y._z,R._w=6*(I-x)*f._w+(3*I-4*x+1)*g._w+6*(-I+x)*S._w+(3*I-2*x)*y._w,R._isDirty=!0,R},T.Normalize=function(f){var g=T.Zero();return T.NormalizeToRef(f,g),g},T.NormalizeToRef=function(f,g){return f.normalizeToRef(g),g},T.Clamp=function(f,g,S){var y=new T;return T.ClampToRef(f,g,S,y),y},T.ClampToRef=function(f,g,S,y){return y.copyFromFloats((0,c.Clamp)(f.x,g.x,S.x),(0,c.Clamp)(f.y,g.y,S.y),(0,c.Clamp)(f.z,g.z,S.z),(0,c.Clamp)(f.w,g.w,S.w))},T.Random=function(f,g){return f===void 0&&(f=0),g===void 0&&(g=1),new T((0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g))},T.RandomToRef=function(f,g,S){return f===void 0&&(f=0),g===void 0&&(g=1),S.copyFromFloats((0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g),(0,c.RandomRange)(f,g))},T.Minimize=function(){throw new ReferenceError("Quaternion.Minimize does not make sense")},T.Maximize=function(){throw new ReferenceError("Quaternion.Maximize does not make sense")},T.Distance=function(f,g){return Math.sqrt(T.DistanceSquared(f,g))},T.DistanceSquared=function(f,g){var S=f.x-g.x,y=f.y-g.y,x=f.z-g.z,R=f.w-g.w;return S*S+y*y+x*x+R*R},T.Center=function(f,g){return T.CenterToRef(f,g,T.Zero())},T.CenterToRef=function(f,g,S){return S.copyFromFloats((f.x+g.x)/2,(f.y+g.y)/2,(f.z+g.z)/2,(f.w+g.w)/2)},T}();Object.defineProperties(m.prototype,{dimension:{value:[4]},rank:{value:1}});var v=function(){function T(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,s.I.MatrixTrackPrecisionChange&&s.I.MatrixTrackedMatrices.push(this),this._m=new s.I.MatrixCurrentType(16),this.markAsUpdated()}return Object.defineProperty(T,"Use64Bits",{get:function(){return s.I.MatrixUse64Bits},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"m",{get:function(){return this._m},enumerable:!1,configurable:!0}),T.prototype.markAsUpdated=function(){this.updateFlag=T._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},T.prototype._updateIdentityStatus=function(f,g,S,y){g===void 0&&(g=!1),S===void 0&&(S=!1),y===void 0&&(y=!0),this._isIdentity=f,this._isIdentity3x2=f||S,this._isIdentityDirty=!this._isIdentity&&g,this._isIdentity3x2Dirty=!this._isIdentity3x2&&y},T.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var f=this._m;this._isIdentity=f[0]===1&&f[1]===0&&f[2]===0&&f[3]===0&&f[4]===0&&f[5]===1&&f[6]===0&&f[7]===0&&f[8]===0&&f[9]===0&&f[10]===1&&f[11]===0&&f[12]===0&&f[13]===0&&f[14]===0&&f[15]===1}return this._isIdentity},T.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,this._m[0]!==1||this._m[5]!==1||this._m[15]!==1||this._m[1]!==0||this._m[2]!==0||this._m[3]!==0||this._m[4]!==0||this._m[6]!==0||this._m[7]!==0||this._m[8]!==0||this._m[9]!==0||this._m[10]!==0||this._m[11]!==0||this._m[12]!==0||this._m[13]!==0||this._m[14]!==0?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},T.prototype.determinant=function(){if(this._isIdentity===!0)return 1;var f=this._m,g=f[0],S=f[1],y=f[2],x=f[3],R=f[4],I=f[5],M=f[6],D=f[7],B=f[8],F=f[9],X=f[10],$=f[11],Q=f[12],ie=f[13],q=f[14],ee=f[15],te=X*ee-q*$,ce=F*ee-ie*$,fe=F*q-ie*X,de=B*ee-Q*$,Te=B*q-X*Q,ue=B*ie-Q*F;return g*+(I*te-M*ce+D*fe)+S*-(R*te-M*de+D*Te)+y*+(R*ce-I*de+D*ue)+x*-(R*fe-I*Te+M*ue)},T.prototype.toString=function(){return"{".concat(this.m[0],", ").concat(this.m[1],", ").concat(this.m[2],", ").concat(this.m[3],`
|
||
`).concat(this.m[4],", ").concat(this.m[5],", ").concat(this.m[6],", ").concat(this.m[7],`
|
||
`).concat(this.m[8],", ").concat(this.m[9],", ").concat(this.m[10],", ").concat(this.m[11],`
|
||
`).concat(this.m[12],", ").concat(this.m[13],", ").concat(this.m[14],", ").concat(this.m[15],"}")},T.prototype.toArray=function(f,g){if(f===void 0&&(f=null),g===void 0&&(g=0),!f)return this._m;for(var S=this._m,y=0;y<16;y++)f[g+y]=S[y];return this},T.prototype.asArray=function(){return this._m},T.prototype.fromArray=function(f,g){return g===void 0&&(g=0),T.FromArrayToRef(f,g,this)},T.prototype.copyFromFloats=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];return T.FromArrayToRef(f,0,this)},T.prototype.set=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=this._m,y=0;y<16;y++)S[y]=f[y];return this.markAsUpdated(),this},T.prototype.setAll=function(f){for(var g=this._m,S=0;S<16;S++)g[S]=f;return this.markAsUpdated(),this},T.prototype.invert=function(){return this.invertToRef(this),this},T.prototype.reset=function(){return T.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},T.prototype.add=function(f){var g=new T;return this.addToRef(f,g),g},T.prototype.addToRef=function(f,g){for(var S=this._m,y=g._m,x=f.m,R=0;R<16;R++)y[R]=S[R]+x[R];return g.markAsUpdated(),g},T.prototype.addToSelf=function(f){var g=this._m,S=f.m;return g[0]+=S[0],g[1]+=S[1],g[2]+=S[2],g[3]+=S[3],g[4]+=S[4],g[5]+=S[5],g[6]+=S[6],g[7]+=S[7],g[8]+=S[8],g[9]+=S[9],g[10]+=S[10],g[11]+=S[11],g[12]+=S[12],g[13]+=S[13],g[14]+=S[14],g[15]+=S[15],this.markAsUpdated(),this},T.prototype.addInPlace=function(f){for(var g=this._m,S=f.m,y=0;y<16;y++)g[y]+=S[y];return this.markAsUpdated(),this},T.prototype.addInPlaceFromFloats=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=this._m,y=0;y<16;y++)S[y]+=f[y];return this.markAsUpdated(),this},T.prototype.subtract=function(f){for(var g=this._m,S=f.m,y=0;y<16;y++)g[y]-=S[y];return this.markAsUpdated(),this},T.prototype.subtractToRef=function(f,g){for(var S=this._m,y=f.m,x=g._m,R=0;R<16;R++)x[R]=S[R]-y[R];return g.markAsUpdated(),g},T.prototype.subtractInPlace=function(f){for(var g=this._m,S=f.m,y=0;y<16;y++)g[y]-=S[y];return this.markAsUpdated(),this},T.prototype.subtractFromFloats=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];return this.subtractFromFloatsToRef.apply(this,(0,n.fX)((0,n.fX)([],f,!1),[new T],!1))},T.prototype.subtractFromFloatsToRef=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=f.pop(),y=this._m,x=S._m,R=f,I=0;I<16;I++)x[I]=y[I]-R[I];return S.markAsUpdated(),S},T.prototype.invertToRef=function(f){if(this._isIdentity===!0)return T.IdentityToRef(f),f;var g=this._m,S=g[0],y=g[1],x=g[2],R=g[3],I=g[4],M=g[5],D=g[6],B=g[7],F=g[8],X=g[9],$=g[10],Q=g[11],ie=g[12],q=g[13],ee=g[14],te=g[15],ce=$*te-ee*Q,fe=X*te-q*Q,de=X*ee-q*$,Te=F*te-ie*Q,ue=F*ee-$*ie,U=F*q-ie*X,N=+(M*ce-D*fe+B*de),w=-(I*ce-D*Te+B*ue),k=+(I*fe-M*Te+B*U),J=-(I*de-M*ue+D*U),le=S*N+y*w+x*k+R*J;if(le===0)return f.copyFrom(this),f;var be=1/le,ve=D*te-ee*B,ye=M*te-q*B,Me=M*ee-q*D,we=I*te-ie*B,He=I*ee-ie*D,Ke=I*q-ie*M,Qe=D*Q-$*B,Je=M*Q-X*B,ht=M*$-X*D,mt=I*Q-F*B,yt=I*$-F*D,zt=I*X-F*M,$t=-(y*ce-x*fe+R*de),St=+(S*ce-x*Te+R*ue),Ot=-(S*fe-y*Te+R*U),Et=+(S*de-y*ue+x*U),Vt=+(y*ve-x*ye+R*Me),ln=-(S*ve-x*we+R*He),Yt=+(S*ye-y*we+R*Ke),Un=-(S*Me-y*He+x*Ke),lr=-(y*Qe-x*Je+R*ht),ii=+(S*Qe-x*mt+R*yt),Li=-(S*Je-y*mt+R*zt),$r=+(S*ht-y*yt+x*zt);return T.FromValuesToRef(N*be,$t*be,Vt*be,lr*be,w*be,St*be,ln*be,ii*be,k*be,Ot*be,Yt*be,Li*be,J*be,Et*be,Un*be,$r*be,f),f},T.prototype.addAtIndex=function(f,g){return this._m[f]+=g,this.markAsUpdated(),this},T.prototype.multiplyAtIndex=function(f,g){return this._m[f]*=g,this.markAsUpdated(),this},T.prototype.setTranslationFromFloats=function(f,g,S){return this._m[12]=f,this._m[13]=g,this._m[14]=S,this.markAsUpdated(),this},T.prototype.addTranslationFromFloats=function(f,g,S){return this._m[12]+=f,this._m[13]+=g,this._m[14]+=S,this.markAsUpdated(),this},T.prototype.setTranslation=function(f){return this.setTranslationFromFloats(f._x,f._y,f._z)},T.prototype.getTranslation=function(){return new h(this._m[12],this._m[13],this._m[14])},T.prototype.getTranslationToRef=function(f){return f.x=this._m[12],f.y=this._m[13],f.z=this._m[14],f},T.prototype.removeRotationAndScaling=function(){var f=this.m;return T.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,f[12],f[13],f[14],f[15],this),this._updateIdentityStatus(f[12]===0&&f[13]===0&&f[14]===0&&f[15]===1),this},T.prototype.copyFrom=function(f){f.copyToArray(this._m);var g=f;return this.updateFlag=g.updateFlag,this._updateIdentityStatus(g._isIdentity,g._isIdentityDirty,g._isIdentity3x2,g._isIdentity3x2Dirty),this},T.prototype.copyToArray=function(f,g){g===void 0&&(g=0);var S=this._m;return f[g]=S[0],f[g+1]=S[1],f[g+2]=S[2],f[g+3]=S[3],f[g+4]=S[4],f[g+5]=S[5],f[g+6]=S[6],f[g+7]=S[7],f[g+8]=S[8],f[g+9]=S[9],f[g+10]=S[10],f[g+11]=S[11],f[g+12]=S[12],f[g+13]=S[13],f[g+14]=S[14],f[g+15]=S[15],this},T.prototype.multiply=function(f){var g=new T;return this.multiplyToRef(f,g),g},T.prototype.multiplyInPlace=function(f){for(var g=this._m,S=f.m,y=0;y<16;y++)g[y]*=S[y];return this.markAsUpdated(),this},T.prototype.multiplyByFloats=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=this._m,y=0;y<16;y++)S[y]*=f[y];return this.markAsUpdated(),this},T.prototype.multiplyByFloatsToRef=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=f.pop(),y=this._m,x=S._m,R=f,I=0;I<16;I++)x[I]=y[I]*R[I];return S.markAsUpdated(),S},T.prototype.multiplyToRef=function(f,g){return this._isIdentity?(g.copyFrom(f),g):f._isIdentity?(g.copyFrom(this),g):(this.multiplyToArray(f,g._m,0),g.markAsUpdated(),g)},T.prototype.multiplyToArray=function(f,g,S){var y=this._m,x=f.m,R=y[0],I=y[1],M=y[2],D=y[3],B=y[4],F=y[5],X=y[6],$=y[7],Q=y[8],ie=y[9],q=y[10],ee=y[11],te=y[12],ce=y[13],fe=y[14],de=y[15],Te=x[0],ue=x[1],U=x[2],N=x[3],w=x[4],k=x[5],J=x[6],le=x[7],be=x[8],ve=x[9],ye=x[10],Me=x[11],we=x[12],He=x[13],Ke=x[14],Qe=x[15];return g[S]=R*Te+I*w+M*be+D*we,g[S+1]=R*ue+I*k+M*ve+D*He,g[S+2]=R*U+I*J+M*ye+D*Ke,g[S+3]=R*N+I*le+M*Me+D*Qe,g[S+4]=B*Te+F*w+X*be+$*we,g[S+5]=B*ue+F*k+X*ve+$*He,g[S+6]=B*U+F*J+X*ye+$*Ke,g[S+7]=B*N+F*le+X*Me+$*Qe,g[S+8]=Q*Te+ie*w+q*be+ee*we,g[S+9]=Q*ue+ie*k+q*ve+ee*He,g[S+10]=Q*U+ie*J+q*ye+ee*Ke,g[S+11]=Q*N+ie*le+q*Me+ee*Qe,g[S+12]=te*Te+ce*w+fe*be+de*we,g[S+13]=te*ue+ce*k+fe*ve+de*He,g[S+14]=te*U+ce*J+fe*ye+de*Ke,g[S+15]=te*N+ce*le+fe*Me+de*Qe,this},T.prototype.divide=function(f){return this.divideToRef(f,new T)},T.prototype.divideToRef=function(f,g){for(var S=this._m,y=f.m,x=g._m,R=0;R<16;R++)x[R]=S[R]/y[R];return g.markAsUpdated(),g},T.prototype.divideInPlace=function(f){for(var g=this._m,S=f.m,y=0;y<16;y++)g[y]/=S[y];return this.markAsUpdated(),this},T.prototype.minimizeInPlace=function(f){for(var g=this._m,S=f.m,y=0;y<16;y++)g[y]=Math.min(g[y],S[y]);return this.markAsUpdated(),this},T.prototype.minimizeInPlaceFromFloats=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=this._m,y=0;y<16;y++)S[y]=Math.min(S[y],f[y]);return this.markAsUpdated(),this},T.prototype.maximizeInPlace=function(f){for(var g=this._m,S=f.m,y=0;y<16;y++)g[y]=Math.min(g[y],S[y]);return this.markAsUpdated(),this},T.prototype.maximizeInPlaceFromFloats=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=this._m,y=0;y<16;y++)S[y]=Math.min(S[y],f[y]);return this.markAsUpdated(),this},T.prototype.negate=function(){return this.negateToRef(new T)},T.prototype.negateInPlace=function(){for(var f=this._m,g=0;g<16;g++)f[g]=-f[g];return this.markAsUpdated(),this},T.prototype.negateToRef=function(f){for(var g=this._m,S=f._m,y=0;y<16;y++)S[y]=-g[y];return f.markAsUpdated(),f},T.prototype.equals=function(f){var g=f;if(!g)return!1;if((this._isIdentity||g._isIdentity)&&!this._isIdentityDirty&&!g._isIdentityDirty)return this._isIdentity&&g._isIdentity;var S=this.m,y=g.m;return S[0]===y[0]&&S[1]===y[1]&&S[2]===y[2]&&S[3]===y[3]&&S[4]===y[4]&&S[5]===y[5]&&S[6]===y[6]&&S[7]===y[7]&&S[8]===y[8]&&S[9]===y[9]&&S[10]===y[10]&&S[11]===y[11]&&S[12]===y[12]&&S[13]===y[13]&&S[14]===y[14]&&S[15]===y[15]},T.prototype.equalsWithEpsilon=function(f,g){g===void 0&&(g=0);for(var S=this._m,y=f.m,x=0;x<16;x++)if(!(0,c.WithinEpsilon)(S[x],y[x],g))return!1;return!0},T.prototype.equalsToFloats=function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];for(var S=this._m,y=0;y<16;y++)if(S[y]!=f[y])return!1;return!0},T.prototype.floor=function(){return this.floorToRef(new T)},T.prototype.floorToRef=function(f){for(var g=this._m,S=f._m,y=0;y<16;y++)S[y]=Math.floor(g[y]);return f.markAsUpdated(),f},T.prototype.fract=function(){return this.fractToRef(new T)},T.prototype.fractToRef=function(f){for(var g=this._m,S=f._m,y=0;y<16;y++)S[y]=g[y]-Math.floor(g[y]);return f.markAsUpdated(),f},T.prototype.clone=function(){var f=new T;return f.copyFrom(this),f},T.prototype.getClassName=function(){return"Matrix"},T.prototype.getHashCode=function(){for(var f=u(this._m[0]),g=1;g<16;g++)f=397*f^u(this._m[g]);return f},T.prototype.decomposeToTransformNode=function(f){return f.rotationQuaternion=f.rotationQuaternion||new m,this.decompose(f.scaling,f.rotationQuaternion,f.position)},T.prototype.decompose=function(f,g,S,y,x){if(x===void 0&&(x=!0),this._isIdentity)return S&&S.setAll(0),f&&f.setAll(1),g&&g.copyFromFloats(0,0,0,1),!0;var R=this._m;if(S&&S.copyFromFloats(R[12],R[13],R[14]),(f=f||b.Vector3[0]).x=Math.sqrt(R[0]*R[0]+R[1]*R[1]+R[2]*R[2]),f.y=Math.sqrt(R[4]*R[4]+R[5]*R[5]+R[6]*R[6]),f.z=Math.sqrt(R[8]*R[8]+R[9]*R[9]+R[10]*R[10]),y){var I=(x?y.absoluteScaling.x:y.scaling.x)<0?-1:1,M=(x?y.absoluteScaling.y:y.scaling.y)<0?-1:1,D=(x?y.absoluteScaling.z:y.scaling.z)<0?-1:1;f.x*=I,f.y*=M,f.z*=D}else this.determinant()<=0&&(f.y*=-1);if(f._x===0||f._y===0||f._z===0)return g&&g.copyFromFloats(0,0,0,1),!1;if(g){var B=1/f._x,F=1/f._y,X=1/f._z;T.FromValuesToRef(R[0]*B,R[1]*B,R[2]*B,0,R[4]*F,R[5]*F,R[6]*F,0,R[8]*X,R[9]*X,R[10]*X,0,0,0,0,1,b.Matrix[0]),m.FromRotationMatrixToRef(b.Matrix[0],g)}return!0},T.prototype.getRow=function(f){if(f<0||f>3)return null;var g=4*f;return new p(this._m[g+0],this._m[g+1],this._m[g+2],this._m[g+3])},T.prototype.getRowToRef=function(f,g){if(f>=0&&f<=3){var S=4*f;g.x=this._m[S+0],g.y=this._m[S+1],g.z=this._m[S+2],g.w=this._m[S+3]}return g},T.prototype.setRow=function(f,g){return this.setRowFromFloats(f,g.x,g.y,g.z,g.w)},T.prototype.transpose=function(){var f=new T;return T.TransposeToRef(this,f),f},T.prototype.transposeToRef=function(f){return T.TransposeToRef(this,f),f},T.prototype.setRowFromFloats=function(f,g,S,y,x){if(f<0||f>3)return this;var R=4*f;return this._m[R+0]=g,this._m[R+1]=S,this._m[R+2]=y,this._m[R+3]=x,this.markAsUpdated(),this},T.prototype.scale=function(f){var g=new T;return this.scaleToRef(f,g),g},T.prototype.scaleToRef=function(f,g){for(var S=0;S<16;S++)g._m[S]=this._m[S]*f;return g.markAsUpdated(),g},T.prototype.scaleAndAddToRef=function(f,g){for(var S=0;S<16;S++)g._m[S]+=this._m[S]*f;return g.markAsUpdated(),g},T.prototype.scaleInPlace=function(f){for(var g=this._m,S=0;S<16;S++)g[S]*=f;return this.markAsUpdated(),this},T.prototype.toNormalMatrix=function(f){var g=b.Matrix[0];this.invertToRef(g),g.transposeToRef(f);var S=f._m;return T.FromValuesToRef(S[0],S[1],S[2],0,S[4],S[5],S[6],0,S[8],S[9],S[10],0,0,0,0,1,f),f},T.prototype.getRotationMatrix=function(){var f=new T;return this.getRotationMatrixToRef(f),f},T.prototype.getRotationMatrixToRef=function(f){var g=b.Vector3[0];if(!this.decompose(g))return T.IdentityToRef(f),f;var S=this._m,y=1/g._x,x=1/g._y,R=1/g._z;return T.FromValuesToRef(S[0]*y,S[1]*y,S[2]*y,0,S[4]*x,S[5]*x,S[6]*x,0,S[8]*R,S[9]*R,S[10]*R,0,0,0,0,1,f),f},T.prototype.toggleModelMatrixHandInPlace=function(){var f=this._m;return f[2]*=-1,f[6]*=-1,f[8]*=-1,f[9]*=-1,f[14]*=-1,this.markAsUpdated(),this},T.prototype.toggleProjectionMatrixHandInPlace=function(){var f=this._m;return f[8]*=-1,f[9]*=-1,f[10]*=-1,f[11]*=-1,this.markAsUpdated(),this},T.FromArray=function(f,g){g===void 0&&(g=0);var S=new T;return T.FromArrayToRef(f,g,S),S},T.FromArrayToRef=function(f,g,S){for(var y=0;y<16;y++)S._m[y]=f[y+g];return S.markAsUpdated(),S},T.FromFloat32ArrayToRefScaled=function(f,g,S,y){return y._m[0]=f[0+g]*S,y._m[1]=f[1+g]*S,y._m[2]=f[2+g]*S,y._m[3]=f[3+g]*S,y._m[4]=f[4+g]*S,y._m[5]=f[5+g]*S,y._m[6]=f[6+g]*S,y._m[7]=f[7+g]*S,y._m[8]=f[8+g]*S,y._m[9]=f[9+g]*S,y._m[10]=f[10+g]*S,y._m[11]=f[11+g]*S,y._m[12]=f[12+g]*S,y._m[13]=f[13+g]*S,y._m[14]=f[14+g]*S,y._m[15]=f[15+g]*S,y.markAsUpdated(),y},Object.defineProperty(T,"IdentityReadOnly",{get:function(){return T._IdentityReadOnly},enumerable:!1,configurable:!0}),T.FromValuesToRef=function(f,g,S,y,x,R,I,M,D,B,F,X,$,Q,ie,q,ee){var te=ee._m;te[0]=f,te[1]=g,te[2]=S,te[3]=y,te[4]=x,te[5]=R,te[6]=I,te[7]=M,te[8]=D,te[9]=B,te[10]=F,te[11]=X,te[12]=$,te[13]=Q,te[14]=ie,te[15]=q,ee.markAsUpdated()},T.FromValues=function(f,g,S,y,x,R,I,M,D,B,F,X,$,Q,ie,q){var ee=new T,te=ee._m;return te[0]=f,te[1]=g,te[2]=S,te[3]=y,te[4]=x,te[5]=R,te[6]=I,te[7]=M,te[8]=D,te[9]=B,te[10]=F,te[11]=X,te[12]=$,te[13]=Q,te[14]=ie,te[15]=q,ee.markAsUpdated(),ee},T.Compose=function(f,g,S){var y=new T;return T.ComposeToRef(f,g,S,y),y},T.ComposeToRef=function(f,g,S,y){var x=y._m,R=g._x,I=g._y,M=g._z,D=g._w,B=R+R,F=I+I,X=M+M,$=R*B,Q=R*F,ie=R*X,q=I*F,ee=I*X,te=M*X,ce=D*B,fe=D*F,de=D*X,Te=f._x,ue=f._y,U=f._z;return x[0]=(1-(q+te))*Te,x[1]=(Q+de)*Te,x[2]=(ie-fe)*Te,x[3]=0,x[4]=(Q-de)*ue,x[5]=(1-($+te))*ue,x[6]=(ee+ce)*ue,x[7]=0,x[8]=(ie+fe)*U,x[9]=(ee-ce)*U,x[10]=(1-($+q))*U,x[11]=0,x[12]=S._x,x[13]=S._y,x[14]=S._z,x[15]=1,y.markAsUpdated(),y},T.Identity=function(){var f=T.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return f._updateIdentityStatus(!0),f},T.IdentityToRef=function(f){return T.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,f),f._updateIdentityStatus(!0),f},T.Zero=function(){var f=T.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return f._updateIdentityStatus(!1),f},T.RotationX=function(f){var g=new T;return T.RotationXToRef(f,g),g},T.Invert=function(f){var g=new T;return f.invertToRef(g),g},T.RotationXToRef=function(f,g){var S=Math.sin(f),y=Math.cos(f);return T.FromValuesToRef(1,0,0,0,0,y,S,0,0,-S,y,0,0,0,0,1,g),g._updateIdentityStatus(y===1&&S===0),g},T.RotationY=function(f){var g=new T;return T.RotationYToRef(f,g),g},T.RotationYToRef=function(f,g){var S=Math.sin(f),y=Math.cos(f);return T.FromValuesToRef(y,0,-S,0,0,1,0,0,S,0,y,0,0,0,0,1,g),g._updateIdentityStatus(y===1&&S===0),g},T.RotationZ=function(f){var g=new T;return T.RotationZToRef(f,g),g},T.RotationZToRef=function(f,g){var S=Math.sin(f),y=Math.cos(f);return T.FromValuesToRef(y,S,0,0,-S,y,0,0,0,0,1,0,0,0,0,1,g),g._updateIdentityStatus(y===1&&S===0),g},T.RotationAxis=function(f,g){var S=new T;return T.RotationAxisToRef(f,g,S),S},T.RotationAxisToRef=function(f,g,S){var y=Math.sin(-g),x=Math.cos(-g),R=1-x;f=f.normalizeToRef(b.Vector3[0]);var I=S._m;return I[0]=f._x*f._x*R+x,I[1]=f._x*f._y*R-f._z*y,I[2]=f._x*f._z*R+f._y*y,I[3]=0,I[4]=f._y*f._x*R+f._z*y,I[5]=f._y*f._y*R+x,I[6]=f._y*f._z*R-f._x*y,I[7]=0,I[8]=f._z*f._x*R-f._y*y,I[9]=f._z*f._y*R+f._x*y,I[10]=f._z*f._z*R+x,I[11]=0,I[12]=0,I[13]=0,I[14]=0,I[15]=1,S.markAsUpdated(),S},T.RotationAlignToRef=function(f,g,S,y){y===void 0&&(y=!1);var x=h.Dot(g,f),R=S._m;if(x<-1+i.bH)R[0]=-1,R[1]=0,R[2]=0,R[3]=0,R[4]=0,R[5]=y?1:-1,R[6]=0,R[7]=0,R[8]=0,R[9]=0,R[10]=y?-1:1,R[11]=0;else{var I=h.Cross(g,f),M=1/(1+x);R[0]=I._x*I._x*M+x,R[1]=I._y*I._x*M-I._z,R[2]=I._z*I._x*M+I._y,R[3]=0,R[4]=I._x*I._y*M+I._z,R[5]=I._y*I._y*M+x,R[6]=I._z*I._y*M-I._x,R[7]=0,R[8]=I._x*I._z*M-I._y,R[9]=I._y*I._z*M+I._x,R[10]=I._z*I._z*M+x,R[11]=0}return R[12]=0,R[13]=0,R[14]=0,R[15]=1,S.markAsUpdated(),S},T.RotationYawPitchRoll=function(f,g,S){var y=new T;return T.RotationYawPitchRollToRef(f,g,S,y),y},T.RotationYawPitchRollToRef=function(f,g,S,y){return m.RotationYawPitchRollToRef(f,g,S,b.Quaternion[0]),b.Quaternion[0].toRotationMatrix(y),y},T.Scaling=function(f,g,S){var y=new T;return T.ScalingToRef(f,g,S,y),y},T.ScalingToRef=function(f,g,S,y){return T.FromValuesToRef(f,0,0,0,0,g,0,0,0,0,S,0,0,0,0,1,y),y._updateIdentityStatus(f===1&&g===1&&S===1),y},T.Translation=function(f,g,S){var y=new T;return T.TranslationToRef(f,g,S,y),y},T.TranslationToRef=function(f,g,S,y){return T.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,f,g,S,1,y),y._updateIdentityStatus(f===0&&g===0&&S===0),y},T.Lerp=function(f,g,S){var y=new T;return T.LerpToRef(f,g,S,y),y},T.LerpToRef=function(f,g,S,y){for(var x=y._m,R=f.m,I=g.m,M=0;M<16;M++)x[M]=R[M]*(1-S)+I[M]*S;return y.markAsUpdated(),y},T.DecomposeLerp=function(f,g,S){var y=new T;return T.DecomposeLerpToRef(f,g,S,y),y},T.DecomposeLerpToRef=function(f,g,S,y){var x=b.Vector3[0],R=b.Quaternion[0],I=b.Vector3[1];f.decompose(x,R,I);var M=b.Vector3[2],D=b.Quaternion[1],B=b.Vector3[3];g.decompose(M,D,B);var F=b.Vector3[4];h.LerpToRef(x,M,S,F);var X=b.Quaternion[2];m.SlerpToRef(R,D,S,X);var $=b.Vector3[5];return h.LerpToRef(I,B,S,$),T.ComposeToRef(F,X,$,y),y},T.LookAtLH=function(f,g,S){var y=new T;return T.LookAtLHToRef(f,g,S,y),y},T.LookAtLHToRef=function(f,g,S,y){var x=b.Vector3[0],R=b.Vector3[1],I=b.Vector3[2];g.subtractToRef(f,I),I.normalize(),h.CrossToRef(S,I,x);var M=x.lengthSquared();M===0?x.x=1:x.normalizeFromLength(Math.sqrt(M)),h.CrossToRef(I,x,R),R.normalize();var D=-h.Dot(x,f),B=-h.Dot(R,f),F=-h.Dot(I,f);return T.FromValuesToRef(x._x,R._x,I._x,0,x._y,R._y,I._y,0,x._z,R._z,I._z,0,D,B,F,1,y),y},T.LookAtRH=function(f,g,S){var y=new T;return T.LookAtRHToRef(f,g,S,y),y},T.LookAtRHToRef=function(f,g,S,y){var x=b.Vector3[0],R=b.Vector3[1],I=b.Vector3[2];f.subtractToRef(g,I),I.normalize(),h.CrossToRef(S,I,x);var M=x.lengthSquared();M===0?x.x=1:x.normalizeFromLength(Math.sqrt(M)),h.CrossToRef(I,x,R),R.normalize();var D=-h.Dot(x,f),B=-h.Dot(R,f),F=-h.Dot(I,f);return T.FromValuesToRef(x._x,R._x,I._x,0,x._y,R._y,I._y,0,x._z,R._z,I._z,0,D,B,F,1,y),y},T.LookDirectionLH=function(f,g){var S=new T;return T.LookDirectionLHToRef(f,g,S),S},T.LookDirectionLHToRef=function(f,g,S){var y=b.Vector3[0];y.copyFrom(f),y.scaleInPlace(-1);var x=b.Vector3[1];return h.CrossToRef(g,y,x),T.FromValuesToRef(x._x,x._y,x._z,0,g._x,g._y,g._z,0,y._x,y._y,y._z,0,0,0,0,1,S),S},T.LookDirectionRH=function(f,g){var S=new T;return T.LookDirectionRHToRef(f,g,S),S},T.LookDirectionRHToRef=function(f,g,S){var y=b.Vector3[2];return h.CrossToRef(g,f,y),T.FromValuesToRef(y._x,y._y,y._z,0,g._x,g._y,g._z,0,f._x,f._y,f._z,0,0,0,0,1,S),S},T.OrthoLH=function(f,g,S,y,x){var R=new T;return T.OrthoLHToRef(f,g,S,y,R,x),R},T.OrthoLHToRef=function(f,g,S,y,x,R){var I=2/f,M=2/g,D=2/(y-S),B=-(y+S)/(y-S);return T.FromValuesToRef(I,0,0,0,0,M,0,0,0,0,D,0,0,0,B,1,x),R&&x.multiplyToRef(C,x),x._updateIdentityStatus(I===1&&M===1&&D===1&&B===0),x},T.OrthoOffCenterLH=function(f,g,S,y,x,R,I){var M=new T;return T.OrthoOffCenterLHToRef(f,g,S,y,x,R,M,I),M},T.OrthoOffCenterLHToRef=function(f,g,S,y,x,R,I,M){var D=2/(g-f),B=2/(y-S),F=2/(R-x),X=-(R+x)/(R-x),$=(f+g)/(f-g),Q=(y+S)/(S-y);return T.FromValuesToRef(D,0,0,0,0,B,0,0,0,0,F,0,$,Q,X,1,I),M&&I.multiplyToRef(C,I),I.markAsUpdated(),I},T.ObliqueOffCenterLHToRef=function(f,g,S,y,x,R,I,M,D,B,F){var X=-I*Math.cos(M),$=-I*Math.sin(M);return T.TranslationToRef(0,0,-D,b.Matrix[1]),T.FromValuesToRef(1,0,0,0,0,1,0,0,X,$,1,0,0,0,0,1,b.Matrix[0]),b.Matrix[1].multiplyToRef(b.Matrix[0],b.Matrix[0]),T.TranslationToRef(0,0,D,b.Matrix[1]),b.Matrix[0].multiplyToRef(b.Matrix[1],b.Matrix[0]),T.OrthoOffCenterLHToRef(f,g,S,y,x,R,B,F),b.Matrix[0].multiplyToRef(B,B),B},T.OrthoOffCenterRH=function(f,g,S,y,x,R,I){var M=new T;return T.OrthoOffCenterRHToRef(f,g,S,y,x,R,M,I),M},T.OrthoOffCenterRHToRef=function(f,g,S,y,x,R,I,M){return T.OrthoOffCenterLHToRef(f,g,S,y,x,R,I,M),I._m[10]*=-1,I},T.ObliqueOffCenterRHToRef=function(f,g,S,y,x,R,I,M,D,B,F){var X=I*Math.cos(M),$=I*Math.sin(M);return T.TranslationToRef(0,0,D,b.Matrix[1]),T.FromValuesToRef(1,0,0,0,0,1,0,0,X,$,1,0,0,0,0,1,b.Matrix[0]),b.Matrix[1].multiplyToRef(b.Matrix[0],b.Matrix[0]),T.TranslationToRef(0,0,-D,b.Matrix[1]),b.Matrix[0].multiplyToRef(b.Matrix[1],b.Matrix[0]),T.OrthoOffCenterRHToRef(f,g,S,y,x,R,B,F),b.Matrix[0].multiplyToRef(B,B),B},T.PerspectiveLH=function(f,g,S,y,x,R){R===void 0&&(R=0);var I=new T,M=2*S/f,D=2*S/g,B=(y+S)/(y-S),F=-2*y*S/(y-S),X=Math.tan(R);return T.FromValuesToRef(M,0,0,0,0,D,0,X,0,0,B,1,0,0,F,0,I),x&&I.multiplyToRef(C,I),I._updateIdentityStatus(!1),I},T.PerspectiveFovLH=function(f,g,S,y,x,R,I){R===void 0&&(R=0),I===void 0&&(I=!1);var M=new T;return T.PerspectiveFovLHToRef(f,g,S,y,M,!0,x,R,I),M},T.PerspectiveFovLHToRef=function(f,g,S,y,x,R,I,M,D){R===void 0&&(R=!0),M===void 0&&(M=0),D===void 0&&(D=!1);var B=S,F=y,X=1/Math.tan(.5*f),$=R?X/g:X,Q=R?X:X*g,ie=D&&B===0?-1:F!==0?(F+B)/(F-B):1,q=D&&B===0?2*F:F!==0?-2*F*B/(F-B):-2*B,ee=Math.tan(M);return T.FromValuesToRef($,0,0,0,0,Q,0,ee,0,0,ie,1,0,0,q,0,x),I&&x.multiplyToRef(C,x),x._updateIdentityStatus(!1),x},T.PerspectiveFovReverseLHToRef=function(f,g,S,y,x,R,I,M){R===void 0&&(R=!0),M===void 0&&(M=0);var D=1/Math.tan(.5*f),B=R?D/g:D,F=R?D:D*g,X=Math.tan(M);return T.FromValuesToRef(B,0,0,0,0,F,0,X,0,0,-S,1,0,0,1,0,x),I&&x.multiplyToRef(C,x),x._updateIdentityStatus(!1),x},T.PerspectiveFovRH=function(f,g,S,y,x,R,I){R===void 0&&(R=0),I===void 0&&(I=!1);var M=new T;return T.PerspectiveFovRHToRef(f,g,S,y,M,!0,x,R,I),M},T.PerspectiveFovRHToRef=function(f,g,S,y,x,R,I,M,D){R===void 0&&(R=!0),M===void 0&&(M=0),D===void 0&&(D=!1);var B=S,F=y,X=1/Math.tan(.5*f),$=R?X/g:X,Q=R?X:X*g,ie=D&&B===0?1:F!==0?-(F+B)/(F-B):-1,q=D&&B===0?2*F:F!==0?-2*F*B/(F-B):-2*B,ee=Math.tan(M);return T.FromValuesToRef($,0,0,0,0,Q,0,ee,0,0,ie,-1,0,0,q,0,x),I&&x.multiplyToRef(C,x),x._updateIdentityStatus(!1),x},T.PerspectiveFovReverseRHToRef=function(f,g,S,y,x,R,I,M){R===void 0&&(R=!0),M===void 0&&(M=0);var D=1/Math.tan(.5*f),B=R?D/g:D,F=R?D:D*g,X=Math.tan(M);return T.FromValuesToRef(B,0,0,0,0,F,0,X,0,0,-S,-1,0,0,-1,0,x),I&&x.multiplyToRef(C,x),x._updateIdentityStatus(!1),x},T.GetFinalMatrix=function(f,g,S,y,x,R){var I=f.width,M=f.height,D=f.x,B=f.y,F=T.FromValues(I/2,0,0,0,0,-M/2,0,0,0,0,R-x,0,D+I/2,M/2+B,x,1),X=new T;return g.multiplyToRef(S,X),X.multiplyToRef(y,X),X.multiplyToRef(F,X)},T.GetAsMatrix2x2=function(f){var g=f.m,S=[g[0],g[1],g[4],g[5]];return s.I.MatrixUse64Bits?S:new Float32Array(S)},T.GetAsMatrix3x3=function(f){var g=f.m,S=[g[0],g[1],g[2],g[4],g[5],g[6],g[8],g[9],g[10]];return s.I.MatrixUse64Bits?S:new Float32Array(S)},T.Transpose=function(f){var g=new T;return T.TransposeToRef(f,g),g},T.TransposeToRef=function(f,g){var S=f.m,y=S[0],x=S[4],R=S[8],I=S[12],M=S[1],D=S[5],B=S[9],F=S[13],X=S[2],$=S[6],Q=S[10],ie=S[14],q=S[3],ee=S[7],te=S[11],ce=S[15],fe=g._m;return fe[0]=y,fe[1]=x,fe[2]=R,fe[3]=I,fe[4]=M,fe[5]=D,fe[6]=B,fe[7]=F,fe[8]=X,fe[9]=$,fe[10]=Q,fe[11]=ie,fe[12]=q,fe[13]=ee,fe[14]=te,fe[15]=ce,g.markAsUpdated(),g._updateIdentityStatus(f._isIdentity,f._isIdentityDirty),g},T.Reflection=function(f){var g=new T;return T.ReflectionToRef(f,g),g},T.ReflectionToRef=function(f,g){f.normalize();var S=f.normal.x,y=f.normal.y,x=f.normal.z,R=-2*S,I=-2*y,M=-2*x;return T.FromValuesToRef(R*S+1,I*S,M*S,0,R*y,I*y+1,M*y,0,R*x,I*x,M*x+1,0,R*f.d,I*f.d,M*f.d,1,g),g},T.FromXYZAxesToRef=function(f,g,S,y){return T.FromValuesToRef(f._x,f._y,f._z,0,g._x,g._y,g._z,0,S._x,S._y,S._z,0,0,0,0,1,y),y},T.FromQuaternionToRef=function(f,g){var S=f._x*f._x,y=f._y*f._y,x=f._z*f._z,R=f._x*f._y,I=f._z*f._w,M=f._z*f._x,D=f._y*f._w,B=f._y*f._z,F=f._x*f._w;return g._m[0]=1-2*(y+x),g._m[1]=2*(R+I),g._m[2]=2*(M-D),g._m[3]=0,g._m[4]=2*(R-I),g._m[5]=1-2*(x+S),g._m[6]=2*(B+F),g._m[7]=0,g._m[8]=2*(M+D),g._m[9]=2*(B-F),g._m[10]=1-2*(y+S),g._m[11]=0,g._m[12]=0,g._m[13]=0,g._m[14]=0,g._m[15]=1,g.markAsUpdated(),g},T._UpdateFlagSeed=0,T._IdentityReadOnly=T.Identity(),T}();Object.defineProperties(v.prototype,{dimension:{value:[4,4]},rank:{value:2}});var b=function(){function T(){}return T.Vector3=(0,o.ln)(11,h.Zero),T.Matrix=(0,o.ln)(2,v.Identity),T.Quaternion=(0,o.ln)(3,m.Zero),T}(),E=function(){function T(){}return T.Vector2=(0,o.ln)(3,d.Zero),T.Vector3=(0,o.ln)(13,h.Zero),T.Vector4=(0,o.ln)(3,p.Zero),T.Quaternion=(0,o.ln)(3,m.Zero),T.Matrix=(0,o.ln)(8,v.Identity),T}();(0,a.Y5)("BABYLON.Vector2",d),(0,a.Y5)("BABYLON.Vector3",h),(0,a.Y5)("BABYLON.Vector4",p),(0,a.Y5)("BABYLON.Matrix",v);var C=v.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1)},25187:(r,t,e)=>{e.d(t,{L:()=>n});var n=function(){function i(o,a,s,l){this.x=o,this.y=a,this.width=s,this.height=l}return i.prototype.toGlobal=function(o,a){return new i(this.x*o,this.y*a,this.width*o,this.height*a)},i.prototype.toGlobalToRef=function(o,a,s){return s.x=this.x*o,s.y=this.y*a,s.width=this.width*o,s.height=this.height*a,this},i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height)},i}()},51428:(r,t,e)=>{e.d(t,{O:()=>c,Q:()=>u});var n=e(8046),i=e(51322),o=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],a=[function(){return 1},function(d){return d.y},function(d){return d.z},function(d){return d.x},function(d){return d.x*d.y},function(d){return d.y*d.z},function(d){return 3*d.z*d.z-1},function(d){return d.x*d.z},function(d){return d.x*d.x-d.y*d.y}],s=function(d,h){return o[d]*a[d](h)},l=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4],c=function(){function d(){this.preScaled=!1,this.l00=n.Pq.Zero(),this.l1_1=n.Pq.Zero(),this.l10=n.Pq.Zero(),this.l11=n.Pq.Zero(),this.l2_2=n.Pq.Zero(),this.l2_1=n.Pq.Zero(),this.l20=n.Pq.Zero(),this.l21=n.Pq.Zero(),this.l22=n.Pq.Zero()}return d.prototype.addLight=function(h,p,m){i.AA.Vector3[0].set(p.r,p.g,p.b);var v=i.AA.Vector3[0],b=i.AA.Vector3[1];v.scaleToRef(m,b),b.scaleToRef(s(0,h),i.AA.Vector3[2]),this.l00.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(1,h),i.AA.Vector3[2]),this.l1_1.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(2,h),i.AA.Vector3[2]),this.l10.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(3,h),i.AA.Vector3[2]),this.l11.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(4,h),i.AA.Vector3[2]),this.l2_2.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(5,h),i.AA.Vector3[2]),this.l2_1.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(6,h),i.AA.Vector3[2]),this.l20.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(7,h),i.AA.Vector3[2]),this.l21.addInPlace(i.AA.Vector3[2]),b.scaleToRef(s(8,h),i.AA.Vector3[2]),this.l22.addInPlace(i.AA.Vector3[2])},d.prototype.scaleInPlace=function(h){this.l00.scaleInPlace(h),this.l1_1.scaleInPlace(h),this.l10.scaleInPlace(h),this.l11.scaleInPlace(h),this.l2_2.scaleInPlace(h),this.l2_1.scaleInPlace(h),this.l20.scaleInPlace(h),this.l21.scaleInPlace(h),this.l22.scaleInPlace(h)},d.prototype.convertIncidentRadianceToIrradiance=function(){this.l00.scaleInPlace(l[0]),this.l1_1.scaleInPlace(l[1]),this.l10.scaleInPlace(l[2]),this.l11.scaleInPlace(l[3]),this.l2_2.scaleInPlace(l[4]),this.l2_1.scaleInPlace(l[5]),this.l20.scaleInPlace(l[6]),this.l21.scaleInPlace(l[7]),this.l22.scaleInPlace(l[8])},d.prototype.convertIrradianceToLambertianRadiance=function(){this.scaleInPlace(1/Math.PI)},d.prototype.preScaleForRendering=function(){this.preScaled=!0,this.l00.scaleInPlace(o[0]),this.l1_1.scaleInPlace(o[1]),this.l10.scaleInPlace(o[2]),this.l11.scaleInPlace(o[3]),this.l2_2.scaleInPlace(o[4]),this.l2_1.scaleInPlace(o[5]),this.l20.scaleInPlace(o[6]),this.l21.scaleInPlace(o[7]),this.l22.scaleInPlace(o[8])},d.prototype.updateFromArray=function(h){return n.Pq.FromArrayToRef(h[0],0,this.l00),n.Pq.FromArrayToRef(h[1],0,this.l1_1),n.Pq.FromArrayToRef(h[2],0,this.l10),n.Pq.FromArrayToRef(h[3],0,this.l11),n.Pq.FromArrayToRef(h[4],0,this.l2_2),n.Pq.FromArrayToRef(h[5],0,this.l2_1),n.Pq.FromArrayToRef(h[6],0,this.l20),n.Pq.FromArrayToRef(h[7],0,this.l21),n.Pq.FromArrayToRef(h[8],0,this.l22),this},d.prototype.updateFromFloatsArray=function(h){return n.Pq.FromFloatsToRef(h[0],h[1],h[2],this.l00),n.Pq.FromFloatsToRef(h[3],h[4],h[5],this.l1_1),n.Pq.FromFloatsToRef(h[6],h[7],h[8],this.l10),n.Pq.FromFloatsToRef(h[9],h[10],h[11],this.l11),n.Pq.FromFloatsToRef(h[12],h[13],h[14],this.l2_2),n.Pq.FromFloatsToRef(h[15],h[16],h[17],this.l2_1),n.Pq.FromFloatsToRef(h[18],h[19],h[20],this.l20),n.Pq.FromFloatsToRef(h[21],h[22],h[23],this.l21),n.Pq.FromFloatsToRef(h[24],h[25],h[26],this.l22),this},d.FromArray=function(h){return new d().updateFromArray(h)},d.FromPolynomial=function(h){var p=new d;return p.l00=h.xx.scale(.376127).add(h.yy.scale(.376127)).add(h.zz.scale(.376126)),p.l1_1=h.y.scale(.977204),p.l10=h.z.scale(.977204),p.l11=h.x.scale(.977204),p.l2_2=h.xy.scale(1.16538),p.l2_1=h.yz.scale(1.16538),p.l20=h.zz.scale(1.34567).subtract(h.xx.scale(.672834)).subtract(h.yy.scale(.672834)),p.l21=h.zx.scale(1.16538),p.l22=h.xx.scale(1.16538).subtract(h.yy.scale(1.16538)),p.l1_1.scaleInPlace(-1),p.l11.scaleInPlace(-1),p.l2_1.scaleInPlace(-1),p.l21.scaleInPlace(-1),p.scaleInPlace(Math.PI),p},d}(),u=function(){function d(){this.x=n.Pq.Zero(),this.y=n.Pq.Zero(),this.z=n.Pq.Zero(),this.xx=n.Pq.Zero(),this.yy=n.Pq.Zero(),this.zz=n.Pq.Zero(),this.xy=n.Pq.Zero(),this.yz=n.Pq.Zero(),this.zx=n.Pq.Zero()}return Object.defineProperty(d.prototype,"preScaledHarmonics",{get:function(){return this._harmonics||(this._harmonics=c.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics},enumerable:!1,configurable:!0}),d.prototype.addAmbient=function(h){i.AA.Vector3[0].copyFromFloats(h.r,h.g,h.b);var p=i.AA.Vector3[0];this.xx.addInPlace(p),this.yy.addInPlace(p),this.zz.addInPlace(p)},d.prototype.scaleInPlace=function(h){this.x.scaleInPlace(h),this.y.scaleInPlace(h),this.z.scaleInPlace(h),this.xx.scaleInPlace(h),this.yy.scaleInPlace(h),this.zz.scaleInPlace(h),this.yz.scaleInPlace(h),this.zx.scaleInPlace(h),this.xy.scaleInPlace(h)},d.prototype.updateFromHarmonics=function(h){return this._harmonics=h,this.x.copyFrom(h.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(h.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(h.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(h.l00),i.AA.Vector3[0].copyFrom(h.l20).scaleInPlace(.247708),i.AA.Vector3[1].copyFrom(h.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(i.AA.Vector3[0]).addInPlace(i.AA.Vector3[1]),this.yy.copyFrom(h.l00),this.yy.scaleInPlace(.886277).subtractInPlace(i.AA.Vector3[0]).subtractInPlace(i.AA.Vector3[1]),this.zz.copyFrom(h.l00),i.AA.Vector3[0].copyFrom(h.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(i.AA.Vector3[0]),this.yz.copyFrom(h.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(h.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(h.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this},d.FromHarmonics=function(h){return new d().updateFromHarmonics(h)},d.FromArray=function(h){var p=new d;return n.Pq.FromArrayToRef(h[0],0,p.x),n.Pq.FromArrayToRef(h[1],0,p.y),n.Pq.FromArrayToRef(h[2],0,p.z),n.Pq.FromArrayToRef(h[3],0,p.xx),n.Pq.FromArrayToRef(h[4],0,p.yy),n.Pq.FromArrayToRef(h[5],0,p.zz),n.Pq.FromArrayToRef(h[6],0,p.yz),n.Pq.FromArrayToRef(h[7],0,p.zx),n.Pq.FromArrayToRef(h[8],0,p.xy),p},d}()},26218:(r,t,e)=>{e.d(t,{A:()=>i});var n=e(78322),i=function(o){function a(s){var l=o.call(this)||this;return l._buffer=s,l}return(0,n.C6)(a,o),Object.defineProperty(a.prototype,"underlyingResource",{get:function(){return this._buffer},enumerable:!1,configurable:!0}),a}(e(37943).n)},75768:(r,t,e)=>{e.d(t,{d:()=>u});var n=e(8046),i=e(48810),o=e(51428),a=e(81152),s=e(56740),l=e(64726),c=function(d,h,p,m){this.name=d,this.worldAxisForNormal=h,this.worldAxisForFileX=p,this.worldAxisForFileY=m},u=function(){function d(){}return d.ConvertCubeMapTextureToSphericalPolynomial=function(h){var p,m=this;if(!h.isCube)return null;(p=h.getScene())===null||p===void 0||p.getEngine().flushFramebuffer();var v,b,E=h.getSize().width,C=h.readPixels(0,void 0,void 0,!1),T=h.readPixels(1,void 0,void 0,!1);h.isRenderTarget?(v=h.readPixels(3,void 0,void 0,!1),b=h.readPixels(2,void 0,void 0,!1)):(v=h.readPixels(2,void 0,void 0,!1),b=h.readPixels(3,void 0,void 0,!1));var f=h.readPixels(4,void 0,void 0,!1),g=h.readPixels(5,void 0,void 0,!1),S=h.gammaSpace,y=a.Y.TEXTUREFORMAT_RGBA,x=a.Y.TEXTURETYPE_UNSIGNED_INT;return h.textureType!=a.Y.TEXTURETYPE_FLOAT&&h.textureType!=a.Y.TEXTURETYPE_HALF_FLOAT||(x=a.Y.TEXTURETYPE_FLOAT),new Promise(function(R){Promise.all([T,C,v,b,f,g]).then(function(I){var M=I[0],D=I[1],B=I[2],F=I[3],X=I[4],$=I[5],Q={size:E,right:D,left:M,up:B,down:F,front:X,back:$,format:y,type:x,gammaSpace:S};R(m.ConvertCubeMapToSphericalPolynomial(Q))})})},d._AreaElement=function(h,p){return Math.atan2(h*p,Math.sqrt(h*h+p*p+1))},d.ConvertCubeMapToSphericalPolynomial=function(h){for(var p=new o.O,m=0,v=2/h.size,b=v,E=.5*v,C=E-1,T=0;T<6;T++)for(var f=this._FileFaces[T],g=h[f.name],S=C,y=h.format===a.Y.TEXTUREFORMAT_RGBA?4:3,x=0;x<h.size;x++){for(var R=C,I=0;I<h.size;I++){var M=f.worldAxisForFileX.scale(R).add(f.worldAxisForFileY.scale(S)).add(f.worldAxisForNormal);M.normalize();var D=this._AreaElement(R-E,S-E)-this._AreaElement(R-E,S+E)-this._AreaElement(R+E,S-E)+this._AreaElement(R+E,S+E),B=g[x*h.size*y+I*y+0],F=g[x*h.size*y+I*y+1],X=g[x*h.size*y+I*y+2];isNaN(B)&&(B=0),isNaN(F)&&(F=0),isNaN(X)&&(X=0),h.type===a.Y.TEXTURETYPE_UNSIGNED_INT&&(B/=255,F/=255,X/=255),h.gammaSpace&&(B=Math.pow((0,i.Clamp)(B),s.tk),F=Math.pow((0,i.Clamp)(F),s.tk),X=Math.pow((0,i.Clamp)(X),s.tk));var $=this.MAX_HDRI_VALUE;if(this.PRESERVE_CLAMPED_COLORS){var Q=Math.max(B,F,X);if(Q>$){var ie=$/Q;B*=ie,F*=ie,X*=ie}}else B=(0,i.Clamp)(B,0,$),F=(0,i.Clamp)(F,0,$),X=(0,i.Clamp)(X,0,$);var q=new l.v9(B,F,X);p.addLight(M,q,D),m+=D,R+=v}S+=b}var ee=4*Math.PI*6/6/m;return p.scaleInPlace(ee),p.convertIncidentRadianceToIrradiance(),p.convertIrradianceToLambertianRadiance(),o.Q.FromHarmonics(p)},d._FileFaces=[new c("right",new n.Pq(1,0,0),new n.Pq(0,0,-1),new n.Pq(0,-1,0)),new c("left",new n.Pq(-1,0,0),new n.Pq(0,0,1),new n.Pq(0,-1,0)),new c("up",new n.Pq(0,1,0),new n.Pq(1,0,0),new n.Pq(0,0,1)),new c("down",new n.Pq(0,-1,0),new n.Pq(1,0,0),new n.Pq(0,0,-1)),new c("front",new n.Pq(0,0,1),new n.Pq(1,0,0),new n.Pq(0,-1,0)),new c("back",new n.Pq(0,0,-1),new n.Pq(-1,0,0),new n.Pq(0,-1,0))],d.MAX_HDRI_VALUE=4096,d.PRESERVE_CLAMPED_COLORS=!1,d}()},51967:(r,t,e)=>{e.d(t,{I9:()=>u,LT:()=>l,NK:()=>a,VH:()=>s});var n=e(16814);function i(d,h,p,m,v,b){v>0?(v=function(E,C){return C>1023?1*Math.pow(2,1023)*Math.pow(2,C-1023):C<-1074?1*Math.pow(2,-1074)*Math.pow(2,C+1074):1*Math.pow(2,C)}(0,v-136),d[b+0]=h*v,d[b+1]=p*v,d[b+2]=m*v):(d[b+0]=0,d[b+1]=0,d[b+2]=0)}function o(d,h){for(var p="",m="",v=h;v<d.length-h&&(m=String.fromCharCode(d[v]))!=`
|
||
`;v++)p+=m;return p}function a(d){var h,p,m=o(d,0);if(m[0]!="#"||m[1]!="?")throw"Bad HDR Format.";var v=!1,b=!1,E=0;do(m=o(d,E+=m.length+1))=="FORMAT=32-bit_rle_rgbe"?b=!0:m.length==0&&(v=!0);while(!v);if(!b)throw"HDR Bad header format, unsupported FORMAT";m=o(d,E+=m.length+1);var C=/^-Y (.*) \+X (.*)$/g.exec(m);if(!C||C.length<3)throw"HDR Bad header format, no size";if(p=parseInt(C[2]),h=parseInt(C[1]),p<8||p>32767)throw"HDR Bad header format, unsupported size";return{height:h,width:p,dataPosition:E+=m.length+1}}function s(d,h,p){p===void 0&&(p=!1);var m=new Uint8Array(d),v=a(m),b=l(m,v);return n.D.ConvertPanoramaToCubemap(b,v.width,v.height,h,p)}function l(d,h){return function(p,m){for(var v,b,E,C,T,f=m.height,g=m.width,S=m.dataPosition,y=0,x=0,R=0,I=new ArrayBuffer(4*g),M=new Uint8Array(I),D=new ArrayBuffer(m.width*m.height*4*3),B=new Float32Array(D);f>0;){if(v=p[S++],b=p[S++],E=p[S++],C=p[S++],v!=2||b!=2||128&E||m.width<8||m.width>32767)return c(p,m);if((E<<8|C)!=g)throw"HDR Bad header format, wrong scan line width";for(y=0,R=0;R<4;R++)for(x=(R+1)*g;y<x;)if(v=p[S++],b=p[S++],v>128){if((T=v-128)==0||T>x-y)throw"HDR Bad Format, bad scanline data (run)";for(;T-- >0;)M[y++]=b}else{if((T=v)==0||T>x-y)throw"HDR Bad Format, bad scanline data (non-run)";if(M[y++]=b,--T>0)for(var F=0;F<T;F++)M[y++]=p[S++]}for(R=0;R<g;R++)i(B,v=M[R],b=M[R+g],E=M[R+2*g],C=M[R+3*g],(m.height-f)*g*3+3*R);f--}return B}(d,h)}function c(d,h){for(var p,m=h.height,v=h.width,b=h.dataPosition,E=new ArrayBuffer(h.width*h.height*4*3),C=new Float32Array(E);m>0;){for(p=0;p<h.width;p++)i(C,d[b++],d[b++],d[b++],d[b++],(h.height-m)*v*3+3*p);m--}return C}var u={RGBE_ReadHeader:a,GetCubeMapTextureData:s,RGBE_ReadPixels:l}},16814:(r,t,e)=>{e.d(t,{D:()=>o});var n=e(8046),i=e(81152),o=function(){function a(){}return a.ConvertPanoramaToCubemap=function(s,l,c,u,d){if(d===void 0&&(d=!1),!s)throw"ConvertPanoramaToCubemap: input cannot be null";if(s.length!=l*c*3)throw"ConvertPanoramaToCubemap: input size is wrong";return{front:this.CreateCubemapTexture(u,this.FACE_FRONT,s,l,c,d),back:this.CreateCubemapTexture(u,this.FACE_BACK,s,l,c,d),left:this.CreateCubemapTexture(u,this.FACE_LEFT,s,l,c,d),right:this.CreateCubemapTexture(u,this.FACE_RIGHT,s,l,c,d),up:this.CreateCubemapTexture(u,this.FACE_UP,s,l,c,d),down:this.CreateCubemapTexture(u,this.FACE_DOWN,s,l,c,d),size:u,type:i.Y.TEXTURETYPE_FLOAT,format:i.Y.TEXTUREFORMAT_RGB,gammaSpace:!1}},a.CreateCubemapTexture=function(s,l,c,u,d,h){h===void 0&&(h=!1);for(var p=new ArrayBuffer(s*s*4*3),m=new Float32Array(p),v=h?Math.max(1,Math.round(u/4/s)):1,b=1/v,E=b*b,C=l[1].subtract(l[0]).scale(b/s),T=l[3].subtract(l[2]).scale(b/s),f=1/s,g=0,S=0;S<s;S++)for(var y=0;y<v;y++){for(var x=l[0],R=l[2],I=0;I<s;I++)for(var M=0;M<v;M++){var D=R.subtract(x).scale(g).add(x);D.normalize();var B=this.CalcProjectionSpherical(D,c,u,d);m[S*s*3+3*I+0]+=B.r*E,m[S*s*3+3*I+1]+=B.g*E,m[S*s*3+3*I+2]+=B.b*E,x=x.add(C),R=R.add(T)}g+=f*b}return m},a.CalcProjectionSpherical=function(s,l,c,u){for(var d=Math.atan2(s.z,s.x),h=Math.acos(s.y);d<-Math.PI;)d+=2*Math.PI;for(;d>Math.PI;)d-=2*Math.PI;var p=d/Math.PI,m=h/Math.PI;p=.5*p+.5;var v=Math.round(p*c);v<0?v=0:v>=c&&(v=c-1);var b=Math.round(m*u);b<0?b=0:b>=u&&(b=u-1);var E=u-b-1;return{r:l[E*c*3+3*v+0],g:l[E*c*3+3*v+1],b:l[E*c*3+3*v+2]}},a.FACE_LEFT=[new n.Pq(-1,-1,-1),new n.Pq(1,-1,-1),new n.Pq(-1,1,-1),new n.Pq(1,1,-1)],a.FACE_RIGHT=[new n.Pq(1,-1,1),new n.Pq(-1,-1,1),new n.Pq(1,1,1),new n.Pq(-1,1,1)],a.FACE_FRONT=[new n.Pq(1,-1,-1),new n.Pq(1,-1,1),new n.Pq(1,1,-1),new n.Pq(1,1,1)],a.FACE_BACK=[new n.Pq(-1,-1,1),new n.Pq(-1,-1,-1),new n.Pq(-1,1,1),new n.Pq(-1,1,-1)],a.FACE_DOWN=[new n.Pq(1,1,-1),new n.Pq(1,1,1),new n.Pq(-1,1,-1),new n.Pq(-1,1,1)],a.FACE_UP=[new n.Pq(-1,-1,-1),new n.Pq(-1,-1,1),new n.Pq(1,-1,-1),new n.Pq(1,-1,1)],a}()},92548:(r,t,e)=>{e.d(t,{Z:()=>n});var n=function(){function i(){}return i.Eval=function(o,a){return(o=o.match(/\([^()]*\)/g)?o.replace(/\([^()]*\)/g,function(s){return s=s.slice(1,s.length-1),i._HandleParenthesisContent(s,a)}):i._HandleParenthesisContent(o,a))==="true"||o!=="false"&&i.Eval(o,a)},i._HandleParenthesisContent=function(o,a){var s;a=a||function(m){return m==="true"};var l=o.split("||");for(var c in l)if(Object.prototype.hasOwnProperty.call(l,c)){var u=i._SimplifyNegation(l[c].trim()),d=u.split("&&");if(d.length>1)for(var h=0;h<d.length;++h){var p=i._SimplifyNegation(d[h].trim());if(!(s=p!=="true"&&p!=="false"?p[0]==="!"?!a(p.substring(1)):a(p):p==="true")){u="false";break}}if(s||u==="true"){s=!0;break}s=u!=="true"&&u!=="false"?u[0]==="!"?!a(u.substring(1)):a(u):u==="true"}return s?"true":"false"},i._SimplifyNegation=function(o){return(o=(o=o.replace(/^[\s!]+/,function(a){return(a=a.replace(/[\s]/g,function(){return""})).length%2?"!":""})).trim())==="!true"?o="false":o==="!false"&&(o="true"),o},i}()},11296:(r,t,e)=>{function n(s,l){for(var c=[],u=0;u<s;++u)c.push(l());return c}function i(s,l){return n(s,l)}e.d(t,{lL:()=>a,ln:()=>i,mI:()=>n});var o=["push","splice","pop","shift","unshift"];function a(s,l){var c=o.map(function(u){return function(d,h,p){var m=d[h];if(typeof m!="function")return null;var v=function(){var b=d.length,E=v.previous.apply(d,arguments);return p(h,b),E};return m.next=v,v.previous=m,d[h]=v,function(){var b=v.previous;if(b){var E=v.next;E?(b.next=E,E.previous=b):(b.next=void 0,d[h]=b),v.next=void 0,v.previous=void 0}}}(s,u,l)});return function(){c.forEach(function(u){u?.()})}}},82941:(r,t,e)=>{e.d(t,{$e:()=>c,ED:()=>f,Sl:()=>d,SV:()=>u,yT:()=>h,aB:()=>T,af:()=>b,yk:()=>E});var n=e(44957),i=e(50582),o=e(19133),a=e(81152);function s(){var g=null;function S(y,x,R,I,M){var D=y.getImageTranscodedSizeInBytes(x,R,I),B=new Uint8Array(D);return y.transcodeImage(B,x,R,I,1,0)?(M&&(B=function(F,X,$,Q){for(var ie=new Uint16Array(4),q=new Uint16Array($*Q),ee=$/4,te=Q/4,ce=0;ce<te;ce++)for(var fe=0;fe<ee;fe++){var de=0+8*(ce*ee+fe);ie[0]=F[de]|F[de+1]<<8,ie[1]=F[de+2]|F[de+3]<<8,ie[2]=(2*(31&ie[0])+1*(31&ie[1]))/3|(2*(2016&ie[0])+1*(2016&ie[1]))/3&2016|(2*(63488&ie[0])+1*(63488&ie[1]))/3&63488,ie[3]=(2*(31&ie[1])+1*(31&ie[0]))/3|(2*(2016&ie[1])+1*(2016&ie[0]))/3&2016|(2*(63488&ie[1])+1*(63488&ie[0]))/3&63488;for(var Te=0;Te<4;Te++){var ue=F[de+4+Te],U=(4*ce+Te)*$+4*fe;q[U++]=ie[3&ue],q[U++]=ie[ue>>2&3],q[U++]=ie[ue>>4&3],q[U++]=ie[ue>>6&3]}}return q}(B,0,y.getImageWidth(x,R)+3&-4,y.getImageHeight(x,R)+3&-4)),B):null}onmessage=function(y){if(y.data.action==="init"){if(y.data.url)try{importScripts(y.data.url)}catch(ce){postMessage({action:"error",error:ce})}g||(g=BASIS({wasmBinary:y.data.wasmBinary})),g!==null&&g.then(function(ce){BASIS=ce,ce.initializeBasis(),postMessage({action:"init"})})}else if(y.data.action==="transcode"){var x=y.data.config,R=y.data.imageData,I=new BASIS.BasisFile(R),M=function(ce){for(var fe=ce.getHasAlpha(),de=ce.getNumImages(),Te=[],ue=0;ue<de;ue++){for(var U={levels:[]},N=ce.getNumLevels(ue),w=0;w<N;w++){var k={width:ce.getImageWidth(ue,w),height:ce.getImageHeight(ue,w)};U.levels.push(k)}Te.push(U)}return{hasAlpha:fe,images:Te}}(I),D=y.data.ignoreSupportedFormats?null:function(ce,fe){var de=null;return ce.supportedCompressionFormats&&(de=ce.supportedCompressionFormats.astc?10:ce.supportedCompressionFormats.bc7?6:ce.supportedCompressionFormats.s3tc?fe.hasAlpha?3:2:ce.supportedCompressionFormats.pvrtc?fe.hasAlpha?9:8:ce.supportedCompressionFormats.etc2?1:ce.supportedCompressionFormats.etc1?0:14),de}(y.data.config,M),B=!1;D===null&&(B=!0,D=M.hasAlpha?3:2);var F=!0;I.startTranscoding()||(F=!1);for(var X=[],$=0;$<M.images.length&&F;$++){var Q=M.images[$];if(x.loadSingleImage===void 0||x.loadSingleImage===$){var ie=Q.levels.length;x.loadMipmapLevels===!1&&(ie=1);for(var q=0;q<ie;q++){var ee=Q.levels[q],te=S(I,$,q,D,B);if(!te){F=!1;break}ee.transcodedPixels=te,X.push(ee.transcodedPixels.buffer)}}}I.close(),I.delete(),B&&(D=-1),F?postMessage({action:"transcode",success:F,id:y.data.id,fileInfo:M,format:D},X):postMessage({action:"transcode",success:F,id:y.data.id})}}}var l,c=function(){},u=function(){};(function(g){g[g.cTFETC1=0]="cTFETC1",g[g.cTFETC2=1]="cTFETC2",g[g.cTFBC1=2]="cTFBC1",g[g.cTFBC3=3]="cTFBC3",g[g.cTFBC4=4]="cTFBC4",g[g.cTFBC5=5]="cTFBC5",g[g.cTFBC7=6]="cTFBC7",g[g.cTFPVRTC1_4_RGB=8]="cTFPVRTC1_4_RGB",g[g.cTFPVRTC1_4_RGBA=9]="cTFPVRTC1_4_RGBA",g[g.cTFASTC_4x4=10]="cTFASTC_4x4",g[g.cTFATC_RGB=11]="cTFATC_RGB",g[g.cTFATC_RGBA_INTERPOLATED_ALPHA=12]="cTFATC_RGBA_INTERPOLATED_ALPHA",g[g.cTFRGBA32=13]="cTFRGBA32",g[g.cTFRGB565=14]="cTFRGB565",g[g.cTFBGR565=15]="cTFBGR565",g[g.cTFRGBA4444=16]="cTFRGBA4444",g[g.cTFFXT1_RGB=17]="cTFFXT1_RGB",g[g.cTFPVRTC2_4_RGB=18]="cTFPVRTC2_4_RGB",g[g.cTFPVRTC2_4_RGBA=19]="cTFPVRTC2_4_RGBA",g[g.cTFETC2_EAC_R11=20]="cTFETC2_EAC_R11",g[g.cTFETC2_EAC_RG11=21]="cTFETC2_EAC_RG11"})(l||(l={}));var d={JSModuleURL:"".concat(n.S0._DefaultCdnUrl,"/basisTranscoder/1/basis_transcoder.js"),WasmModuleURL:"".concat(n.S0._DefaultCdnUrl,"/basisTranscoder/1/basis_transcoder.wasm")},h=function(g,S){var y;switch(g){case l.cTFETC1:y=a.Y.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL;break;case l.cTFBC1:y=a.Y.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;break;case l.cTFBC4:y=a.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;break;case l.cTFASTC_4x4:y=a.Y.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;break;case l.cTFETC2:y=a.Y.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;break;case l.cTFBC7:y=a.Y.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM}if(y===void 0)throw"The chosen Basis transcoder format is not currently supported";return y},p=null,m=null,v=0,b=function(g){m=g},E=function(g,S){var y=g instanceof ArrayBuffer?new Uint8Array(g):g;return new Promise(function(x,R){(p||(p=new Promise(function(I,M){m?I(m):n.S0.LoadFileAsync(n.S0.GetBabylonScriptURL(d.WasmModuleURL)).then(function(D){if(typeof URL!="function")return M("Basis transcoder requires an environment with a URL constructor");var B=URL.createObjectURL(new Blob(["(".concat(s,")()")],{type:"application/javascript"}));(function(F,X,$){return new Promise(function(Q,ie){var q=function(ee){ee.data.action==="init"?(F.removeEventListener("message",q),Q(F)):ee.data.action==="error"&&ie(ee.data.error||"error initializing worker")};F.addEventListener("message",q),F.postMessage({action:"init",url:$?n.S0.GetBabylonScriptURL($):void 0,wasmBinary:X},[X])})})(m=new Worker(B),D,d.JSModuleURL).then(I,M)}).catch(M)})),p).then(function(){var I=v++,M=function(B){B.data.action==="transcode"&&B.data.id===I&&(m.removeEventListener("message",M),B.data.success?x(B.data):R("Transcode is not supported on this device"))};m.addEventListener("message",M);var D=new Uint8Array(y.byteLength);D.set(new Uint8Array(y.buffer,y.byteOffset,y.byteLength)),m.postMessage({action:"transcode",id:I,imageData:D,config:S,ignoreSupportedFormats:!1},[D.buffer])},function(I){R(I)})})},C=function(g,S){var y,x,R=(y=S._gl)===null||y===void 0?void 0:y.TEXTURE_2D;g.isCube&&(R=(x=S._gl)===null||x===void 0?void 0:x.TEXTURE_CUBE_MAP),S._bindTextureDirectly(R,g,!0)},T=function(g,S){for(var y=g.getEngine(),x=function(I){var M=S.fileInfo.images[I].levels[0];if(g._invertVScale=g.invertY,S.format===-1||S.format===l.cTFRGB565)if(g.type=a.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,g.format=a.Y.TEXTUREFORMAT_RGB,!y._features.basisNeedsPOT||Math.log2(M.width)%1==0&&Math.log2(M.height)%1==0)g._invertVScale=!g.invertY,g.width=M.width+3&-4,g.height=M.height+3&-4,g.samplingMode=a.Y.TEXTURE_LINEAR_LINEAR,C(g,y),y._uploadDataToTextureDirectly(g,new Uint16Array(M.transcodedPixels.buffer),I,0,a.Y.TEXTUREFORMAT_RGB,!0);else{var D=new o.h(y,2);g._invertVScale=g.invertY,D.type=a.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,D.format=a.Y.TEXTUREFORMAT_RGB,D.width=M.width+3&-4,D.height=M.height+3&-4,C(D,y),y._uploadDataToTextureDirectly(D,new Uint16Array(M.transcodedPixels.buffer),I,0,a.Y.TEXTUREFORMAT_RGB,!0),y._rescaleTexture(D,g,y.scenes[0],y._getInternalFormat(a.Y.TEXTUREFORMAT_RGB),function(){y._releaseTexture(D),C(g,y)})}else{g.width=M.width,g.height=M.height,g.generateMipMaps=S.fileInfo.images[I].levels.length>1;var B=f.GetInternalFormatFromBasisFormat(S.format,y);g.format=B,C(g,y),S.fileInfo.images[I].levels.forEach(function(F,X){y._uploadCompressedDataToTextureDirectly(g,B,F.width,F.height,F.transcodedPixels,I,X)}),!y._features.basisNeedsPOT||Math.log2(g.width)%1==0&&Math.log2(g.height)%1==0||(n.S0.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."),g._cachedWrapU=i.g.CLAMP_ADDRESSMODE,g._cachedWrapV=i.g.CLAMP_ADDRESSMODE)}},R=0;R<S.fileInfo.images.length;R++)x(R)},f={JSModuleURL:d.JSModuleURL,WasmModuleURL:d.WasmModuleURL,GetInternalFormatFromBasisFormat:h,TranscodeAsync:E,LoadTextureFromTranscodeResult:T};Object.defineProperty(f,"JSModuleURL",{get:function(){return d.JSModuleURL},set:function(g){d.JSModuleURL=g}}),Object.defineProperty(f,"WasmModuleURL",{get:function(){return d.WasmModuleURL},set:function(g){d.WasmModuleURL=g}})},75838:(r,t,e)=>{e.d(t,{D8:()=>s,c9:()=>i,lP:()=>o,nh:()=>a});var n=e(78322);function i(l,c,u){u===void 0&&(u=!1);var d=c.width,h=c.height;if(l instanceof Float32Array){for(var p=l.byteLength/l.BYTES_PER_ELEMENT,m=new Uint8Array(p);--p>=0;){var v=l[p];v<0?v=0:v>1&&(v=1),m[p]=255*v}l=m}var b=document.createElement("canvas");b.width=d,b.height=h;var E=b.getContext("2d");if(!E)return null;var C=E.createImageData(d,h);if(C.data.set(l),E.putImageData(C,0,0),u){var T=document.createElement("canvas");T.width=d,T.height=h;var f=T.getContext("2d");return f?(f.translate(0,h),f.scale(1,-1),f.drawImage(b,0,0),T.toDataURL("image/png")):null}return b.toDataURL("image/png")}function o(l,c,u){c===void 0&&(c=0),u===void 0&&(u=0);var d=l.getInternalTexture();if(!d)return null;var h=l._readPixelsSync(c,u);return h?i(h,l.getSize(),d.invertY):null}function a(l,c,u){return c===void 0&&(c=0),u===void 0&&(u=0),(0,n.sH)(this,void 0,void 0,function(){var d,h;return(0,n.YH)(this,function(p){switch(p.label){case 0:return(d=l.getInternalTexture())?[4,l.readPixels(c,u)]:[2,null];case 1:return(h=p.sent())?[2,i(h,l.getSize(),d.invertY)]:[2,null]}})})}var s={GenerateBase64StringFromPixelData:i,GenerateBase64StringFromTexture:o,GenerateBase64StringFromTextureAsync:a}},49611:(r,t,e)=>{e.d(t,{D:()=>v});var n=e(48810),i=e(81152),o=e(7164),a=e(75768),s=e(35877),l=(e(19966),e(71974),131072),c=131072;function u(b){return b.charCodeAt(0)+(b.charCodeAt(1)<<8)+(b.charCodeAt(2)<<16)+(b.charCodeAt(3)<<24)}var d=u("DXT1"),h=u("DXT3"),p=u("DXT5"),m=u("DX10"),v=function(){function b(){}return b.GetDDSInfo=function(E){var C=new Int32Array(E.buffer,E.byteOffset,31),T=new Int32Array(E.buffer,E.byteOffset,35),f=1;C[2]&l&&(f=Math.max(1,C[7]));var g=C[21],S=g===m?T[32]:0,y=i.Y.TEXTURETYPE_UNSIGNED_INT;switch(g){case 113:y=i.Y.TEXTURETYPE_HALF_FLOAT;break;case 116:y=i.Y.TEXTURETYPE_FLOAT;break;case m:if(S===10){y=i.Y.TEXTURETYPE_HALF_FLOAT;break}if(S===2){y=i.Y.TEXTURETYPE_FLOAT;break}}return{width:C[4],height:C[3],mipmapCount:f,isFourCC:!(4&~C[20]),isRGB:!(64&~C[20]),isLuminance:(C[20]&c)===c,isCube:!(512&~C[28]),isCompressed:g===d||g===h||g===p,dxgiFormat:S,textureType:y}},b._GetHalfFloatAsFloatRGBAArrayBuffer=function(E,C,T,f,g,S){for(var y=new Float32Array(f),x=new Uint16Array(g,T),R=0,I=0;I<C;I++)for(var M=0;M<E;M++){var D=4*(M+I*E);y[R]=(0,s.SX)(x[D]),y[R+1]=(0,s.SX)(x[D+1]),y[R+2]=(0,s.SX)(x[D+2]),b.StoreLODInAlphaChannel?y[R+3]=S:y[R+3]=(0,s.SX)(x[D+3]),R+=4}return y},b._GetHalfFloatRGBAArrayBuffer=function(E,C,T,f,g,S){if(b.StoreLODInAlphaChannel){for(var y=new Uint16Array(f),x=new Uint16Array(g,T),R=0,I=0;I<C;I++)for(var M=0;M<E;M++){var D=4*(M+I*E);y[R]=x[D],y[R+1]=x[D+1],y[R+2]=x[D+2],y[R+3]=(0,s.LZ)(S),R+=4}return y}return new Uint16Array(g,T,f)},b._GetFloatRGBAArrayBuffer=function(E,C,T,f,g,S){if(b.StoreLODInAlphaChannel){for(var y=new Float32Array(f),x=new Float32Array(g,T),R=0,I=0;I<C;I++)for(var M=0;M<E;M++){var D=4*(M+I*E);y[R]=x[D],y[R+1]=x[D+1],y[R+2]=x[D+2],y[R+3]=S,R+=4}return y}return new Float32Array(g,T,f)},b._GetFloatAsHalfFloatRGBAArrayBuffer=function(E,C,T,f,g,S){for(var y=new Uint16Array(f),x=new Float32Array(g,T),R=0,I=0;I<C;I++)for(var M=0;M<E;M++)y[R]=(0,s.LZ)(x[R]),y[R+1]=(0,s.LZ)(x[R+1]),y[R+2]=(0,s.LZ)(x[R+2]),b.StoreLODInAlphaChannel?y[R+3]=(0,s.LZ)(S):y[R+3]=(0,s.LZ)(x[R+3]),R+=4;return y},b._GetFloatAsUIntRGBAArrayBuffer=function(E,C,T,f,g,S){for(var y=new Uint8Array(f),x=new Float32Array(g,T),R=0,I=0;I<C;I++)for(var M=0;M<E;M++){var D=4*(M+I*E);y[R]=255*(0,n.Clamp)(x[D]),y[R+1]=255*(0,n.Clamp)(x[D+1]),y[R+2]=255*(0,n.Clamp)(x[D+2]),b.StoreLODInAlphaChannel?y[R+3]=S:y[R+3]=255*(0,n.Clamp)(x[D+3]),R+=4}return y},b._GetHalfFloatAsUIntRGBAArrayBuffer=function(E,C,T,f,g,S){for(var y=new Uint8Array(f),x=new Uint16Array(g,T),R=0,I=0;I<C;I++)for(var M=0;M<E;M++){var D=4*(M+I*E);y[R]=255*(0,n.Clamp)((0,s.SX)(x[D])),y[R+1]=255*(0,n.Clamp)((0,s.SX)(x[D+1])),y[R+2]=255*(0,n.Clamp)((0,s.SX)(x[D+2])),b.StoreLODInAlphaChannel?y[R+3]=S:y[R+3]=255*(0,n.Clamp)((0,s.SX)(x[D+3])),R+=4}return y},b._GetRGBAArrayBuffer=function(E,C,T,f,g,S,y,x,R){for(var I=new Uint8Array(f),M=new Uint8Array(g,T),D=0,B=0;B<C;B++)for(var F=0;F<E;F++){var X=4*(F+B*E);I[D]=M[X+S],I[D+1]=M[X+y],I[D+2]=M[X+x],I[D+3]=M[X+R],D+=4}return I},b._ExtractLongWordOrder=function(E){return E===0||E===255||E===-16777216?0:1+b._ExtractLongWordOrder(E>>8)},b._GetRGBArrayBuffer=function(E,C,T,f,g,S,y,x){for(var R=new Uint8Array(f),I=new Uint8Array(g,T),M=0,D=0;D<C;D++)for(var B=0;B<E;B++){var F=3*(B+D*E);R[M]=I[F+S],R[M+1]=I[F+y],R[M+2]=I[F+x],M+=3}return R},b._GetLuminanceArrayBuffer=function(E,C,T,f,g){for(var S=new Uint8Array(f),y=new Uint8Array(g,T),x=0,R=0;R<C;R++)for(var I=0;I<E;I++){var M=I+R*E;S[x]=y[M],x++}return S},b.UploadDDSLevels=function(E,C,T,f,g,S,y,x,R){y===void 0&&(y=-1),R===void 0&&(R=!0);var I=null;f.sphericalPolynomial&&(I=[]);var M=!!E.getCaps().s3tc;C.generateMipMaps=g;var D,B,F,X,$,Q,ie,q=new Int32Array(T.buffer,T.byteOffset,31),ee=0,te=0,ce=1;if(q[0]===542327876)if(f.isFourCC||f.isRGB||f.isLuminance)if(!f.isCompressed||M){var fe=q[22];X=q[1]+4;var de,Te=!1;if(f.isFourCC)switch(D=q[21]){case d:ce=8,te=i.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1;break;case h:ce=16,te=i.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;break;case p:ce=16,te=i.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;break;case 113:Te=!0,fe=64;break;case 116:Te=!0,fe=128;break;case m:X+=20;var ue=!1;switch(f.dxgiFormat){case 10:Te=!0,fe=64,ue=!0;break;case 2:Te=!0,fe=128,ue=!0;break;case 88:f.isRGB=!0,f.isFourCC=!1,fe=32,ue=!0}if(ue)break;default:return void o.V.Error(["Unsupported FourCC code:",(de=D,String.fromCharCode(255&de,de>>8&255,de>>16&255,de>>24&255))])}var U=b._ExtractLongWordOrder(q[23]),N=b._ExtractLongWordOrder(q[24]),w=b._ExtractLongWordOrder(q[25]),k=b._ExtractLongWordOrder(q[26]);Te&&(te=E._getRGBABufferInternalSizedFormat(f.textureType)),Q=1,q[2]&l&&g!==!1&&(Q=Math.max(1,q[7]));for(var J=x||0,le=E.getCaps(),be=J;be<S;be++){for(B=q[4],F=q[3],ie=0;ie<Q;++ie){if(y===-1||y===ie){var ve=y===-1?ie:0;if(!f.isCompressed&&f.isFourCC){C.format=i.Y.TEXTUREFORMAT_RGBA,ee=B*F*4;var ye=null;if(E._badOS||E._badDesktopOS||!le.textureHalfFloat&&!le.textureFloat)fe===128?(ye=b._GetFloatAsUIntRGBAArrayBuffer(B,F,T.byteOffset+X,ee,T.buffer,ve),I&&ve==0&&I.push(b._GetFloatRGBAArrayBuffer(B,F,T.byteOffset+X,ee,T.buffer,ve))):fe===64&&(ye=b._GetHalfFloatAsUIntRGBAArrayBuffer(B,F,T.byteOffset+X,ee,T.buffer,ve),I&&ve==0&&I.push(b._GetHalfFloatAsFloatRGBAArrayBuffer(B,F,T.byteOffset+X,ee,T.buffer,ve))),C.type=i.Y.TEXTURETYPE_UNSIGNED_INT;else{var Me=le.textureFloat&&(R&&le.textureFloatLinearFiltering||!R),we=le.textureHalfFloat&&(R&&le.textureHalfFloatLinearFiltering||!R),He=(fe===128||fe===64&&!we)&&Me?i.Y.TEXTURETYPE_FLOAT:(fe===64||fe===128&&!Me)&&we?i.Y.TEXTURETYPE_HALF_FLOAT:i.Y.TEXTURETYPE_UNSIGNED_BYTE,Ke=void 0,Qe=null;if(fe===128)switch(He){case i.Y.TEXTURETYPE_FLOAT:Ke=b._GetFloatRGBAArrayBuffer,Qe=null;break;case i.Y.TEXTURETYPE_HALF_FLOAT:Ke=b._GetFloatAsHalfFloatRGBAArrayBuffer,Qe=b._GetFloatRGBAArrayBuffer;break;case i.Y.TEXTURETYPE_UNSIGNED_BYTE:Ke=b._GetFloatAsUIntRGBAArrayBuffer,Qe=b._GetFloatRGBAArrayBuffer}else switch(He){case i.Y.TEXTURETYPE_FLOAT:Ke=b._GetHalfFloatAsFloatRGBAArrayBuffer,Qe=null;break;case i.Y.TEXTURETYPE_HALF_FLOAT:Ke=b._GetHalfFloatRGBAArrayBuffer,Qe=b._GetHalfFloatAsFloatRGBAArrayBuffer;break;case i.Y.TEXTURETYPE_UNSIGNED_BYTE:Ke=b._GetHalfFloatAsUIntRGBAArrayBuffer,Qe=b._GetHalfFloatAsFloatRGBAArrayBuffer}C.type=He,ye=Ke(B,F,T.byteOffset+X,ee,T.buffer,ve),I&&ve==0&&I.push(Qe?Qe(B,F,T.byteOffset+X,ee,T.buffer,ve):ye)}ye&&E._uploadDataToTextureDirectly(C,ye,be,ve)}else if(f.isRGB)C.type=i.Y.TEXTURETYPE_UNSIGNED_INT,fe===24?(C.format=i.Y.TEXTUREFORMAT_RGB,ee=B*F*3,$=b._GetRGBArrayBuffer(B,F,T.byteOffset+X,ee,T.buffer,U,N,w),E._uploadDataToTextureDirectly(C,$,be,ve)):(C.format=i.Y.TEXTUREFORMAT_RGBA,ee=B*F*4,$=b._GetRGBAArrayBuffer(B,F,T.byteOffset+X,ee,T.buffer,U,N,w,k),E._uploadDataToTextureDirectly(C,$,be,ve));else if(f.isLuminance){var Je=E._getUnpackAlignement(),ht=B;ee=Math.floor((B+Je-1)/Je)*Je*(F-1)+ht,$=b._GetLuminanceArrayBuffer(B,F,T.byteOffset+X,ee,T.buffer),C.format=i.Y.TEXTUREFORMAT_LUMINANCE,C.type=i.Y.TEXTURETYPE_UNSIGNED_INT,E._uploadDataToTextureDirectly(C,$,be,ve)}else ee=Math.max(4,B)/4*Math.max(4,F)/4*ce,$=new Uint8Array(T.buffer,T.byteOffset+X,ee),C.type=i.Y.TEXTURETYPE_UNSIGNED_INT,E._uploadCompressedDataToTextureDirectly(C,te,B,F,$,be,ve)}X+=fe?B*F*(fe/8):ee,B*=.5,F*=.5,B=Math.max(1,B),F=Math.max(1,F)}if(x!==void 0)break}I&&I.length>0?f.sphericalPolynomial=a.d.ConvertCubeMapToSphericalPolynomial({size:q[4],right:I[0],left:I[1],up:I[2],down:I[3],front:I[4],back:I[5],format:i.Y.TEXTUREFORMAT_RGBA,type:i.Y.TEXTURETYPE_FLOAT,gammaSpace:!1}):f.sphericalPolynomial=void 0}else o.V.Error("Compressed textures are not supported on this platform.");else o.V.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else o.V.Error("Invalid magic number in DDS header")},b.StoreLODInAlphaChannel=!1,b}()},36729:(r,t,e)=>{e.d(t,{B:()=>o,K:()=>a});var n={},i={};function o(s){var l=s.getClassName();return i[l]||(i[l]={}),i[l]}function a(s){var l=s.getClassName();if(n[l])return n[l];n[l]={};for(var c=n[l],u=s,d=l;d;){var h=i[d];for(var p in h)c[p]=h[p];var m=void 0,v=!1;do{if(!(m=Object.getPrototypeOf(u)).getClassName){v=!0;break}if(m.getClassName()!==d)break;u=m}while(m);if(v)break;d=m.getClassName(),u=m}return c}},12028:(r,t,e)=>{e.d(t,{p:()=>c});var n=e(41190),i=e(31985),o=e(64726),a=e(8046),s=e(36729),l=function(u,d,h,p){p===void 0&&(p={});var m=u();i.Y&&i.Y.HasTags(d)&&i.Y.AddTagsTo(m,i.Y.GetTags(d,!0));var v=(0,s.K)(m),b={};for(var E in v){var C=v[E],T=d[E],f=C.type;if(T!=null&&(E!=="uniqueId"||c.AllowLoadingUniqueId))switch(f){case 0:case 6:case 11:m[E]=T;break;case 1:p.cloneTexturesOnlyOnce&&b[T.uniqueId]?m[E]=b[T.uniqueId]:(m[E]=h||T.isRenderTarget?T:T.clone(),b[T.uniqueId]=m[E]);break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:m[E]=h?T:T.clone()}}return m},c=function(){function u(){}return u.AppendSerializedAnimations=function(d,h){if(d.animations){h.animations=[];for(var p=0;p<d.animations.length;p++){var m=d.animations[p];h.animations.push(m.serialize())}}},u.Serialize=function(d,h){h||(h={}),i.Y&&(h.tags=i.Y.GetTags(d));var p=(0,s.K)(d);for(var m in p){var v=p[m],b=v.sourceName||m,E=v.type,C=d[m];if(C!=null&&(m!=="uniqueId"||u.AllowLoadingUniqueId))switch(E){case 0:h[b]=C;break;case 1:case 3:case 7:case 9:h[b]=C.serialize();break;case 2:case 4:case 5:case 8:case 10:case 12:h[b]=C.asArray();break;case 6:case 11:h[b]=C.id}}return h},u.ParseProperties=function(d,h,p,m){m||(m="");var v=(0,s.K)(h);for(var b in v){var E=v[b],C=d[E.sourceName||b],T=E.type;if(C!=null&&(b!=="uniqueId"||u.AllowLoadingUniqueId)){var f=h;switch(T){case 0:f[b]=C;break;case 1:p&&(f[b]=u._TextureParser(C,p,m));break;case 2:f[b]=o.v9.FromArray(C);break;case 3:f[b]=u._FresnelParametersParser(C);break;case 4:f[b]=a.I9.FromArray(C);break;case 5:f[b]=a.Pq.FromArray(C);break;case 6:p&&(f[b]=p.getLastMeshById(C));break;case 7:f[b]=u._ColorCurvesParser(C);break;case 8:f[b]=o.ov.FromArray(C);break;case 9:f[b]=u._ImageProcessingConfigurationParser(C);break;case 10:f[b]=a.PT.FromArray(C);break;case 11:p&&(f[b]=p.getCameraById(C));break;case 12:f[b]=a.uq.FromArray(C)}}}},u.Parse=function(d,h,p,m){m===void 0&&(m=null);var v=d();return i.Y&&i.Y.AddTagsTo(v,h.tags),u.ParseProperties(h,v,p,m),v},u.Clone=function(d,h,p){return p===void 0&&(p={}),l(d,h,!1,p)},u.Instanciate=function(d,h){return l(d,h,!0)},u.AllowLoadingUniqueId=!1,u._ImageProcessingConfigurationParser=function(d){throw(0,n.n)("ImageProcessingConfiguration")},u._FresnelParametersParser=function(d){throw(0,n.n)("FresnelParameters")},u._ColorCurvesParser=function(d){throw(0,n.n)("ColorCurves")},u._TextureParser=function(d,h,p){throw(0,n.n)("Texture")},u}()},6174:(r,t,e)=>{e.d(t,{$z:()=>o,Cx:()=>T,GG:()=>E,P_:()=>d,WM:()=>u,Y9:()=>c,bR:()=>b,fW:()=>C,jT:()=>l,lK:()=>a,n1:()=>v,qK:()=>m,uM:()=>s,wL:()=>p,xG:()=>h});var n=e(36729);function i(f,g){return function(S,y){var x=(0,n.B)(S);x[y]||(x[y]={type:f,sourceName:g})}}function o(f,g){return g===void 0&&(g=null),function(S,y){return y===void 0&&(y=null),function(x,R){var I=y||"_"+R;Object.defineProperty(x,R,{get:function(){return this[I]},set:function(M){typeof this.equals=="function"&&this.equals(M)||this[I]!==M&&(this[I]=M,x[S].apply(this))},enumerable:!0,configurable:!0})}}(f,g)}function a(f){return i(0,f)}function s(f){return i(1,f)}function l(f){return i(2,f)}function c(f){return i(3,f)}function u(f){return i(4,f)}function d(f){return i(5,f)}function h(f){return i(6,f)}function p(f){return i(7,f)}function m(f){return i(8,f)}function v(f){return i(9,f)}function b(f){return i(10,f)}function E(f){return i(12,f)}function C(f){return i(11,f)}function T(f,g,S,y){var x=S.value;S.value=function(){for(var R=[],I=0;I<arguments.length;I++)R[I]=arguments[I];var M=x;if(typeof _native<"u"&&_native[g]){var D=_native[g];M=y?function(){for(var B=[],F=0;F<arguments.length;F++)B[F]=arguments[F];return y.apply(void 0,B)?D.apply(void 0,B):x.apply(void 0,B)}:D}return f[g]=M,M.apply(void 0,R)}}T.filter=function(f){return function(g,S,y){return T(g,S,y,f)}}},44576:(r,t,e)=>{e.d(t,{r:()=>a});var n=e(78322),i=e(7164),o=function(s,l,c){return s?s.getClassName&&s.getClassName()==="Mesh"?null:!s.getClassName||s.getClassName()!=="SubMesh"&&s.getClassName()!=="PhysicsBody"?s.clone?s.clone():Array.isArray(s)?s.slice():c&&typeof s=="object"?(0,n.Cl)({},s):null:s.clone(l):null},a=function(){function s(){}return s.DeepCopy=function(l,c,u,d,h){h===void 0&&(h=!1);for(var p=function(g){var S=[];do Object.getOwnPropertyNames(g).forEach(function(y){S.indexOf(y)===-1&&S.push(y)});while(g=Object.getPrototypeOf(g));return S}(l),m=0,v=p;m<v.length;m++){var b=v[m];if((b[0]!=="_"||d&&d.indexOf(b)!==-1)&&!(b.endsWith("Observable")||u&&u.indexOf(b)!==-1)){var E=l[b],C=typeof E;if(C!=="function")try{if(C==="object")if(E instanceof Uint8Array)c[b]=Uint8Array.from(E);else if(E instanceof Array){if(c[b]=[],E.length>0)if(typeof E[0]=="object")for(var T=0;T<E.length;T++){var f=o(E[T],c,h);c[b].indexOf(f)===-1&&c[b].push(f)}else c[b]=E.slice(0)}else c[b]=o(E,c,h);else c[b]=E}catch(g){i.V.Warn(g.message)}}}},s}()},41190:(r,t,e)=>{e.d(t,{n:()=>i});var n={};function i(o,a){if(a===void 0&&(a=!1),!a||!n[o])return n[o]=!0,"".concat(o," needs to be imported before as it contains a side-effect required by your code.")}},5153:(r,t,e)=>{function n(){return typeof window<"u"}function i(){return typeof navigator<"u"}function o(){return typeof document<"u"}function a(l){for(var c="",u=l.firstChild;u;)u.nodeType===3&&(c+=u.textContent),u=u.nextSibling;return c}e.d(t,{Az:()=>s,BA:()=>n,Nf:()=>o,XD:()=>i,Zl:()=>a});var s={IsWindowObjectExist:n,IsNavigatorAvailable:i,IsDocumentAvailable:o,GetDOMTextContent:a}},24687:(r,t,e)=>{e.d(t,{RJ:()=>m,dq:()=>p,e9:()=>b,yp:()=>h});var n,i=e(78322),o=e(96352),a=e(81152),s=e(93540),l=e(44957),c=e(56017),u=e(48810),d=e(66614);function h(E,C,T,f,g,S,y){return g===void 0&&(g="image/png"),(0,i.sH)(this,void 0,void 0,function(){var x,R;return(0,i.YH)(this,function(I){switch(I.label){case 0:return[4,T.readPixels(0,0,E,C)];case 1:return x=I.sent(),R=new Uint8Array(x.buffer),m(E,C,R,f,g,S,!0,void 0,y),[2]}})})}function p(E,C,T,f,g,S,y,x){return f===void 0&&(f="image/png"),S===void 0&&(S=!1),y===void 0&&(y=!1),new Promise(function(R){m(E,C,T,function(I){return R(I)},f,g,S,y,x)})}function m(E,C,T,f,g,S,y,x,R){g===void 0&&(g="image/png"),y===void 0&&(y=!1),x===void 0&&(x=!1);var I=function(){if(!n){var X=void 0,$=null,Q={preserveDrawingBuffer:!0,depth:!1,stencil:!1,alpha:!0,premultipliedAlpha:!1,antialias:!1,failIfMajorPerformanceCaveat:!1};try{X=new OffscreenCanvas(100,100),$=new o.w(X,!1,Q)}catch{X=document.createElement("canvas"),$=new o.w(X,!1,Q)}d.q.Instances.pop(),d.q.OnEnginesDisposedObservable.add(function(ee){$&&ee!==$&&!$.isDisposed&&d.q.Instances.length===0&&v()}),$.getCaps().parallelShaderCompile=void 0;var ie=new s.J($),q=new s.$({engine:$,name:c.passPixelShader.name,fragmentShader:c.passPixelShader.shader,samplerNames:["textureSampler"]});n={canvas:X,engine:$,renderer:ie,wrapper:q}}return n}();if(I.engine.setSize(E,C,!0),T instanceof Float32Array){for(var M=new Uint8Array(T.length),D=T.length;D--;){var B=T[D];M[D]=Math.round(255*(0,u.Clamp)(B))}T=M}var F=I.engine.createRawTexture(T,E,C,a.Y.TEXTUREFORMAT_RGBA,!1,!y,a.Y.TEXTURE_NEAREST_NEAREST);I.renderer.setViewport(),I.renderer.applyEffectWrapper(I.wrapper),I.wrapper.effect._bindTexture("textureSampler",F),I.renderer.draw(),x?l.S0.ToBlob(I.canvas,function(X){var $=new FileReader;$.onload=function(Q){var ie=Q.target.result;f&&f(ie)},$.readAsArrayBuffer(X)},g,R):l.S0.EncodeScreenshotCanvasData(I.canvas,f,g,S,R),F.dispose()}function v(){n&&(n.wrapper.dispose(),n.renderer.dispose(),n.engine.dispose()),n=null}var b={DumpData:m,DumpDataAsync:p,DumpFramebuffer:h,Dispose:v};l.S0.DumpData=m,l.S0.DumpDataAsync=p,l.S0.DumpFramebuffer=h},88309:(r,t,e)=>{e.d(t,{$h:()=>y,Hx:()=>g,RZ:()=>f,bv:()=>I,cU:()=>T,gW:()=>D,o5:()=>x,ow:()=>M,qY:()=>B});var n=e(78322),i=e(44957),o=e(8046),a=e(48810),s=e(51428),l=e(19133),c=e(28081),u=e(81152),d=e(76170),h=e(30622),p=e(7164),m=e(97411),v=(e(8864),e(82345),e(39813),e(24687)),b="image/png",E=2,C=[134,22,135,150,246,214,150,54];function T(F){for(var X=new DataView(F.buffer,F.byteOffset,F.byteLength),$=0,Q=0;Q<C.length;Q++)if(X.getUint8($++)!==C[Q])return p.V.Error("Not a babylon environment map"),null;for(var ie="",q=0;q=X.getUint8($++);)ie+=String.fromCharCode(q);var ee=JSON.parse(ie);return(ee=f(ee)).specular&&(ee.specular.specularDataPosition=$,ee.specular.lodGenerationScale=ee.specular.lodGenerationScale||.8),ee}function f(F){if(F.version>E)throw new Error('Unsupported babylon environment map version "'.concat(F.version,'". Latest supported version is "').concat(E,'".'));return F.version===2?F:F=(0,n.Cl)((0,n.Cl)({},F),{version:2,imageType:b})}function g(F,X){var $,Q;return X===void 0&&(X={}),(0,n.sH)(this,void 0,void 0,function(){var ie,q,ee,te,ce,fe,de,Te,ue,U,N,w,k,J,le,be,ve,ye,Me,we,He,Ke,Qe,Je,ht,mt,yt,zt,$t,St,Ot,Et,Vt;return(0,n.YH)(this,function(ln){switch(ln.label){case 0:if(!(ie=F.getInternalTexture()))return[2,Promise.reject("The cube texture is invalid.")];if(q=($=X.imageType)!==null&&$!==void 0?$:b,ee=ie.getEngine(),F.textureType!==u.Y.TEXTURETYPE_HALF_FLOAT&&F.textureType!==u.Y.TEXTURETYPE_FLOAT&&F.textureType!==u.Y.TEXTURETYPE_UNSIGNED_BYTE&&F.textureType!==u.Y.TEXTURETYPE_UNSIGNED_INT&&F.textureType!==u.Y.TEXTURETYPE_UNSIGNED_INTEGER&&F.textureType!==-1)return[2,Promise.reject("The cube texture should allow HDR (Full Float or Half Float).")];if(te=u.Y.TEXTURETYPE_FLOAT,!ee.getCaps().textureFloatRender&&(te=u.Y.TEXTURETYPE_HALF_FLOAT,!ee.getCaps().textureHalfFloatRender))return[2,Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];F.sphericalPolynomial,ce=(Q=F.getInternalTexture())===null||Q===void 0?void 0:Q._sphericalPolynomialPromise,fe=ie.width,de=new d.Z(ee),Te={},ee.flushFramebuffer(),ue=(0,a.ILog2)(ie.width),Ot=0,ln.label=1;case 1:if(!(Ot<=ue))return[3,9];U=Math.pow(2,ue-Ot),Et=0,ln.label=2;case 2:return Et<6?[4,F.readPixels(Et,Ot,void 0,!1)]:[3,8];case 3:if((N=ln.sent())&&N.byteLength===N.length){for(w=new Float32Array(4*N.byteLength),k=0;k<N.byteLength;k++)w[k]=N[k]/255,w[k]=Math.pow(w[k],2.2);N=w}else if(N&&F.gammaSpace)for(J=N,le=0;le<J.length;le++)J[le]=Math.pow(J[le],2.2);return be=ee.createRawTexture(N,U,U,u.Y.TEXTUREFORMAT_RGBA,!1,!0,u.Y.TEXTURE_NEAREST_SAMPLINGMODE,null,te),[4,m.G.EncodeTextureToRGBD(be,de,te)];case 4:return ln.sent(),[4,ee._readTexturePixels(be,U,U)];case 5:return ve=ln.sent(),[4,(0,v.dq)(U,U,ve,q,void 0,!1,!0,X.imageQuality)];case 6:ye=ln.sent(),Te[6*Ot+Et]=ye,be.dispose(),ln.label=7;case 7:return Et++,[3,2];case 8:return Ot++,[3,1];case 9:return de.dispose(),ce?[4,ce]:[3,11];case 10:ln.sent(),ln.label=11;case 11:for(Me={version:E,width:fe,imageType:q,irradiance:S(F),specular:{mipmaps:[],lodGenerationScale:F.lodGenerationScale}},we=0,Ot=0;Ot<=ue;Ot++)for(Et=0;Et<6;Et++)He=Te[6*Ot+Et].byteLength,Me.specular.mipmaps.push({length:He,position:we}),we+=He;for(Ke=JSON.stringify(Me),Qe=new ArrayBuffer(Ke.length+1),Je=new Uint8Array(Qe),Ot=0,ht=Ke.length;Ot<ht;Ot++)Je[Ot]=Ke.charCodeAt(Ot);for(Je[Ke.length]=0,mt=C.length+we+Qe.byteLength,yt=new ArrayBuffer(mt),zt=new Uint8Array(yt),$t=new DataView(yt),St=0,Ot=0;Ot<C.length;Ot++)$t.setUint8(St++,C[Ot]);for(zt.set(new Uint8Array(Qe),St),St+=Qe.byteLength,Ot=0;Ot<=ue;Ot++)for(Et=0;Et<6;Et++)Vt=Te[6*Ot+Et],zt.set(new Uint8Array(Vt),St),St+=Vt.byteLength;return[2,yt]}})})}function S(F){var X=F.sphericalPolynomial;return X==null?null:{x:[X.x.x,X.x.y,X.x.z],y:[X.y.x,X.y.y,X.y.z],z:[X.z.x,X.z.y,X.z.z],xx:[X.xx.x,X.xx.y,X.xx.z],yy:[X.yy.x,X.yy.y,X.yy.z],zz:[X.zz.x,X.zz.y,X.zz.z],yz:[X.yz.x,X.yz.y,X.yz.z],zx:[X.zx.x,X.zx.y,X.zx.z],xy:[X.xy.x,X.xy.y,X.xy.z]}}function y(F,X){var $=(X=f(X)).specular,Q=Math.log2(X.width);if(Q=Math.round(Q)+1,$.mipmaps.length!==6*Q)throw new Error('Unsupported specular mipmaps number "'.concat($.mipmaps.length,'"'));for(var ie=new Array(Q),q=0;q<Q;q++){ie[q]=new Array(6);for(var ee=0;ee<6;ee++){var te=$.mipmaps[6*q+ee];ie[q][ee]=new Uint8Array(F.buffer,F.byteOffset+$.specularDataPosition+te.position,te.length)}}return ie}function x(F,X,$){var Q=($=f($)).specular;return Q?(F._lodGenerationScale=Q.lodGenerationScale,I(F,y(X,$),$.imageType)):Promise.resolve()}function R(F,X,$,Q,ie,q,ee,te,ce,fe,de){return new Promise(function(Te,ue){if($){var U=X.createTexture(null,!0,!0,null,u.Y.TEXTURE_NEAREST_SAMPLINGMODE,null,function(w){ue(w)},F);Q?.onEffectCreatedObservable.addOnce(function(w){w.executeWhenCompiled(function(){Q.externalTextureSamplerBinding=!0,Q.onApply=function(k){k._bindTexture("textureSampler",U),k.setFloat2("scale",1,X._features.needsInvertingBitmap&&F instanceof ImageBitmap?-1:1)},X.scenes.length&&(X.scenes[0].postProcessManager.directRender([Q],fe,!0,q,ee),X.restoreDefaultFramebuffer(),U.dispose(),URL.revokeObjectURL(ie),Te())})})}else{if(X._uploadImageToTexture(de,F,q,ee),te){var N=ce[ee];N&&X._uploadImageToTexture(N._texture,F,q,0)}Te()}})}function I(F,X,$){return $===void 0&&($=b),(0,n.sH)(this,void 0,void 0,function(){var Q,ie,q,ee,te,ce,fe,de,Te,ue,U,N,w,k,J,le,be,ve,ye,Me,we,He,Ke,Qe;return(0,n.YH)(this,function(Je){switch(Je.label){case 0:if(!i.S0.IsExponentOfTwo(F.width))throw new Error("Texture size must be a power of two");return Q=(0,a.ILog2)(F.width)+1,ie=F.getEngine(),q=!1,ee=!1,te=null,ce=null,fe=null,de=ie.getCaps(),F.format=u.Y.TEXTUREFORMAT_RGBA,F.type=u.Y.TEXTURETYPE_UNSIGNED_INT,F.generateMipMaps=!0,F._cachedAnisotropicFilteringLevel=null,ie.updateTextureSamplingMode(u.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,F),de.textureLOD?ie._features.supportRenderAndCopyToLodForFloatTextures?de.textureHalfFloatRender&&de.textureHalfFloatLinearFiltering?(q=!0,F.type=u.Y.TEXTURETYPE_HALF_FLOAT):de.textureFloatRender&&de.textureFloatLinearFiltering&&(q=!0,F.type=u.Y.TEXTURETYPE_FLOAT):q=!1:(q=!1,ee=!0,fe={}),Te=0,q?ie.isWebGPU?(Te=1,[4,Promise.resolve().then(e.bind(e,37494))]):[3,2]:[3,5];case 1:return Je.sent(),[3,4];case 2:return[4,Promise.resolve().then(e.bind(e,32407))];case 3:Je.sent(),Je.label=4;case 4:return te=new h.w("rgbdDecode","rgbdDecode",null,null,1,null,u.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,ie,!1,void 0,F.type,void 0,null,!1,void 0,Te),F._isRGBD=!1,F.invertY=!1,ce=ie.createRenderTargetCubeTexture(F.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:u.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,type:F.type,format:u.Y.TEXTUREFORMAT_RGBA}),[3,6];case 5:if(F._isRGBD=!0,F.invertY=!0,ee)for(ue=F._lodGenerationScale,U=F._lodGenerationOffset,Ke=0;Ke<3;Ke++)switch(k=(N=U)+((w=(Q-1)*ue+U)-N)*(1-Ke/2),J=Math.round(Math.min(Math.max(k,0),w)),(le=new l.h(ie,2)).isCube=!0,le.invertY=!0,le.generateMipMaps=!1,ie.updateTextureSamplingMode(u.Y.TEXTURE_LINEAR_LINEAR,le),(be=new c.t(null))._isCube=!0,be._texture=le,fe[J]=be,Ke){case 0:F._lodTextureLow=be;break;case 1:F._lodTextureMid=be;break;case 2:F._lodTextureHigh=be}Je.label=6;case 6:for(ve=[],ye=function(ht){for(var mt=function(zt){var $t=X[ht][zt],St=new Blob([$t],{type:$}),Ot=URL.createObjectURL(St),Et=void 0;if(ie._features.forceBitmapOverHTMLImageElement)Et=ie.createImageBitmap(St,{premultiplyAlpha:"none"}).then(function(ln){return R(ln,ie,q,te,Ot,zt,ht,ee,fe,ce,F)});else{var Vt=new Image;Vt.src=Ot,Et=new Promise(function(ln,Yt){Vt.onload=function(){R(Vt,ie,q,te,Ot,zt,ht,ee,fe,ce,F).then(function(){return ln()}).catch(function(Un){Yt(Un)})},Vt.onerror=function(Un){Yt(Un)}})}ve.push(Et)},yt=0;yt<6;yt++)mt(yt)},Ke=0;Ke<X.length;Ke++)ye(Ke);if(X.length<Q){switch(Me=void 0,we=Math.pow(2,Q-1-X.length),He=we*we*4,F.type){case u.Y.TEXTURETYPE_UNSIGNED_INT:Me=new Uint8Array(He);break;case u.Y.TEXTURETYPE_HALF_FLOAT:Me=new Uint16Array(He);break;case u.Y.TEXTURETYPE_FLOAT:Me=new Float32Array(He)}for(Ke=X.length;Ke<Q;Ke++)for(Qe=0;Qe<6;Qe++)ie._uploadArrayBufferViewToTexture(F,Me,Qe,Ke)}return[2,Promise.all(ve).then(function(){ce&&(ie._releaseTexture(F),ce._swapAndDie(F)),te&&te.dispose(),ee&&(F._lodTextureHigh&&F._lodTextureHigh._texture&&(F._lodTextureHigh._texture.isReady=!0),F._lodTextureMid&&F._lodTextureMid._texture&&(F._lodTextureMid._texture.isReady=!0),F._lodTextureLow&&F._lodTextureLow._texture&&(F._lodTextureLow._texture.isReady=!0))})]}})})}function M(F,X){var $=(X=f(X)).irradiance;if($){var Q=new s.Q;o.Pq.FromArrayToRef($.x,0,Q.x),o.Pq.FromArrayToRef($.y,0,Q.y),o.Pq.FromArrayToRef($.z,0,Q.z),o.Pq.FromArrayToRef($.xx,0,Q.xx),o.Pq.FromArrayToRef($.yy,0,Q.yy),o.Pq.FromArrayToRef($.zz,0,Q.zz),o.Pq.FromArrayToRef($.yz,0,Q.yz),o.Pq.FromArrayToRef($.zx,0,Q.zx),o.Pq.FromArrayToRef($.xy,0,Q.xy),F._sphericalPolynomial=Q}}function D(F,X,$,Q,ie){var q=I(F.getEngine().createRawCubeTexture(null,F.width,F.format,F.type,F.generateMipMaps,F.invertY,F.samplingMode,F._compression),X).then(function(){return F});return F.onRebuildCallback=function(ee){return{proxy:q,isReady:!0,isAsync:!0}},F._source=13,F._bufferViewArrayArray=X,F._lodGenerationScale=Q,F._lodGenerationOffset=ie,F._sphericalPolynomial=$,I(F,X).then(function(){return F.isReady=!0,F})}var B={GetEnvInfo:T,CreateEnvTextureAsync:g,CreateImageDataArrayBufferViews:y,UploadEnvLevelsAsync:x,UploadLevelsAsync:I,UploadEnvSpherical:M}},91016:(r,t,e)=>{e.d(t,{Cf:()=>i,bu:()=>a,tG:()=>o});var n=e(78322),i=function(s){function l(){return s!==null&&s.apply(this,arguments)||this}return(0,n.C6)(l,s),l._setPrototypeOf=Object.setPrototypeOf||function(c,u){return c.__proto__=u,c},l}(Error),o={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002},a=function(s){function l(c,u,d){var h=s.call(this,c)||this;return h.errorCode=u,h.innerError=d,h.name="RuntimeError",i._setPrototypeOf(h,l.prototype),h}return(0,n.C6)(l,s),l}(i)},17347:(r,t,e)=>{e.d(t,{M1:()=>S,Mi:()=>T,NJ:()=>R,VB:()=>f,W$:()=>x,ZP:()=>F,dy:()=>Q,eC:()=>g,f2:()=>B,hX:()=>C,my:()=>D,qc:()=>y,rh:()=>ie,rz:()=>X,sh:()=>M,wS:()=>$,zU:()=>I});var n=e(78322),i=e(46799),o=e(5153),a=e(66377),s=e(23148),l=e(49449),c=e(91016),u=e(37530),d=e(35930),h=e(66614),p=e(7164),m=e(53695),v=e(24894),b=e(82673),E=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i),C=function(q){function ee(te,ce){var fe=q.call(this,te,c.tG.LoadFileError)||this;return fe.name="LoadFileError",c.Cf._setPrototypeOf(fe,ee.prototype),ce instanceof i.u?fe.request=ce:fe.file=ce,fe}return(0,n.C6)(ee,q),ee}(c.bu),T=function(q){function ee(te,ce){var fe=q.call(this,te,c.tG.RequestFileError)||this;return fe.request=ce,fe.name="RequestFileError",c.Cf._setPrototypeOf(fe,ee.prototype),fe}return(0,n.C6)(ee,q),ee}(c.bu),f=function(q){function ee(te,ce){var fe=q.call(this,te,c.tG.ReadFileError)||this;return fe.file=ce,fe.name="ReadFileError",c.Cf._setPrototypeOf(fe,ee.prototype),fe}return(0,n.C6)(ee,q),ee}(c.bu),g={DefaultRetryStrategy:l.a.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:function(q){return q},ScriptBaseUrl:"",ScriptPreprocessUrl:function(q){return q},CleanUrl:function(q){return q.replace(/#/gm,"%23")}},S=function(q,ee){if((!q||q.indexOf("data:")!==0)&&g.CorsBehavior)if(typeof g.CorsBehavior=="string"||g.CorsBehavior instanceof String)ee.crossOrigin=g.CorsBehavior;else{var te=g.CorsBehavior(q);te&&(ee.crossOrigin=te)}},y={getRequiredSize:null},x=function(q,ee,te,ce,fe,de){fe===void 0&&(fe="");var Te,ue=h.q.LastCreatedEngine;if(typeof HTMLImageElement>"u"&&!ue?._features.forceBitmapOverHTMLImageElement)return te("LoadImage is only supported in web or BabylonNative environments."),null;var U=!1;q instanceof ArrayBuffer||ArrayBuffer.isView(q)?typeof Blob<"u"&&typeof URL<"u"?(Te=URL.createObjectURL(new Blob([q],{type:fe})),U=!0):Te="data:".concat(fe,";base64,")+(0,u.EL)(q):q instanceof Blob?(Te=URL.createObjectURL(q),U=!0):(Te=g.CleanUrl(q),Te=g.PreprocessUrl(Te));var N=function(He){if(te){var Ke=Te||q.toString();te("Error while trying to load image: ".concat(Ke.indexOf("http")===0||Ke.length<=128?Ke:Ke.slice(0,128)+"..."),He)}};if(ue?._features.forceBitmapOverHTMLImageElement)return I(Te,function(He){ue.createImageBitmap(new Blob([He],{type:fe}),(0,n.Cl)({premultiplyAlpha:"none"},de)).then(function(Ke){ee(Ke),U&&URL.revokeObjectURL(Te)}).catch(function(Ke){te&&te("Error while trying to load image: "+q,Ke)})},void 0,ce||void 0,!0,function(He,Ke){N(Ke)}),null;var w=new Image;if(y.getRequiredSize){var k=y.getRequiredSize(q);k.width&&(w.width=k.width),k.height&&(w.height=k.height)}S(Te,w);var J=[],le=function(){J.forEach(function(He){He.target.removeEventListener(He.name,He.handler)}),J.length=0};J.push({target:w,name:"load",handler:function(){le(),ee(w),U&&w.src&&URL.revokeObjectURL(w.src)}}),J.push({target:w,name:"error",handler:function(He){le(),N(He),U&&w.src&&URL.revokeObjectURL(w.src)}}),J.push({target:document,name:"securitypolicyviolation",handler:function(He){if(He.blockedURI===w.src&&He.disposition!=="report"){le();var Ke=new Error("CSP violation of policy ".concat(He.effectiveDirective," ").concat(He.blockedURI,". Current policy is ").concat(He.originalPolicy));h.q.UseFallbackTexture=!1,N(Ke),U&&w.src&&URL.revokeObjectURL(w.src),w.src=""}}}),J.forEach(function(He){He.target.addEventListener(He.name,He.handler)});var be=Te.substring(0,5)==="blob:",ve=Te.substring(0,5)==="data:",ye=function(){be||ve||!i.u.IsCustomRequestAvailable?w.src=Te:I(Te,function(He,Ke,Qe){var Je=new Blob([He],{type:!fe&&Qe?Qe:fe}),ht=URL.createObjectURL(Je);U=!0,w.src=ht},void 0,ce||void 0,!0,function(He,Ke){N(Ke)})};if(!be&&!ve&&ce&&ce.enableTexturesOffline)ce.open(function(){ce&&ce.loadImage(Te,w)},ye);else{if(Te.indexOf("file:")!==-1){var Me=decodeURIComponent(Te.substring(5).toLowerCase());if(s.T.FilesToLoad[Me]&&typeof URL<"u"){try{var we=void 0;try{we=URL.createObjectURL(s.T.FilesToLoad[Me])}catch{we=URL.createObjectURL(s.T.FilesToLoad[Me])}w.src=we,U=!0}catch{w.src=""}return w}}ye()}return w},R=function(q,ee,te,ce,fe){var de=new FileReader,Te={onCompleteObservable:new a.cP,abort:function(){return de.abort()}};return de.onloadend=function(){return Te.onCompleteObservable.notifyObservers(Te)},fe&&(de.onerror=function(){fe(new f("Unable to read ".concat(q.name),q))}),de.onload=function(ue){ee(ue.target.result)},te&&(de.onprogress=te),ce?de.readAsArrayBuffer(q):de.readAsText(q),Te},I=function(q,ee,te,ce,fe,de,Te){if(q.name)return R(q,ee,te,fe,de?function(ve){de(void 0,ve)}:void 0);var ue=q;if(ue.indexOf("file:")!==-1){var U=decodeURIComponent(ue.substring(5).toLowerCase());U.indexOf("./")===0&&(U=U.substring(2));var N=s.T.FilesToLoad[U];if(N)return R(N,ee,te,fe,de?function(ve){return de(void 0,new C(ve.message,ve.file))}:void 0)}var w=F(ue),k=w.match,J=w.type;if(k){var le={onCompleteObservable:new a.cP,abort:function(){return function(){}}};try{var be=fe?X(ue):Q(ue);ee(be,void 0,J)}catch(ve){de?de(void 0,ve):p.V.Error(ve.message||"Failed to parse the Data URL")}return m._.SetImmediate(function(){le.onCompleteObservable.notifyObservers(le)}),le}return M(ue,function(ve,ye){ee(ve,ye?.responseURL,ye?.getResponseHeader("content-type"))},te,ce,fe,de?function(ve){de(ve.request,new C(ve.message,ve.request))}:void 0,Te)},M=function(q,ee,te,ce,fe,de,Te){q=g.CleanUrl(q),q=g.PreprocessUrl(q);var ue=g.BaseUrl+q,U=!1,N={onCompleteObservable:new a.cP,abort:function(){return U=!0}},w=function(){var J,le=new i.u,be=null,ve=function(){le&&(te&&le.removeEventListener("progress",te),J&&le.removeEventListener("readystatechange",J),le.removeEventListener("loadend",ye))},ye=function(){ve(),N.onCompleteObservable.notifyObservers(N),N.onCompleteObservable.clear(),te=void 0,J=null,ye=null,de=void 0,Te=void 0,ee=void 0};N.abort=function(){U=!0,ye&&ye(),le&&le.readyState!==(XMLHttpRequest.DONE||4)&&le.abort(),be!==null&&(clearTimeout(be),be=null),le=null};var Me=function(He){var Ke=He.message||"Unknown error";de&&le?de(new T(Ke,le)):p.V.Error(Ke)},we=function(He){if(le){if(le.open("GET",ue),Te)try{Te(le)}catch(Ke){return void Me(Ke)}fe&&(le.responseType="arraybuffer"),te&&le.addEventListener("progress",te),ye&&le.addEventListener("loadend",ye),J=function(){if(!U&&le&&le.readyState===(XMLHttpRequest.DONE||4)){if(J&&le.removeEventListener("readystatechange",J),le.status>=200&&le.status<300||le.status===0&&(!(0,o.BA)()||D())){try{ee&&ee(fe?le.response:le.responseText,le)}catch(ht){Me(ht)}return}var Ke=g.DefaultRetryStrategy;if(Ke){var Qe=Ke(ue,le,He);if(Qe!==-1)return ve(),le=new i.u,void(be=setTimeout(function(){return we(He+1)},Qe))}var Je=new T("Error status: "+le.status+" "+le.statusText+" - Unable to load "+ue,le);de&&de(Je)}},le.addEventListener("readystatechange",J),le.send()}};we(0)};if(ce&&ce.enableSceneOffline){var k=function(J){J&&J.status>400?de&&de(J):w()};ce.open(function(){ce&&ce.loadFile(g.BaseUrl+q,function(J){!U&&ee&&ee(J),N.onCompleteObservable.notifyObservers(N)},te?function(J){!U&&te&&te(J)}:void 0,k,fe)},k)}else w();return N},D=function(){return typeof location<"u"&&location.protocol==="file:"},B=function(q){return E.test(q)},F=function(q){var ee=E.exec(q);return ee===null||ee.length===0?{match:!1,type:""}:{match:!0,type:ee[0].replace("data:","").replace("base64,","")}};function X(q){return(0,u.yS)(q.split(",")[1])}var $,Q=function(q){return(0,u.AV)(q.split(",")[1])};b.$._FileToolsLoadImage=x,v.sg.loadFile=I,d.J.loadFile=I;var ie=function(q,ee,te,ce,fe,de,Te,ue,U,N){$={DecodeBase64UrlToBinary:q,DecodeBase64UrlToString:ee,DefaultRetryStrategy:te.DefaultRetryStrategy,BaseUrl:te.BaseUrl,CorsBehavior:te.CorsBehavior,PreprocessUrl:te.PreprocessUrl,IsBase64DataUrl:ce,IsFileURL:fe,LoadFile:de,LoadImage:Te,ReadFile:ue,RequestFile:U,SetCorsBehavior:N},Object.defineProperty($,"DefaultRetryStrategy",{get:function(){return te.DefaultRetryStrategy},set:function(w){te.DefaultRetryStrategy=w}}),Object.defineProperty($,"BaseUrl",{get:function(){return te.BaseUrl},set:function(w){te.BaseUrl=w}}),Object.defineProperty($,"PreprocessUrl",{get:function(){return te.PreprocessUrl},set:function(w){te.PreprocessUrl=w}}),Object.defineProperty($,"CorsBehavior",{get:function(){return te.CorsBehavior},set:function(w){te.CorsBehavior=w}})};ie(X,Q,g,B,D,I,x,R,M,S)},23148:(r,t,e)=>{e.d(t,{T:()=>n});var n=function(){function i(){}return i.FilesToLoad={},i}()},23885:(r,t,e)=>{function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){var a=16*Math.random()|0;return(o==="x"?a:3&a|8).toString(16)})}e.d(t,{S:()=>i,z:()=>n});var i={RandomId:n}},252:(r,t,e)=>{e.d(t,{n:()=>o});var n=e(7164),i=e(34623),o=function(){function a(){}return a.Instantiate=function(s){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[s])return this.RegisteredExternalClasses[s];var l=(0,i.n9)(s);if(l)return l;n.V.Warn(s+" not found, you may have missed an import.");for(var c=s.split("."),u=window||this,d=0,h=c.length;d<h;d++)u=u[c[d]];return typeof u!="function"?null:u},a.RegisteredExternalClasses={},a}()},88188:(r,t,e)=>{e.d(t,{H:()=>i});var n=e(7164),i=function(){function o(a,s){if(this.data=a,this.isInvalid=!1,!o.IsValid(a))return this.isInvalid=!0,void n.V.Error("texture missing KTX identifier");var l=Uint32Array.BYTES_PER_ELEMENT,c=new DataView(this.data.buffer,this.data.byteOffset+12,13*l),u=c.getUint32(0,!0)===67305985;return this.glType=c.getUint32(1*l,u),this.glTypeSize=c.getUint32(2*l,u),this.glFormat=c.getUint32(3*l,u),this.glInternalFormat=c.getUint32(4*l,u),this.glBaseInternalFormat=c.getUint32(5*l,u),this.pixelWidth=c.getUint32(6*l,u),this.pixelHeight=c.getUint32(7*l,u),this.pixelDepth=c.getUint32(8*l,u),this.numberOfArrayElements=c.getUint32(9*l,u),this.numberOfFaces=c.getUint32(10*l,u),this.numberOfMipmapLevels=c.getUint32(11*l,u),this.bytesOfKeyValueData=c.getUint32(12*l,u),this.glType!==0?(n.V.Error("only compressed formats currently supported"),void(this.isInvalid=!0)):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),this.pixelHeight===0||this.pixelDepth!==0?(n.V.Error("only 2D textures currently supported"),void(this.isInvalid=!0)):this.numberOfArrayElements!==0?(n.V.Error("texture arrays not currently supported"),void(this.isInvalid=!0)):this.numberOfFaces!==s?(n.V.Error("number of faces expected"+s+", but found "+this.numberOfFaces),void(this.isInvalid=!0)):void(this.loadType=o.COMPRESSED_2D))}return o.prototype.uploadLevels=function(a,s){switch(this.loadType){case o.COMPRESSED_2D:this._upload2DCompressedLevels(a,s);case o.TEX_2D:case o.COMPRESSED_3D:case o.TEX_3D:}},o.prototype._upload2DCompressedLevels=function(a,s){for(var l=o.HEADER_LEN+this.bytesOfKeyValueData,c=this.pixelWidth,u=this.pixelHeight,d=s?this.numberOfMipmapLevels:1,h=0;h<d;h++){var p=new Int32Array(this.data.buffer,this.data.byteOffset+l,1)[0];l+=4;for(var m=0;m<this.numberOfFaces;m++){var v=new Uint8Array(this.data.buffer,this.data.byteOffset+l,p);a.getEngine()._uploadCompressedDataToTextureDirectly(a,a.format,c,u,v,m,h),l+=p,l+=3-(p+3)%4}c=Math.max(1,.5*c),u=Math.max(1,.5*u)}},o.IsValid=function(a){if(a.byteLength>=12){var s=new Uint8Array(a.buffer,a.byteOffset,12);if(s[0]===171&&s[1]===75&&s[2]===84&&s[3]===88&&s[4]===32&&s[5]===49&&s[6]===49&&s[7]===187&&s[8]===13&&s[9]===10&&s[10]===26&&s[11]===10)return!0}return!1},o.HEADER_LEN=64,o.COMPRESSED_2D=0,o.COMPRESSED_3D=1,o.TEX_2D=2,o.TEX_3D=3,o}()},47347:(r,t,e)=>{e.d(t,{$:()=>u,Z:()=>d});var n=e(81152),i=e(80244),o=e(44957),a=e(54665),s=e(78322);function l(h,p){var m=p?.jsDecoderModule||KTX2DECODER;h&&(h.wasmUASTCToASTC&&(m.LiteTranscoder_UASTC_ASTC.WasmModuleURL=h.wasmUASTCToASTC),h.wasmUASTCToBC7&&(m.LiteTranscoder_UASTC_BC7.WasmModuleURL=h.wasmUASTCToBC7),h.wasmUASTCToRGBA_UNORM&&(m.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=h.wasmUASTCToRGBA_UNORM),h.wasmUASTCToRGBA_SRGB&&(m.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=h.wasmUASTCToRGBA_SRGB),h.wasmUASTCToR8_UNORM&&(m.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL=h.wasmUASTCToR8_UNORM),h.wasmUASTCToRG8_UNORM&&(m.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL=h.wasmUASTCToRG8_UNORM),h.jsMSCTranscoder&&(m.MSCTranscoder.JSModuleURL=h.jsMSCTranscoder),h.wasmMSCTranscoder&&(m.MSCTranscoder.WasmModuleURL=h.wasmMSCTranscoder),h.wasmZSTDDecoder&&(m.ZSTDDecoder.WasmModuleURL=h.wasmZSTDDecoder)),p&&(p.wasmUASTCToASTC&&(m.LiteTranscoder_UASTC_ASTC.WasmBinary=p.wasmUASTCToASTC),p.wasmUASTCToBC7&&(m.LiteTranscoder_UASTC_BC7.WasmBinary=p.wasmUASTCToBC7),p.wasmUASTCToRGBA_UNORM&&(m.LiteTranscoder_UASTC_RGBA_UNORM.WasmBinary=p.wasmUASTCToRGBA_UNORM),p.wasmUASTCToRGBA_SRGB&&(m.LiteTranscoder_UASTC_RGBA_SRGB.WasmBinary=p.wasmUASTCToRGBA_SRGB),p.wasmUASTCToR8_UNORM&&(m.LiteTranscoder_UASTC_R8_UNORM.WasmBinary=p.wasmUASTCToR8_UNORM),p.wasmUASTCToRG8_UNORM&&(m.LiteTranscoder_UASTC_RG8_UNORM.WasmBinary=p.wasmUASTCToRG8_UNORM),p.jsMSCTranscoder&&(m.MSCTranscoder.JSModule=p.jsMSCTranscoder),p.wasmMSCTranscoder&&(m.MSCTranscoder.WasmBinary=p.wasmMSCTranscoder),p.wasmZSTDDecoder&&(m.ZSTDDecoder.WasmBinary=p.wasmZSTDDecoder))}function c(h){var p;h===void 0&&typeof KTX2DECODER<"u"&&(h=KTX2DECODER),onmessage=function(m){if(m.data)switch(m.data.action){case"init":var v=m.data.urls;v&&(v.jsDecoderModule&&h===void 0&&(importScripts(v.jsDecoderModule),h=KTX2DECODER),l(v)),m.data.wasmBinaries&&l(void 0,(0,s.Cl)((0,s.Cl)({},m.data.wasmBinaries),{jsDecoderModule:h})),p=new h.KTX2Decoder,postMessage({action:"init"});break;case"setDefaultDecoderOptions":h.KTX2Decoder.DefaultDecoderOptions=m.data.options;break;case"decode":p.decode(m.data.data,m.data.caps,m.data.options).then(function(b){for(var E=[],C=0;C<b.mipmaps.length;++C){var T=b.mipmaps[C];T&&T.data&&E.push(T.data.buffer)}postMessage({action:"decoded",success:!0,decodedData:b},E)}).catch(function(b){postMessage({action:"decoded",success:!1,msg:b})})}}}var u=function(){function h(){this._isDirty=!0,this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=!0,this._ktx2DecoderOptions={}}return Object.defineProperty(h.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"useRGBAIfASTCBC7NotAvailableWhenUASTC",{get:function(){return this._useRGBAIfASTCBC7NotAvailableWhenUASTC},set:function(p){this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==p&&(this._useRGBAIfASTCBC7NotAvailableWhenUASTC=p,this._isDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"useRGBAIfOnlyBC1BC3AvailableWhenUASTC",{get:function(){return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC},set:function(p){this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC!==p&&(this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=p,this._isDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"forceRGBA",{get:function(){return this._forceRGBA},set:function(p){this._forceRGBA!==p&&(this._forceRGBA=p,this._isDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"forceR8",{get:function(){return this._forceR8},set:function(p){this._forceR8!==p&&(this._forceR8=p,this._isDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"forceRG8",{get:function(){return this._forceRG8},set:function(p){this._forceRG8!==p&&(this._forceRG8=p,this._isDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"bypassTranscoders",{get:function(){return this._bypassTranscoders},set:function(p){this._bypassTranscoders!==p&&(this._bypassTranscoders=p,this._isDirty=!0)},enumerable:!1,configurable:!0}),h.prototype._getKTX2DecoderOptions=function(){if(!this._isDirty)return this._ktx2DecoderOptions;this._isDirty=!1;var p={useRGBAIfASTCBC7NotAvailableWhenUASTC:this._useRGBAIfASTCBC7NotAvailableWhenUASTC,forceRGBA:this._forceRGBA,forceR8:this._forceR8,forceRG8:this._forceRG8,bypassTranscoders:this._bypassTranscoders};return this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC&&(p.transcodeFormatDecisionTree={UASTC:{transcodeFormat:[a.Xl.BC1_RGB,a.Xl.BC3_RGBA],yes:{transcodeFormat:a.Xl.RGBA32,engineFormat:32856,roundToMultiple4:!1}}}),this._ktx2DecoderOptions=p,p},h}(),d=function(){function h(p,m){var v,b;m===void 0&&(m=h.DefaultNumWorkers),this._engine=p;var E=typeof m=="object"&&m.workerPool||h.WorkerPool;if(E)h._WorkerPoolPromise=Promise.resolve(E);else{typeof m=="object"?h._KTX2DecoderModule=(v=m?.binariesAndModulesContainer)===null||v===void 0?void 0:v.jsDecoderModule:typeof KTX2DECODER<"u"&&(h._KTX2DecoderModule=KTX2DECODER);var C=typeof m=="number"?m:(b=m.numWorkers)!==null&&b!==void 0?b:h.DefaultNumWorkers;h._Initialize(C)}}return h.GetDefaultNumWorkers=function(){return typeof navigator=="object"&&navigator.hardwareConcurrency?Math.min(Math.floor(.5*navigator.hardwareConcurrency),4):1},h._Initialize=function(p){if(!h._WorkerPoolPromise&&!h._DecoderModulePromise){var m={jsDecoderModule:o.S0.GetBabylonScriptURL(this.URLConfig.jsDecoderModule,!0),wasmUASTCToASTC:o.S0.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC,!0),wasmUASTCToBC7:o.S0.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7,!0),wasmUASTCToRGBA_UNORM:o.S0.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM,!0),wasmUASTCToRGBA_SRGB:o.S0.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB,!0),wasmUASTCToR8_UNORM:o.S0.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM,!0),wasmUASTCToRG8_UNORM:o.S0.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM,!0),jsMSCTranscoder:o.S0.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder,!0),wasmMSCTranscoder:o.S0.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder,!0),wasmZSTDDecoder:o.S0.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder,!0)};p&&typeof Worker=="function"&&typeof URL<"u"?h._WorkerPoolPromise=new Promise(function(v){var b="".concat(l,"(").concat(c,")()"),E=URL.createObjectURL(new Blob([b],{type:"application/javascript"}));v(new i.h(p,function(){return function(C,T,f){return new Promise(function(g,S){var y=function(R){C.removeEventListener("error",y),C.removeEventListener("message",x),S(R)},x=function(R){R.data.action==="init"&&(C.removeEventListener("error",y),C.removeEventListener("message",x),g(C))};C.addEventListener("error",y),C.addEventListener("message",x),C.postMessage({action:"init",urls:f,wasmBinaries:void 0})})}(new Worker(E),0,m)}))}):h._KTX2DecoderModule===void 0?h._DecoderModulePromise=o.S0.LoadBabylonScriptAsync(m.jsDecoderModule).then(function(){return h._KTX2DecoderModule=KTX2DECODER,h._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,h._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,l(m,h._KTX2DecoderModule),new h._KTX2DecoderModule.KTX2Decoder}):(h._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,h._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,h._DecoderModulePromise=Promise.resolve(new h._KTX2DecoderModule.KTX2Decoder))}},h.prototype._uploadAsync=function(p,m,v){var b=this,E=this._engine.getCaps(),C={astc:!!E.astc,bptc:!!E.bptc,s3tc:!!E.s3tc,pvrtc:!!E.pvrtc,etc2:!!E.etc2,etc1:!!E.etc1};if(h._WorkerPoolPromise)return h._WorkerPoolPromise.then(function(T){return new Promise(function(f,g){T.push(function(S,y){var x=function(M){S.removeEventListener("error",x),S.removeEventListener("message",R),g(M),y()},R=function(M){if(M.data.action==="decoded"){if(S.removeEventListener("error",x),S.removeEventListener("message",R),M.data.success)try{b._createTexture(M.data.decodedData,m,v),f()}catch(D){g({message:D})}else g({message:M.data.msg});y()}};S.addEventListener("error",x),S.addEventListener("message",R),S.postMessage({action:"setDefaultDecoderOptions",options:h.DefaultDecoderOptions._getKTX2DecoderOptions()});var I=new Uint8Array(p.byteLength);I.set(new Uint8Array(p.buffer,p.byteOffset,p.byteLength)),S.postMessage({action:"decode",data:I,caps:C,options:v},[I.buffer])})})});if(h._DecoderModulePromise)return h._DecoderModulePromise.then(function(T){return h.DefaultDecoderOptions.isDirty&&(h._KTX2DecoderModule.KTX2Decoder.DefaultDecoderOptions=h.DefaultDecoderOptions._getKTX2DecoderOptions()),new Promise(function(f,g){T.decode(p,E).then(function(S){b._createTexture(S,m),f()}).catch(function(S){g({message:S})})})});throw new Error("KTX2 decoder module is not available")},h.prototype._createTexture=function(p,m,v){this._engine._bindTextureDirectly(3553,m),v&&(v.transcodedFormat=p.transcodedFormat,v.isInGammaSpace=p.isInGammaSpace,v.hasAlpha=p.hasAlpha,v.transcoderName=p.transcoderName);var b=!0;switch(p.transcodedFormat){case 32856:m.type=n.Y.TEXTURETYPE_UNSIGNED_BYTE,m.format=n.Y.TEXTUREFORMAT_RGBA;break;case 33321:m.type=n.Y.TEXTURETYPE_UNSIGNED_BYTE,m.format=n.Y.TEXTUREFORMAT_R;break;case 33323:m.type=n.Y.TEXTURETYPE_UNSIGNED_BYTE,m.format=n.Y.TEXTUREFORMAT_RG;break;default:m.format=p.transcodedFormat,b=!1}if(m._gammaSpace=p.isInGammaSpace,m.generateMipMaps=p.mipmaps.length>1,p.errors)throw new Error("KTX2 container - could not transcode the data. "+p.errors);for(var E=0;E<p.mipmaps.length;++E){var C=p.mipmaps[E];if(!C||!C.data)throw new Error("KTX2 container - could not transcode one of the image");b?(m.width=C.width,m.height=C.height,this._engine._uploadDataToTextureDirectly(m,C.data,0,E,void 0,!0)):this._engine._uploadCompressedDataToTextureDirectly(m,p.transcodedFormat,C.width,C.height,C.data,0,E)}m._extension=".ktx2",m.width=p.mipmaps[0].width,m.height=p.mipmaps[0].height,m.isReady=!0,this._engine._bindTextureDirectly(3553,null)},h.IsValid=function(p){if(p.byteLength>=12){var m=new Uint8Array(p.buffer,p.byteOffset,12);if(m[0]===171&&m[1]===75&&m[2]===84&&m[3]===88&&m[4]===32&&m[5]===50&&m[6]===48&&m[7]===187&&m[8]===13&&m[9]===10&&m[10]===26&&m[11]===10)return!0}return!1},h.URLConfig={jsDecoderModule:"https://cdn.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,wasmUASTCToR8_UNORM:null,wasmUASTCToRG8_UNORM:null,jsMSCTranscoder:null,wasmMSCTranscoder:null,wasmZSTDDecoder:null},h.DefaultNumWorkers=h.GetDefaultNumWorkers(),h.DefaultDecoderOptions=new u,h}()},7164:(r,t,e)=>{e.d(t,{V:()=>i});var n=e(78322),i=function(){function o(){}return o._CheckLimit=function(a,s){var l=o._LogLimitOutputs[a];return l?l.current++:(l={limit:s,current:1},o._LogLimitOutputs[a]=l),l.current<=l.limit},o._GenerateLimitMessage=function(a,s){var l;s===void 0&&(s=1);var c=o._LogLimitOutputs[a];if(c&&o.MessageLimitReached){var u=this._Levels[s];c.current===c.limit&&o[u.name](o.MessageLimitReached.replace(/%LIMIT%/g,""+c.limit).replace(/%TYPE%/g,(l=u.name)!==null&&l!==void 0?l:""))}},o._AddLogEntry=function(a){o._LogCache=a+o._LogCache,o.OnNewCacheEntry&&o.OnNewCacheEntry(a)},o._FormatMessage=function(a){var s=function(c){return c<10?"0"+c:""+c},l=new Date;return"["+s(l.getHours())+":"+s(l.getMinutes())+":"+s(l.getSeconds())+"]: "+a},o._LogDisabled=function(a,s){},o._LogEnabled=function(a,s,l){a===void 0&&(a=1);var c=Array.isArray(s)?s[0]:s;if(l===void 0||o._CheckLimit(c,l)){var u=o._FormatMessage(c),d=this._Levels[a],h=Array.isArray(s)?s.slice(1):[];d.logFunc&&d.logFunc.apply(d,(0,n.fX)(["BJS - "+u],h,!1));var p="<div style='color:".concat(d.color,"'>").concat(u,"</div><br>");o._AddLogEntry(p),o._GenerateLimitMessage(c,a)}},Object.defineProperty(o,"LogCache",{get:function(){return o._LogCache},enumerable:!1,configurable:!0}),o.ClearLogCache=function(){o._LogCache="",o._LogLimitOutputs={},o.errorsCount=0},Object.defineProperty(o,"LogLevels",{set:function(a){var s=this;o.Log=o._LogDisabled,o.Warn=o._LogDisabled,o.Error=o._LogDisabled,[o.MessageLogLevel,o.WarningLogLevel,o.ErrorLogLevel].forEach(function(l){(a&l)===l&&(o[s._Levels[l].name]=o._LogEnabled.bind(o,l))})},enumerable:!1,configurable:!0}),o.NoneLogLevel=0,o.MessageLogLevel=1,o.WarningLogLevel=2,o.ErrorLogLevel=4,o.AllLogLevel=7,o.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",o._LogCache="",o._LogLimitOutputs={},o._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],o.errorsCount=0,o.Log=o._LogEnabled.bind(o,o.MessageLogLevel),o.Warn=o._LogEnabled.bind(o,o.WarningLogLevel),o.Error=o._LogEnabled.bind(o,o.ErrorLogLevel),o}()},66377:(r,t,e)=>{e.d(t,{cP:()=>o,nu:()=>i,qO:()=>n});var n=function(){function a(s,l,c,u){l===void 0&&(l=!1),this.initialize(s,l,c,u)}return a.prototype.initialize=function(s,l,c,u){return l===void 0&&(l=!1),this.mask=s,this.skipNextObservers=l,this.target=c,this.currentTarget=u,this},a}(),i=function(){function a(s,l,c){c===void 0&&(c=null),this.callback=s,this.mask=l,this.scope=c,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}return a.prototype.remove=function(){this._remove&&this._remove()},a}(),o=function(){function a(s,l){l===void 0&&(l=!1),this.notifyIfTriggered=l,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new n(0),s&&(this._onObserverAdded=s)}return a.FromPromise=function(s,l){var c=new a;return s.then(function(u){c.notifyObservers(u)}).catch(function(u){if(!l)throw u;l.notifyObservers(u)}),c},Object.defineProperty(a.prototype,"observers",{get:function(){return this._observers},enumerable:!1,configurable:!0}),a.prototype.add=function(s,l,c,u,d){var h=this;if(l===void 0&&(l=-1),c===void 0&&(c=!1),u===void 0&&(u=null),d===void 0&&(d=!1),!s)return null;var p=new i(s,l,u);return p.unregisterOnNextCall=d,c?this._observers.unshift(p):this._observers.push(p),this._onObserverAdded&&this._onObserverAdded(p),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(p,this._lastNotifiedValue),p._remove=function(){h.remove(p)},p},a.prototype.addOnce=function(s){return this.add(s,void 0,void 0,void 0,!0)},a.prototype.remove=function(s){return!!s&&(s._remove=null,this._observers.indexOf(s)!==-1&&(this._deferUnregister(s),!0))},a.prototype.removeCallback=function(s,l){for(var c=0;c<this._observers.length;c++){var u=this._observers[c];if(!(u._willBeUnregistered||u.callback!==s||l&&l!==u.scope))return this._deferUnregister(u),!0}return!1},a.prototype._deferUnregister=function(s){var l=this;s._willBeUnregistered||(this._numObserversMarkedAsDeleted++,s.unregisterOnNextCall=!1,s._willBeUnregistered=!0,setTimeout(function(){l._remove(s)},0))},a.prototype._remove=function(s,l){if(l===void 0&&(l=!0),!s)return!1;var c=this._observers.indexOf(s);return c!==-1&&(l&&this._numObserversMarkedAsDeleted--,this._observers.splice(c,1),!0)},a.prototype.makeObserverTopPriority=function(s){this._remove(s,!1),this._observers.unshift(s)},a.prototype.makeObserverBottomPriority=function(s){this._remove(s,!1),this._observers.push(s)},a.prototype.notifyObservers=function(s,l,c,u,d){if(l===void 0&&(l=-1),this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=s),!this._observers.length)return!0;var h=this._eventState;h.mask=l,h.target=c,h.currentTarget=u,h.skipNextObservers=!1,h.lastReturnValue=s,h.userInfo=d;for(var p=0,m=this._observers;p<m.length;p++){var v=m[p];if(!v._willBeUnregistered&&(v.mask&l&&(v.unregisterOnNextCall&&this._deferUnregister(v),v.scope?h.lastReturnValue=v.callback.apply(v.scope,[s,h]):h.lastReturnValue=v.callback(s,h)),h.skipNextObservers))return!1}return!0},a.prototype.notifyObserver=function(s,l,c){if(c===void 0&&(c=-1),this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=l),!s._willBeUnregistered){var u=this._eventState;u.mask=c,u.skipNextObservers=!1,s.unregisterOnNextCall&&this._deferUnregister(s),s.callback(l,u)}},a.prototype.hasObservers=function(){return this._observers.length-this._numObserversMarkedAsDeleted>0},a.prototype.clear=function(){for(;this._observers.length;){var s=this._observers.pop();s&&(s._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()},a.prototype.cleanLastNotifiedState=function(){this._hasNotified=!1,this._lastNotifiedValue=void 0},a.prototype.clone=function(){var s=new a;return s._observers=this._observers.slice(0),s},a.prototype.hasSpecificMask=function(s){s===void 0&&(s=-1);for(var l=0,c=this._observers;l<c.length;l++){var u=c[l];if(u.mask&s||u.mask===s)return!0}return!1},a}()},70511:(r,t,e)=>{e.d(t,{A:()=>i});var n=e(85258),i=function(){function o(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(o.prototype,"min",{get:function(){return this._min},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"max",{get:function(){return this._max},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"average",{get:function(){return this._average},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"current",{get:function(){return this._current},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!1,configurable:!0}),o.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},o.prototype.addCount=function(a,s){o.Enabled&&(this._current+=a,s&&this._fetchResult())},o.prototype.beginMonitoring=function(){o.Enabled&&(this._startMonitoringTime=n.j.Now)},o.prototype.endMonitoring=function(a){if(a===void 0&&(a=!0),o.Enabled){a&&this.fetchNewFrame();var s=n.j.Now;this._current=s-this._startMonitoringTime,a&&this._fetchResult()}},o.prototype.endFrame=function(){this._fetchResult()},o.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var a=n.j.Now;a-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=a,this._lastSecAccumulated=0,this._lastSecValueCount=0)},o.Enabled=!0,o}()},85258:(r,t,e)=>{e.d(t,{j:()=>i});var n=e(5153),i=function(){function o(){}return Object.defineProperty(o,"Now",{get:function(){return(0,n.BA)()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),o}()},49449:(r,t,e)=>{e.d(t,{a:()=>n});var n=function(){function i(){}return i.ExponentialBackoff=function(o,a){return o===void 0&&(o=3),a===void 0&&(a=500),function(s,l,c){return l.status!==0||c>=o||s.indexOf("file:")!==-1?-1:Math.pow(2,c)*a}},i}()},97411:(r,t,e)=>{e.d(t,{G:()=>s});var n=e(78322),i=e(81152),o=e(30622),a=(e(71073),e(35877)),s=function(){function l(){}return l.ExpandRGBDTexture=function(c){var u=this,d=c._texture;if(d&&c.isRGBD){var h=d.getEngine(),p=h.getCaps(),m=d.isReady,v=!1;p.textureHalfFloatRender&&p.textureHalfFloatLinearFiltering?(v=!0,d.type=i.Y.TEXTURETYPE_HALF_FLOAT):p.textureFloatRender&&p.textureFloatLinearFiltering&&(v=!0,d.type=i.Y.TEXTURETYPE_FLOAT),v&&(d.isReady=!1,d._isRGBD=!1,d.invertY=!1);var b=function(){return(0,n.sH)(u,void 0,void 0,function(){var E,C,T,f;return(0,n.YH)(this,function(g){switch(g.label){case 0:return E=h.isWebGPU,C=E?1:0,d.isReady=!1,this._ShaderImported?[3,4]:(this._ShaderImported=!0,E?[4,Promise.all([Promise.resolve().then(e.bind(e,37494)),Promise.resolve().then(e.bind(e,86558))])]:[3,2]);case 1:return g.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(e.bind(e,32407)),Promise.resolve().then(e.bind(e,22955))])];case 3:g.sent(),g.label=4;case 4:return(T=new o.w("rgbdDecode","rgbdDecode",null,null,1,null,i.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,h,!1,void 0,d.type,void 0,null,!1,void 0,C)).externalTextureSamplerBinding=!0,f=h.createRenderTargetTexture(d.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:d.samplingMode,type:d.type,format:i.Y.TEXTUREFORMAT_RGBA}),T.onEffectCreatedObservable.addOnce(function(S){S.executeWhenCompiled(function(){T.onApply=function(y){y._bindTexture("textureSampler",d),y.setFloat2("scale",1,1)},c.getScene().postProcessManager.directRender([T],f,!0),h.restoreDefaultFramebuffer(),h._releaseTexture(d),T&&T.dispose(),f._swapAndDie(d),d.isReady=!0})}),[2]}})})};v&&(m?b():c.onLoadObservable.addOnce(b))}},l.EncodeTextureToRGBD=function(c,u,d){return d===void 0&&(d=i.Y.TEXTURETYPE_UNSIGNED_BYTE),(0,a.Qs)("rgbdEncode",c,u,d,i.Y.TEXTURE_NEAREST_SAMPLINGMODE,i.Y.TEXTUREFORMAT_RGBA)},l._ShaderImported=!1,l}()},53770:(r,t,e)=>{e.d(t,{L:()=>i,b:()=>o});var n=e(78322),i=function(){function a(s){this.length=0,this.data=new Array(s),this._id=a._GlobalId++}return a.prototype.push=function(s){this.data[this.length++]=s,this.length>this.data.length&&(this.data.length*=2)},a.prototype.forEach=function(s){for(var l=0;l<this.length;l++)s(this.data[l])},a.prototype.sort=function(s){this.data.sort(s)},a.prototype.reset=function(){this.length=0},a.prototype.dispose=function(){this.reset(),this.data&&(this.data.length=0)},a.prototype.concat=function(s){if(s.length!==0){this.length+s.length>this.data.length&&(this.data.length=2*(this.length+s.length));for(var l=0;l<s.length;l++)this.data[this.length++]=(s.data||s)[l]}},a.prototype.indexOf=function(s){var l=this.data.indexOf(s);return l>=this.length?-1:l},a.prototype.contains=function(s){return this.indexOf(s)!==-1},a._GlobalId=0,a}(),o=function(a){function s(){var l=a!==null&&a.apply(this,arguments)||this;return l._duplicateId=0,l}return(0,n.C6)(s,a),s.prototype.push=function(l){a.prototype.push.call(this,l),l.__smartArrayFlags||(l.__smartArrayFlags={}),l.__smartArrayFlags[this._id]=this._duplicateId},s.prototype.pushNoDuplicate=function(l){return!(l.__smartArrayFlags&&l.__smartArrayFlags[this._id]===this._duplicateId||(this.push(l),0))},s.prototype.reset=function(){a.prototype.reset.call(this),this._duplicateId++},s.prototype.concatWithNoDuplicate=function(l){if(l.length!==0){this.length+l.length>this.data.length&&(this.data.length=2*(this.length+l.length));for(var c=0;c<l.length;c++){var u=(l.data||l)[c];this.pushNoDuplicate(u)}}},s}(i)},59437:(r,t,e)=>{e.d(t,{w:()=>n});var n=function(){function i(){this._count=0,this._data={}}return i.prototype.copyFrom=function(o){var a=this;this.clear(),o.forEach(function(s,l){return a.add(s,l)})},i.prototype.get=function(o){var a=this._data[o];if(a!==void 0)return a},i.prototype.getOrAddWithFactory=function(o,a){var s=this.get(o);return s!==void 0||(s=a(o))&&this.add(o,s),s},i.prototype.getOrAdd=function(o,a){var s=this.get(o);return s!==void 0?s:(this.add(o,a),a)},i.prototype.contains=function(o){return this._data[o]!==void 0},i.prototype.add=function(o,a){return this._data[o]===void 0&&(this._data[o]=a,++this._count,!0)},i.prototype.set=function(o,a){return this._data[o]!==void 0&&(this._data[o]=a,!0)},i.prototype.getAndRemove=function(o){var a=this.get(o);return a!==void 0?(delete this._data[o],--this._count,a):null},i.prototype.remove=function(o){return!!this.contains(o)&&(delete this._data[o],--this._count,!0)},i.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(i.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),i.prototype.forEach=function(o){for(var a in this._data)o(a,this._data[a])},i.prototype.first=function(o){for(var a in this._data){var s=o(a,this._data[a]);if(s)return s}return null},i}()},37530:(r,t,e)=>{e.d(t,{AV:()=>s,EL:()=>a,LW:()=>c,Tq:()=>o,UH:()=>i,jq:()=>n,nQ:()=>u,yS:()=>l});var n=function(d,h){return d.endsWith(h)},i=function(d,h){return!!d&&d.startsWith(h)},o=function(d){if(typeof TextDecoder<"u")return new TextDecoder().decode(d);for(var h="",p=0;p<d.byteLength;p++)h+=String.fromCharCode(d[p]);return h},a=function(d){for(var h,p,m,v,b,E,C,T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="",g=0,S=ArrayBuffer.isView(d)?new Uint8Array(d.buffer,d.byteOffset,d.byteLength):new Uint8Array(d);g<S.length;)v=(h=S[g++])>>2,b=(3&h)<<4|(p=g<S.length?S[g++]:Number.NaN)>>4,E=(15&p)<<2|(m=g<S.length?S[g++]:Number.NaN)>>6,C=63&m,isNaN(p)?E=C=64:isNaN(m)&&(C=64),f+=T.charAt(v)+T.charAt(b)+T.charAt(E)+T.charAt(C);return f},s=function(d){return atob(d)},l=function(d){for(var h=s(d),p=h.length,m=new Uint8Array(new ArrayBuffer(p)),v=0;v<p;v++)m[v]=h.charCodeAt(v);return m.buffer},c=function(d,h){for(var p=String(d);p.length<h;)p="0"+p;return p},u={EndsWith:n,StartsWith:i,Decode:o,EncodeArrayBufferToBase64:a,DecodeBase64ToString:s,DecodeBase64ToBinary:l,PadNumber:c}},31985:(r,t,e)=>{e.d(t,{Y:()=>i});var n=e(92548),i=function(){function o(){}return o.EnableFor=function(a){a._tags=a._tags||{},a.hasTags=function(){return o.HasTags(a)},a.addTags=function(s){return o.AddTagsTo(a,s)},a.removeTags=function(s){return o.RemoveTagsFrom(a,s)},a.matchesTagsQuery=function(s){return o.MatchesQuery(a,s)}},o.DisableFor=function(a){delete a._tags,delete a.hasTags,delete a.addTags,delete a.removeTags,delete a.matchesTagsQuery},o.HasTags=function(a){if(!a._tags)return!1;var s=a._tags;for(var l in s)if(Object.prototype.hasOwnProperty.call(s,l))return!0;return!1},o.GetTags=function(a,s){if(s===void 0&&(s=!0),!a._tags)return null;if(s){var l=[];for(var c in a._tags)Object.prototype.hasOwnProperty.call(a._tags,c)&&a._tags[c]===!0&&l.push(c);return l.join(" ")}return a._tags},o.AddTagsTo=function(a,s){s&&typeof s=="string"&&s.split(" ").forEach(function(l){o._AddTagTo(a,l)})},o._AddTagTo=function(a,s){(s=s.trim())!==""&&s!=="true"&&s!=="false"&&(s.match(/[\s]/)||s.match(/^([!]|([|]|[&]){2})/)||(o.EnableFor(a),a._tags[s]=!0))},o.RemoveTagsFrom=function(a,s){if(o.HasTags(a)){var l=s.split(" ");for(var c in l)o._RemoveTagFrom(a,l[c])}},o._RemoveTagFrom=function(a,s){delete a._tags[s]},o.MatchesQuery=function(a,s){return s===void 0||(s===""?o.HasTags(a):n.Z.Eval(s,function(l){return o.HasTags(a)&&a._tags[l]}))},o}()},35877:(r,t,e)=>{e.d(t,{Qs:()=>p,EE:()=>h,SX:()=>v,Oz:()=>E,LO:()=>C,LZ:()=>m});var n=e(78322),i=e(50582),o=e(41085),a=e(73441),s=e(81152),l=e(30622),c=e(98519);c.l.ShadersStore.lodPixelShader=`#extension GL_EXT_shader_texture_lod : enable
|
||
precision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform sampler2D textureSampler;uniform float lod;uniform vec2 texSize;uniform bool gamma;void main(void)
|
||
{gl_FragColor=textureLod(textureSampler,vUV,lod);if (!gamma) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}
|
||
`;var u,d;function h(T,f,g,S){S===void 0&&(S=!0);var y=T.getScene(),x=y.getEngine(),R=new o.$("resized"+T.name,{width:f,height:g},y,!T.noMipmap,!0,T._texture.type,!1,T.samplingMode,!1);R.wrapU=T.wrapU,R.wrapV=T.wrapV,R.uOffset=T.uOffset,R.vOffset=T.vOffset,R.uScale=T.uScale,R.vScale=T.vScale,R.uAng=T.uAng,R.vAng=T.vAng,R.wAng=T.wAng,R.coordinatesIndex=T.coordinatesIndex,R.level=T.level,R.anisotropicFilteringLevel=T.anisotropicFilteringLevel,R._texture.isReady=!1,T.wrapU=i.g.CLAMP_ADDRESSMODE,T.wrapV=i.g.CLAMP_ADDRESSMODE;var I=new a.v("pass",1,null,S?i.g.BILINEAR_SAMPLINGMODE:i.g.NEAREST_SAMPLINGMODE,x,!1,s.Y.TEXTURETYPE_UNSIGNED_INT);return I.externalTextureSamplerBinding=!0,I.onEffectCreatedObservable.addOnce(function(M){M.executeWhenCompiled(function(){I.onApply=function(B){B.setTexture("textureSampler",T)};var D=R.renderTarget;D&&(y.postProcessManager.directRender([I],D),x.unBindFramebuffer(D),R.disposeFramebufferObjects(),I.dispose(),R.getInternalTexture().isReady=!0)})}),R}function p(T,f,g,S,y,x,R,I){var M=f.getEngine();return f.isReady=!1,y=y??f.samplingMode,S=S??f.type,x=x??f.format,R=R??f.width,I=I??f.height,S===-1&&(S=s.Y.TEXTURETYPE_UNSIGNED_BYTE),new Promise(function(D){var B=new l.w("postprocess",T,null,null,1,null,y,M,!1,void 0,S,void 0,null,!1,x);B.externalTextureSamplerBinding=!0;var F=M.createRenderTargetTexture({width:R,height:I},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:y,type:S,format:x});B.onEffectCreatedObservable.addOnce(function(X){X.executeWhenCompiled(function(){B.onApply=function($){$._bindTexture("textureSampler",f),$.setFloat2("scale",1,1)},g.postProcessManager.directRender([B],F,!0),M.restoreDefaultFramebuffer(),M._releaseTexture(f),B&&B.dispose(),F._swapAndDie(f),f.type=S,f.format=s.Y.TEXTUREFORMAT_RGBA,f.isReady=!0,D(f)})})})}function m(T){u||(u=new Float32Array(1),d=new Int32Array(u.buffer)),u[0]=T;var f=d[0],g=f>>16&32768,S=f>>12&2047,y=f>>23&255;return y<103?g:y>142?(g|=31744,g|=(y==255?0:1)&&8388607&f):y<113?g|=((S|=2048)>>114-y)+(S>>113-y&1):(g|=y-112<<10|S>>1,g+=1&S)}function v(T){var f=(32768&T)>>15,g=(31744&T)>>10,S=1023&T;return g===0?(f?-1:1)*Math.pow(2,-14)*(S/Math.pow(2,10)):g==31?S?NaN:1/0*(f?-1:1):(f?-1:1)*Math.pow(2,g-15)*(1+S/Math.pow(2,10))}c.l.ShadersStore.lodCubePixelShader=`precision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform samplerCube textureSampler;uniform float lod;uniform bool gamma;void main(void)
|
||
{vec2 uv=vUV*2.0-1.0;
|
||
#ifdef POSITIVEX
|
||
gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x),lod);
|
||
#endif
|
||
#ifdef NEGATIVEX
|
||
gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x),lod);
|
||
#endif
|
||
#ifdef POSITIVEY
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x),lod);
|
||
#endif
|
||
#ifdef NEGATIVEY
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x),lod);
|
||
#endif
|
||
#ifdef POSITIVEZ
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv,1.001),lod);
|
||
#endif
|
||
#ifdef NEGATIVEZ
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001),lod);
|
||
#endif
|
||
if (!gamma) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}
|
||
`;var b=function(T,f,g,S,y){return(0,n.sH)(void 0,void 0,void 0,function(){var x,R,I,M,D,B,F,X,$;return(0,n.YH)(this,function(Q){switch(Q.label){case 0:return x=T.getScene(),R=x.getEngine(),T.isCube?(M=["#define POSITIVEX","#define NEGATIVEX","#define POSITIVEY","#define NEGATIVEY","#define POSITIVEZ","#define NEGATIVEZ"],I=new l.w("lodCube","lodCube",["lod","gamma"],null,1,null,i.g.NEAREST_NEAREST_MIPNEAREST,R,!1,M[S])):I=new l.w("lod","lod",["lod","gamma"],null,1,null,i.g.NEAREST_NEAREST_MIPNEAREST,R),[4,new Promise(function(ie){I.onEffectCreatedObservable.addOnce(function(q){q.executeWhenCompiled(function(){ie(0)})})})];case 1:Q.sent(),D=new o.$("temp",{width:f,height:g},x,!1),I.onApply=function(ie){ie.setTexture("textureSampler",T),ie.setFloat("lod",y),ie.setBool("gamma",T.gammaSpace)},B=T.getInternalTexture(),Q.label=2;case 2:return Q.trys.push([2,,6,7]),D.renderTarget&&B?(F=B.samplingMode,y!==0?T.updateSamplingMode(i.g.NEAREST_NEAREST_MIPNEAREST):T.updateSamplingMode(i.g.NEAREST_NEAREST),x.postProcessManager.directRender([I],D.renderTarget,!0),T.updateSamplingMode(F),[4,R.readPixels(0,0,f,g)]):[3,4];case 3:return X=Q.sent(),$=new Uint8Array(X.buffer,0,X.byteLength),R.unBindFramebuffer(D.renderTarget),[2,$];case 4:throw Error("Render to texture failed.");case 5:return[3,7];case 6:return D.dispose(),I.dispose(),[7];case 7:return[2]}})})};function E(T,f,g,S,y){return S===void 0&&(S=0),y===void 0&&(y=0),(0,n.sH)(this,void 0,void 0,function(){return(0,n.YH)(this,function(x){switch(x.label){case 0:return T.isReady()||!T._texture?[3,2]:[4,new Promise(function(R,I){T._texture!==null?T._texture.onLoadedObservable.addOnce(function(){R(0)}):I(0)})];case 1:x.sent(),x.label=2;case 2:return[4,b(T,f,g,S,y)];case 3:return[2,x.sent()]}})})}var C={CreateResizedCopy:h,ApplyPostProcess:p,ToHalfFloat:m,FromHalfFloat:v,GetTextureDataAsync:E}},65054:(r,t,e)=>{e.d(t,{FA:()=>E,O_:()=>b,uT:()=>C});var n=e(7164),i=1,o=2,a=3,s=9,l=10,c=11,u=48,d=4,h=0,p=1,m=2,v=3;function b(T){var f=0;return{id_length:T[f++],colormap_type:T[f++],image_type:T[f++],colormap_index:T[f++]|T[f++]<<8,colormap_length:T[f++]|T[f++]<<8,colormap_size:T[f++],origin:[T[f++]|T[f++]<<8,T[f++]|T[f++]<<8],width:T[f++]|T[f++]<<8,height:T[f++]|T[f++]<<8,pixel_size:T[f++],flags:T[f++]}}function E(T,f){if(f.length<19)n.V.Error("Unable to load TGA file - Not enough data to contain header");else{var g=18,S=b(f);if(S.id_length+g>f.length)n.V.Error("Unable to load TGA file - Not enough data");else{g+=S.id_length;var y,x=!1,R=!1,I=!1;switch(S.image_type){case s:x=!0;case i:R=!0;break;case l:x=!0;case o:break;case c:x=!0;case a:I=!0}var M,D,B,F,X,$,Q,ie=S.pixel_size>>3,q=S.width*S.height*ie;if(R&&(M=f.subarray(g,g+=S.colormap_length*(S.colormap_size>>3))),x){y=new Uint8Array(q);for(var ee=void 0,te=void 0,ce=void 0,fe=0,de=new Uint8Array(ie);g<q&&fe<q;)if(te=1+(127&(ee=f[g++])),128&ee){for(ce=0;ce<ie;++ce)de[ce]=f[g++];for(ce=0;ce<te;++ce)y.set(de,fe+ce*ie);fe+=ie*te}else{for(te*=ie,ce=0;ce<te;++ce)y[fe+ce]=f[g++];fe+=te}}else y=f.subarray(g,g+=R?S.width*S.height:q);switch((S.flags&u)>>d){default:case m:D=0,F=1,Q=S.width,B=0,X=1,$=S.height;break;case h:D=0,F=1,Q=S.width,B=S.height-1,X=-1,$=-1;break;case v:D=S.width-1,F=-1,Q=-1,B=0,X=1,$=S.height;break;case p:D=S.width-1,F=-1,Q=-1,B=S.height-1,X=-1,$=-1}var Te="_getImageData"+(I?"Grey":"")+S.pixel_size+"bits",ue=C[Te](S,M,y,B,X,$,D,F,Q);T.getEngine()._uploadDataToTextureDirectly(T,ue)}}}var C={GetTGAHeader:b,UploadContent:E,_getImageData8bits:function(T,f,g,S,y,x,R,I,M){var D,B,F,X=g,$=f,Q=T.width,ie=T.height,q=0,ee=new Uint8Array(Q*ie*4);for(F=S;F!==x;F+=y)for(B=R;B!==M;B+=I,q++)D=X[q],ee[4*(B+Q*F)+3]=255,ee[4*(B+Q*F)+2]=$[3*D+0],ee[4*(B+Q*F)+1]=$[3*D+1],ee[4*(B+Q*F)+0]=$[3*D+2];return ee},_getImageData16bits:function(T,f,g,S,y,x,R,I,M){var D,B,F,X=g,$=T.width,Q=T.height,ie=0,q=new Uint8Array($*Q*4);for(F=S;F!==x;F+=y)for(B=R;B!==M;B+=I,ie+=2){var ee=255*((31744&(D=X[ie+0]+(X[ie+1]<<8)))>>10)/31|0,te=255*((992&D)>>5)/31|0,ce=255*(31&D)/31|0;q[4*(B+$*F)+0]=ee,q[4*(B+$*F)+1]=te,q[4*(B+$*F)+2]=ce,q[4*(B+$*F)+3]=32768&D?0:255}return q},_getImageData24bits:function(T,f,g,S,y,x,R,I,M){var D,B,F=g,X=T.width,$=T.height,Q=0,ie=new Uint8Array(X*$*4);for(B=S;B!==x;B+=y)for(D=R;D!==M;D+=I,Q+=3)ie[4*(D+X*B)+3]=255,ie[4*(D+X*B)+2]=F[Q+0],ie[4*(D+X*B)+1]=F[Q+1],ie[4*(D+X*B)+0]=F[Q+2];return ie},_getImageData32bits:function(T,f,g,S,y,x,R,I,M){var D,B,F=g,X=T.width,$=T.height,Q=0,ie=new Uint8Array(X*$*4);for(B=S;B!==x;B+=y)for(D=R;D!==M;D+=I,Q+=4)ie[4*(D+X*B)+2]=F[Q+0],ie[4*(D+X*B)+1]=F[Q+1],ie[4*(D+X*B)+0]=F[Q+2],ie[4*(D+X*B)+3]=F[Q+3];return ie},_getImageDataGrey8bits:function(T,f,g,S,y,x,R,I,M){var D,B,F,X=g,$=T.width,Q=T.height,ie=0,q=new Uint8Array($*Q*4);for(F=S;F!==x;F+=y)for(B=R;B!==M;B+=I,ie++)D=X[ie],q[4*(B+$*F)+0]=D,q[4*(B+$*F)+1]=D,q[4*(B+$*F)+2]=D,q[4*(B+$*F)+3]=255;return q},_getImageDataGrey16bits:function(T,f,g,S,y,x,R,I,M){var D,B,F=g,X=T.width,$=T.height,Q=0,ie=new Uint8Array(X*$*4);for(B=S;B!==x;B+=y)for(D=R;D!==M;D+=I,Q+=2)ie[4*(D+X*B)+0]=F[Q+0],ie[4*(D+X*B)+1]=F[Q+0],ie[4*(D+X*B)+2]=F[Q+0],ie[4*(D+X*B)+3]=F[Q+1];return ie}}},53695:(r,t,e)=>{e.d(t,{_:()=>i});var n=e(5153),i=function(){function o(){}return o.SetImmediate=function(a){(0,n.BA)()&&window.setImmediate?window.setImmediate(a):setTimeout(a,1)},o}()},87074:(r,t,e)=>{e.d(t,{C4:()=>l,L8:()=>i,OG:()=>a,R:()=>c,zF:()=>o});var n=e(81152);function i(u){var d=1;do d*=2;while(d<u);return d===u}function o(u,d,h){return u*(1-h)+d*h}function a(u){var d=s(u),h=l(u);return d-u>u-h?h:d}function s(u){return u--,u|=u>>1,u|=u>>2,u|=u>>4,u|=u>>8,u|=u>>16,++u}function l(u){return u|=u>>1,u|=u>>2,u|=u>>4,u|=u>>8,(u|=u>>16)-(u>>1)}function c(u,d,h){var p;switch(h===void 0&&(h=n.Y.SCALEMODE_NEAREST),h){case n.Y.SCALEMODE_FLOOR:p=l(u);break;case n.Y.SCALEMODE_NEAREST:p=a(u);break;case n.Y.SCALEMODE_CEILING:default:p=s(u)}return Math.min(p,d)}},44957:(r,t,e)=>{e.d(t,{LV:()=>T,S0:()=>E,s7:()=>C});var n=e(78322),i=e(66377),o=e(5153),a=e(7164),s=e(44576),l=e(85258),c=e(41190),u=e(46799),d=e(66614),h=e(17347),p=e(53695),m=e(252),v=e(23885),b=e(87074),E=function(){function f(){}return Object.defineProperty(f,"BaseUrl",{get:function(){return h.eC.BaseUrl},set:function(g){h.eC.BaseUrl=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"CleanUrl",{get:function(){return h.eC.CleanUrl},set:function(g){h.eC.CleanUrl=g},enumerable:!1,configurable:!0}),f.IsAbsoluteUrl=function(g){return g.indexOf("//")===0||g.indexOf("://")!==-1&&g.indexOf(".")!==-1&&g.indexOf("/")!==-1&&!(g.indexOf(":")>g.indexOf("/"))&&(g.indexOf("://")<g.indexOf(".")||g.indexOf("data:")===0||g.indexOf("blob:")===0)},Object.defineProperty(f,"ScriptBaseUrl",{get:function(){return h.eC.ScriptBaseUrl},set:function(g){h.eC.ScriptBaseUrl=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"ScriptPreprocessUrl",{get:function(){return h.eC.ScriptPreprocessUrl},set:function(g){h.eC.ScriptPreprocessUrl=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"DefaultRetryStrategy",{get:function(){return h.eC.DefaultRetryStrategy},set:function(g){h.eC.DefaultRetryStrategy=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"CorsBehavior",{get:function(){return h.eC.CorsBehavior},set:function(g){h.eC.CorsBehavior=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"UseFallbackTexture",{get:function(){return d.q.UseFallbackTexture},set:function(g){d.q.UseFallbackTexture=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"RegisteredExternalClasses",{get:function(){return m.n.RegisteredExternalClasses},set:function(g){m.n.RegisteredExternalClasses=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"fallbackTexture",{get:function(){return d.q.FallbackTexture},set:function(g){d.q.FallbackTexture=g},enumerable:!1,configurable:!0}),f.FetchToRef=function(g,S,y,x,R,I){var M=4*((Math.abs(g)*y%y|0)+(Math.abs(S)*x%x|0)*y);I.r=R[M]/255,I.g=R[M+1]/255,I.b=R[M+2]/255,I.a=R[M+3]/255},f.Mix=function(g,S,y){return 0},f.Instantiate=function(g){return m.n.Instantiate(g)},f.SetImmediate=function(g){p._.SetImmediate(g)},f.IsExponentOfTwo=function(g){return!0},f.FloatRound=function(g){return Math.fround(g)},f.GetFilename=function(g){var S=g.lastIndexOf("/");return S<0?g:g.substring(S+1)},f.GetFolderPath=function(g,S){S===void 0&&(S=!1);var y=g.lastIndexOf("/");return y<0?S?g:"":g.substring(0,y+1)},f.ToDegrees=function(g){return 180*g/Math.PI},f.ToRadians=function(g){return g*Math.PI/180},f.SmoothAngleChange=function(g,S,y){y===void 0&&(y=.9);var x=this.ToRadians(g),R=this.ToRadians(S);return this.ToDegrees(Math.atan2((1-y)*Math.sin(R)+y*Math.sin(x),(1-y)*Math.cos(R)+y*Math.cos(x)))},f.MakeArray=function(g,S){return S===!0||g!==void 0&&g!=null?Array.isArray(g)?g:[g]:null},f.GetPointerPrefix=function(g){var S="pointer";return(0,o.BA)()&&!window.PointerEvent&&(S="mouse"),!g._badDesktopOS||g._badOS||document&&"ontouchend"in document||(S="mouse"),S},f.SetCorsBehavior=function(g,S){(0,h.M1)(g,S)},f.SetReferrerPolicyBehavior=function(g,S){S.referrerPolicy=g},Object.defineProperty(f,"PreprocessUrl",{get:function(){return h.eC.PreprocessUrl},set:function(g){h.eC.PreprocessUrl=g},enumerable:!1,configurable:!0}),f.LoadImage=function(g,S,y,x,R,I){return(0,h.W$)(g,S,y,x,R,I)},f.LoadFile=function(g,S,y,x,R,I){return(0,h.zU)(g,S,y,x,R,I)},f.LoadFileAsync=function(g,S){return S===void 0&&(S=!0),new Promise(function(y,x){(0,h.zU)(g,function(R){y(R)},void 0,void 0,S,function(R,I){x(I)})})},f.GetBabylonScriptURL=function(g,S){if(!g)return"";if(f.ScriptBaseUrl&&g.startsWith(f._DefaultCdnUrl)){var y=f.ScriptBaseUrl[f.ScriptBaseUrl.length-1]==="/"?f.ScriptBaseUrl.substring(0,f.ScriptBaseUrl.length-1):f.ScriptBaseUrl;g=g.replace(f._DefaultCdnUrl,y)}return g=f.ScriptPreprocessUrl(g),S&&(g=f.GetAbsoluteUrl(g)),g},f.LoadBabylonScript=function(g,S,y,x){g=f.GetBabylonScriptURL(g),f.LoadScript(g,S,y)},f.LoadBabylonScriptAsync=function(g){return g=f.GetBabylonScriptURL(g),f.LoadScriptAsync(g)},f.LoadScript=function(g,S,y,x){if(typeof importScripts!="function")if((0,o.BA)()){var R=document.getElementsByTagName("head")[0],I=document.createElement("script");I.setAttribute("type","text/javascript"),I.setAttribute("src",g),x&&(I.id=x),I.onload=function(){S&&S()},I.onerror=function(M){y&&y("Unable to load script '".concat(g,"'"),M)},R.appendChild(I)}else y?.("Cannot load script '".concat(g,"' outside of a window or a worker"));else try{importScripts(g),S()}catch(M){y?.("Unable to load script '".concat(g,"' in worker"),M)}},f.LoadScriptAsync=function(g,S){var y=this;return new Promise(function(x,R){y.LoadScript(g,function(){x()},function(I,M){R(M||new Error(I))},S)})},f.ReadFileAsDataURL=function(g,S,y){var x=new FileReader,R={onCompleteObservable:new i.cP,abort:function(){return x.abort()}};return x.onloadend=function(){R.onCompleteObservable.notifyObservers(R)},x.onload=function(I){S(I.target.result)},x.onprogress=y,x.readAsDataURL(g),R},f.ReadFile=function(g,S,y,x,R){return(0,h.NJ)(g,S,y,x,R)},f.FileAsURL=function(g){var S=new Blob([g]);return window.URL.createObjectURL(S)},f.Format=function(g,S){return S===void 0&&(S=2),g.toFixed(S)},f.DeepCopy=function(g,S,y,x){s.r.DeepCopy(g,S,y,x)},f.IsEmpty=function(g){for(var S in g)if(Object.prototype.hasOwnProperty.call(g,S))return!1;return!0},f.RegisterTopRootEvents=function(g,S){for(var y=0;y<S.length;y++){var x=S[y];g.addEventListener(x.name,x.handler,!1);try{window.parent&&window.parent.addEventListener(x.name,x.handler,!1)}catch{}}},f.UnregisterTopRootEvents=function(g,S){for(var y=0;y<S.length;y++){var x=S[y];g.removeEventListener(x.name,x.handler);try{g.parent&&g.parent.removeEventListener(x.name,x.handler)}catch{}}},f.DumpFramebuffer=function(g,S,y,x,R,I,M){return(0,n.sH)(this,void 0,void 0,function(){return(0,n.YH)(this,function(D){throw(0,c.n)("DumpTools")})})},f.DumpData=function(g,S,y,x,R,I,M,D,B){throw(0,c.n)("DumpTools")},f.DumpDataAsync=function(g,S,y,x,R,I,M,D){throw(0,c.n)("DumpTools")},f._IsOffScreenCanvas=function(g){return g.convertToBlob!==void 0},f.ToBlob=function(g,S,y,x){y===void 0&&(y="image/png"),f._IsOffScreenCanvas(g)||g.toBlob||(g.toBlob=function(R,I,M){var D=this;setTimeout(function(){for(var B=atob(D.toDataURL(I,M).split(",")[1]),F=B.length,X=new Uint8Array(F),$=0;$<F;$++)X[$]=B.charCodeAt($);R(new Blob([X]))})}),f._IsOffScreenCanvas(g)?g.convertToBlob({type:y,quality:x}).then(function(R){return S(R)}):g.toBlob(function(R){S(R)},y,x)},f.DownloadBlob=function(g,S){if("download"in document.createElement("a")){if(!S){var y=new Date;S="screenshot_"+(y.getFullYear()+"-"+(y.getMonth()+1)).slice(2)+"-"+y.getDate()+"_"+y.getHours()+"-"+("0"+y.getMinutes()).slice(-2)+".png"}f.Download(g,S)}else if(g&&typeof URL<"u"){var x=URL.createObjectURL(g),R=window.open("");if(!R)return;var I=R.document.createElement("img");I.onload=function(){URL.revokeObjectURL(x)},I.src=x,R.document.body.appendChild(I)}},f.EncodeScreenshotCanvasData=function(g,S,y,x,R){if(y===void 0&&(y="image/png"),typeof x!="string"&&S){if(S){if(f._IsOffScreenCanvas(g))return void g.convertToBlob({type:y,quality:R}).then(function(M){var D=new FileReader;D.readAsDataURL(M),D.onloadend=function(){var B=D.result;S(B)}});var I=g.toDataURL(y,R);S(I)}}else this.ToBlob(g,function(M){M&&f.DownloadBlob(M,x),S&&S("")},y,R)},f.Download=function(g,S){if(typeof URL<"u"){var y=window.URL.createObjectURL(g),x=document.createElement("a");document.body.appendChild(x),x.style.display="none",x.href=y,x.download=S,x.addEventListener("click",function(){x.parentElement&&x.parentElement.removeChild(x)}),x.click(),window.URL.revokeObjectURL(y)}},f.BackCompatCameraNoPreventDefault=function(g){return typeof g[0]=="boolean"?g[0]:typeof g[1]=="boolean"&&g[1]},f.CreateScreenshot=function(g,S,y,x,R,I,M){throw(0,c.n)("ScreenshotTools")},f.CreateScreenshotAsync=function(g,S,y,x,R){throw(0,c.n)("ScreenshotTools")},f.CreateScreenshotUsingRenderTarget=function(g,S,y,x,R,I,M,D,B,F,X,$,Q){throw(0,c.n)("ScreenshotTools")},f.CreateScreenshotUsingRenderTargetAsync=function(g,S,y,x,R,I,M,D,B,F,X,$){throw(0,c.n)("ScreenshotTools")},f.RandomId=function(){return(0,v.z)()},f.IsBase64=function(g){return(0,h.f2)(g)},f.DecodeBase64=function(g){return(0,h.rz)(g)},Object.defineProperty(f,"errorsCount",{get:function(){return a.V.errorsCount},enumerable:!1,configurable:!0}),f.Log=function(g){a.V.Log(g)},f.Warn=function(g){a.V.Warn(g)},f.Error=function(g){a.V.Error(g)},Object.defineProperty(f,"LogCache",{get:function(){return a.V.LogCache},enumerable:!1,configurable:!0}),f.ClearLogCache=function(){a.V.ClearLogCache()},Object.defineProperty(f,"LogLevels",{set:function(g){a.V.LogLevels=g},enumerable:!1,configurable:!0}),Object.defineProperty(f,"PerformanceLogLevel",{set:function(g){return(g&f.PerformanceUserMarkLogLevel)===f.PerformanceUserMarkLogLevel?(f.StartPerformanceCounter=f._StartUserMark,void(f.EndPerformanceCounter=f._EndUserMark)):(g&f.PerformanceConsoleLogLevel)===f.PerformanceConsoleLogLevel?(f.StartPerformanceCounter=f._StartPerformanceConsole,void(f.EndPerformanceCounter=f._EndPerformanceConsole)):(f.StartPerformanceCounter=f._StartPerformanceCounterDisabled,void(f.EndPerformanceCounter=f._EndPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),f._StartPerformanceCounterDisabled=function(g,S){},f._EndPerformanceCounterDisabled=function(g,S){},f._StartUserMark=function(g,S){if(S===void 0&&(S=!0),!f._Performance){if(!(0,o.BA)())return;f._Performance=window.performance}S&&f._Performance.mark&&f._Performance.mark(g+"-Begin")},f._EndUserMark=function(g,S){S===void 0&&(S=!0),S&&f._Performance.mark&&(f._Performance.mark(g+"-End"),f._Performance.measure(g,g+"-Begin",g+"-End"))},f._StartPerformanceConsole=function(g,S){S===void 0&&(S=!0),S&&(f._StartUserMark(g,S),console.time&&console.time(g))},f._EndPerformanceConsole=function(g,S){S===void 0&&(S=!0),S&&(f._EndUserMark(g,S),console.timeEnd(g))},Object.defineProperty(f,"Now",{get:function(){return l.j.Now},enumerable:!1,configurable:!0}),f.GetClassName=function(g,S){S===void 0&&(S=!1);var y=null;return!S&&g.getClassName?y=g.getClassName():(g instanceof Object&&(y=(S?g:Object.getPrototypeOf(g)).constructor.__bjsclassName__),y||(y=typeof g)),y},f.First=function(g,S){for(var y=0,x=g;y<x.length;y++){var R=x[y];if(S(R))return R}return null},f.getFullClassName=function(g,S){S===void 0&&(S=!1);var y=null,x=null;if(!S&&g.getClassName)y=g.getClassName();else{if(g instanceof Object){var R=S?g:Object.getPrototypeOf(g);y=R.constructor.__bjsclassName__,x=R.constructor.__bjsmoduleName__}y||(y=typeof g)}return y?(x!=null?x+".":"")+y:null},f.DelayAsync=function(g){return new Promise(function(S){setTimeout(function(){S()},g)})},f.IsSafari=function(){return!!(0,o.XD)()&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},f.UseCustomRequestHeaders=!1,f.CustomRequestHeaders=u.u.CustomRequestHeaders,f.GetDOMTextContent=o.Zl,f._DefaultCdnUrl="https://cdn.babylonjs.com",f.GetAbsoluteUrl=typeof document=="object"?function(g){var S=document.createElement("a");return S.href=g,S.href}:typeof URL=="function"&&typeof location=="object"?function(g){return new URL(g,location.origin).href}:function(){throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")},f.NoneLogLevel=a.V.NoneLogLevel,f.MessageLogLevel=a.V.MessageLogLevel,f.WarningLogLevel=a.V.WarningLogLevel,f.ErrorLogLevel=a.V.ErrorLogLevel,f.AllLogLevel=a.V.AllLogLevel,f.IsWindowObjectExist=o.BA,f.PerformanceNoneLogLevel=0,f.PerformanceUserMarkLogLevel=1,f.PerformanceConsoleLogLevel=2,f.StartPerformanceCounter=f._StartPerformanceCounterDisabled,f.EndPerformanceCounter=f._EndPerformanceCounterDisabled,f}();function C(f,g){return function(S){S.__bjsclassName__=f,S.__bjsmoduleName__=g??null}}var T=function(){function f(g,S,y,x){x===void 0&&(x=0),this.iterations=g,this.index=x-1,this._done=!1,this._fn=S,this._successCallback=y}return f.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},f.prototype.breakLoop=function(){this._done=!0,this._successCallback()},f.Run=function(g,S,y,x){x===void 0&&(x=0);var R=new f(g,S,y,x);return R.executeNext(),R},f.SyncAsyncForLoop=function(g,S,y,x,R,I){return I===void 0&&(I=0),f.Run(Math.ceil(g/S),function(M){R&&R()?M.breakLoop():setTimeout(function(){for(var D=0;D<S;++D){var B=M.index*S+D;if(B>=g)break;if(y(B),R&&R()){M.breakLoop();break}}M.executeNext()},I)},x)},f}();E.Mix=b.zF,E.IsExponentOfTwo=b.L8,d.q.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z"},34623:(r,t,e)=>{e.d(t,{Uu:()=>a,Y5:()=>i,n9:()=>o});var n={};function i(s,l){n[s]=l}function o(s){return n[s]}function a(s){for(var l in n)if(s instanceof n[l]&&!l.includes("Abstract"))return l;return"Unknown"}},62273:(r,t,e)=>{e.d(t,{K:()=>n});var n=function(){function i(){}return Object.defineProperty(i,"UniqueId",{get:function(){var o=this._UniqueIdCounter;return this._UniqueIdCounter++,o},enumerable:!1,configurable:!0}),i._UniqueIdCounter=1,i}()},46799:(r,t,e)=>{e.d(t,{u:()=>n});var n=function(){function i(){this._xhr=typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest,this._requestURL=""}return Object.defineProperty(i,"IsCustomRequestAvailable",{get:function(){return Object.keys(i.CustomRequestHeaders).length>0||i.CustomRequestModifiers.length>0},enumerable:!1,configurable:!0}),i.prototype._injectCustomRequestHeaders=function(){if(!this._shouldSkipRequestModifications(this._requestURL))for(var o in i.CustomRequestHeaders){var a=i.CustomRequestHeaders[o];a&&this._xhr.setRequestHeader(o,a)}},i.prototype._shouldSkipRequestModifications=function(o){return i.SkipRequestModificationForBabylonCDN&&(o.includes("preview.babylonjs.com")||o.includes("cdn.babylonjs.com"))},Object.defineProperty(i.prototype,"onprogress",{get:function(){return this._xhr.onprogress},set:function(o){this._xhr.onprogress=o},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"readyState",{get:function(){return this._xhr.readyState},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"status",{get:function(){return this._xhr.status},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"statusText",{get:function(){return this._xhr.statusText},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"response",{get:function(){return this._xhr.response},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"responseURL",{get:function(){return this._xhr.responseURL},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"responseText",{get:function(){return this._xhr.responseText},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"responseType",{get:function(){return this._xhr.responseType},set:function(o){this._xhr.responseType=o},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"timeout",{get:function(){return this._xhr.timeout},set:function(o){this._xhr.timeout=o},enumerable:!1,configurable:!0}),i.prototype.addEventListener=function(o,a,s){this._xhr.addEventListener(o,a,s)},i.prototype.removeEventListener=function(o,a,s){this._xhr.removeEventListener(o,a,s)},i.prototype.abort=function(){this._xhr.abort()},i.prototype.send=function(o){i.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(o)},i.prototype.open=function(o,a){for(var s=0,l=i.CustomRequestModifiers;s<l.length;s++){var c=l[s];if(this._shouldSkipRequestModifications(a))return;c(this._xhr,a)}a=(a=a.replace("file:http:","http:")).replace("file:https:","https:"),this._requestURL=a,this._xhr.open(o,a,!0)},i.prototype.setRequestHeader=function(o,a){this._xhr.setRequestHeader(o,a)},i.prototype.getResponseHeader=function(o){return this._xhr.getResponseHeader(o)},i.CustomRequestHeaders={},i.CustomRequestModifiers=new Array,i.SkipRequestModificationForBabylonCDN=!0,i}()},80244:(r,t,e)=>{e.d(t,{T:()=>i,h:()=>o});var n=e(78322),i=function(){function a(s){this._pendingActions=new Array,this._workerInfos=s.map(function(l){return{workerPromise:Promise.resolve(l),idle:!0}})}return a.prototype.dispose=function(){for(var s=0,l=this._workerInfos;s<l.length;s++)l[s].workerPromise.then(function(c){c.terminate()});this._workerInfos.length=0,this._pendingActions.length=0},a.prototype.push=function(s){this._executeOnIdleWorker(s)||this._pendingActions.push(s)},a.prototype._executeOnIdleWorker=function(s){for(var l=0,c=this._workerInfos;l<c.length;l++){var u=c[l];if(u.idle)return this._execute(u,s),!0}return!1},a.prototype._execute=function(s,l){var c=this;s.idle=!1,s.workerPromise.then(function(u){l(u,function(){var d=c._pendingActions.shift();d?c._execute(s,d):s.idle=!0})})},a}(),o=function(a){function s(l,c,u){u===void 0&&(u=s.DefaultOptions);var d=a.call(this,[])||this;return d._maxWorkers=l,d._createWorkerAsync=c,d._options=u,d}return(0,n.C6)(s,a),s.prototype.push=function(l){if(!this._executeOnIdleWorker(l))if(this._workerInfos.length<this._maxWorkers){var c={workerPromise:this._createWorkerAsync(),idle:!1};this._workerInfos.push(c),this._execute(c,l)}else this._pendingActions.push(l)},s.prototype._execute=function(l,c){var u=this;l.timeoutId&&(clearTimeout(l.timeoutId),delete l.timeoutId),a.prototype._execute.call(this,l,function(d,h){c(d,function(){h(),l.idle&&(l.timeoutId=setTimeout(function(){l.workerPromise.then(function(m){m.terminate()});var p=u._workerInfos.indexOf(l);p!==-1&&u._workerInfos.splice(p,1)},u._options.idleTimeElapsedBeforeRelease))})})},s.DefaultOptions={idleTimeElapsedBeforeRelease:1e3},s}(i)},73441:(r,t,e)=>{e.d(t,{s:()=>u,v:()=>c});var n=e(78322),i=e(81152),o=e(30622),a=e(82673),s=e(34623),l=e(12028),c=function(d){function h(p,m,v,b,E,C,T,f){return v===void 0&&(v=null),T===void 0&&(T=i.Y.TEXTURETYPE_UNSIGNED_INT),f===void 0&&(f=!1),d.call(this,p,"pass",null,null,m,v,b,E,C,void 0,T,void 0,null,f)||this}return(0,n.C6)(h,d),h.prototype.getClassName=function(){return"PassPostProcess"},h.prototype._gatherImports=function(p,m){p?(this._webGPUReady=!0,m.push(Promise.all([Promise.resolve().then(e.bind(e,59448))]))):m.push(Promise.all([Promise.resolve().then(e.bind(e,56017))])),d.prototype._gatherImports.call(this,p,m)},h._Parse=function(p,m,v,b){return l.p.Parse(function(){return new h(p.name,p.options,m,p.renderTargetSamplingMode,p._engine,p.reusable)},p,v,b)},h}(o.w);(0,s.Y5)("BABYLON.PassPostProcess",c);var u=function(d){function h(p,m,v,b,E,C,T,f){v===void 0&&(v=null),T===void 0&&(T=i.Y.TEXTURETYPE_UNSIGNED_INT),f===void 0&&(f=!1);var g=d.call(this,p,"passCube",null,null,m,v,b,E,C,"#define POSITIVEX",T,void 0,null,f)||this;return g._face=0,g}return(0,n.C6)(h,d),Object.defineProperty(h.prototype,"face",{get:function(){return this._face},set:function(p){if(!(p<0||p>5))switch(this._face=p,this._face){case 0:this.updateEffect("#define POSITIVEX");break;case 1:this.updateEffect("#define NEGATIVEX");break;case 2:this.updateEffect("#define POSITIVEY");break;case 3:this.updateEffect("#define NEGATIVEY");break;case 4:this.updateEffect("#define POSITIVEZ");break;case 5:this.updateEffect("#define NEGATIVEZ")}},enumerable:!1,configurable:!0}),h.prototype.getClassName=function(){return"PassCubePostProcess"},h.prototype._gatherImports=function(p,m){p?(this._webGPUReady=!0,m.push(Promise.all([Promise.resolve().then(e.bind(e,33739))]))):m.push(Promise.all([Promise.resolve().then(e.bind(e,25750))])),d.prototype._gatherImports.call(this,p,m)},h._Parse=function(p,m,v,b){return l.p.Parse(function(){return new h(p.name,p.options,m,p.renderTargetSamplingMode,p._engine,p.reusable)},p,v,b)},h}(o.w);a.$._RescalePostProcessFactory=function(d){return new c("rescale",1,null,i.Y.TEXTURE_BILINEAR_SAMPLINGMODE,d,!1,i.Y.TEXTURETYPE_UNSIGNED_INT)}},30622:(r,t,e)=>{e.d(t,{w:()=>v});var n=e(78322),i=e(53770),o=e(66377),a=e(8046),s=e(74239),l=e(81152),c=(e(96795),e(71073),e(6174)),u=e(12028),d=e(34623),h=e(14777),p=e(82673),m=e(87074);p.$.prototype.setTextureFromPostProcess=function(b,E,C){var T,f=null;E&&(E._forcedOutputTexture?f=E._forcedOutputTexture:E._textures.data[E._currentRenderTextureInd]&&(f=E._textures.data[E._currentRenderTextureInd])),this._bindTexture(b,(T=f?.texture)!==null&&T!==void 0?T:null,C)},p.$.prototype.setTextureFromPostProcessOutput=function(b,E,C){var T,f;this._bindTexture(b,(f=(T=E?._outputTexture)===null||T===void 0?void 0:T.texture)!==null&&f!==void 0?f:null,C)},s.M.prototype.setTextureFromPostProcess=function(b,E){this._engine.setTextureFromPostProcess(this._samplers[b],E,b)},s.M.prototype.setTextureFromPostProcessOutput=function(b,E){this._engine.setTextureFromPostProcessOutput(this._samplers[b],E,b)};var v=function(){function b(E,C,T,f,g,S,y,x,R,I,M,D,B,F,X,$,Q){var ie,q,ee,te,ce,fe,de,Te,ue,U,N,w;y===void 0&&(y=l.Y.TEXTURE_NEAREST_SAMPLINGMODE),I===void 0&&(I=null),M===void 0&&(M=l.Y.TEXTURETYPE_UNSIGNED_INT),D===void 0&&(D="postprocess"),F===void 0&&(F=!1),X===void 0&&(X=l.Y.TEXTUREFORMAT_RGBA),this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.alphaMode=l.Y.ALPHA_DISABLE,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=l.Y.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._shadersLoaded=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new i.L(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new a.I9(1,1),this._texelSize=a.I9.Zero(),this.onEffectCreatedObservable=new o.cP(void 0,!0),this.onActivateObservable=new o.cP,this.onSizeChangedObservable=new o.cP,this.onApplyObservable=new o.cP,this.onBeforeRenderObservable=new o.cP,this.onAfterRenderObservable=new o.cP,this._importPromises=[],this.name=E;var k=1,J=null;if(T&&!Array.isArray(T)){var le=T;T=(ie=le.uniforms)!==null&&ie!==void 0?ie:null,f=(q=le.samplers)!==null&&q!==void 0?q:null,k=(ee=le.size)!==null&&ee!==void 0?ee:1,S=(te=le.camera)!==null&&te!==void 0?te:null,y=(ce=le.samplingMode)!==null&&ce!==void 0?ce:l.Y.TEXTURE_NEAREST_SAMPLINGMODE,x=le.engine,R=le.reusable,I=(fe=le.defines)!==null&&fe!==void 0?fe:null,M=(de=le.textureType)!==null&&de!==void 0?de:l.Y.TEXTURETYPE_UNSIGNED_INT,D=(Te=le.vertexUrl)!==null&&Te!==void 0?Te:"postprocess",B=le.indexParameters,F=(ue=le.blockCompilation)!==null&&ue!==void 0&&ue,X=(U=le.textureFormat)!==null&&U!==void 0?U:l.Y.TEXTUREFORMAT_RGBA,$=(N=le.shaderLanguage)!==null&&N!==void 0?N:0,J=(w=le.uniformBuffers)!==null&&w!==void 0?w:null,Q=le.extraInitializations}else g&&(k=typeof g=="number"?g:{width:g.width,height:g.height});S!=null?(this._camera=S,this._scene=S.getScene(),S.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):x&&(this._engine=x,this._engine.postProcesses.push(this)),this._options=k,this.renderTargetSamplingMode=y||l.Y.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=R||!1,this._textureType=M,this._textureFormat=X,this._shaderLanguage=$||0,this._samplers=f||[],this._samplers.push("textureSampler"),this._fragmentUrl=C,this._vertexUrl=D,this._parameters=T||[],this._parameters.push("scale"),this._uniformBuffers=J||[],this._indexParameters=B,this._drawWrapper=new h.E(this._engine),this._webGPUReady=this._shaderLanguage===1,this._postConstructor(F,I,Q)}return b.RegisterShaderCodeProcessing=function(E,C){C?b._CustomShaderCodeProcessing[E??""]=C:delete b._CustomShaderCodeProcessing[E??""]},b._GetShaderCodeProcessing=function(E){var C;return(C=b._CustomShaderCodeProcessing[E])!==null&&C!==void 0?C:b._CustomShaderCodeProcessing[""]},Object.defineProperty(b.prototype,"samples",{get:function(){return this._samples},set:function(E){var C=this;this._samples=Math.min(E,this._engine.getCaps().maxMSAASamples),this._textures.forEach(function(T){T.setSamples(C._samples)})},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),b.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(b.prototype,"onActivate",{set:function(E){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),E&&(this._onActivateObserver=this.onActivateObservable.add(E))},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"onSizeChanged",{set:function(E){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(E)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"onApply",{set:function(E){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(E)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"onBeforeRender",{set:function(E){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(E)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"onAfterRender",{set:function(E){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(E)},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(E){this._forcedOutputTexture=E},enumerable:!1,configurable:!0}),b.prototype.restoreDefaultInputTexture=function(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())},b.prototype.getCamera=function(){return this._camera},Object.defineProperty(b.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!1,configurable:!0}),b.prototype._gatherImports=function(E,C){E===void 0&&(E=!1),E&&this._webGPUReady?C.push(Promise.all([Promise.resolve().then(e.bind(e,3072))])):C.push(Promise.all([Promise.resolve().then(e.bind(e,96795))]))},b.prototype._postConstructor=function(E,C,T){C===void 0&&(C=null);var f=this.getEngine().isWebGPU&&!b.ForceGLSL;this._gatherImports(f,this._importPromises),T&&T(f,this._importPromises),f&&this._webGPUReady&&(this._shaderLanguage=1),E||this.updateEffect(C)},b.prototype.getClassName=function(){return"PostProcess"},b.prototype.getEngine=function(){return this._engine},b.prototype.getEffect=function(){return this._drawWrapper.effect},b.prototype.shareOutputWith=function(E){return this._disposeTextures(),this._shareOutputWithPostProcess=E,this},b.prototype.useOwnOutput=function(){this._textures.length==0&&(this._textures=new i.L(2)),this._shareOutputWithPostProcess=null},b.prototype.updateEffect=function(E,C,T,f,g,S,y,x){var R,I,M=this;E===void 0&&(E=null),C===void 0&&(C=null),T===void 0&&(T=null);var D=b._GetShaderCodeProcessing(this.name);if(D?.defineCustomBindings){var B=(R=C?.slice())!==null&&R!==void 0?R:[];B.push.apply(B,this._parameters);var F=(I=T?.slice())!==null&&I!==void 0?I:[];F.push.apply(F,this._samplers),E=D.defineCustomBindings(this.name,E,B,F),C=B,T=F}this._postProcessDefines=E,this._drawWrapper.effect=this._engine.createEffect({vertex:y??this._vertexUrl,fragment:x??this._fragmentUrl},{attributes:["position"],uniformsNames:C||this._parameters,uniformBuffersNames:this._uniformBuffers,samplers:T||this._samplers,defines:E!==null?E:"",fallbacks:null,onCompiled:g??null,onError:S??null,indexParameters:f||this._indexParameters,processCodeAfterIncludes:D?.processCodeAfterIncludes?function(X,$){return D.processCodeAfterIncludes(M.name,X,$)}:null,processFinalCode:D?.processFinalCode?function(X,$){return D.processFinalCode(M.name,X,$)}:null,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:function(){return(0,n.sH)(M,void 0,void 0,function(){return(0,n.YH)(this,function(X){switch(X.label){case 0:return[4,Promise.all(this._importPromises)];case 1:return X.sent(),this._shadersLoaded=!0,[2]}})})}},this._engine),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)},b.prototype.isReusable=function(){return this._reusable},b.prototype.markTextureDirty=function(){this.width=-1},b.prototype._createRenderTargetTexture=function(E,C,T){T===void 0&&(T=0);for(var f=0;f<this._textureCache.length;f++)if(this._textureCache[f].texture.width===E.width&&this._textureCache[f].texture.height===E.height&&this._textureCache[f].postProcessChannel===T&&this._textureCache[f].texture._generateDepthBuffer===C.generateDepthBuffer&&this._textureCache[f].texture.samples===C.samples)return this._textureCache[f].texture;var g=this._engine.createRenderTargetTexture(E,C);return this._textureCache.push({texture:g,postProcessChannel:T,lastUsedRenderId:-1}),g},b.prototype._flushTextureCache=function(){for(var E=this._renderId,C=this._textureCache.length-1;C>=0;C--)if(E-this._textureCache[C].lastUsedRenderId>100){for(var T=!1,f=0;f<this._textures.length;f++)if(this._textures.data[f]===this._textureCache[C].texture){T=!0;break}T||(this._textureCache[C].texture.dispose(),this._textureCache.splice(C,1))}},b.prototype.resize=function(E,C,T,f,g){T===void 0&&(T=null),f===void 0&&(f=!1),g===void 0&&(g=!1),this._textures.length>0&&this._textures.reset(),this.width=E,this.height=C;var S=null;if(T){for(var y=0;y<T._postProcesses.length;y++)if(T._postProcesses[y]!==null){S=T._postProcesses[y];break}}var x={width:this.width,height:this.height},R={generateMipMaps:f,generateDepthBuffer:g||S===this,generateStencilBuffer:(g||S===this)&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType,format:this._textureFormat,samples:this._samples,label:"PostProcessRTT-"+this.name};this._textures.push(this._createRenderTargetTexture(x,R,0)),this._reusable&&this._textures.push(this._createRenderTargetTexture(x,R,1)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)},b.prototype._getTarget=function(){var E;if(this._shareOutputWithPostProcess)E=this._shareOutputWithPostProcess.inputTexture;else if(this._forcedOutputTexture)E=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height;else{E=this.inputTexture;for(var C=void 0,T=0;T<this._textureCache.length;T++)if(this._textureCache[T].texture===E){C=this._textureCache[T];break}C&&(C.lastUsedRenderId=this._renderId)}return E},b.prototype.activate=function(E,C,T){var f,g,S=this;C===void 0&&(C=null);var y=(E=E||this._camera).getScene(),x=y.getEngine(),R=x.getCaps().maxTextureSize,I=(C?C.width:this._engine.getRenderWidth(!0))*this._options|0,M=(C?C.height:this._engine.getRenderHeight(!0))*this._options|0,D=this._options.width||I,B=this._options.height||M,F=this.renderTargetSamplingMode!==l.Y.TEXTURE_NEAREST_LINEAR&&this.renderTargetSamplingMode!==l.Y.TEXTURE_NEAREST_NEAREST&&this.renderTargetSamplingMode!==l.Y.TEXTURE_LINEAR_LINEAR,X=null;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var $=x.currentViewport;$&&(D*=$.width,B*=$.height)}(F||this.alwaysForcePOT)&&(this._options.width||(D=x.needPOTTextures?(0,m.R)(D,R,this.scaleMode):D),this._options.height||(B=x.needPOTTextures?(0,m.R)(B,R,this.scaleMode):B)),this.width===D&&this.height===B&&(X=this._getTarget())||this.resize(D,B,E,F,T),this._textures.forEach(function(Q){Q.samples!==S.samples&&S._engine.updateRenderTargetTextureSampleCount(Q,S.samples)}),this._flushTextureCache(),this._renderId++}return X||(X=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(I/D,M/B),this._engine.bindFramebuffer(X,0,I,M,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(X,0,void 0,void 0,this.forceFullscreenViewport)),(g=(f=this._engine)._debugInsertMarker)===null||g===void 0||g.call(f,"post process ".concat(this.name," input")),this.onActivateObservable.notifyObservers(E),this.autoClear&&(this.alphaMode===l.Y.ALPHA_DISABLE||this.forceAutoClearInAlphaMode)&&this._engine.clear(this.clearColor?this.clearColor:y.clearColor,y._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),X},Object.defineProperty(b.prototype,"isSupported",{get:function(){return this._drawWrapper.effect.isSupported},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"aspectRatio",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height},enumerable:!1,configurable:!0}),b.prototype.isReady=function(){var E,C;return(C=(E=this._drawWrapper.effect)===null||E===void 0?void 0:E.isReady())!==null&&C!==void 0&&C},b.prototype.apply=function(){var E,C,T,f;return!((E=this._drawWrapper.effect)===null||E===void 0)&&E.isReady()?(this._engine.enableEffect(this._drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._engine.setAlphaMode(this.alphaMode),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),f=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this.externalTextureSamplerBinding||this._drawWrapper.effect._bindTexture("textureSampler",f?.texture),this._drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._drawWrapper.effect),(T=(C=b._GetShaderCodeProcessing(this.name))===null||C===void 0?void 0:C.bindCustomBindings)===null||T===void 0||T.call(C,this.name,this._drawWrapper.effect),this._drawWrapper.effect):null},b.prototype._disposeTextures=function(){this._shareOutputWithPostProcess||this._forcedOutputTexture?this._disposeTextureCache():(this._disposeTextureCache(),this._textures.dispose())},b.prototype._disposeTextureCache=function(){for(var E=this._textureCache.length-1;E>=0;E--)this._textureCache[E].texture.dispose();this._textureCache.length=0},b.prototype.setPrePassRenderer=function(E){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=E.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)},b.prototype.dispose=function(E){var C;if(E=E||this._camera,this._disposeTextures(),this._scene&&(C=this._scene.postProcesses.indexOf(this))!==-1&&this._scene.postProcesses.splice(C,1),this._parentContainer){var T=this._parentContainer.postProcesses.indexOf(this);T>-1&&this._parentContainer.postProcesses.splice(T,1),this._parentContainer=null}if((C=this._engine.postProcesses.indexOf(this))!==-1&&this._engine.postProcesses.splice(C,1),E){if(E.detachPostProcess(this),(C=E._postProcesses.indexOf(this))===0&&E._postProcesses.length>0){var f=this._camera._getFirstPostProcess();f&&f.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear(),this.onEffectCreatedObservable.clear()}},b.prototype.serialize=function(){var E=u.p.Serialize(this),C=this.getCamera()||this._scene&&this._scene.activeCamera;return E.customType="BABYLON."+this.getClassName(),E.cameraId=C?C.id:null,E.reusable=this._reusable,E.textureType=this._textureType,E.fragmentUrl=this._fragmentUrl,E.parameters=this._parameters,E.samplers=this._samplers,E.options=this._options,E.defines=this._postProcessDefines,E.textureFormat=this._textureFormat,E.vertexUrl=this._vertexUrl,E.indexParameters=this._indexParameters,E},b.prototype.clone=function(){var E=this.serialize();E._engine=this._engine,E.cameraId=null;var C=b.Parse(E,this._scene,"");return C?(C.onActivateObservable=this.onActivateObservable.clone(),C.onSizeChangedObservable=this.onSizeChangedObservable.clone(),C.onApplyObservable=this.onApplyObservable.clone(),C.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),C.onAfterRenderObservable=this.onAfterRenderObservable.clone(),C._prePassEffectConfiguration=this._prePassEffectConfiguration,C):null},b.Parse=function(E,C,T){var f=(0,d.n9)(E.customType);if(!f||!f._Parse)return null;var g=C?C.getCameraById(E.cameraId):null;return f._Parse(E,g,C,T)},b._Parse=function(E,C,T,f){return u.p.Parse(function(){return new b(E.name,E.fragmentUrl,E.parameters,E.samplers,E.options,C,E.renderTargetSamplingMode,E._engine,E.reusable,E.defines,E.textureType,E.vertexUrl,E.indexParameters,!1,E.textureFormat)},E,T,f)},b.ForceGLSL=!1,b._CustomShaderCodeProcessing={},(0,n.Cg)([(0,c.lK)()],b.prototype,"uniqueId",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"name",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"width",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"height",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"renderTargetSamplingMode",void 0),(0,n.Cg)([(0,c.qK)()],b.prototype,"clearColor",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"autoClear",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"forceAutoClearInAlphaMode",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"alphaMode",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"alphaConstants",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"enablePixelPerfectMode",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"forceFullscreenViewport",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"scaleMode",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"alwaysForcePOT",void 0),(0,n.Cg)([(0,c.lK)("samples")],b.prototype,"_samples",void 0),(0,n.Cg)([(0,c.lK)()],b.prototype,"adaptScaleToCurrentViewport",void 0),b}();(0,d.Y5)("BABYLON.PostProcess",v)},63639:(r,t,e)=>{e.d(t,{X:()=>a});var n=e(62623),i=e(81152),o=e(66377),a=function(){function s(l){this._vertexBuffers={},this.onBeforeRenderObservable=new o.cP,this._scene=l}return s.prototype._prepareBuffers=function(){if(!this._vertexBuffers[n.R.PositionKind]){var l=[];l.push(1,1),l.push(-1,1),l.push(-1,-1),l.push(1,-1),this._vertexBuffers[n.R.PositionKind]=new n.R(this._scene.getEngine(),l,n.R.PositionKind,!1,!1,2),this._buildIndexBuffer()}},s.prototype._buildIndexBuffer=function(){var l=[];l.push(0),l.push(1),l.push(2),l.push(0),l.push(2),l.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(l)},s.prototype._rebuild=function(){var l=this._vertexBuffers[n.R.PositionKind];l&&(l._rebuild(),this._buildIndexBuffer())},s.prototype._prepareFrame=function(l,c){l===void 0&&(l=null),c===void 0&&(c=null);var u=this._scene.activeCamera;return!(!u||!(c=c||u._postProcesses.filter(function(d){return d!=null}))||c.length===0||!this._scene.postProcessesEnabled||(c[0].activate(u,l,c!=null),0))},s.prototype.directRender=function(l,c,u,d,h,p){var m;c===void 0&&(c=null),u===void 0&&(u=!1),d===void 0&&(d=0),h===void 0&&(h=0),p===void 0&&(p=!1);for(var v=this._scene.getEngine(),b=0;b<l.length;b++){b<l.length-1?l[b+1].activate(this._scene.activeCamera,c?.texture):(c?v.bindFramebuffer(c,d,void 0,void 0,u,h):p||v.restoreDefaultFramebuffer(),(m=v._debugInsertMarker)===null||m===void 0||m.call(v,"post process ".concat(l[b].name," output")));var E=l[b],C=E.apply();C&&(E.onBeforeRenderObservable.notifyObservers(C),this._prepareBuffers(),v.bindBuffers(this._vertexBuffers,this._indexBuffer,C),v.drawElementsType(i.Y.MATERIAL_TriangleFillMode,0,6),E.onAfterRenderObservable.notifyObservers(C))}v.setDepthBuffer(!0),v.setDepthWrite(!0)},s.prototype._finalizeFrame=function(l,c,u,d,h){var p;h===void 0&&(h=!1);var m=this._scene.activeCamera;if(m&&(this.onBeforeRenderObservable.notifyObservers(this),d=d||m._postProcesses.filter(function(f){return f!=null}),d.length!==0&&this._scene.postProcessesEnabled)){for(var v=this._scene.getEngine(),b=0,E=d.length;b<E;b++){var C=d[b];if(b<E-1?C._outputTexture=d[b+1].activate(m,c?.texture):(c?(v.bindFramebuffer(c,u,void 0,void 0,h),C._outputTexture=c):(v.restoreDefaultFramebuffer(),C._outputTexture=null),(p=v._debugInsertMarker)===null||p===void 0||p.call(v,"post process ".concat(d[b].name," output"))),l)break;var T=C.apply();T&&(C.onBeforeRenderObservable.notifyObservers(T),this._prepareBuffers(),v.bindBuffers(this._vertexBuffers,this._indexBuffer,T),v.drawElementsType(i.Y.MATERIAL_TriangleFillMode,0,6),C.onAfterRenderObservable.notifyObservers(T))}v.setDepthBuffer(!0),v.setDepthWrite(!0),v.setAlphaMode(i.Y.ALPHA_DISABLE)}},s.prototype.dispose=function(){var l=this._vertexBuffers[n.R.PositionKind];l&&(l.dispose(),this._vertexBuffers[n.R.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},s}()},85043:(r,t,e)=>{e.d(t,{U:()=>a});var n=e(53770),i=e(8046),o=e(81152),a=function(){function s(l,c,u,d,h){u===void 0&&(u=null),d===void 0&&(d=null),h===void 0&&(h=null),this.index=l,this._opaqueSubMeshes=new n.L(256),this._transparentSubMeshes=new n.L(256),this._alphaTestSubMeshes=new n.L(256),this._depthOnlySubMeshes=new n.L(256),this._particleSystems=new n.L(256),this._spriteManagers=new n.L(256),this._empty=!0,this._edgesRenderers=new n.b(16),this._scene=c,this.opaqueSortCompareFn=u,this.alphaTestSortCompareFn=d,this.transparentSortCompareFn=h}return Object.defineProperty(s.prototype,"opaqueSortCompareFn",{set:function(l){this._opaqueSortCompareFn=l||s.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"alphaTestSortCompareFn",{set:function(l){this._alphaTestSortCompareFn=l||s.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"transparentSortCompareFn",{set:function(l){this._transparentSortCompareFn=l||s.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted},enumerable:!1,configurable:!0}),s.prototype.render=function(l,c,u,d){if(l)l(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var h=this._scene.getEngine();this._depthOnlySubMeshes.length!==0&&(h.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),h.setColorWrite(!0)),this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);var p=h.getStencilBuffer();if(h.setStencilBuffer(!1),c&&this._renderSprites(),u&&this._renderParticles(d),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._transparentSubMeshes.length!==0||this._scene.useOrderIndependentTransparency){if(h.setStencilBuffer(p),this._scene.useOrderIndependentTransparency){var m=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);m.length&&this._renderTransparent(m)}else this._renderTransparent(this._transparentSubMeshes);h.setAlphaMode(o.Y.ALPHA_DISABLE)}if(h.setStencilBuffer(!1),this._edgesRenderers.length){for(var v=0;v<this._edgesRenderers.length;v++)this._edgesRenderers.data[v].render();h.setAlphaMode(o.Y.ALPHA_DISABLE)}h.setStencilBuffer(p)}},s.prototype._renderOpaqueSorted=function(l){s._RenderSorted(l,this._opaqueSortCompareFn,this._scene.activeCamera,!1)},s.prototype._renderAlphaTestSorted=function(l){s._RenderSorted(l,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)},s.prototype._renderTransparentSorted=function(l){s._RenderSorted(l,this._transparentSortCompareFn,this._scene.activeCamera,!0)},s._RenderSorted=function(l,c,u,d){var h,p=0,m=u?u.globalPosition:s._ZeroVector;if(d)for(;p<l.length;p++)(h=l.data[p])._alphaIndex=h.getMesh().alphaIndex,h._distanceToCamera=i.Pq.Distance(h.getBoundingInfo().boundingSphere.centerWorld,m);var v=l.length===l.data.length?l.data:l.data.slice(0,l.length);c&&v.sort(c);var b=v[0].getMesh().getScene();for(p=0;p<v.length;p++)if(h=v[p],!b._activeMeshesFrozenButKeepClipping||h.isInFrustum(b._frustumPlanes)){if(d){var E=h.getMaterial();if(E&&E.needDepthPrePass){var C=E.getScene().getEngine();C.setColorWrite(!1),C.setAlphaMode(o.Y.ALPHA_DISABLE),h.render(!1),C.setColorWrite(!0)}}h.render(d)}},s.defaultTransparentSortCompare=function(l,c){return l._alphaIndex>c._alphaIndex?1:l._alphaIndex<c._alphaIndex?-1:s.backToFrontSortCompare(l,c)},s.backToFrontSortCompare=function(l,c){return l._distanceToCamera<c._distanceToCamera?1:l._distanceToCamera>c._distanceToCamera?-1:0},s.frontToBackSortCompare=function(l,c){return l._distanceToCamera<c._distanceToCamera?-1:l._distanceToCamera>c._distanceToCamera?1:0},s.PainterSortCompare=function(l,c){var u=l.getMesh(),d=c.getMesh();return u.material&&d.material?u.material.uniqueId-d.material.uniqueId:u.uniqueId-d.uniqueId},s.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0},s.prototype.prepareSprites=function(){this._spriteManagers.reset()},s.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},s.prototype.dispatch=function(l,c,u){c===void 0&&(c=l.getMesh()),u===void 0&&(u=l.getMaterial()),u!=null&&(u.needAlphaBlendingForMesh(c)?this._transparentSubMeshes.push(l):u.needAlphaTesting()?(u.needDepthPrePass&&this._depthOnlySubMeshes.push(l),this._alphaTestSubMeshes.push(l)):(u.needDepthPrePass&&this._depthOnlySubMeshes.push(l),this._opaqueSubMeshes.push(l)),c._renderingGroup=this,c._edgesRenderer&&c.isEnabled()&&c.isVisible&&c._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(c._edgesRenderer),this._empty=!1)},s.prototype.dispatchSprites=function(l){this._spriteManagers.push(l),this._empty=!1},s.prototype.dispatchParticles=function(l){this._particleSystems.push(l),this._empty=!1},s.prototype._renderParticles=function(l){if(this._particleSystems.length!==0){var c=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var u=0;u<this._particleSystems.length;u++){var d=this._particleSystems.data[u];if((c&&c.layerMask&d.layerMask)!==0){var h=d.emitter;h.position&&l&&l.indexOf(h)===-1||this._scene._activeParticles.addCount(d.render(),!1)}}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}},s.prototype._renderSprites=function(){if(this._scene.spritesEnabled&&this._spriteManagers.length!==0){var l=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(var c=0;c<this._spriteManagers.length;c++){var u=this._spriteManagers.data[c];(l&&l.layerMask&u.layerMask)!==0&&u.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}},s._ZeroVector=i.Pq.Zero(),s}()},7931:(r,t,e)=>{e.d(t,{m:()=>o,o:()=>i});var n=e(85043),i=function(){},o=function(){function a(s){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new i,this._maintainStateBetweenFrames=!1,this._scene=s;for(var l=a.MIN_RENDERINGGROUPS;l<a.MAX_RENDERINGGROUPS;l++)this._autoClearDepthStencil[l]={autoClear:!0,depth:!0,stencil:!0}}return Object.defineProperty(a.prototype,"maintainStateBetweenFrames",{get:function(){return this._maintainStateBetweenFrames},set:function(s){s!==this._maintainStateBetweenFrames&&(this._maintainStateBetweenFrames=s,this._maintainStateBetweenFrames||this.restoreDispachedFlags())},enumerable:!1,configurable:!0}),a.prototype.restoreDispachedFlags=function(){for(var s=0,l=this._scene.meshes;s<l.length;s++){var c=l[s];if(c.subMeshes)for(var u=0,d=c.subMeshes;u<d.length;u++)d[u]._wasDispatched=!1}if(this._scene.spriteManagers)for(var h=0,p=this._scene.spriteManagers;h<p.length;h++)p[h]._wasDispatched=!1;for(var m=0,v=this._scene.particleSystems;m<v.length;m++)v[m]._wasDispatched=!1},a.prototype.getRenderingGroup=function(s){var l=s||0;return this._prepareRenderingGroup(l),this._renderingGroups[l]},a.prototype._clearDepthStencilBuffer=function(s,l){s===void 0&&(s=!0),l===void 0&&(l=!0),this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,s,l),this._depthStencilBufferAlreadyCleaned=!0)},a.prototype.render=function(s,l,c,u){var d=this._renderingGroupInfo;if(d.scene=this._scene,d.camera=this._scene.activeCamera,this._scene.spriteManagers&&u)for(var h=0;h<this._scene.spriteManagers.length;h++){var p=this._scene.spriteManagers[h];this.dispatchSprites(p)}for(h=a.MIN_RENDERINGGROUPS;h<a.MAX_RENDERINGGROUPS;h++){this._depthStencilBufferAlreadyCleaned=h===a.MIN_RENDERINGGROUPS;var m=this._renderingGroups[h];if(m&&!m._empty){var v=1<<h;if(d.renderingGroupId=h,this._scene.onBeforeRenderingGroupObservable.notifyObservers(d,v),a.AUTOCLEAR){var b=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(h):this._autoClearDepthStencil[h];b&&b.autoClear&&this._clearDepthStencilBuffer(b.depth,b.stencil)}for(var E=0,C=this._scene._beforeRenderingGroupDrawStage;E<C.length;E++)C[E].action(h);m.render(s,u,c,l);for(var T=0,f=this._scene._afterRenderingGroupDrawStage;T<f.length;T++)f[T].action(h);this._scene.onAfterRenderingGroupObservable.notifyObservers(d,v)}}},a.prototype.reset=function(){if(!this.maintainStateBetweenFrames)for(var s=a.MIN_RENDERINGGROUPS;s<a.MAX_RENDERINGGROUPS;s++){var l=this._renderingGroups[s];l&&l.prepare()}},a.prototype.resetSprites=function(){if(!this.maintainStateBetweenFrames)for(var s=a.MIN_RENDERINGGROUPS;s<a.MAX_RENDERINGGROUPS;s++){var l=this._renderingGroups[s];l&&l.prepareSprites()}},a.prototype.dispose=function(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null},a.prototype.freeRenderingGroups=function(){for(var s=a.MIN_RENDERINGGROUPS;s<a.MAX_RENDERINGGROUPS;s++){var l=this._renderingGroups[s];l&&l.dispose()}},a.prototype._prepareRenderingGroup=function(s){this._renderingGroups[s]===void 0&&(this._renderingGroups[s]=new n.U(s,this._scene,this._customOpaqueSortCompareFn[s],this._customAlphaTestSortCompareFn[s],this._customTransparentSortCompareFn[s]))},a.prototype.dispatchSprites=function(s){this.maintainStateBetweenFrames&&s._wasDispatched||(s._wasDispatched=!0,this.getRenderingGroup(s.renderingGroupId).dispatchSprites(s))},a.prototype.dispatchParticles=function(s){this.maintainStateBetweenFrames&&s._wasDispatched||(s._wasDispatched=!0,this.getRenderingGroup(s.renderingGroupId).dispatchParticles(s))},a.prototype.dispatch=function(s,l,c){l===void 0&&(l=s.getMesh()),this.maintainStateBetweenFrames&&s._wasDispatched||(s._wasDispatched=!0,this.getRenderingGroup(l.renderingGroupId).dispatch(s,l,c))},a.prototype.setRenderingOrder=function(s,l,c,u){if(l===void 0&&(l=null),c===void 0&&(c=null),u===void 0&&(u=null),this._customOpaqueSortCompareFn[s]=l,this._customAlphaTestSortCompareFn[s]=c,this._customTransparentSortCompareFn[s]=u,this._renderingGroups[s]){var d=this._renderingGroups[s];d.opaqueSortCompareFn=this._customOpaqueSortCompareFn[s],d.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[s],d.transparentSortCompareFn=this._customTransparentSortCompareFn[s]}},a.prototype.setRenderingAutoClearDepthStencil=function(s,l,c,u){c===void 0&&(c=!0),u===void 0&&(u=!0),this._autoClearDepthStencil[s]={autoClear:l,depth:c,stencil:u}},a.prototype.getAutoClearDepthStencilSetup=function(s){return this._autoClearDepthStencil[s]},a.MAX_RENDERINGGROUPS=4,a.MIN_RENDERINGGROUPS=0,a.AUTOCLEAR=!0,a}()},27947:(r,t,e)=>{var n=e(98519),i=(e(50851),"backgroundUboDeclaration");n.l.IncludesShadersStore[i]=`layout(std140,column_major) uniform;uniform Material
|
||
{uniform vec4 vPrimaryColor;uniform vec4 vPrimaryColorShadow;uniform vec2 vDiffuseInfos;uniform vec2 vReflectionInfos;uniform mat4 diffuseMatrix;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;uniform float fFovMultiplier;uniform float pointSize;uniform float shadowLevel;uniform float alpha;uniform vec3 vBackgroundCenter;uniform vec4 vReflectionControl;uniform vec2 projectedGroundInfos;};
|
||
#include<sceneUboDeclaration>
|
||
`},49334:(r,t,e)=>{e(98519).l.IncludesShadersStore.bakedVertexAnimation=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
{
|
||
#ifdef INSTANCES
|
||
#define BVASNAME bakedVertexAnimationSettingsInstanced
|
||
#else
|
||
#define BVASNAME bakedVertexAnimationSettings
|
||
#endif
|
||
float 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];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
|
||
#endif
|
||
finalWorld=finalWorld*VATInfluence;}
|
||
#endif
|
||
`},64400:(r,t,e)=>{e(98519).l.IncludesShadersStore.bakedVertexAnimationDeclaration=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
uniform float bakedVertexAnimationTime;uniform vec2 bakedVertexAnimationTextureSizeInverted;uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture;
|
||
#ifdef INSTANCES
|
||
attribute vec4 bakedVertexAnimationSettingsInstanced;
|
||
#endif
|
||
#define inline
|
||
mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
|
||
{float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;float dx=bakedVertexAnimationTextureSizeInverted.x;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));return mat4(m0,m1,m2,m3);}
|
||
#endif
|
||
`},36470:(r,t,e)=>{e.r(t),e.d(t,{bonesDeclaration:()=>o});var n="bonesDeclaration",i=`#if NUM_BONE_INFLUENCERS>0
|
||
attribute vec4 matricesIndices;attribute vec4 matricesWeights;
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
attribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra;
|
||
#endif
|
||
#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
#ifdef BONETEXTURE
|
||
uniform highp sampler2D boneSampler;uniform float boneTextureWidth;
|
||
#else
|
||
uniform mat4 mBones[BonesPerMesh];
|
||
#endif
|
||
#ifdef BONES_VELOCITY_ENABLED
|
||
uniform mat4 mPreviousBones[BonesPerMesh];
|
||
#endif
|
||
#ifdef BONETEXTURE
|
||
#define inline
|
||
mat4 readMatrixFromRawSampler(sampler2D smp,float index)
|
||
{float offset=index *4.0;float dx=1.0/boneTextureWidth;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));return mat4(m0,m1,m2,m3);}
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},76898:(r,t,e)=>{e.r(t),e.d(t,{bonesVertex:()=>o});var n="bonesVertex",i=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
mat4 influence;
|
||
#ifdef BONETEXTURE
|
||
influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
|
||
#endif
|
||
#else
|
||
influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
|
||
#endif
|
||
#endif
|
||
finalWorld=finalWorld*influence;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},90253:(r,t,e)=>{e(98519).l.IncludesShadersStore.boundingBoxRendererUboDeclaration=`#ifdef WEBGL2
|
||
uniform vec4 color;uniform mat4 world;uniform mat4 viewProjection;
|
||
#ifdef MULTIVIEW
|
||
uniform mat4 viewProjectionR;
|
||
#endif
|
||
#else
|
||
layout(std140,column_major) uniform;uniform BoundingBoxRenderer {vec4 color;mat4 world;mat4 viewProjection;mat4 viewProjectionR;};
|
||
#endif
|
||
`},56159:(r,t,e)=>{e.r(t),e.d(t,{bumpFragment:()=>o});var n="bumpFragment",i=`vec2 uvOffset=vec2(0.0,0.0);
|
||
#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
|
||
#ifdef NORMALXYSCALE
|
||
float normalScale=1.0;
|
||
#elif defined(BUMP)
|
||
float normalScale=vBumpInfos.y;
|
||
#else
|
||
float normalScale=1.0;
|
||
#endif
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
mat3 TBN=vTBN;
|
||
#elif defined(BUMP)
|
||
vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
|
||
#else
|
||
vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
|
||
#endif
|
||
#elif defined(ANISOTROPIC)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
mat3 TBN=vTBN;
|
||
#else
|
||
vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
|
||
#endif
|
||
#endif
|
||
#ifdef PARALLAX
|
||
mat3 invTBN=transposeMat3(TBN);
|
||
#ifdef PARALLAXOCCLUSION
|
||
uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);
|
||
#else
|
||
uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);
|
||
#endif
|
||
#endif
|
||
#ifdef DETAIL
|
||
vec4 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);
|
||
#endif
|
||
#ifdef BUMP
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
#define CUSTOM_FRAGMENT_BUMP_FRAGMENT
|
||
normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW);
|
||
#elif !defined(DETAIL)
|
||
normalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);
|
||
#else
|
||
vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;
|
||
#if DETAIL_NORMALBLENDMETHOD==0
|
||
detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
|
||
#elif DETAIL_NORMALBLENDMETHOD==1
|
||
detailNormal.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;
|
||
#endif
|
||
normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);
|
||
#endif
|
||
#elif defined(DETAIL)
|
||
detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},75394:(r,t,e)=>{e.r(t),e.d(t,{bumpFragmentFunctions:()=>a});var n=e(98519),i=(e(37755),"bumpFragmentFunctions"),o=`#if defined(BUMP)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
|
||
#endif
|
||
#if defined(DETAIL)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
|
||
#endif
|
||
#if defined(BUMP) && defined(PARALLAX)
|
||
const 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++)
|
||
{currSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;if (!keepWorking)
|
||
{}
|
||
else if (currSampledHeight>currRayHeight)
|
||
{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
|
||
else
|
||
{currRayHeight-=stepSize;vLastOffset=vCurrOffset;
|
||
#ifdef PARALLAX_RHS
|
||
vCurrOffset-=stepSize*vMaxOffset;
|
||
#else
|
||
vCurrOffset+=stepSize*vMaxOffset;
|
||
#endif
|
||
lastSampledHeight=currSampledHeight;}}
|
||
return vCurrOffset;}
|
||
vec2 parallaxOffset(vec3 viewDir,float heightScale)
|
||
{float height=texture2D(bumpSampler,vBumpUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height;
|
||
#ifdef PARALLAX_RHS
|
||
return texCoordOffset;
|
||
#else
|
||
return -texCoordOffset;
|
||
#endif
|
||
}
|
||
#endif
|
||
`;n.l.IncludesShadersStore[i]=o;var a={name:i,shader:o}},48661:(r,t,e)=>{e.r(t),e.d(t,{bumpFragmentMainFunctions:()=>o});var n="bumpFragmentMainFunctions",i=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
varying mat3 vTBN;
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
uniform mat4 normalMatrix;
|
||
#if defined(WEBGL2) || defined(WEBGPU)
|
||
mat4 toNormalMatrix(mat4 wMatrix)
|
||
{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;}
|
||
#else
|
||
mat4 toNormalMatrix(mat4 m)
|
||
{float
|
||
a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],
|
||
a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],
|
||
a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],
|
||
a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],
|
||
b00=a00*a11-a01*a10,
|
||
b01=a00*a12-a02*a10,
|
||
b02=a00*a13-a03*a10,
|
||
b03=a01*a12-a02*a11,
|
||
b04=a01*a13-a03*a11,
|
||
b05=a02*a13-a03*a12,
|
||
b06=a20*a31-a21*a30,
|
||
b07=a20*a32-a22*a30,
|
||
b08=a20*a33-a23*a30,
|
||
b09=a21*a32-a22*a31,
|
||
b10=a21*a33-a23*a31,
|
||
b11=a22*a33-a23*a32,
|
||
det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4(
|
||
a11*b11-a12*b10+a13*b09,
|
||
a02*b10-a01*b11-a03*b09,
|
||
a31*b05-a32*b04+a33*b03,
|
||
a22*b04-a21*b05-a23*b03,
|
||
a12*b08-a10*b11-a13*b07,
|
||
a00*b11-a02*b08+a03*b07,
|
||
a32*b02-a30*b05-a33*b01,
|
||
a20*b05-a22*b02+a23*b01,
|
||
a10*b10-a11*b08+a13*b06,
|
||
a01*b08-a00*b10-a03*b06,
|
||
a30*b04-a31*b02+a33*b00,
|
||
a21*b02-a20*b04-a23*b00,
|
||
a11*b07-a10*b09-a12*b06,
|
||
a00*b09-a01*b07+a02*b06,
|
||
a31*b01-a30*b03-a32*b00,
|
||
a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
|
||
mi[0][1],mi[1][1],mi[2][1],mi[3][1],
|
||
mi[0][2],mi[1][2],mi[2][2],mi[3][2],
|
||
mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
|
||
#endif
|
||
#endif
|
||
vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
|
||
{
|
||
#ifdef NORMALXYSCALE
|
||
normal=normalize(normal*vec3(scale,scale,1.0));
|
||
#endif
|
||
return normalize(cotangentFrame*normal);}
|
||
vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
|
||
{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
|
||
mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
|
||
{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);}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},35845:(r,t,e)=>{e(98519).l.IncludesShadersStore.bumpVertex=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
vec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
|
||
#endif
|
||
#endif
|
||
`},42513:(r,t,e)=>{e(98519).l.IncludesShadersStore.bumpVertexDeclaration=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
varying mat3 vTBN;
|
||
#endif
|
||
#endif
|
||
`},39643:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneFragment:()=>o});var n="clipPlaneFragment",i=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
|
||
if (false) {}
|
||
#endif
|
||
#ifdef CLIPPLANE
|
||
else if (fClipDistance>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
else if (fClipDistance2>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
else if (fClipDistance3>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
else if (fClipDistance4>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
else if (fClipDistance5>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
else if (fClipDistance6>0.0)
|
||
{discard;}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},27003:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneFragmentDeclaration:()=>o});var n="clipPlaneFragmentDeclaration",i=`#ifdef CLIPPLANE
|
||
varying float fClipDistance;
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
varying float fClipDistance2;
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
varying float fClipDistance3;
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
varying float fClipDistance4;
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
varying float fClipDistance5;
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
varying float fClipDistance6;
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},83057:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneVertex:()=>o});var n="clipPlaneVertex",i=`#ifdef CLIPPLANE
|
||
fClipDistance=dot(worldPos,vClipPlane);
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
fClipDistance2=dot(worldPos,vClipPlane2);
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
fClipDistance3=dot(worldPos,vClipPlane3);
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
fClipDistance4=dot(worldPos,vClipPlane4);
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
fClipDistance5=dot(worldPos,vClipPlane5);
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
fClipDistance6=dot(worldPos,vClipPlane6);
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},85637:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneVertexDeclaration:()=>o});var n="clipPlaneVertexDeclaration",i=`#ifdef CLIPPLANE
|
||
uniform vec4 vClipPlane;varying float fClipDistance;
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
uniform vec4 vClipPlane2;varying float fClipDistance2;
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
uniform vec4 vClipPlane3;varying float fClipDistance3;
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
uniform vec4 vClipPlane4;varying float fClipDistance4;
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
uniform vec4 vClipPlane5;varying float fClipDistance5;
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
uniform vec4 vClipPlane6;varying float fClipDistance6;
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},93130:(r,t,e)=>{e(98519).l.IncludesShadersStore.decalFragment=`#ifdef DECAL
|
||
#ifdef GAMMADECAL
|
||
decalColor.rgb=toLinearSpace(decalColor.rgb);
|
||
#endif
|
||
#ifdef DECAL_SMOOTHALPHA
|
||
decalColor.a*=decalColor.a;
|
||
#endif
|
||
surfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,decalColor.rgb,decalColor.a);
|
||
#endif
|
||
`},77740:(r,t,e)=>{e(98519).l.IncludesShadersStore.decalFragmentDeclaration=`#ifdef DECAL
|
||
uniform vec4 vDecalInfos;
|
||
#endif
|
||
`},42858:(r,t,e)=>{e(98519).l.IncludesShadersStore.decalVertexDeclaration=`#ifdef DECAL
|
||
uniform vec4 vDecalInfos;uniform mat4 decalMatrix;
|
||
#endif
|
||
`},51578:(r,t,e)=>{var n=e(98519),i=(e(50851),e(56174),"defaultUboDeclaration");n.l.IncludesShadersStore[i]=`layout(std140,column_major) uniform;uniform Material
|
||
{vec4 diffuseLeftColor;vec4 diffuseRightColor;vec4 opacityParts;vec4 reflectionLeftColor;vec4 reflectionRightColor;vec4 refractionLeftColor;vec4 refractionRightColor;vec4 emissiveLeftColor;vec4 emissiveRightColor;vec2 vDiffuseInfos;vec2 vAmbientInfos;vec2 vOpacityInfos;vec2 vReflectionInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 reflectionMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 specularMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;float pointSize;float alphaCutOff;mat4 refractionMatrix;vec4 vRefractionInfos;vec3 vRefractionPosition;vec3 vRefractionSize;vec4 vSpecularColor;vec3 vEmissiveColor;vec4 vDiffuseColor;vec3 vAmbientColor;
|
||
#define ADDITIONAL_UBO_DECLARATION
|
||
};
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
`},15656:(r,t,e)=>{e(98519).l.IncludesShadersStore.depthPrePass=`#ifdef DEPTHPREPASS
|
||
gl_FragColor=vec4(0.,0.,0.,1.0);return;
|
||
#endif
|
||
`},86343:(r,t,e)=>{e(98519).l.IncludesShadersStore.fogFragment=`#ifdef FOG
|
||
float fog=CalcFogFactor();
|
||
#ifdef PBR
|
||
fog=toLinearSpace(fog);
|
||
#endif
|
||
color.rgb=mix(vFogColor,color.rgb,fog);
|
||
#endif
|
||
`},52767:(r,t,e)=>{e.r(t),e.d(t,{fogFragmentDeclaration:()=>o});var n="fogFragmentDeclaration",i=`#ifdef FOG
|
||
#define FOGMODE_NONE 0.
|
||
#define FOGMODE_EXP 1.
|
||
#define FOGMODE_EXP2 2.
|
||
#define FOGMODE_LINEAR 3.
|
||
#define E 2.71828
|
||
uniform vec4 vFogInfos;uniform vec3 vFogColor;varying vec3 vFogDistance;float CalcFogFactor()
|
||
{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)
|
||
{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);}
|
||
else if (FOGMODE_EXP==vFogInfos.x)
|
||
{fogCoeff=1.0/pow(E,fogDistance*fogDensity);}
|
||
else if (FOGMODE_EXP2==vFogInfos.x)
|
||
{fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);}
|
||
return clamp(fogCoeff,0.0,1.0);}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},62589:(r,t,e)=>{e(98519).l.IncludesShadersStore.fogVertex=`#ifdef FOG
|
||
vFogDistance=(view*worldPos).xyz;
|
||
#endif
|
||
`},72153:(r,t,e)=>{e(98519).l.IncludesShadersStore.fogVertexDeclaration=`#ifdef FOG
|
||
varying vec3 vFogDistance;
|
||
#endif
|
||
`},18644:(r,t,e)=>{e(98519).l.IncludesShadersStore.fresnelFunction=`#ifdef FRESNEL
|
||
float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)
|
||
{float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}
|
||
#endif
|
||
`},92518:(r,t,e)=>{e(98519).l.IncludesShadersStore.harmonicsFunctions=`#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#ifdef SPHERICAL_HARMONICS
|
||
vec3 computeEnvironmentIrradiance(vec3 normal) {return vSphericalL00
|
||
+ vSphericalL1_1*(normal.y)
|
||
+ vSphericalL10*(normal.z)
|
||
+ vSphericalL11*(normal.x)
|
||
+ vSphericalL2_2*(normal.y*normal.x)
|
||
+ vSphericalL2_1*(normal.y*normal.z)
|
||
+ vSphericalL20*((3.0*normal.z*normal.z)-1.0)
|
||
+ vSphericalL21*(normal.z*normal.x)
|
||
+ vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));}
|
||
#else
|
||
vec3 computeEnvironmentIrradiance(vec3 normal) {float Nx=normal.x;float Ny=normal.y;float Nz=normal.z;vec3 C1=vSphericalZZ.rgb;vec3 Cx=vSphericalX.rgb;vec3 Cy=vSphericalY.rgb;vec3 Cz=vSphericalZ.rgb;vec3 Cxx_zz=vSphericalXX_ZZ.rgb;vec3 Cyy_zz=vSphericalYY_ZZ.rgb;vec3 Cxy=vSphericalXY.rgb;vec3 Cyz=vSphericalYZ.rgb;vec3 Czx=vSphericalZX.rgb;vec3 a1=Cyy_zz*Ny+Cy;vec3 a2=Cyz*Nz+a1;vec3 b1=Czx*Nz+Cx;vec3 b2=Cxy*Ny+b1;vec3 b3=Cxx_zz*Nx+b2;vec3 t1=Cz *Nz+C1;vec3 t2=a2 *Ny+t1;vec3 t3=b3 *Nx+t2;return t3;}
|
||
#endif
|
||
#endif
|
||
`},10114:(r,t,e)=>{e(98519).l.IncludesShadersStore.hdrFilteringFunctions=`#ifdef NUM_SAMPLES
|
||
#if NUM_SAMPLES>0
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
float radicalInverse_VdC(uint bits)
|
||
{bits=(bits<<16u) | (bits>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return float(bits)*2.3283064365386963e-10; }
|
||
vec2 hammersley(uint i,uint N)
|
||
{return vec2(float(i)/float(N),radicalInverse_VdC(i));}
|
||
#else
|
||
float vanDerCorpus(int n,int base)
|
||
{float invBase=1.0/float(base);float denom =1.0;float result =0.0;for(int i=0; i<32; ++i)
|
||
{if(n>0)
|
||
{denom =mod(float(n),2.0);result+=denom*invBase;invBase=invBase/2.0;n =int(float(n)/2.0);}}
|
||
return result;}
|
||
vec2 hammersley(int i,int N)
|
||
{return vec2(float(i)/float(N),vanDerCorpus(i,2));}
|
||
#endif
|
||
float log4(float x) {return log2(x)/2.;}
|
||
const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.;
|
||
#define inline
|
||
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
|
||
{vec3 n=normalize(inputN);vec3 result=vec3(0.0);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
||
#else
|
||
for(int i=0; i<NUM_SAMPLES; ++i)
|
||
#endif
|
||
{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 Ls=hemisphereCosSample(Xi);Ls=normalize(Ls);vec3 Ns=vec3(0.,0.,1.);float NoL=dot(Ns,Ls);if (NoL>0.) {float pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.0,maxLevel);vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
|
||
#ifdef GAMMA_INPUT
|
||
c=toLinearSpace(c);
|
||
#endif
|
||
result+=c;}}
|
||
result=result*NUM_SAMPLES_FLOAT_INVERSED;return result;}
|
||
#define inline
|
||
vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
|
||
{vec3 n=normalize(inputN);vec3 c=textureCube(inputTexture,n).rgb;
|
||
if (alphaG==0.) {
|
||
#ifdef GAMMA_INPUT
|
||
c=toLinearSpace(c);
|
||
#endif
|
||
return c;} else {vec3 result=vec3(0.);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);float weight=0.;
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
||
#else
|
||
for(int i=0; i<NUM_SAMPLES; ++i)
|
||
#endif
|
||
{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);float NoV=1.;float NoH=H.z;float NoH2=H.z*H.z;float NoL=2.*NoH2-1.;vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
|
||
#ifdef GAMMA_INPUT
|
||
c=toLinearSpace(c);
|
||
#endif
|
||
result+=c*NoL;}}
|
||
result=result/weight;return result;}}
|
||
#endif
|
||
#endif
|
||
`},75334:(r,t,e)=>{e.r(t),e.d(t,{helperFunctions:()=>o});var n="helperFunctions",i=`const float PI=3.1415926535897932384626433832795;const float RECIPROCAL_PI=0.3183098861837907;const float RECIPROCAL_PI2=0.15915494309189535;const float HALF_MIN=5.96046448e-08;
|
||
const float LinearEncodePowerApprox=2.2;const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);const float Epsilon=0.0000001;
|
||
#define saturate(x) clamp(x,0.0,1.0)
|
||
#define absEps(x) abs(x)+Epsilon
|
||
#define maxEps(x) max(x,Epsilon)
|
||
#define saturateEps(x) clamp(x,Epsilon,1.0)
|
||
mat3 transposeMat3(mat3 inMatrix) {vec3 i0=inMatrix[0];vec3 i1=inMatrix[1];vec3 i2=inMatrix[2];mat3 outMatrix=mat3(
|
||
vec3(i0.x,i1.x,i2.x),
|
||
vec3(i0.y,i1.y,i2.y),
|
||
vec3(i0.z,i1.z,i2.z)
|
||
);return outMatrix;}
|
||
mat3 inverseMat3(mat3 inMatrix) {float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
|
||
b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
|
||
b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
vec3 toLinearSpaceExact(vec3 color)
|
||
{vec3 nearZeroSection=0.0773993808*color;vec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));
|
||
#else
|
||
return
|
||
vec3(
|
||
color.r<=0.04045 ? nearZeroSection.r : remainingSection.r,
|
||
color.g<=0.04045 ? nearZeroSection.g : remainingSection.g,
|
||
color.b<=0.04045 ? nearZeroSection.b : remainingSection.b);
|
||
#endif
|
||
}
|
||
vec3 toGammaSpaceExact(vec3 color)
|
||
{vec3 nearZeroSection=12.92*color;vec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055);
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));
|
||
#else
|
||
return
|
||
vec3(
|
||
color.r<=0.0031308 ? nearZeroSection.r : remainingSection.r,
|
||
color.g<=0.0031308 ? nearZeroSection.g : remainingSection.g,
|
||
color.b<=0.0031308 ? nearZeroSection.b : remainingSection.b);
|
||
#endif
|
||
}
|
||
#endif
|
||
float toLinearSpace(float color)
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
float nearZeroSection=0.0773993808*color;float remainingSection=pow(0.947867299*(color+0.055),2.4);return color<=0.04045 ? nearZeroSection : remainingSection;
|
||
#else
|
||
return pow(color,LinearEncodePowerApprox);
|
||
#endif
|
||
}
|
||
vec3 toLinearSpace(vec3 color)
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return toLinearSpaceExact(color);
|
||
#else
|
||
return pow(color,vec3(LinearEncodePowerApprox));
|
||
#endif
|
||
}
|
||
vec4 toLinearSpace(vec4 color)
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return vec4(toLinearSpaceExact(color.rgb),color.a);
|
||
#else
|
||
return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);
|
||
#endif
|
||
}
|
||
float toGammaSpace(float color)
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
float nearZeroSection=12.92*color;float remainingSection=1.055*pow(color,0.41666)-0.055;return color<=0.0031308 ? nearZeroSection : remainingSection;
|
||
#else
|
||
return pow(color,GammaEncodePowerApprox);
|
||
#endif
|
||
}
|
||
vec3 toGammaSpace(vec3 color)
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return toGammaSpaceExact(color);
|
||
#else
|
||
return pow(color,vec3(GammaEncodePowerApprox));
|
||
#endif
|
||
}
|
||
vec4 toGammaSpace(vec4 color)
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return vec4(toGammaSpaceExact(color.rgb),color.a);
|
||
#else
|
||
return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);
|
||
#endif
|
||
}
|
||
float square(float value)
|
||
{return value*value;}
|
||
vec3 square(vec3 value)
|
||
{return value*value;}
|
||
float pow5(float value) {float sq=value*value;return sq*sq*value;}
|
||
float getLuminance(vec3 color)
|
||
{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}
|
||
float getRand(vec2 seed) {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);}
|
||
float dither(vec2 seed,float varianceAmount) {float rand=getRand(seed);float normVariance=varianceAmount/255.0;float dither=mix(-normVariance,normVariance,rand);return dither;}
|
||
const float rgbdMaxRange=255.0;vec4 toRGBD(vec3 color) {float maxRGB=maxEps(max(color.r,max(color.g,color.b)));float D =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);vec3 rgb=color.rgb*D;rgb=toGammaSpace(rgb);return vec4(clamp(rgb,0.,1.),D); }
|
||
vec3 fromRGBD(vec4 rgbd) {rgbd.rgb=toLinearSpace(rgbd.rgb);return rgbd.rgb/rgbd.a;}
|
||
vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;vec3 halfSize=cubeSize*0.5;vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);vec3 intersectPositionWS=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},59581:(r,t,e)=>{e.r(t),e.d(t,{imageProcessingDeclaration:()=>o});var n="imageProcessingDeclaration",i=`#ifdef EXPOSURE
|
||
uniform float exposureLinear;
|
||
#endif
|
||
#ifdef CONTRAST
|
||
uniform float contrast;
|
||
#endif
|
||
#if defined(VIGNETTE) || defined(DITHER)
|
||
uniform vec2 vInverseScreenSize;
|
||
#endif
|
||
#ifdef VIGNETTE
|
||
uniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2;
|
||
#endif
|
||
#ifdef COLORCURVES
|
||
uniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive;
|
||
#endif
|
||
#ifdef COLORGRADING
|
||
#ifdef COLORGRADING3D
|
||
uniform highp sampler3D txColorTransform;
|
||
#else
|
||
uniform sampler2D txColorTransform;
|
||
#endif
|
||
uniform vec4 colorTransformSettings;
|
||
#endif
|
||
#ifdef DITHER
|
||
uniform float ditherIntensity;
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},40688:(r,t,e)=>{e.r(t),e.d(t,{imageProcessingFunctions:()=>o});var n="imageProcessingFunctions",i=`#if defined(COLORGRADING) && !defined(COLORGRADING3D)
|
||
/**
|
||
* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.
|
||
* sampler3dSetting.x=textureOffset (0.5/textureSize).
|
||
* sampler3dSetting.y=textureSize.
|
||
*/
|
||
#define inline
|
||
vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
|
||
{float sliceSize=2.0*sampler3dSetting.x;
|
||
#ifdef SAMPLER3DGREENDEPTH
|
||
float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
|
||
#else
|
||
float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
|
||
#endif
|
||
float sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger;
|
||
#ifdef SAMPLER3DGREENDEPTH
|
||
vec2 sliceUV=color.rb;
|
||
#else
|
||
vec2 sliceUV=color.rg;
|
||
#endif
|
||
sliceUV.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);
|
||
#ifdef SAMPLER3DBGRMAP
|
||
color.rgb=result.rgb;
|
||
#else
|
||
color.rgb=result.bgr;
|
||
#endif
|
||
return color;}
|
||
#endif
|
||
#if TONEMAPPING==3
|
||
const 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);}
|
||
#endif
|
||
#if TONEMAPPING==2
|
||
const mat3 ACESInputMat=mat3(
|
||
vec3(0.59719,0.07600,0.02840),
|
||
vec3(0.35458,0.90834,0.13383),
|
||
vec3(0.04823,0.01566,0.83777)
|
||
);const mat3 ACESOutputMat=mat3(
|
||
vec3( 1.60475,-0.10208,-0.00327),
|
||
vec3(-0.53108, 1.10813,-0.07276),
|
||
vec3(-0.07367,-0.00605, 1.07602)
|
||
);vec3 RRTAndODTFit(vec3 v)
|
||
{vec3 a=v*(v+0.0245786)-0.000090537;vec3 b=v*(0.983729*v+0.4329510)+0.238081;return a/b;}
|
||
vec3 ACESFitted(vec3 color)
|
||
{color=ACESInputMat*color;color=RRTAndODTFit(color);color=ACESOutputMat*color;color=saturate(color);return color;}
|
||
#endif
|
||
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
|
||
vec4 applyImageProcessing(vec4 result) {
|
||
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
|
||
#ifdef EXPOSURE
|
||
result.rgb*=exposureLinear;
|
||
#endif
|
||
#ifdef VIGNETTE
|
||
vec2 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;
|
||
#ifdef VIGNETTEBLENDMODEMULTIPLY
|
||
vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);result.rgb*=vignetteColorMultiplier;
|
||
#endif
|
||
#ifdef VIGNETTEBLENDMODEOPAQUE
|
||
result.rgb=mix(vignetteColor,result.rgb,vignette);
|
||
#endif
|
||
#endif
|
||
#if TONEMAPPING==3
|
||
result.rgb=PBRNeutralToneMapping(result.rgb);
|
||
#elif TONEMAPPING==2
|
||
result.rgb=ACESFitted(result.rgb);
|
||
#elif TONEMAPPING==1
|
||
const float tonemappingCalibration=1.590579;result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
|
||
#endif
|
||
result.rgb=toGammaSpace(result.rgb);result.rgb=saturate(result.rgb);
|
||
#ifdef CONTRAST
|
||
vec3 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);}
|
||
#endif
|
||
#ifdef COLORGRADING
|
||
vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
|
||
#ifdef COLORGRADING3D
|
||
vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
|
||
#else
|
||
vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
|
||
#endif
|
||
result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
|
||
#endif
|
||
#ifdef COLORCURVES
|
||
float 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);
|
||
#endif
|
||
#ifdef DITHER
|
||
float rand=getRand(gl_FragCoord.xy*vInverseScreenSize);float dither=mix(-ditherIntensity,ditherIntensity,rand);result.rgb=saturate(result.rgb+vec3(dither));
|
||
#endif
|
||
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
|
||
return result;}`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},19568:(r,t,e)=>{e(98519).l.IncludesShadersStore.importanceSampling=`vec3 hemisphereCosSample(vec2 u) {float phi=2.*PI*u.x;float cosTheta2=1.-u.y;float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
|
||
vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {float phi=2.*PI*u.x;float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
|
||
vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {
|
||
float phi=2.*PI*u.x;float sinTheta=pow(u.y,a/(2.*a+1.));float cosTheta=sqrt(1.-sinTheta*sinTheta);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`},38615:(r,t,e)=>{e(98519).l.IncludesShadersStore.instancesDeclaration=`#ifdef INSTANCES
|
||
attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;
|
||
#ifdef INSTANCESCOLOR
|
||
attribute vec4 instanceColor;
|
||
#endif
|
||
#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
|
||
uniform mat4 world;
|
||
#endif
|
||
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
attribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;
|
||
#ifdef THIN_INSTANCES
|
||
uniform mat4 previousWorld;
|
||
#endif
|
||
#endif
|
||
#else
|
||
#if !defined(WORLD_UBO)
|
||
uniform mat4 world;
|
||
#endif
|
||
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
uniform mat4 previousWorld;
|
||
#endif
|
||
#endif
|
||
`},35397:(r,t,e)=>{e(98519).l.IncludesShadersStore.instancesVertex=`#ifdef INSTANCES
|
||
mat4 finalWorld=mat4(world0,world1,world2,world3);
|
||
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,
|
||
previousWorld2,previousWorld3);
|
||
#endif
|
||
#ifdef THIN_INSTANCES
|
||
finalWorld=world*finalWorld;
|
||
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
finalPreviousWorld=previousWorld*finalPreviousWorld;
|
||
#endif
|
||
#endif
|
||
#else
|
||
mat4 finalWorld=world;
|
||
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
mat4 finalPreviousWorld=previousWorld;
|
||
#endif
|
||
#endif
|
||
`},67303:(r,t,e)=>{e(98519).l.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};"},7363:(r,t,e)=>{e.r(t),e.d(t,{lightFragment:()=>o});var n="lightFragment",i=`#ifdef LIGHT{X}
|
||
#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
|
||
#else
|
||
vec4 diffuse{X}=light{X}.vLightDiffuse;
|
||
#define CUSTOM_LIGHT{X}_COLOR
|
||
#ifdef PBR
|
||
#ifdef SPOTLIGHT{X}
|
||
preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);
|
||
#elif defined(POINTLIGHT{X})
|
||
preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);
|
||
#elif defined(HEMILIGHT{X})
|
||
preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
|
||
#elif defined(DIRLIGHT{X})
|
||
preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
|
||
#endif
|
||
preInfo.NdotV=NdotV;
|
||
#ifdef SPOTLIGHT{X}
|
||
#ifdef LIGHT_FALLOFF_GLTF{X}
|
||
preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
||
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
|
||
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
|
||
#else
|
||
preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
||
#endif
|
||
#elif defined(POINTLIGHT{X})
|
||
#ifdef LIGHT_FALLOFF_GLTF{X}
|
||
preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
|
||
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
|
||
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
|
||
#else
|
||
preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
||
#endif
|
||
#else
|
||
preInfo.attenuation=1.0;
|
||
#endif
|
||
#ifdef HEMILIGHT{X}
|
||
preInfo.roughness=roughness;
|
||
#else
|
||
preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
preInfo.iridescenceIntensity=iridescenceIntensity;
|
||
#endif
|
||
#ifdef HEMILIGHT{X}
|
||
info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround);
|
||
#elif defined(SS_TRANSLUCENCY)
|
||
info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
|
||
#else
|
||
info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb);
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
#ifdef ANISOTROPIC
|
||
info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
|
||
#else
|
||
info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
preInfo.roughness=sheenOut.sheenIntensity;
|
||
#else
|
||
#ifdef HEMILIGHT{X}
|
||
preInfo.roughness=sheenOut.sheenRoughness;
|
||
#else
|
||
preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
|
||
#endif
|
||
#endif
|
||
info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
#ifdef HEMILIGHT{X}
|
||
preInfo.roughness=clearcoatOut.clearCoatRoughness;
|
||
#else
|
||
preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
|
||
#endif
|
||
info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb);
|
||
#ifdef CLEARCOAT_TINT
|
||
absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
|
||
#ifdef SPECULARTERM
|
||
info.specular*=absorption;
|
||
#endif
|
||
#endif
|
||
info.diffuse*=info.clearCoat.w;
|
||
#ifdef SPECULARTERM
|
||
info.specular*=info.clearCoat.w;
|
||
#endif
|
||
#ifdef SHEEN
|
||
info.sheen*=info.clearCoat.w;
|
||
#endif
|
||
#endif
|
||
#else
|
||
#ifdef SPOTLIGHT{X}
|
||
info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
|
||
#elif defined(HEMILIGHT{X})
|
||
info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
|
||
#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
|
||
info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
|
||
#endif
|
||
#endif
|
||
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
||
info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
|
||
#endif
|
||
#endif
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
|
||
{
|
||
#ifdef SHADOWCSM_RIGHTHANDED{X}
|
||
diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
|
||
#else
|
||
diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
|
||
#endif
|
||
if (diff{X}>=0.) {index{X}=i;break;}}
|
||
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
|
||
if (index{X}>=0)
|
||
#endif
|
||
{
|
||
#if defined(SHADOWPCF{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=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);
|
||
#else
|
||
shadow=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);
|
||
#endif
|
||
#elif defined(SHADOWPCSS{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=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});
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=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});
|
||
#else
|
||
shadow=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});
|
||
#endif
|
||
#else
|
||
shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
|
||
#endif
|
||
#ifndef SHADOWCSMNOBLEND{X}
|
||
float frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
|
||
{index{X}+=1;float nextShadow=0.;
|
||
#if defined(SHADOWPCF{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
nextShadow=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);
|
||
#else
|
||
nextShadow=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);
|
||
#endif
|
||
#elif defined(SHADOWPCSS{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
nextShadow=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});
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
nextShadow=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});
|
||
#else
|
||
nextShadow=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});
|
||
#endif
|
||
#else
|
||
nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
shadow=mix(nextShadow,shadow,diffRatio);
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
|
||
#endif
|
||
}
|
||
#endif
|
||
}
|
||
#elif defined(SHADOWCLOSEESM{X})
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWESM{X})
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPOISSON{X})
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPCF{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#else
|
||
shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPCSS{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=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);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=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);
|
||
#else
|
||
shadow=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);
|
||
#endif
|
||
#else
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#endif
|
||
#ifdef SHADOWONLY
|
||
#ifndef SHADOWINUSE
|
||
#define SHADOWINUSE
|
||
#endif
|
||
globalShadow+=shadow;shadowLightCount+=1.0;
|
||
#endif
|
||
#else
|
||
shadow=1.;
|
||
#endif
|
||
aggShadow+=shadow;numLights+=1.0;
|
||
#ifndef SHADOWONLY
|
||
#ifdef CUSTOMUSERLIGHTING
|
||
diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
|
||
#ifdef SPECULARTERM
|
||
specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
|
||
#endif
|
||
#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
|
||
diffuseBase+=lightmapColor.rgb*shadow;
|
||
#ifdef SPECULARTERM
|
||
#ifndef LIGHTMAPNOSPECULAR{X}
|
||
specularBase+=info.specular*shadow*lightmapColor.rgb;
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
#ifndef LIGHTMAPNOSPECULAR{X}
|
||
clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
#ifndef LIGHTMAPNOSPECULAR{X}
|
||
sheenBase+=info.sheen.rgb*shadow;
|
||
#endif
|
||
#endif
|
||
#else
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
diffuseBase+=info.diffuse*shadowDebug{X};
|
||
#else
|
||
diffuseBase+=info.diffuse*shadow;
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
specularBase+=info.specular*shadow;
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
clearCoatBase+=info.clearCoat.rgb*shadow;
|
||
#endif
|
||
#ifdef SHEEN
|
||
sheenBase+=info.sheen.rgb*shadow;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},87283:(r,t,e)=>{e.r(t),e.d(t,{lightFragmentDeclaration:()=>o});var n="lightFragmentDeclaration",i=`#ifdef LIGHT{X}
|
||
uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
|
||
#ifdef SPECULARTERM
|
||
uniform vec4 vLightSpecular{X};
|
||
#else
|
||
vec4 vLightSpecular{X}=vec4(0.);
|
||
#endif
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
uniform 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};
|
||
#if defined(SHADOWPCSS{X})
|
||
uniform 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};
|
||
#elif defined(SHADOWPCF{X})
|
||
uniform highp sampler2DArrayShadow shadowTexture{X};
|
||
#else
|
||
uniform highp sampler2DArray shadowTexture{X};
|
||
#endif
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
|
||
(
|
||
vec3 ( 1.5,0.0,0.0 ),
|
||
vec3 ( 0.0,1.5,0.0 ),
|
||
vec3 ( 0.0,0.0,5.5 ),
|
||
vec3 ( 1.5,0.0,5.5 ),
|
||
vec3 ( 1.5,1.5,0.0 ),
|
||
vec3 ( 1.0,1.0,1.0 ),
|
||
vec3 ( 0.0,1.0,5.5 ),
|
||
vec3 ( 0.5,3.5,0.75 )
|
||
);vec3 shadowDebug{X};
|
||
#endif
|
||
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
|
||
int index{X}=-1;
|
||
#else
|
||
int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
|
||
#endif
|
||
float diff{X}=0.;
|
||
#elif defined(SHADOWCUBE{X})
|
||
uniform samplerCube shadowTexture{X};
|
||
#else
|
||
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
|
||
#if defined(SHADOWPCSS{X})
|
||
uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
|
||
#elif defined(SHADOWPCF{X})
|
||
uniform highp sampler2DShadow shadowTexture{X};
|
||
#else
|
||
uniform sampler2D shadowTexture{X};
|
||
#endif
|
||
uniform mat4 lightMatrix{X};
|
||
#endif
|
||
uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
|
||
#endif
|
||
#ifdef SPOTLIGHT{X}
|
||
uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
|
||
#elif defined(POINTLIGHT{X})
|
||
uniform vec4 vLightFalloff{X};
|
||
#elif defined(HEMILIGHT{X})
|
||
uniform vec3 vLightGround{X};
|
||
#endif
|
||
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
||
uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},32823:(r,t,e)=>{e.r(t),e.d(t,{lightUboDeclaration:()=>o});var n="lightUboDeclaration",i=`#ifdef LIGHT{X}
|
||
uniform Light{X}
|
||
{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
|
||
#ifdef SPOTLIGHT{X}
|
||
vec4 vLightDirection;vec4 vLightFalloff;
|
||
#elif defined(POINTLIGHT{X})
|
||
vec4 vLightFalloff;
|
||
#elif defined(HEMILIGHT{X})
|
||
vec3 vLightGround;
|
||
#endif
|
||
vec4 shadowsInfo;vec2 depthValues;} light{X};
|
||
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
||
uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
|
||
#endif
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
uniform 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};
|
||
#if defined(SHADOWPCSS{X})
|
||
uniform 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};
|
||
#elif defined(SHADOWPCF{X})
|
||
uniform highp sampler2DArrayShadow shadowTexture{X};
|
||
#else
|
||
uniform highp sampler2DArray shadowTexture{X};
|
||
#endif
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
|
||
(
|
||
vec3 ( 1.5,0.0,0.0 ),
|
||
vec3 ( 0.0,1.5,0.0 ),
|
||
vec3 ( 0.0,0.0,5.5 ),
|
||
vec3 ( 1.5,0.0,5.5 ),
|
||
vec3 ( 1.5,1.5,0.0 ),
|
||
vec3 ( 1.0,1.0,1.0 ),
|
||
vec3 ( 0.0,1.0,5.5 ),
|
||
vec3 ( 0.5,3.5,0.75 )
|
||
);vec3 shadowDebug{X};
|
||
#endif
|
||
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
|
||
int index{X}=-1;
|
||
#else
|
||
int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
|
||
#endif
|
||
float diff{X}=0.;
|
||
#elif defined(SHADOWCUBE{X})
|
||
uniform samplerCube shadowTexture{X};
|
||
#else
|
||
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
|
||
#if defined(SHADOWPCSS{X})
|
||
uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
|
||
#elif defined(SHADOWPCF{X})
|
||
uniform highp sampler2DShadow shadowTexture{X};
|
||
#else
|
||
uniform sampler2D shadowTexture{X};
|
||
#endif
|
||
uniform mat4 lightMatrix{X};
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},94785:(r,t,e)=>{e.r(t),e.d(t,{lightVxFragmentDeclaration:()=>o});var n="lightVxFragmentDeclaration",i=`#ifdef LIGHT{X}
|
||
uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
|
||
#ifdef SPECULARTERM
|
||
uniform vec4 vLightSpecular{X};
|
||
#else
|
||
vec4 vLightSpecular{X}=vec4(0.);
|
||
#endif
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
|
||
#elif defined(SHADOWCUBE{X})
|
||
#else
|
||
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};
|
||
#endif
|
||
uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
|
||
#endif
|
||
#ifdef SPOTLIGHT{X}
|
||
uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
|
||
#elif defined(POINTLIGHT{X})
|
||
uniform vec4 vLightFalloff{X};
|
||
#elif defined(HEMILIGHT{X})
|
||
uniform vec3 vLightGround{X};
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},48961:(r,t,e)=>{e.r(t),e.d(t,{lightVxUboDeclaration:()=>o});var n="lightVxUboDeclaration",i=`#ifdef LIGHT{X}
|
||
uniform Light{X}
|
||
{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
|
||
#ifdef SPOTLIGHT{X}
|
||
vec4 vLightDirection;vec4 vLightFalloff;
|
||
#elif defined(POINTLIGHT{X})
|
||
vec4 vLightFalloff;
|
||
#elif defined(HEMILIGHT{X})
|
||
vec3 vLightGround;
|
||
#endif
|
||
vec4 shadowsInfo;vec2 depthValues;} light{X};
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
|
||
#elif defined(SHADOWCUBE{X})
|
||
#else
|
||
varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},54409:(r,t,e)=>{e.r(t),e.d(t,{lightsFragmentFunctions:()=>o});var n="lightsFragmentFunctions",i=`struct lightingInfo
|
||
{vec3 diffuse;
|
||
#ifdef SPECULARTERM
|
||
vec3 specular;
|
||
#endif
|
||
#ifdef NDOTL
|
||
float ndl;
|
||
#endif
|
||
};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.)
|
||
{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
|
||
else
|
||
{lightVectorW=normalize(-lightData.xyz);}
|
||
float ndl=max(0.,dot(vNormal,lightVectorW));
|
||
#ifdef NDOTL
|
||
result.ndl=ndl;
|
||
#endif
|
||
result.diffuse=ndl*diffuseColor*attenuation;
|
||
#ifdef SPECULARTERM
|
||
vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
|
||
#endif
|
||
return result;}
|
||
lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)
|
||
{cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;float ndl=max(0.,dot(vNormal,lightVectorW));
|
||
#ifdef NDOTL
|
||
result.ndl=ndl;
|
||
#endif
|
||
result.diffuse=ndl*diffuseColor*attenuation;
|
||
#ifdef SPECULARTERM
|
||
vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
|
||
#endif
|
||
return result;}
|
||
result.diffuse=vec3(0.);
|
||
#ifdef SPECULARTERM
|
||
result.specular=vec3(0.);
|
||
#endif
|
||
#ifdef NDOTL
|
||
result.ndl=0.;
|
||
#endif
|
||
return result;}
|
||
lightingInfo 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;
|
||
#ifdef NDOTL
|
||
result.ndl=ndl;
|
||
#endif
|
||
result.diffuse=mix(groundColor,diffuseColor,ndl);
|
||
#ifdef SPECULARTERM
|
||
vec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
|
||
#endif
|
||
return result;}
|
||
#define inline
|
||
vec3 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;}`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},59262:(r,t,e)=>{e(98519).l.IncludesShadersStore.logDepthDeclaration=`#ifdef LOGARITHMICDEPTH
|
||
uniform float logarithmicDepthConstant;varying float vFragmentDepth;
|
||
#endif
|
||
`},13088:(r,t,e)=>{e(98519).l.IncludesShadersStore.logDepthFragment=`#ifdef LOGARITHMICDEPTH
|
||
gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
|
||
#endif
|
||
`},56458:(r,t,e)=>{e(98519).l.IncludesShadersStore.logDepthVertex=`#ifdef LOGARITHMICDEPTH
|
||
vFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
|
||
#endif
|
||
`},48493:(r,t,e)=>{e(98519).l.IncludesShadersStore.mainUVVaryingDeclaration=`#ifdef MAINUV{X}
|
||
varying vec2 vMainUV{X};
|
||
#endif
|
||
`},56174:(r,t,e)=>{e(98519).l.IncludesShadersStore.meshUboDeclaration=`#ifdef WEBGL2
|
||
uniform mat4 world;uniform float visibility;
|
||
#else
|
||
layout(std140,column_major) uniform;uniform Mesh
|
||
{mat4 world;float visibility;};
|
||
#endif
|
||
#define WORLD_UBO
|
||
`},84589:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertex:()=>o});var n="morphTargetsVertex",i=`#ifdef MORPHTARGETS
|
||
#ifdef MORPHTARGETS_TEXTURE
|
||
#if {X}==0
|
||
for (int i=0; i<NUM_MORPH_INFLUENCERS; i++) {if (i>=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;positionUpdated+=(readVector3FromRawSampler(i,vertexID)-position)*morphTargetInfluences[i];vertexID+=1.0;
|
||
#ifdef MORPHTARGETS_NORMAL
|
||
normalUpdated+=(readVector3FromRawSampler(i,vertexID) -normal)*morphTargetInfluences[i];vertexID+=1.0;
|
||
#endif
|
||
#ifdef MORPHTARGETS_UV
|
||
uvUpdated+=(readVector3FromRawSampler(i,vertexID).xy-uv)*morphTargetInfluences[i];vertexID+=1.0;
|
||
#endif
|
||
#ifdef MORPHTARGETS_TANGENT
|
||
tangentUpdated.xyz+=(readVector3FromRawSampler(i,vertexID) -tangent.xyz)*morphTargetInfluences[i];
|
||
#endif
|
||
}
|
||
#endif
|
||
#else
|
||
positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
|
||
#ifdef MORPHTARGETS_NORMAL
|
||
normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
|
||
#endif
|
||
#ifdef MORPHTARGETS_TANGENT
|
||
tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
|
||
#endif
|
||
#ifdef MORPHTARGETS_UV
|
||
uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},67369:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertexDeclaration:()=>o});var n="morphTargetsVertexDeclaration",i=`#ifdef MORPHTARGETS
|
||
#ifndef MORPHTARGETS_TEXTURE
|
||
attribute vec3 position{X};
|
||
#ifdef MORPHTARGETS_NORMAL
|
||
attribute vec3 normal{X};
|
||
#endif
|
||
#ifdef MORPHTARGETS_TANGENT
|
||
attribute vec3 tangent{X};
|
||
#endif
|
||
#ifdef MORPHTARGETS_UV
|
||
attribute vec2 uv_{X};
|
||
#endif
|
||
#elif {X}==0
|
||
uniform int morphTargetCount;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},58266:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertexGlobal:()=>o});var n="morphTargetsVertexGlobal",i=`#ifdef MORPHTARGETS
|
||
#ifdef MORPHTARGETS_TEXTURE
|
||
float vertexID;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},24444:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertexGlobalDeclaration:()=>o});var n="morphTargetsVertexGlobalDeclaration",i=`#ifdef MORPHTARGETS
|
||
uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
|
||
#ifdef MORPHTARGETS_TEXTURE
|
||
uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)
|
||
{
|
||
float 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;}
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},81751:(r,t,e)=>{e(98519).l.IncludesShadersStore.oitDeclaration=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
|
||
#extension GL_EXT_draw_buffers : require
|
||
layout(location=0) out vec2 depth;
|
||
layout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;
|
||
#define MAX_DEPTH 99999.0
|
||
highp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;
|
||
#endif
|
||
`},11135:(r,t,e)=>{e(98519).l.IncludesShadersStore.oitFragment=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
|
||
float fragDepth=gl_FragCoord.z;
|
||
#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
|
||
uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x;
|
||
#endif
|
||
ivec2 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);
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y;
|
||
#else
|
||
float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y;
|
||
#endif
|
||
float alphaMultiplier=1.0-lastFrontColor.a;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
|
||
#else
|
||
if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
|
||
#endif
|
||
return;}
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
|
||
#else
|
||
if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
|
||
#endif
|
||
depth.rg=vec2(-fragDepth,fragDepth);return;}
|
||
#endif
|
||
`},78531:(r,t,e)=>{e.r(t),e.d(t,{packingFunctions:()=>o});var n="packingFunctions",i=`vec4 pack(float depth)
|
||
{const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
|
||
float unpack(vec4 color)
|
||
{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);}`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},64244:(r,t,e)=>{e(98519).l.IncludesShadersStore.pbrBRDFFunctions=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
|
||
#ifdef MS_BRDF_ENERGY_CONSERVATION
|
||
vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);}
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {vec2 UV=vec2(NdotV,perceptualRoughness);vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);
|
||
#ifdef ENVIRONMENTBRDF_RGBD
|
||
brdfLookup.rgb=fromRGBD(brdfLookup.rgba);
|
||
#endif
|
||
return brdfLookup.rgb;}
|
||
vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
|
||
#else
|
||
vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
|
||
#endif
|
||
return reflectance;}
|
||
vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
|
||
#else
|
||
vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
|
||
#endif
|
||
return reflectance;}
|
||
#endif
|
||
/* NOT USED
|
||
#if defined(SHEEN) && defined(SHEEN_SOFTER)
|
||
float getBRDFLookupCharlieSheen(float NdotV,float perceptualRoughness)
|
||
{float c=1.0-NdotV;float c3=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));}
|
||
#endif
|
||
*/
|
||
#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
|
||
vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
|
||
{float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
|
||
#endif
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
||
/**
|
||
* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.
|
||
* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table
|
||
*/
|
||
vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;}
|
||
#endif
|
||
vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)
|
||
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
|
||
float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)
|
||
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
|
||
#ifdef CLEARCOAT
|
||
vec3 getR0RemappedForClearCoat(vec3 f0) {
|
||
#ifdef CLEARCOAT_DEFAULTIOR
|
||
#ifdef MOBILE
|
||
return saturate(f0*(f0*0.526868+0.529324)-0.0482256);
|
||
#else
|
||
return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
|
||
#endif
|
||
#else
|
||
vec3 s=sqrt(f0);vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);return square(t);
|
||
#endif
|
||
}
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
const mat3 XYZ_TO_REC709=mat3(
|
||
3.2404542,-0.9692660, 0.0556434,
|
||
-1.5371385, 1.8760108,-0.2040259,
|
||
-0.4985314, 0.0415560, 1.0572252
|
||
);vec3 getIORTfromAirToSurfaceR0(vec3 f0) {vec3 sqrtF0=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);}
|
||
vec3 getR0fromIORs(vec3 iorT,float iorI) {return square((iorT-vec3(iorI))/(iorT+vec3(iorI)));}
|
||
float getR0fromIORs(float iorT,float iorI) {return square((iorT-iorI)/(iorT+iorI));}
|
||
vec3 evalSensitivity(float opd,vec3 shift) {float phase=2.0*PI*opd*1.0e-9;const vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);const vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);const vec3 var=vec3(4.3278e+09,9.3046e+09,6.6121e+09);vec3 xyz=val*sqrt(2.0*PI*var)*cos(pos*phase+shift)*exp(-square(phase)*var);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*square(phase));xyz/=1.0685e-7;vec3 srgb=XYZ_TO_REC709*xyz;return srgb;}
|
||
vec3 evalIridescence(float outsideIOR,float eta2,float cosTheta1,float thinFilmThickness,vec3 baseF0) {vec3 I=vec3(1.0);float iridescenceIOR=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));float sinTheta2Sq=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));float cosTheta2Sq=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;}
|
||
float cosTheta2=sqrt(cosTheta2Sq);float R0=getR0fromIORs(iridescenceIOR,outsideIOR);float R12=fresnelSchlickGGX(cosTheta1,R0,1.);float R21=R12;float T121=1.0-R12;float phi12=0.0;if (iridescenceIOR<outsideIOR) phi12=PI;float phi21=PI-phi12;vec3 baseIOR=getIORTfromAirToSurfaceR0(clamp(baseF0,0.0,0.9999));
|
||
vec3 R1=getR0fromIORs(baseIOR,iridescenceIOR);vec3 R23=fresnelSchlickGGX(cosTheta2,R1,vec3(1.));vec3 phi23=vec3(0.0);if (baseIOR[0]<iridescenceIOR) phi23[0]=PI;if (baseIOR[1]<iridescenceIOR) phi23[1]=PI;if (baseIOR[2]<iridescenceIOR) phi23[2]=PI;float opd=2.0*iridescenceIOR*thinFilmThickness*cosTheta2;vec3 phi=vec3(phi21)+phi23;vec3 R123=clamp(R12*R23,1e-5,0.9999);vec3 r123=sqrt(R123);vec3 Rs=square(T121)*R23/(vec3(1.0)-R123);vec3 C0=R12+Rs;I=C0;vec3 Cm=Rs-T121;for (int m=1; m<=2; ++m)
|
||
{Cm*=r123;vec3 Sm=2.0*evalSensitivity(float(m)*opd,float(m)*phi);I+=Cm*Sm;}
|
||
return max(I,vec3(0.0));}
|
||
#endif
|
||
float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)
|
||
{float a2=square(alphaG);float d=NdotH*NdotH*(a2-1.0)+1.0;return a2/(PI*d*d);}
|
||
#ifdef SHEEN
|
||
float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)
|
||
{float invR=1./alphaG;float cos2h=NdotH*NdotH;float sin2h=1.-cos2h;return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);}
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {float a2=alphaTB.x*alphaTB.y;vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);float v2=dot(v,v);float w2=a2/v2;return a2*w2*w2*RECIPROCAL_PI;}
|
||
#endif
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {
|
||
#ifdef MOBILE
|
||
float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);return 0.5/(GGXV+GGXL);
|
||
#else
|
||
float a2=alphaG*alphaG;float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);return 0.5/(GGXV+GGXL);
|
||
#endif
|
||
}
|
||
#else
|
||
float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)
|
||
{
|
||
#ifdef MOBILE
|
||
return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
|
||
#else
|
||
float alphaSquared=alphaG*alphaG;return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
|
||
#endif
|
||
}
|
||
float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)
|
||
{float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);return visibility;}
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));float v=0.5/(lambdaV+lambdaL);return v;}
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
float visibility_Kelemen(float VdotH) {return 0.25/(VdotH*VdotH); }
|
||
#endif
|
||
#ifdef SHEEN
|
||
float visibility_Ashikhmin(float NdotL,float NdotV)
|
||
{return 1./(4.*(NdotL+NdotV-NdotL*NdotV));}
|
||
/* NOT USED
|
||
#ifdef SHEEN_SOFTER
|
||
float l(float x,float alphaG)
|
||
{float oneMinusAlphaSq=(1.0-alphaG)*(1.0-alphaG);float a=mix(21.5473,25.3245,oneMinusAlphaSq);float b=mix(3.82987,3.32435,oneMinusAlphaSq);float c=mix(0.19823,0.16801,oneMinusAlphaSq);float d=mix(-1.97760,-1.27393,oneMinusAlphaSq);float e=mix(-4.32054,-4.85967,oneMinusAlphaSq);return a/(1.0+b*pow(x,c))+d*x+e;}
|
||
float lambdaSheen(float cosTheta,float alphaG)
|
||
{return abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));}
|
||
float visibility_CharlieSheen(float NdotL,float NdotV,float alphaG)
|
||
{float G=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));return G/(4.0*NdotV*NdotL);}
|
||
#endif
|
||
*/
|
||
#endif
|
||
float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;float fresnel =
|
||
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
|
||
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);return fresnel/PI;}
|
||
#ifdef SS_TRANSLUCENCY
|
||
vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {vec3 S=1./maxEps(diffusionDistance);vec3 temp=exp((-0.333333333*thickness)*S);return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);}
|
||
float computeWrappedDiffuseNdotL(float NdotL,float w) {float t=1.0+w;float invt2=1.0/square(t);return saturate((NdotL+w)*invt2);}
|
||
#endif
|
||
`},48915:(r,t,e)=>{var n=e(98519),i=(e(50851),e(56174),"pbrUboDeclaration");n.l.IncludesShadersStore[i]=`layout(std140,column_major) uniform;uniform Material {vec2 vAlbedoInfos;vec4 vAmbientInfos;vec2 vOpacityInfos;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec3 vReflectivityInfos;vec2 vMicroSurfaceSamplerInfos;vec2 vReflectionInfos;vec2 vReflectionFilteringInfo;vec3 vReflectionPosition;vec3 vReflectionSize;vec3 vBumpInfos;mat4 albedoMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 reflectivityMatrix;mat4 microSurfaceSamplerMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;mat4 reflectionMatrix;vec3 vReflectionColor;vec4 vAlbedoColor;vec4 vLightingIntensity;vec3 vReflectionMicrosurfaceInfos;float pointSize;vec4 vReflectivityColor;vec3 vEmissiveColor;vec3 vAmbientColor;vec2 vDebugMode;vec4 vMetallicReflectanceFactors;vec2 vMetallicReflectanceInfos;mat4 metallicReflectanceMatrix;vec2 vReflectanceInfos;mat4 reflectanceMatrix;vec3 vSphericalL00;vec3 vSphericalL1_1;vec3 vSphericalL10;vec3 vSphericalL11;vec3 vSphericalL2_2;vec3 vSphericalL2_1;vec3 vSphericalL20;vec3 vSphericalL21;vec3 vSphericalL22;vec3 vSphericalX;vec3 vSphericalY;vec3 vSphericalZ;vec3 vSphericalXX_ZZ;vec3 vSphericalYY_ZZ;vec3 vSphericalZZ;vec3 vSphericalXY;vec3 vSphericalYZ;vec3 vSphericalZX;
|
||
#define ADDITIONAL_UBO_DECLARATION
|
||
};
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
`},52226:(r,t,e)=>{e(98519).l.IncludesShadersStore.pointCloudVertex=`#if defined(POINTSIZE) && !defined(WEBGPU)
|
||
gl_PointSize=pointSize;
|
||
#endif
|
||
`},42107:(r,t,e)=>{e(98519).l.IncludesShadersStore.prePassDeclaration=`#ifdef PREPASS
|
||
#extension GL_EXT_draw_buffers : require
|
||
layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
varying highp vec3 vPosition;
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
varying highp vec3 vViewPos;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;
|
||
#endif
|
||
#endif
|
||
`},7761:(r,t,e)=>{e(98519).l.IncludesShadersStore.prePassVertex=`#ifdef PREPASS_DEPTH
|
||
vViewPos=(view*worldPos).rgb;
|
||
#endif
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
vPosition=positionUpdated.xyz;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED) || defined(PREPASS_VELOCITY_LINEAR)
|
||
vCurrentPosition=viewProjection*worldPos;
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
|
||
#endif
|
||
vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);
|
||
#else
|
||
vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
|
||
#endif
|
||
#endif
|
||
`},60965:(r,t,e)=>{e(98519).l.IncludesShadersStore.prePassVertexDeclaration=`#ifdef PREPASS
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
varying vec3 vPosition;
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
varying vec3 vViewPos;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
|
||
#endif
|
||
#endif
|
||
`},40150:(r,t,e)=>{e.r(t),e.d(t,{reflectionFunction:()=>o});var n="reflectionFunction",i=`vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
|
||
{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); }
|
||
vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
|
||
{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); }
|
||
vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
|
||
{vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);vec3 r=normalize(reflect(cameraToVertex,worldNormal));r=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);}
|
||
vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)
|
||
{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);}
|
||
vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
|
||
{vec3 viewDir=worldPos.xyz-eyePosition;vec3 coords=normalize(reflect(viewDir,worldNormal));return vec3(reflectionMatrix*vec4(coords,1));}
|
||
vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
|
||
{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=vec3(reflectionMatrix*vec4(coords,0));
|
||
#ifdef INVERTCUBICMAP
|
||
coords.y*=-1.0;
|
||
#endif
|
||
return coords;}
|
||
vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)
|
||
{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=vec3(reflectionMatrix*vec4(coords,0));
|
||
#ifdef INVERTCUBICMAP
|
||
coords.y*=-1.0;
|
||
#endif
|
||
return coords;}
|
||
vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)
|
||
{return vec3(reflectionMatrix*(view*worldPos));}
|
||
vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)
|
||
{return vec3(reflectionMatrix*vec4(positionW,1.));}
|
||
#ifdef REFLECTION
|
||
vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)
|
||
{
|
||
#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
|
||
vec3 direction=normalize(vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
|
||
vec3 direction=normalize(vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_EQUIRECTANGULAR
|
||
return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SPHERICAL
|
||
return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_PLANAR
|
||
return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_CUBIC
|
||
#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
|
||
return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);
|
||
#else
|
||
return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
return computeProjectionCoords(worldPos,view,reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
return computeSkyBoxCoords(vPositionUVW,reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_EXPLICIT
|
||
return vec3(0,0,0);
|
||
#endif
|
||
}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},37755:(r,t,e)=>{e(98519).l.IncludesShadersStore.samplerFragmentDeclaration=`#ifdef _DEFINENAME_
|
||
#if _DEFINENAME_DIRECTUV==1
|
||
#define v_VARYINGNAME_UV vMainUV1
|
||
#elif _DEFINENAME_DIRECTUV==2
|
||
#define v_VARYINGNAME_UV vMainUV2
|
||
#elif _DEFINENAME_DIRECTUV==3
|
||
#define v_VARYINGNAME_UV vMainUV3
|
||
#elif _DEFINENAME_DIRECTUV==4
|
||
#define v_VARYINGNAME_UV vMainUV4
|
||
#elif _DEFINENAME_DIRECTUV==5
|
||
#define v_VARYINGNAME_UV vMainUV5
|
||
#elif _DEFINENAME_DIRECTUV==6
|
||
#define v_VARYINGNAME_UV vMainUV6
|
||
#else
|
||
varying vec2 v_VARYINGNAME_UV;
|
||
#endif
|
||
uniform sampler2D _SAMPLERNAME_Sampler;
|
||
#endif
|
||
`},60581:(r,t,e)=>{e(98519).l.IncludesShadersStore.samplerVertexDeclaration=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
|
||
varying vec2 v_VARYINGNAME_UV;
|
||
#endif
|
||
`},81067:(r,t,e)=>{e(98519).l.IncludesShadersStore.samplerVertexImplementation=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
|
||
if (v_INFONAME_==0.)
|
||
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));}
|
||
#ifdef UV2
|
||
else if (v_INFONAME_==1.)
|
||
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));}
|
||
#endif
|
||
#ifdef UV3
|
||
else if (v_INFONAME_==2.)
|
||
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));}
|
||
#endif
|
||
#ifdef UV4
|
||
else if (v_INFONAME_==3.)
|
||
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));}
|
||
#endif
|
||
#ifdef UV5
|
||
else if (v_INFONAME_==4.)
|
||
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));}
|
||
#endif
|
||
#ifdef UV6
|
||
else if (v_INFONAME_==5.)
|
||
{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));}
|
||
#endif
|
||
#endif
|
||
`},50851:(r,t,e)=>{e(98519).l.IncludesShadersStore.sceneUboDeclaration=`layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;
|
||
#ifdef MULTIVIEW
|
||
mat4 viewProjectionR;
|
||
#endif
|
||
mat4 view;mat4 projection;vec4 vEyePosition;};
|
||
`},93664:(r,t,e)=>{e(98519).l.IncludesShadersStore.screenSpaceRayTrace=`float distanceSquared(vec2 a,vec2 b) { a-=b; return dot(a,a); }
|
||
/**
|
||
param csOrigin Camera-space ray origin,which must be
|
||
within the view volume and must have z>0.01 and project within the valid screen rectangle
|
||
param csDirection Unit length camera-space ray direction
|
||
param projectToPixelMatrix A projection matrix that maps to **pixel** coordinates
|
||
(**not** [-1,+1] normalized device coordinates).
|
||
param csZBuffer The camera-space Z buffer
|
||
param csZBufferSize Dimensions of csZBuffer
|
||
param csZThickness Camera space csZThickness to ascribe to each pixel in the depth buffer
|
||
param nearPlaneZ Positive number. Doesn't have to be THE actual near plane,just a reasonable value
|
||
for clipping rays headed towards the camera
|
||
param stride Step in horizontal or vertical pixels between samples. This is a float
|
||
because integer math is slow on GPUs,but should be set to an integer>=1
|
||
param jitterFraction Number between 0 and 1 for how far to bump the ray in stride units
|
||
to conceal banding artifacts,plus the stride ray offset.
|
||
param maxSteps Maximum number of iterations. Higher gives better images but may be slow
|
||
param maxRayTraceDistance Maximum camera-space distance to trace before returning a miss
|
||
param selfCollisionNumSkip Number of steps to skip at start when raytracing to avoid self collisions.
|
||
1 is a reasonable value,depending on the scene you may need to set this value to 2
|
||
param hitPixel Pixel coordinates of the first intersection with the scene
|
||
param numIterations number of iterations performed
|
||
param csHitPoint Camera space location of the ray hit
|
||
*/
|
||
#define inline
|
||
bool traceScreenSpaceRay1(
|
||
vec3 csOrigin,
|
||
vec3 csDirection,
|
||
mat4 projectToPixelMatrix,
|
||
sampler2D csZBuffer,
|
||
vec2 csZBufferSize,
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
sampler2D csZBackBuffer,
|
||
float csZBackSizeFactor,
|
||
#endif
|
||
float csZThickness,
|
||
float nearPlaneZ,
|
||
float stride,
|
||
float jitterFraction,
|
||
float maxSteps,
|
||
float maxRayTraceDistance,
|
||
float selfCollisionNumSkip,
|
||
out vec2 startPixel,
|
||
out vec2 hitPixel,
|
||
out vec3 csHitPoint,
|
||
out float numIterations
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
,out vec3 debugColor
|
||
#endif
|
||
)
|
||
{
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
float rayLength=(csOrigin.z+csDirection.z*maxRayTraceDistance)>-nearPlaneZ ? (-nearPlaneZ-csOrigin.z)/csDirection.z : maxRayTraceDistance;
|
||
#else
|
||
float rayLength=(csOrigin.z+csDirection.z*maxRayTraceDistance)<nearPlaneZ ? (nearPlaneZ-csOrigin.z)/csDirection.z : maxRayTraceDistance;
|
||
#endif
|
||
vec3 csEndPoint=csOrigin+csDirection*rayLength;hitPixel=vec2(-1.0,-1.0);vec4 H0=projectToPixelMatrix*vec4(csOrigin,1.0);vec4 H1=projectToPixelMatrix*vec4(csEndPoint,1.0);float k0=1.0/H0.w;float k1=1.0/H1.w;vec3 Q0=csOrigin*k0;vec3 Q1=csEndPoint*k1;vec2 P0=H0.xy*k0;vec2 P1=H1.xy*k1;
|
||
#ifdef SSRAYTRACE_CLIP_TO_FRUSTUM
|
||
float xMax=csZBufferSize.x-0.5,xMin=0.5,yMax=csZBufferSize.y-0.5,yMin=0.5;float alpha=0.0;if ((P1.y>yMax) || (P1.y<yMin)) {alpha=(P1.y-((P1.y>yMax) ? yMax : yMin))/(P1.y-P0.y);}
|
||
if ((P1.x>xMax) || (P1.x<xMin)) {alpha=max(alpha,(P1.x-((P1.x>xMax) ? xMax : xMin))/(P1.x-P0.x));}
|
||
P1=mix(P1,P0,alpha); k1=mix(k1,k0,alpha); Q1=mix(Q1,Q0,alpha);
|
||
#endif
|
||
P1+=vec2((distanceSquared(P0,P1)<0.0001) ? 0.01 : 0.0);vec2 delta=P1-P0;bool permute=false;if (abs(delta.x)<abs(delta.y)) {
|
||
permute=true;delta=delta.yx;P0=P0.yx;P1=P1.yx; }
|
||
float stepDirection=sign(delta.x);float invdx=stepDirection/delta.x;vec2 dP=vec2(stepDirection,delta.y*invdx);vec3 dQ=(Q1-Q0)*invdx;float dk=(k1-k0)*invdx;float zMin=min(csEndPoint.z,csOrigin.z);float zMax=max(csEndPoint.z,csOrigin.z);dP*=stride; dQ*=stride; dk*=stride;P0+=dP*jitterFraction; Q0+=dQ*jitterFraction; k0+=dk*jitterFraction;vec4 pqk=vec4(P0,Q0.z,k0);vec4 dPQK=vec4(dP,dQ.z,dk);startPixel=permute ? P0.yx : P0.xy;float prevZMaxEstimate=csOrigin.z;float rayZMin=prevZMaxEstimate,rayZMax=prevZMaxEstimate;float sceneZMax=rayZMax+1e4;float end=P1.x*stepDirection;bool hit=false;float stepCount;for (stepCount=0.0;stepCount<=selfCollisionNumSkip ||
|
||
(pqk.x*stepDirection)<=end &&
|
||
stepCount<maxSteps &&
|
||
!hit &&
|
||
sceneZMax != 0.0;
|
||
pqk+=dPQK,++stepCount)
|
||
{hitPixel=permute ? pqk.yx : pqk.xy;rayZMin=prevZMaxEstimate;rayZMax=(dPQK.z*0.5+pqk.z)/(dPQK.w*0.5+pqk.w);rayZMax=clamp(rayZMax,zMin,zMax);prevZMaxEstimate=rayZMax;if (rayZMin>rayZMax) {
|
||
float t=rayZMin; rayZMin=rayZMax; rayZMax=t;}
|
||
sceneZMax=texelFetch(csZBuffer,ivec2(hitPixel),0).r;
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
float sceneBackZ=texelFetch(csZBackBuffer,ivec2(hitPixel/csZBackSizeFactor),0).r;hit=(rayZMax>=sceneBackZ-csZThickness) && (rayZMin<=sceneZMax);
|
||
#else
|
||
hit=(rayZMax>=sceneZMax-csZThickness) && (rayZMin<=sceneZMax);
|
||
#endif
|
||
#else
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
float sceneBackZ=texelFetch(csZBackBuffer,ivec2(hitPixel/csZBackSizeFactor),0).r;hit=(rayZMin<=sceneBackZ+csZThickness) && (rayZMax>=sceneZMax) && (sceneZMax != 0.0);
|
||
#else
|
||
hit=(rayZMin<=sceneZMax+csZThickness) && (rayZMax>=sceneZMax);
|
||
#endif
|
||
#endif
|
||
}
|
||
pqk-=dPQK;stepCount-=1.0;if (((pqk.x+dPQK.x)*stepDirection)>end || (stepCount+1.0)>=maxSteps || sceneZMax==0.0) {hit=false;}
|
||
#ifdef SSRAYTRACE_ENABLE_REFINEMENT
|
||
if (stride>1.0 && hit) {pqk-=dPQK;stepCount-=1.0;float invStride=1.0/stride;dPQK*=invStride;float refinementStepCount=0.0;prevZMaxEstimate=pqk.z/pqk.w;rayZMax=prevZMaxEstimate;sceneZMax=rayZMax+1e7;for (;refinementStepCount<=1.0 ||
|
||
(refinementStepCount<=stride*1.4) &&
|
||
(rayZMax<sceneZMax) && (sceneZMax != 0.0);pqk+=dPQK,refinementStepCount+=1.0)
|
||
{rayZMin=prevZMaxEstimate;rayZMax=(dPQK.z*0.5+pqk.z)/(dPQK.w*0.5+pqk.w);rayZMax=clamp(rayZMax,zMin,zMax);prevZMaxEstimate=rayZMax;rayZMax=max(rayZMax,rayZMin);hitPixel=permute ? pqk.yx : pqk.xy;sceneZMax=texelFetch(csZBuffer,ivec2(hitPixel),0).r;}
|
||
pqk-=dPQK;refinementStepCount-=1.0;stepCount+=refinementStepCount/stride;}
|
||
#endif
|
||
Q0.xy+=dQ.xy*stepCount;Q0.z=pqk.z;csHitPoint=Q0/pqk.w;numIterations=stepCount+1.0;
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
if (((pqk.x+dPQK.x)*stepDirection)>end) {debugColor=vec3(0,0,1);} else if ((stepCount+1.0)>=maxSteps) {debugColor=vec3(1,0,0);} else if (sceneZMax==0.0) {debugColor=vec3(1,1,0);} else {debugColor=vec3(0,stepCount/maxSteps,0);}
|
||
#endif
|
||
return hit;}
|
||
/**
|
||
texCoord: in the [0,1] range
|
||
depth: depth in view space (range [znear,zfar]])
|
||
*/
|
||
vec3 computeViewPosFromUVDepth(vec2 texCoord,float depth,mat4 projection,mat4 invProjectionMatrix) {vec4 ndc;ndc.xy=texCoord*2.0-1.0;
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
#ifdef ORTHOGRAPHIC_CAMERA
|
||
ndc.z=-projection[2].z*depth+projection[3].z;
|
||
#else
|
||
ndc.z=-projection[2].z-projection[3].z/depth;
|
||
#endif
|
||
#else
|
||
#ifdef ORTHOGRAPHIC_CAMERA
|
||
ndc.z=projection[2].z*depth+projection[3].z;
|
||
#else
|
||
ndc.z=projection[2].z+projection[3].z/depth;
|
||
#endif
|
||
#endif
|
||
ndc.w=1.0;vec4 eyePos=invProjectionMatrix*ndc;eyePos.xyz/=eyePos.w;return eyePos.xyz;}
|
||
`},29313:(r,t,e)=>{e.r(t),e.d(t,{shadowMapFragment:()=>o});var n="shadowMapFragment",i=`float depthSM=vDepthMetricSM;
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
#if SM_USEDISTANCE==1
|
||
depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
|
||
#else
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
depthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
|
||
#else
|
||
depthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
gl_FragDepth=clamp(1.0-depthSM,0.0,1.0);
|
||
#else
|
||
gl_FragDepth=clamp(depthSM,0.0,1.0);
|
||
#endif
|
||
#elif SM_USEDISTANCE==1
|
||
depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
|
||
#endif
|
||
#if SM_ESM==1
|
||
depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);
|
||
#endif
|
||
#if SM_FLOAT==1
|
||
gl_FragColor=vec4(depthSM,1.0,1.0,1.0);
|
||
#else
|
||
gl_FragColor=pack(depthSM);
|
||
#endif
|
||
return;`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},61195:(r,t,e)=>{e.r(t),e.d(t,{shadowMapFragmentSoftTransparentShadow:()=>o});var n="shadowMapFragmentSoftTransparentShadow",i=`#if SM_SOFTTRANSPARENTSHADOW==1
|
||
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x*alpha) discard;
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},62371:(r,t,e)=>{e.r(t),e.d(t,{shadowMapVertexMetric:()=>o});var n="shadowMapVertexMetric",i=`#if SM_USEDISTANCE==1
|
||
vPositionWSM=worldPos.xyz;
|
||
#endif
|
||
#if SM_DEPTHTEXTURE==1
|
||
#ifdef IS_NDC_HALF_ZRANGE
|
||
#define BIASFACTOR 0.5
|
||
#else
|
||
#define BIASFACTOR 1.0
|
||
#endif
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
gl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
|
||
#else
|
||
gl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
|
||
#endif
|
||
#endif
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
zSM=gl_Position.z;gl_Position.z=0.0;
|
||
#elif SM_USEDISTANCE==0
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
|
||
#else
|
||
vDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},46837:(r,t,e)=>{e.r(t),e.d(t,{shadowsFragmentFunctions:()=>o});var n="shadowsFragmentFunctions",i=`#ifdef SHADOWS
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
|
||
#else
|
||
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
|
||
#endif
|
||
#ifndef SHADOWFLOAT
|
||
float unpack(vec4 color)
|
||
{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);}
|
||
#endif
|
||
float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
|
||
{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
|
||
#define inline
|
||
float computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
|
||
{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;
|
||
#ifndef SHADOWFLOAT
|
||
float shadow=unpack(textureCube(shadowSampler,directionToLight));
|
||
#else
|
||
float shadow=textureCube(shadowSampler,directionToLight).x;
|
||
#endif
|
||
return depth>shadow ? darkness : 1.0;}
|
||
#define inline
|
||
float computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
|
||
{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);
|
||
#ifndef SHADOWFLOAT
|
||
if (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;
|
||
#else
|
||
if (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;
|
||
#endif
|
||
return min(1.0,visibility+darkness);}
|
||
#define inline
|
||
float computeShadowWithESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
|
||
{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;
|
||
#ifndef SHADOWFLOAT
|
||
float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
|
||
#else
|
||
float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
|
||
#endif
|
||
float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
|
||
#define inline
|
||
float computeShadowWithCloseESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
|
||
{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;
|
||
#ifndef SHADOWFLOAT
|
||
float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
|
||
#else
|
||
float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
|
||
#endif
|
||
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define inline
|
||
float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
|
||
{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);
|
||
#ifndef SHADOWFLOAT
|
||
float shadow=unpack(texture2D(shadowSampler,uvLayer));
|
||
#else
|
||
float shadow=texture2D(shadowSampler,uvLayer).x;
|
||
#endif
|
||
return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}
|
||
#endif
|
||
#define inline
|
||
float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
|
||
{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)
|
||
{return 1.0;}
|
||
else
|
||
{float shadowPixelDepth=clamp(depthMetric,0.,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
|
||
#else
|
||
float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;
|
||
#endif
|
||
return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}
|
||
#define inline
|
||
float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
|
||
{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)
|
||
{return 1.0;}
|
||
else
|
||
{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);
|
||
#ifndef SHADOWFLOAT
|
||
if (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;
|
||
#else
|
||
if (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;
|
||
#endif
|
||
return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
|
||
#define inline
|
||
float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
|
||
{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)
|
||
{return 1.0;}
|
||
else
|
||
{float shadowPixelDepth=clamp(depthMetric,0.,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
|
||
#else
|
||
float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
|
||
#endif
|
||
float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
|
||
#define inline
|
||
float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
|
||
{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)
|
||
{return 1.0;}
|
||
else
|
||
{float shadowPixelDepth=clamp(depthMetric,0.,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
|
||
#else
|
||
float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
|
||
#endif
|
||
float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
|
||
#ifdef IS_NDC_HALF_ZRANGE
|
||
#define ZINCLIP clipSpace.z
|
||
#else
|
||
#define ZINCLIP uvDepth.z
|
||
#endif
|
||
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define GREATEST_LESS_THAN_ONE 0.99999994
|
||
#define DISABLE_UNIFORMITY_ANALYSIS
|
||
#define inline
|
||
float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
|
||
#define inline
|
||
float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
vec2 st=fract(uv);
|
||
vec2 base_uv=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
vec2 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);}
|
||
#define inline
|
||
float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
vec2 st=fract(uv);
|
||
vec2 base_uv=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
vec2 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);}
|
||
#define inline
|
||
float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
|
||
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
|
||
else
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
|
||
#define inline
|
||
float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
||
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
|
||
else
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
vec2 st=fract(uv);
|
||
vec2 base_uv=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
vec2 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);}}
|
||
#define inline
|
||
float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
|
||
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
|
||
else
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
vec2 st=fract(uv);
|
||
vec2 base_uv=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
vec2 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);}}
|
||
const vec3 PoissonSamplers32[64]=vec3[64](
|
||
vec3(0.06407013,0.05409927,0.),
|
||
vec3(0.7366577,0.5789394,0.),
|
||
vec3(-0.6270542,-0.5320278,0.),
|
||
vec3(-0.4096107,0.8411095,0.),
|
||
vec3(0.6849564,-0.4990818,0.),
|
||
vec3(-0.874181,-0.04579735,0.),
|
||
vec3(0.9989998,0.0009880066,0.),
|
||
vec3(-0.004920578,-0.9151649,0.),
|
||
vec3(0.1805763,0.9747483,0.),
|
||
vec3(-0.2138451,0.2635818,0.),
|
||
vec3(0.109845,0.3884785,0.),
|
||
vec3(0.06876755,-0.3581074,0.),
|
||
vec3(0.374073,-0.7661266,0.),
|
||
vec3(0.3079132,-0.1216763,0.),
|
||
vec3(-0.3794335,-0.8271583,0.),
|
||
vec3(-0.203878,-0.07715034,0.),
|
||
vec3(0.5912697,0.1469799,0.),
|
||
vec3(-0.88069,0.3031784,0.),
|
||
vec3(0.5040108,0.8283722,0.),
|
||
vec3(-0.5844124,0.5494877,0.),
|
||
vec3(0.6017799,-0.1726654,0.),
|
||
vec3(-0.5554981,0.1559997,0.),
|
||
vec3(-0.3016369,-0.3900928,0.),
|
||
vec3(-0.5550632,-0.1723762,0.),
|
||
vec3(0.925029,0.2995041,0.),
|
||
vec3(-0.2473137,0.5538505,0.),
|
||
vec3(0.9183037,-0.2862392,0.),
|
||
vec3(0.2469421,0.6718712,0.),
|
||
vec3(0.3916397,-0.4328209,0.),
|
||
vec3(-0.03576927,-0.6220032,0.),
|
||
vec3(-0.04661255,0.7995201,0.),
|
||
vec3(0.4402924,0.3640312,0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.),
|
||
vec3(0.)
|
||
);const vec3 PoissonSamplers64[64]=vec3[64](
|
||
vec3(-0.613392,0.617481,0.),
|
||
vec3(0.170019,-0.040254,0.),
|
||
vec3(-0.299417,0.791925,0.),
|
||
vec3(0.645680,0.493210,0.),
|
||
vec3(-0.651784,0.717887,0.),
|
||
vec3(0.421003,0.027070,0.),
|
||
vec3(-0.817194,-0.271096,0.),
|
||
vec3(-0.705374,-0.668203,0.),
|
||
vec3(0.977050,-0.108615,0.),
|
||
vec3(0.063326,0.142369,0.),
|
||
vec3(0.203528,0.214331,0.),
|
||
vec3(-0.667531,0.326090,0.),
|
||
vec3(-0.098422,-0.295755,0.),
|
||
vec3(-0.885922,0.215369,0.),
|
||
vec3(0.566637,0.605213,0.),
|
||
vec3(0.039766,-0.396100,0.),
|
||
vec3(0.751946,0.453352,0.),
|
||
vec3(0.078707,-0.715323,0.),
|
||
vec3(-0.075838,-0.529344,0.),
|
||
vec3(0.724479,-0.580798,0.),
|
||
vec3(0.222999,-0.215125,0.),
|
||
vec3(-0.467574,-0.405438,0.),
|
||
vec3(-0.248268,-0.814753,0.),
|
||
vec3(0.354411,-0.887570,0.),
|
||
vec3(0.175817,0.382366,0.),
|
||
vec3(0.487472,-0.063082,0.),
|
||
vec3(-0.084078,0.898312,0.),
|
||
vec3(0.488876,-0.783441,0.),
|
||
vec3(0.470016,0.217933,0.),
|
||
vec3(-0.696890,-0.549791,0.),
|
||
vec3(-0.149693,0.605762,0.),
|
||
vec3(0.034211,0.979980,0.),
|
||
vec3(0.503098,-0.308878,0.),
|
||
vec3(-0.016205,-0.872921,0.),
|
||
vec3(0.385784,-0.393902,0.),
|
||
vec3(-0.146886,-0.859249,0.),
|
||
vec3(0.643361,0.164098,0.),
|
||
vec3(0.634388,-0.049471,0.),
|
||
vec3(-0.688894,0.007843,0.),
|
||
vec3(0.464034,-0.188818,0.),
|
||
vec3(-0.440840,0.137486,0.),
|
||
vec3(0.364483,0.511704,0.),
|
||
vec3(0.034028,0.325968,0.),
|
||
vec3(0.099094,-0.308023,0.),
|
||
vec3(0.693960,-0.366253,0.),
|
||
vec3(0.678884,-0.204688,0.),
|
||
vec3(0.001801,0.780328,0.),
|
||
vec3(0.145177,-0.898984,0.),
|
||
vec3(0.062655,-0.611866,0.),
|
||
vec3(0.315226,-0.604297,0.),
|
||
vec3(-0.780145,0.486251,0.),
|
||
vec3(-0.371868,0.882138,0.),
|
||
vec3(0.200476,0.494430,0.),
|
||
vec3(-0.494552,-0.711051,0.),
|
||
vec3(0.612476,0.705252,0.),
|
||
vec3(-0.578845,-0.768792,0.),
|
||
vec3(-0.772454,-0.090976,0.),
|
||
vec3(0.504440,0.372295,0.),
|
||
vec3(0.155736,0.065157,0.),
|
||
vec3(0.391522,0.849605,0.),
|
||
vec3(-0.620106,-0.328104,0.),
|
||
vec3(0.789239,-0.419965,0.),
|
||
vec3(-0.545396,0.538133,0.),
|
||
vec3(-0.178564,-0.596057,0.)
|
||
);
|
||
#define inline
|
||
float 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)
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
|
||
float 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);}
|
||
shadow/=float(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);if (numBlocker<1.0) {return 1.0;}
|
||
else
|
||
{return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
|
||
#define inline
|
||
float 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)
|
||
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
|
||
else
|
||
{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=TEXTUREFUNC(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0.).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
|
||
if (numBlocker<1.0) {return 1.0;}
|
||
else
|
||
{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.);}
|
||
shadow/=float(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}}
|
||
#define inline
|
||
float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
|
||
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
|
||
#define inline
|
||
float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
|
||
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
|
||
#define inline
|
||
float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
|
||
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
|
||
#define inline
|
||
float 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)
|
||
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
|
||
#define inline
|
||
float 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)
|
||
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
|
||
#define inline
|
||
float 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)
|
||
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},62136:(r,t,e)=>{e.r(t),e.d(t,{shadowsVertex:()=>o});var n="shadowsVertex",i=`#ifdef SHADOWS
|
||
#if defined(SHADOWCSM{X})
|
||
vPositionFromCamera{X}=view*worldPos;for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {vPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#else
|
||
vDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#endif
|
||
}
|
||
#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})
|
||
vPositionFromLight{X}=lightMatrix{X}*worldPos;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#else
|
||
vDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStore[n]=i;var o={name:n,shader:i}},5447:(r,t,e)=>{e(98519).l.IncludesShadersStore.subSurfaceScatteringFunctions=`bool testLightingForSSS(float diffusionProfile)
|
||
{return diffusionProfile<1.;}`},77976:(r,t,e)=>{e(98519).l.IncludesShadersStore.uvAttributeDeclaration=`#ifdef UV{X}
|
||
attribute vec2 uv{X};
|
||
#endif
|
||
`},45858:(r,t,e)=>{e(98519).l.IncludesShadersStore.uvVariableDeclaration=`#if !defined(UV{X}) && defined(MAINUV{X})
|
||
vec2 uv{X}=vec2(0.,0.);
|
||
#endif
|
||
#ifdef MAINUV{X}
|
||
vMainUV{X}=uv{X};
|
||
#endif
|
||
`},45812:(r,t,e)=>{e(98519).l.IncludesShadersStore.vertexColorMixing=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
vColor=vec4(1.0);
|
||
#ifdef VERTEXCOLOR
|
||
#ifdef VERTEXALPHA
|
||
vColor*=color;
|
||
#else
|
||
vColor.rgb*=color.rgb;
|
||
#endif
|
||
#endif
|
||
#ifdef INSTANCESCOLOR
|
||
vColor*=instanceColor;
|
||
#endif
|
||
#endif
|
||
`},10534:(r,t,e)=>{e.r(t),e.d(t,{anaglyphPixelShader:()=>o});var n="anaglyphPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D leftSampler;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec4 leftFrag=texture2D(leftSampler,vUV);leftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);vec4 rightFrag=texture2D(textureSampler,vUV);rightFrag=vec4(rightFrag.r,1.0,1.0,1.0);gl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},7590:(r,t,e)=>{e.r(t),e.d(t,{backgroundPixelShader:()=>a});var n=e(98519);n.l.IncludesShadersStore.backgroundFragmentDeclaration=`uniform vec4 vEyePosition;uniform vec4 vPrimaryColor;
|
||
#ifdef USEHIGHLIGHTANDSHADOWCOLORS
|
||
uniform vec4 vPrimaryColorShadow;
|
||
#endif
|
||
uniform float shadowLevel;uniform float alpha;
|
||
#ifdef DIFFUSE
|
||
uniform vec2 vDiffuseInfos;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
|
||
#endif
|
||
#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
|
||
uniform vec3 vBackgroundCenter;
|
||
#endif
|
||
#ifdef REFLECTIONFRESNEL
|
||
uniform vec4 vReflectionControl;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
|
||
uniform mat4 view;
|
||
#endif
|
||
#ifdef PROJECTED_GROUND
|
||
uniform vec2 projectedGroundInfos;
|
||
#endif
|
||
`,e(27947),e(75334),e(40150),e(59581),e(87283),e(32823),e(54409),e(46837),e(40688),e(59262),e(27003),e(52767),e(39643),e(7363),e(13088),e(86343);var i="backgroundPixelShader",o=`#ifdef TEXTURELODSUPPORT
|
||
#extension GL_EXT_shader_texture_lod : enable
|
||
#endif
|
||
precision highp float;
|
||
#include<__decl__backgroundFragment>
|
||
#include<helperFunctions>
|
||
varying vec3 vPositionW;
|
||
#ifdef MAINUV1
|
||
varying vec2 vMainUV1;
|
||
#endif
|
||
#ifdef MAINUV2
|
||
varying vec2 vMainUV2;
|
||
#endif
|
||
#ifdef NORMAL
|
||
varying vec3 vNormalW;
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
#if DIFFUSEDIRECTUV==1
|
||
#define vDiffuseUV vMainUV1
|
||
#elif DIFFUSEDIRECTUV==2
|
||
#define vDiffuseUV vMainUV2
|
||
#else
|
||
varying vec2 vDiffuseUV;
|
||
#endif
|
||
uniform sampler2D diffuseSampler;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef REFLECTIONMAP_3D
|
||
#define sampleReflection(s,c) textureCube(s,c)
|
||
uniform samplerCube reflectionSampler;
|
||
#ifdef TEXTURELODSUPPORT
|
||
#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
|
||
#else
|
||
uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
|
||
#endif
|
||
#else
|
||
#define sampleReflection(s,c) texture2D(s,c)
|
||
uniform sampler2D reflectionSampler;
|
||
#ifdef TEXTURELODSUPPORT
|
||
#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
|
||
#else
|
||
uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vec3 vPositionUVW;
|
||
#else
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vec3 vDirectionW;
|
||
#endif
|
||
#endif
|
||
#include<reflectionFunction>
|
||
#endif
|
||
#ifndef FROMLINEARSPACE
|
||
#define FROMLINEARSPACE;
|
||
#endif
|
||
#ifndef SHADOWONLY
|
||
#define SHADOWONLY;
|
||
#endif
|
||
#include<imageProcessingDeclaration>
|
||
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
||
#include<lightsFragmentFunctions>
|
||
#include<shadowsFragmentFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#ifdef REFLECTIONFRESNEL
|
||
#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
|
||
vec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
|
||
{float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
|
||
#endif
|
||
#ifdef PROJECTED_GROUND
|
||
float diskIntersectWithBackFaceCulling(vec3 ro,vec3 rd,vec3 c,float r) {float d=rd.y;if(d>0.0) { return 1e6; }
|
||
vec3 o=ro-c;float t=-o.y/d;vec3 q=o+rd*t;return (dot(q,q)<r*r) ? t : 1e6;}
|
||
float sphereIntersect(vec3 ro,vec3 rd,float ra) {float b=dot(ro,rd);float c=dot(ro,ro)-ra*ra;float h=b*b-c;if(h<0.0) { return -1.0; }
|
||
h=sqrt(h);return-b+h;}
|
||
vec3 project(vec3 viewDirectionW,vec3 eyePosition) {float radius=projectedGroundInfos.x;float height=projectedGroundInfos.y;vec3 camDir=-viewDirectionW;float skySphereDistance=sphereIntersect(eyePosition,camDir,radius);vec3 skySpherePositionW=eyePosition+camDir*skySphereDistance;vec3 p=normalize(skySpherePositionW);eyePosition.y-=height;float sIntersection=sphereIntersect(eyePosition,p,radius);vec3 h=vec3(0.0,-height,0.0);float dIntersection=diskIntersectWithBackFaceCulling(eyePosition,p,h,radius);p=(eyePosition+min(sIntersection,dIntersection)*p);return p;}
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
|
||
#ifdef NORMAL
|
||
vec3 normalW=normalize(vNormalW);
|
||
#else
|
||
vec3 normalW=vec3(0.0,1.0,0.0);
|
||
#endif
|
||
float shadow=1.;float globalShadow=0.;float shadowLightCount=0.;float aggShadow=0.;float numLights=0.;
|
||
#include<lightFragment>[0..maxSimultaneousLights]
|
||
#ifdef SHADOWINUSE
|
||
globalShadow/=shadowLightCount;
|
||
#else
|
||
globalShadow=1.0;
|
||
#endif
|
||
#ifndef BACKMAT_SHADOWONLY
|
||
vec4 reflectionColor=vec4(1.,1.,1.,1.);
|
||
#ifdef REFLECTION
|
||
#ifdef PROJECTED_GROUND
|
||
vec3 reflectionVector=project(viewDirectionW,vEyePosition.xyz);reflectionVector=vec3(reflectionMatrix*vec4(reflectionVector,1.));
|
||
#else
|
||
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
reflectionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
vec3 reflectionCoords=reflectionVector;
|
||
#else
|
||
vec2 reflectionCoords=reflectionVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
reflectionCoords/=reflectionVector.z;
|
||
#endif
|
||
reflectionCoords.y=1.0-reflectionCoords.y;
|
||
#endif
|
||
#ifdef REFLECTIONBLUR
|
||
float reflectionLOD=vReflectionInfos.y;
|
||
#ifdef TEXTURELODSUPPORT
|
||
reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
|
||
#else
|
||
float lodReflectionNormalized=saturate(reflectionLOD);float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);if(lodReflectionNormalizedDoubled<1.0){reflectionColor=mix(
|
||
sampleReflection(reflectionSamplerHigh,reflectionCoords),
|
||
reflectionSpecularMid,
|
||
lodReflectionNormalizedDoubled
|
||
);} else {reflectionColor=mix(
|
||
reflectionSpecularMid,
|
||
sampleReflection(reflectionSamplerLow,reflectionCoords),
|
||
lodReflectionNormalizedDoubled-1.0
|
||
);}
|
||
#endif
|
||
#else
|
||
vec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);reflectionColor=reflectionSample;
|
||
#endif
|
||
#ifdef RGBDREFLECTION
|
||
reflectionColor.rgb=fromRGBD(reflectionColor);
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
reflectionColor.rgb=toLinearSpace(reflectionColor.rgb);
|
||
#endif
|
||
#ifdef REFLECTIONBGR
|
||
reflectionColor.rgb=reflectionColor.bgr;
|
||
#endif
|
||
reflectionColor.rgb*=vReflectionInfos.x;
|
||
#endif
|
||
vec3 diffuseColor=vec3(1.,1.,1.);float finalAlpha=alpha;
|
||
#ifdef DIFFUSE
|
||
vec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);
|
||
#ifdef GAMMADIFFUSE
|
||
diffuseMap.rgb=toLinearSpace(diffuseMap.rgb);
|
||
#endif
|
||
diffuseMap.rgb*=vDiffuseInfos.y;
|
||
#ifdef DIFFUSEHASALPHA
|
||
finalAlpha*=diffuseMap.a;
|
||
#endif
|
||
diffuseColor=diffuseMap.rgb;
|
||
#endif
|
||
#ifdef REFLECTIONFRESNEL
|
||
vec3 colorBase=diffuseColor;
|
||
#else
|
||
vec3 colorBase=reflectionColor.rgb*diffuseColor;
|
||
#endif
|
||
colorBase=max(colorBase,0.0);
|
||
#ifdef USERGBCOLOR
|
||
vec3 finalColor=colorBase;
|
||
#else
|
||
#ifdef USEHIGHLIGHTANDSHADOWCOLORS
|
||
vec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);
|
||
#else
|
||
vec3 mainColor=vPrimaryColor.rgb;
|
||
#endif
|
||
vec3 finalColor=colorBase*mainColor;
|
||
#endif
|
||
#ifdef REFLECTIONFRESNEL
|
||
vec3 reflectionAmount=vReflectionControl.xxx;vec3 reflectionReflectance0=vReflectionControl.yyy;vec3 reflectionReflectance90=vReflectionControl.zzz;float VdotN=dot(normalize(vEyePosition.xyz),normalW);vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);reflectionAmount*=planarReflectionFresnel;
|
||
#ifdef REFLECTIONFALLOFF
|
||
float reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);reflectionDistanceFalloff*=reflectionDistanceFalloff;reflectionAmount*=reflectionDistanceFalloff;
|
||
#endif
|
||
finalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));
|
||
#endif
|
||
#ifdef OPACITYFRESNEL
|
||
float viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));const float startAngle=0.1;float fadeFactor=saturate(viewAngleToFloor/startAngle);finalAlpha*=fadeFactor*fadeFactor;
|
||
#endif
|
||
#ifdef SHADOWINUSE
|
||
finalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);
|
||
#endif
|
||
vec4 color=vec4(finalColor,finalAlpha);
|
||
#else
|
||
vec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);
|
||
#endif
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>
|
||
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
#if !defined(SKIPFINALCOLORCLAMP)
|
||
color.rgb=clamp(color.rgb,0.,30.0);
|
||
#endif
|
||
#else
|
||
color=applyImageProcessing(color);
|
||
#endif
|
||
#ifdef PREMULTIPLYALPHA
|
||
color.rgb*=color.a;
|
||
#endif
|
||
#ifdef NOISE
|
||
color.rgb+=dither(vPositionW.xy,0.5);color=max(color,0.0);
|
||
#endif
|
||
gl_FragColor=color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},57826:(r,t,e)=>{e.r(t),e.d(t,{backgroundVertexShader:()=>a});var n=e(98519);n.l.IncludesShadersStore.backgroundVertexDeclaration=`uniform mat4 view;uniform mat4 viewProjection;uniform float shadowLevel;
|
||
#ifdef DIFFUSE
|
||
uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;uniform float fFovMultiplier;
|
||
#endif
|
||
#ifdef POINTSIZE
|
||
uniform float pointSize;
|
||
#endif
|
||
`,e(27947),e(75334),e(36470),e(64400),e(38615),e(85637),e(72153),e(94785),e(48961),e(59262),e(35397),e(76898),e(49334),e(83057),e(62589),e(62136),e(56458);var i="backgroundVertexShader",o=`precision highp float;
|
||
#include<__decl__backgroundVertex>
|
||
#include<helperFunctions>
|
||
attribute vec3 position;
|
||
#ifdef NORMAL
|
||
attribute vec3 normal;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<instancesDeclaration>
|
||
varying vec3 vPositionW;
|
||
#ifdef NORMAL
|
||
varying vec3 vNormalW;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute vec2 uv2;
|
||
#endif
|
||
#ifdef MAINUV1
|
||
varying vec2 vMainUV1;
|
||
#endif
|
||
#ifdef MAINUV2
|
||
varying vec2 vMainUV2;
|
||
#endif
|
||
#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0
|
||
varying vec2 vDiffuseUV;
|
||
#endif
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vec3 vPositionUVW;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vec3 vDirectionW;
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
vPositionUVW=position;
|
||
#endif
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*finalWorld*vec4(position,1.0);} else {gl_Position=viewProjectionR*finalWorld*vec4(position,1.0);}
|
||
#else
|
||
gl_Position=viewProjection*finalWorld*vec4(position,1.0);
|
||
#endif
|
||
vec4 worldPos=finalWorld*vec4(position,1.0);vPositionW=vec3(worldPos);
|
||
#ifdef NORMAL
|
||
mat3 normalWorld=mat3(finalWorld);
|
||
#ifdef NONUNIFORMSCALING
|
||
normalWorld=transposeMat3(inverseMat3(normalWorld));
|
||
#endif
|
||
vNormalW=normalize(normalWorld*normal);
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
vDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));
|
||
#ifdef EQUIRECTANGULAR_RELFECTION_FOV
|
||
mat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));if (fFovMultiplier<=1.0) {vDirectionW=normalize(segment);} else {vDirectionW=normalize(vDirectionW+(vDirectionW-segment));}
|
||
#endif
|
||
#endif
|
||
#ifndef UV1
|
||
vec2 uv=vec2(0.,0.);
|
||
#endif
|
||
#ifndef UV2
|
||
vec2 uv2=vec2(0.,0.);
|
||
#endif
|
||
#ifdef MAINUV1
|
||
vMainUV1=uv;
|
||
#endif
|
||
#ifdef MAINUV2
|
||
vMainUV2=uv2;
|
||
#endif
|
||
#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0
|
||
if (vDiffuseInfos.x==0.)
|
||
{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}
|
||
else
|
||
{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<shadowsVertex>[0..maxSimultaneousLights]
|
||
#ifdef VERTEXCOLOR
|
||
vColor=color;
|
||
#endif
|
||
#if defined(POINTSIZE) && !defined(WEBGPU)
|
||
gl_PointSize=pointSize;
|
||
#endif
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},87851:(r,t,e)=>{e.r(t),e.d(t,{bilateralBlurPixelShader:()=>o});var n="bilateralBlurPixelShader",i=`uniform sampler2D textureSampler;uniform sampler2D depthSampler;uniform sampler2D normalSampler;uniform int filterSize;uniform vec2 blurDir;uniform float depthThreshold;uniform float normalThreshold;varying vec2 vUV;void main(void) {vec3 color=textureLod(textureSampler,vUV,0.).rgb;float depth=textureLod(depthSampler,vUV,0.).x;if (depth>=1e6 || depth<=0.) {glFragColor=vec4(color,1.);return;}
|
||
vec3 normal=textureLod(normalSampler,vUV,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
normal=normal*2.0-1.0;
|
||
#endif
|
||
float sigma=float(filterSize);float two_sigma2=2.0*sigma*sigma;float sigmaDepth=depthThreshold;float two_sigmaDepth2=2.0*sigmaDepth*sigmaDepth;float sigmaNormal=normalThreshold;float two_sigmaNormal2=2.0*sigmaNormal*sigmaNormal;vec3 sum=vec3(0.);float wsum=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec3 sampleColor=textureLod(textureSampler,vUV+coords*blurDir,0.).rgb;float sampleDepth=textureLod(depthSampler,vUV+coords*blurDir,0.).r;vec3 sampleNormal=textureLod(normalSampler,vUV+coords*blurDir,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
sampleNormal=sampleNormal*2.0-1.0;
|
||
#endif
|
||
float r=dot(coords,coords);float w=exp(-r/two_sigma2);float depthDelta=abs(sampleDepth-depth);float wd=step(depthDelta,depthThreshold);vec3 normalDelta=abs(sampleNormal-normal);float wn=step(normalDelta.x+normalDelta.y+normalDelta.z,normalThreshold);sum+=sampleColor*w*wd*wn;wsum+=w*wd*wn;}
|
||
glFragColor=vec4(sum/wsum,1.);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},12132:(r,t,e)=>{e.r(t),e.d(t,{bilateralBlurQualityPixelShader:()=>o});var n="bilateralBlurQualityPixelShader",i=`uniform sampler2D textureSampler;uniform sampler2D depthSampler;uniform sampler2D normalSampler;uniform int filterSize;uniform vec2 blurDir;uniform float depthThreshold;uniform float normalThreshold;varying vec2 vUV;void main(void) {vec3 color=textureLod(textureSampler,vUV,0.).rgb;float depth=textureLod(depthSampler,vUV,0.).x;if (depth>=1e6 || depth<=0.) {glFragColor=vec4(color,1.);return;}
|
||
vec3 normal=textureLod(normalSampler,vUV,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
normal=normal*2.0-1.0;
|
||
#endif
|
||
float sigma=float(filterSize);float two_sigma2=2.0*sigma*sigma;float sigmaDepth=depthThreshold;float two_sigmaDepth2=2.0*sigmaDepth*sigmaDepth;float sigmaNormal=normalThreshold;float two_sigmaNormal2=2.0*sigmaNormal*sigmaNormal;vec3 sum=vec3(0.);float wsum=0.;for (int x=-filterSize; x<=filterSize; ++x) {for (int y=-filterSize; y<=filterSize; ++y) {vec2 coords=vec2(x,y)*blurDir;vec3 sampleColor=textureLod(textureSampler,vUV+coords,0.).rgb;float sampleDepth=textureLod(depthSampler,vUV+coords,0.).r;vec3 sampleNormal=textureLod(normalSampler,vUV+coords,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
sampleNormal=sampleNormal*2.0-1.0;
|
||
#endif
|
||
float r=dot(coords,coords);float w=exp(-r/two_sigma2);float rDepth=sampleDepth-depth;float wd=exp(-rDepth*rDepth/two_sigmaDepth2);float rNormal=abs(sampleNormal.x-normal.x)+abs(sampleNormal.y-normal.y)+abs(sampleNormal.z-normal.z);float wn=exp(-rNormal*rNormal/two_sigmaNormal2);sum+=sampleColor*w*wd*wn;wsum+=w*wd*wn;}}
|
||
glFragColor=vec4(sum/wsum,1.);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},5439:(r,t,e)=>{e.r(t),e.d(t,{blackAndWhitePixelShader:()=>o});var n="blackAndWhitePixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform float degree;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec3 color=texture2D(textureSampler,vUV).rgb;float luminance=dot(color,vec3(0.3,0.59,0.11));
|
||
vec3 blackAndWhite=vec3(luminance,luminance,luminance);gl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},25781:(r,t,e)=>{e.r(t),e.d(t,{bloomMergePixelShader:()=>o});var n="bloomMergePixelShader",i=`uniform sampler2D textureSampler;uniform sampler2D bloomBlur;varying vec2 vUV;uniform float bloomWeight;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=texture2D(textureSampler,vUV);vec3 blurred=texture2D(bloomBlur,vUV).rgb;gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); }
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},72627:(r,t,e)=>{e.r(t),e.d(t,{boundingBoxRendererPixelShader:()=>a});var n=e(98519);n.l.IncludesShadersStore.boundingBoxRendererFragmentDeclaration=`uniform vec4 color;
|
||
`,e(90253);var i="boundingBoxRendererPixelShader",o=`#include<__decl__boundingBoxRendererFragment>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
gl_FragColor=color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},67569:(r,t,e)=>{e.r(t),e.d(t,{boundingBoxRendererVertexShader:()=>a});var n=e(98519);n.l.IncludesShadersStore.boundingBoxRendererVertexDeclaration=`uniform mat4 world;uniform mat4 viewProjection;
|
||
#ifdef MULTIVIEW
|
||
uniform mat4 viewProjectionR;
|
||
#endif
|
||
`,e(90253);var i="boundingBoxRendererVertexShader",o=`attribute vec3 position;
|
||
#include<__decl__boundingBoxRendererVertex>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vec4 worldPos=world*vec4(position,1.0);
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
|
||
#else
|
||
gl_Position=viewProjection*worldPos;
|
||
#endif
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},95579:(r,t,e)=>{e.r(t),e.d(t,{chromaticAberrationPixelShader:()=>o});var n="chromaticAberrationPixelShader",i=`uniform sampler2D textureSampler;
|
||
uniform float chromatic_aberration;uniform float radialIntensity;uniform vec2 direction;uniform vec2 centerPosition;uniform float screen_width;uniform float screen_height;varying vec2 vUV;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);vec2 directionOfEffect=direction;if(directionOfEffect.x==0. && directionOfEffect.y==0.){directionOfEffect=normalize(centered_screen_pos);}
|
||
float radius2=centered_screen_pos.x*centered_screen_pos.x
|
||
+ centered_screen_pos.y*centered_screen_pos.y;float radius=sqrt(radius2);vec3 ref_indices=vec3(-0.3,0.0,0.3);float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);vec4 r=texture2D(textureSampler,ref_coords_r);vec4 g=texture2D(textureSampler,ref_coords_g);vec4 b=texture2D(textureSampler,ref_coords_b);float a=clamp(r.a+g.a+b.a,0.,1.);gl_FragColor=vec4(r.r,g.g,b.b,a);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},26345:(r,t,e)=>{e.r(t),e.d(t,{circleOfConfusionPixelShader:()=>o});var n="circleOfConfusionPixelShader",i=`uniform sampler2D depthSampler;varying vec2 vUV;uniform vec2 cameraMinMaxZ;uniform float focusDistance;uniform float cocPrecalculation;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{float depth=texture2D(depthSampler,vUV).r;
|
||
#define CUSTOM_COC_DEPTH
|
||
float pixelDistance=(cameraMinMaxZ.x+cameraMinMaxZ.y*depth)*1000.0;
|
||
#define CUSTOM_COC_PIXELDISTANCE
|
||
float coc=abs(cocPrecalculation*((focusDistance-pixelDistance)/pixelDistance));coc=clamp(coc,0.0,1.0);gl_FragColor=vec4(coc,coc,coc,1.0);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},38589:(r,t,e)=>{e.r(t),e.d(t,{colorPixelShader:()=>a});var n=e(98519),i=(e(27003),e(52767),e(39643),e(86343),"colorPixelShader"),o=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
#define VERTEXCOLOR
|
||
varying vec4 vColor;
|
||
#else
|
||
uniform vec4 color;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
gl_FragColor=vColor;
|
||
#else
|
||
gl_FragColor=color;
|
||
#endif
|
||
#include<fogFragment>(color,gl_FragColor)
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},32755:(r,t,e)=>{e.r(t),e.d(t,{colorVertexShader:()=>a});var n=e(98519),i=(e(36470),e(64400),e(85637),e(72153),e(38615),e(35397),e(76898),e(49334),e(83057),e(62589),e(45812),"colorVertexShader"),o=`attribute vec3 position;
|
||
#ifdef VERTEXCOLOR
|
||
attribute vec4 color;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#ifdef FOG
|
||
uniform mat4 view;
|
||
#endif
|
||
#include<instancesDeclaration>
|
||
uniform mat4 viewProjection;
|
||
#ifdef MULTIVIEW
|
||
uniform mat4 viewProjectionR;
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vec4 vColor;
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(position,1.0);
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
|
||
#else
|
||
gl_Position=viewProjection*worldPos;
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<vertexColorMixing>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},88977:(r,t,e)=>{e.r(t),e.d(t,{colorCorrectionPixelShader:()=>o});var n="colorCorrectionPixelShader",i=`uniform sampler2D textureSampler;
|
||
uniform sampler2D colorTable;
|
||
varying vec2 vUV;const float SLICE_COUNT=16.0;
|
||
vec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {float sliceSize=1.0/width;
|
||
float slicePixelSize=sliceSize/width;
|
||
float sliceInnerSize=slicePixelSize*(width-1.0);
|
||
float zSlice0=min(floor(uv.z*width),width-1.0);float zSlice1=min(zSlice0+1.0,width-1.0);float xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;float s0=xOffset+(zSlice0*sliceSize);float s1=xOffset+(zSlice1*sliceSize);vec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));vec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));float zOffset=mod(uv.z*width,1.0);vec4 result=mix(slice0Color,slice1Color,zOffset);return result;}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec4 screen_color=texture2D(textureSampler,vUV);gl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},9406:(r,t,e)=>{e.r(t),e.d(t,{convolutionPixelShader:()=>o});var n="convolutionPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform float kernel[9];
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 colorSum =
|
||
texture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];float kernelWeight =
|
||
kernel[0] +
|
||
kernel[1] +
|
||
kernel[2] +
|
||
kernel[3] +
|
||
kernel[4] +
|
||
kernel[5] +
|
||
kernel[6] +
|
||
kernel[7] +
|
||
kernel[8];if (kernelWeight<=0.0) {kernelWeight=1.0;}
|
||
gl_FragColor=vec4((colorSum/kernelWeight).rgb,1);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},37592:(r,t,e)=>{e.r(t),e.d(t,{copyTexture3DLayerToTexturePixelShader:()=>o});var n="copyTexture3DLayerToTexturePixelShader",i=`precision highp sampler3D;uniform sampler3D textureSampler;uniform int layerNum;varying vec2 vUV;void main(void) {vec3 coord=vec3(0.0,0.0,float(layerNum));coord.xy=vec2(vUV.x,vUV.y)*vec2(textureSize(textureSampler,0).xy);vec3 color=texelFetch(textureSampler,ivec3(coord),0).rgb;gl_FragColor=vec4(color,1);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},18778:(r,t,e)=>{e.r(t),e.d(t,{copyTextureToTexturePixelShader:()=>a});var n=e(98519),i=(e(75334),"copyTextureToTexturePixelShader"),o=`uniform float conversion;uniform sampler2D textureSampler;varying vec2 vUV;
|
||
#include<helperFunctions>
|
||
void main(void)
|
||
{vec4 color=texture2D(textureSampler,vUV);
|
||
#ifdef DEPTH_TEXTURE
|
||
gl_FragDepth=color.r;
|
||
#else
|
||
if (conversion==1.) {color=toLinearSpace(color);} else if (conversion==2.) {color=toGammaSpace(color);}
|
||
gl_FragColor=color;
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},23667:(r,t,e)=>{e.r(t),e.d(t,{defaultPixelShader:()=>s});var n=e(98519),i=(e(77740),"defaultFragmentDeclaration");n.l.IncludesShadersStore[i]=`uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;
|
||
#ifdef SPECULARTERM
|
||
uniform vec4 vSpecularColor;
|
||
#endif
|
||
uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility;
|
||
#ifdef DIFFUSE
|
||
uniform vec2 vDiffuseInfos;
|
||
#endif
|
||
#ifdef AMBIENT
|
||
uniform vec2 vAmbientInfos;
|
||
#endif
|
||
#ifdef OPACITY
|
||
uniform vec2 vOpacityInfos;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
uniform vec2 vEmissiveInfos;
|
||
#endif
|
||
#ifdef LIGHTMAP
|
||
uniform vec2 vLightmapInfos;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
|
||
#endif
|
||
#ifdef ALPHATEST
|
||
uniform float alphaCutOff;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)
|
||
uniform mat4 view;
|
||
#endif
|
||
#ifdef REFRACTION
|
||
uniform vec4 vRefractionInfos;
|
||
#ifndef REFRACTIONMAP_3D
|
||
uniform mat4 refractionMatrix;
|
||
#endif
|
||
#ifdef REFRACTIONFRESNEL
|
||
uniform vec4 refractionLeftColor;uniform vec4 refractionRightColor;
|
||
#endif
|
||
#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)
|
||
uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize;
|
||
#endif
|
||
#endif
|
||
#if defined(SPECULAR) && defined(SPECULARTERM)
|
||
uniform vec2 vSpecularInfos;
|
||
#endif
|
||
#ifdef DIFFUSEFRESNEL
|
||
uniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor;
|
||
#endif
|
||
#ifdef OPACITYFRESNEL
|
||
uniform vec4 opacityParts;
|
||
#endif
|
||
#ifdef EMISSIVEFRESNEL
|
||
uniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
uniform vec2 vReflectionInfos;
|
||
#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
|
||
uniform mat4 reflectionMatrix;
|
||
#endif
|
||
#ifndef REFLECTIONMAP_SKYBOX
|
||
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
|
||
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONFRESNEL
|
||
uniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor;
|
||
#endif
|
||
#endif
|
||
#ifdef DETAIL
|
||
uniform vec4 vDetailInfos;
|
||
#endif
|
||
#include<decalFragmentDeclaration>
|
||
#define ADDITIONAL_FRAGMENT_DECLARATION
|
||
`,e(51578),e(42107),e(81751),e(48493),e(75334),e(87283),e(32823),e(54409),e(46837),e(37755),e(18644),e(40150),e(59581),e(40688),e(48661),e(75394),e(27003),e(59262),e(52767),e(39643),e(56159),e(93130),e(15656),e(7363),e(13088),e(86343),e(11135);var o="defaultPixelShader",a=`#include<__decl__defaultFragment>
|
||
#if defined(BUMP) || !defined(NORMAL)
|
||
#extension GL_OES_standard_derivatives : enable
|
||
#endif
|
||
#include<prePassDeclaration>[SCENE_MRT_COUNT]
|
||
#include<oitDeclaration>
|
||
#define CUSTOM_FRAGMENT_BEGIN
|
||
#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
varying vec3 vPositionW;
|
||
#ifdef NORMAL
|
||
varying vec3 vNormalW;
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vec4 vColor;
|
||
#endif
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#include<helperFunctions>
|
||
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
||
#include<lightsFragmentFunctions>
|
||
#include<shadowsFragmentFunctions>
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
||
#ifdef REFRACTION
|
||
#ifdef REFRACTIONMAP_3D
|
||
uniform samplerCube refractionCubeSampler;
|
||
#else
|
||
uniform sampler2D refraction2DSampler;
|
||
#endif
|
||
#endif
|
||
#if defined(SPECULARTERM)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
|
||
#endif
|
||
#include<fresnelFunction>
|
||
#ifdef REFLECTION
|
||
#ifdef REFLECTIONMAP_3D
|
||
uniform samplerCube reflectionCubeSampler;
|
||
#else
|
||
uniform sampler2D reflection2DSampler;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vec3 vPositionUVW;
|
||
#else
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vec3 vDirectionW;
|
||
#endif
|
||
#endif
|
||
#include<reflectionFunction>
|
||
#endif
|
||
#include<imageProcessingDeclaration>
|
||
#include<imageProcessingFunctions>
|
||
#include<bumpFragmentMainFunctions>
|
||
#include<bumpFragmentFunctions>
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;
|
||
#ifdef NORMAL
|
||
vec3 normalW=normalize(vNormalW);
|
||
#else
|
||
vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
|
||
#endif
|
||
#include<bumpFragment>
|
||
#ifdef TWOSIDEDLIGHTING
|
||
normalW=gl_FrontFacing ? normalW : -normalW;
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);
|
||
#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
|
||
if (baseColor.a<alphaCutOff)
|
||
discard;
|
||
#endif
|
||
#ifdef ALPHAFROMDIFFUSE
|
||
alpha*=baseColor.a;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
|
||
baseColor.rgb*=vDiffuseInfos.y;
|
||
#endif
|
||
#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)
|
||
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
|
||
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
|
||
#endif
|
||
#include<depthPrePass>
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
baseColor.rgb*=vColor.rgb;
|
||
#endif
|
||
#ifdef DETAIL
|
||
baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
|
||
#endif
|
||
#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)
|
||
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
|
||
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
|
||
vec3 baseAmbientColor=vec3(1.,1.,1.);
|
||
#ifdef AMBIENT
|
||
baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
||
#ifdef SPECULARTERM
|
||
float glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;
|
||
#ifdef SPECULAR
|
||
vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;
|
||
#ifdef GLOSSINESS
|
||
glossiness=glossiness*specularMapColor.a;
|
||
#endif
|
||
#endif
|
||
#else
|
||
float glossiness=0.;
|
||
#endif
|
||
vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;
|
||
#ifdef SPECULARTERM
|
||
vec3 specularBase=vec3(0.,0.,0.);
|
||
#endif
|
||
float shadow=1.;float aggShadow=0.;float numLights=0.;
|
||
#ifdef LIGHTMAP
|
||
vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
|
||
#ifdef RGBDLIGHTMAP
|
||
lightmapColor.rgb=fromRGBD(lightmapColor);
|
||
#endif
|
||
lightmapColor.rgb*=vLightmapInfos.y;
|
||
#endif
|
||
#include<lightFragment>[0..maxSimultaneousLights]
|
||
aggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.);
|
||
#ifdef REFRACTION
|
||
vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
|
||
#ifdef REFRACTIONMAP_3D
|
||
#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);
|
||
#endif
|
||
refractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}
|
||
#else
|
||
vec3 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);
|
||
#endif
|
||
#ifdef RGBDREFRACTION
|
||
refractionColor.rgb=fromRGBD(refractionColor);
|
||
#endif
|
||
#ifdef IS_REFRACTION_LINEAR
|
||
refractionColor.rgb=toGammaSpace(refractionColor.rgb);
|
||
#endif
|
||
refractionColor.rgb*=vRefractionInfos.x;
|
||
#endif
|
||
vec4 reflectionColor=vec4(0.,0.,0.,1.);
|
||
#ifdef REFLECTION
|
||
vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
vReflectionUVW.z*=-1.0;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
#ifdef ROUGHNESS
|
||
float bias=vReflectionInfos.y;
|
||
#ifdef SPECULARTERM
|
||
#ifdef SPECULAR
|
||
#ifdef GLOSSINESS
|
||
bias*=(1.0-specularMapColor.a);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
|
||
#else
|
||
reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
|
||
#endif
|
||
#else
|
||
vec2 coords=vReflectionUVW.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
coords/=vReflectionUVW.z;
|
||
#endif
|
||
coords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords);
|
||
#endif
|
||
#ifdef RGBDREFLECTION
|
||
reflectionColor.rgb=fromRGBD(reflectionColor);
|
||
#endif
|
||
#ifdef IS_REFLECTION_LINEAR
|
||
reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
|
||
#endif
|
||
reflectionColor.rgb*=vReflectionInfos.x;
|
||
#ifdef REFLECTIONFRESNEL
|
||
float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
|
||
#ifdef REFLECTIONFRESNELFROMSPECULAR
|
||
#ifdef SPECULARTERM
|
||
reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
|
||
#else
|
||
reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
|
||
#endif
|
||
#else
|
||
reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef REFRACTIONFRESNEL
|
||
float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
|
||
#endif
|
||
#ifdef OPACITY
|
||
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
|
||
#ifdef OPACITYRGB
|
||
opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
|
||
#else
|
||
alpha*=opacityMap.a*vOpacityInfos.y;
|
||
#endif
|
||
#endif
|
||
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
alpha*=vColor.a;
|
||
#endif
|
||
#ifdef OPACITYFRESNEL
|
||
float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
|
||
#endif
|
||
#ifdef ALPHATEST
|
||
#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
|
||
if (alpha<alphaCutOff)
|
||
discard;
|
||
#endif
|
||
#ifndef ALPHABLEND
|
||
alpha=1.0;
|
||
#endif
|
||
#endif
|
||
vec3 emissiveColor=vEmissiveColor;
|
||
#ifdef EMISSIVE
|
||
emissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;
|
||
#endif
|
||
#ifdef EMISSIVEFRESNEL
|
||
float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;
|
||
#endif
|
||
#ifdef DIFFUSEFRESNEL
|
||
float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;
|
||
#endif
|
||
#ifdef EMISSIVEASILLUMINATION
|
||
vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
|
||
#else
|
||
#ifdef LINKEMISSIVEWITHDIFFUSE
|
||
vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
|
||
#else
|
||
vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
|
||
#endif
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
vec3 finalSpecular=specularBase*specularColor;
|
||
#ifdef SPECULAROVERALPHA
|
||
alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);
|
||
#endif
|
||
#else
|
||
vec3 finalSpecular=vec3(0.0);
|
||
#endif
|
||
#ifdef REFLECTIONOVERALPHA
|
||
alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);
|
||
#endif
|
||
#ifdef EMISSIVEASILLUMINATION
|
||
vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
|
||
#else
|
||
vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
|
||
#endif
|
||
#ifdef LIGHTMAP
|
||
#ifndef LIGHTMAPEXCLUDED
|
||
#ifdef USELIGHTMAPASSHADOWMAP
|
||
color.rgb*=lightmapColor.rgb;
|
||
#else
|
||
color.rgb+=lightmapColor.rgb;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_BEFORE_FOG
|
||
color.rgb=max(color.rgb,0.);
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>
|
||
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
color.rgb=toLinearSpace(color.rgb);
|
||
#else
|
||
#ifdef IMAGEPROCESSING
|
||
color.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color);
|
||
#endif
|
||
#endif
|
||
color.a*=visibility;
|
||
#ifdef PREMULTIPLYALPHA
|
||
color.rgb*=color.a;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
|
||
#ifdef PREPASS
|
||
float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;gl_FragData[0]=color;
|
||
#ifdef PREPASS_POSITION
|
||
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
gl_FragData[PREPASS_LOCAL_POSITION_INDEX] =
|
||
vec4(vPosition,writeGeometryInfo);
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY)
|
||
vec2 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);
|
||
#elif defined(PREPASS_VELOCITY_LINEAR)
|
||
vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) -
|
||
(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX] =
|
||
vec4(velocity,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_IRRADIANCE
|
||
gl_FragData[PREPASS_IRRADIANCE_INDEX] =
|
||
vec4(0.0,0.0,0.0,
|
||
writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
gl_FragData[PREPASS_DEPTH_INDEX] =
|
||
vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_SCREENSPACE_DEPTH
|
||
gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX] =
|
||
vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_NORMAL
|
||
#ifdef PREPASS_NORMAL_WORLDSPACE
|
||
gl_FragData[PREPASS_NORMAL_INDEX] =
|
||
vec4(normalW,writeGeometryInfo);
|
||
#else
|
||
gl_FragData[PREPASS_NORMAL_INDEX] =
|
||
vec4(normalize((view*vec4(normalW,0.0)).rgb),
|
||
writeGeometryInfo);
|
||
#endif
|
||
#endif
|
||
#ifdef PREPASS_WORLD_NORMAL
|
||
gl_FragData[PREPASS_WORLD_NORMAL_INDEX] =
|
||
vec4(normalW*0.5+0.5,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_ALBEDO_SQRT
|
||
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_REFLECTIVITY
|
||
#if defined(SPECULARTERM)
|
||
#if defined(SPECULAR)
|
||
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo;
|
||
#else
|
||
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo;
|
||
#endif
|
||
#else
|
||
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0)*writeGeometryInfo;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if !defined(PREPASS) || defined(WEBGL2)
|
||
gl_FragColor=color;
|
||
#endif
|
||
#include<oitFragment>
|
||
#if ORDER_INDEPENDENT_TRANSPARENCY
|
||
if (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;}
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},84765:(r,t,e)=>{e.r(t),e.d(t,{defaultVertexShader:()=>s});var n=e(98519),i=(e(42858),"defaultVertexDeclaration");n.l.IncludesShadersStore[i]=`uniform mat4 viewProjection;uniform mat4 view;
|
||
#ifdef DIFFUSE
|
||
uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;
|
||
#endif
|
||
#ifdef AMBIENT
|
||
uniform mat4 ambientMatrix;uniform vec2 vAmbientInfos;
|
||
#endif
|
||
#ifdef OPACITY
|
||
uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix;
|
||
#endif
|
||
#ifdef LIGHTMAP
|
||
uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix;
|
||
#endif
|
||
#if defined(SPECULAR) && defined(SPECULARTERM)
|
||
uniform vec2 vSpecularInfos;uniform mat4 specularMatrix;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform vec3 vBumpInfos;uniform mat4 bumpMatrix;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
uniform mat4 reflectionMatrix;
|
||
#endif
|
||
#ifdef POINTSIZE
|
||
uniform float pointSize;
|
||
#endif
|
||
#ifdef DETAIL
|
||
uniform vec4 vDetailInfos;uniform mat4 detailMatrix;
|
||
#endif
|
||
#include<decalVertexDeclaration>
|
||
#define ADDITIONAL_VERTEX_DECLARATION
|
||
`,e(51578),e(77976),e(75334),e(36470),e(64400),e(38615),e(60965),e(48493),e(60581),e(42513),e(85637),e(72153),e(94785),e(48961),e(24444),e(67369),e(59262),e(58266),e(84589),e(35397),e(76898),e(49334),e(7761),e(45858),e(81067),e(35845),e(83057),e(62589),e(62136),e(45812),e(52226),e(56458);var o="defaultVertexShader",a=`#include<__decl__defaultVertex>
|
||
#define CUSTOM_VERTEX_BEGIN
|
||
attribute vec3 position;
|
||
#ifdef NORMAL
|
||
attribute vec3 normal;
|
||
#endif
|
||
#ifdef TANGENT
|
||
attribute vec4 tangent;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#include<uvAttributeDeclaration>[2..7]
|
||
#ifdef VERTEXCOLOR
|
||
attribute vec4 color;
|
||
#endif
|
||
#include<helperFunctions>
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<instancesDeclaration>
|
||
#include<prePassVertexDeclaration>
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
|
||
#if defined(SPECULARTERM)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)
|
||
#endif
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
|
||
varying vec3 vPositionW;
|
||
#ifdef NORMAL
|
||
varying vec3 vNormalW;
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vec4 vColor;
|
||
#endif
|
||
#include<bumpVertexDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vec3 vPositionUVW;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vec3 vDirectionW;
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vec3 positionUpdated=position;
|
||
#ifdef NORMAL
|
||
vec3 normalUpdated=normal;
|
||
#endif
|
||
#ifdef TANGENT
|
||
vec4 tangentUpdated=tangent;
|
||
#endif
|
||
#ifdef UV1
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
vPositionUVW=positionUpdated;
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_POSITION
|
||
#define CUSTOM_VERTEX_UPDATE_NORMAL
|
||
#include<instancesVertex>
|
||
#if defined(PREPASS) && (defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED) || defined(PREPASS_VELOCITY_LINEAR))
|
||
vCurrentPosition =
|
||
viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld *
|
||
vec4(positionUpdated,1.0);
|
||
#endif
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
|
||
#ifdef NORMAL
|
||
mat3 normalWorld=mat3(finalWorld);
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normalWorld=transposeMat3(inverseMat3(normalWorld));
|
||
#endif
|
||
vNormalW=normalize(normalWorld*normalUpdated);
|
||
#endif
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_WORLDPOS
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
|
||
#else
|
||
gl_Position=viewProjection*worldPos;
|
||
#endif
|
||
vPositionW=vec3(worldPos);
|
||
#include<prePassVertex>
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
|
||
#endif
|
||
#ifndef UV1
|
||
vec2 uvUpdated=vec2(0.,0.);
|
||
#endif
|
||
#ifdef MAINUV1
|
||
vMainUV1=uvUpdated;
|
||
#endif
|
||
#include<uvVariableDeclaration>[2..7]
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
|
||
#if defined(SPECULARTERM)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)
|
||
#endif
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
|
||
#include<bumpVertex>
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<shadowsVertex>[0..maxSimultaneousLights]
|
||
#include<vertexColorMixing>
|
||
#include<pointCloudVertex>
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},80119:(r,t,e)=>{e.r(t),e.d(t,{depthPixelShader:()=>a});var n=e(98519),i=(e(27003),e(78531),e(39643),"depthPixelShader"),o=`#ifdef ALPHATEST
|
||
varying vec2 vUV;uniform sampler2D diffuseSampler;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
varying float vDepthMetric;
|
||
#ifdef PACKED
|
||
#include<packingFunctions>
|
||
#endif
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
varying vec4 vViewPos;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEST
|
||
if (texture2D(diffuseSampler,vUV).a<0.4)
|
||
discard;
|
||
#endif
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
#ifdef PACKED
|
||
gl_FragColor=pack(vViewPos.z);
|
||
#else
|
||
gl_FragColor=vec4(vViewPos.z,0.0,0.0,1.0);
|
||
#endif
|
||
#else
|
||
#ifdef NONLINEARDEPTH
|
||
#ifdef PACKED
|
||
gl_FragColor=pack(gl_FragCoord.z);
|
||
#else
|
||
gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);
|
||
#endif
|
||
#else
|
||
#ifdef PACKED
|
||
gl_FragColor=pack(vDepthMetric);
|
||
#else
|
||
gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},36321:(r,t,e)=>{e.r(t),e.d(t,{depthVertexShader:()=>s});var n=e(98519),i=(e(36470),e(64400),e(24444),e(67369),e(85637),e(38615),"pointCloudVertexDeclaration");n.l.IncludesShadersStore[i]=`#ifdef POINTSIZE
|
||
uniform float pointSize;
|
||
#endif
|
||
`,e(58266),e(84589),e(35397),e(76898),e(49334),e(83057),e(52226);var o="depthVertexShader",a=`attribute vec3 position;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<instancesDeclaration>
|
||
uniform mat4 viewProjection;uniform vec2 depthValues;
|
||
#if defined(ALPHATEST) || defined(NEED_UV)
|
||
varying vec2 vUV;uniform mat4 diffuseMatrix;
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute vec2 uv2;
|
||
#endif
|
||
#endif
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
uniform mat4 view;varying vec4 vViewPos;
|
||
#endif
|
||
#include<pointCloudVertexDeclaration>
|
||
varying float vDepthMetric;
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void)
|
||
{vec3 positionUpdated=position;
|
||
#ifdef UV1
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
|
||
#include<clipPlaneVertex>
|
||
gl_Position=viewProjection*worldPos;
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
vViewPos=view*worldPos;
|
||
#else
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));
|
||
#else
|
||
vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));
|
||
#endif
|
||
#endif
|
||
#if defined(ALPHATEST) || defined(BASIC_RENDER)
|
||
#ifdef UV1
|
||
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef UV2
|
||
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#include<pointCloudVertex>
|
||
}
|
||
`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},71859:(r,t,e)=>{e.r(t),e.d(t,{depthBoxBlurPixelShader:()=>o});var n="depthBoxBlurPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec4 colorDepth=vec4(0.0);for (int x=-OFFSET; x<=OFFSET; x++)
|
||
for (int y=-OFFSET; y<=OFFSET; y++)
|
||
colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},88456:(r,t,e)=>{e.r(t),e.d(t,{depthOfFieldMergePixelShader:()=>o});var n="depthOfFieldMergePixelShader",i=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
|
||
#else
|
||
#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
|
||
#endif
|
||
uniform sampler2D textureSampler;varying vec2 vUV;uniform sampler2D circleOfConfusionSampler;uniform sampler2D blurStep0;
|
||
#if BLUR_LEVEL>0
|
||
uniform sampler2D blurStep1;
|
||
#endif
|
||
#if BLUR_LEVEL>1
|
||
uniform sampler2D blurStep2;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{float coc=TEXTUREFUNC(circleOfConfusionSampler,vUV,0.0).r;
|
||
#if BLUR_LEVEL==0
|
||
vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);gl_FragColor=mix(original,blurred0,coc);
|
||
#endif
|
||
#if BLUR_LEVEL==1
|
||
if(coc<0.5){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(original,blurred1,coc/0.5);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);}
|
||
#endif
|
||
#if BLUR_LEVEL==2
|
||
if(coc<0.33){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(original,blurred2,coc/0.33);}else if(coc<0.66){vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);}
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},30145:(r,t,e)=>{e.r(t),e.d(t,{displayPassPixelShader:()=>o});var n="displayPassPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D passSampler;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=texture2D(passSampler,vUV);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},57372:(r,t,e)=>{e.r(t),e.d(t,{extractHighlightsPixelShader:()=>a});var n=e(98519),i=(e(75334),"extractHighlightsPixelShader"),o=`#include<helperFunctions>
|
||
varying vec2 vUV;uniform sampler2D textureSampler;uniform float threshold;uniform float exposure;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=texture2D(textureSampler,vUV);float luma=dot(LuminanceEncodeApprox,gl_FragColor.rgb*exposure);gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},80432:(r,t,e)=>{e.r(t),e.d(t,{filterPixelShader:()=>o});var n="filterPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform mat4 kernelMatrix;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec3 baseColor=texture2D(textureSampler,vUV).rgb;vec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;gl_FragColor=vec4(updatedColor,1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},48063:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingBilateralBlurPixelShader:()=>o});var n="fluidRenderingBilateralBlurPixelShader",i=`uniform sampler2D textureSampler;uniform int maxFilterSize;uniform vec2 blurDir;uniform float projectedParticleConstant;uniform float depthThreshold;varying vec2 vUV;void main(void) {float depth=textureLod(textureSampler,vUV,0.).x;if (depth>=1e6 || depth<=0.) {glFragColor=vec4(vec3(depth),1.);return;}
|
||
int filterSize=min(maxFilterSize,int(ceil(projectedParticleConstant/depth)));float sigma=float(filterSize)/3.0;float two_sigma2=2.0*sigma*sigma;float sigmaDepth=depthThreshold/3.0;float two_sigmaDepth2=2.0*sigmaDepth*sigmaDepth;float sum=0.;float wsum=0.;float sumVel=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec2 sampleDepthVel=textureLod(textureSampler,vUV+coords*blurDir,0.).rg;float r=dot(coords,coords);float w=exp(-r/two_sigma2);float rDepth=sampleDepthVel.r-depth;float wd=exp(-rDepth*rDepth/two_sigmaDepth2);sum+=sampleDepthVel.r*w*wd;sumVel+=sampleDepthVel.g*w*wd;wsum+=w*wd;}
|
||
glFragColor=vec4(sum/wsum,sumVel/wsum,0.,1.);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},18337:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleDepthPixelShader:()=>o});var n="fluidRenderingParticleDepthPixelShader",i=`uniform mat4 projection;varying vec2 uv;varying vec3 viewPos;varying float sphereRadius;
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
varying float velocityNorm;
|
||
#endif
|
||
void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;normal.z=sqrt(1.0-r2);
|
||
#ifndef FLUIDRENDERING_RHS
|
||
normal.z=-normal.z;
|
||
#endif
|
||
vec4 realViewPos=vec4(viewPos+normal*sphereRadius,1.0);vec4 clipSpacePos=projection*realViewPos;
|
||
#ifdef WEBGPU
|
||
gl_FragDepth=clipSpacePos.z/clipSpacePos.w;
|
||
#else
|
||
gl_FragDepth=(clipSpacePos.z/clipSpacePos.w)*0.5+0.5;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_RHS
|
||
realViewPos.z=-realViewPos.z;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
glFragColor=vec4(realViewPos.z,velocityNorm,0.,1.);
|
||
#else
|
||
glFragColor=vec4(realViewPos.z,0.,0.,1.);
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},29687:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleDepthVertexShader:()=>o});var n="fluidRenderingParticleDepthVertexShader",i=`attribute vec3 position;attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;varying vec3 viewPos;varying float sphereRadius;
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
attribute vec3 velocity;varying float velocityNorm;
|
||
#endif
|
||
void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;viewPos=(view*vec4(position,1.0)).xyz;gl_Position=projection*vec4(viewPos+cornerPos,1.0);uv=offset;sphereRadius=size.x/2.0;
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
velocityNorm=length(velocity);
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},45868:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleDiffusePixelShader:()=>o});var n="fluidRenderingParticleDiffusePixelShader",i=`uniform float particleAlpha;varying vec2 uv;varying vec3 diffuseColor;void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;glFragColor=vec4(diffuseColor,1.0);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},10151:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleThicknessPixelShader:()=>o});var n="fluidRenderingParticleThicknessPixelShader",i=`uniform float particleAlpha;varying vec2 uv;void main(void) {vec3 normal;normal.xy=uv*2.0-1.0;float r2=dot(normal.xy,normal.xy);if (r2>1.0) discard;float thickness=sqrt(1.0-r2);glFragColor=vec4(vec3(particleAlpha*thickness),1.0);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},55214:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleThicknessVertexShader:()=>o});var n="fluidRenderingParticleThicknessVertexShader",i=`attribute vec3 position;attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;vec3 viewPos=(view*vec4(position,1.0)).xyz+cornerPos;gl_Position=projection*vec4(viewPos,1.0);uv=offset;}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},36870:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingRenderPixelShader:()=>o});var n="fluidRenderingRenderPixelShader",i=`#define DISABLE_UNIFORMITY_ANALYSIS
|
||
#define IOR 1.333
|
||
#define ETA 1.0/IOR
|
||
#define F0 0.02
|
||
uniform sampler2D textureSampler;uniform sampler2D depthSampler;
|
||
#ifdef FLUIDRENDERING_DIFFUSETEXTURE
|
||
uniform sampler2D diffuseSampler;
|
||
#else
|
||
uniform vec3 diffuseColor;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_FIXED_THICKNESS
|
||
uniform float thickness;uniform sampler2D bgDepthSampler;
|
||
#else
|
||
uniform float minimumThickness;uniform sampler2D thicknessSampler;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_ENVIRONMENT
|
||
uniform samplerCube reflectionSampler;
|
||
#endif
|
||
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)
|
||
uniform sampler2D debugSampler;
|
||
#endif
|
||
uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform mat4 invProjectionMatrix;uniform vec2 texelSize;uniform vec3 dirLight;uniform float cameraFar;uniform float density;uniform float refractionStrength;uniform float fresnelClamp;uniform float specularPower;varying vec2 vUV;vec3 computeViewPosFromUVDepth(vec2 texCoord,float depth) {vec4 ndc;ndc.xy=texCoord*2.0-1.0;
|
||
#ifdef FLUIDRENDERING_RHS
|
||
ndc.z=-projectionMatrix[2].z+projectionMatrix[3].z/depth;
|
||
#else
|
||
ndc.z=projectionMatrix[2].z+projectionMatrix[3].z/depth;
|
||
#endif
|
||
ndc.w=1.0;vec4 eyePos=invProjectionMatrix*ndc;eyePos.xyz/=eyePos.w;return eyePos.xyz;}
|
||
vec3 getViewPosFromTexCoord(vec2 texCoord) {float depth=textureLod(depthSampler,texCoord,0.).x;return computeViewPosFromUVDepth(texCoord,depth);}
|
||
void main(void) {vec2 texCoord=vUV;
|
||
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)
|
||
vec4 color=texture2D(debugSampler,texCoord);
|
||
#ifdef FLUIDRENDERING_DEBUG_DEPTH
|
||
glFragColor=vec4(color.rgb/vec3(2.0),1.);if (color.r>0.999 && color.g>0.999) {glFragColor=texture2D(textureSampler,texCoord);}
|
||
#else
|
||
glFragColor=vec4(color.rgb,1.);if (color.r<0.001 && color.g<0.001 && color.b<0.001) {glFragColor=texture2D(textureSampler,texCoord);}
|
||
#endif
|
||
return;
|
||
#endif
|
||
vec2 depthVel=textureLod(depthSampler,texCoord,0.).rg;float depth=depthVel.r;
|
||
#ifndef FLUIDRENDERING_FIXED_THICKNESS
|
||
float thickness=texture2D(thicknessSampler,texCoord).x;
|
||
#else
|
||
float bgDepth=texture2D(bgDepthSampler,texCoord).x;float depthNonLinear=projectionMatrix[2].z+projectionMatrix[3].z/depth;depthNonLinear=depthNonLinear*0.5+0.5;
|
||
#endif
|
||
vec4 backColor=texture2D(textureSampler,texCoord);
|
||
#ifndef FLUIDRENDERING_FIXED_THICKNESS
|
||
if (depth>=cameraFar || depth<=0. || thickness<=minimumThickness) {
|
||
#else
|
||
if (depth>=cameraFar || depth<=0. || bgDepth<=depthNonLinear) {
|
||
#endif
|
||
#ifdef FLUIDRENDERING_COMPOSITE_MODE
|
||
glFragColor.rgb=backColor.rgb*backColor.a;glFragColor.a=backColor.a;
|
||
#else
|
||
glFragColor=backColor;
|
||
#endif
|
||
return;}
|
||
vec3 viewPos=computeViewPosFromUVDepth(texCoord,depth);vec3 ddx=getViewPosFromTexCoord(texCoord+vec2(texelSize.x,0.))-viewPos;vec3 ddy=getViewPosFromTexCoord(texCoord+vec2(0.,texelSize.y))-viewPos;vec3 ddx2=viewPos-getViewPosFromTexCoord(texCoord+vec2(-texelSize.x,0.));if (abs(ddx.z)>abs(ddx2.z)) {ddx=ddx2;}
|
||
vec3 ddy2=viewPos-getViewPosFromTexCoord(texCoord+vec2(0.,-texelSize.y));if (abs(ddy.z)>abs(ddy2.z)) {ddy=ddy2;}
|
||
vec3 normal=normalize(cross(ddy,ddx));
|
||
#ifdef FLUIDRENDERING_RHS
|
||
normal=-normal;
|
||
#endif
|
||
#ifndef WEBGPU
|
||
if(isnan(normal.x) || isnan(normal.y) || isnan(normal.z) || isinf(normal.x) || isinf(normal.y) || isinf(normal.z)) {normal=vec3(0.,0.,-1.);}
|
||
#endif
|
||
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_SHOWNORMAL)
|
||
glFragColor=vec4(normal*0.5+0.5,1.0);return;
|
||
#endif
|
||
vec3 rayDir=normalize(viewPos);
|
||
#ifdef FLUIDRENDERING_DIFFUSETEXTURE
|
||
vec3 diffuseColor=textureLod(diffuseSampler,texCoord,0.0).rgb;
|
||
#endif
|
||
vec3 lightDir=normalize(vec3(viewMatrix*vec4(-dirLight,0.)));vec3 H =normalize(lightDir-rayDir);float specular=pow(max(0.0,dot(H,normal)),specularPower);
|
||
#ifdef FLUIDRENDERING_DEBUG_DIFFUSERENDERING
|
||
float diffuse =max(0.0,dot(lightDir,normal))*1.0;glFragColor=vec4(vec3(0.1) /*ambient*/+vec3(0.42,0.50,1.00)*diffuse+vec3(0,0,0.2)+specular,1.);return;
|
||
#endif
|
||
vec3 refractionDir=refract(rayDir,normal,ETA);vec4 transmitted=textureLod(textureSampler,vec2(texCoord+refractionDir.xy*thickness*refractionStrength),0.0);
|
||
#ifdef FLUIDRENDERING_COMPOSITE_MODE
|
||
if (transmitted.a==0.) transmitted.a=thickness;
|
||
#endif
|
||
vec3 transmittance=exp(-density*thickness*(1.0-diffuseColor));
|
||
vec3 refractionColor=transmitted.rgb*transmittance;
|
||
#ifdef FLUIDRENDERING_ENVIRONMENT
|
||
vec3 reflectionDir=reflect(rayDir,normal);vec3 reflectionColor=(textureCube(reflectionSampler,reflectionDir).rgb);float fresnel=clamp(F0+(1.0-F0)*pow(1.0-dot(normal,-rayDir),5.0),0.,fresnelClamp);vec3 finalColor=mix(refractionColor,reflectionColor,fresnel)+specular;
|
||
#else
|
||
vec3 finalColor=refractionColor+specular;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
float velocity=depthVel.g;finalColor=mix(finalColor,vec3(1.0),smoothstep(0.3,1.0,velocity/6.0));
|
||
#endif
|
||
glFragColor=vec4(finalColor,transmitted.a);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},31298:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingStandardBlurPixelShader:()=>o});var n="fluidRenderingStandardBlurPixelShader",i=`uniform sampler2D textureSampler;uniform int filterSize;uniform vec2 blurDir;varying vec2 vUV;void main(void) {vec4 s=textureLod(textureSampler,vUV,0.);if (s.r==0.) {glFragColor=vec4(0.,0.,0.,1.);return;}
|
||
float sigma=float(filterSize)/3.0;float twoSigma2=2.0*sigma*sigma;vec4 sum=vec4(0.);float wsum=0.;for (int x=-filterSize; x<=filterSize; ++x) {vec2 coords=vec2(x);vec4 sampl=textureLod(textureSampler,vUV+coords*blurDir,0.);float w=exp(-coords.x*coords.x/twoSigma2);sum+=sampl*w;wsum+=w;}
|
||
sum/=wsum;glFragColor=vec4(sum.rgb,1.);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},59210:(r,t,e)=>{e.r(t),e.d(t,{fxaaPixelShader:()=>o});var n="fxaaPixelShader",i=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
|
||
#else
|
||
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
|
||
#endif
|
||
uniform sampler2D textureSampler;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const float fxaaQualitySubpix=1.0;const float fxaaQualityEdgeThreshold=0.166;const float fxaaQualityEdgeThresholdMin=0.0833;const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);
|
||
#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)
|
||
void main(){vec2 posM;posM.x=vUV.x;posM.y=vUV.y;vec4 rgbyM=TEXTUREFUNC(textureSampler,vUV,0.0);float lumaM=FxaaLuma(rgbyM);float lumaS=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordS,0.0));float lumaE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordE,0.0));float lumaN=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordN,0.0));float lumaW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordW,0.0));float maxSM=max(lumaS,lumaM);float minSM=min(lumaS,lumaM);float maxESM=max(lumaE,maxSM);float minESM=min(lumaE,minSM);float maxWN=max(lumaN,lumaW);float minWN=min(lumaN,lumaW);float rangeMax=max(maxWN,maxESM);float rangeMin=min(minWN,minESM);float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;float range=rangeMax-rangeMin;float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);
|
||
#ifndef MALI
|
||
if(range<rangeMaxClamped)
|
||
{gl_FragColor=rgbyM;return;}
|
||
#endif
|
||
float lumaNW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordNW,0.0));float lumaSE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordSE,0.0));float lumaNE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordNE,0.0));float lumaSW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordSW,0.0));float lumaNS=lumaN+lumaS;float lumaWE=lumaW+lumaE;float subpixRcpRange=1.0/range;float subpixNSWE=lumaNS+lumaWE;float edgeHorz1=(-2.0*lumaM)+lumaNS;float edgeVert1=(-2.0*lumaM)+lumaWE;float lumaNESE=lumaNE+lumaSE;float lumaNWNE=lumaNW+lumaNE;float edgeHorz2=(-2.0*lumaE)+lumaNESE;float edgeVert2=(-2.0*lumaN)+lumaNWNE;float lumaNWSW=lumaNW+lumaSW;float lumaSWSE=lumaSW+lumaSE;float edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);float edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);float edgeHorz3=(-2.0*lumaW)+lumaNWSW;float edgeVert3=(-2.0*lumaS)+lumaSWSE;float edgeHorz=abs(edgeHorz3)+edgeHorz4;float edgeVert=abs(edgeVert3)+edgeVert4;float subpixNWSWNESE=lumaNWSW+lumaNESE;float lengthSign=texelSize.x;bool horzSpan=edgeHorz>=edgeVert;float subpixA=subpixNSWE*2.0+subpixNWSWNESE;if (!horzSpan)
|
||
{lumaN=lumaW;}
|
||
if (!horzSpan)
|
||
{lumaS=lumaE;}
|
||
if (horzSpan)
|
||
{lengthSign=texelSize.y;}
|
||
float subpixB=(subpixA*(1.0/12.0))-lumaM;float gradientN=lumaN-lumaM;float gradientS=lumaS-lumaM;float lumaNN=lumaN+lumaM;float lumaSS=lumaS+lumaM;bool pairN=abs(gradientN)>=abs(gradientS);float gradient=max(abs(gradientN),abs(gradientS));if (pairN)
|
||
{lengthSign=-lengthSign;}
|
||
float subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);vec2 posB;posB.x=posM.x;posB.y=posM.y;vec2 offNP;offNP.x=(!horzSpan) ? 0.0 : texelSize.x;offNP.y=(horzSpan) ? 0.0 : texelSize.y;if (!horzSpan)
|
||
{posB.x+=lengthSign*0.5;}
|
||
if (horzSpan)
|
||
{posB.y+=lengthSign*0.5;}
|
||
vec2 posN;posN.x=posB.x-offNP.x*1.5;posN.y=posB.y-offNP.y*1.5;vec2 posP;posP.x=posB.x+offNP.x*1.5;posP.y=posB.y+offNP.y*1.5;float subpixD=((-2.0)*subpixC)+3.0;float lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN,0.0));float subpixE=subpixC*subpixC;float lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP,0.0));if (!pairN)
|
||
{lumaNN=lumaSS;}
|
||
float gradientScaled=gradient*1.0/4.0;float lumaMM=lumaM-lumaNN*0.5;float subpixF=subpixD*subpixE;bool lumaMLTZero=lumaMM<0.0;lumaEndN-=lumaNN*0.5;lumaEndP-=lumaNN*0.5;bool doneN=abs(lumaEndN)>=gradientScaled;bool doneP=abs(lumaEndP)>=gradientScaled;if (!doneN)
|
||
{posN.x-=offNP.x*3.0;}
|
||
if (!doneN)
|
||
{posN.y-=offNP.y*3.0;}
|
||
bool doneNP=(!doneN) || (!doneP);if (!doneP)
|
||
{posP.x+=offNP.x*3.0;}
|
||
if (!doneP)
|
||
{posP.y+=offNP.y*3.0;}
|
||
if (doneNP)
|
||
{if (!doneN) lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN.xy,0.0));if (!doneP) lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP.xy,0.0));if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;doneN=abs(lumaEndN)>=gradientScaled;doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) posN.x-=offNP.x*12.0;if (!doneN) posN.y-=offNP.y*12.0;doneNP=(!doneN) || (!doneP);if (!doneP) posP.x+=offNP.x*12.0;if (!doneP) posP.y+=offNP.y*12.0;}
|
||
float dstN=posM.x-posN.x;float dstP=posP.x-posM.x;if (!horzSpan)
|
||
{dstN=posM.y-posN.y;}
|
||
if (!horzSpan)
|
||
{dstP=posP.y-posM.y;}
|
||
bool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;float spanLength=(dstP+dstN);bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;float spanLengthRcp=1.0/spanLength;bool directionN=dstN<dstP;float dst=min(dstN,dstP);bool goodSpan=directionN ? goodSpanN : goodSpanP;float subpixG=subpixF*subpixF;float pixelOffset=(dst*(-spanLengthRcp))+0.5;float subpixH=subpixG*fxaaQualitySubpix;float pixelOffsetGood=goodSpan ? pixelOffset : 0.0;float pixelOffsetSubpix=max(pixelOffsetGood,subpixH);if (!horzSpan)
|
||
{posM.x+=pixelOffsetSubpix*lengthSign;}
|
||
if (horzSpan)
|
||
{posM.y+=pixelOffsetSubpix*lengthSign;}
|
||
#ifdef MALI
|
||
if(range<rangeMaxClamped)
|
||
{gl_FragColor=rgbyM;}
|
||
else
|
||
{gl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);}
|
||
#else
|
||
gl_FragColor=TEXTUREFUNC(textureSampler,posM,0.0);
|
||
#endif
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},93100:(r,t,e)=>{e.r(t),e.d(t,{fxaaVertexShader:()=>o});var n="fxaaVertexShader",i=`attribute vec2 position;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const vec2 madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vUV=(position*madd+madd);sampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;sampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;sampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;sampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;sampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;sampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;gl_Position=vec4(position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},93102:(r,t,e)=>{e.r(t),e.d(t,{geometryPixelShader:()=>s});var n=e(98519),i=(e(27003),"mrtFragmentDeclaration");n.l.IncludesShadersStore[i]=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
layout(location=0) out vec4 glFragData[{X}];
|
||
#endif
|
||
`,e(48661),e(75394),e(75334),e(39643),e(56159);var o="geometryPixelShader",a=`#extension GL_EXT_draw_buffers : require
|
||
#if defined(BUMP) || !defined(NORMAL)
|
||
#extension GL_OES_standard_derivatives : enable
|
||
#endif
|
||
precision highp float;
|
||
#ifdef BUMP
|
||
varying mat4 vWorldView;varying vec3 vNormalW;
|
||
#else
|
||
varying vec3 vNormalV;
|
||
#endif
|
||
varying vec4 vViewPos;
|
||
#if defined(POSITION) || defined(BUMP)
|
||
varying vec3 vPositionW;
|
||
#endif
|
||
#ifdef VELOCITY
|
||
varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
|
||
#endif
|
||
#ifdef NEED_UV
|
||
varying vec2 vUV;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
|
||
#endif
|
||
#if defined(REFLECTIVITY)
|
||
#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
||
uniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;
|
||
#endif
|
||
#ifdef ALBEDOTEXTURE
|
||
varying vec2 vAlbedoUV;uniform sampler2D albedoSampler;
|
||
#endif
|
||
#ifdef REFLECTIVITYCOLOR
|
||
uniform vec3 reflectivityColor;
|
||
#endif
|
||
#ifdef ALBEDOCOLOR
|
||
uniform vec3 albedoColor;
|
||
#endif
|
||
#ifdef METALLIC
|
||
uniform float metallic;
|
||
#endif
|
||
#if defined(ROUGHNESS) || defined(GLOSSINESS)
|
||
uniform float glossiness;
|
||
#endif
|
||
#endif
|
||
#if defined(ALPHATEST) && defined(NEED_UV)
|
||
uniform sampler2D diffuseSampler;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<mrtFragmentDeclaration>[SCENE_MRT_COUNT]
|
||
#include<bumpFragmentMainFunctions>
|
||
#include<bumpFragmentFunctions>
|
||
#include<helperFunctions>
|
||
void main() {
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEST
|
||
if (texture2D(diffuseSampler,vUV).a<0.4)
|
||
discard;
|
||
#endif
|
||
vec3 normalOutput;
|
||
#ifdef BUMP
|
||
vec3 normalW=normalize(vNormalW);
|
||
#include<bumpFragment>
|
||
#ifdef NORMAL_WORLDSPACE
|
||
normalOutput=normalW;
|
||
#else
|
||
normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));
|
||
#endif
|
||
#else
|
||
normalOutput=normalize(vNormalV);
|
||
#endif
|
||
#ifdef ENCODE_NORMAL
|
||
normalOutput=normalOutput*0.5+0.5;
|
||
#endif
|
||
#ifdef PREPASS
|
||
#ifdef PREPASS_DEPTH
|
||
gl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);
|
||
#endif
|
||
#if defined(PREPASS_NORMAL) || defined(PREPASS_WORLD_NORMAL)
|
||
gl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);
|
||
#endif
|
||
#else
|
||
gl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);gl_FragData[1]=vec4(normalOutput,1.0);
|
||
#endif
|
||
#ifdef POSITION
|
||
gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);
|
||
#endif
|
||
#ifdef VELOCITY
|
||
vec2 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[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
vec4 reflectivity=vec4(0.0,0.0,0.0,1.0);
|
||
#ifdef METALLICWORKFLOW
|
||
float metal=1.0;float roughness=1.0;
|
||
#ifdef ORMTEXTURE
|
||
metal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;
|
||
#endif
|
||
#ifdef METALLIC
|
||
metal*=metallic;
|
||
#endif
|
||
#ifdef ROUGHNESS
|
||
roughness*=(1.0-glossiness);
|
||
#endif
|
||
reflectivity.a-=roughness;vec3 color=vec3(1.0);
|
||
#ifdef ALBEDOTEXTURE
|
||
color=texture2D(albedoSampler,vAlbedoUV).rgb;
|
||
#ifdef GAMMAALBEDO
|
||
color=toLinearSpace(color);
|
||
#endif
|
||
#endif
|
||
#ifdef ALBEDOCOLOR
|
||
color*=albedoColor.xyz;
|
||
#endif
|
||
reflectivity.rgb=mix(vec3(0.04),color,metal);
|
||
#else
|
||
#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
||
reflectivity=texture2D(reflectivitySampler,vReflectivityUV);
|
||
#ifdef GAMMAREFLECTIVITYTEXTURE
|
||
reflectivity.rgb=toLinearSpace(reflectivity.rgb);
|
||
#endif
|
||
#else
|
||
#ifdef REFLECTIVITYCOLOR
|
||
reflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;
|
||
#endif
|
||
#endif
|
||
#ifdef GLOSSINESSS
|
||
reflectivity.a*=glossiness;
|
||
#endif
|
||
#endif
|
||
gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},779:(r,t,e)=>{e.r(t),e.d(t,{geometryVertexShader:()=>s});var n=e(98519),i=(e(36470),e(64400),e(24444),e(67369),e(38615),"geometryVertexDeclaration");n.l.IncludesShadersStore[i]="uniform mat4 viewProjection;uniform mat4 view;",e(50851),n.l.IncludesShadersStore.geometryUboDeclaration=`#include<sceneUboDeclaration>
|
||
`,e(85637),e(58266),e(84589),e(35397),e(76898),e(49334),e(83057),e(35845);var o="geometryVertexShader",a=`precision highp float;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesDeclaration>
|
||
#include<__decl__geometryVertex>
|
||
#include<clipPlaneVertexDeclaration>
|
||
attribute vec3 position;attribute vec3 normal;
|
||
#ifdef NEED_UV
|
||
varying vec2 vUV;
|
||
#ifdef ALPHATEST
|
||
uniform mat4 diffuseMatrix;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform mat4 bumpMatrix;varying vec2 vBumpUV;
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
uniform mat4 reflectivityMatrix;uniform mat4 albedoMatrix;varying vec2 vReflectivityUV;varying vec2 vAlbedoUV;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute vec2 uv2;
|
||
#endif
|
||
#endif
|
||
#ifdef BUMP
|
||
varying mat4 vWorldView;
|
||
#endif
|
||
#ifdef BUMP
|
||
varying vec3 vNormalW;
|
||
#else
|
||
varying vec3 vNormalV;
|
||
#endif
|
||
varying vec4 vViewPos;
|
||
#if defined(POSITION) || defined(BUMP)
|
||
varying vec3 vPositionW;
|
||
#endif
|
||
#ifdef VELOCITY
|
||
uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void)
|
||
{vec3 positionUpdated=position;vec3 normalUpdated=normal;
|
||
#ifdef UV1
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
|
||
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
|
||
#endif
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=vec4(finalWorld*vec4(positionUpdated,1.0));
|
||
#ifdef BUMP
|
||
vWorldView=view*finalWorld;vNormalW=normalUpdated;
|
||
#else
|
||
#ifdef NORMAL_WORLDSPACE
|
||
vNormalV=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));
|
||
#else
|
||
vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));
|
||
#endif
|
||
#endif
|
||
vViewPos=view*worldPos;
|
||
#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)
|
||
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
|
||
#endif
|
||
vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);
|
||
#else
|
||
vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
|
||
#endif
|
||
#endif
|
||
#if defined(POSITION) || defined(BUMP)
|
||
vPositionW=worldPos.xyz/worldPos.w;
|
||
#endif
|
||
gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
|
||
#include<clipPlaneVertex>
|
||
#ifdef NEED_UV
|
||
#ifdef UV1
|
||
#if defined(ALPHATEST) && defined(ALPHATEST_UV1)
|
||
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#else
|
||
vUV=uv;
|
||
#endif
|
||
#ifdef BUMP_UV1
|
||
vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef REFLECTIVITY_UV1
|
||
vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef ALBEDO_UV1
|
||
vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#ifdef UV2
|
||
#if defined(ALPHATEST) && defined(ALPHATEST_UV2)
|
||
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
|
||
#else
|
||
vUV=uv2;
|
||
#endif
|
||
#ifdef BUMP_UV2
|
||
vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#ifdef REFLECTIVITY_UV2
|
||
vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#ifdef ALBEDO_UV2
|
||
vAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#include<bumpVertex>
|
||
}
|
||
`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},67881:(r,t,e)=>{e.r(t),e.d(t,{glowBlurPostProcessPixelShader:()=>o});var n="glowBlurPostProcessPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 direction;uniform float blurWidth;float getLuminance(vec3 color)
|
||
{return dot(color,vec3(0.2126,0.7152,0.0722));}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{float weights[7];weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);vec2 texelStep=texelSize*direction*blurWidth;vec2 start=vUV-3.0*texelStep;vec4 baseColor=vec4(0.,0.,0.,0.);vec2 texelOffset=vec2(0.,0.);for (int i=0; i<7; i++)
|
||
{vec4 texel=texture2D(textureSampler,start+texelOffset);baseColor.a+=texel.a*weights[i];float luminance=getLuminance(baseColor.rgb);float luminanceTexel=getLuminance(texel.rgb);float choice=step(luminanceTexel,luminance);baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;texelOffset+=texelStep;}
|
||
gl_FragColor=baseColor;}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},75417:(r,t,e)=>{e.r(t),e.d(t,{glowMapGenerationPixelShader:()=>a});var n=e(98519),i=(e(75334),e(27003),e(39643),"glowMapGenerationPixelShader"),o=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)
|
||
#include<helperFunctions>
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
varying vec2 vUVDiffuse;uniform sampler2D diffuseSampler;
|
||
#endif
|
||
#ifdef OPACITY
|
||
varying vec2 vUVOpacity;uniform sampler2D opacitySampler;uniform float opacityIntensity;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
varying vec2 vUVEmissive;uniform sampler2D emissiveSampler;
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
varying vec4 vColor;
|
||
#endif
|
||
uniform vec4 glowColor;uniform float glowIntensity;
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{
|
||
#include<clipPlaneFragment>
|
||
vec4 finalColor=glowColor;
|
||
#ifdef DIFFUSE
|
||
vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);
|
||
#ifdef DIFFUSE_ISLINEAR
|
||
albedoTexture=toGammaSpace(albedoTexture);
|
||
#endif
|
||
#ifdef GLOW
|
||
finalColor.a*=albedoTexture.a;
|
||
#endif
|
||
#ifdef HIGHLIGHT
|
||
finalColor.a=albedoTexture.a;
|
||
#endif
|
||
#endif
|
||
#ifdef OPACITY
|
||
vec4 opacityMap=texture2D(opacitySampler,vUVOpacity);
|
||
#ifdef OPACITYRGB
|
||
finalColor.a*=getLuminance(opacityMap.rgb);
|
||
#else
|
||
finalColor.a*=opacityMap.a;
|
||
#endif
|
||
finalColor.a*=opacityIntensity;
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
finalColor.a*=vColor.a;
|
||
#endif
|
||
#ifdef ALPHATEST
|
||
if (finalColor.a<ALPHATESTVALUE)
|
||
discard;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
vec4 emissive=texture2D(emissiveSampler,vUVEmissive);
|
||
#ifdef EMISSIVE_ISLINEAR
|
||
emissive=toGammaSpace(emissive);
|
||
#endif
|
||
gl_FragColor=emissive*finalColor*glowIntensity;
|
||
#else
|
||
gl_FragColor=finalColor*glowIntensity;
|
||
#endif
|
||
#ifdef HIGHLIGHT
|
||
gl_FragColor.a=glowColor.a;
|
||
#endif
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},47615:(r,t,e)=>{e.r(t),e.d(t,{glowMapGenerationVertexShader:()=>a});var n=e(98519),i=(e(36470),e(64400),e(24444),e(67369),e(85637),e(38615),e(58266),e(84589),e(35397),e(76898),e(49334),e(83057),"glowMapGenerationVertexShader"),o=`attribute vec3 position;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<instancesDeclaration>
|
||
uniform mat4 viewProjection;varying vec4 vPosition;
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute vec2 uv2;
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
varying vec2 vUVDiffuse;uniform mat4 diffuseMatrix;
|
||
#endif
|
||
#ifdef OPACITY
|
||
varying vec2 vUVOpacity;uniform mat4 opacityMatrix;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
varying vec2 vUVEmissive;uniform mat4 emissiveMatrix;
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
attribute vec4 color;varying vec4 vColor;
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void)
|
||
{vec3 positionUpdated=position;
|
||
#ifdef UV1
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
|
||
#ifdef CUBEMAP
|
||
vPosition=worldPos;gl_Position=viewProjection*finalWorld*vec4(position,1.0);
|
||
#else
|
||
vPosition=viewProjection*worldPos;gl_Position=vPosition;
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
#ifdef DIFFUSEUV1
|
||
vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef DIFFUSEUV2
|
||
vUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#ifdef OPACITY
|
||
#ifdef OPACITYUV1
|
||
vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef OPACITYUV2
|
||
vUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
#ifdef EMISSIVEUV1
|
||
vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef EMISSIVEUV2
|
||
vUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
vColor=color;
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},62191:(r,t,e)=>{e.r(t),e.d(t,{glowMapMergePixelShader:()=>o});var n="glowMapMergePixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;
|
||
#ifdef EMISSIVE
|
||
uniform sampler2D textureSampler2;
|
||
#endif
|
||
uniform float offset;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
vec4 baseColor=texture2D(textureSampler,vUV);
|
||
#ifdef EMISSIVE
|
||
baseColor+=texture2D(textureSampler2,vUV);baseColor*=offset;
|
||
#else
|
||
baseColor.a=abs(offset-baseColor.a);
|
||
#ifdef STROKE
|
||
float alpha=smoothstep(.0,.1,baseColor.a);baseColor.a=alpha;baseColor.rgb=baseColor.rgb*alpha;
|
||
#endif
|
||
#endif
|
||
#if LDR
|
||
baseColor=clamp(baseColor,0.,1.0);
|
||
#endif
|
||
gl_FragColor=baseColor;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},99349:(r,t,e)=>{e.r(t),e.d(t,{glowMapMergeVertexShader:()=>o});var n="glowMapMergeVertexShader",i=`attribute vec2 position;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},47469:(r,t,e)=>{e.r(t),e.d(t,{grainPixelShader:()=>a});var n=e(98519),i=(e(75334),"grainPixelShader"),o=`#include<helperFunctions>
|
||
uniform sampler2D textureSampler;
|
||
uniform float intensity;uniform float animatedSeed;varying vec2 vUV;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=texture2D(textureSampler,vUV);vec2 seed=vUV*(animatedSeed);float grain=dither(seed,intensity);float lum=getLuminance(gl_FragColor.rgb);float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;gl_FragColor.rgb+=grain*grainAmount;gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},59586:(r,t,e)=>{e.r(t),e.d(t,{hdrFilteringPixelShader:()=>a});var n=e(98519),i=(e(75334),e(19568),e(64244),e(10114),"hdrFilteringPixelShader"),o=`#include<helperFunctions>
|
||
#include<importanceSampling>
|
||
#include<pbrBRDFFunctions>
|
||
#include<hdrFilteringFunctions>
|
||
uniform float alphaG;uniform samplerCube inputTexture;uniform vec2 vFilteringInfo;uniform float hdrScale;varying vec3 direction;void main() {vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);gl_FragColor=vec4(color*hdrScale,1.0);}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},88724:(r,t,e)=>{e.r(t),e.d(t,{hdrFilteringVertexShader:()=>o});var n="hdrFilteringVertexShader",i=`attribute vec2 position;varying vec3 direction;uniform vec3 up;uniform vec3 right;uniform vec3 front;
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
mat3 view=mat3(up,right,front);direction=view*vec3(position,1.0);gl_Position=vec4(position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},36489:(r,t,e)=>{e.r(t),e.d(t,{highlightsPixelShader:()=>o});var n="highlightsPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;const vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec4 tex=texture2D(textureSampler,vUV);vec3 c=tex.rgb;float luma=dot(c.rgb,RGBLuminanceCoefficients);gl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); }`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},82911:(r,t,e)=>{e.r(t),e.d(t,{iblCombineVoxelGridsPixelShader:()=>o});var n="iblCombineVoxelGridsPixelShader",i="precision highp float;precision highp sampler3D;varying vec2 vUV;uniform sampler3D voxelXaxisSampler;uniform sampler3D voxelYaxisSampler;uniform sampler3D voxelZaxisSampler;uniform float layer;void main(void) {vec3 coordZ=vec3(vUV.x,vUV.y,layer);float voxelZ=texture(voxelZaxisSampler,coordZ).r;vec3 coordX=vec3(1.0-layer,vUV.y,vUV.x);float voxelX=texture(voxelXaxisSampler,coordX).r;vec3 coordY=vec3(layer,vUV.x,vUV.y);float voxelY=texture(voxelYaxisSampler,coordY).r;float voxel=(voxelX>0.0 || voxelY>0.0 || voxelZ>0.0) ? 1.0 : 0.0;glFragColor=vec4(vec3(voxel),1.0);}";e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},92228:(r,t,e)=>{e.r(t),e.d(t,{iblGenerateVoxelMipPixelShader:()=>o});var n="iblGenerateVoxelMipPixelShader",i=`precision highp float;precision highp sampler3D;varying vec2 vUV;uniform sampler3D srcMip;uniform int layerNum;void main(void) {ivec3 Coords=ivec3(2)*ivec3(gl_FragCoord.x,gl_FragCoord.y,layerNum);uint tex =
|
||
uint(texelFetch(srcMip,Coords+ivec3(0,0,0),0).x>0.0f ? 1u : 0u)
|
||
<< 0u |
|
||
uint(texelFetch(srcMip,Coords+ivec3(1,0,0),0).x>0.0f ? 1u : 0u)
|
||
<< 1u |
|
||
uint(texelFetch(srcMip,Coords+ivec3(0,1,0),0).x>0.0f ? 1u : 0u)
|
||
<< 2u |
|
||
uint(texelFetch(srcMip,Coords+ivec3(1,1,0),0).x>0.0f ? 1u : 0u)
|
||
<< 3u |
|
||
uint(texelFetch(srcMip,Coords+ivec3(0,0,1),0).x>0.0f ? 1u : 0u)
|
||
<< 4u |
|
||
uint(texelFetch(srcMip,Coords+ivec3(1,0,1),0).x>0.0f ? 1u : 0u)
|
||
<< 5u |
|
||
uint(texelFetch(srcMip,Coords+ivec3(0,1,1),0).x>0.0f ? 1u : 0u)
|
||
<< 6u |
|
||
uint(texelFetch(srcMip,Coords+ivec3(1,1,1),0).x>0.0f ? 1u : 0u)
|
||
<< 7u;glFragColor.rgb=vec3(float(tex)/255.0f,0.0f,0.0f);glFragColor.a=1.0;}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},84586:(r,t,e)=>{e.r(t),e.d(t,{iblShadowAccumulationPixelShader:()=>o});var n="iblShadowAccumulationPixelShader",i=`#ifdef GL_ES
|
||
precision mediump float;
|
||
#endif
|
||
varying vec2 vUV;uniform vec4 accumulationParameters;
|
||
#define remanence accumulationParameters.x
|
||
#define resetb accumulationParameters.y
|
||
uniform sampler2D motionSampler;
|
||
uniform sampler2D localPositionSampler;
|
||
uniform sampler2D textureSampler;
|
||
uniform sampler2D oldAccumulationSampler;
|
||
uniform sampler2D prevLocalPositionSampler;
|
||
vec2 max2(vec2 v,vec2 w) { return vec2(max(v.x,w.x),max(v.y,w.y)); }
|
||
void main(void) {bool reset=bool(resetb);vec2 Resolution=vec2(textureSize(textureSampler,0));ivec2 currentPixel=ivec2(vUV*Resolution);vec4 LP=texelFetch(localPositionSampler,currentPixel,0);if (0.0==LP.w) {gl_FragColor=vec4(1.0,0.0,0.0,1.0);return;}
|
||
vec2 velocityColor=texelFetch(motionSampler,currentPixel,0).xy;vec2 prevCoord=vUV+velocityColor;vec3 PrevLP=textureLod(prevLocalPositionSampler,prevCoord,0.0).xyz;vec2 PrevShadows=textureLod(oldAccumulationSampler,prevCoord,0.0).xy;float newShadows=texelFetch(textureSampler,currentPixel,0).x;PrevShadows.y =
|
||
!reset && all(lessThan(abs(prevCoord-vec2(0.5)),vec2(0.5))) &&
|
||
distance(LP.xyz,PrevLP)<5e-2
|
||
? max(PrevShadows.y/(1.0+PrevShadows.y),1.0-remanence)
|
||
: 1.0;PrevShadows=max(vec2(0.0),PrevShadows);gl_FragColor=vec4(mix(PrevShadows.x,newShadows,PrevShadows.y),
|
||
PrevShadows.y,0,1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},45310:(r,t,e)=>{e.r(t),e.d(t,{iblShadowDebugPixelShader:()=>o});var n="iblShadowDebugPixelShader",i=`#ifdef GL_ES
|
||
precision mediump float;
|
||
#endif
|
||
varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D debugSampler;uniform vec4 sizeParams;
|
||
#define offsetX sizeParams.x
|
||
#define offsetY sizeParams.y
|
||
#define widthScale sizeParams.z
|
||
#define heightScale sizeParams.w
|
||
void main(void) {vec2 uv =
|
||
vec2((offsetX+vUV.x)*widthScale,(offsetY+vUV.y)*heightScale);vec4 background=texture2D(textureSampler,vUV);vec4 debugColour=texture2D(debugSampler,vUV);if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {gl_FragColor.rgba=background;} else {gl_FragColor.rgb=mix(debugColour.rgb,background.rgb,0.0);gl_FragColor.a=1.0;}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},41745:(r,t,e)=>{e.r(t),e.d(t,{iblShadowGBufferDebugPixelShader:()=>o});var n="iblShadowGBufferDebugPixelShader",i=`#ifdef GL_ES
|
||
precision mediump float;
|
||
#endif
|
||
varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D prePass_NdcDepth;uniform sampler2D prePass_WorldNormal;uniform sampler2D prePass_Position;uniform sampler2D prePass_LocalPosition;uniform sampler2D prePass_VelocityLinear;uniform vec4 sizeParams;uniform float maxDepth;
|
||
#define offsetX sizeParams.x
|
||
#define offsetY sizeParams.y
|
||
#define widthScale sizeParams.z
|
||
#define heightScale sizeParams.w
|
||
void main(void) {vec2 uv =
|
||
vec2((offsetX+vUV.x)*widthScale,(offsetY+vUV.y)*heightScale);vec4 backgroundColour=texture2D(textureSampler,vUV).rgba;vec4 depth=texture2D(prePass_NdcDepth,vUV);vec4 worldNormal=texture2D(prePass_WorldNormal,vUV);vec4 worldPosition=texture2D(prePass_Position,vUV);vec4 localPosition=texture2D(prePass_LocalPosition,vUV);vec4 velocityLinear=texture2D(prePass_VelocityLinear,vUV);if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {gl_FragColor.rgba=backgroundColour;} else {gl_FragColor.a=1.0;if (uv.x<=0.2) {
|
||
gl_FragColor.rgb=depth.rgb;gl_FragColor.a=1.0;} else if (uv.x<=0.4) {velocityLinear.rg=velocityLinear.rg*0.5+0.5;gl_FragColor.rgb=velocityLinear.rgb;} else if (uv.x<=0.6) {gl_FragColor.rgb=worldPosition.rgb;} else if (uv.x<=0.8) {gl_FragColor.rgb=localPosition.rgb;} else {gl_FragColor.rgb=worldNormal.rgb;}}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},31984:(r,t,e)=>{e.r(t),e.d(t,{iblShadowSpatialBlurPixelShader:()=>o});var n="iblShadowSpatialBlurPixelShader",i=`precision highp sampler2D;
|
||
#define PI 3.1415927
|
||
varying vec2 vUV;uniform sampler2D linearDepthSampler;uniform sampler2D worldNormalSampler;uniform sampler2D textureSampler;uniform vec4 blurParameters;
|
||
#define stridef blurParameters.x
|
||
#define worldScale blurParameters.y
|
||
const float weights[5]=float[5](0.0625,0.25,0.375,0.25,0.0625);const int nbWeights=5;vec2 max2(vec2 v,vec2 w) {return vec2(max(v.x,w.x),max(v.y,w.y));}
|
||
void main(void)
|
||
{vec2 Resolution=vec2(textureSize(linearDepthSampler,0));ivec2 PixelCoord=ivec2(vUV*Resolution);vec3 N=texelFetch(worldNormalSampler,PixelCoord,0).xyz;if (length(N)<0.01) {glFragColor=vec4(1.0,1.0,0.0,1.0);return;}
|
||
float depth=-texelFetch(linearDepthSampler,PixelCoord,0).x;vec2 X=vec2(0.0);for(int y=0; y<nbWeights; ++y) {for(int x=0; x<nbWeights; ++x) {ivec2 Coords=PixelCoord+ int(stridef)*ivec2(x-(nbWeights>>1),y-(nbWeights>>1));vec2 T=texelFetch(textureSampler,Coords,0).xy;float ddepth=-texelFetch(linearDepthSampler,Coords,0).x-depth;vec3 dN=texelFetch(worldNormalSampler,Coords,0).xyz-N;float w=weights[x]*weights[y] *
|
||
exp2(max(-1000.0/(worldScale*worldScale),-0.5) *
|
||
(ddepth*ddepth) -
|
||
1e1*dot(dN,dN));X+=vec2(w*T.x,w);}}
|
||
gl_FragColor=vec4(X.x/X.y,1.0,0.0,1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},53365:(r,t,e)=>{e.r(t),e.d(t,{iblShadowVoxelTracingPixelShader:()=>o});var n="iblShadowVoxelTracingPixelShader",i=`precision highp sampler2D;precision highp sampler3D;
|
||
#define PI 3.1415927
|
||
varying vec2 vUV;
|
||
#define DISABLE_UNIFORMITY_ANALYSIS
|
||
uniform sampler2D depthSampler;uniform sampler2D worldNormalSampler;uniform sampler2D worldPositionSampler;uniform sampler2D blueNoiseSampler;uniform sampler2D icdfxSampler;uniform sampler2D icdfySampler;uniform sampler3D voxelGridSampler;uniform vec4 shadowParameters;
|
||
#define SHADOWdirs shadowParameters.x
|
||
#define SHADOWframe shadowParameters.y
|
||
#define SHADOWdownscale shadowParameters.z
|
||
#define SHADOWenvRot shadowParameters.w
|
||
uniform vec4 offsetDataParameters;
|
||
#define PixelOffset offsetDataParameters.xy
|
||
#define highestMipLevel offsetDataParameters.z
|
||
uniform vec4 sssParameters;
|
||
#define SSSsamples sssParameters.x
|
||
#define SSSstride sssParameters.y
|
||
#define SSSmaxDistance sssParameters.z
|
||
#define SSSthickness sssParameters.w
|
||
uniform vec4 shadowOpacity;uniform mat4 projMtx;uniform mat4 viewMtx;uniform mat4 invProjMtx;uniform mat4 invViewMtx;uniform mat4 wsNormalizationMtx;uniform mat4 invVPMtx;
|
||
#define PI 3.1415927
|
||
#define GOLD 0.618034
|
||
struct AABB3f {vec3 m_min;vec3 m_max;};struct Ray {vec3 orig;vec3 dir;vec3 dir_rcp;float t_min;float t_max;};Ray make_ray(const vec3 origin,const vec3 direction,const float tmin,
|
||
const float tmax) {Ray ray;ray.orig=origin;ray.dir=direction;ray.dir_rcp=1.0f/direction;ray.t_min=tmin;ray.t_max=tmax;return ray;}
|
||
bool ray_box_intersection(const in AABB3f aabb,const in Ray ray,
|
||
out float distance_near,out float distance_far) {vec3 tbot=ray.dir_rcp*(aabb.m_min-ray.orig);vec3 ttop=ray.dir_rcp*(aabb.m_max-ray.orig);vec3 tmin=min(ttop,tbot);vec3 tmax=max(ttop,tbot);distance_near=max(ray.t_min,max(tmin.x,max(tmin.y,tmin.z)));distance_far=min(ray.t_max,min(tmax.x,min(tmax.y,tmax.z)));return distance_near<=distance_far;}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
struct VoxelMarchDiagnosticInfo {float heat;ivec3 voxel_intersect_coords;};
|
||
#endif
|
||
uint hash(uint i) {i ^= i>>16u;i*=0x7FEB352Du;i ^= i>>15u;i*=0x846CA68Bu;i ^= i>>16u;return i;}
|
||
float uint2float(uint i) {return uintBitsToFloat(0x3F800000u | (i>>9u))-1.0;}
|
||
vec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.0*PI;float phi=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}
|
||
vec2 plasticSequence(const uint rstate) {return vec2(uint2float(rstate*3242174889u),
|
||
uint2float(rstate*2447445414u));}
|
||
float goldenSequence(const uint rstate) {return uint2float(rstate*2654435769u);}
|
||
float distanceSquared(vec2 a,vec2 b) {vec2 diff=a-b;return dot(diff,diff);}
|
||
void genTB(const vec3 N,out vec3 T,out vec3 B) {float s=N.z<0.0 ? -1.0 : 1.0;float a=-1.0/(s+N.z);float b=N.x*N.y*a;T=vec3(1.0+s*N.x*N.x*a,s*b,-s*N.x);B=vec3(b,s+N.y*N.y*a,-N.y);}
|
||
int stack[24];
|
||
#define PUSH(i) stack[stackLevel++]=i;
|
||
#define POP() stack[--stackLevel]
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
bool anyHitVoxels(const Ray ray_vs,
|
||
out VoxelMarchDiagnosticInfo voxel_march_diagnostic_info) {
|
||
#else
|
||
bool anyHitVoxels(const Ray ray_vs) {
|
||
#endif
|
||
vec3 invD=ray_vs.dir_rcp;vec3 D=ray_vs.dir;vec3 O=ray_vs.orig;ivec3 negD=ivec3(lessThan(D,vec3(0,0,0)));int voxel0=negD.x | negD.y<<1 | negD.z<<2;vec3 t0=-O*invD,t1=(vec3(1.0)-O)*invD;int maxLod=int(highestMipLevel);int stackLevel=0;
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
uint steps=0u;
|
||
#endif
|
||
PUSH(maxLod<<24);while (stackLevel>0) {int elem=POP();ivec4 Coords =
|
||
ivec4(elem & 0xFF,elem>>8 & 0xFF,elem>>16 & 0xFF,elem>>24);if (Coords.w==0) {
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
voxel_march_diagnostic_info.heat=float(steps)/24.0;
|
||
#endif
|
||
return true;}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
++steps;
|
||
#endif
|
||
float invRes=exp2(float(Coords.w-maxLod));vec3 bbmin=invRes*vec3(Coords.xyz+negD);vec3 bbmax=invRes*vec3(Coords.xyz-negD+ivec3(1));vec3 mint=mix(t0,t1,bbmin);vec3 maxt=mix(t0,t1,bbmax);vec3 midt=0.5*(mint+maxt);mint.x=max(0.0,mint.x);midt.x=max(0.0,midt.x);int nodeMask=int(
|
||
round(texelFetch(voxelGridSampler,Coords.xyz,Coords.w).x*255.0));Coords.w--;int voxelBit=voxel0;Coords.xyz=(Coords.xyz<<1)+negD;int packedCoords =
|
||
Coords.x | Coords.y<<8 | Coords.z<<16 | Coords.w<<24;if (max(mint.x,max(mint.y,mint.z))<min(midt.x,min(midt.y,midt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(mint.y,mint.z))<min(maxt.x,min(midt.y,midt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(midt.y,mint.z))<min(maxt.x,min(maxt.y,midt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(midt.y,mint.z))<min(midt.x,min(maxt.y,midt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);voxelBit ^= 0x4;packedCoords ^= 0x10000;if (max(mint.x,max(midt.y,midt.z))<min(midt.x,min(maxt.y,maxt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(midt.y,midt.z))<min(maxt.x,min(maxt.y,maxt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(mint.y,midt.z))<min(maxt.x,min(midt.y,maxt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(mint.y,midt.z))<min(midt.x,min(midt.y,maxt.z)) &&
|
||
(1<<voxelBit & nodeMask) != 0)
|
||
PUSH(packedCoords);}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
voxel_march_diagnostic_info.heat=float(steps)/24.0;
|
||
#endif
|
||
return false;}
|
||
float screenSpaceShadow(vec3 csOrigin,vec3 csDirection,vec2 csZBufferSize,
|
||
float nearPlaneZ,float noise) {float csZDir=projMtx[2][2]>0.0 ? 1.0 : -1.0;float ssSamples=SSSsamples;float ssMaxDist=SSSmaxDistance;float ssStride=SSSstride;float ssThickness=SSSthickness;float rayLength =
|
||
csZDir*(csOrigin.z+ssMaxDist*csDirection.z)<csZDir*nearPlaneZ
|
||
?
|
||
(nearPlaneZ-csOrigin.z)/csDirection.z
|
||
: ssMaxDist;vec3 csEndPoint=csOrigin+rayLength*csDirection;vec4 H0=projMtx*vec4(csOrigin,1.0);vec4 H1=projMtx*vec4(csEndPoint,1.0);
|
||
#ifndef IS_NDC_HALF_ZRANGE
|
||
float Z0=(0.5*H0.z/H0.w+0.5);float Z1=(0.5*H1.z/H1.w+0.5);
|
||
#else
|
||
float Z0=(H0.z/H0.w);float Z1=(H1.z/H1.w);
|
||
#endif
|
||
vec2 P0=csZBufferSize*(0.5*H0.xy/H0.w+0.5);vec2 P1=csZBufferSize*(0.5*H1.xy/H1.w+0.5);P1+=vec2(distanceSquared(P0,P1)<0.0001 ? 0.01 : 0.0);vec2 delta=P1-P0;bool permute=false;if (abs(delta.x)<abs(delta.y)) {permute=true;P0=P0.yx;P1=P1.yx;delta=delta.yx;}
|
||
float stepDirection=sign(delta.x);float invdx=stepDirection/delta.x;vec2 dP=ssStride*vec2(stepDirection,invdx*delta.y);float dZ=ssStride*invdx*(Z1-Z0);float opacity=0.0;vec2 P=P0+noise*dP;float Z=Z0+noise*dZ;float end=P1.x*stepDirection;Z+=dZ;for (float stepCount=0.0;opacity<1.0 && P.x*stepDirection<end && stepCount<ssSamples;stepCount++,P+=dP,
|
||
Z+=dZ) {
|
||
ivec2 coords=ivec2(permute ? P.yx : P);float sceneDepth=texelFetch(depthSampler,coords,0).x;float thicknessScale=pow(1.0-sceneDepth,1.6);opacity +=
|
||
max(opacity,step(Z+dZ,sceneDepth+thicknessScale*ssThickness) *
|
||
step(sceneDepth,Z));}
|
||
return opacity;}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
float voxelShadow(vec3 wsOrigin,vec3 wsDirection,vec3 wsNormal,
|
||
vec2 DitherNoise,
|
||
out VoxelMarchDiagnosticInfo voxel_march_diagnostic_info) {
|
||
#else
|
||
float voxelShadow(vec3 wsOrigin,vec3 wsDirection,vec3 wsNormal,
|
||
vec2 DitherNoise) {
|
||
#endif
|
||
float vxResolution=float(textureSize(voxelGridSampler,0).x);vec3 T,B;genTB(wsDirection,T,B);vec2 DitherXY=sqrt(DitherNoise.x)*vec2(cos(2.0*PI*DitherNoise.y),
|
||
sin(2.0*PI*DitherNoise.y));vec3 Dithering =
|
||
(2.0*wsNormal+3.0*wsDirection+DitherXY.x*T+DitherXY.y*B) /
|
||
vxResolution;vec3 O=0.5*wsOrigin+0.5+Dithering;Ray ray_vs=make_ray(O,wsDirection,0.0,10.0);AABB3f voxel_aabb;voxel_aabb.m_min=vec3(0);voxel_aabb.m_max=vec3(1);float near,far;if (!ray_box_intersection(voxel_aabb,ray_vs,near,far))
|
||
return 0.0;ray_vs.t_min=max(ray_vs.t_min,near);ray_vs.t_max=min(ray_vs.t_max,far);
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
return anyHitVoxels(ray_vs,voxel_march_diagnostic_info) ? 1.0f : 0.0f;
|
||
#else
|
||
return anyHitVoxels(ray_vs) ? 1.0f : 0.0f;
|
||
#endif
|
||
}
|
||
void main(void) {uint nbDirs=uint(SHADOWdirs);uint frameId=uint(SHADOWframe);int downscale=int(SHADOWdownscale);float envRot=SHADOWenvRot;vec2 Resolution=vec2(textureSize(depthSampler,0));ivec2 currentPixel=ivec2(vUV*Resolution);ivec2 PixelCoord=ivec2(vec2(currentPixel*downscale)+PixelOffset.xy);uint GlobalIndex =
|
||
(frameId*uint(Resolution.y)+uint(PixelCoord.y))*uint(Resolution.x) +
|
||
uint(PixelCoord.x);vec3 N=texelFetch(worldNormalSampler,PixelCoord,0).xyz;N=N*vec3(2.0)-vec3(1.0);if (length(N)<0.01) {glFragColor=vec4(1.0,1.0,0.0,1.0);return;}
|
||
float normalizedRotation=envRot/(2.0*PI);float depth=texelFetch(depthSampler,PixelCoord,0).x;
|
||
#ifndef IS_NDC_HALF_ZRANGE
|
||
depth=depth*2.0-1.0;
|
||
#endif
|
||
vec2 temp=(vec2(PixelCoord)+vec2(0.5))*2.0/Resolution-vec2(1.0);vec2 temp2=vUV*vec2(2.0)-vec2(1.0);vec4 VP=invProjMtx*vec4(temp.x,-temp.y,depth,1.0);VP/=VP.w;N=normalize(N);vec3 noise=texelFetch(blueNoiseSampler,PixelCoord & 0xFF,0).xyz;noise.z=fract(noise.z+goldenSequence(frameId*nbDirs));
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
float heat=0.0f;
|
||
#endif
|
||
float shadowAccum=0.0;for (uint i=0u; i<nbDirs; i++) {uint dirId=nbDirs*GlobalIndex+i;vec4 L;{vec2 r=plasticSequence(frameId*nbDirs+i);r=fract(r+vec2(2.0)*abs(noise.xy-vec2(0.5)));vec2 T;T.x=textureLod(icdfxSampler,vec2(r.x,0.0),0.0).x;T.y=textureLod(icdfySampler,vec2(T.x,r.y),0.0).x;T.x-=normalizedRotation;L=vec4(uv_to_normal(T),0);}
|
||
float edge_tint_const=-0.001;float cosNL=dot(N,L.xyz);float opacity=cosNL<edge_tint_const ? 1.0 : 0.0;if (cosNL>edge_tint_const) {vec4 VP2=VP;VP2.y*=-1.0;vec4 unormWP=invViewMtx*VP2;vec3 WP=(wsNormalizationMtx*unormWP).xyz;vec2 vxNoise =
|
||
vec2(uint2float(hash(dirId*2u)),uint2float(hash(dirId*2u+1u)));
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
VoxelMarchDiagnosticInfo voxel_march_diagnostic_info;opacity=max(opacity,
|
||
shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise,
|
||
voxel_march_diagnostic_info));heat+=voxel_march_diagnostic_info.heat;
|
||
#else
|
||
opacity =
|
||
max(opacity,shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise));
|
||
#endif
|
||
vec3 VL=(viewMtx*L).xyz;float nearPlaneZ =
|
||
-projMtx[3][2]/projMtx[2][2];
|
||
float ssShadow=shadowOpacity.y *
|
||
screenSpaceShadow(VP2.xyz,VL,Resolution,nearPlaneZ,
|
||
abs(2.0*noise.z-1.0));opacity=max(opacity,ssShadow);shadowAccum+=min(1.0-opacity,smoothstep(-0.1,0.2,cosNL));} else {shadowAccum+=min(1.0-opacity,smoothstep(-0.1,0.2,cosNL));}
|
||
noise.z=fract(noise.z+GOLD);}
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
gl_FragColor =
|
||
vec4(shadowAccum/float(nbDirs),heat/float(nbDirs),0.0,1.0);
|
||
#else
|
||
gl_FragColor=vec4(shadowAccum/float(nbDirs),0.0,0.0,1.0);
|
||
#endif
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},12191:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsCdfxPixelShader:()=>o});var n="iblShadowsCdfxPixelShader",i=`precision highp sampler2D;
|
||
#define PI 3.1415927
|
||
varying vec2 vUV;uniform sampler2D cdfy;void main(void) {ivec2 cdfyRes=textureSize(cdfy,0);ivec2 currentPixel=ivec2(gl_FragCoord.xy);float cdfx=0.0;for (int x=1; x<=currentPixel.x; x++) {cdfx+=texelFetch(cdfy,ivec2(x-1,cdfyRes.y-1),0).x;}
|
||
gl_FragColor=vec4(vec3(cdfx),1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},31898:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsCdfyPixelShader:()=>o});var n="iblShadowsCdfyPixelShader",i=`precision highp sampler2D;precision highp samplerCube;
|
||
#define PI 3.1415927
|
||
varying vec2 vUV;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
uniform samplerCube iblSource;
|
||
#else
|
||
uniform sampler2D iblSource;
|
||
#endif
|
||
uniform int iblHeight;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
vec3 equirectangularToCubemapDirection(vec2 uv) {float longitude=uv.x*2.0*PI-PI;float latitude=PI*0.5-uv.y*PI;vec3 direction;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}
|
||
float fetchCube(vec2 uv) {vec3 direction=equirectangularToCubemapDirection(uv);return sin(PI*uv.y)*dot(textureCubeLodEXT(iblSource,direction,0.0).rgb,
|
||
vec3(0.3,0.6,0.1));}
|
||
#else
|
||
float fetchPanoramic(ivec2 Coords,float envmapHeight) {return sin(PI*(float(Coords.y)+0.5)/envmapHeight) *
|
||
dot(texelFetch(iblSource,Coords,0).rgb,vec3(0.3,0.6,0.1));}
|
||
#endif
|
||
void main(void) {ivec2 coords=ivec2(gl_FragCoord.x,gl_FragCoord.y);float cdfy=0.0;for (int y=1; y<=coords.y; y++) {
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
vec2 uv=vec2(vUV.x,(float(y-1)+0.5)/float(iblHeight));cdfy+=fetchCube(uv);
|
||
#else
|
||
cdfy+=fetchPanoramic(ivec2(coords.x,y-1),float(iblHeight));
|
||
#endif
|
||
}
|
||
gl_FragColor=vec4(cdfy,0.0,0.0,1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},41037:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsCombinePixelShader:()=>o});var n="iblShadowsCombinePixelShader",i=`precision highp float;varying vec2 vUV;uniform sampler2D sceneTexture;uniform sampler2D textureSampler;uniform float shadowOpacity;void main(void)
|
||
{vec3 color=texture(sceneTexture,vUV).rgb;vec3 shadow=texture(textureSampler,vUV).rgb;float shadowValue=mix(1.0,shadow.x,shadowOpacity);gl_FragColor=vec4(color*shadowValue,1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},41888:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsIcdfxPixelShader:()=>o});var n="iblShadowsIcdfxPixelShader",i=`precision highp sampler2D;
|
||
#define PI 3.1415927
|
||
varying vec2 vUV;uniform sampler2D cdfx;float fetchCDF(int x) {return texelFetch(cdfx,ivec2(x,0),0).x;}
|
||
float bisect(int size,float targetValue)
|
||
{int a=0,b=size-1;while (b-a>1) {int c=a+b>>1;if (fetchCDF(c)<targetValue)
|
||
a=c;else
|
||
b=c;}
|
||
return mix(float(a),float(b),(targetValue-fetchCDF(a))/(fetchCDF(b)-fetchCDF(a)))/float(size-1);}
|
||
void main(void) {ivec2 cdfSize=textureSize(cdfx,0);int cdfWidth=cdfSize.x;int icdfWidth=cdfWidth-1;ivec2 currentPixel=ivec2(gl_FragCoord.xy);if (currentPixel.x==0)
|
||
{gl_FragColor=vec4(0.0);}
|
||
else if (currentPixel.x==icdfWidth-1) {gl_FragColor=vec4(1.0);} else {float targetValue=fetchCDF(cdfWidth-1)*vUV.x;gl_FragColor=vec4(vec3(bisect(cdfWidth,targetValue)),1.0);}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},99381:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsIcdfyPixelShader:()=>o});var n="iblShadowsIcdfyPixelShader",i=`precision highp sampler2D;
|
||
#define PI 3.1415927
|
||
varying vec2 vUV;uniform sampler2D cdfy;float fetchCDF(int y,int invocationId) {return texelFetch(cdfy,ivec2(invocationId,y),0).x;}
|
||
float bisect(int size,float targetValue,int invocationId)
|
||
{int a=0,b=size-1;while (b-a>1) {int c=a+b>>1;if (fetchCDF(c,invocationId)<targetValue)
|
||
a=c;else
|
||
b=c;}
|
||
return mix(float(a),float(b),(targetValue-fetchCDF(a,invocationId))/(fetchCDF(b,invocationId)-fetchCDF(a,invocationId)))/float(size-1);}
|
||
void main(void) {ivec2 cdfSize=textureSize(cdfy,0);int cdfHeight=cdfSize.y;ivec2 currentPixel=ivec2(gl_FragCoord.xy);if (currentPixel.y==0)
|
||
{gl_FragColor=vec4(0.0);}
|
||
else if (currentPixel.y==cdfHeight-2) {gl_FragColor=vec4(1.0);} else {float targetValue=fetchCDF(cdfHeight-1,currentPixel.x)*vUV.y;gl_FragColor=vec4(vec3(bisect(cdfHeight,targetValue,currentPixel.x)),1.0);}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},54428:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsImportanceSamplingDebugPixelShader:()=>o});var n="iblShadowsImportanceSamplingDebugPixelShader",i=`precision highp samplerCube;
|
||
#define PI 3.1415927
|
||
varying vec2 vUV;uniform sampler2D cdfy;uniform sampler2D icdfy;uniform sampler2D cdfx;uniform sampler2D icdfx;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
uniform samplerCube iblSource;
|
||
#else
|
||
uniform sampler2D iblSource;
|
||
#endif
|
||
uniform sampler2D textureSampler;
|
||
#define cdfyVSize 0.4
|
||
#define cdfxVSize 0.1
|
||
#define cdfyHSize 0.5
|
||
uniform vec4 sizeParams;
|
||
#define offsetX sizeParams.x
|
||
#define offsetY sizeParams.y
|
||
#define widthScale sizeParams.z
|
||
#define heightScale sizeParams.w
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
vec3 equirectangularToCubemapDirection(vec2 uv) {float longitude=uv.x*2.0*PI-PI;float latitude=PI*0.5-uv.y*PI;vec3 direction;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}
|
||
#endif
|
||
void main(void) {vec3 colour=vec3(0.0);vec2 uv =
|
||
vec2((offsetX+vUV.x)*widthScale,(offsetY+vUV.y)*heightScale);vec3 backgroundColour=texture2D(textureSampler,vUV).rgb;const float iblStart=1.0-cdfyVSize;const float cdfyStart=1.0-2.0*cdfyVSize;const float cdfxStart=1.0-2.0*cdfyVSize-cdfxVSize;const float icdfxStart=1.0-2.0*cdfyVSize-2.0*cdfxVSize;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
vec3 direction=equirectangularToCubemapDirection(
|
||
(uv-vec2(0.0,iblStart))*vec2(1.0,1.0/cdfyVSize));vec3 iblColour=textureCubeLodEXT(iblSource,direction,0.0).rgb;
|
||
#else
|
||
vec3 iblColour=texture2D(iblSource,(uv-vec2(0.0,iblStart)) *
|
||
vec2(1.0,1.0/cdfyVSize))
|
||
.rgb;
|
||
#endif
|
||
float cdfyColour =
|
||
texture2D(cdfy,(uv-vec2(0.0,cdfyStart))*vec2(2.0,1.0/cdfyVSize))
|
||
.r;float icdfyColour =
|
||
texture2D(icdfy,(uv-vec2(0.5,cdfyStart))*vec2(2.0,1.0/cdfyVSize))
|
||
.r;float cdfxColour =
|
||
texture2D(cdfx,(uv-vec2(0.0,cdfxStart))*vec2(1.0,1.0/cdfxVSize))
|
||
.r;float icdfxColour=texture2D(icdfx,(uv-vec2(0.0,icdfxStart)) *
|
||
vec2(1.0,1.0/cdfxVSize))
|
||
.r;if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {colour=backgroundColour;} else if (uv.y>iblStart) {colour+=iblColour;} else if (uv.y>cdfyStart && uv.x<0.5) {colour.r+=0.003*cdfyColour;} else if (uv.y>cdfyStart && uv.x>0.5) {colour.r+=icdfyColour;} else if (uv.y>cdfxStart) {colour.r+=0.00003*cdfxColour;} else if (uv.y>icdfxStart) {colour.r+=icdfxColour;}
|
||
gl_FragColor=vec4(colour,1.0);glFragColor.rgb=mix(gl_FragColor.rgb,backgroundColour,0.5);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},81487:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGridPixelShader:()=>o});var n="iblVoxelGridPixelShader",i=`precision highp float;layout(location=0) out highp float glFragData[MAX_DRAW_BUFFERS];varying vec3 vNormalizedPosition;uniform float nearPlane;uniform float farPlane;uniform float stepSize;void main(void) {vec3 normPos=vNormalizedPosition.xyz;if (normPos.z<nearPlane || normPos.z>farPlane) {discard;}
|
||
glFragData[0]=normPos.z<nearPlane+stepSize ? 1.0 : 0.0;glFragData[1]=normPos.z>=nearPlane+stepSize && normPos.z<nearPlane+2.0*stepSize ? 1.0 : 0.0;glFragData[2]=normPos.z>=nearPlane+2.0*stepSize && normPos.z<nearPlane+3.0*stepSize ? 1.0 : 0.0;glFragData[3]=normPos.z>=nearPlane+3.0*stepSize && normPos.z<nearPlane+4.0*stepSize ? 1.0 : 0.0;
|
||
#if MAX_DRAW_BUFFERS>4
|
||
glFragData[4]=normPos.z>=nearPlane+4.0*stepSize && normPos.z<nearPlane+5.0*stepSize ? 1.0 : 0.0;glFragData[5]=normPos.z>=nearPlane+5.0*stepSize && normPos.z<nearPlane+6.0*stepSize ? 1.0 : 0.0;glFragData[6]=normPos.z>=nearPlane+6.0*stepSize && normPos.z<nearPlane+7.0*stepSize ? 1.0 : 0.0;glFragData[7]=normPos.z>=nearPlane+7.0*stepSize && normPos.z<nearPlane+8.0*stepSize ? 1.0 : 0.0;
|
||
#endif
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},90453:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGridVertexShader:()=>o});var n="iblVoxelGridVertexShader",i=`attribute vec3 position;attribute vec3 normal;varying vec3 vNormalizedPosition;uniform mat4 world;uniform mat4 invWorldScale;uniform mat4 viewMatrix;void main(void) {gl_Position=viewMatrix*invWorldScale*world*vec4(position,1.);vNormalizedPosition.xyz=gl_Position.xyz*0.5+0.5;
|
||
#ifdef IS_NDC_HALF_ZRANGE
|
||
gl_Position.z=gl_Position.z*0.5+0.5;
|
||
#endif
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},76933:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGrid2dArrayDebugPixelShader:()=>o});var n="iblVoxelGrid2dArrayDebugPixelShader",i="precision highp sampler2DArray;varying vec2 vUV;uniform sampler2DArray voxelTexture;uniform sampler2D textureSampler;uniform int slice;void main(void) {ivec3 size=textureSize(voxelTexture,0);float dimension=sqrt(float(size.z));vec2 samplePos=fract(vUV.xy*vec2(dimension));int sampleIndex=int(floor(vUV.x*float(dimension))+floor(vUV.y*float(dimension))*dimension);glFragColor.rgb=texture(voxelTexture,vec3(samplePos.xy,sampleIndex)).rrr;glFragColor.a=1.0;glFragColor.rgb+=texture(textureSampler,vUV.xy).rgb;}";e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},48533:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGrid3dDebugPixelShader:()=>o});var n="iblVoxelGrid3dDebugPixelShader",i=`precision highp sampler3D;varying vec2 vUV;uniform sampler3D voxelTexture;uniform sampler2D voxelSlabTexture;uniform sampler2D textureSampler;uniform vec4 sizeParams;
|
||
#define offsetX sizeParams.x
|
||
#define offsetY sizeParams.y
|
||
#define widthScale sizeParams.z
|
||
#define heightScale sizeParams.w
|
||
uniform float mipNumber;void main(void) {vec2 uv =
|
||
vec2((offsetX+vUV.x)*widthScale,(offsetY+vUV.y)*heightScale);vec4 background=texture2D(textureSampler,vUV);vec4 voxelSlab=texture2D(voxelSlabTexture,vUV);ivec3 size=textureSize(voxelTexture,int(mipNumber));float dimension=ceil(sqrt(float(size.z)));vec2 samplePos=fract(uv.xy*vec2(dimension));int sampleIndex=int(floor(uv.x*float(dimension)) +
|
||
floor(uv.y*float(dimension))*dimension);float mip_separator=0.0;if (samplePos.x<0.01 || samplePos.y<0.01) {mip_separator=1.0;}
|
||
bool outBounds=sampleIndex>size.z-1 ? true : false;sampleIndex=clamp(sampleIndex,0,size.z-1);ivec2 samplePosInt=ivec2(samplePos.xy*vec2(size.xy));vec3 voxel=texelFetch(voxelTexture,
|
||
ivec3(samplePosInt.x,samplePosInt.y,sampleIndex),
|
||
int(mipNumber))
|
||
.rgb;if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {gl_FragColor.rgba=background;} else {if (outBounds) {voxel=vec3(0.15,0.0,0.0);} else {if (voxel.r>0.001) {voxel.g=1.0;}
|
||
voxel.r+=mip_separator;}
|
||
glFragColor.rgb=mix(background.rgb,voxelSlab.rgb,voxelSlab.a)+voxel;glFragColor.a=1.0;}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},77142:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelSlabDebugPixelShader:()=>o});var n="iblVoxelSlabDebugPixelShader",i=`precision highp float;varying vec3 vNormalizedPosition;uniform float nearPlane;uniform float farPlane;uniform float stepSize;void main(void) {vec3 normPos=vNormalizedPosition.xyz;float chunkSize=stepSize*float(MAX_DRAW_BUFFERS);float numChunks=1.0/chunkSize;float positionInChunk=fract(normPos.z/chunkSize);float slab=floor(positionInChunk*float(MAX_DRAW_BUFFERS)) /
|
||
float(MAX_DRAW_BUFFERS);if (normPos.x<0.0 || normPos.y<0.0 || normPos.z<0.0 ||
|
||
normPos.x>1.0 || normPos.y>1.0 || normPos.z>1.0) {gl_FragColor=vec4(0.0,0.0,0.0,0.0);} else {gl_FragColor=vec4(slab,0.0,0.0,0.75);}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},99032:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelSlabDebugVertexShader:()=>o});var n="iblVoxelSlabDebugVertexShader",i="attribute vec3 position;varying vec3 vNormalizedPosition;uniform mat4 world;uniform mat4 invWorldScale;uniform mat4 cameraViewMatrix;uniform mat4 projection;uniform mat4 viewMatrix;void main(void) {vec4 worldPosition=(world*vec4(position,1.));gl_Position=projection*cameraViewMatrix*worldPosition;vNormalizedPosition=(viewMatrix*invWorldScale*worldPosition).rgb;vNormalizedPosition.xyz=vNormalizedPosition.xyz*vec3(0.5)+vec3(0.5);}";e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},14830:(r,t,e)=>{e.r(t),e.d(t,{imageProcessingPixelShader:()=>a});var n=e(98519),i=(e(59581),e(75334),e(40688),"imageProcessingPixelShader"),o=`varying vec2 vUV;uniform sampler2D textureSampler;
|
||
#include<imageProcessingDeclaration>
|
||
#include<helperFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec4 result=texture2D(textureSampler,vUV);
|
||
#ifdef IMAGEPROCESSING
|
||
#ifndef FROMLINEARSPACE
|
||
result.rgb=toLinearSpace(result.rgb);
|
||
#endif
|
||
result=applyImageProcessing(result);
|
||
#else
|
||
#ifdef FROMLINEARSPACE
|
||
result=applyImageProcessing(result);
|
||
#endif
|
||
#endif
|
||
gl_FragColor=result;}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},42015:(r,t,e)=>{e.r(t),e.d(t,{kernelBlurPixelShader:()=>s});var n=e(98519),i=(e(67303),e(78531),"kernelBlurFragment");n.l.IncludesShadersStore[i]=`#ifdef DOF
|
||
factor=sampleCoC(sampleCoord{X});
|
||
computedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight;
|
||
#else
|
||
computedWeight=KERNEL_WEIGHT{X};
|
||
#endif
|
||
#ifdef PACKEDFLOAT
|
||
blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
|
||
#else
|
||
blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
|
||
#endif
|
||
`,n.l.IncludesShadersStore.kernelBlurFragment2=`#ifdef DOF
|
||
factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight;
|
||
#else
|
||
computedWeight=KERNEL_DEP_WEIGHT{X};
|
||
#endif
|
||
#ifdef PACKEDFLOAT
|
||
blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
|
||
#else
|
||
blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
|
||
#endif
|
||
`;var o="kernelBlurPixelShader",a=`uniform sampler2D textureSampler;uniform vec2 delta;varying vec2 sampleCenter;
|
||
#ifdef DOF
|
||
uniform sampler2D circleOfConfusionSampler;float sampleCoC(in vec2 offset) {float coc=texture2D(circleOfConfusionSampler,offset).r;return coc; }
|
||
#endif
|
||
#include<kernelBlurVaryingDeclaration>[0..varyingCount]
|
||
#ifdef PACKEDFLOAT
|
||
#include<packingFunctions>
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{float computedWeight=0.0;
|
||
#ifdef PACKEDFLOAT
|
||
float blend=0.;
|
||
#else
|
||
vec4 blend=vec4(0.);
|
||
#endif
|
||
#ifdef DOF
|
||
float sumOfWeights=CENTER_WEIGHT;
|
||
float factor=0.0;
|
||
#ifdef PACKEDFLOAT
|
||
blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
|
||
#else
|
||
blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
|
||
#endif
|
||
#endif
|
||
#include<kernelBlurFragment>[0..varyingCount]
|
||
#include<kernelBlurFragment2>[0..depCount]
|
||
#ifdef PACKEDFLOAT
|
||
gl_FragColor=pack(blend);
|
||
#else
|
||
gl_FragColor=blend;
|
||
#endif
|
||
#ifdef DOF
|
||
gl_FragColor/=sumOfWeights;
|
||
#endif
|
||
}`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},41182:(r,t,e)=>{e.r(t),e.d(t,{kernelBlurVertexShader:()=>s});var n=e(98519),i=(e(67303),"kernelBlurVertex");n.l.IncludesShadersStore[i]="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var o="kernelBlurVertexShader",a=`attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter;
|
||
#include<kernelBlurVaryingDeclaration>[0..varyingCount]
|
||
const vec2 madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
sampleCenter=(position*madd+madd);
|
||
#include<kernelBlurVertex>[0..varyingCount]
|
||
gl_Position=vec4(position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},94567:(r,t,e)=>{e.r(t),e.d(t,{layerPixelShader:()=>a});var n=e(98519),i=(e(75334),"layerPixelShader"),o=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec4 color;
|
||
#include<helperFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
vec4 baseColor=texture2D(textureSampler,vUV);
|
||
#ifdef LINEAR
|
||
baseColor.rgb=toGammaSpace(baseColor.rgb);
|
||
#endif
|
||
#ifdef ALPHATEST
|
||
if (baseColor.a<0.4)
|
||
discard;
|
||
#endif
|
||
gl_FragColor=baseColor*color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},79645:(r,t,e)=>{e.r(t),e.d(t,{layerVertexShader:()=>o});var n="layerVertexShader",i=`attribute vec2 position;uniform vec2 scale;uniform vec2 offset;uniform mat4 textureMatrix;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vec2 shiftedPosition=position*scale+offset;vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));gl_Position=vec4(shiftedPosition,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},25188:(r,t,e)=>{e.r(t),e.d(t,{lensFlarePixelShader:()=>o});var n="lensFlarePixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec4 color;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
vec4 baseColor=texture2D(textureSampler,vUV);gl_FragColor=baseColor*color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},51006:(r,t,e)=>{e.r(t),e.d(t,{lensFlareVertexShader:()=>o});var n="lensFlareVertexShader",i=`attribute vec2 position;uniform mat4 viewportMatrix;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vUV=position*madd+madd;gl_Position=viewportMatrix*vec4(position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},97468:(r,t,e)=>{e.r(t),e.d(t,{linePixelShader:()=>a});var n=e(98519),i=(e(27003),e(59262),e(13088),e(39643),"linePixelShader"),o=`#include<clipPlaneFragmentDeclaration>
|
||
uniform vec4 color;
|
||
#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<logDepthFragment>
|
||
#include<clipPlaneFragment>
|
||
gl_FragColor=color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},60738:(r,t,e)=>{e.r(t),e.d(t,{lineVertexShader:()=>a});var n=e(98519);n.l.IncludesShadersStore.lineVertexDeclaration=`uniform mat4 viewProjection;
|
||
#define ADDITIONAL_VERTEX_DECLARATION
|
||
`,e(50851),e(56174),n.l.IncludesShadersStore.lineUboDeclaration=`layout(std140,column_major) uniform;
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
`,e(38615),e(85637),e(59262),e(35397),e(83057),e(56458);var i="lineVertexShader",o=`#include<__decl__lineVertex>
|
||
#include<instancesDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
attribute vec3 position;attribute vec4 normal;uniform float width;uniform float aspectRatio;
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
#include<instancesVertex>
|
||
mat4 worldViewProjection=viewProjection*finalWorld;vec4 viewPosition=worldViewProjection*vec4(position,1.0);vec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);vec2 currentScreen=viewPosition.xy/viewPosition.w;vec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;currentScreen.x*=aspectRatio;nextScreen.x*=aspectRatio;vec2 dir=normalize(nextScreen-currentScreen);vec2 normalDir=vec2(-dir.y,dir.x);normalDir*=width/2.0;normalDir.x/=aspectRatio;vec4 offset=vec4(normalDir*normal.w,0.0,0.0);gl_Position=viewPosition+offset;
|
||
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
|
||
vec4 worldPos=finalWorld*vec4(position,1.0);
|
||
#include<clipPlaneVertex>
|
||
#endif
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},69425:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererPixelShader:()=>o});var n="meshUVSpaceRendererPixelShader",i=`precision highp float;varying vec2 vDecalTC;uniform sampler2D textureSampler;void main(void) {if (vDecalTC.x<0. || vDecalTC.x>1. || vDecalTC.y<0. || vDecalTC.y>1.) {discard;}
|
||
gl_FragColor=texture2D(textureSampler,vDecalTC);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},34855:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererVertexShader:()=>a});var n=e(98519),i=(e(36470),e(64400),e(24444),e(67369),e(38615),e(58266),e(84589),e(35397),e(76898),e(49334),"meshUVSpaceRendererVertexShader"),o=`precision highp float;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;uniform mat4 projMatrix;varying vec2 vDecalTC;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesDeclaration>
|
||
void main(void) {vec3 positionUpdated=position;vec3 normalUpdated=normal;
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);mat3 normWorldSM=mat3(finalWorld);vec3 vNormalW;
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normWorldSM=transposeMat3(inverseMat3(normWorldSM));
|
||
#endif
|
||
vNormalW=normalize(normWorldSM*normalUpdated);
|
||
#endif
|
||
vec3 normalView=normalize((projMatrix*vec4(vNormalW,0.0)).xyz);vec3 decalTC=(projMatrix*worldPos).xyz;vDecalTC=decalTC.xy;gl_Position=vec4(uv*2.0-1.0,normalView.z>0.0 ? 2. : decalTC.z,1.0);}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},79444:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererFinaliserPixelShader:()=>o});var n="meshUVSpaceRendererFinaliserPixelShader",i=`precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D maskTextureSampler;uniform vec2 textureSize;void main() {vec4 mask=texture2D(maskTextureSampler,vUV).rgba;if (mask.r>0.5) {gl_FragColor=texture2D(textureSampler,vUV);} else {vec2 texelSize=4.0/textureSize;vec2 uv_p01=vUV+vec2(-1.0,0.0)*texelSize;vec2 uv_p21=vUV+vec2(1.0,0.0)*texelSize;vec2 uv_p10=vUV+vec2(0.0,-1.0)*texelSize;vec2 uv_p12=vUV+vec2(0.0,1.0)*texelSize;float mask_p01=texture2D(maskTextureSampler,uv_p01).r;float mask_p21=texture2D(maskTextureSampler,uv_p21).r;float mask_p10=texture2D(maskTextureSampler,uv_p10).r;float mask_p12=texture2D(maskTextureSampler,uv_p12).r;vec4 col=vec4(0.0,0.0,0.0,0.0);float total_weight=0.0;if (mask_p01>0.5) {col+=texture2D(textureSampler,uv_p01);total_weight+=1.0;}
|
||
if (mask_p21>0.5) {col+=texture2D(textureSampler,uv_p21);total_weight+=1.0;}
|
||
if (mask_p10>0.5) {col+=texture2D(textureSampler,uv_p10);total_weight+=1.0;}
|
||
if (mask_p12>0.5) {col+=texture2D(textureSampler,uv_p12);total_weight+=1.0;}
|
||
if (total_weight>0.0) {gl_FragColor=col/total_weight;} else {gl_FragColor=col;}}}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},7726:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererFinaliserVertexShader:()=>o});var n="meshUVSpaceRendererFinaliserVertexShader",i=`precision highp float;attribute vec3 position;attribute vec2 uv;uniform mat4 worldViewProjection;varying vec2 vUV;void main() {gl_Position=worldViewProjection*vec4(position,1.0);vUV=uv;}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},30004:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererMaskerPixelShader:()=>o});var n="meshUVSpaceRendererMaskerPixelShader",i=`varying vec2 vUV;void main(void) {gl_FragColor=vec4(1.0,1.0,1.0,1.0);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},86254:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererMaskerVertexShader:()=>o});var n="meshUVSpaceRendererMaskerVertexShader",i="attribute vec2 uv;varying vec2 vUV;void main(void) {gl_Position=vec4(vec2(uv.x,uv.y)*2.0-1.0,0.,1.0);vUV=uv;}";e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},35007:(r,t,e)=>{e.r(t),e.d(t,{motionBlurPixelShader:()=>o});var n="motionBlurPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform float motionStrength;uniform float motionScale;uniform vec2 screenSize;
|
||
#ifdef OBJECT_BASED
|
||
uniform sampler2D velocitySampler;
|
||
#else
|
||
uniform sampler2D depthSampler;uniform mat4 inverseViewProjection;uniform mat4 prevViewProjection;uniform mat4 projection;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{
|
||
#ifdef GEOMETRY_SUPPORTED
|
||
#ifdef OBJECT_BASED
|
||
vec2 texelSize=1.0/screenSize;vec4 velocityColor=texture2D(velocitySampler,vUV);velocityColor.rg=velocityColor.rg*2.0-vec2(1.0);vec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0))*velocityColor.a;velocity*=motionScale*motionStrength;float speed=length(velocity/texelSize);int samplesCount=int(clamp(speed,1.0,SAMPLES));velocity=normalize(velocity)*texelSize;float hlim=float(-samplesCount)*0.5+0.5;vec4 result=texture2D(textureSampler,vUV);for (int i=1; i<int(SAMPLES); ++i)
|
||
{if (i>=samplesCount)
|
||
break;vec2 offset=vUV+velocity*(hlim+float(i));
|
||
#if defined(WEBGPU)
|
||
result+=texture2DLodEXT(textureSampler,offset,0.0);
|
||
#else
|
||
result+=texture2D(textureSampler,offset);
|
||
#endif
|
||
}
|
||
gl_FragColor=result/float(samplesCount);gl_FragColor.a=1.0;
|
||
#else
|
||
vec2 texelSize=1.0/screenSize;float depth=texture2D(depthSampler,vUV).r;depth=projection[2].z+projection[3].z/depth;
|
||
vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);cpos=inverseViewProjection*cpos;cpos/=cpos.w;vec4 ppos=prevViewProjection*cpos;ppos/=ppos.w;ppos.xy=ppos.xy*0.5+0.5;vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;float speed=length(velocity/texelSize);int nSamples=int(clamp(speed,1.0,SAMPLES));vec4 result=texture2D(textureSampler,vUV);for (int i=1; i<int(SAMPLES); ++i) {if (i>=nSamples)
|
||
break;vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);
|
||
#if defined(WEBGPU)
|
||
result+=texture2DLodEXT(textureSampler,offset1,0.0);
|
||
#else
|
||
result+=texture2D(textureSampler,offset1);
|
||
#endif
|
||
}
|
||
gl_FragColor=result/float(nSamples);
|
||
#endif
|
||
#else
|
||
gl_FragColor=texture2D(textureSampler,vUV);
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},37624:(r,t,e)=>{e.r(t),e.d(t,{oitBackBlendPixelShader:()=>o});var n="oitBackBlendPixelShader",i=`precision highp float;uniform sampler2D uBackColor;void main() {glFragColor=texelFetch(uBackColor,ivec2(gl_FragCoord.xy),0);if (glFragColor.a==0.0) {
|
||
discard;}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},73758:(r,t,e)=>{e.r(t),e.d(t,{oitFinalPixelShader:()=>o});var n="oitFinalPixelShader",i=`precision highp float;uniform sampler2D uFrontColor;uniform sampler2D uBackColor;void main() {ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec4 frontColor=texelFetch(uFrontColor,fragCoord,0);vec4 backColor=texelFetch(uBackColor,fragCoord,0);float alphaMultiplier=1.0-frontColor.a;glFragColor=vec4(
|
||
frontColor.rgb+alphaMultiplier*backColor.rgb,
|
||
frontColor.a+backColor.a
|
||
);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},23338:(r,t,e)=>{e.r(t),e.d(t,{outlinePixelShader:()=>a});var n=e(98519),i=(e(27003),e(59262),e(39643),e(13088),"outlinePixelShader"),o=`#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
uniform vec4 color;
|
||
#ifdef ALPHATEST
|
||
varying vec2 vUV;uniform sampler2D diffuseSampler;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEST
|
||
if (texture2D(diffuseSampler,vUV).a<0.4)
|
||
discard;
|
||
#endif
|
||
#include<logDepthFragment>
|
||
gl_FragColor=color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},18924:(r,t,e)=>{e.r(t),e.d(t,{outlineVertexShader:()=>a});var n=e(98519),i=(e(36470),e(64400),e(24444),e(67369),e(85637),e(38615),e(59262),e(58266),e(84589),e(35397),e(76898),e(49334),e(83057),e(56458),"outlineVertexShader"),o=`attribute vec3 position;attribute vec3 normal;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<clipPlaneVertexDeclaration>
|
||
uniform float offset;
|
||
#include<instancesDeclaration>
|
||
uniform mat4 viewProjection;
|
||
#ifdef ALPHATEST
|
||
varying vec2 vUV;uniform mat4 diffuseMatrix;
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute vec2 uv2;
|
||
#endif
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void)
|
||
{vec3 positionUpdated=position;vec3 normalUpdated=normal;
|
||
#ifdef UV1
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
vec3 offsetPosition=positionUpdated+(normalUpdated*offset);
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(offsetPosition,1.0);gl_Position=viewProjection*worldPos;
|
||
#ifdef ALPHATEST
|
||
#ifdef UV1
|
||
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef UV2
|
||
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<logDepthVertex>
|
||
}
|
||
`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},90821:(r,t,e)=>{e.r(t),e.d(t,{particlesPixelShader:()=>a});var n=e(98519),i=(e(27003),e(59581),e(59262),e(75334),e(40688),e(52767),e(39643),e(13088),e(86343),"particlesPixelShader"),o=`#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
varying vec2 vUV;varying vec4 vColor;uniform vec4 textureMask;uniform sampler2D diffuseSampler;
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<imageProcessingDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<helperFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#ifdef RAMPGRADIENT
|
||
varying vec4 remapRanges;uniform sampler2D rampSampler;
|
||
#endif
|
||
#include<fogFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
vec4 textureColor=texture2D(diffuseSampler,vUV);vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;
|
||
#ifdef RAMPGRADIENT
|
||
float alpha=baseColor.a;float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));baseColor.rgb*=rampColor.rgb;float finalAlpha=baseColor.a;baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);
|
||
#endif
|
||
#ifdef BLENDMULTIPLYMODE
|
||
float sourceAlpha=vColor.a*textureColor.a;baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);
|
||
#endif
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>(color,baseColor)
|
||
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
baseColor.rgb=toLinearSpace(baseColor.rgb);
|
||
#else
|
||
#ifdef IMAGEPROCESSING
|
||
baseColor.rgb=toLinearSpace(baseColor.rgb);baseColor=applyImageProcessing(baseColor);
|
||
#endif
|
||
#endif
|
||
gl_FragColor=baseColor;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},33355:(r,t,e)=>{e.r(t),e.d(t,{particlesVertexShader:()=>a});var n=e(98519),i=(e(85637),e(72153),e(59262),e(83057),e(62589),e(56458),"particlesVertexShader"),o=`attribute vec3 position;attribute vec4 color;attribute float angle;attribute vec2 size;
|
||
#ifdef ANIMATESHEET
|
||
attribute float cellIndex;
|
||
#endif
|
||
#ifndef BILLBOARD
|
||
attribute vec3 direction;
|
||
#endif
|
||
#ifdef BILLBOARDSTRETCHED
|
||
attribute vec3 direction;
|
||
#endif
|
||
#ifdef RAMPGRADIENT
|
||
attribute vec4 remapData;
|
||
#endif
|
||
attribute vec2 offset;uniform mat4 view;uniform mat4 projection;uniform vec2 translationPivot;
|
||
#ifdef ANIMATESHEET
|
||
uniform vec3 particlesInfos;
|
||
#endif
|
||
varying vec2 vUV;varying vec4 vColor;varying vec3 vPositionW;
|
||
#ifdef RAMPGRADIENT
|
||
varying vec4 remapRanges;
|
||
#endif
|
||
#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
|
||
uniform mat4 invView;
|
||
#endif
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#ifdef BILLBOARD
|
||
uniform vec3 eyePosition;
|
||
#endif
|
||
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));vec3 zaxis=normalize(cross(yaxis,xaxis));vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;return position+alignedCorner;}
|
||
#ifdef BILLBOARDSTRETCHED
|
||
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {vec3 normalizedToCamera=normalize(toCamera);vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
|
||
#ifdef BILLBOARDSTRETCHED_LOCAL
|
||
vec3 row1=direction;
|
||
#else
|
||
vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
|
||
#endif
|
||
mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;return position+alignedCorner;}
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vec2 cornerPos;cornerPos=(vec2(offset.x-0.5,offset.y -0.5)-translationPivot)*size;
|
||
#ifdef BILLBOARD
|
||
vec3 rotatedCorner;
|
||
#ifdef BILLBOARDY
|
||
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=position-eyePosition;yaxis.y=0.;vPositionW=rotate(normalize(yaxis),rotatedCorner);vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
|
||
#elif defined(BILLBOARDSTRETCHED)
|
||
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 toCamera=position-eyePosition;vPositionW=rotateAlign(toCamera,rotatedCorner);vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
|
||
#else
|
||
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;vPositionW=(invView*vec4(viewPos,1)).xyz;
|
||
#endif
|
||
#ifdef RAMPGRADIENT
|
||
remapRanges=remapData;
|
||
#endif
|
||
gl_Position=projection*vec4(viewPos,1.0);
|
||
#else
|
||
vec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=normalize(direction);vPositionW=rotate(yaxis,rotatedCorner);gl_Position=projection*view*vec4(vPositionW,1.0);
|
||
#endif
|
||
vColor=color;
|
||
#ifdef ANIMATESHEET
|
||
float rowOffset=floor(cellIndex*particlesInfos.z);float columnOffset=cellIndex-rowOffset/particlesInfos.z;vec2 uvScale=particlesInfos.xy;vec2 uvOffset=vec2(offset.x ,1.0-offset.y);vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
|
||
#else
|
||
vUV=offset;
|
||
#endif
|
||
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) || defined(FOG)
|
||
vec4 worldPos=vec4(vPositionW,1.0);
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},56017:(r,t,e)=>{e.r(t),e.d(t,{passPixelShader:()=>o});var n="passPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=texture2D(textureSampler,vUV);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},25750:(r,t,e)=>{e.r(t),e.d(t,{passCubePixelShader:()=>o});var n="passCubePixelShader",i=`varying vec2 vUV;uniform samplerCube textureSampler;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec2 uv=vUV*2.0-1.0;
|
||
#ifdef POSITIVEX
|
||
gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));
|
||
#endif
|
||
#ifdef NEGATIVEX
|
||
gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));
|
||
#endif
|
||
#ifdef POSITIVEY
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));
|
||
#endif
|
||
#ifdef NEGATIVEY
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));
|
||
#endif
|
||
#ifdef POSITIVEZ
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv,1.001));
|
||
#endif
|
||
#ifdef NEGATIVEZ
|
||
gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));
|
||
#endif
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},62338:(r,t,e)=>{e.r(t),e.d(t,{pbrPixelShader:()=>s});var n=e(98519),i=(e(42107),e(81751),e(77740),"pbrFragmentDeclaration");n.l.IncludesShadersStore[i]=`uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor;
|
||
#ifdef ALBEDO
|
||
uniform vec2 vAlbedoInfos;
|
||
#endif
|
||
#ifdef AMBIENT
|
||
uniform vec4 vAmbientInfos;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
|
||
#endif
|
||
#ifdef OPACITY
|
||
uniform vec2 vOpacityInfos;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
uniform vec2 vEmissiveInfos;
|
||
#endif
|
||
#ifdef LIGHTMAP
|
||
uniform vec2 vLightmapInfos;
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
uniform vec3 vReflectivityInfos;
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
uniform vec2 vMicroSurfaceSamplerInfos;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
|
||
uniform mat4 view;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
uniform vec2 vReflectionInfos;
|
||
#ifdef REALTIME_FILTERING
|
||
uniform vec2 vReflectionFilteringInfo;
|
||
#endif
|
||
uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
|
||
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
|
||
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
|
||
uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize;
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
uniform vec2 vClearCoatParams;uniform vec4 vClearCoatRefractionParams;
|
||
#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
|
||
uniform vec4 vClearCoatInfos;
|
||
#endif
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
uniform mat4 clearCoatMatrix;
|
||
#endif
|
||
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
|
||
uniform mat4 clearCoatRoughnessMatrix;
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
uniform vec2 vClearCoatBumpInfos;uniform vec2 vClearCoatTangentSpaceParams;uniform mat4 clearCoatBumpMatrix;
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
uniform vec4 vClearCoatTintParams;uniform float clearCoatColorAtDistance;
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
uniform vec4 vIridescenceParams;
|
||
#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)
|
||
uniform vec4 vIridescenceInfos;
|
||
#endif
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
uniform mat4 iridescenceMatrix;
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
uniform mat4 iridescenceThicknessMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
uniform vec3 vAnisotropy;
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
uniform vec4 vSheenColor;
|
||
#ifdef SHEEN_ROUGHNESS
|
||
uniform float vSheenRoughness;
|
||
#endif
|
||
#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
|
||
uniform vec4 vSheenInfos;
|
||
#endif
|
||
#ifdef SHEEN_TEXTURE
|
||
uniform mat4 sheenMatrix;
|
||
#endif
|
||
#ifdef SHEEN_TEXTURE_ROUGHNESS
|
||
uniform mat4 sheenRoughnessMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_REFRACTION
|
||
uniform vec4 vRefractionMicrosurfaceInfos;uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;
|
||
#ifdef REALTIME_FILTERING
|
||
uniform vec2 vRefractionFilteringInfo;
|
||
#endif
|
||
#ifdef SS_DISPERSION
|
||
uniform float dispersion;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;
|
||
#endif
|
||
uniform vec2 vThicknessParam;uniform vec3 vDiffusionDistance;uniform vec4 vTintColor;uniform vec3 vSubSurfaceIntensity;uniform vec4 vTranslucencyColor;
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
uniform vec2 vTranslucencyColorInfos;uniform mat4 translucencyColorMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef PREPASS
|
||
#ifdef SS_SCATTERING
|
||
uniform float scatteringDiffusionProfile;
|
||
#endif
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
uniform vec2 vDebugMode;
|
||
#endif
|
||
#ifdef DETAIL
|
||
uniform vec4 vDetailInfos;
|
||
#endif
|
||
#include<decalFragmentDeclaration>
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#ifdef SPHERICAL_HARMONICS
|
||
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
|
||
#else
|
||
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
|
||
#endif
|
||
#endif
|
||
#define ADDITIONAL_FRAGMENT_DECLARATION
|
||
`,e(48915),e(48493),n.l.IncludesShadersStore.pbrFragmentExtraDeclaration=`varying vec3 vPositionW;
|
||
#if DEBUGMODE>0
|
||
varying vec4 vClipSpacePosition;
|
||
#endif
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#ifdef NORMAL
|
||
varying vec3 vNormalW;
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
varying vec3 vEnvironmentIrradiance;
|
||
#endif
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vec4 vColor;
|
||
#endif
|
||
`,e(87283),e(32823),e(37755),n.l.IncludesShadersStore.samplerFragmentAlternateDeclaration=`#ifdef _DEFINENAME_
|
||
#if _DEFINENAME_DIRECTUV==1
|
||
#define v_VARYINGNAME_UV vMainUV1
|
||
#elif _DEFINENAME_DIRECTUV==2
|
||
#define v_VARYINGNAME_UV vMainUV2
|
||
#elif _DEFINENAME_DIRECTUV==3
|
||
#define v_VARYINGNAME_UV vMainUV3
|
||
#elif _DEFINENAME_DIRECTUV==4
|
||
#define v_VARYINGNAME_UV vMainUV4
|
||
#elif _DEFINENAME_DIRECTUV==5
|
||
#define v_VARYINGNAME_UV vMainUV5
|
||
#elif _DEFINENAME_DIRECTUV==6
|
||
#define v_VARYINGNAME_UV vMainUV6
|
||
#else
|
||
varying vec2 v_VARYINGNAME_UV;
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrFragmentSamplersDeclaration=`#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
||
#ifdef CLEARCOAT
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
|
||
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
|
||
uniform sampler2D clearCoatRoughnessSampler;
|
||
#endif
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
|
||
#endif
|
||
#ifdef SHEEN
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
|
||
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
|
||
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS)
|
||
uniform sampler2D sheenRoughnessSampler;
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef REFLECTIONMAP_3D
|
||
#define sampleReflection(s,c) textureCube(s,c)
|
||
uniform samplerCube reflectionSampler;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
|
||
#else
|
||
uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh;
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
uniform samplerCube irradianceSampler;
|
||
#endif
|
||
#else
|
||
#define sampleReflection(s,c) texture2D(s,c)
|
||
uniform sampler2D reflectionSampler;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
|
||
#else
|
||
uniform sampler2D reflectionSamplerLow;uniform sampler2D reflectionSamplerHigh;
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
uniform sampler2D irradianceSampler;
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vec3 vPositionUVW;
|
||
#else
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vec3 vDirectionW;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
uniform sampler2D environmentBrdfSampler;
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_REFRACTION
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
#define sampleRefraction(s,c) textureCube(s,c)
|
||
uniform samplerCube refractionSampler;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
|
||
#else
|
||
uniform samplerCube refractionSamplerLow;uniform samplerCube refractionSamplerHigh;
|
||
#endif
|
||
#else
|
||
#define sampleRefraction(s,c) texture2D(s,c)
|
||
uniform sampler2D refractionSampler;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
|
||
#else
|
||
uniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor)
|
||
#endif
|
||
`,e(59581),e(27003),e(59262),e(52767),e(75334),e(5447),e(19568),n.l.IncludesShadersStore.pbrHelperFunctions=`#define MINIMUMVARIANCE 0.0005
|
||
float convertRoughnessToAverageSlope(float roughness)
|
||
{return square(roughness)+MINIMUMVARIANCE;}
|
||
float fresnelGrazingReflectance(float reflectance0) {float reflectance90=saturate(reflectance0*25.0);return reflectance90;}
|
||
vec2 getAARoughnessFactors(vec3 normalVector) {
|
||
#ifdef SPECULARAA
|
||
vec3 nDfdx=dFdx(normalVector.xyz);vec3 nDfdy=dFdy(normalVector.xyz);float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);float geometricAlphaGFactor=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
|
||
#else
|
||
return vec2(0.);
|
||
#endif
|
||
}
|
||
#ifdef ANISOTROPIC
|
||
#ifdef ANISOTROPIC_LEGACY
|
||
vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);}
|
||
vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 anisotropicFrameDirection;if (anisotropy>=0.0) {anisotropicFrameDirection=B;} else {anisotropicFrameDirection=T;}
|
||
vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;}
|
||
#else
|
||
vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG,MINIMUMVARIANCE);return vec2(alphaT,alphaB);}
|
||
vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 bentNormal=cross(B,V);bentNormal=normalize(cross(bentNormal,B));float a=square(square(1.0-anisotropy*(1.0-roughness)));bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;}
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT) || defined(SS_REFRACTION)
|
||
vec3 cocaLambert(vec3 alpha,float distance) {return exp(-alpha*distance);}
|
||
vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}
|
||
vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {return -log(color)/distance;}
|
||
vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 clearCoatAbsorption=mix(vec3(1.0),
|
||
cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
|
||
clearCoatIntensity);return clearCoatAbsorption;}
|
||
#endif
|
||
#ifdef MICROSURFACEAUTOMATIC
|
||
float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
|
||
{const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;float reflectivityLuminance=getLuminance(reflectivityColor);float reflectivityLuma=sqrt(reflectivityLuminance);microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return microSurface;}
|
||
#endif
|
||
`,e(40688),e(46837),e(92518),n.l.IncludesShadersStore.pbrDirectLightingSetupFunctions=`struct preLightingInfo
|
||
{vec3 lightOffset;float lightDistanceSquared;float lightDistance;float attenuation;vec3 L;vec3 H;float NdotV;float NdotLUnclamped;float NdotL;float VdotH;float roughness;
|
||
#ifdef IRIDESCENCE
|
||
float iridescenceIntensity;
|
||
#endif
|
||
};preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N,vec3 posW) {preLightingInfo result;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
|
||
preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
|
||
preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL;
|
||
#ifdef SPECULARTERM
|
||
result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));
|
||
#endif
|
||
return result;}`,n.l.IncludesShadersStore.pbrDirectLightingFalloffFunctions=`float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
|
||
{return max(0.,1.0-length(lightOffset)/range);}
|
||
float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
|
||
{return 1.0/maxEps(lightDistanceSquared);}
|
||
float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
|
||
{float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);float factor=lightDistanceSquared*inverseSquaredRange;float attenuation=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;}
|
||
float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
|
||
{
|
||
#ifdef USEPHYSICALLIGHTFALLOFF
|
||
return computeDistanceLightFalloff_Physical(lightDistanceSquared);
|
||
#elif defined(USEGLTFLIGHTFALLOFF)
|
||
return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
|
||
#else
|
||
return computeDistanceLightFalloff_Standard(lightOffset,range);
|
||
#endif
|
||
}
|
||
float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
|
||
{float falloff=0.0;float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)
|
||
{falloff=max(0.,pow(cosAngle,exponent));}
|
||
return falloff;}
|
||
float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
|
||
{const float kMinusLog2ConeAngleIntensityRatio=6.64385618977;
|
||
float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;}
|
||
float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
|
||
{float cd=dot(-lightDirection,directionToLightCenterW);float falloff=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}
|
||
float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
|
||
{
|
||
#ifdef USEPHYSICALLIGHTFALLOFF
|
||
return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
|
||
#elif defined(USEGLTFLIGHTFALLOFF)
|
||
return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
|
||
#else
|
||
return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
|
||
#endif
|
||
}`,e(64244),e(10114),n.l.IncludesShadersStore.pbrDirectLightingFunctions=`#define CLEARCOATREFLECTANCE90 1.0
|
||
struct lightingInfo
|
||
{vec3 diffuse;
|
||
#ifdef SPECULARTERM
|
||
vec3 specular;
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
vec4 clearCoat;
|
||
#endif
|
||
#ifdef SHEEN
|
||
vec3 sheen;
|
||
#endif
|
||
};float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
|
||
#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
|
||
float lightRoughness=lightRadius/lightDistance;float totalRoughness=saturate(lightRoughness+roughness);return totalRoughness;
|
||
#else
|
||
return roughness;
|
||
#endif
|
||
}
|
||
vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {return mix(groundColor,lightColor,info.NdotL);}
|
||
vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*info.attenuation*info.NdotL*lightColor;}
|
||
#define inline
|
||
vec3 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 toLinearSpace(textureColor);}
|
||
#ifdef SS_TRANSLUCENCY
|
||
vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {float NdotL=absEps(info.NdotLUnclamped);float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);float trAdapt=step(0.,info.NdotLUnclamped);vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;}
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
|
||
#ifdef IRIDESCENCE
|
||
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
|
||
#endif
|
||
float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
|
||
#else
|
||
float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
|
||
#endif
|
||
vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float TdotH=dot(T,info.H);float BdotH=dot(B,info.H);float TdotV=dot(T,V);float BdotV=dot(B,V);float TdotL=dot(T,info.L);float BdotL=dot(B,info.L);float alphaG=convertRoughnessToAverageSlope(info.roughness);vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,square(geometricRoughnessFactor));vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
|
||
#ifdef IRIDESCENCE
|
||
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
|
||
#endif
|
||
float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {float NccdotL=saturateEps(dot(Ncc,info.L));float NccdotH=saturateEps(dot(Ncc,info.H));float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);float kelemenVisibility=visibility_Kelemen(info.VdotH);float clearCoatTerm=fresnel*distribution*kelemenVisibility;return vec4(
|
||
clearCoatTerm*info.attenuation*NccdotL*lightColor,
|
||
1.0-fresnel
|
||
);}
|
||
vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);float NdotLRefract=saturateEps(dot(Ncc,LRefract));vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;}
|
||
#endif
|
||
#ifdef SHEEN
|
||
vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);float fresnel=1.;float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER
|
||
float visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);
|
||
#else */
|
||
float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */
|
||
float sheenTerm=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;}
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrIBLFunctions=`#if defined(REFLECTION) || defined(SS_REFRACTION)
|
||
float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;float lod=log2(microsurfaceAverageSlopeTexels);return lod;}
|
||
float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {float lod=log2(cubeMapDimensionPixels)*roughness;return lod;}
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
|
||
float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {float temp=NdotVUnclamped+ambientOcclusion;return saturate(square(temp)-1.0+ambientOcclusion);}
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
|
||
float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {vec3 reflection=reflect(view,normal);float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));return square(temp);}
|
||
#endif
|
||
#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
|
||
#define UNPACK_LOD(x) (1.0-x)*255.0
|
||
float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {float microsurfaceAverageSlope=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
|
||
#endif
|
||
`,e(48661),e(75394),e(40150),e(93130),n.l.IncludesShadersStore.pbrBlockAlbedoOpacity=`struct albedoOpacityOutParams
|
||
{vec3 surfaceAlbedo;float alpha;};
|
||
#define pbr_inline
|
||
albedoOpacityOutParams albedoOpacityBlock(
|
||
in vec4 vAlbedoColor
|
||
#ifdef ALBEDO
|
||
,in vec4 albedoTexture
|
||
,in vec2 albedoInfos
|
||
#endif
|
||
#ifdef OPACITY
|
||
,in vec4 opacityMap
|
||
,in vec2 vOpacityInfos
|
||
#endif
|
||
#ifdef DETAIL
|
||
,in vec4 detailColor
|
||
,in vec4 vDetailInfos
|
||
#endif
|
||
#ifdef DECAL
|
||
,in vec4 decalColor
|
||
,in vec4 vDecalInfos
|
||
#endif
|
||
)
|
||
{albedoOpacityOutParams outParams;vec3 surfaceAlbedo=vAlbedoColor.rgb;float alpha=vAlbedoColor.a;
|
||
#ifdef ALBEDO
|
||
#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
|
||
alpha*=albedoTexture.a;
|
||
#endif
|
||
#ifdef GAMMAALBEDO
|
||
surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
|
||
#else
|
||
surfaceAlbedo*=albedoTexture.rgb;
|
||
#endif
|
||
surfaceAlbedo*=albedoInfos.y;
|
||
#endif
|
||
#ifndef DECAL_AFTER_DETAIL
|
||
#include<decalFragment>
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
surfaceAlbedo*=vColor.rgb;
|
||
#endif
|
||
#ifdef DETAIL
|
||
float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
|
||
#endif
|
||
#ifdef DECAL_AFTER_DETAIL
|
||
#include<decalFragment>
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
|
||
#ifdef OPACITY
|
||
#ifdef OPACITYRGB
|
||
alpha=getLuminance(opacityMap.rgb);
|
||
#else
|
||
alpha*=opacityMap.a;
|
||
#endif
|
||
alpha*=vOpacityInfos.y;
|
||
#endif
|
||
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
alpha*=vColor.a;
|
||
#endif
|
||
#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
|
||
#ifdef ALPHATEST
|
||
#if DEBUGMODE != 88
|
||
if (alpha<ALPHATESTVALUE)
|
||
discard;
|
||
#endif
|
||
#ifndef ALPHABLEND
|
||
alpha=1.0;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;}
|
||
`,n.l.IncludesShadersStore.pbrBlockReflectivity=`struct reflectivityOutParams
|
||
{float microSurface;float roughness;vec3 surfaceReflectivityColor;
|
||
#ifdef METALLICWORKFLOW
|
||
vec3 surfaceAlbedo;
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
vec3 ambientOcclusionColor;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef METALLICWORKFLOW
|
||
vec2 metallicRoughness;
|
||
#ifdef REFLECTIVITY
|
||
vec4 surfaceMetallicColorMap;
|
||
#endif
|
||
#ifndef FROSTBITE_REFLECTANCE
|
||
vec3 metallicF0;
|
||
#endif
|
||
#else
|
||
#ifdef REFLECTIVITY
|
||
vec4 surfaceReflectivityColorMap;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
reflectivityOutParams reflectivityBlock(
|
||
in vec4 vReflectivityColor
|
||
#ifdef METALLICWORKFLOW
|
||
,in vec3 surfaceAlbedo
|
||
,in vec4 metallicReflectanceFactors
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
,in vec3 reflectivityInfos
|
||
,in vec4 surfaceMetallicOrReflectivityColorMap
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
,in vec3 ambientOcclusionColorIn
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
,in vec4 microSurfaceTexel
|
||
#endif
|
||
#ifdef DETAIL
|
||
,in vec4 detailColor
|
||
,in vec4 vDetailInfos
|
||
#endif
|
||
)
|
||
{reflectivityOutParams outParams;float microSurface=vReflectivityColor.a;vec3 surfaceReflectivityColor=vReflectivityColor.rgb;
|
||
#ifdef METALLICWORKFLOW
|
||
vec2 metallicRoughness=surfaceReflectivityColor.rg;
|
||
#ifdef REFLECTIVITY
|
||
#if DEBUGMODE>0
|
||
outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
|
||
#endif
|
||
#ifdef AOSTOREINMETALMAPRED
|
||
vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
|
||
#endif
|
||
#ifdef METALLNESSSTOREINMETALMAPBLUE
|
||
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
|
||
#else
|
||
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
|
||
#endif
|
||
#ifdef ROUGHNESSSTOREINMETALMAPALPHA
|
||
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
|
||
#else
|
||
#ifdef ROUGHNESSSTOREINMETALMAPGREEN
|
||
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef DETAIL
|
||
float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
metallicRoughness.g*=microSurfaceTexel.r;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.metallicRoughness=metallicRoughness;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
|
||
microSurface=1.0-metallicRoughness.g;vec3 baseColor=surfaceAlbedo;
|
||
#ifdef FROSTBITE_REFLECTANCE
|
||
outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
|
||
#else
|
||
vec3 metallicF0=metallicReflectanceFactors.rgb;
|
||
#if DEBUGMODE>0
|
||
outParams.metallicF0=metallicF0;
|
||
#endif
|
||
outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
|
||
#endif
|
||
#else
|
||
#ifdef REFLECTIVITY
|
||
surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
|
||
#if DEBUGMODE>0
|
||
outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
|
||
#endif
|
||
#ifdef MICROSURFACEFROMREFLECTIVITYMAP
|
||
microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
|
||
#else
|
||
#ifdef MICROSURFACEAUTOMATIC
|
||
microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
microSurface*=microSurfaceTexel.r;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
|
||
#endif
|
||
#endif
|
||
#endif
|
||
microSurface=saturate(microSurface);float roughness=1.-microSurface;outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.surfaceReflectivityColor=surfaceReflectivityColor;return outParams;}
|
||
`,n.l.IncludesShadersStore.pbrBlockAmbientOcclusion=`struct ambientOcclusionOutParams
|
||
{vec3 ambientOcclusionColor;
|
||
#if DEBUGMODE>0 && defined(AMBIENT)
|
||
vec3 ambientOcclusionColorMap;
|
||
#endif
|
||
};ambientOcclusionOutParams ambientOcclusionBlock(
|
||
#ifdef AMBIENT
|
||
in vec3 ambientOcclusionColorMap_,
|
||
in vec4 vAmbientInfos
|
||
#endif
|
||
)
|
||
{ambientOcclusionOutParams outParams;vec3 ambientOcclusionColor=vec3(1.,1.,1.);
|
||
#ifdef AMBIENT
|
||
vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
|
||
#ifdef AMBIENTINGRAYSCALE
|
||
ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
|
||
#endif
|
||
ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
|
||
#if DEBUGMODE>0
|
||
outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
|
||
#endif
|
||
#endif
|
||
outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;}
|
||
`,n.l.IncludesShadersStore.pbrBlockAlphaFresnel=`#ifdef ALPHAFRESNEL
|
||
#if defined(ALPHATEST) || defined(ALPHABLEND)
|
||
struct alphaFresnelOutParams
|
||
{float alpha;};
|
||
#define pbr_inline
|
||
alphaFresnelOutParams alphaFresnelBlock(
|
||
in vec3 normalW,
|
||
in vec3 viewDirectionW,
|
||
in float alpha,
|
||
in float microSurface
|
||
)
|
||
{alphaFresnelOutParams outParams;float opacityPerceptual=alpha;
|
||
#ifdef LINEARALPHAFRESNEL
|
||
float opacity0=opacityPerceptual;
|
||
#else
|
||
float opacity0=opacityPerceptual*opacityPerceptual;
|
||
#endif
|
||
float opacity90=fresnelGrazingReflectance(opacity0);vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
|
||
#ifdef ALPHATEST
|
||
if (outParams.alpha<ALPHATESTVALUE)
|
||
discard;
|
||
#ifndef ALPHABLEND
|
||
outParams.alpha=1.0;
|
||
#endif
|
||
#endif
|
||
return outParams;}
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockAnisotropic=`#ifdef ANISOTROPIC
|
||
struct anisotropicOutParams
|
||
{float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;vec3 anisotropicNormal;
|
||
#if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
|
||
vec3 anisotropyMapData;
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
anisotropicOutParams anisotropicBlock(
|
||
in vec3 vAnisotropy,
|
||
in float roughness,
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
in vec3 anisotropyMapData,
|
||
#endif
|
||
in mat3 TBN,
|
||
in vec3 normalW,
|
||
in vec3 viewDirectionW
|
||
)
|
||
{anisotropicOutParams outParams;float anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
anisotropy*=anisotropyMapData.b;
|
||
#if DEBUGMODE>0
|
||
outParams.anisotropyMapData=anisotropyMapData;
|
||
#endif
|
||
anisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0;
|
||
#ifdef ANISOTROPIC_LEGACY
|
||
anisotropyDirection.rg*=anisotropyMapData.rg;
|
||
#else
|
||
anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg);
|
||
#endif
|
||
#endif
|
||
mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockReflection=`#ifdef REFLECTION
|
||
struct reflectionOutParams
|
||
{vec4 environmentRadiance;vec3 environmentIrradiance;
|
||
#ifdef REFLECTIONMAP_3D
|
||
vec3 reflectionCoords;
|
||
#else
|
||
vec2 reflectionCoords;
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
vec3 irradianceVector;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
void createReflectionCoords(
|
||
in vec3 vPositionW,
|
||
in vec3 normalW,
|
||
#ifdef ANISOTROPIC
|
||
in anisotropicOutParams anisotropicOut,
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
out vec3 reflectionCoords
|
||
#else
|
||
out vec2 reflectionCoords
|
||
#endif
|
||
)
|
||
{
|
||
#ifdef ANISOTROPIC
|
||
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
|
||
#else
|
||
vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
reflectionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
reflectionCoords=reflectionVector;
|
||
#else
|
||
reflectionCoords=reflectionVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
reflectionCoords/=reflectionVector.z;
|
||
#endif
|
||
reflectionCoords.y=1.0-reflectionCoords.y;
|
||
#endif
|
||
}
|
||
#define pbr_inline
|
||
#define inline
|
||
void sampleReflectionTexture(
|
||
in float alphaG,
|
||
in vec3 vReflectionMicrosurfaceInfos,
|
||
in vec2 vReflectionInfos,
|
||
in vec3 vReflectionColor,
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
in float NdotVUnclamped,
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
in float roughness,
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
in samplerCube reflectionSampler,
|
||
const vec3 reflectionCoords,
|
||
#else
|
||
in sampler2D reflectionSampler,
|
||
const vec2 reflectionCoords,
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
in samplerCube reflectionSamplerLow,
|
||
in samplerCube reflectionSamplerHigh,
|
||
#else
|
||
in sampler2D reflectionSamplerLow,
|
||
in sampler2D reflectionSamplerHigh,
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
in vec2 vReflectionFilteringInfo,
|
||
#endif
|
||
out vec4 environmentRadiance
|
||
)
|
||
{
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
|
||
#elif defined(LINEARSPECULARREFLECTION)
|
||
float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
|
||
#else
|
||
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
|
||
#endif
|
||
#ifdef LODBASEDMICROSFURACE
|
||
reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
|
||
#ifdef LODINREFLECTIONALPHA
|
||
float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
|
||
#else
|
||
float requestedReflectionLOD=reflectionLOD;
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
|
||
#else
|
||
environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
|
||
#endif
|
||
#else
|
||
float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
|
||
sampleReflection(reflectionSamplerHigh,reflectionCoords),
|
||
environmentMid,
|
||
lodReflectionNormalizedDoubled
|
||
);} else {environmentRadiance=mix(
|
||
environmentMid,
|
||
sampleReflection(reflectionSamplerLow,reflectionCoords),
|
||
lodReflectionNormalizedDoubled-1.0
|
||
);}
|
||
#endif
|
||
#ifdef RGBDREFLECTION
|
||
environmentRadiance.rgb=fromRGBD(environmentRadiance);
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
|
||
#endif
|
||
environmentRadiance.rgb*=vReflectionInfos.x;environmentRadiance.rgb*=vReflectionColor.rgb;}
|
||
#define pbr_inline
|
||
#define inline
|
||
reflectionOutParams reflectionBlock(
|
||
in vec3 vPositionW
|
||
,in vec3 normalW
|
||
,in float alphaG
|
||
,in vec3 vReflectionMicrosurfaceInfos
|
||
,in vec2 vReflectionInfos
|
||
,in vec3 vReflectionColor
|
||
#ifdef ANISOTROPIC
|
||
,in anisotropicOutParams anisotropicOut
|
||
#endif
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,in float NdotVUnclamped
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,in float roughness
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube reflectionSampler
|
||
#else
|
||
,in sampler2D reflectionSampler
|
||
#endif
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
||
,in vec3 vEnvironmentIrradiance
|
||
#endif
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,in mat4 reflectionMatrix
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube irradianceSampler
|
||
#else
|
||
,in sampler2D irradianceSampler
|
||
#endif
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube reflectionSamplerLow
|
||
,in samplerCube reflectionSamplerHigh
|
||
#else
|
||
,in sampler2D reflectionSamplerLow
|
||
,in sampler2D reflectionSamplerHigh
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,in vec2 vReflectionFilteringInfo
|
||
#endif
|
||
)
|
||
{reflectionOutParams outParams;vec4 environmentRadiance=vec4(0.,0.,0.,0.);
|
||
#ifdef REFLECTIONMAP_3D
|
||
vec3 reflectionCoords=vec3(0.);
|
||
#else
|
||
vec2 reflectionCoords=vec2(0.);
|
||
#endif
|
||
createReflectionCoords(
|
||
vPositionW,
|
||
normalW,
|
||
#ifdef ANISOTROPIC
|
||
anisotropicOut,
|
||
#endif
|
||
reflectionCoords
|
||
);sampleReflectionTexture(
|
||
alphaG,
|
||
vReflectionMicrosurfaceInfos,
|
||
vReflectionInfos,
|
||
vReflectionColor,
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
NdotVUnclamped,
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
roughness,
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
reflectionSampler,
|
||
reflectionCoords,
|
||
#else
|
||
reflectionSampler,
|
||
reflectionCoords,
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
reflectionSamplerLow,
|
||
reflectionSamplerHigh,
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
vReflectionFilteringInfo,
|
||
#endif
|
||
environmentRadiance
|
||
);vec3 environmentIrradiance=vec3(0.,0.,0.);
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
||
environmentIrradiance=vEnvironmentIrradiance;
|
||
#else
|
||
#ifdef ANISOTROPIC
|
||
vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
|
||
#else
|
||
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
irradianceVector.z*=-1.0;
|
||
#endif
|
||
#ifdef INVERTCUBICMAP
|
||
irradianceVector.y*=-1.0;
|
||
#endif
|
||
#if defined(REALTIME_FILTERING)
|
||
environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);
|
||
#else
|
||
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
outParams.irradianceVector=irradianceVector;
|
||
#endif
|
||
#endif
|
||
#elif defined(USEIRRADIANCEMAP)
|
||
vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);environmentIrradiance=environmentIrradiance4.rgb;
|
||
#ifdef RGBDREFLECTION
|
||
environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
|
||
#endif
|
||
#endif
|
||
environmentIrradiance*=vReflectionColor.rgb;outParams.environmentRadiance=environmentRadiance;outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockSheen=`#ifdef SHEEN
|
||
struct sheenOutParams
|
||
{float sheenIntensity;vec3 sheenColor;float sheenRoughness;
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
vec3 surfaceAlbedo;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
float sheenAlbedoScaling;
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
vec3 finalSheenRadianceScaled;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef SHEEN_TEXTURE
|
||
vec4 sheenMapData;
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
vec3 sheenEnvironmentReflectance;
|
||
#endif
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
#define inline
|
||
sheenOutParams sheenBlock(
|
||
in vec4 vSheenColor
|
||
#ifdef SHEEN_ROUGHNESS
|
||
,in float vSheenRoughness
|
||
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,in vec4 sheenMapRoughnessData
|
||
#endif
|
||
#endif
|
||
,in float roughness
|
||
#ifdef SHEEN_TEXTURE
|
||
,in vec4 sheenMapData
|
||
,in float sheenMapLevel
|
||
#endif
|
||
,in float reflectance
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
,in vec3 baseColor
|
||
,in vec3 surfaceAlbedo
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
,in float NdotV
|
||
,in vec3 environmentBrdf
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
,in vec2 AARoughnessFactors
|
||
,in vec3 vReflectionMicrosurfaceInfos
|
||
,in vec2 vReflectionInfos
|
||
,in vec3 vReflectionColor
|
||
,in vec4 vLightingIntensity
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube reflectionSampler
|
||
,in vec3 reflectionCoords
|
||
#else
|
||
,in sampler2D reflectionSampler
|
||
,in vec2 reflectionCoords
|
||
#endif
|
||
,in float NdotVUnclamped
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube reflectionSamplerLow
|
||
,in samplerCube reflectionSamplerHigh
|
||
#else
|
||
,in sampler2D reflectionSamplerLow
|
||
,in sampler2D reflectionSamplerHigh
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,in vec2 vReflectionFilteringInfo
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
||
,in float seo
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
,in float eho
|
||
#endif
|
||
#endif
|
||
)
|
||
{sheenOutParams outParams;float sheenIntensity=vSheenColor.a;
|
||
#ifdef SHEEN_TEXTURE
|
||
#if DEBUGMODE>0
|
||
outParams.sheenMapData=sheenMapData;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
float sheenFactor=pow5(1.0-sheenIntensity);vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);float sheenRoughness=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
|
||
#ifdef SHEEN_TEXTURE
|
||
sheenIntensity*=sheenMapData.a;
|
||
#endif
|
||
#else
|
||
vec3 sheenColor=vSheenColor.rgb;
|
||
#ifdef SHEEN_TEXTURE
|
||
#ifdef SHEEN_GAMMATEXTURE
|
||
sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
|
||
#else
|
||
sheenColor.rgb*=sheenMapData.rgb;
|
||
#endif
|
||
sheenColor.rgb*=sheenMapLevel;
|
||
#endif
|
||
#ifdef SHEEN_ROUGHNESS
|
||
float sheenRoughness=vSheenRoughness;
|
||
#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
|
||
#if defined(SHEEN_TEXTURE)
|
||
sheenRoughness*=sheenMapData.a;
|
||
#endif
|
||
#elif defined(SHEEN_TEXTURE_ROUGHNESS)
|
||
sheenRoughness*=sheenMapRoughnessData.a;
|
||
#endif
|
||
#else
|
||
float sheenRoughness=roughness;
|
||
#ifdef SHEEN_TEXTURE
|
||
sheenIntensity*=sheenMapData.a;
|
||
#endif
|
||
#endif
|
||
#if !defined(SHEEN_ALBEDOSCALING)
|
||
sheenIntensity*=(1.-reflectance);
|
||
#endif
|
||
sheenColor*=sheenIntensity;
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
/*#ifdef SHEEN_SOFTER
|
||
vec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
|
||
#else*/
|
||
#ifdef SHEEN_ROUGHNESS
|
||
vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
|
||
#else
|
||
vec3 environmentSheenBrdf=environmentBrdf;
|
||
#endif
|
||
/*#endif*/
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
|
||
#ifdef SPECULARAA
|
||
sheenAlphaG+=AARoughnessFactors.y;
|
||
#endif
|
||
vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);sampleReflectionTexture(
|
||
sheenAlphaG,
|
||
vReflectionMicrosurfaceInfos,
|
||
vReflectionInfos,
|
||
vReflectionColor,
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
NdotVUnclamped,
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
sheenRoughness,
|
||
#endif
|
||
reflectionSampler,
|
||
reflectionCoords,
|
||
#ifndef LODBASEDMICROSFURACE
|
||
reflectionSamplerLow,
|
||
reflectionSamplerHigh,
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
vReflectionFilteringInfo,
|
||
#endif
|
||
environmentSheenRadiance
|
||
);vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
||
sheenEnvironmentReflectance*=seo;
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
sheenEnvironmentReflectance*=eho;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
|
||
#endif
|
||
outParams.finalSheenRadianceScaled=
|
||
environmentSheenRadiance.rgb *
|
||
sheenEnvironmentReflectance *
|
||
vLightingIntensity.z;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
|
||
#endif
|
||
outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockClearcoat=`struct clearcoatOutParams
|
||
{vec3 specularEnvironmentR0;float conservationFactor;vec3 clearCoatNormalW;vec2 clearCoatAARoughnessFactors;float clearCoatIntensity;float clearCoatRoughness;
|
||
#ifdef REFLECTION
|
||
vec3 finalClearCoatRadianceScaled;
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
vec3 absorption;float clearCoatNdotVRefract;vec3 clearCoatColor;float clearCoatThickness;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
vec3 energyConservationFactorClearCoat;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef CLEARCOAT_BUMP
|
||
mat3 TBNClearCoat;
|
||
#endif
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
vec2 clearCoatMapData;
|
||
#endif
|
||
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
||
vec4 clearCoatTintMapData;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
vec4 environmentClearCoatRadiance;vec3 clearCoatEnvironmentReflectance;
|
||
#endif
|
||
float clearCoatNdotV;
|
||
#endif
|
||
};
|
||
#ifdef CLEARCOAT
|
||
#define pbr_inline
|
||
#define inline
|
||
clearcoatOutParams clearcoatBlock(
|
||
in vec3 vPositionW
|
||
,in vec3 geometricNormalW
|
||
,in vec3 viewDirectionW
|
||
,in vec2 vClearCoatParams
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,in vec4 clearCoatMapRoughnessData
|
||
#endif
|
||
,in vec3 specularEnvironmentR0
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,in vec2 clearCoatMapData
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
,in vec4 vClearCoatTintParams
|
||
,in float clearCoatColorAtDistance
|
||
,in vec4 vClearCoatRefractionParams
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
,in vec4 clearCoatTintMapData
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
,in vec2 vClearCoatBumpInfos
|
||
,in vec4 clearCoatBumpMapData
|
||
,in vec2 vClearCoatBumpUV
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
,in mat3 vTBN
|
||
#else
|
||
,in vec2 vClearCoatTangentSpaceParams
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
,in mat4 normalMatrix
|
||
#endif
|
||
#endif
|
||
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
,in vec3 faceNormal
|
||
#endif
|
||
#ifdef REFLECTION
|
||
,in vec3 vReflectionMicrosurfaceInfos
|
||
,in vec2 vReflectionInfos
|
||
,in vec3 vReflectionColor
|
||
,in vec4 vLightingIntensity
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube reflectionSampler
|
||
#else
|
||
,in sampler2D reflectionSampler
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube reflectionSamplerLow
|
||
,in samplerCube reflectionSamplerHigh
|
||
#else
|
||
,in sampler2D reflectionSamplerLow
|
||
,in sampler2D reflectionSamplerHigh
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,in vec2 vReflectionFilteringInfo
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
|
||
,in float frontFacingMultiplier
|
||
#endif
|
||
)
|
||
{clearcoatOutParams outParams;float clearCoatIntensity=vClearCoatParams.x;float clearCoatRoughness=vClearCoatParams.y;
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
clearCoatIntensity*=clearCoatMapData.x;
|
||
#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
|
||
clearCoatRoughness*=clearCoatMapData.y;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatMapData=clearCoatMapData;
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
clearCoatRoughness*=clearCoatMapRoughnessData.y;
|
||
#endif
|
||
outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
|
||
#ifdef CLEARCOAT_TINT
|
||
vec3 clearCoatColor=vClearCoatTintParams.rgb;float clearCoatThickness=vClearCoatTintParams.a;
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
#ifdef CLEARCOAT_TINT_GAMMATEXTURE
|
||
clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
|
||
#else
|
||
clearCoatColor*=clearCoatTintMapData.rgb;
|
||
#endif
|
||
clearCoatThickness*=clearCoatTintMapData.a;
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatTintMapData=clearCoatTintMapData;
|
||
#endif
|
||
#endif
|
||
outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
|
||
#endif
|
||
#ifdef CLEARCOAT_REMAP_F0
|
||
vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
|
||
#else
|
||
vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
|
||
#endif
|
||
outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);vec3 clearCoatNormalW=geometricNormalW;
|
||
#ifdef CLEARCOAT_BUMP
|
||
#ifdef NORMALXYSCALE
|
||
float clearCoatNormalScale=1.0;
|
||
#else
|
||
float clearCoatNormalScale=vClearCoatBumpInfos.y;
|
||
#endif
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
mat3 TBNClearCoat=vTBN;
|
||
#else
|
||
vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.TBNClearCoat=TBNClearCoat;
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
|
||
#else
|
||
clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
|
||
#endif
|
||
#endif
|
||
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
|
||
#endif
|
||
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
||
clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
|
||
#endif
|
||
outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatNdotV=clearCoatNdotV;
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
vec3 clearCoatVRefract=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
|
||
vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
|
||
#endif
|
||
#if defined(REFLECTION)
|
||
float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
|
||
#ifdef SPECULARAA
|
||
clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
|
||
#endif
|
||
vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
clearCoatReflectionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
|
||
#else
|
||
vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
clearCoatReflectionCoords/=clearCoatReflectionVector.z;
|
||
#endif
|
||
clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
|
||
#endif
|
||
sampleReflectionTexture(
|
||
clearCoatAlphaG,
|
||
vReflectionMicrosurfaceInfos,
|
||
vReflectionInfos,
|
||
vReflectionColor,
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
clearCoatNdotVUnclamped,
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
clearCoatRoughness,
|
||
#endif
|
||
reflectionSampler,
|
||
clearCoatReflectionCoords,
|
||
#ifndef LODBASEDMICROSFURACE
|
||
reflectionSamplerLow,
|
||
reflectionSamplerHigh,
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
vReflectionFilteringInfo,
|
||
#endif
|
||
environmentClearCoatRadiance
|
||
);
|
||
#if DEBUGMODE>0
|
||
outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
|
||
#ifdef HORIZONOCCLUSION
|
||
#ifdef BUMP
|
||
#ifdef REFLECTIONMAP_3D
|
||
float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#else
|
||
vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
|
||
#endif
|
||
clearCoatEnvironmentReflectance*=clearCoatIntensity;
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
|
||
#endif
|
||
outParams.finalClearCoatRadianceScaled=
|
||
environmentClearCoatRadiance.rgb *
|
||
clearCoatEnvironmentReflectance *
|
||
vLightingIntensity.z;
|
||
#endif
|
||
#if defined(CLEARCOAT_TINT)
|
||
outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
|
||
#endif
|
||
float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
|
||
#endif
|
||
return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockIridescence=`struct iridescenceOutParams
|
||
{float iridescenceIntensity;float iridescenceIOR;float iridescenceThickness;vec3 specularEnvironmentR0;};
|
||
#ifdef IRIDESCENCE
|
||
#define pbr_inline
|
||
#define inline
|
||
iridescenceOutParams iridescenceBlock(
|
||
in vec4 vIridescenceParams
|
||
,in float viewAngle
|
||
,in vec3 specularEnvironmentR0
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
,in vec2 iridescenceMapData
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
,in vec2 iridescenceThicknessMapData
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
,in float NdotVUnclamped
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,in vec2 clearCoatMapData
|
||
#endif
|
||
#endif
|
||
)
|
||
{iridescenceOutParams outParams;float iridescenceIntensity=vIridescenceParams.x;float iridescenceIOR=vIridescenceParams.y;float iridescenceThicknessMin=vIridescenceParams.z;float iridescenceThicknessMax=vIridescenceParams.w;float iridescenceThicknessWeight=1.;
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
iridescenceIntensity*=iridescenceMapData.x;
|
||
#endif
|
||
#if defined(IRIDESCENCE_THICKNESS_TEXTURE)
|
||
iridescenceThicknessWeight=iridescenceThicknessMapData.g;
|
||
#endif
|
||
float iridescenceThickness=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);float topIor=1.;
|
||
#ifdef CLEARCOAT
|
||
float clearCoatIntensity=vClearCoatParams.x;
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
clearCoatIntensity*=clearCoatMapData.x;
|
||
#endif
|
||
topIor=mix(1.0,vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+square(1.0/topIor)*(square(NdotVUnclamped)-1.0));
|
||
#endif
|
||
vec3 iridescenceFresnel=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockSubSurface=`struct subSurfaceOutParams
|
||
{vec3 specularEnvironmentReflectance;
|
||
#ifdef SS_REFRACTION
|
||
vec3 finalRefraction;vec3 surfaceAlbedo;
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
float alpha;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
float refractionFactorForIrradiance;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
vec3 transmittance;float translucencyIntensity;
|
||
#ifdef REFLECTION
|
||
vec3 refractionIrradiance;
|
||
#endif
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
vec4 thicknessMap;
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
vec4 environmentRefraction;vec3 refractionTransmittance;
|
||
#endif
|
||
#endif
|
||
};
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_REFRACTION
|
||
#define pbr_inline
|
||
#define inline
|
||
vec4 sampleEnvironmentRefraction(
|
||
in float ior
|
||
,in float thickness
|
||
,in float refractionLOD
|
||
,in vec3 normalW
|
||
,in vec3 vPositionW
|
||
,in vec3 viewDirectionW
|
||
,in mat4 view
|
||
,in vec4 vRefractionInfos
|
||
,in mat4 refractionMatrix
|
||
,in vec4 vRefractionMicrosurfaceInfos
|
||
,in float alphaG
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
,in samplerCube refractionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,in samplerCube refractionSamplerLow
|
||
,in samplerCube refractionSamplerHigh
|
||
#endif
|
||
#else
|
||
,in sampler2D refractionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,in sampler2D refractionSamplerLow
|
||
,in sampler2D refractionSamplerHigh
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,in anisotropicOutParams anisotropicOut
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,in vec2 vRefractionFilteringInfo
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,in vec3 refractionPosition
|
||
,in vec3 refractionSize
|
||
#endif
|
||
) {vec4 environmentRefraction=vec4(0.,0.,0.,0.);
|
||
#ifdef ANISOTROPIC
|
||
vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior);
|
||
#else
|
||
vec3 refractionVector=refract(-viewDirectionW,normalW,ior);
|
||
#endif
|
||
#ifdef SS_REFRACTIONMAP_OPPOSITEZ
|
||
refractionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
|
||
#endif
|
||
refractionVector.y=refractionVector.y*vRefractionInfos.w;vec3 refractionCoords=refractionVector;refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
|
||
#else
|
||
#ifdef SS_USE_THICKNESS_AS_DEPTH
|
||
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
|
||
#else
|
||
vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
|
||
#endif
|
||
vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
|
||
#endif
|
||
#ifdef LODBASEDMICROSFURACE
|
||
refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
|
||
#else
|
||
float requestedRefractionLOD=refractionLOD;
|
||
#endif
|
||
#if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
|
||
environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
|
||
#else
|
||
environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
|
||
#endif
|
||
#else
|
||
float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
|
||
sampleRefraction(refractionSamplerHigh,refractionCoords),
|
||
environmentRefractionMid,
|
||
lodRefractionNormalizedDoubled
|
||
);} else {environmentRefraction=mix(
|
||
environmentRefractionMid,
|
||
sampleRefraction(refractionSamplerLow,refractionCoords),
|
||
lodRefractionNormalizedDoubled-1.0
|
||
);}
|
||
#endif
|
||
#ifdef SS_RGBDREFRACTION
|
||
environmentRefraction.rgb=fromRGBD(environmentRefraction);
|
||
#endif
|
||
#ifdef SS_GAMMAREFRACTION
|
||
environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
|
||
#endif
|
||
return environmentRefraction;}
|
||
#endif
|
||
#define pbr_inline
|
||
#define inline
|
||
subSurfaceOutParams subSurfaceBlock(
|
||
in vec3 vSubSurfaceIntensity
|
||
,in vec2 vThicknessParam
|
||
,in vec4 vTintColor
|
||
,in vec3 normalW
|
||
,in vec3 specularEnvironmentReflectance
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
,in vec4 thicknessMap
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
,in vec4 refractionIntensityMap
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
,in vec4 translucencyIntensityMap
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef SS_TRANSLUCENCY
|
||
,in mat4 reflectionMatrix
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,in vec3 irradianceVector_
|
||
#endif
|
||
#if defined(REALTIME_FILTERING)
|
||
,in samplerCube reflectionSampler
|
||
,in vec2 vReflectionFilteringInfo
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
#ifdef REFLECTIONMAP_3D
|
||
,in samplerCube irradianceSampler
|
||
#else
|
||
,in sampler2D irradianceSampler
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
|
||
,in vec3 surfaceAlbedo
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
,in vec3 vPositionW
|
||
,in vec3 viewDirectionW
|
||
,in mat4 view
|
||
,in vec4 vRefractionInfos
|
||
,in mat4 refractionMatrix
|
||
,in vec4 vRefractionMicrosurfaceInfos
|
||
,in vec4 vLightingIntensity
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
,in float alpha
|
||
#endif
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
,in float NdotVUnclamped
|
||
#endif
|
||
#ifdef SS_LINEARSPECULARREFRACTION
|
||
,in float roughness
|
||
#endif
|
||
,in float alphaG
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
,in samplerCube refractionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,in samplerCube refractionSamplerLow
|
||
,in samplerCube refractionSamplerHigh
|
||
#endif
|
||
#else
|
||
,in sampler2D refractionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,in sampler2D refractionSamplerLow
|
||
,in sampler2D refractionSamplerHigh
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,in anisotropicOutParams anisotropicOut
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,in vec2 vRefractionFilteringInfo
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,in vec3 refractionPosition
|
||
,in vec3 refractionSize
|
||
#endif
|
||
#ifdef SS_DISPERSION
|
||
,in float dispersion
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
,in vec3 vDiffusionDistance
|
||
,in vec4 vTranslucencyColor
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
,in vec4 translucencyColorMap
|
||
#endif
|
||
#endif
|
||
)
|
||
{subSurfaceOutParams outParams;outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
|
||
#ifdef SS_REFRACTION
|
||
float refractionIntensity=vSubSurfaceIntensity.x;
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
float translucencyIntensity=vSubSurfaceIntensity.y;
|
||
#endif
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
|
||
#else
|
||
float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.thicknessMap=thicknessMap;
|
||
#endif
|
||
#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
refractionIntensity*=thicknessMap.r;
|
||
#else
|
||
refractionIntensity*=thicknessMap.g;
|
||
#endif
|
||
#endif
|
||
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
translucencyIntensity*=thicknessMap.a;
|
||
#else
|
||
translucencyIntensity*=thicknessMap.b;
|
||
#endif
|
||
#endif
|
||
#else
|
||
float thickness=vThicknessParam.y;
|
||
#endif
|
||
#if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
refractionIntensity*=refractionIntensityMap.r;
|
||
#else
|
||
refractionIntensity*=refractionIntensityMap.g;
|
||
#endif
|
||
#endif
|
||
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
translucencyIntensity*=translucencyIntensityMap.a;
|
||
#else
|
||
translucencyIntensity*=translucencyIntensityMap.b;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
thickness=maxEps(thickness);vec4 translucencyColor=vTranslucencyColor;
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
translucencyColor*=translucencyColorMap;
|
||
#endif
|
||
vec3 transmittance=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
vec4 environmentRefraction=vec4(0.,0.,0.,0.);
|
||
#ifdef SS_HAS_THICKNESS
|
||
float ior=vRefractionInfos.y;
|
||
#else
|
||
float ior=vRefractionMicrosurfaceInfos.w;
|
||
#endif
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
|
||
#elif defined(SS_LINEARSPECULARREFRACTION)
|
||
float refractionRoughness=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
|
||
#else
|
||
float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
|
||
#endif
|
||
float refraction_ior=vRefractionInfos.y;
|
||
#ifdef SS_DISPERSION
|
||
float realIOR=1.0/refraction_ior;float iorDispersionSpread=0.04*dispersion*(realIOR-1.0);vec3 iors=vec3(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (int i=0; i<3; i++) {refraction_ior=iors[i];
|
||
#endif
|
||
vec4 envSample=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
,refractionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionSamplerLow
|
||
,refractionSamplerHigh
|
||
#endif
|
||
#else
|
||
,refractionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionSamplerLow
|
||
,refractionSamplerHigh
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vRefractionFilteringInfo
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,refractionPosition
|
||
,refractionSize
|
||
#endif
|
||
);
|
||
#ifdef SS_DISPERSION
|
||
environmentRefraction[i]=envSample[i];}
|
||
#else
|
||
environmentRefraction=envSample;
|
||
#endif
|
||
environmentRefraction.rgb*=vRefractionInfos.x;
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
vec3 refractionTransmittance=vec3(refractionIntensity);
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
|
||
#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
|
||
float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);environmentRefraction.rgb*=volumeAlbedo;
|
||
#else
|
||
vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
|
||
#endif
|
||
#ifdef SS_ALBEDOFORREFRACTIONTINT
|
||
environmentRefraction.rgb*=surfaceAlbedo.rgb;
|
||
#endif
|
||
outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
|
||
#ifdef REFLECTION
|
||
outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
|
||
#endif
|
||
#ifdef UNUSED_MULTIPLEBOUNCES
|
||
vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
|
||
#endif
|
||
refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
|
||
#if DEBUGMODE>0
|
||
outParams.refractionTransmittance=refractionTransmittance;
|
||
#endif
|
||
outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
|
||
#if DEBUGMODE>0
|
||
outParams.environmentRefraction=environmentRefraction;
|
||
#endif
|
||
#endif
|
||
#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
|
||
vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
irradianceVector.z*=-1.0;
|
||
#endif
|
||
#ifdef INVERTCUBICMAP
|
||
irradianceVector.y*=-1.0;
|
||
#endif
|
||
#else
|
||
vec3 irradianceVector=irradianceVector_;
|
||
#endif
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP)
|
||
#if defined(REALTIME_FILTERING)
|
||
vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);
|
||
#else
|
||
vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
|
||
#endif
|
||
#elif defined(USEIRRADIANCEMAP)
|
||
#ifdef REFLECTIONMAP_3D
|
||
vec3 irradianceCoords=irradianceVector;
|
||
#else
|
||
vec2 irradianceCoords=irradianceVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
irradianceCoords/=irradianceVector.z;
|
||
#endif
|
||
irradianceCoords.y=1.0-irradianceCoords.y;
|
||
#endif
|
||
vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
|
||
#ifdef RGBDREFLECTION
|
||
refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
|
||
#endif
|
||
#else
|
||
vec4 refractionIrradiance=vec4(0.);
|
||
#endif
|
||
refractionIrradiance.rgb*=transmittance;
|
||
#ifdef SS_ALBEDOFORTRANSLUCENCYTINT
|
||
refractionIrradiance.rgb*=surfaceAlbedo.rgb;
|
||
#endif
|
||
outParams.refractionIrradiance=refractionIrradiance.rgb;
|
||
#endif
|
||
return outParams;}
|
||
#endif
|
||
`,e(39643),n.l.IncludesShadersStore.pbrBlockNormalGeometric=`vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
|
||
#ifdef NORMAL
|
||
vec3 normalW=normalize(vNormalW);
|
||
#else
|
||
vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
|
||
#endif
|
||
vec3 geometricNormalW=normalW;
|
||
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
||
geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
|
||
#endif
|
||
`,e(56159),n.l.IncludesShadersStore.pbrBlockNormalFinal=`#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
|
||
#if defined(TWOSIDEDLIGHTING)
|
||
faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
|
||
#endif
|
||
normalW*=sign(dot(normalW,faceNormal));
|
||
#endif
|
||
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
||
normalW=gl_FrontFacing ? normalW : -normalW;
|
||
#endif
|
||
`,e(15656),n.l.IncludesShadersStore.pbrBlockLightmapInit=`#ifdef LIGHTMAP
|
||
vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
|
||
#ifdef RGBDLIGHTMAP
|
||
lightmapColor.rgb=fromRGBD(lightmapColor);
|
||
#endif
|
||
#ifdef GAMMALIGHTMAP
|
||
lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
|
||
#endif
|
||
lightmapColor.rgb*=vLightmapInfos.y;
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockGeometryInfo=`float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
|
||
#ifdef SPECULARAA
|
||
alphaG+=AARoughnessFactors.y;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF)
|
||
vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
#ifdef RADIANCEOCCLUSION
|
||
#ifdef AMBIENTINGRAYSCALE
|
||
float ambientMonochrome=aoOut.ambientOcclusionColor.r;
|
||
#else
|
||
float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
|
||
#endif
|
||
float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
|
||
#endif
|
||
#ifdef HORIZONOCCLUSION
|
||
#ifdef BUMP
|
||
#ifdef REFLECTIONMAP_3D
|
||
float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockReflectance0=`float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;
|
||
#ifdef METALLICWORKFLOW
|
||
vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);
|
||
#else
|
||
vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);
|
||
#endif
|
||
#ifdef ALPHAFRESNEL
|
||
float reflectance90=fresnelGrazingReflectance(reflectance);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockReflectance=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
|
||
#ifdef RADIANCEOCCLUSION
|
||
specularEnvironmentReflectance*=seo;
|
||
#endif
|
||
#ifdef HORIZONOCCLUSION
|
||
#ifdef BUMP
|
||
#ifdef REFLECTIONMAP_3D
|
||
specularEnvironmentReflectance*=eho;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#else
|
||
vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
|
||
#if defined(CLEARCOAT_TINT)
|
||
specularEnvironmentReflectance*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockDirectLighting=`vec3 diffuseBase=vec3(0.,0.,0.);
|
||
#ifdef SPECULARTERM
|
||
vec3 specularBase=vec3(0.,0.,0.);
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
vec3 clearCoatBase=vec3(0.,0.,0.);
|
||
#endif
|
||
#ifdef SHEEN
|
||
vec3 sheenBase=vec3(0.,0.,0.);
|
||
#endif
|
||
preLightingInfo preInfo;lightingInfo info;float shadow=1.;
|
||
float aggShadow=0.;float numLights=0.;
|
||
#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
|
||
vec3 absorption=vec3(0.);
|
||
#endif
|
||
`,e(7363),n.l.IncludesShadersStore.pbrBlockFinalLitComponents=`aggShadow=aggShadow/numLights;
|
||
#if defined(ENVIRONMENTBRDF)
|
||
#ifdef MS_BRDF_ENERGY_CONSERVATION
|
||
vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
|
||
#endif
|
||
#endif
|
||
#ifndef METALLICWORKFLOW
|
||
#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
|
||
surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;
|
||
#endif
|
||
#endif
|
||
#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
|
||
surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
vec3 finalIrradiance=reflectionOut.environmentIrradiance;
|
||
#if defined(CLEARCOAT)
|
||
finalIrradiance*=clearcoatOut.conservationFactor;
|
||
#if defined(CLEARCOAT_TINT)
|
||
finalIrradiance*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION)
|
||
finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
|
||
#endif
|
||
#if defined(SS_TRANSLUCENCY)
|
||
finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
|
||
#endif
|
||
finalIrradiance*=surfaceAlbedo.rgb;finalIrradiance*=vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
vec3 finalSpecular=specularBase;finalSpecular=max(finalSpecular,0.0);vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
finalSpecularScaled*=energyConservationFactor;
|
||
#endif
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTION
|
||
vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
finalRadianceScaled*=energyConservationFactor;
|
||
#endif
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
vec3 finalSheen=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,0.0);vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
|
||
#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
|
||
#if defined(CLEARCOAT_TINT)
|
||
sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
vec3 finalClearCoat=clearCoatBase;finalClearCoat=max(finalClearCoat,0.0);vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
|
||
#ifdef CLEARCOAT_TINT
|
||
subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef ALPHABLEND
|
||
float luminanceOverAlpha=0.0;
|
||
#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
|
||
luminanceOverAlpha+=getLuminance(finalRadianceScaled);
|
||
#if defined(CLEARCOAT)
|
||
luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
|
||
#endif
|
||
#endif
|
||
#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
|
||
luminanceOverAlpha+=getLuminance(finalSpecularScaled);
|
||
#endif
|
||
#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
|
||
luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
|
||
#endif
|
||
#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
|
||
alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStore.pbrBlockFinalUnlitComponents=`vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo.rgb;finalDiffuse=max(finalDiffuse,0.0);finalDiffuse*=vLightingIntensity.x;vec3 finalAmbient=vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;vec3 finalEmissive=vEmissiveColor;
|
||
#ifdef EMISSIVE
|
||
vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
|
||
#ifdef GAMMAEMISSIVE
|
||
finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
|
||
#else
|
||
finalEmissive*=emissiveColorTex.rgb;
|
||
#endif
|
||
finalEmissive*= vEmissiveInfos.y;
|
||
#endif
|
||
finalEmissive*=vLightingIntensity.y;
|
||
#ifdef AMBIENT
|
||
vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
|
||
#else
|
||
vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
|
||
#endif
|
||
finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
|
||
`,n.l.IncludesShadersStore.pbrBlockFinalColorComposition=`vec4 finalColor=vec4(
|
||
#ifndef UNLIT
|
||
#ifdef REFLECTION
|
||
finalIrradiance +
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
finalSpecularScaled +
|
||
#endif
|
||
#ifdef SHEEN
|
||
finalSheenScaled +
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
finalClearCoatScaled +
|
||
#endif
|
||
#ifdef REFLECTION
|
||
finalRadianceScaled +
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
||
sheenOut.finalSheenRadianceScaled +
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
clearcoatOut.finalClearCoatRadianceScaled +
|
||
#endif
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
subSurfaceOut.finalRefraction +
|
||
#endif
|
||
#endif
|
||
finalAmbient +
|
||
finalDiffuse,
|
||
alpha);
|
||
#ifdef LIGHTMAP
|
||
#ifndef LIGHTMAPEXCLUDED
|
||
#ifdef USELIGHTMAPASSHADOWMAP
|
||
finalColor.rgb*=lightmapColor.rgb;
|
||
#else
|
||
finalColor.rgb+=lightmapColor.rgb;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
finalColor.rgb+=finalEmissive;
|
||
#define CUSTOM_FRAGMENT_BEFORE_FOG
|
||
finalColor=max(finalColor,0.0);
|
||
`,e(13088),e(86343),n.l.IncludesShadersStore.pbrBlockImageProcessing=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
|
||
#if !defined(SKIPFINALCOLORCLAMP)
|
||
finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
|
||
#endif
|
||
#else
|
||
finalColor=applyImageProcessing(finalColor);
|
||
#endif
|
||
finalColor.a*=visibility;
|
||
#ifdef PREMULTIPLYALPHA
|
||
finalColor.rgb*=finalColor.a;
|
||
#endif
|
||
`,e(11135),n.l.IncludesShadersStore.pbrDebug=`#if DEBUGMODE>0
|
||
if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
|
||
#if DEBUGMODE==1
|
||
gl_FragColor.rgb=vPositionW.rgb;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==2 && defined(NORMAL)
|
||
gl_FragColor.rgb=vNormalW.rgb;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
|
||
gl_FragColor.rgb=TBN[0];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
|
||
gl_FragColor.rgb=TBN[1];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==5
|
||
gl_FragColor.rgb=normalW;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==6 && defined(MAINUV1)
|
||
gl_FragColor.rgb=vec3(vMainUV1,0.0);
|
||
#elif DEBUGMODE==7 && defined(MAINUV2)
|
||
gl_FragColor.rgb=vec3(vMainUV2,0.0);
|
||
#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
|
||
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
|
||
gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==10 && defined(CLEARCOAT)
|
||
gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==11 && defined(ANISOTROPIC)
|
||
gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==12 && defined(ANISOTROPIC)
|
||
gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==13 && defined(ANISOTROPIC)
|
||
gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==20 && defined(ALBEDO)
|
||
gl_FragColor.rgb=albedoTexture.rgb;
|
||
#ifndef GAMMAALBEDO
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==21 && defined(AMBIENT)
|
||
gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
|
||
#elif DEBUGMODE==22 && defined(OPACITY)
|
||
gl_FragColor.rgb=opacityMap.rgb;
|
||
#elif DEBUGMODE==23 && defined(EMISSIVE)
|
||
gl_FragColor.rgb=emissiveColorTex.rgb;
|
||
#ifndef GAMMAEMISSIVE
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==24 && defined(LIGHTMAP)
|
||
gl_FragColor.rgb=lightmapColor.rgb;
|
||
#ifndef GAMMALIGHTMAP
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
|
||
gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
|
||
#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
|
||
gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
|
||
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
|
||
#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
||
gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
|
||
#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
|
||
gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
|
||
#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
|
||
gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
|
||
#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
|
||
gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
|
||
#elif DEBUGMODE==32 && defined(BUMP)
|
||
gl_FragColor.rgb=texture2D(bumpSampler,vBumpUV).rgb;
|
||
#elif DEBUGMODE==40 && defined(SS_REFRACTION)
|
||
gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==41 && defined(REFLECTION)
|
||
gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
|
||
#ifndef GAMMAREFLECTION
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
|
||
gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==50
|
||
gl_FragColor.rgb=diffuseBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==51 && defined(SPECULARTERM)
|
||
gl_FragColor.rgb=specularBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==52 && defined(CLEARCOAT)
|
||
gl_FragColor.rgb=clearCoatBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==53 && defined(SHEEN)
|
||
gl_FragColor.rgb=sheenBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==54 && defined(REFLECTION)
|
||
gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
|
||
#ifndef GAMMAREFLECTION
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==60
|
||
gl_FragColor.rgb=surfaceAlbedo.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==61
|
||
gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
|
||
gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
|
||
#elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
|
||
gl_FragColor.rgb=reflectivityOut.metallicF0;
|
||
#elif DEBUGMODE==63
|
||
gl_FragColor.rgb=vec3(roughness);
|
||
#elif DEBUGMODE==64
|
||
gl_FragColor.rgb=vec3(alphaG);
|
||
#elif DEBUGMODE==65
|
||
gl_FragColor.rgb=vec3(NdotV);
|
||
#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
|
||
gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==67 && defined(CLEARCOAT)
|
||
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
|
||
#elif DEBUGMODE==68 && defined(CLEARCOAT)
|
||
gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
|
||
#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
|
||
gl_FragColor.rgb=subSurfaceOut.transmittance;
|
||
#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
|
||
gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
|
||
#elif DEBUGMODE==72
|
||
gl_FragColor.rgb=vec3(microSurface);
|
||
#elif DEBUGMODE==73
|
||
gl_FragColor.rgb=vAlbedoColor.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
|
||
gl_FragColor.rgb=vReflectivityColor.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==75
|
||
gl_FragColor.rgb=vEmissiveColor.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
|
||
gl_FragColor.rgb=vec3(seo);
|
||
#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
gl_FragColor.rgb=vec3(eho);
|
||
#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
gl_FragColor.rgb=vec3(energyConservationFactor);
|
||
#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
gl_FragColor.rgb=specularEnvironmentReflectance;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
|
||
gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==86 && defined(ALPHABLEND)
|
||
gl_FragColor.rgb=vec3(luminanceOverAlpha);
|
||
#elif DEBUGMODE==87
|
||
gl_FragColor.rgb=vec3(alpha);
|
||
#elif DEBUGMODE==88 && defined(ALBEDO)
|
||
gl_FragColor.rgb=vec3(albedoTexture.a);
|
||
#elif DEBUGMODE==89
|
||
gl_FragColor.rgb=aoOut.ambientOcclusionColor.rgb;
|
||
#else
|
||
float stripeWidth=30.;float stripePos=floor(gl_FragCoord.x/stripeWidth);float whichColor=mod(stripePos,2.);vec3 color1=vec3(.6,.2,.2);vec3 color2=vec3(.3,.1,.1);gl_FragColor.rgb=mix(color1,color2,whichColor);
|
||
#endif
|
||
gl_FragColor.rgb*=vDebugMode.y;
|
||
#ifdef DEBUGMODE_NORMALIZE
|
||
gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
|
||
#endif
|
||
#ifdef DEBUGMODE_GAMMA
|
||
gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
|
||
#endif
|
||
gl_FragColor.a=1.0;
|
||
#ifdef PREPASS
|
||
gl_FragData[0]=toLinearSpace(gl_FragColor);
|
||
gl_FragData[1]=vec4(0.,0.,0.,0.);
|
||
#endif
|
||
#ifdef DEBUGMODE_FORCERETURN
|
||
return;
|
||
#endif
|
||
}
|
||
#endif
|
||
`;var o="pbrPixelShader",a=`#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
|
||
#extension GL_OES_standard_derivatives : enable
|
||
#endif
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#extension GL_EXT_shader_texture_lod : enable
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_BEGIN
|
||
#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
#include<prePassDeclaration>[SCENE_MRT_COUNT]
|
||
precision highp float;
|
||
#include<oitDeclaration>
|
||
#ifndef FROMLINEARSPACE
|
||
#define FROMLINEARSPACE
|
||
#endif
|
||
#include<__decl__pbrFragment>
|
||
#include<pbrFragmentExtraDeclaration>
|
||
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
||
#include<pbrFragmentSamplersDeclaration>
|
||
#include<imageProcessingDeclaration>
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#include<helperFunctions>
|
||
#include<subSurfaceScatteringFunctions>
|
||
#include<importanceSampling>
|
||
#include<pbrHelperFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#include<shadowsFragmentFunctions>
|
||
#include<harmonicsFunctions>
|
||
#include<pbrDirectLightingSetupFunctions>
|
||
#include<pbrDirectLightingFalloffFunctions>
|
||
#include<pbrBRDFFunctions>
|
||
#include<hdrFilteringFunctions>
|
||
#include<pbrDirectLightingFunctions>
|
||
#include<pbrIBLFunctions>
|
||
#include<bumpFragmentMainFunctions>
|
||
#include<bumpFragmentFunctions>
|
||
#ifdef REFLECTION
|
||
#include<reflectionFunction>
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
#include<pbrBlockAlbedoOpacity>
|
||
#include<pbrBlockReflectivity>
|
||
#include<pbrBlockAmbientOcclusion>
|
||
#include<pbrBlockAlphaFresnel>
|
||
#include<pbrBlockAnisotropic>
|
||
#include<pbrBlockReflection>
|
||
#include<pbrBlockSheen>
|
||
#include<pbrBlockClearcoat>
|
||
#include<pbrBlockIridescence>
|
||
#include<pbrBlockSubSurface>
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
#include<pbrBlockNormalGeometric>
|
||
#include<bumpFragment>
|
||
#include<pbrBlockNormalFinal>
|
||
albedoOpacityOutParams albedoOpacityOut;
|
||
#ifdef ALBEDO
|
||
vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
|
||
#endif
|
||
#ifdef OPACITY
|
||
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
|
||
#endif
|
||
#ifdef DECAL
|
||
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
|
||
#endif
|
||
albedoOpacityOut=albedoOpacityBlock(
|
||
vAlbedoColor
|
||
#ifdef ALBEDO
|
||
,albedoTexture
|
||
,vAlbedoInfos
|
||
#endif
|
||
#ifdef OPACITY
|
||
,opacityMap
|
||
,vOpacityInfos
|
||
#endif
|
||
#ifdef DETAIL
|
||
,detailColor
|
||
,vDetailInfos
|
||
#endif
|
||
#ifdef DECAL
|
||
,decalColor
|
||
,vDecalInfos
|
||
#endif
|
||
);vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha;
|
||
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
|
||
#include<depthPrePass>
|
||
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
||
ambientOcclusionOutParams aoOut;
|
||
#ifdef AMBIENT
|
||
vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
|
||
#endif
|
||
aoOut=ambientOcclusionBlock(
|
||
#ifdef AMBIENT
|
||
ambientOcclusionColorMap,
|
||
vAmbientInfos
|
||
#endif
|
||
);
|
||
#include<pbrBlockLightmapInit>
|
||
#ifdef UNLIT
|
||
vec3 diffuseBase=vec3(1.,1.,1.);
|
||
#else
|
||
vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut;
|
||
#if defined(REFLECTIVITY)
|
||
vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
|
||
#ifndef METALLICWORKFLOW
|
||
#ifdef REFLECTIVITY_GAMMA
|
||
surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
|
||
#endif
|
||
surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
|
||
#endif
|
||
#endif
|
||
#if defined(MICROSURFACEMAP)
|
||
vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
|
||
#endif
|
||
#ifdef METALLICWORKFLOW
|
||
vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
|
||
#ifdef REFLECTANCE
|
||
vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
|
||
#ifdef REFLECTANCE_GAMMA
|
||
reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
|
||
#endif
|
||
metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
|
||
#endif
|
||
#ifdef METALLIC_REFLECTANCE
|
||
vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
|
||
#ifdef METALLIC_REFLECTANCE_GAMMA
|
||
metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
|
||
#endif
|
||
#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
|
||
metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
|
||
#endif
|
||
metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
|
||
#endif
|
||
#endif
|
||
reflectivityOut=reflectivityBlock(
|
||
vReflectivityColor
|
||
#ifdef METALLICWORKFLOW
|
||
,surfaceAlbedo
|
||
,metallicReflectanceFactors
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
,vReflectivityInfos
|
||
,surfaceMetallicOrReflectivityColorMap
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
,aoOut.ambientOcclusionColor
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
,microSurfaceTexel
|
||
#endif
|
||
#ifdef DETAIL
|
||
,detailColor
|
||
,vDetailInfos
|
||
#endif
|
||
);float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;
|
||
#ifdef METALLICWORKFLOW
|
||
surfaceAlbedo=reflectivityOut.surfaceAlbedo;
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
|
||
#endif
|
||
#ifdef ALPHAFRESNEL
|
||
#if defined(ALPHATEST) || defined(ALPHABLEND)
|
||
alphaFresnelOutParams alphaFresnelOut;alphaFresnelOut=alphaFresnelBlock(
|
||
normalW,
|
||
viewDirectionW,
|
||
alpha,
|
||
microSurface
|
||
);alpha=alphaFresnelOut.alpha;
|
||
#endif
|
||
#endif
|
||
#include<pbrBlockGeometryInfo>
|
||
#ifdef ANISOTROPIC
|
||
anisotropicOutParams anisotropicOut;
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
|
||
#endif
|
||
anisotropicOut=anisotropicBlock(
|
||
vAnisotropy,
|
||
roughness,
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
anisotropyMapData,
|
||
#endif
|
||
TBN,
|
||
normalW,
|
||
viewDirectionW
|
||
);
|
||
#endif
|
||
#ifdef REFLECTION
|
||
reflectionOutParams reflectionOut;
|
||
#ifndef USE_CUSTOM_REFLECTION
|
||
reflectionOut=reflectionBlock(
|
||
vPositionW
|
||
,normalW
|
||
,alphaG
|
||
,vReflectionMicrosurfaceInfos
|
||
,vReflectionInfos
|
||
,vReflectionColor
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut
|
||
#endif
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,NdotVUnclamped
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,roughness
|
||
#endif
|
||
,reflectionSampler
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
||
,vEnvironmentIrradiance
|
||
#endif
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,reflectionMatrix
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
,irradianceSampler
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionSamplerLow
|
||
,reflectionSamplerHigh
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
);
|
||
#else
|
||
#define CUSTOM_REFLECTION
|
||
#endif
|
||
#endif
|
||
#include<pbrBlockReflectance0>
|
||
#ifdef SHEEN
|
||
sheenOutParams sheenOut;
|
||
#ifdef SHEEN_TEXTURE
|
||
vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
|
||
#endif
|
||
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
|
||
#endif
|
||
sheenOut=sheenBlock(
|
||
vSheenColor
|
||
#ifdef SHEEN_ROUGHNESS
|
||
,vSheenRoughness
|
||
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,sheenMapRoughnessData
|
||
#endif
|
||
#endif
|
||
,roughness
|
||
#ifdef SHEEN_TEXTURE
|
||
,sheenMapData
|
||
,vSheenInfos.y
|
||
#endif
|
||
,reflectance
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
,baseColor
|
||
,surfaceAlbedo
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
,NdotV
|
||
,environmentBrdf
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
,AARoughnessFactors
|
||
,vReflectionMicrosurfaceInfos
|
||
,vReflectionInfos
|
||
,vReflectionColor
|
||
,vLightingIntensity
|
||
,reflectionSampler
|
||
,reflectionOut.reflectionCoords
|
||
,NdotVUnclamped
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionSamplerLow
|
||
,reflectionSamplerHigh
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
||
,seo
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
,eho
|
||
#endif
|
||
#endif
|
||
);
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
surfaceAlbedo=sheenOut.surfaceAlbedo;
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
|
||
#endif
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
iridescenceOutParams iridescenceOut;
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
vec2 iridescenceMapData=texture2D(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
vec2 iridescenceThicknessMapData=texture2D(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
|
||
#endif
|
||
iridescenceOut=iridescenceBlock(
|
||
vIridescenceParams
|
||
,NdotV
|
||
,specularEnvironmentR0
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
,iridescenceMapData
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
,iridescenceThicknessMapData
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
,NdotVUnclamped
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,clearCoatMapData
|
||
#endif
|
||
#endif
|
||
);float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
|
||
#endif
|
||
clearcoatOutParams clearcoatOut;
|
||
#ifdef CLEARCOAT
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
|
||
#endif
|
||
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
||
vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
|
||
#endif
|
||
clearcoatOut=clearcoatBlock(
|
||
vPositionW
|
||
,geometricNormalW
|
||
,viewDirectionW
|
||
,vClearCoatParams
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,clearCoatMapRoughnessData
|
||
#endif
|
||
,specularEnvironmentR0
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,clearCoatMapData
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
,vClearCoatTintParams
|
||
,clearCoatColorAtDistance
|
||
,vClearCoatRefractionParams
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
,clearCoatTintMapData
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
,vClearCoatBumpInfos
|
||
,clearCoatBumpMapData
|
||
,vClearCoatBumpUV
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
,vTBN
|
||
#else
|
||
,vClearCoatTangentSpaceParams
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
,normalMatrix
|
||
#endif
|
||
#endif
|
||
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
,faceNormal
|
||
#endif
|
||
#ifdef REFLECTION
|
||
,vReflectionMicrosurfaceInfos
|
||
,vReflectionInfos
|
||
,vReflectionColor
|
||
,vLightingIntensity
|
||
,reflectionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionSamplerLow
|
||
,reflectionSamplerHigh
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
|
||
,(gl_FrontFacing ? 1. : -1.)
|
||
#endif
|
||
);
|
||
#else
|
||
clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
|
||
#endif
|
||
#include<pbrBlockReflectance>
|
||
subSurfaceOutParams subSurfaceOut;
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
vec4 translucencyColorMap=texture2D(translucencyColorSampler,vTranslucencyColorUV+uvOffset);
|
||
#endif
|
||
subSurfaceOut=subSurfaceBlock(
|
||
vSubSurfaceIntensity
|
||
,vThicknessParam
|
||
,vTintColor
|
||
,normalW
|
||
,specularEnvironmentReflectance
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
,thicknessMap
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
,refractionIntensityMap
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
,translucencyIntensityMap
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef SS_TRANSLUCENCY
|
||
,reflectionMatrix
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,reflectionOut.irradianceVector
|
||
#endif
|
||
#if defined(REALTIME_FILTERING)
|
||
,reflectionSampler
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
,irradianceSampler
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
|
||
,surfaceAlbedo
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
,vPositionW
|
||
,viewDirectionW
|
||
,view
|
||
,vRefractionInfos
|
||
,refractionMatrix
|
||
,vRefractionMicrosurfaceInfos
|
||
,vLightingIntensity
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
,alpha
|
||
#endif
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
,NdotVUnclamped
|
||
#endif
|
||
#ifdef SS_LINEARSPECULARREFRACTION
|
||
,roughness
|
||
#endif
|
||
,alphaG
|
||
,refractionSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionSamplerLow
|
||
,refractionSamplerHigh
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vRefractionFilteringInfo
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,vRefractionPosition
|
||
,vRefractionSize
|
||
#endif
|
||
#ifdef SS_DISPERSION
|
||
,dispersion
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
,vDiffusionDistance
|
||
,vTranslucencyColor
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
,translucencyColorMap
|
||
#endif
|
||
#endif
|
||
);
|
||
#ifdef SS_REFRACTION
|
||
surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
alpha=subSurfaceOut.alpha;
|
||
#endif
|
||
#endif
|
||
#else
|
||
subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
|
||
#endif
|
||
#include<pbrBlockDirectLighting>
|
||
#include<lightFragment>[0..maxSimultaneousLights]
|
||
#include<pbrBlockFinalLitComponents>
|
||
#endif
|
||
#include<pbrBlockFinalUnlitComponents>
|
||
#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
|
||
#include<pbrBlockFinalColorComposition>
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>(color,finalColor)
|
||
#include<pbrBlockImageProcessing>
|
||
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
|
||
#ifdef PREPASS
|
||
float writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0;
|
||
#ifdef PREPASS_POSITION
|
||
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
gl_FragData[PREPASS_LOCAL_POSITION_INDEX] =
|
||
vec4(vPosition,writeGeometryInfo);
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY)
|
||
vec2 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);
|
||
#elif defined(PREPASS_VELOCITY_LINEAR)
|
||
vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) -
|
||
(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX] =
|
||
vec4(velocity,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_ALBEDO_SQRT
|
||
vec3 sqAlbedo=sqrt(surfaceAlbedo);
|
||
#endif
|
||
#ifdef PREPASS_IRRADIANCE
|
||
vec3 irradiance=finalDiffuse;
|
||
#ifndef UNLIT
|
||
#ifdef REFLECTION
|
||
irradiance+=finalIrradiance;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_SCATTERING
|
||
gl_FragData[0]=vec4(finalColor.rgb-irradiance,
|
||
finalColor.a);
|
||
irradiance/=sqAlbedo;
|
||
#else
|
||
gl_FragData[0]=finalColor;
|
||
float scatteringDiffusionProfile=255.;
|
||
#endif
|
||
gl_FragData[PREPASS_IRRADIANCE_INDEX] =
|
||
vec4(clamp(irradiance,vec3(0.),vec3(1.)),
|
||
writeGeometryInfo*scatteringDiffusionProfile /
|
||
255.);
|
||
#else
|
||
gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
gl_FragData[PREPASS_DEPTH_INDEX] =
|
||
vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_SCREENSPACE_DEPTH
|
||
gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX] =
|
||
vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_NORMAL
|
||
#ifdef PREPASS_NORMAL_WORLDSPACE
|
||
gl_FragData[PREPASS_NORMAL_INDEX] =
|
||
vec4(normalW,writeGeometryInfo);
|
||
#else
|
||
gl_FragData[PREPASS_NORMAL_INDEX] =
|
||
vec4(normalize((view*vec4(normalW,0.0)).rgb),
|
||
writeGeometryInfo);
|
||
#endif
|
||
#endif
|
||
#ifdef PREPASS_WORLD_NORMAL
|
||
gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_ALBEDO_SQRT
|
||
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_REFLECTIVITY
|
||
#ifndef UNLIT
|
||
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;
|
||
#else
|
||
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if !defined(PREPASS) || defined(WEBGL2)
|
||
gl_FragColor=finalColor;
|
||
#endif
|
||
#include<oitFragment>
|
||
#if ORDER_INDEPENDENT_TRANSPARENCY
|
||
if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
|
||
#endif
|
||
#include<pbrDebug>
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},17152:(r,t,e)=>{e.r(t),e.d(t,{pbrVertexShader:()=>s});var n=e(98519),i=(e(42858),"pbrVertexDeclaration");n.l.IncludesShadersStore[i]=`uniform mat4 view;uniform mat4 viewProjection;
|
||
#ifdef ALBEDO
|
||
uniform mat4 albedoMatrix;uniform vec2 vAlbedoInfos;
|
||
#endif
|
||
#ifdef AMBIENT
|
||
uniform mat4 ambientMatrix;uniform vec4 vAmbientInfos;
|
||
#endif
|
||
#ifdef OPACITY
|
||
uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix;
|
||
#endif
|
||
#ifdef LIGHTMAP
|
||
uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix;
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
uniform vec3 vReflectivityInfos;uniform mat4 reflectivityMatrix;
|
||
#endif
|
||
#ifdef METALLIC_REFLECTANCE
|
||
uniform vec2 vMetallicReflectanceInfos;uniform mat4 metallicReflectanceMatrix;
|
||
#endif
|
||
#ifdef REFLECTANCE
|
||
uniform vec2 vReflectanceInfos;uniform mat4 reflectanceMatrix;
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
uniform vec2 vMicroSurfaceSamplerInfos;uniform mat4 microSurfaceSamplerMatrix;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform vec3 vBumpInfos;uniform mat4 bumpMatrix;
|
||
#endif
|
||
#ifdef POINTSIZE
|
||
uniform float pointSize;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix;
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
|
||
uniform vec4 vClearCoatInfos;
|
||
#endif
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
uniform mat4 clearCoatMatrix;
|
||
#endif
|
||
#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
|
||
uniform mat4 clearCoatRoughnessMatrix;
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
uniform vec2 vClearCoatBumpInfos;uniform mat4 clearCoatBumpMatrix;
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)
|
||
uniform vec4 vIridescenceInfos;
|
||
#endif
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
uniform mat4 iridescenceMatrix;
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
uniform mat4 iridescenceThicknessMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
|
||
uniform vec4 vSheenInfos;
|
||
#endif
|
||
#ifdef SHEEN_TEXTURE
|
||
uniform mat4 sheenMatrix;
|
||
#endif
|
||
#ifdef SHEEN_TEXTURE_ROUGHNESS
|
||
uniform mat4 sheenRoughnessMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_REFRACTION
|
||
uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;
|
||
#endif
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
uniform vec2 vTranslucencyColorInfos;uniform mat4 translucencyColorMatrix;
|
||
#endif
|
||
#endif
|
||
#ifdef NORMAL
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#ifdef SPHERICAL_HARMONICS
|
||
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
|
||
#else
|
||
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef DETAIL
|
||
uniform vec4 vDetailInfos;uniform mat4 detailMatrix;
|
||
#endif
|
||
#include<decalVertexDeclaration>
|
||
#define ADDITIONAL_VERTEX_DECLARATION
|
||
`,e(48915),e(77976),e(48493),e(75334),e(36470),e(64400),e(38615),e(60965),e(60581),e(92518),e(42513),e(85637),e(72153),e(94785),e(48961),e(24444),e(67369),e(59262),e(58266),e(84589),e(35397),e(76898),e(49334),e(7761),e(45858),e(81067),e(35845),e(83057),e(62589),e(62136),e(45812),e(56458);var o="pbrVertexShader",a=`precision highp float;
|
||
#include<__decl__pbrVertex>
|
||
#define CUSTOM_VERTEX_BEGIN
|
||
attribute vec3 position;
|
||
#ifdef NORMAL
|
||
attribute vec3 normal;
|
||
#endif
|
||
#ifdef TANGENT
|
||
attribute vec4 tangent;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#include<uvAttributeDeclaration>[2..7]
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#ifdef VERTEXCOLOR
|
||
attribute vec4 color;
|
||
#endif
|
||
#include<helperFunctions>
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<instancesDeclaration>
|
||
#include<prePassVertexDeclaration>
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
|
||
#ifdef CLEARCOAT
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness)
|
||
#endif
|
||
#ifdef SHEEN
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor)
|
||
#endif
|
||
varying vec3 vPositionW;
|
||
#if DEBUGMODE>0
|
||
varying vec4 vClipSpacePosition;
|
||
#endif
|
||
#ifdef NORMAL
|
||
varying vec3 vNormalW;
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
varying vec3 vEnvironmentIrradiance;
|
||
#include<harmonicsFunctions>
|
||
#endif
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vec4 vColor;
|
||
#endif
|
||
#include<bumpVertexDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vec3 vPositionUVW;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vec3 vDirectionW;
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vec3 positionUpdated=position;
|
||
#ifdef NORMAL
|
||
vec3 normalUpdated=normal;
|
||
#endif
|
||
#ifdef TANGENT
|
||
vec4 tangentUpdated=tangent;
|
||
#endif
|
||
#ifdef UV1
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
vPositionUVW=positionUpdated;
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_POSITION
|
||
#define CUSTOM_VERTEX_UPDATE_NORMAL
|
||
#include<instancesVertex>
|
||
#if defined(PREPASS) && (defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED) || defined(PREPASS_VELOCITY_LINEAR))
|
||
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
|
||
#endif
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vPositionW=vec3(worldPos);
|
||
#include<prePassVertex>
|
||
#ifdef NORMAL
|
||
mat3 normalWorld=mat3(finalWorld);
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normalWorld=transposeMat3(inverseMat3(normalWorld));
|
||
#endif
|
||
vNormalW=normalize(normalWorld*normalUpdated);
|
||
#endif
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
reflectionVector.z*=-1.0;
|
||
#endif
|
||
vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
|
||
#endif
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_WORLDPOS
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
|
||
#else
|
||
gl_Position=viewProjection*worldPos;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
vClipSpacePosition=gl_Position;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
|
||
#endif
|
||
#ifndef UV1
|
||
vec2 uvUpdated=vec2(0.,0.);
|
||
#endif
|
||
#ifdef MAINUV1
|
||
vMainUV1=uvUpdated;
|
||
#endif
|
||
#include<uvVariableDeclaration>[2..7]
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
|
||
#ifdef CLEARCOAT
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z)
|
||
#endif
|
||
#ifdef SHEEN
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheenRoughness,_INFONAME_,SheenInfos.z)
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_MATRIXNAME_,translucencyColor,_INFONAME_,TranslucencyColorInfos.x)
|
||
#endif
|
||
#include<bumpVertex>
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<shadowsVertex>[0..maxSimultaneousLights]
|
||
#include<vertexColorMixing>
|
||
#if defined(POINTSIZE) && !defined(WEBGPU)
|
||
gl_PointSize=pointSize;
|
||
#endif
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},98197:(r,t,e)=>{e.r(t),e.d(t,{pickingPixelShader:()=>o});var n="pickingPixelShader",i=`#if defined(INSTANCES)
|
||
varying vec4 vMeshID;
|
||
#else
|
||
uniform vec4 meshID;
|
||
#endif
|
||
void main(void) {
|
||
#if defined(INSTANCES)
|
||
gl_FragColor=vMeshID;
|
||
#else
|
||
gl_FragColor=meshID;
|
||
#endif
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},30683:(r,t,e)=>{e.r(t),e.d(t,{pickingVertexShader:()=>a});var n=e(98519),i=(e(36470),e(64400),e(24444),e(67369),e(38615),e(58266),e(84589),e(35397),e(76898),e(49334),"pickingVertexShader"),o=`attribute vec3 position;
|
||
#if defined(INSTANCES)
|
||
attribute vec4 instanceMeshID;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesDeclaration>
|
||
uniform mat4 viewProjection;
|
||
#if defined(INSTANCES)
|
||
varying vec4 vMeshID;
|
||
#endif
|
||
void main(void) {
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;
|
||
#if defined(INSTANCES)
|
||
vMeshID=instanceMeshID;
|
||
#endif
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},96795:(r,t,e)=>{e.r(t),e.d(t,{postprocessVertexShader:()=>o});var n="postprocessVertexShader",i=`attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},6777:(r,t,e)=>{e.r(t),e.d(t,{proceduralVertexShader:()=>o});var n="proceduralVertexShader",i=`attribute vec2 position;varying vec2 vPosition;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vPosition=position;vUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},32407:(r,t,e)=>{e.r(t),e.d(t,{rgbdDecodePixelShader:()=>a});var n=e(98519),i=(e(75334),"rgbdDecodePixelShader"),o=`varying vec2 vUV;uniform sampler2D textureSampler;
|
||
#include<helperFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},22955:(r,t,e)=>{e.r(t),e.d(t,{rgbdEncodePixelShader:()=>a});var n=e(98519),i=(e(75334),"rgbdEncodePixelShader"),o=`varying vec2 vUV;uniform sampler2D textureSampler;
|
||
#include<helperFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},91209:(r,t,e)=>{e.r(t),e.d(t,{rsmFullGlobalIlluminationPixelShader:()=>o});var n="rsmFullGlobalIlluminationPixelShader",i=`/**
|
||
* The implementation is a direct application of the formula found in http:
|
||
*/
|
||
precision highp float;varying vec2 vUV;uniform mat4 rsmLightMatrix;uniform vec4 rsmInfo;uniform sampler2D textureSampler;uniform sampler2D normalSampler;uniform sampler2D rsmPositionW;uniform sampler2D rsmNormalW;uniform sampler2D rsmFlux;
|
||
#ifdef TRANSFORM_NORMAL
|
||
uniform mat4 invView;
|
||
#endif
|
||
vec3 computeIndirect(vec3 p,vec3 n) {vec3 indirectDiffuse=vec3(0.);float intensity=rsmInfo.z;float edgeArtifactCorrection=rsmInfo.w;vec4 texRSM=rsmLightMatrix*vec4(p,1.);texRSM.xy/=texRSM.w;texRSM.xy=texRSM.xy*0.5+0.5;int width=int(rsmInfo.x);int height=int(rsmInfo.y);for (int j=0; j<height; j++) {for (int i=0; i<width; i++) {ivec2 uv=ivec2(i,j);vec3 vplPositionW=texelFetch(rsmPositionW,uv,0).xyz;vec3 vplNormalW=texelFetch(rsmNormalW,uv,0).xyz*2.0-1.0;vec3 vplFlux=texelFetch(rsmFlux,uv,0).rgb;vplPositionW-=vplNormalW*edgeArtifactCorrection;
|
||
float dist2=dot(vplPositionW-p,vplPositionW-p);indirectDiffuse+=vplFlux*max(0.,dot(n,vplPositionW-p))*max(0.,dot(vplNormalW,p-vplPositionW))/(dist2*dist2);}}
|
||
return clamp(indirectDiffuse*intensity,0.0,1.0);}
|
||
void main(void)
|
||
{vec3 positionW=texture2D(textureSampler,vUV).xyz;vec3 normalW=texture2D(normalSampler,vUV).xyz;
|
||
#ifdef DECODE_NORMAL
|
||
normalW=normalW*2.0-1.0;
|
||
#endif
|
||
#ifdef TRANSFORM_NORMAL
|
||
normalW=(invView*vec4(normalW,0.)).xyz;
|
||
#endif
|
||
gl_FragColor.rgb=computeIndirect(positionW,normalW);gl_FragColor.a=1.0;}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},76526:(r,t,e)=>{e.r(t),e.d(t,{rsmGlobalIlluminationPixelShader:()=>o});var n="rsmGlobalIlluminationPixelShader",i=`/**
|
||
* The implementation is an application of the formula found in http:
|
||
* For better results,it also adds a random (noise) rotation to the RSM samples (the noise artifacts are easier to remove than the banding artifacts).
|
||
*/
|
||
precision highp float;varying vec2 vUV;uniform mat4 rsmLightMatrix;uniform vec4 rsmInfo;uniform vec4 rsmInfo2;uniform sampler2D textureSampler;uniform sampler2D normalSampler;uniform sampler2D rsmPositionW;uniform sampler2D rsmNormalW;uniform sampler2D rsmFlux;uniform sampler2D rsmSamples;
|
||
#ifdef TRANSFORM_NORMAL
|
||
uniform mat4 invView;
|
||
#endif
|
||
float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}
|
||
vec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}
|
||
vec4 perm(vec4 x){return mod289(((x*34.0)+1.0)*x);}
|
||
float noise(vec3 p){vec3 a=floor(p);vec3 d=p-a;d=d*d*(3.0-2.0*d);vec4 b=a.xxyy+vec4(0.0,1.0,0.0,1.0);vec4 k1=perm(b.xyxy);vec4 k2=perm(k1.xyxy+b.zzww);vec4 c=k2+a.zzzz;vec4 k3=perm(c);vec4 k4=perm(c+1.0);vec4 o1=fract(k3*(1.0/41.0));vec4 o2=fract(k4*(1.0/41.0));vec4 o3=o2*d.z+o1*(1.0-d.z);vec2 o4=o3.yw*d.x+o3.xz*(1.0-d.x);return o4.y*d.y+o4.x*(1.0-d.y);}
|
||
vec3 computeIndirect(vec3 p,vec3 n) {vec3 indirectDiffuse=vec3(0.);int numSamples=int(rsmInfo.x);float radius=rsmInfo.y;float intensity=rsmInfo.z;float edgeArtifactCorrection=rsmInfo.w;vec4 texRSM=rsmLightMatrix*vec4(p,1.);texRSM.xy/=texRSM.w;texRSM.xy=texRSM.xy*0.5+0.5;float angle=noise(p*rsmInfo2.x);float c=cos(angle);float s=sin(angle);for (int i=0; i<numSamples; i++) {vec3 rsmSample=texelFetch(rsmSamples,ivec2(i,0),0).xyz;float weightSquare=rsmSample.z;if (rsmInfo2.y==1.0) rsmSample.xy=vec2(rsmSample.x*c+rsmSample.y*s,-rsmSample.x*s+rsmSample.y*c);vec2 uv=texRSM.xy+rsmSample.xy*radius;if (uv.x<0. || uv.x>1. || uv.y<0. || uv.y>1.) continue;vec3 vplPositionW=textureLod(rsmPositionW,uv,0.).xyz;vec3 vplNormalW=textureLod(rsmNormalW,uv,0.).xyz*2.0-1.0;vec3 vplFlux=textureLod(rsmFlux,uv,0.).rgb;vplPositionW-=vplNormalW*edgeArtifactCorrection;
|
||
float dist2=dot(vplPositionW-p,vplPositionW-p);indirectDiffuse+=vplFlux*weightSquare*max(0.,dot(n,vplPositionW-p))*max(0.,dot(vplNormalW,p-vplPositionW))/(dist2*dist2);}
|
||
return clamp(indirectDiffuse*intensity,0.0,1.0);}
|
||
void main(void)
|
||
{vec3 positionW=texture2D(textureSampler,vUV).xyz;vec3 normalW=texture2D(normalSampler,vUV).xyz;
|
||
#ifdef DECODE_NORMAL
|
||
normalW=normalW*2.0-1.0;
|
||
#endif
|
||
#ifdef TRANSFORM_NORMAL
|
||
normalW=(invView*vec4(normalW,0.)).xyz;
|
||
#endif
|
||
gl_FragColor.rgb=computeIndirect(positionW,normalW);gl_FragColor.a=1.0;}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},72527:(r,t,e)=>{e.r(t),e.d(t,{screenSpaceReflection2PixelShader:()=>a});var n=e(98519),i=(e(75334),e(64244),e(93664),"screenSpaceReflection2PixelShader"),o=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
|
||
#define TEXTURECUBEFUNC(s,c,lod) textureLod(s,c,lod)
|
||
#else
|
||
#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
|
||
#define TEXTURECUBEFUNC(s,c,bias) textureCube(s,c,bias)
|
||
#endif
|
||
uniform sampler2D textureSampler;varying vec2 vUV;
|
||
#ifdef SSR_SUPPORTED
|
||
uniform sampler2D reflectivitySampler;uniform sampler2D normalSampler;uniform sampler2D depthSampler;
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
uniform sampler2D backDepthSampler;uniform float backSizeFactor;
|
||
#endif
|
||
#ifdef SSR_USE_ENVIRONMENT_CUBE
|
||
uniform samplerCube envCubeSampler;
|
||
#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC
|
||
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
|
||
#endif
|
||
#endif
|
||
uniform mat4 view;uniform mat4 invView;uniform mat4 projection;uniform mat4 invProjectionMatrix;uniform mat4 projectionPixel;uniform float nearPlaneZ;uniform float stepSize;uniform float maxSteps;uniform float strength;uniform float thickness;uniform float roughnessFactor;uniform float reflectionSpecularFalloffExponent;uniform float maxDistance;uniform float selfCollisionNumSkip;uniform float reflectivityThreshold;
|
||
#include<helperFunctions>
|
||
#include<pbrBRDFFunctions>
|
||
#include<screenSpaceRayTrace>
|
||
vec3 hash(vec3 a)
|
||
{a=fract(a*0.8);a+=dot(a,a.yxz+19.19);return fract((a.xxy+a.yxx)*a.zyx);}
|
||
float computeAttenuationForIntersection(ivec2 hitPixel,vec2 hitUV,vec3 vsRayOrigin,vec3 vsHitPoint,vec3 reflectionVector,float maxRayDistance,float numIterations) {float attenuation=1.0;
|
||
#ifdef SSR_ATTENUATE_SCREEN_BORDERS
|
||
vec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-hitUV.xy));attenuation*=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_INTERSECTION_DISTANCE
|
||
attenuation*=1.0-clamp(distance(vsRayOrigin,vsHitPoint)/maxRayDistance,0.0,1.0);
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_INTERSECTION_NUMITERATIONS
|
||
attenuation*=1.0-(numIterations/maxSteps);
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_BACKFACE_REFLECTION
|
||
vec3 reflectionNormal=texelFetch(normalSampler,hitPixel,0).xyz;float directionBasedAttenuation=smoothstep(-0.17,0.0,dot(reflectionNormal,-reflectionVector));attenuation*=directionBasedAttenuation;
|
||
#endif
|
||
return attenuation;}
|
||
#endif
|
||
void main()
|
||
{
|
||
#ifdef SSR_SUPPORTED
|
||
vec4 colorFull=TEXTUREFUNC(textureSampler,vUV,0.0);vec3 color=colorFull.rgb;vec4 reflectivity=TEXTUREFUNC(reflectivitySampler,vUV,0.0);
|
||
#ifndef SSR_DISABLE_REFLECTIVITY_TEST
|
||
if (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=reflectivityThreshold) {
|
||
#ifdef SSR_USE_BLUR
|
||
gl_FragColor=vec4(0.);
|
||
#else
|
||
gl_FragColor=colorFull;
|
||
#endif
|
||
return;}
|
||
#endif
|
||
#ifdef SSR_INPUT_IS_GAMMA_SPACE
|
||
color=toLinearSpace(color);
|
||
#endif
|
||
vec2 texSize=vec2(textureSize(depthSampler,0));vec3 csNormal=texelFetch(normalSampler,ivec2(vUV*texSize),0).xyz;
|
||
#ifdef SSR_DECODE_NORMAL
|
||
csNormal=csNormal*2.0-1.0;
|
||
#endif
|
||
#ifdef SSR_NORMAL_IS_IN_WORLDSPACE
|
||
csNormal=(view*vec4(csNormal,0.0)).xyz;
|
||
#endif
|
||
float depth=texelFetch(depthSampler,ivec2(vUV*texSize),0).r;vec3 csPosition=computeViewPosFromUVDepth(vUV,depth,projection,invProjectionMatrix);
|
||
#ifdef ORTHOGRAPHIC_CAMERA
|
||
vec3 csViewDirection=vec3(0.,0.,1.);
|
||
#else
|
||
vec3 csViewDirection=normalize(csPosition);
|
||
#endif
|
||
vec3 csReflectedVector=reflect(csViewDirection,csNormal);
|
||
#ifdef SSR_USE_ENVIRONMENT_CUBE
|
||
vec3 wReflectedVector=vec3(invView*vec4(csReflectedVector,0.0));
|
||
#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC
|
||
vec4 worldPos=invView*vec4(csPosition,1.0);wReflectedVector=parallaxCorrectNormal(worldPos.xyz,normalize(wReflectedVector),vReflectionSize,vReflectionPosition);
|
||
#endif
|
||
#ifdef SSR_INVERTCUBICMAP
|
||
wReflectedVector.y*=-1.0;
|
||
#endif
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
wReflectedVector.z*=-1.0;
|
||
#endif
|
||
vec3 envColor=TEXTURECUBEFUNC(envCubeSampler,wReflectedVector,0.0).xyz;
|
||
#ifdef SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE
|
||
envColor=toLinearSpace(envColor);
|
||
#endif
|
||
#else
|
||
vec3 envColor=color;
|
||
#endif
|
||
float reflectionAttenuation=1.0;bool rayHasHit=false;vec2 startPixel;vec2 hitPixel;vec3 hitPoint;float numIterations;
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
vec3 debugColor;
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_FACING_CAMERA
|
||
reflectionAttenuation*=1.0-smoothstep(0.25,0.5,dot(-csViewDirection,csReflectedVector));
|
||
#endif
|
||
if (reflectionAttenuation>0.0) {
|
||
#ifdef SSR_USE_BLUR
|
||
vec3 jitt=vec3(0.);
|
||
#else
|
||
float roughness=1.0-reflectivity.a;vec3 jitt=mix(vec3(0.0),hash(csPosition)-vec3(0.5),roughness)*roughnessFactor;
|
||
#endif
|
||
vec2 uv2=vUV*texSize;float c=(uv2.x+uv2.y)*0.25;float jitter=mod(c,1.0);
|
||
rayHasHit=traceScreenSpaceRay1(
|
||
csPosition,
|
||
normalize(csReflectedVector+jitt),
|
||
projectionPixel,
|
||
depthSampler,
|
||
texSize,
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
backDepthSampler,
|
||
backSizeFactor,
|
||
#endif
|
||
thickness,
|
||
nearPlaneZ,
|
||
stepSize,
|
||
jitter,
|
||
maxSteps,
|
||
maxDistance,
|
||
selfCollisionNumSkip,
|
||
startPixel,
|
||
hitPixel,
|
||
hitPoint,
|
||
numIterations
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
,debugColor
|
||
#endif
|
||
);}
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
gl_FragColor=vec4(debugColor,1.);return;
|
||
#endif
|
||
vec3 F0=reflectivity.rgb;vec3 fresnel=fresnelSchlickGGX(max(dot(csNormal,-csViewDirection),0.0),F0,vec3(1.));vec3 SSR=envColor;if (rayHasHit) {vec3 reflectedColor=texelFetch(textureSampler,ivec2(hitPixel),0).rgb;
|
||
#ifdef SSR_INPUT_IS_GAMMA_SPACE
|
||
reflectedColor=toLinearSpace(reflectedColor);
|
||
#endif
|
||
reflectionAttenuation*=computeAttenuationForIntersection(ivec2(hitPixel),hitPixel/texSize,csPosition,hitPoint,csReflectedVector,maxDistance,numIterations);SSR=reflectedColor*reflectionAttenuation+(1.0-reflectionAttenuation)*envColor;}
|
||
#ifndef SSR_BLEND_WITH_FRESNEL
|
||
SSR*=fresnel;
|
||
#endif
|
||
#ifdef SSR_USE_BLUR
|
||
float blur_radius=0.0;float roughness=1.0-reflectivity.a*(1.0-roughnessFactor);if (roughness>0.001) {float cone_angle=min(roughness,0.999)*3.14159265*0.5;float cone_len=distance(startPixel,hitPixel);float op_len=2.0*tan(cone_angle)*cone_len;
|
||
float a=op_len;float h=cone_len;float a2=a*a;float fh2=4.0f*h*h;blur_radius=(a*(sqrt(a2+fh2)-a))/(4.0f*h);}
|
||
gl_FragColor=vec4(SSR,blur_radius/255.0);
|
||
#else
|
||
#ifdef SSR_BLEND_WITH_FRESNEL
|
||
vec3 reflectionMultiplier=clamp(pow(fresnel*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
|
||
#else
|
||
vec3 reflectionMultiplier=clamp(pow(reflectivity.rgb*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
|
||
#endif
|
||
vec3 colorMultiplier=1.0-reflectionMultiplier;vec3 finalColor=(color*colorMultiplier)+(SSR*reflectionMultiplier);
|
||
#ifdef SSR_OUTPUT_IS_GAMMA_SPACE
|
||
finalColor=toGammaSpace(finalColor);
|
||
#endif
|
||
gl_FragColor=vec4(finalColor,colorFull.a);
|
||
#endif
|
||
#else
|
||
gl_FragColor=TEXTUREFUNC(textureSampler,vUV,0.0);
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},12064:(r,t,e)=>{e.r(t),e.d(t,{screenSpaceReflection2BlurPixelShader:()=>o});var n="screenSpaceReflection2BlurPixelShader",i=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)
|
||
#else
|
||
#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)
|
||
#endif
|
||
uniform sampler2D textureSampler;varying vec2 vUV;uniform vec2 texelOffsetScale;const float weights[8]=float[8] (0.071303,0.131514,0.189879,0.321392,0.452906, 0.584419,0.715932,0.847445);void processSample(vec2 uv,float i,vec2 stepSize,inout vec4 accumulator,inout float denominator)
|
||
{vec2 offsetUV=stepSize*i+uv;float coefficient=weights[int(2.0-abs(i))];accumulator+=TEXTUREFUNC(textureSampler,offsetUV,0.0)*coefficient;denominator+=coefficient;}
|
||
void main()
|
||
{vec4 colorFull=TEXTUREFUNC(textureSampler,vUV,0.0);if (dot(colorFull,vec4(1.0))==0.0) {gl_FragColor=colorFull;return;}
|
||
float blurRadius=colorFull.a*255.0;
|
||
vec2 stepSize=texelOffsetScale.xy*blurRadius;vec4 accumulator=TEXTUREFUNC(textureSampler,vUV,0.0)*0.214607;float denominator=0.214607;processSample(vUV,1.0,stepSize,accumulator,denominator);processSample(vUV,1.0*0.2,stepSize,accumulator,denominator);processSample(vUV,1.0*0.4,stepSize,accumulator,denominator);processSample(vUV,1.0*0.6,stepSize,accumulator,denominator);processSample(vUV,1.0*0.8,stepSize,accumulator,denominator);processSample(vUV,1.0*1.2,stepSize,accumulator,denominator);processSample(vUV,1.0*1.4,stepSize,accumulator,denominator);processSample(vUV,1.0*1.6,stepSize,accumulator,denominator);processSample(vUV,1.0*1.8,stepSize,accumulator,denominator);processSample(vUV,1.0*2.0,stepSize,accumulator,denominator);processSample(vUV,-1.0,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.2,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.4,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.6,stepSize,accumulator,denominator);processSample(vUV,-1.0*0.8,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.2,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.4,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.6,stepSize,accumulator,denominator);processSample(vUV,-1.0*1.8,stepSize,accumulator,denominator);processSample(vUV,-1.0*2.0,stepSize,accumulator,denominator);gl_FragColor=vec4(accumulator.rgb/denominator,colorFull.a);}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},88331:(r,t,e)=>{e.r(t),e.d(t,{screenSpaceReflection2BlurCombinerPixelShader:()=>a});var n=e(98519),i=(e(75334),e(64244),e(93664),"screenSpaceReflection2BlurCombinerPixelShader"),o=`uniform sampler2D textureSampler;
|
||
uniform sampler2D mainSampler;uniform sampler2D reflectivitySampler;uniform float strength;uniform float reflectionSpecularFalloffExponent;uniform float reflectivityThreshold;varying vec2 vUV;
|
||
#include<helperFunctions>
|
||
#ifdef SSR_BLEND_WITH_FRESNEL
|
||
#include<pbrBRDFFunctions>
|
||
#include<screenSpaceRayTrace>
|
||
uniform mat4 projection;uniform mat4 invProjectionMatrix;uniform sampler2D normalSampler;uniform sampler2D depthSampler;
|
||
#endif
|
||
void main()
|
||
{
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
gl_FragColor=texture2D(textureSampler,vUV);
|
||
#else
|
||
vec3 SSR=texture2D(textureSampler,vUV).rgb;vec4 color=texture2D(mainSampler,vUV);vec4 reflectivity=texture2D(reflectivitySampler,vUV);
|
||
#ifndef SSR_DISABLE_REFLECTIVITY_TEST
|
||
if (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=reflectivityThreshold) {gl_FragColor=color;return;}
|
||
#endif
|
||
#ifdef SSR_INPUT_IS_GAMMA_SPACE
|
||
color=toLinearSpace(color);
|
||
#endif
|
||
#ifdef SSR_BLEND_WITH_FRESNEL
|
||
vec2 texSize=vec2(textureSize(depthSampler,0));vec3 csNormal=texelFetch(normalSampler,ivec2(vUV*texSize),0).xyz;float depth=texelFetch(depthSampler,ivec2(vUV*texSize),0).r;vec3 csPosition=computeViewPosFromUVDepth(vUV,depth,projection,invProjectionMatrix);vec3 csViewDirection=normalize(csPosition);vec3 F0=reflectivity.rgb;vec3 fresnel=fresnelSchlickGGX(max(dot(csNormal,-csViewDirection),0.0),F0,vec3(1.));vec3 reflectionMultiplier=clamp(pow(fresnel*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
|
||
#else
|
||
vec3 reflectionMultiplier=clamp(pow(reflectivity.rgb*strength,vec3(reflectionSpecularFalloffExponent)),0.0,1.0);
|
||
#endif
|
||
vec3 colorMultiplier=1.0-reflectionMultiplier;vec3 finalColor=(color.rgb*colorMultiplier)+(SSR*reflectionMultiplier);
|
||
#ifdef SSR_OUTPUT_IS_GAMMA_SPACE
|
||
finalColor=toGammaSpace(finalColor);
|
||
#endif
|
||
gl_FragColor=vec4(finalColor,color.a);
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},79908:(r,t,e)=>{e.r(t),e.d(t,{shadowMapPixelShader:()=>s});var n=e(98519),i=(e(78531),"bayerDitherFunctions");n.l.IncludesShadersStore[i]=`float bayerDither2(vec2 _P) {return mod(2.0*_P.y+_P.x+1.0,4.0);}
|
||
float bayerDither4(vec2 _P) {vec2 P1=mod(_P,2.0);
|
||
vec2 P2=floor(0.5*mod(_P,4.0));
|
||
return 4.0*bayerDither2(P1)+bayerDither2(P2);}
|
||
float bayerDither8(vec2 _P) {vec2 P1=mod(_P,2.0);
|
||
vec2 P2=floor(0.5 *mod(_P,4.0));
|
||
vec2 P4=floor(0.25*mod(_P,8.0));
|
||
return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);}
|
||
`,n.l.IncludesShadersStore.shadowMapFragmentExtraDeclaration=`#if SM_FLOAT==0
|
||
#include<packingFunctions>
|
||
#endif
|
||
#if SM_SOFTTRANSPARENTSHADOW==1
|
||
#include<bayerDitherFunctions>
|
||
uniform vec2 softTransparentShadowSM;
|
||
#endif
|
||
varying float vDepthMetricSM;
|
||
#if SM_USEDISTANCE==1
|
||
uniform vec3 lightDataSM;varying vec3 vPositionWSM;
|
||
#endif
|
||
uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
varying float zSM;
|
||
#endif
|
||
`,e(27003),e(39643),e(29313);var o="shadowMapPixelShader",a=`#include<shadowMapFragmentExtraDeclaration>
|
||
#ifdef ALPHATEXTURE
|
||
varying vec2 vUV;uniform sampler2D diffuseSampler;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEXTURE
|
||
vec4 opacityMap=texture2D(diffuseSampler,vUV);float alphaFromAlphaTexture=opacityMap.a;
|
||
#if SM_SOFTTRANSPARENTSHADOW==1
|
||
if (softTransparentShadowSM.y==1.0) {opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alphaFromAlphaTexture=opacityMap.x+opacityMap.y+opacityMap.z;}
|
||
#endif
|
||
#ifdef ALPHATESTVALUE
|
||
if (alphaFromAlphaTexture<ALPHATESTVALUE)
|
||
discard;
|
||
#endif
|
||
#endif
|
||
#if SM_SOFTTRANSPARENTSHADOW==1
|
||
#ifdef ALPHATEXTURE
|
||
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x*alphaFromAlphaTexture) discard;
|
||
#else
|
||
if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x) discard;
|
||
#endif
|
||
#endif
|
||
#include<shadowMapFragment>
|
||
}`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},35004:(r,t,e)=>{e.r(t),e.d(t,{shadowMapVertexShader:()=>s});var n=e(98519),i=(e(36470),e(64400),e(24444),e(67369),e(75334),"sceneVertexDeclaration");n.l.IncludesShadersStore[i]=`uniform mat4 viewProjection;
|
||
#ifdef MULTIVIEW
|
||
uniform mat4 viewProjectionR;
|
||
#endif
|
||
uniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;
|
||
`,n.l.IncludesShadersStore.meshVertexDeclaration=`uniform mat4 world;uniform float visibility;
|
||
`,n.l.IncludesShadersStore.shadowMapVertexDeclaration=`#include<sceneVertexDeclaration>
|
||
#include<meshVertexDeclaration>
|
||
`,e(50851),e(56174),n.l.IncludesShadersStore.shadowMapUboDeclaration=`layout(std140,column_major) uniform;
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
`,n.l.IncludesShadersStore.shadowMapVertexExtraDeclaration=`#if SM_NORMALBIAS==1
|
||
uniform vec3 lightDataSM;
|
||
#endif
|
||
uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;varying float vDepthMetricSM;
|
||
#if SM_USEDISTANCE==1
|
||
varying vec3 vPositionWSM;
|
||
#endif
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
varying float zSM;
|
||
#endif
|
||
`,e(85637),e(58266),e(84589),e(35397),e(76898),e(49334),n.l.IncludesShadersStore.shadowMapVertexNormalBias=`#if SM_NORMALBIAS==1
|
||
#if SM_DIRECTIONINLIGHTDATA==1
|
||
vec3 worldLightDirSM=normalize(-lightDataSM.xyz);
|
||
#else
|
||
vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;vec3 worldLightDirSM=normalize(directionToLightSM);
|
||
#endif
|
||
float ndlSM=dot(vNormalW,worldLightDirSM);float sinNLSM=sqrt(1.0-ndlSM*ndlSM);float normalBiasSM=biasAndScaleSM.y*sinNLSM;worldPos.xyz-=vNormalW*normalBiasSM;
|
||
#endif
|
||
`,e(62371),e(83057);var o="shadowMapVertexShader",a=`attribute vec3 position;
|
||
#ifdef NORMAL
|
||
attribute vec3 normal;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#ifdef INSTANCES
|
||
attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;
|
||
#endif
|
||
#include<helperFunctions>
|
||
#include<__decl__shadowMapVertex>
|
||
#ifdef ALPHATEXTURE
|
||
varying vec2 vUV;uniform mat4 diffuseMatrix;
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute vec2 uv2;
|
||
#endif
|
||
#endif
|
||
#include<shadowMapVertexExtraDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void)
|
||
{vec3 positionUpdated=position;
|
||
#ifdef UV1
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#ifdef NORMAL
|
||
vec3 normalUpdated=normal;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
|
||
#ifdef NORMAL
|
||
mat3 normWorldSM=mat3(finalWorld);
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normWorldSM=transposeMat3(inverseMat3(normWorldSM));
|
||
#endif
|
||
vec3 vNormalW=normalize(normWorldSM*normalUpdated);
|
||
#endif
|
||
#endif
|
||
#include<shadowMapVertexNormalBias>
|
||
gl_Position=viewProjection*worldPos;
|
||
#include<shadowMapVertexMetric>
|
||
#ifdef ALPHATEXTURE
|
||
#ifdef UV1
|
||
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef UV2
|
||
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
}`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},22129:(r,t,e)=>{e.r(t),e.d(t,{sharpenPixelShader:()=>o});var n="sharpenPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 sharpnessAmounts;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 color=texture2D(textureSampler,vUV);vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(1,0)) +
|
||
texture2D(textureSampler,vUV+onePixel*vec2(0,1)) -
|
||
color*4.0;gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},22088:(r,t,e)=>{e.r(t),e.d(t,{spritesPixelShader:()=>s});var n=e(98519),i=(e(52767),e(59262),e(13088),e(86343),"imageProcessingCompatibility");n.l.IncludesShadersStore[i]=`#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));
|
||
#endif
|
||
`;var o="spritesPixelShader",a=`#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
uniform bool alphaTest;varying vec4 vColor;varying vec2 vUV;uniform sampler2D diffuseSampler;
|
||
#include<fogFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
#ifdef PIXEL_PERFECT
|
||
vec2 uvPixelPerfect(vec2 uv) {vec2 res=vec2(textureSize(diffuseSampler,0));uv=uv*res;vec2 seam=floor(uv+0.5);uv=seam+clamp((uv-seam)/fwidth(uv),-0.5,0.5);return uv/res;}
|
||
#endif
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#ifdef PIXEL_PERFECT
|
||
vec2 uv=uvPixelPerfect(vUV);
|
||
#else
|
||
vec2 uv=vUV;
|
||
#endif
|
||
vec4 color=texture2D(diffuseSampler,uv);float fAlphaTest=float(alphaTest);if (fAlphaTest != 0.)
|
||
{if (color.a<0.95)
|
||
discard;}
|
||
color*=vColor;
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>
|
||
gl_FragColor=color;
|
||
#include<imageProcessingCompatibility>
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStore[o]=a;var s={name:o,shader:a}},25792:(r,t,e)=>{e.r(t),e.d(t,{spritesVertexShader:()=>a});var n=e(98519),i=(e(72153),e(59262),e(56458),"spritesVertexShader"),o=`attribute vec4 position;attribute vec2 options;attribute vec2 offsets;attribute vec2 inverts;attribute vec4 cellInfo;attribute vec4 color;uniform mat4 view;uniform mat4 projection;varying vec2 vUV;varying vec4 vColor;
|
||
#include<fogVertexDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;
|
||
vec2 cornerPos;float angle=position.w;vec2 size=vec2(options.x,options.y);vec2 offset=offsets.xy;cornerPos=vec2(offset.x-0.5,offset.y -0.5)*size;vec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;viewPos+=rotatedCorner;gl_Position=projection*vec4(viewPos,1.0);
|
||
vColor=color;vec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));vec2 uvPlace=cellInfo.xy;vec2 uvSize=cellInfo.zw;vUV.x=uvPlace.x+uvSize.x*uvOffset.x;vUV.y=uvPlace.y+uvSize.y*uvOffset.y;
|
||
#ifdef FOG
|
||
vFogDistance=viewPos;
|
||
#endif
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStore[i]=o;var a={name:i,shader:o}},16040:(r,t,e)=>{e.r(t),e.d(t,{ssao2PixelShader:()=>o});var n="ssao2PixelShader",i=`precision highp float;uniform sampler2D textureSampler;varying vec2 vUV;
|
||
#ifdef SSAO
|
||
float scales[16]=float[16](
|
||
0.1,
|
||
0.11406250000000001,
|
||
0.131640625,
|
||
0.15625,
|
||
0.187890625,
|
||
0.2265625,
|
||
0.272265625,
|
||
0.325,
|
||
0.384765625,
|
||
0.4515625,
|
||
0.525390625,
|
||
0.60625,
|
||
0.694140625,
|
||
0.7890625,
|
||
0.891015625,
|
||
1.0
|
||
);uniform float near;uniform float radius;uniform sampler2D depthSampler;uniform sampler2D randomSampler;uniform sampler2D normalSampler;uniform float randTextureTiles;uniform float samplesFactor;uniform vec3 sampleSphere[SAMPLES];uniform float totalStrength;uniform float base;uniform float xViewport;uniform float yViewport;uniform mat3 depthProjection;uniform float maxZ;uniform float minZAspect;uniform vec2 texelSize;uniform mat4 projection;void main()
|
||
{vec3 random=textureLod(randomSampler,vUV*randTextureTiles,0.0).rgb;float depth=textureLod(depthSampler,vUV,0.0).r;float depthSign=sign(depth);depth=depth*depthSign;vec3 normal=textureLod(normalSampler,vUV,0.0).rgb;float occlusion=0.0;float correctedRadius=min(radius,minZAspect*depth/near);vec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);vec3 vDepthFactor=depthProjection*vec3(1.0,1.0,depth);vec3 origin=vViewRay*vDepthFactor;vec3 rvec=random*2.0-1.0;rvec.z=0.0;float dotProduct=dot(rvec,normal);rvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);vec3 tangent=normalize(rvec-normal*dot(rvec,normal));vec3 bitangent=cross(normal,tangent);mat3 tbn=mat3(tangent,bitangent,normal);float difference;for (int i=0; i<SAMPLES; ++i) {vec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];samplePosition=samplePosition*correctedRadius+origin;vec4 offset=vec4(samplePosition,1.0);offset=projection*offset;offset.xyz/=offset.w;offset.xy=offset.xy*0.5+0.5;if (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {continue;}
|
||
float sampleDepth=abs(textureLod(depthSampler,offset.xy,0.0).r);difference=depthSign*samplePosition.z-sampleDepth;float rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);occlusion+=step(EPSILON,difference)*rangeCheck;}
|
||
occlusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));float ao=1.0-totalStrength*occlusion*samplesFactor;float result=clamp(ao+base,0.0,1.0);gl_FragColor=vec4(vec3(result),1.0);}
|
||
#endif
|
||
#ifdef BLUR
|
||
uniform float outSize;uniform float soften;uniform float tolerance;uniform int samples;
|
||
#ifndef BLUR_BYPASS
|
||
uniform sampler2D depthSampler;
|
||
#ifdef BLUR_LEGACY
|
||
#define inline
|
||
float blur13Bilateral(sampler2D image,vec2 uv,vec2 step) {float result=0.0;vec2 off1=vec2(1.411764705882353)*step;vec2 off2=vec2(3.2941176470588234)*step;vec2 off3=vec2(5.176470588235294)*step;float compareDepth=abs(textureLod(depthSampler,uv,0.0).r);float sampleDepth;float weight;float weightSum=30.0;result+=textureLod(image,uv,0.0).r*30.0;sampleDepth=abs(textureLod(depthSampler,uv+off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureLod(image,uv+off1,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureLod(image,uv-off1,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv+off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv+off2,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv-off2,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv+off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv+off3,0.0).r*weight;sampleDepth=abs(textureLod(depthSampler,uv-off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureLod(image,uv-off3,0.0).r*weight;return result/weightSum;}
|
||
#endif
|
||
#endif
|
||
void main()
|
||
{float result=0.0;
|
||
#ifdef BLUR_BYPASS
|
||
result=textureLod(textureSampler,vUV,0.0).r;
|
||
#else
|
||
#ifdef BLUR_H
|
||
vec2 step=vec2(1.0/outSize,0.0);
|
||
#else
|
||
vec2 step=vec2(0.0,1.0/outSize);
|
||
#endif
|
||
#ifdef BLUR_LEGACY
|
||
result=blur13Bilateral(textureSampler,vUV,step);
|
||
#else
|
||
float compareDepth=abs(textureLod(depthSampler,vUV,0.0).r);float weightSum=0.0;for (int i=-samples; i<samples; i+=2)
|
||
{vec2 samplePos=vUV+step*(float(i)+0.5);float sampleDepth=abs(textureLod(depthSampler,samplePos,0.0).r);float falloff=smoothstep(0.0,
|
||
float(samples),
|
||
float(samples)-abs(float(i))*soften);float minDivider=tolerance*0.5+0.003;float weight=falloff/( minDivider+abs(compareDepth-sampleDepth));result+=textureLod(textureSampler,samplePos,0.0).r*weight;weightSum+=weight;}
|
||
result/=weightSum;
|
||
#endif
|
||
#endif
|
||
gl_FragColor.rgb=vec3(result);gl_FragColor.a=1.0;}
|
||
#endif
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},19061:(r,t,e)=>{e.r(t),e.d(t,{ssaoCombinePixelShader:()=>o});var n="ssaoCombinePixelShader",i=`uniform sampler2D textureSampler;uniform sampler2D originalColor;uniform vec4 viewport;varying vec2 vUV;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
vec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);vec4 sceneColor=texture2D(originalColor,vUV);gl_FragColor=sceneColor*ssaoColor;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},1746:(r,t,e)=>{e.r(t),e.d(t,{tonemapPixelShader:()=>o});var n="tonemapPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform float _ExposureAdjustment;
|
||
#if defined(HABLE_TONEMAPPING)
|
||
const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;const float W=11.2;
|
||
#endif
|
||
float Luminance(vec3 c)
|
||
{return dot(c,vec3(0.22,0.707,0.071));}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec3 colour=texture2D(textureSampler,vUV).rgb;
|
||
#if defined(REINHARD_TONEMAPPING)
|
||
float lum=Luminance(colour.rgb);
|
||
float lumTm=lum*_ExposureAdjustment;float scale=lumTm/(1.0+lumTm);
|
||
colour*=scale/lum;
|
||
#elif defined(HABLE_TONEMAPPING)
|
||
colour*=_ExposureAdjustment;const float ExposureBias=2.0;vec3 x=ExposureBias*colour;vec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;x=vec3(W,W,W);vec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);colour=curr*whiteScale;
|
||
#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)
|
||
colour*=_ExposureAdjustment;vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);colour=retColor*retColor;
|
||
#elif defined(PHOTOGRAPHIC_TONEMAPPING)
|
||
colour= vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);
|
||
#endif
|
||
gl_FragColor=vec4(colour.rgb,1.0);}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},67291:(r,t,e)=>{e.r(t),e.d(t,{vrDistortionCorrectionPixelShader:()=>o});var n="vrDistortionCorrectionPixelShader",i=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 LensCenter;uniform vec2 Scale;uniform vec2 ScaleIn;uniform vec4 HmdWarpParam;vec2 HmdWarp(vec2 in01) {vec2 theta=(in01-LensCenter)*ScaleIn;
|
||
float rSq=theta.x*theta.x+theta.y*theta.y;vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);return LensCenter+Scale*rvector;}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec2 tc=HmdWarp(vUV);if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)
|
||
gl_FragColor=vec4(0.0,0.0,0.0,0.0);else{gl_FragColor=texture2D(textureSampler,tc);}}`;e(98519).l.ShadersStore[n]=i;var o={name:n,shader:i}},66138:(r,t,e)=>{var n=e(98519),i=(e(36644),"backgroundUboDeclaration");n.l.IncludesShadersStoreWGSL[i]=`uniform vPrimaryColor: vec4f;uniform vPrimaryColorShadow: vec4f;uniform vDiffuseInfos: vec2f;uniform vReflectionInfos: vec2f;uniform diffuseMatrix: mat4x4f;uniform reflectionMatrix: mat4x4f;uniform vReflectionMicrosurfaceInfos: vec3f;uniform fFovMultiplier: f32;uniform pointSize: f32;uniform shadowLevel: f32;uniform alpha: f32;uniform vBackgroundCenter: vec3f;uniform vReflectionControl: vec4f;uniform projectedGroundInfos: vec2f;
|
||
#include<sceneUboDeclaration>
|
||
`},86615:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.bakedVertexAnimation=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
{
|
||
#ifdef INSTANCES
|
||
let VATStartFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.x;let VATEndFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.y;let VATOffsetFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.z;let VATSpeed: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.w;
|
||
#else
|
||
let VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;let VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;let VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;let VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;
|
||
#endif
|
||
let totalFrames: f32=VATEndFrame-VATStartFrame+1.0;let time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;let frameCorrection: f32=select(1.0,0.0,time<1.0);let numOfFrames: f32=totalFrames-frameCorrection;var VATFrameNum: f32=fract(time)*numOfFrames;VATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;VATFrameNum=floor(VATFrameNum);VATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;var VATInfluence : mat4x4<f32>;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[0],VATFrameNum)*vertexInputs.matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[1],VATFrameNum)*vertexInputs.matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[2],VATFrameNum)*vertexInputs.matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[3],VATFrameNum)*vertexInputs.matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[0],VATFrameNum)*vertexInputs.matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[1],VATFrameNum)*vertexInputs.matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[2],VATFrameNum)*vertexInputs.matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[3],VATFrameNum)*vertexInputs.matricesWeightsExtra[3];
|
||
#endif
|
||
finalWorld=finalWorld*VATInfluence;}
|
||
#endif
|
||
`},27279:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.bakedVertexAnimationDeclaration=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
uniform bakedVertexAnimationTime: f32;uniform bakedVertexAnimationTextureSizeInverted: vec2<f32>;uniform bakedVertexAnimationSettings: vec4<f32>;var bakedVertexAnimationTexture : texture_2d<f32>;
|
||
#ifdef INSTANCES
|
||
attribute bakedVertexAnimationSettingsInstanced : vec4<f32>;
|
||
#endif
|
||
fn readMatrixFromRawSamplerVAT(smp : texture_2d<f32>,index : f32,frame : f32)->mat4x4<f32>
|
||
{let offset=i32(index)*4;let frameUV=i32(frame);let m0=textureLoad(smp,vec2<i32>(offset+0,frameUV),0);let m1=textureLoad(smp,vec2<i32>(offset+1,frameUV),0);let m2=textureLoad(smp,vec2<i32>(offset+2,frameUV),0);let m3=textureLoad(smp,vec2<i32>(offset+3,frameUV),0);return mat4x4<f32>(m0,m1,m2,m3);}
|
||
#endif
|
||
`},45699:(r,t,e)=>{e.r(t),e.d(t,{bonesDeclarationWGSL:()=>o});var n="bonesDeclaration",i=`#if NUM_BONE_INFLUENCERS>0
|
||
attribute matricesIndices : vec4<f32>;attribute matricesWeights : vec4<f32>;
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
attribute matricesIndicesExtra : vec4<f32>;attribute matricesWeightsExtra : vec4<f32>;
|
||
#endif
|
||
#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
#ifdef BONETEXTURE
|
||
var boneSampler : texture_2d<f32>;uniform boneTextureWidth : f32;
|
||
#else
|
||
uniform mBones : array<mat4x4,BonesPerMesh>;
|
||
#ifdef BONES_VELOCITY_ENABLED
|
||
uniform mPreviousBones : array<mat4x4,BonesPerMesh>;
|
||
#endif
|
||
#endif
|
||
#ifdef BONETEXTURE
|
||
fn readMatrixFromRawSampler(smp : texture_2d<f32>,index : f32)->mat4x4<f32>
|
||
{let offset=i32(index) *4;
|
||
let m0=textureLoad(smp,vec2<i32>(offset+0,0),0);let m1=textureLoad(smp,vec2<i32>(offset+1,0),0);let m2=textureLoad(smp,vec2<i32>(offset+2,0),0);let m3=textureLoad(smp,vec2<i32>(offset+3,0),0);return mat4x4<f32>(m0,m1,m2,m3);}
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},3641:(r,t,e)=>{e.r(t),e.d(t,{bonesVertexWGSL:()=>o});var n="bonesVertex",i=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
var influence : mat4x4<f32>;
|
||
#ifdef BONETEXTURE
|
||
influence=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[0])*vertexInputs.matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[1])*vertexInputs.matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[2])*vertexInputs.matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[3])*vertexInputs.matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[0])*vertexInputs.matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[1])*vertexInputs.matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[2])*vertexInputs.matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[3])*vertexInputs.matricesWeightsExtra[3];
|
||
#endif
|
||
#else
|
||
influence=uniforms.mBones[int(vertexInputs.matricesIndices[0])]*vertexInputs.matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[1])]*vertexInputs.matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[2])]*vertexInputs.matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndices[3])]*vertexInputs.matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[0])]*vertexInputs.matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[1])]*vertexInputs.matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[2])]*vertexInputs.matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
influence=influence+uniforms.mBones[int(vertexInputs.matricesIndicesExtra[3])]*vertexInputs.matricesWeightsExtra[3];
|
||
#endif
|
||
#endif
|
||
finalWorld=finalWorld*influence;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},20274:(r,t,e)=>{e.r(t),e.d(t,{bumpFragmentWGSL:()=>o});var n="bumpFragment",i=`var uvOffset: vec2f= vec2f(0.0,0.0);
|
||
#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
|
||
#ifdef NORMALXYSCALE
|
||
var normalScale: f32=1.0;
|
||
#elif defined(BUMP)
|
||
var normalScale: f32=uniforms.vBumpInfos.y;
|
||
#else
|
||
var normalScale: f32=1.0;
|
||
#endif
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
|
||
#elif defined(BUMP)
|
||
var TBNUV: vec2f=select(-fragmentInputs.vBumpUV,fragmentInputs.vBumpUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams);
|
||
#else
|
||
var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.));
|
||
#endif
|
||
#elif defined(ANISOTROPIC)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
|
||
#else
|
||
var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.));
|
||
#endif
|
||
#endif
|
||
#ifdef PARALLAX
|
||
var invTBN: mat3x3f=transposeMat3(TBN);
|
||
#ifdef PARALLAXOCCLUSION
|
||
uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,fragmentInputs.vBumpUV,uniforms.vBumpInfos.z);
|
||
#else
|
||
uvOffset=parallaxOffset(invTBN*viewDirectionW,uniforms.vBumpInfos.z);
|
||
#endif
|
||
#endif
|
||
#ifdef DETAIL
|
||
var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB);
|
||
#endif
|
||
#ifdef BUMP
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
#define CUSTOM_FRAGMENT_BUMP_FRAGMENT
|
||
normalW=normalize(textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW);
|
||
#elif !defined(DETAIL)
|
||
normalW=perturbNormal(TBN,textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz,uniforms.vBumpInfos.y);
|
||
#else
|
||
var bumpNormal: vec3f=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz*2.0-1.0;
|
||
#if DETAIL_NORMALBLENDMETHOD==0
|
||
detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
|
||
#elif DETAIL_NORMALBLENDMETHOD==1
|
||
detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);bumpNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
|
||
#endif
|
||
normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vBumpInfos.y);
|
||
#endif
|
||
#elif defined(DETAIL)
|
||
detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z);
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},66633:(r,t,e)=>{e.r(t),e.d(t,{bumpFragmentFunctionsWGSL:()=>a});var n=e(98519),i=(e(338),"bumpFragmentFunctions"),o=`#if defined(BUMP)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
|
||
#endif
|
||
#if defined(DETAIL)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
|
||
#endif
|
||
#if defined(BUMP) && defined(PARALLAX)
|
||
const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; i<iMaxSamples; i++)
|
||
{currSampledHeight=textureSample(bumpSampler,bumpSamplerSampler,texCoord+vCurrOffset).w;if (!keepWorking)
|
||
{}
|
||
else if (currSampledHeight>currRayHeight)
|
||
{var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
|
||
else
|
||
{currRayHeight-=stepSize;vLastOffset=vCurrOffset;
|
||
#ifdef PARALLAX_RHS
|
||
vCurrOffset-=stepSize*vMaxOffset;
|
||
#else
|
||
vCurrOffset+=stepSize*vMaxOffset;
|
||
#endif
|
||
lastSampledHeight=currSampledHeight;}}
|
||
return vCurrOffset;}
|
||
fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f
|
||
{var height: f32=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).w;var texCoordOffset: vec2f=heightScale*viewDir.xy*height;
|
||
#ifdef PARALLAX_RHS
|
||
return texCoordOffset;
|
||
#else
|
||
return -texCoordOffset;
|
||
#endif
|
||
}
|
||
#endif
|
||
`;n.l.IncludesShadersStoreWGSL[i]=o;var a={name:i,shader:o}},96830:(r,t,e)=>{e.r(t),e.d(t,{bumpFragmentMainFunctionsWGSL:()=>o});var n="bumpFragmentMainFunctions",i=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f;
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f
|
||
{var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0];
|
||
var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0];
|
||
var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4<f32>(
|
||
(a11*b11-a12*b10+a13*b09)/det,
|
||
(a02*b10-a01*b11-a03*b09)/det,
|
||
(a31*b05-a32*b04+a33*b03)/det,
|
||
(a22*b04-a21*b05-a23*b03)/det,
|
||
(a12*b08-a10*b11-a13*b07)/det,
|
||
(a00*b11-a02*b08+a03*b07)/det,
|
||
(a32*b02-a30*b05-a33*b01)/det,
|
||
(a20*b05-a22*b02+a23*b01)/det,
|
||
(a10*b10-a11*b08+a13*b06)/det,
|
||
(a01*b08-a00*b10-a03*b06)/det,
|
||
(a30*b04-a31*b02+a33*b00)/det,
|
||
(a21*b02-a20*b04-a23*b00)/det,
|
||
(a11*b07-a10*b09-a12*b06)/det,
|
||
(a00*b09-a01*b07+a02*b06)/det,
|
||
(a31*b01-a30*b03-a32*b00)/det,
|
||
(a20*b03-a21*b01+a22*b00)/det);return mat4x4<f32>(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
|
||
mi[0][1],mi[1][1],mi[2][1],mi[3][1],
|
||
mi[0][2],mi[1][2],mi[2][2],mi[3][2],
|
||
mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
|
||
#endif
|
||
fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f
|
||
{var output=normal;
|
||
#ifdef NORMALXYSCALE
|
||
output=normalize(output* vec3f(scale,scale,1.0));
|
||
#endif
|
||
return normalize(cotangentFrame*output);}
|
||
fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f
|
||
{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
|
||
fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f
|
||
{var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},19748:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.bumpVertex=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
var tbnNormal: vec3f=normalize(normalUpdated);var tbnTangent: vec3f=normalize(tangentUpdated.xyz);var tbnBitangent: vec3f=cross(tbnNormal,tbnTangent)*tangentUpdated.w;var matTemp= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz)* mat3x3f(tbnTangent,tbnBitangent,tbnNormal);vertexOutputs.vTBN0=matTemp[0];vertexOutputs.vTBN1=matTemp[1];vertexOutputs.vTBN2=matTemp[2];
|
||
#endif
|
||
#endif
|
||
`},33330:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.bumpVertexDeclaration=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f;
|
||
#endif
|
||
#endif
|
||
`},30032:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneFragmentWGSL:()=>o});var n="clipPlaneFragment",i=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
|
||
if (false) {}
|
||
#endif
|
||
#ifdef CLIPPLANE
|
||
else if (fragmentInputs.fClipDistance>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
else if (fragmentInputs.fClipDistance2>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
else if (fragmentInputs.fClipDistance3>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
else if (fragmentInputs.fClipDistance4>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
else if (fragmentInputs.fClipDistance5>0.0)
|
||
{discard;}
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
else if (fragmentInputs.fClipDistance6>0.0)
|
||
{discard;}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},20502:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneFragmentDeclarationWGSL:()=>o});var n="clipPlaneFragmentDeclaration",i=`#ifdef CLIPPLANE
|
||
varying fClipDistance: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
varying fClipDistance2: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
varying fClipDistance3: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
varying fClipDistance4: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
varying fClipDistance5: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
varying fClipDistance6: f32;
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},63002:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneVertexWGSL:()=>o});var n="clipPlaneVertex",i=`#ifdef CLIPPLANE
|
||
vertexOutputs.fClipDistance=dot(worldPos,uniforms.vClipPlane);
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
vertexOutputs.fClipDistance2=dot(worldPos,uniforms.vClipPlane2);
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
vertexOutputs.fClipDistance3=dot(worldPos,uniforms.vClipPlane3);
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
vertexOutputs.fClipDistance4=dot(worldPos,uniforms.vClipPlane4);
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
vertexOutputs.fClipDistance5=dot(worldPos,uniforms.vClipPlane5);
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
vertexOutputs.fClipDistance6=dot(worldPos,uniforms.vClipPlane6);
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},9436:(r,t,e)=>{e.r(t),e.d(t,{clipPlaneVertexDeclarationWGSL:()=>o});var n="clipPlaneVertexDeclaration",i=`#ifdef CLIPPLANE
|
||
uniform vClipPlane: vec4<f32>;varying fClipDistance: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
uniform vClipPlane2: vec4<f32>;varying fClipDistance2: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
uniform vClipPlane3: vec4<f32>;varying fClipDistance3: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
uniform vClipPlane4: vec4<f32>;varying fClipDistance4: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
uniform vClipPlane5: vec4<f32>;varying fClipDistance5: f32;
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
uniform vClipPlane6: vec4<f32>;varying fClipDistance6: f32;
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},65969:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.decalFragment=`#ifdef DECAL
|
||
var decalTempColor=decalColor.rgb;var decalTempAlpha=decalColor.a;
|
||
#ifdef GAMMADECAL
|
||
decalTempColor=toLinearSpaceVec3(decalColor.rgb);
|
||
#endif
|
||
#ifdef DECAL_SMOOTHALPHA
|
||
decalTempAlpha=decalColor.a*decalColor.a;
|
||
#endif
|
||
surfaceAlbedo=mix(surfaceAlbedo.rgb,decalTempColor,decalTempAlpha);
|
||
#endif
|
||
`},76941:(r,t,e)=>{var n=e(98519),i=(e(36644),e(40647),"defaultUboDeclaration");n.l.IncludesShadersStoreWGSL[i]=`uniform diffuseLeftColor: vec4f;uniform diffuseRightColor: vec4f;uniform opacityParts: vec4f;uniform reflectionLeftColor: vec4f;uniform reflectionRightColor: vec4f;uniform refractionLeftColor: vec4f;uniform refractionRightColor: vec4f;uniform emissiveLeftColor: vec4f;uniform emissiveRightColor: vec4f;uniform vDiffuseInfos: vec2f;uniform vAmbientInfos: vec2f;uniform vOpacityInfos: vec2f;uniform vReflectionInfos: vec2f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;uniform vEmissiveInfos: vec2f;uniform vLightmapInfos: vec2f;uniform vSpecularInfos: vec2f;uniform vBumpInfos: vec3f;uniform diffuseMatrix: mat4x4f;uniform ambientMatrix: mat4x4f;uniform opacityMatrix: mat4x4f;uniform reflectionMatrix: mat4x4f;uniform emissiveMatrix: mat4x4f;uniform lightmapMatrix: mat4x4f;uniform specularMatrix: mat4x4f;uniform bumpMatrix: mat4x4f;uniform vTangentSpaceParams: vec2f;uniform pointSize: f32;uniform alphaCutOff: f32;uniform refractionMatrix: mat4x4f;uniform vRefractionInfos: vec4f;uniform vRefractionPosition: vec3f;uniform vRefractionSize: vec3f;uniform vSpecularColor: vec4f;uniform vEmissiveColor: vec3f;uniform vDiffuseColor: vec4f;uniform vAmbientColor: vec3f;
|
||
#define ADDITIONAL_UBO_DECLARATION
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
`},25757:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.depthPrePass=`#ifdef DEPTHPREPASS
|
||
fragmentOutputs.color= vec4f(0.,0.,0.,1.0);return fragmentOutputs;
|
||
#endif
|
||
`},83512:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.fogFragment=`#ifdef FOG
|
||
var fog: f32=CalcFogFactor();
|
||
#ifdef PBR
|
||
fog=toLinearSpace(fog);
|
||
#endif
|
||
color= vec4f(mix(uniforms.vFogColor,color.rgb,fog),color.a);
|
||
#endif
|
||
`},98318:(r,t,e)=>{e.r(t),e.d(t,{fogFragmentDeclarationWGSL:()=>o});var n="fogFragmentDeclaration",i=`#ifdef FOG
|
||
#define FOGMODE_NONE 0.
|
||
#define FOGMODE_EXP 1.
|
||
#define FOGMODE_EXP2 2.
|
||
#define FOGMODE_LINEAR 3.
|
||
const E=2.71828;uniform vFogInfos: vec4f;uniform vFogColor: vec3f;varying vFogDistance: vec3f;fn CalcFogFactor()->f32
|
||
{var fogCoeff: f32=1.0;var fogStart: f32=uniforms.vFogInfos.y;var fogEnd: f32=uniforms.vFogInfos.z;var fogDensity: f32=uniforms.vFogInfos.w;var fogDistance: f32=length(fragmentInputs.vFogDistance);if (FOGMODE_LINEAR==uniforms.vFogInfos.x)
|
||
{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);}
|
||
else if (FOGMODE_EXP==uniforms.vFogInfos.x)
|
||
{fogCoeff=1.0/pow(E,fogDistance*fogDensity);}
|
||
else if (FOGMODE_EXP2==uniforms.vFogInfos.x)
|
||
{fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);}
|
||
return clamp(fogCoeff,0.0,1.0);}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},70898:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.fogVertex=`#ifdef FOG
|
||
vertexOutputs.vFogDistance=(scene.view*worldPos).xyz;
|
||
#endif
|
||
`},79716:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.fogVertexDeclaration=`#ifdef FOG
|
||
varying vFogDistance: vec3f;
|
||
#endif
|
||
`},92331:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.fresnelFunction=`#ifdef FRESNEL
|
||
fn computeFresnelTerm(viewDirection: vec3f,worldNormal: vec3f,bias: f32,power: f32)->f32
|
||
{let fresnelTerm: f32=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}
|
||
#endif
|
||
`},44467:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.harmonicsFunctions=`#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#ifdef SPHERICAL_HARMONICS
|
||
fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {return uniforms.vSphericalL00
|
||
+ uniforms.vSphericalL1_1*(normal.y)
|
||
+ uniforms.vSphericalL10*(normal.z)
|
||
+ uniforms.vSphericalL11*(normal.x)
|
||
+ uniforms.vSphericalL2_2*(normal.y*normal.x)
|
||
+ uniforms.vSphericalL2_1*(normal.y*normal.z)
|
||
+ uniforms.vSphericalL20*((3.0*normal.z*normal.z)-1.0)
|
||
+ uniforms.vSphericalL21*(normal.z*normal.x)
|
||
+ uniforms.vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));}
|
||
#else
|
||
fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {var Nx: f32=normal.x;var Ny: f32=normal.y;var Nz: f32=normal.z;var C1: vec3f=uniforms.vSphericalZZ.rgb;var Cx: vec3f=uniforms.vSphericalX.rgb;var Cy: vec3f=uniforms.vSphericalY.rgb;var Cz: vec3f=uniforms.vSphericalZ.rgb;var Cxx_zz: vec3f=uniforms.vSphericalXX_ZZ.rgb;var Cyy_zz: vec3f=uniforms.vSphericalYY_ZZ.rgb;var Cxy: vec3f=uniforms.vSphericalXY.rgb;var Cyz: vec3f=uniforms.vSphericalYZ.rgb;var Czx: vec3f=uniforms.vSphericalZX.rgb;var a1: vec3f=Cyy_zz*Ny+Cy;var a2: vec3f=Cyz*Nz+a1;var b1: vec3f=Czx*Nz+Cx;var b2: vec3f=Cxy*Ny+b1;var b3: vec3f=Cxx_zz*Nx+b2;var t1: vec3f=Cz *Nz+C1;var t2: vec3f=a2 *Ny+t1;var t3: vec3f=b3 *Nx+t2;return t3;}
|
||
#endif
|
||
#endif
|
||
`},31321:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.hdrFilteringFunctions=`#ifdef NUM_SAMPLES
|
||
#if NUM_SAMPLES>0
|
||
fn radicalInverse_VdC(value: u32)->f32
|
||
{var bits=(value<<16u) | (value>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return f32(bits)*2.3283064365386963e-10; }
|
||
fn hammersley(i: u32,N: u32)->vec2f
|
||
{return vec2f( f32(i)/ f32(N),radicalInverse_VdC(i));}
|
||
fn log4(x: f32)->f32 {return log2(x)/2.;}
|
||
const NUM_SAMPLES_FLOAT: f32= f32(NUM_SAMPLES);const NUM_SAMPLES_FLOAT_INVERSED: f32=1./NUM_SAMPLES_FLOAT;const K: f32=4.;fn irradiance(inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f
|
||
{var n: vec3f=normalize(inputN);var result: vec3f= vec3f(0.0);var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);for(var i: u32=0u; i<NUM_SAMPLES; i++)
|
||
{var Xi: vec2f=hammersley(i,NUM_SAMPLES);var Ls: vec3f=hemisphereCosSample(Xi);Ls=normalize(Ls);var Ns: vec3f= vec3f(0.,0.,1.);var NoL: f32=dot(Ns,Ls);if (NoL>0.) {var pdf_inversed: f32=PI/NoL;var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0,maxLevel);var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*Ls,mipLevel).rgb;
|
||
#ifdef GAMMA_INPUT
|
||
c=toLinearSpaceVec3(c);
|
||
#endif
|
||
result+=c;}}
|
||
result=result*NUM_SAMPLES_FLOAT_INVERSED;return result;}
|
||
fn radiance(alphaG: f32,inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f
|
||
{var n: vec3f=normalize(inputN);var c: vec3f=textureSample(inputTexture,inputSampler,n).rgb;
|
||
if (alphaG==0.) {
|
||
#ifdef GAMMA_INPUT
|
||
c=toLinearSpace(c);
|
||
#endif
|
||
return c;} else {var result: vec3f= vec3f(0.);var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var weight: f32=0.;for(var i: u32=0u; i<NUM_SAMPLES; i++)
|
||
{var Xi: vec2f=hammersley(i,NUM_SAMPLES);var H: vec3f=hemisphereImportanceSampleDggx(Xi,alphaG);var NoV: f32=1.;var NoH: f32=H.z;var NoH2: f32=H.z*H.z;var NoL: f32=2.*NoH2-1.;var L: vec3f= vec3f(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {var pdf_inversed: f32=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp( f32(l),0.0,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*L,mipLevel).rgb;
|
||
#ifdef GAMMA_INPUT
|
||
c=toLinearSpace(c);
|
||
#endif
|
||
result+=c*NoL;}}
|
||
result=result/weight;return result;}}
|
||
#endif
|
||
#endif
|
||
`},17393:(r,t,e)=>{e.r(t),e.d(t,{helperFunctionsWGSL:()=>o});var n="helperFunctions",i=`const PI: f32=3.1415926535897932384626433832795;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const HALF_MIN: f32=5.96046448e-08;
|
||
const LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3<f32>=vec3<f32> (0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;fn square(x: f32)->f32 {return x*x;}
|
||
fn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);}
|
||
fn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(0.0),vec3f(1.0));}
|
||
fn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);}
|
||
fn maxEps(x: f32)->f32 {return max(x,Epsilon);}
|
||
fn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));}
|
||
fn absEps(x: f32)->f32 {return abs(x)+Epsilon;}
|
||
fn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3<f32>=inMatrix[0];let i1: vec3<f32>=inMatrix[1];let i2: vec3<f32>=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(
|
||
vec3(i0.x,i1.x,i2.x),
|
||
vec3(i0.y,i1.y,i2.y),
|
||
vec3(i0.z,i1.z,i2.z)
|
||
);return outMatrix;}
|
||
fn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01: f32=inMatrix[0][1];let a02: f32=inMatrix[0][2];let a10: f32=inMatrix[1][0];let a11: f32=inMatrix[1][1];let a12: f32=inMatrix[1][2];let a20: f32=inMatrix[2][0];let a21: f32=inMatrix[2][1];let a22: f32=inMatrix[2][2];let b01: f32=a22*a11-a12*a21;let b11: f32=-a22*a10+a12*a20;let b21: f32=a21*a10-a11*a20;let det: f32=a00*b01+a01*b11+a02*b21;return mat3x3f(b01/det,(-a22*a01+a02*a21)/det,(a12*a01-a02*a11)/det,
|
||
b11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,
|
||
b21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
fn toLinearSpaceExact(color: vec3<f32>)->vec3<f32>
|
||
{let nearZeroSection: vec3<f32>=0.0773993808*color;let remainingSection: vec3<f32>=pow(0.947867299*(color+vec3<f32>(0.055)),vec3<f32>(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3<f32>(0.04045)));}
|
||
fn toGammaSpaceExact(color: vec3<f32>)->vec3<f32>
|
||
{let nearZeroSection: vec3<f32>=12.92*color;let remainingSection: vec3<f32>=1.055*pow(color,vec3<f32>(0.41666))-vec3<f32>(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3<f32>(0.0031308)));}
|
||
#endif
|
||
fn toLinearSpace(color: f32)->f32
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
var nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(color+0.055),2.4);return select(remainingSection,nearZeroSection,color<=0.04045);
|
||
#else
|
||
return pow(color,LinearEncodePowerApprox);
|
||
#endif
|
||
}
|
||
fn toLinearSpaceVec3(color: vec3<f32>)->vec3<f32>
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return toLinearSpaceExact(color);
|
||
#else
|
||
return pow(color,vec3<f32>(LinearEncodePowerApprox));
|
||
#endif
|
||
}
|
||
fn toLinearSpaceVec4(color: vec4<f32>)->vec4<f32>
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return vec4f(toLinearSpaceExact(color.rgb),color.a);
|
||
#else
|
||
return vec4f(pow(color.rgb,vec3f(LinearEncodePowerApprox)),color.a);
|
||
#endif
|
||
}
|
||
fn toGammaSpace(color: vec4<f32>)->vec4<f32>
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return vec4<f32>(toGammaSpaceExact(color.rgb),color.a);
|
||
#else
|
||
return vec4<f32>(pow(color.rgb,vec3<f32>(GammaEncodePowerApprox)),color.a);
|
||
#endif
|
||
}
|
||
fn toGammaSpaceVec3(color: vec3<f32>)->vec3<f32>
|
||
{
|
||
#if USE_EXACT_SRGB_CONVERSIONS
|
||
return toGammaSpaceExact(color);
|
||
#else
|
||
return pow(color,vec3<f32>(GammaEncodePowerApprox));
|
||
#endif
|
||
}
|
||
fn squareVec3(value: vec3<f32>)->vec3<f32>
|
||
{return value*value;}
|
||
fn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}
|
||
fn getLuminance(color: vec3<f32>)->f32
|
||
{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}
|
||
fn getRand(seed: vec2<f32>)->f32 {return fract(sin(dot(seed.xy ,vec2<f32>(12.9898,78.233)))*43758.5453);}
|
||
fn dither(seed: vec2<f32>,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;}
|
||
const rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3<f32>)->vec4<f32> {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3<f32> =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4<f32>(clamp(rgb,vec3<f32>(0.,0.,0.),vec3<f32>(1.,1.,1.)),D); }
|
||
fn fromRGBD(rgbd: vec4<f32>)->vec3<f32> {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}
|
||
fn parallaxCorrectNormal(vertexPos: vec3<f32>,origVec: vec3<f32>,cubeSize: vec3<f32>,cubePos: vec3<f32>)->vec3<f32> {let invOrigVec: vec3<f32>=vec3<f32>(1.0,1.0,1.0)/origVec;let halfSize: vec3<f32>=cubeSize*0.5;let intersecAtMaxPlane: vec3<f32>=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3<f32>=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3<f32>=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3<f32>=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},86320:(r,t,e)=>{e.r(t),e.d(t,{imageProcessingDeclarationWGSL:()=>o});var n="imageProcessingDeclaration",i=`#ifdef EXPOSURE
|
||
uniform exposureLinear: f32;
|
||
#endif
|
||
#ifdef CONTRAST
|
||
uniform contrast: f32;
|
||
#endif
|
||
#if defined(VIGNETTE) || defined(DITHER)
|
||
uniform vInverseScreenSize: vec2f;
|
||
#endif
|
||
#ifdef VIGNETTE
|
||
uniform vignetteSettings1: vec4f;uniform vignetteSettings2: vec4f;
|
||
#endif
|
||
#ifdef COLORCURVES
|
||
uniform vCameraColorCurveNegative: vec4f;uniform vCameraColorCurveNeutral: vec4f;uniform vCameraColorCurvePositive: vec4f;
|
||
#endif
|
||
#ifdef COLORGRADING
|
||
#ifdef COLORGRADING3D
|
||
var txColorTransformSampler: sampler;var txColorTransform: texture_3d<f32>;
|
||
#else
|
||
var txColorTransformSampler: sampler;var txColorTransform: texture_2d<f32>;
|
||
#endif
|
||
uniform colorTransformSettings: vec4f;
|
||
#endif
|
||
#ifdef DITHER
|
||
uniform ditherIntensity: f32;
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},4661:(r,t,e)=>{e.r(t),e.d(t,{imageProcessingFunctionsWGSL:()=>o});var n="imageProcessingFunctions",i=`#if TONEMAPPING==3
|
||
const PBRNeutralStartCompression: f32=0.8-0.04;const PBRNeutralDesaturation: f32=0.15;fn PBRNeutralToneMapping( color: vec3f )->vec3f {var x: f32=min(color.r,min(color.g,color.b));var offset: f32=select(0.04,x-6.25*x*x,x<0.08);var result=color;result-=offset;var peak: f32=max(result.r,max(result.g,result.b));if (peak<PBRNeutralStartCompression) {return result;}
|
||
var d: f32=1.-PBRNeutralStartCompression;var newPeak: f32=1.-d*d/(peak+d-PBRNeutralStartCompression);result*=newPeak/peak;var g: f32=1.-1./(PBRNeutralDesaturation*(peak-newPeak)+1.);return mix(result,newPeak* vec3f(1,1,1),g);}
|
||
#endif
|
||
#if TONEMAPPING==2
|
||
const ACESInputMat: mat3x3f= mat3x3f(
|
||
vec3f(0.59719,0.07600,0.02840),
|
||
vec3f(0.35458,0.90834,0.13383),
|
||
vec3f(0.04823,0.01566,0.83777)
|
||
);const ACESOutputMat: mat3x3f= mat3x3f(
|
||
vec3f( 1.60475,-0.10208,-0.00327),
|
||
vec3f(-0.53108, 1.10813,-0.07276),
|
||
vec3f(-0.07367,-0.00605, 1.07602)
|
||
);fn RRTAndODTFit(v: vec3f)->vec3f
|
||
{var a: vec3f=v*(v+0.0245786)-0.000090537;var b: vec3f=v*(0.983729*v+0.4329510)+0.238081;return a/b;}
|
||
fn ACESFitted(color: vec3f)->vec3f
|
||
{var output=ACESInputMat*color;output=RRTAndODTFit(output);output=ACESOutputMat*output;output=saturateVec3(output);return output;}
|
||
#endif
|
||
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
|
||
fn applyImageProcessing(result: vec4f)->vec4f {
|
||
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
|
||
var rgb=result.rgb;;
|
||
#ifdef EXPOSURE
|
||
rgb*=uniforms.exposureLinear;
|
||
#endif
|
||
#ifdef VIGNETTE
|
||
var viewportXY: vec2f=fragmentInputs.position.xy*uniforms.vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;var vignetteXY1: vec3f= vec3f(viewportXY*uniforms.vignetteSettings1.xy+uniforms.vignetteSettings1.zw,1.0);var vignetteTerm: f32=dot(vignetteXY1,vignetteXY1);var vignette: f32=pow(vignetteTerm,uniforms.vignetteSettings2.w);var vignetteColor: vec3f=uniforms.vignetteSettings2.rgb;
|
||
#ifdef VIGNETTEBLENDMODEMULTIPLY
|
||
var vignetteColorMultiplier: vec3f=mix(vignetteColor, vec3f(1,1,1),vignette);rgb*=vignetteColorMultiplier;
|
||
#endif
|
||
#ifdef VIGNETTEBLENDMODEOPAQUE
|
||
rgb=mix(vignetteColor,rgb,vignette);
|
||
#endif
|
||
#endif
|
||
#if TONEMAPPING==3
|
||
rgb=PBRNeutralToneMapping(rgb);
|
||
#elif TONEMAPPING==2
|
||
rgb=ACESFitted(rgb);
|
||
#elif TONEMAPPING==1
|
||
const tonemappingCalibration: f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb);
|
||
#endif
|
||
rgb=toGammaSpaceVec3(rgb);rgb=saturateVec3(rgb);
|
||
#ifdef CONTRAST
|
||
var resultHighContrast: vec3f=rgb*rgb*(3.0-2.0*rgb);if (uniforms.contrast<1.0) {rgb=mix( vec3f(0.5,0.5,0.5),rgb,uniforms.contrast);} else {rgb=mix(rgb,resultHighContrast,uniforms.contrast-1.0);}
|
||
#endif
|
||
#ifdef COLORGRADING
|
||
var colorTransformInput: vec3f=rgb*uniforms.colorTransformSettings.xxx+uniforms.colorTransformSettings.yyy;
|
||
#ifdef COLORGRADING3D
|
||
var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput).rgb;
|
||
#else
|
||
var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput,uniforms.colorTransformSettings.yz).rgb;
|
||
#endif
|
||
rgb=mix(rgb,colorTransformOutput,uniforms.colorTransformSettings.www);
|
||
#endif
|
||
#ifdef COLORCURVES
|
||
var luma: f32=getLuminance(rgb);var curveMix: vec2f=clamp( vec2f(luma*3.0-1.5,luma*-3.0+1.5), vec2f(0.0), vec2f(1.0));var colorCurve: vec4f=uniforms.vCameraColorCurveNeutral+curveMix.x*uniforms.vCameraColorCurvePositive-curveMix.y*uniforms.vCameraColorCurveNegative;rgb*=colorCurve.rgb;rgb=mix( vec3f(luma),rgb,colorCurve.a);
|
||
#endif
|
||
#ifdef DITHER
|
||
var rand: f32=getRand(fragmentInputs.position.xy*uniforms.vInverseScreenSize);var dither: f32=mix(-uniforms.ditherIntensity,uniforms.ditherIntensity,rand);rgb=saturateVec3(rgb+ vec3f(dither));
|
||
#endif
|
||
#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
|
||
return vec4f(rgb,result.a);}`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},28469:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.importanceSampling=`fn hemisphereCosSample(u: vec2f)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=1.-u.y;var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
|
||
fn hemisphereImportanceSampleDggx(u: vec2f,a: f32)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
|
||
fn hemisphereImportanceSampleDCharlie(u: vec2f,a: f32)->vec3f {
|
||
var phi: f32=2.*PI*u.x;var sinTheta: f32=pow(u.y,a/(2.*a+1.));var cosTheta: f32=sqrt(1.-sinTheta*sinTheta);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`},63866:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.instancesDeclaration=`#ifdef INSTANCES
|
||
attribute world0 : vec4<f32>;attribute world1 : vec4<f32>;attribute world2 : vec4<f32>;attribute world3 : vec4<f32>;
|
||
#ifdef INSTANCESCOLOR
|
||
attribute instanceColor : vec4<f32>;
|
||
#endif
|
||
#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
|
||
uniform world : mat4x4<f32>;
|
||
#endif
|
||
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
attribute previousWorld0 : vec4<f32>;attribute previousWorld1 : vec4<f32>;attribute previousWorld2 : vec4<f32>;attribute previousWorld3 : vec4<f32>;
|
||
#ifdef THIN_INSTANCES
|
||
uniform previousWorld : mat4x4<f32>;
|
||
#endif
|
||
#endif
|
||
#else
|
||
#if !defined(WORLD_UBO)
|
||
uniform world : mat4x4<f32>;
|
||
#endif
|
||
#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
uniform previousWorld : mat4x4<f32>;
|
||
#endif
|
||
#endif
|
||
`},21310:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.instancesVertex=`#ifdef INSTANCES
|
||
var finalWorld=mat4x4<f32>(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3);
|
||
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
var finalPreviousWorld=mat4x4<f32>(
|
||
vertexInputs.previousWorld0,vertexInputs.previousWorld1,
|
||
vertexInputs.previousWorld2,vertexInputs.previousWorld3);
|
||
#endif
|
||
#ifdef THIN_INSTANCES
|
||
#if !defined(WORLD_UBO)
|
||
finalWorld=uniforms.world*finalWorld;
|
||
#else
|
||
finalWorld=mesh.world*finalWorld;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
finalPreviousWorld=uniforms.previousWorld*finalPreviousWorld;
|
||
#endif
|
||
#endif
|
||
#else
|
||
#if !defined(WORLD_UBO)
|
||
var finalWorld=uniforms.world;
|
||
#else
|
||
var finalWorld=mesh.world;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
var finalPreviousWorld=uniforms.previousWorld;
|
||
#endif
|
||
#endif
|
||
`},14782:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.kernelBlurVaryingDeclaration="varying sampleCoord{X}: vec2f;"},84192:(r,t,e)=>{e.r(t),e.d(t,{lightFragmentWGSL:()=>o});var n="lightFragment",i=`#ifdef LIGHT{X}
|
||
#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
|
||
#else
|
||
var diffuse{X}: vec4f=light{X}.vLightDiffuse;
|
||
#define CUSTOM_LIGHT{X}_COLOR
|
||
#ifdef PBR
|
||
#ifdef SPOTLIGHT{X}
|
||
preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);
|
||
#elif defined(POINTLIGHT{X})
|
||
preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);
|
||
#elif defined(HEMILIGHT{X})
|
||
preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
|
||
#elif defined(DIRLIGHT{X})
|
||
preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
|
||
#endif
|
||
preInfo.NdotV=NdotV;
|
||
#ifdef SPOTLIGHT{X}
|
||
#ifdef LIGHT_FALLOFF_GLTF{X}
|
||
preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
||
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
|
||
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
|
||
#else
|
||
preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
||
#endif
|
||
#elif defined(POINTLIGHT{X})
|
||
#ifdef LIGHT_FALLOFF_GLTF{X}
|
||
preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
|
||
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
|
||
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
||
preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
|
||
#else
|
||
preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
||
#endif
|
||
#else
|
||
preInfo.attenuation=1.0;
|
||
#endif
|
||
#ifdef HEMILIGHT{X}
|
||
preInfo.roughness=roughness;
|
||
#else
|
||
preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
preInfo.iridescenceIntensity=iridescenceIntensity;
|
||
#endif
|
||
#ifdef HEMILIGHT{X}
|
||
info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround);
|
||
#elif defined(SS_TRANSLUCENCY)
|
||
info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
|
||
#else
|
||
info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb);
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
#ifdef ANISOTROPIC
|
||
info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
|
||
#else
|
||
info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
preInfo.roughness=sheenOut.sheenIntensity;
|
||
#else
|
||
#ifdef HEMILIGHT{X}
|
||
preInfo.roughness=sheenOut.sheenRoughness;
|
||
#else
|
||
preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
|
||
#endif
|
||
#endif
|
||
info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
#ifdef HEMILIGHT{X}
|
||
preInfo.roughness=clearcoatOut.clearCoatRoughness;
|
||
#else
|
||
preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
|
||
#endif
|
||
info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb);
|
||
#ifdef CLEARCOAT_TINT
|
||
absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
|
||
#ifdef SPECULARTERM
|
||
info.specular*=absorption;
|
||
#endif
|
||
#endif
|
||
info.diffuse*=info.clearCoat.w;
|
||
#ifdef SPECULARTERM
|
||
info.specular*=info.clearCoat.w;
|
||
#endif
|
||
#ifdef SHEEN
|
||
info.sheen*=info.clearCoat.w;
|
||
#endif
|
||
#endif
|
||
#else
|
||
#ifdef SPOTLIGHT{X}
|
||
info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
|
||
#elif defined(HEMILIGHT{X})
|
||
info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
|
||
#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
|
||
info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
|
||
#endif
|
||
#endif
|
||
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
||
info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},projectionLightTexture{X}Sampler,uniforms.textureProjectionMatrix{X},fragmentInputs.vPositionW);
|
||
#endif
|
||
#endif
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
var shadowDebug{X}: vec3f;
|
||
#endif
|
||
#ifdef SHADOWCSM{X}
|
||
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
|
||
var index{X}: i32=-1;
|
||
#else
|
||
var index{X}: i32=SHADOWCSMNUM_CASCADES{X}-1;
|
||
#endif
|
||
var diff{X}: f32=0.;vPositionFromLight{X}[0]=fragmentInputs.vPositionFromLight{X}_0;vPositionFromLight{X}[1]=fragmentInputs.vPositionFromLight{X}_1;vPositionFromLight{X}[2]=fragmentInputs.vPositionFromLight{X}_2;vPositionFromLight{X}[3]=fragmentInputs.vPositionFromLight{X}_3;vDepthMetric{X}[0]=fragmentInputs.vDepthMetric{X}_0;vDepthMetric{X}[1]=fragmentInputs.vDepthMetric{X}_1;vDepthMetric{X}[2]=fragmentInputs.vDepthMetric{X}_2;vDepthMetric{X}[3]=fragmentInputs.vDepthMetric{X}_3;for (var i:i32=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
|
||
{
|
||
#ifdef SHADOWCSM_RIGHTHANDED{X}
|
||
diff{X}=uniforms.viewFrustumZ{X}[i]+fragmentInputs.vPositionFromCamera{X}.z;
|
||
#else
|
||
diff{X}=uniforms.viewFrustumZ{X}[i]-fragmentInputs.vPositionFromCamera{X}.z;
|
||
#endif
|
||
if (diff{X}>=0.) {index{X}=i;break;}}
|
||
#ifdef SHADOWCSMUSESHADOWMAXZ{X}
|
||
if (index{X}>=0)
|
||
#endif
|
||
{
|
||
#if defined(SHADOWPCF{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#else
|
||
shadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPCSS{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
|
||
#else
|
||
shadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
|
||
#endif
|
||
#else
|
||
shadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
shadowDebug{X}=vec3f(shadow)*vCascadeColorsMultiplier{X}[index{X}];
|
||
#endif
|
||
#ifndef SHADOWCSMNOBLEND{X}
|
||
var frustumLength:f32=uniforms.frustumLengths{X}[index{X}];var diffRatio:f32=clamp(diff{X}/frustumLength,0.,1.)*uniforms.cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
|
||
{index{X}+=1;var nextShadow: f32=0.;
|
||
#if defined(SHADOWPCF{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
nextShadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
nextShadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#else
|
||
nextShadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPCSS{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
nextShadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
nextShadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
|
||
#else
|
||
nextShadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
|
||
#endif
|
||
#else
|
||
nextShadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
shadow=mix(nextShadow,shadow,diffRatio);
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
|
||
#endif
|
||
}
|
||
#endif
|
||
}
|
||
#elif defined(SHADOWCLOSEESM{X})
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowWithCloseESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadowWithCloseESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWESM{X})
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowWithESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadowWithESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPOISSON{X})
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowWithPoissonSamplingCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadowWithPoissonSampling(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPCF{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=computeShadowWithPCF1(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=computeShadowWithPCF3(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#else
|
||
shadow=computeShadowWithPCF5(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#elif defined(SHADOWPCSS{X})
|
||
#if defined(SHADOWLOWQUALITY{X})
|
||
shadow=computeShadowWithPCSS16(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#elif defined(SHADOWMEDIUMQUALITY{X})
|
||
shadow=computeShadowWithPCSS32(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#else
|
||
shadow=computeShadowWithPCSS64(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#else
|
||
#if defined(SHADOWCUBE{X})
|
||
shadow=computeShadowCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.depthValues);
|
||
#else
|
||
shadow=computeShadow(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
|
||
#endif
|
||
#endif
|
||
#ifdef SHADOWONLY
|
||
#ifndef SHADOWINUSE
|
||
#define SHADOWINUSE
|
||
#endif
|
||
globalShadow+=shadow;shadowLightCount+=1.0;
|
||
#endif
|
||
#else
|
||
shadow=1.;
|
||
#endif
|
||
aggShadow+=shadow;numLights+=1.0;
|
||
#ifndef SHADOWONLY
|
||
#ifdef CUSTOMUSERLIGHTING
|
||
diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
|
||
#ifdef SPECULARTERM
|
||
specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
|
||
#endif
|
||
#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
|
||
diffuseBase+=lightmapColor.rgb*shadow;
|
||
#ifdef SPECULARTERM
|
||
#ifndef LIGHTMAPNOSPECULAR{X}
|
||
specularBase+=info.specular*shadow*lightmapColor.rgb;
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
#ifndef LIGHTMAPNOSPECULAR{X}
|
||
clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
#ifndef LIGHTMAPNOSPECULAR{X}
|
||
sheenBase+=info.sheen.rgb*shadow;
|
||
#endif
|
||
#endif
|
||
#else
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
diffuseBase+=info.diffuse*shadowDebug{X};
|
||
#else
|
||
diffuseBase+=info.diffuse*shadow;
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
specularBase+=info.specular*shadow;
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
clearCoatBase+=info.clearCoat.rgb*shadow;
|
||
#endif
|
||
#ifdef SHEEN
|
||
sheenBase+=info.sheen.rgb*shadow;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},10896:(r,t,e)=>{e.r(t),e.d(t,{lightUboDeclarationWGSL:()=>o});var n="lightUboDeclaration",i=`#ifdef LIGHT{X}
|
||
struct Light{X}
|
||
{vLightData: vec4f,
|
||
vLightDiffuse: vec4f,
|
||
vLightSpecular: vec4f,
|
||
#ifdef SPOTLIGHT{X}
|
||
vLightDirection: vec4f,
|
||
vLightFalloff: vec4f,
|
||
#elif defined(POINTLIGHT{X})
|
||
vLightFalloff: vec4f,
|
||
#elif defined(HEMILIGHT{X})
|
||
vLightGround: vec3f,
|
||
#endif
|
||
shadowsInfo: vec4f,
|
||
depthValues: vec2f} ;var<uniform> light{X} : Light{X};
|
||
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
||
uniform textureProjectionMatrix{X}: mat4x4f;var projectionLightTexture{X}Sampler: sampler;var projectionLightTexture{X}: texture_2d<f32>;
|
||
#endif
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
uniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;uniform viewFrustumZ{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform frustumLengths{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform cascadeBlendFactor{X}: f32;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;var<private> vPositionFromLight{X}: array<vec4f,4>;var<private> vDepthMetric{X} : array<f32,4>;
|
||
#if defined(SHADOWPCSS{X})
|
||
var shadowTexture{X}Sampler: sampler_comparison;
|
||
var shadowTexture{X}: texture_depth_2d_array;var depthTexture{X}Sampler: sampler;var depthTexture{X}: texture_2d_array<f32>;uniform lightSizeUVCorrection{X}: array<vec2f,SHADOWCSMNUM_CASCADES{X}>;uniform depthCorrection{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform penumbraDarkness{X}: f32;
|
||
#elif defined(SHADOWPCF{X})
|
||
var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d_array;
|
||
#else
|
||
var shadowTexture{X}Sampler: sampler;
|
||
var shadowTexture{X}: texture_2d_array<f32>;
|
||
#endif
|
||
#ifdef SHADOWCSMDEBUG{X}
|
||
const vCascadeColorsMultiplier{X}: array<vec3f,8>=array<vec3f,8>
|
||
(
|
||
vec3f ( 1.5,0.0,0.0 ),
|
||
vec3f ( 0.0,1.5,0.0 ),
|
||
vec3f ( 0.0,0.0,5.5 ),
|
||
vec3f ( 1.5,0.0,5.5 ),
|
||
vec3f ( 1.5,1.5,0.0 ),
|
||
vec3f ( 1.0,1.0,1.0 ),
|
||
vec3f ( 0.0,1.0,5.5 ),
|
||
vec3f ( 0.5,3.5,0.75 )
|
||
);
|
||
#endif
|
||
#elif defined(SHADOWCUBE{X})
|
||
var shadowTexture{X}Sampler: sampler;var shadowTexture{X}: texture_cube<f32>;
|
||
#else
|
||
varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;
|
||
#if defined(SHADOWPCSS{X})
|
||
var shadowTexture{X}Sampler: sampler_comparison;
|
||
var shadowTexture{X}: texture_depth_2d;var depthTexture{X}Sampler: sampler;
|
||
var depthTexture{X}: texture_2d<f32>;
|
||
#elif defined(SHADOWPCF{X})
|
||
var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d;
|
||
#else
|
||
var shadowTexture{X}Sampler: sampler;
|
||
var shadowTexture{X}: texture_2d<f32>;
|
||
#endif
|
||
uniform lightMatrix{X}: mat4x4f;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},58902:(r,t,e)=>{e.r(t),e.d(t,{lightVxUboDeclarationWGSL:()=>o});var n="lightVxUboDeclaration",i=`#ifdef LIGHT{X}
|
||
struct Light{X}
|
||
{vLightData: vec4f,
|
||
vLightDiffuse: vec4f,
|
||
vLightSpecular: vec4f,
|
||
#ifdef SPOTLIGHT{X}
|
||
vLightDirection: vec4f,
|
||
vLightFalloff: vec4f,
|
||
#elif defined(POINTLIGHT{X})
|
||
vLightFalloff: vec4f,
|
||
#elif defined(HEMILIGHT{X})
|
||
vLightGround: vec3f,
|
||
#endif
|
||
shadowsInfo: vec4f,
|
||
depthValues: vec2f} ;var<uniform> light{X} : Light{X};
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
uniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;
|
||
#elif defined(SHADOWCUBE{X})
|
||
#else
|
||
varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;uniform lightMatrix{X}: mat4x4f;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},53378:(r,t,e)=>{e.r(t),e.d(t,{lightsFragmentFunctionsWGSL:()=>o});var n="lightsFragmentFunctions",i=`struct lightingInfo
|
||
{diffuse: vec3f,
|
||
#ifdef SPECULARTERM
|
||
specular: vec3f,
|
||
#endif
|
||
#ifdef NDOTL
|
||
ndl: f32,
|
||
#endif
|
||
};fn computeLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var lightVectorW: vec3f;var attenuation: f32=1.0;if (lightData.w==0.)
|
||
{var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var attenuation: f32=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
|
||
else
|
||
{lightVectorW=normalize(-lightData.xyz);}
|
||
var ndl: f32=max(0.,dot(vNormal,lightVectorW));
|
||
#ifdef NDOTL
|
||
result.ndl=ndl;
|
||
#endif
|
||
result.diffuse=ndl*diffuseColor*attenuation;
|
||
#ifdef SPECULARTERM
|
||
var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
|
||
#endif
|
||
return result;}
|
||
fn computeSpotLighting(viewDirectionW: vec3f,vNormal: vec3f ,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var cosAngle: f32=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)
|
||
{cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;var ndl: f32=max(0.,dot(vNormal,lightVectorW));
|
||
#ifdef NDOTL
|
||
result.ndl=ndl;
|
||
#endif
|
||
result.diffuse=ndl*diffuseColor*attenuation;
|
||
#ifdef SPECULARTERM
|
||
var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
|
||
#endif
|
||
return result;}
|
||
result.diffuse=vec3f(0.);
|
||
#ifdef SPECULARTERM
|
||
result.specular=vec3f(0.);
|
||
#endif
|
||
#ifdef NDOTL
|
||
result.ndl=0.;
|
||
#endif
|
||
return result;}
|
||
fn computeHemisphericLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,groundColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=dot(vNormal,lightData.xyz)*0.5+0.5;
|
||
#ifdef NDOTL
|
||
result.ndl=ndl;
|
||
#endif
|
||
result.diffuse=mix(groundColor,diffuseColor,ndl);
|
||
#ifdef SPECULARTERM
|
||
var angleW: vec3f=normalize(viewDirectionW+lightData.xyz);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
|
||
#endif
|
||
return result;}
|
||
fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f {var strq: vec4f=textureProjectionMatrix*vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return textureColor;}`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},38197:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.logDepthDeclaration=`#ifdef LOGARITHMICDEPTH
|
||
uniform logarithmicDepthConstant: f32;varying vFragmentDepth: f32;
|
||
#endif
|
||
`},56897:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.logDepthFragment=`#ifdef LOGARITHMICDEPTH
|
||
fragmentOutputs.fragDepth=log2(fragmentInputs.vFragmentDepth)*uniforms.logarithmicDepthConstant*0.5;
|
||
#endif
|
||
`},55607:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.logDepthVertex=`#ifdef LOGARITHMICDEPTH
|
||
vertexOutputs.vFragmentDepth=1.0+vertexOutputs.position.w;vertexOutputs.position.z=log2(max(0.000001,vertexOutputs.vFragmentDepth))*uniforms.logarithmicDepthConstant;
|
||
#endif
|
||
`},14188:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.mainUVVaryingDeclaration=`#ifdef MAINUV{X}
|
||
varying vMainUV{X}: vec2f;
|
||
#endif
|
||
`},40647:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.meshUboDeclaration=`struct Mesh {world : mat4x4<f32>,
|
||
visibility : f32,};var<uniform> mesh : Mesh;
|
||
#define WORLD_UBO
|
||
`},77320:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertexWGSL:()=>o});var n="morphTargetsVertex",i=`#ifdef MORPHTARGETS
|
||
#ifdef MORPHTARGETS_TEXTURE
|
||
#if {X}==0
|
||
for (var i=0; i<NUM_MORPH_INFLUENCERS; i=i+1) {if (i>=uniforms.morphTargetCount) {break;}
|
||
vertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x;positionUpdated=positionUpdated+(readVector3FromRawSampler(i,vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[i];vertexID=vertexID+1.0;
|
||
#ifdef MORPHTARGETS_NORMAL
|
||
normalUpdated=normalUpdated+(readVector3FromRawSampler(i,vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[i];vertexID=vertexID+1.0;
|
||
#endif
|
||
#ifdef MORPHTARGETS_UV
|
||
uvUpdated=uvUpdated+(readVector3FromRawSampler(i,vertexID).xy-vertexInputs.uv)*uniforms.morphTargetInfluences[i];vertexID=vertexID+1.0;
|
||
#endif
|
||
#ifdef MORPHTARGETS_TANGENT
|
||
tangentUpdated=vec4f(tangentUpdated.xyz+(readVector3FromRawSampler(i,vertexID) -vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[i],tangentUpdated.a);
|
||
#endif
|
||
}
|
||
#endif
|
||
#else
|
||
positionUpdated=positionUpdated+(vertexInputs.position{X}-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];
|
||
#ifdef MORPHTARGETS_NORMAL
|
||
normalUpdated+=(vertexInputs.normal{X}-vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];
|
||
#endif
|
||
#ifdef MORPHTARGETS_TANGENT
|
||
tangentUpdated=vec4f(tangentUpdated.xyz+(vertexInputs.tangent{X}-vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}],tangentUpdated.a);
|
||
#endif
|
||
#ifdef MORPHTARGETS_UV
|
||
uvUpdated=uvUpdated+(vertexInputs.uv_{X}-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},68478:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertexDeclarationWGSL:()=>o});var n="morphTargetsVertexDeclaration",i=`#ifdef MORPHTARGETS
|
||
#ifndef MORPHTARGETS_TEXTURE
|
||
attribute position{X} : vec3<f32>;
|
||
#ifdef MORPHTARGETS_NORMAL
|
||
attribute normal{X} : vec3<f32>;
|
||
#endif
|
||
#ifdef MORPHTARGETS_TANGENT
|
||
attribute tangent{X} : vec3<f32>;
|
||
#endif
|
||
#ifdef MORPHTARGETS_UV
|
||
attribute uv_{X} : vec2<f32>;
|
||
#endif
|
||
#elif {X}==0
|
||
uniform morphTargetCount: i32;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},98819:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertexGlobalWGSL:()=>o});var n="morphTargetsVertexGlobal",i=`#ifdef MORPHTARGETS
|
||
#ifdef MORPHTARGETS_TEXTURE
|
||
var vertexID : f32;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},73683:(r,t,e)=>{e.r(t),e.d(t,{morphTargetsVertexGlobalDeclarationWGSL:()=>o});var n="morphTargetsVertexGlobalDeclaration",i=`#ifdef MORPHTARGETS
|
||
uniform morphTargetInfluences : array<f32,NUM_MORPH_INFLUENCERS>;
|
||
#ifdef MORPHTARGETS_TEXTURE
|
||
uniform morphTargetTextureIndices : array<f32,NUM_MORPH_INFLUENCERS>;uniform morphTargetTextureInfo : vec3<f32>;var morphTargets : texture_2d_array<f32>;var morphTargetsSampler : sampler;fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3<f32>
|
||
{
|
||
let y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;let textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);return textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;}
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},76778:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.oitDeclaration=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
|
||
#define MAX_DEPTH 99999.0
|
||
var oitDepthSamplerSampler: sampler;var oitDepthSampler: texture_2d<f32>;var oitFrontColorSamplerSampler: sampler;var oitFrontColorSampler: texture_2d<f32>;
|
||
#endif
|
||
`},73876:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.oitFragment=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY
|
||
var fragDepth: f32=fragmentInputs.position.z;
|
||
#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
|
||
var halfFloat: i32=packHalf2x16( vec2f(fragDepth));var full: vec2f=unpackHalf2x16(halfFloat);fragDepth=full.x;
|
||
#endif
|
||
var fragCoord: vec2i=vec2i(fragmentInputs.position.xy);var lastDepth: vec2f=textureLoad(oitDepthSampler,fragCoord,0).rg;var lastFrontColor: vec4f=textureLoad(oitFrontColorSampler,fragCoord,0);fragmentOutputs.depth=vec2f(-MAX_DEPTH);fragmentOutputs.frontColor=lastFrontColor;fragmentOutputs.backColor= vec4f(0.0);
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
var furthestDepth: f32=-lastDepth.x;var nearestDepth: f32=lastDepth.y;
|
||
#else
|
||
var nearestDepth: f32=-lastDepth.x;var furthestDepth: f32=lastDepth.y;
|
||
#endif
|
||
var alphaMultiplier: f32=1.0-lastFrontColor.a;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
|
||
#else
|
||
if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
|
||
#endif
|
||
return fragmentOutputs;}
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
|
||
#else
|
||
if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
|
||
#endif
|
||
fragmentOutputs.depth=vec2f(-fragDepth,fragDepth);return fragmentOutputs;}
|
||
#endif
|
||
`},68298:(r,t,e)=>{e.r(t),e.d(t,{packingFunctionsWGSL:()=>o});var n="packingFunctions",i=`fn pack(depth: f32)->vec4f
|
||
{const bit_shift: vec4f= vec4f(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const bit_mask: vec4f= vec4f(0.0,1.0/255.0,1.0/255.0,1.0/255.0);var res: vec4f=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
|
||
fn unpack(color: vec4f)->f32
|
||
{const bit_shift: vec4f= vec4f(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);}`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},61669:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.pbrBRDFFunctions=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
|
||
#ifdef MS_BRDF_ENERGY_CONSERVATION
|
||
fn getEnergyConservationFactor(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);}
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
fn getBRDFLookup(NdotV: f32,perceptualRoughness: f32)->vec3f {var UV: vec2f= vec2f(NdotV,perceptualRoughness);var brdfLookup: vec4f= textureSample(environmentBrdfSampler,environmentBrdfSamplerSampler,UV);
|
||
#ifdef ENVIRONMENTBRDF_RGBD
|
||
brdfLookup=vec4f(fromRGBD(brdfLookup.rgba),brdfLookup.a);
|
||
#endif
|
||
return brdfLookup.rgb;}
|
||
fn getReflectanceFromBRDFWithEnvLookup(specularEnvironmentR0: vec3f,specularEnvironmentR90: vec3f,environmentBrdf: vec3f)->vec3f {
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
var reflectance: vec3f=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
|
||
#else
|
||
var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
|
||
#endif
|
||
return reflectance;}
|
||
fn getReflectanceFromBRDFLookup(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
var reflectance: vec3f=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
|
||
#else
|
||
var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
|
||
#endif
|
||
return reflectance;}
|
||
#endif
|
||
/* NOT USED
|
||
#if defined(SHEEN) && defined(SHEEN_SOFTER)
|
||
fn getBRDFLookupCharlieSheen(NdotV: f32,perceptualRoughness: f32)->f32
|
||
{var c: f32=1.0-NdotV;var c3: f32=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));}
|
||
#endif
|
||
*/
|
||
#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
|
||
fn getReflectanceFromAnalyticalBRDFLookup_Jones(VdotN: f32,reflectance0: vec3f,reflectance90: vec3f,smoothness: f32)->vec3f
|
||
{var weight: f32=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
|
||
#endif
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
||
/**
|
||
* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.
|
||
* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table
|
||
*/
|
||
fn getSheenReflectanceFromBRDFLookup(reflectance0: vec3f,environmentBrdf: vec3f)->vec3f {var sheenEnvironmentReflectance: vec3f=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;}
|
||
#endif
|
||
fn fresnelSchlickGGXVec3(VdotH: f32,reflectance0: vec3f,reflectance90: vec3f)->vec3f
|
||
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
|
||
fn fresnelSchlickGGX(VdotH: f32,reflectance0: f32,reflectance90: f32)->f32
|
||
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
|
||
#ifdef CLEARCOAT
|
||
fn getR0RemappedForClearCoat(f0: vec3f)->vec3f {
|
||
#ifdef CLEARCOAT_DEFAULTIOR
|
||
#ifdef MOBILE
|
||
return saturateVec3(f0*(f0*0.526868+0.529324)-0.0482256);
|
||
#else
|
||
return saturateVec3(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
|
||
#endif
|
||
#else
|
||
var s: vec3f=sqrt(f0);var t: vec3f=(uniforms.vClearCoatRefractionParams.z+uniforms.vClearCoatRefractionParams.w*s)/(uniforms.vClearCoatRefractionParams.w+uniforms.vClearCoatRefractionParams.z*s);return squareVec3(t);
|
||
#endif
|
||
}
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
const XYZ_TO_REC709: mat3x3f= mat3x3f(
|
||
3.2404542,-0.9692660, 0.0556434,
|
||
-1.5371385, 1.8760108,-0.2040259,
|
||
-0.4985314, 0.0415560, 1.0572252
|
||
);fn getIORTfromAirToSurfaceR0(f0: vec3f)->vec3f {var sqrtF0: vec3f=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);}
|
||
fn getR0fromIORsVec3(iorT: vec3f,iorI: f32)->vec3f {return squareVec3((iorT- vec3f(iorI))/(iorT+ vec3f(iorI)));}
|
||
fn getR0fromIORs(iorT: f32,iorI: f32)->f32 {return square((iorT-iorI)/(iorT+iorI));}
|
||
fn evalSensitivity(opd: f32,shift: vec3f)->vec3f {var phase: f32=2.0*PI*opd*1.0e-9;const val: vec3f= vec3f(5.4856e-13,4.4201e-13,5.2481e-13);const pos: vec3f= vec3f(1.6810e+06,1.7953e+06,2.2084e+06);const vr: vec3f= vec3f(4.3278e+09,9.3046e+09,6.6121e+09);var xyz: vec3f=val*sqrt(2.0*PI*vr)*cos(pos*phase+shift)*exp(-square(phase)*vr);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*square(phase));xyz/=1.0685e-7;var srgb: vec3f=XYZ_TO_REC709*xyz;return srgb;}
|
||
fn evalIridescence(outsideIOR: f32,eta2: f32,cosTheta1: f32,thinFilmThickness: f32,baseF0: vec3f)->vec3f {var I: vec3f= vec3f(1.0);var iridescenceIOR: f32=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));var sinTheta2Sq: f32=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));var cosTheta2Sq: f32=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;}
|
||
var cosTheta2: f32=sqrt(cosTheta2Sq);var R0: f32=getR0fromIORs(iridescenceIOR,outsideIOR);var R12: f32=fresnelSchlickGGX(cosTheta1,R0,1.);var R21: f32=R12;var T121: f32=1.0-R12;var phi12: f32=0.0;if (iridescenceIOR<outsideIOR) {phi12=PI;}
|
||
var phi21: f32=PI-phi12;var baseIOR: vec3f=getIORTfromAirToSurfaceR0(clamp(baseF0,vec3f(0.0),vec3f(0.9999)));
|
||
var R1: vec3f=getR0fromIORsVec3(baseIOR,iridescenceIOR);var R23: vec3f=fresnelSchlickGGXVec3(cosTheta2,R1, vec3f(1.));var phi23: vec3f= vec3f(0.0);if (baseIOR[0]<iridescenceIOR) {phi23[0]=PI;}
|
||
if (baseIOR[1]<iridescenceIOR) {phi23[1]=PI;}
|
||
if (baseIOR[2]<iridescenceIOR) {phi23[2]=PI;}
|
||
var opd: f32=2.0*iridescenceIOR*thinFilmThickness*cosTheta2;var phi: vec3f= vec3f(phi21)+phi23;var R123: vec3f=clamp(R12*R23,vec3f(1e-5),vec3f(0.9999));var r123: vec3f=sqrt(R123);var Rs: vec3f=(T121*T121)*R23/( vec3f(1.0)-R123);var C0: vec3f=R12+Rs;I=C0;var Cm: vec3f=Rs-T121;for (var m: i32=1; m<=2; m++)
|
||
{Cm*=r123;var Sm: vec3f=2.0*evalSensitivity( f32(m)*opd, f32(m)*phi);I+=Cm*Sm;}
|
||
return max(I, vec3f(0.0));}
|
||
#endif
|
||
fn normalDistributionFunction_TrowbridgeReitzGGX(NdotH: f32,alphaG: f32)->f32
|
||
{var a2: f32=alphaG*alphaG;var d: f32=NdotH*NdotH*(a2-1.0)+1.0;return a2/(PI*d*d);}
|
||
#ifdef SHEEN
|
||
fn normalDistributionFunction_CharlieSheen(NdotH: f32,alphaG: f32)->f32
|
||
{var invR: f32=1./alphaG;var cos2h: f32=NdotH*NdotH;var sin2h: f32=1.-cos2h;return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);}
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
fn normalDistributionFunction_BurleyGGX_Anisotropic(NdotH: f32,TdotH: f32,BdotH: f32,alphaTB: vec2f)->f32 {var a2: f32=alphaTB.x*alphaTB.y;var v: vec3f= vec3f(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);var v2: f32=dot(v,v);var w2: f32=a2/v2;return a2*w2*w2*RECIPROCAL_PI;}
|
||
#endif
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
fn smithVisibility_GGXCorrelated(NdotL: f32,NdotV: f32,alphaG: f32)->f32 {
|
||
#ifdef MOBILE
|
||
var GGXV: f32=NdotL*(NdotV*(1.0-alphaG)+alphaG);var GGXL: f32=NdotV*(NdotL*(1.0-alphaG)+alphaG);return 0.5/(GGXV+GGXL);
|
||
#else
|
||
var a2: f32=alphaG*alphaG;var GGXV: f32=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);var GGXL: f32=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);return 0.5/(GGXV+GGXL);
|
||
#endif
|
||
}
|
||
#else
|
||
fn smithVisibilityG1_TrowbridgeReitzGGXFast(dot: f32,alphaG: f32)->f32
|
||
{
|
||
#ifdef MOBILE
|
||
return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
|
||
#else
|
||
var alphaSquared: f32=alphaG*alphaG;return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
|
||
#endif
|
||
}
|
||
fn smithVisibility_TrowbridgeReitzGGXFast(NdotL: f32,NdotV: f32,alphaG: f32)->f32
|
||
{var visibility: f32=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);return visibility;}
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
fn smithVisibility_GGXCorrelated_Anisotropic(NdotL: f32,NdotV: f32,TdotV: f32,BdotV: f32,TdotL: f32,BdotL: f32,alphaTB: vec2f)->f32 {var lambdaV: f32=NdotL*length( vec3f(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));var lambdaL: f32=NdotV*length( vec3f(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));var v: f32=0.5/(lambdaV+lambdaL);return v;}
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
fn visibility_Kelemen(VdotH: f32)->f32 {return 0.25/(VdotH*VdotH); }
|
||
#endif
|
||
#ifdef SHEEN
|
||
fn visibility_Ashikhmin(NdotL: f32,NdotV: f32)->f32
|
||
{return 1./(4.*(NdotL+NdotV-NdotL*NdotV));}
|
||
/* NOT USED
|
||
#ifdef SHEEN_SOFTER
|
||
fn l(x: f32,alphaG: f32)->f32
|
||
{var oneMinusAlphaSq: f32=(1.0-alphaG)*(1.0-alphaG);var a: f32=mix(21.5473,25.3245,oneMinusAlphaSq);var b: f32=mix(3.82987,3.32435,oneMinusAlphaSq);var c: f32=mix(0.19823,0.16801,oneMinusAlphaSq);var d: f32=mix(-1.97760,-1.27393,oneMinusAlphaSq);var e: f32=mix(-4.32054,-4.85967,oneMinusAlphaSq);return a/(1.0+b*pow(x,c))+d*x+e;}
|
||
fn lambdaSheen(cosTheta: f32,alphaG: f32)->f32
|
||
{return abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));}
|
||
fn visibility_CharlieSheen(NdotL: f32,NdotV: f32,alphaG: f32)->f32
|
||
{var G: f32=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));return G/(4.0*NdotV*NdotL);}
|
||
#endif
|
||
*/
|
||
#endif
|
||
fn diffuseBRDF_Burley(NdotL: f32,NdotV: f32,VdotH: f32,roughness: f32)->f32 {var diffuseFresnelNV: f32=pow5(saturateEps(1.0-NdotL));var diffuseFresnelNL: f32=pow5(saturateEps(1.0-NdotV));var diffuseFresnel90: f32=0.5+2.0*VdotH*VdotH*roughness;var fresnel: f32 =
|
||
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
|
||
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);return fresnel/PI;}
|
||
#ifdef SS_TRANSLUCENCY
|
||
fn transmittanceBRDF_Burley(tintColor: vec3f,diffusionDistance: vec3f,thickness: f32)->vec3f {var S: vec3f=1./maxEpsVec3(diffusionDistance);var temp: vec3f=exp((-0.333333333*thickness)*S);return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);}
|
||
fn computeWrappedDiffuseNdotL(NdotL: f32,w: f32)->f32 {var t: f32=1.0+w;var invt2: f32=1.0/(t*t);return saturate((NdotL+w)*invt2);}
|
||
#endif
|
||
`},14052:(r,t,e)=>{var n=e(98519),i=(e(36644),e(40647),"pbrUboDeclaration");n.l.IncludesShadersStoreWGSL[i]=`uniform vAlbedoInfos: vec2f;uniform vAmbientInfos: vec4f;uniform vOpacityInfos: vec2f;uniform vEmissiveInfos: vec2f;uniform vLightmapInfos: vec2f;uniform vReflectivityInfos: vec3f;uniform vMicroSurfaceSamplerInfos: vec2f;uniform vReflectionInfos: vec2f;uniform vReflectionFilteringInfo: vec2f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;uniform vBumpInfos: vec3f;uniform albedoMatrix: mat4x4f;uniform ambientMatrix: mat4x4f;uniform opacityMatrix: mat4x4f;uniform emissiveMatrix: mat4x4f;uniform lightmapMatrix: mat4x4f;uniform reflectivityMatrix: mat4x4f;uniform microSurfaceSamplerMatrix: mat4x4f;uniform bumpMatrix: mat4x4f;uniform vTangentSpaceParams: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionColor: vec3f;uniform vAlbedoColor: vec4f;uniform vLightingIntensity: vec4f;uniform vReflectionMicrosurfaceInfos: vec3f;uniform pointSize: f32;uniform vReflectivityColor: vec4f;uniform vEmissiveColor: vec3f;uniform vAmbientColor: vec3f;uniform vDebugMode: vec2f;uniform vMetallicReflectanceFactors: vec4f;uniform vMetallicReflectanceInfos: vec2f;uniform metallicReflectanceMatrix: mat4x4f;uniform vReflectanceInfos: vec2f;uniform reflectanceMatrix: mat4x4f;uniform vSphericalL00: vec3f;uniform vSphericalL1_1: vec3f;uniform vSphericalL10: vec3f;uniform vSphericalL11: vec3f;uniform vSphericalL2_2: vec3f;uniform vSphericalL2_1: vec3f;uniform vSphericalL20: vec3f;uniform vSphericalL21: vec3f;uniform vSphericalL22: vec3f;uniform vSphericalX: vec3f;uniform vSphericalY: vec3f;uniform vSphericalZ: vec3f;uniform vSphericalXX_ZZ: vec3f;uniform vSphericalYY_ZZ: vec3f;uniform vSphericalZZ: vec3f;uniform vSphericalXY: vec3f;uniform vSphericalYZ: vec3f;uniform vSphericalZX: vec3f;
|
||
#define ADDITIONAL_UBO_DECLARATION
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
`},78710:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.prePassDeclaration=`#ifdef PREPASS
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
varying vPosition : vec3f;
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
varying vViewPos: vec3f;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
|
||
#endif
|
||
#endif
|
||
`},21954:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.prePassVertex=`#ifdef PREPASS_DEPTH
|
||
vertexOutputs.vViewPos=(scene.view*worldPos).rgb;
|
||
#endif
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
vertexOutputs.vPosition=positionUpdated.xyz;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED) || defined(PREPASS_VELOCITY_LINEAR)
|
||
vertexOutputs.vCurrentPosition=scene.viewProjection*worldPos;
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
var previousInfluence: mat4x4f;previousInfluence=mPreviousBones[ i32(matricesIndices[0])]*matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndices[1])]*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndices[2])]*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndices[3])]*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
|
||
#endif
|
||
vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*previousInfluence* vec4f(positionUpdated,1.0);
|
||
#else
|
||
vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0);
|
||
#endif
|
||
#endif
|
||
`},84020:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.prePassVertexDeclaration=`#ifdef PREPASS
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
varying vPosition : vec3f;
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
varying vViewPos: vec3f;
|
||
#endif
|
||
#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
|
||
uniform previousViewProjection: mat4x4f;varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
|
||
#endif
|
||
#endif
|
||
`},61439:(r,t,e)=>{e.r(t),e.d(t,{reflectionFunctionWGSL:()=>o});var n="reflectionFunction",i=`fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
|
||
{var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0); }
|
||
fn computeMirroredFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
|
||
{var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(1.0-s,t,0); }
|
||
fn computeEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
||
{var cameraToVertex: vec3f=normalize(worldPos.xyz-eyePosition);var r: vec3f=normalize(reflect(cameraToVertex,worldNormal));r= (reflectionMatrix* vec4f(r,0)).xyz;var lon: f32=atan2(r.z,r.x);var lat: f32=acos(r.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0);}
|
||
fn computeSphericalCoords(worldPos: vec4f,worldNormal: vec3f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
|
||
{var viewDir: vec3f=normalize((view*worldPos).xyz);var viewNormal: vec3f=normalize((view* vec4f(worldNormal,0.0)).xyz);var r: vec3f=reflect(viewDir,viewNormal);r= (reflectionMatrix* vec4f(r,0)).xyz;r.z=r.z-1.0;var m: f32=2.0*length(r);return vec3f(r.x/m+0.5,1.0-r.y/m-0.5,0);}
|
||
fn computePlanarCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
||
{var viewDir: vec3f=worldPos.xyz-eyePosition;var coords: vec3f=normalize(reflect(viewDir,worldNormal));return (reflectionMatrix* vec4f(coords,1)).xyz;}
|
||
fn computeCubicCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
||
{var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords= (reflectionMatrix* vec4f(coords,0)).xyz;
|
||
#ifdef INVERTCUBICMAP
|
||
coords.y*=-1.0;
|
||
#endif
|
||
return coords;}
|
||
fn computeCubicLocalCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f,reflectionSize: vec3f,reflectionPosition: vec3f)->vec3f
|
||
{var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=(reflectionMatrix* vec4f(coords,0)).xyz;
|
||
#ifdef INVERTCUBICMAP
|
||
coords.y*=-1.0;
|
||
#endif
|
||
return coords;}
|
||
fn computeProjectionCoords(worldPos: vec4f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
|
||
{return (reflectionMatrix*(view*worldPos)).xyz;}
|
||
fn computeSkyBoxCoords(positionW: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
||
{return (reflectionMatrix* vec4f(positionW,1.)).xyz;}
|
||
#ifdef REFLECTION
|
||
fn computeReflectionCoords(worldPos: vec4f,worldNormal: vec3f)->vec3f
|
||
{
|
||
#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
|
||
var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
|
||
var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_EQUIRECTANGULAR
|
||
return computeEquirectangularCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SPHERICAL
|
||
return computeSphericalCoords(worldPos,worldNormal,scene.view,uniforms.reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_PLANAR
|
||
return computePlanarCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_CUBIC
|
||
#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
|
||
return computeCubicLocalCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix,uniforms.vReflectionSize,uniforms.vReflectionPosition);
|
||
#else
|
||
return computeCubicCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
return computeProjectionCoords(worldPos,scene.view,uniforms.reflectionMatrix);
|
||
#endif
|
||
#ifndef REFLECTIONMAP_CUBIC
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
return computeSkyBoxCoords(fragmentInputs.vPositionUVW,uniforms.reflectionMatrix);
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONMAP_EXPLICIT
|
||
return vec3f(0,0,0);
|
||
#endif
|
||
}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},338:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.samplerFragmentDeclaration=`#ifdef _DEFINENAME_
|
||
#if _DEFINENAME_DIRECTUV==1
|
||
#define v_VARYINGNAME_UV vMainUV1
|
||
#elif _DEFINENAME_DIRECTUV==2
|
||
#define v_VARYINGNAME_UV vMainUV2
|
||
#elif _DEFINENAME_DIRECTUV==3
|
||
#define v_VARYINGNAME_UV vMainUV3
|
||
#elif _DEFINENAME_DIRECTUV==4
|
||
#define v_VARYINGNAME_UV vMainUV4
|
||
#elif _DEFINENAME_DIRECTUV==5
|
||
#define v_VARYINGNAME_UV vMainUV5
|
||
#elif _DEFINENAME_DIRECTUV==6
|
||
#define v_VARYINGNAME_UV vMainUV6
|
||
#else
|
||
varying v_VARYINGNAME_UV: vec2f;
|
||
#endif
|
||
var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d<f32>;
|
||
#endif
|
||
`},12520:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.samplerVertexDeclaration=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
|
||
varying v_VARYINGNAME_UV: vec2f;
|
||
#endif
|
||
`},88380:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.samplerVertexImplementation=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0
|
||
if (uniforms.v_INFONAME_==0.)
|
||
{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(uvUpdated,1.0,0.0)).xy;}
|
||
#ifdef UV2
|
||
else if (uniforms.v_INFONAME_==1.)
|
||
{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv2,1.0,0.0)).xy;}
|
||
#endif
|
||
#ifdef UV3
|
||
else if (uniforms.v_INFONAME_==2.)
|
||
{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv3,1.0,0.0)).xy;}
|
||
#endif
|
||
#ifdef UV4
|
||
else if (uniforms.v_INFONAME_==3.)
|
||
{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv4,1.0,0.0)).xy;}
|
||
#endif
|
||
#ifdef UV5
|
||
else if (uniforms.v_INFONAME_==4.)
|
||
{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv5,1.0,0.0)).xy;}
|
||
#endif
|
||
#ifdef UV6
|
||
else if (uniforms.v_INFONAME_==5.)
|
||
{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv6,1.0,0.0)).xy;}
|
||
#endif
|
||
#endif
|
||
`},36644:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.sceneUboDeclaration=`struct Scene {viewProjection : mat4x4<f32>,
|
||
#ifdef MULTIVIEW
|
||
viewProjectionR : mat4x4<f32>,
|
||
#endif
|
||
view : mat4x4<f32>,
|
||
projection : mat4x4<f32>,
|
||
vEyePosition : vec4<f32>,};var<uniform> scene : Scene;
|
||
`},7779:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.screenSpaceRayTrace=`fn distanceSquared(a: vec2f,b: vec2f)->f32 {
|
||
var temp=a-b;
|
||
return dot(temp,temp); }
|
||
/**
|
||
param csOrigin Camera-space ray origin,which must be
|
||
within the view volume and must have z>0.01 and project within the valid screen rectangle
|
||
param csDirection Unit length camera-space ray direction
|
||
param projectToPixelMatrix A projection matrix that maps to **pixel** coordinates
|
||
(**not** [-1,+1] normalized device coordinates).
|
||
param csZBuffer The camera-space Z buffer
|
||
param csZBufferSize Dimensions of csZBuffer
|
||
param csZThickness Camera space csZThickness to ascribe to each pixel in the depth buffer
|
||
param nearPlaneZ Positive number. Doesn't have to be THE actual near plane,just a reasonable value
|
||
for clipping rays headed towards the camera
|
||
param stride Step in horizontal or vertical pixels between samples. This is a var because: f32 integer math is slow on GPUs,but should be set to an integer>=1
|
||
param jitterFraction Number between 0 and 1 for how far to bump the ray in stride units
|
||
to conceal banding artifacts,plus the stride ray offset.
|
||
param maxSteps Maximum number of iterations. Higher gives better images but may be slow
|
||
param maxRayTraceDistance Maximum camera-space distance to trace before returning a miss
|
||
param selfCollisionNumSkip Number of steps to skip at start when raytracing to avar self: voidnull collisions.
|
||
1 is a reasonable value,depending on the scene you may need to set this value to 2
|
||
param hitPixel Pixel coordinates of the first intersection with the scene
|
||
param numIterations number of iterations performed
|
||
param csHitPovar Camera: i32 space location of the ray hit
|
||
*/
|
||
fn traceScreenSpaceRay1(
|
||
csOrigin: vec3f,
|
||
csDirection: vec3f,
|
||
projectToPixelMatrix: mat4x4f,
|
||
csZBuffer: texture_2d<f32>,
|
||
csZBufferSize: vec2f,
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
csZBackBuffer: texture_2d<f32>,
|
||
csZBackSizeFactor: f32,
|
||
#endif
|
||
csZThickness: f32,
|
||
nearPlaneZ: f32,
|
||
stride: f32,
|
||
jitterFraction: f32,
|
||
maxSteps: f32,
|
||
maxRayTraceDistance: f32,
|
||
selfCollisionNumSkip: f32,
|
||
startPixel: ptr<function,vec2f>,
|
||
hitPixel: ptr<function,vec2f>,
|
||
csHitPoint: ptr<function,vec3f>,
|
||
numIterations: ptr<function,f32>
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
,debugColor: ptr<function,vec3f>
|
||
#endif
|
||
)->bool
|
||
{
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
var rayLength: f32=select(maxRayTraceDistance,(-nearPlaneZ-csOrigin.z)/csDirection.z,(csOrigin.z+csDirection.z*maxRayTraceDistance)>-nearPlaneZ);
|
||
#else
|
||
var rayLength: f32=select(maxRayTraceDistance,(nearPlaneZ-csOrigin.z)/csDirection.z,(csOrigin.z+csDirection.z*maxRayTraceDistance)<nearPlaneZ);
|
||
#endif
|
||
var csEndPoint: vec3f=csOrigin+csDirection*rayLength;*hitPixel= vec2f(-1.0,-1.0);var H0: vec4f=projectToPixelMatrix* vec4f(csOrigin,1.0);var H1: vec4f=projectToPixelMatrix* vec4f(csEndPoint,1.0);var k0: f32=1.0/H0.w;var k1: f32=1.0/H1.w;var Q0: vec3f=csOrigin*k0;var Q1: vec3f=csEndPoint*k1;var P0: vec2f=H0.xy*k0;var P1: vec2f=H1.xy*k1;
|
||
#ifdef SSRAYTRACE_CLIP_TO_FRUSTUM
|
||
var xMax: f32=csZBufferSize.x-0.5;var xMin=0.5;var yMax=csZBufferSize.y-0.5;var yMin=0.5;var alpha: f32=0.0;if ((P1.y>yMax) || (P1.y<yMin)) {alpha=(P1.y-select(yMin,yMax,(P1.y>yMax)))/(P1.y-P0.y);}
|
||
if ((P1.x>xMax) || (P1.x<xMin)) {alpha=max(alpha,(P1.x-select(xMin,xMax,(P1.x>xMax)))/(P1.x-P0.x));}
|
||
P1=mix(P1,P0,alpha); k1=mix(k1,k0,alpha); Q1=mix(Q1,Q0,alpha);
|
||
#endif
|
||
P1+= vec2f(select(0.0,0.01,distanceSquared(P0,P1)<0.0001));var delta: vec2f=P1-P0;var permute: bool=false;if (abs(delta.x)<abs(delta.y)) {
|
||
permute=true;delta=delta.yx;P0=P0.yx;P1=P1.yx; }
|
||
var stepDirection: f32=sign(delta.x);var invdx: f32=stepDirection/delta.x;var dP: vec2f= vec2f(stepDirection,delta.y*invdx);var dQ: vec3f=(Q1-Q0)*invdx;var dk: f32=(k1-k0)*invdx;var zMin: f32=min(csEndPoint.z,csOrigin.z);var zMax: f32=max(csEndPoint.z,csOrigin.z);dP*=stride; dQ*=stride; dk*=stride;P0+=dP*jitterFraction; Q0+=dQ*jitterFraction; k0+=dk*jitterFraction;var pqk: vec4f= vec4f(P0,Q0.z,k0);var dPQK: vec4f= vec4f(dP,dQ.z,dk);*startPixel=select(P0.xy,P0.yx,permute);var prevZMaxEstimate: f32=csOrigin.z;var rayZMin: f32=prevZMaxEstimate;var rayZMax=prevZMaxEstimate;var sceneZMax: f32=rayZMax+1e4;var end: f32=P1.x*stepDirection;var hit: bool=false;var stepCount: f32;for (stepCount=0.0;(stepCount<=selfCollisionNumSkip) ||
|
||
((pqk.x*stepDirection)<=end &&
|
||
stepCount<maxSteps &&
|
||
!hit &&
|
||
sceneZMax != 0.0);pqk+=dPQK
|
||
)
|
||
{*hitPixel=select(pqk.xy,pqk.yx,permute);rayZMin=prevZMaxEstimate;rayZMax=(dPQK.z*0.5+pqk.z)/(dPQK.w*0.5+pqk.w);rayZMax=clamp(rayZMax,zMin,zMax);prevZMaxEstimate=rayZMax;if (rayZMin>rayZMax) {
|
||
var t: f32=rayZMin; rayZMin=rayZMax; rayZMax=t;}
|
||
sceneZMax=textureLoad(csZBuffer,vec2<i32>(*hitPixel),0).r;
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
var sceneBackZ: f32=textureLoad(csZBackBuffer,vec2<i32>(*hitPixel/csZBackSizeFactor),0).r;hit=(rayZMax>=sceneBackZ-csZThickness) && (rayZMin<=sceneZMax);
|
||
#else
|
||
hit=(rayZMax>=sceneZMax-csZThickness) && (rayZMin<=sceneZMax);
|
||
#endif
|
||
#else
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
var sceneBackZ: f32=textureLoad(csZBackBuffer,vec2<i32>(*hitPixel/csZBackSizeFactor),0).r;hit=(rayZMin<=sceneBackZ+csZThickness) && (rayZMax>=sceneZMax) && (sceneZMax != 0.0);
|
||
#else
|
||
hit=(rayZMin<=sceneZMax+csZThickness) && (rayZMax>=sceneZMax);
|
||
#endif
|
||
#endif
|
||
stepCount+=1.0;}
|
||
pqk-=dPQK;stepCount-=1.0;if (((pqk.x+dPQK.x)*stepDirection)>end || (stepCount+1.0)>=maxSteps || sceneZMax==0.0) {hit=false;}
|
||
#ifdef SSRAYTRACE_ENABLE_REFINEMENT
|
||
if (stride>1.0 && hit) {pqk-=dPQK;stepCount-=1.0;var invStride: f32=1.0/stride;dPQK*=invStride;var refinementStepCount: f32=0.0;prevZMaxEstimate=pqk.z/pqk.w;rayZMax=prevZMaxEstimate;sceneZMax=rayZMax+1e7;for (;refinementStepCount<=1.0 ||
|
||
((refinementStepCount<=stride*1.4) &&
|
||
(rayZMax<sceneZMax) && (sceneZMax != 0.0));pqk+=dPQK)
|
||
{rayZMin=prevZMaxEstimate;rayZMax=(dPQK.z*0.5+pqk.z)/(dPQK.w*0.5+pqk.w);rayZMax=clamp(rayZMax,zMin,zMax);prevZMaxEstimate=rayZMax;rayZMax=max(rayZMax,rayZMin);*hitPixel=select(pqk.xy,pqk.yx,permute);sceneZMax=textureLoad(csZBuffer,vec2<i32>(*hitPixel),0).r;refinementStepCount+=1.0;}
|
||
pqk-=dPQK;refinementStepCount-=1.0;stepCount+=refinementStepCount/stride;}
|
||
#endif
|
||
Q0=vec3f(Q0.xy+dQ.xy*stepCount,pqk.z);*csHitPoint=Q0/pqk.w;*numIterations=stepCount+1.0;
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
if (((pqk.x+dPQK.x)*stepDirection)>end) {*debugColor= vec3f(0,0,1);} else if ((stepCount+1.0)>=maxSteps) {*debugColor= vec3f(1,0,0);} else if (sceneZMax==0.0) {*debugColor= vec3f(1,1,0);} else {*debugColor= vec3f(0,stepCount/maxSteps,0);}
|
||
#endif
|
||
return hit;}
|
||
/**
|
||
texCoord: in the [0,1] range
|
||
depth: depth in view space (range [znear,zfar]])
|
||
*/
|
||
fn computeViewPosFromUVDepth(texCoord: vec2f,depth: f32,projection: mat4x4f,invProjectionMatrix: mat4x4f)->vec3f {var xy=texCoord*2.0-1.0;var z: f32;
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
#ifdef ORTHOGRAPHIC_CAMERA
|
||
z=-projection[2].z*depth+projection[3].z;
|
||
#else
|
||
z=-projection[2].z-projection[3].z/depth;
|
||
#endif
|
||
#else
|
||
#ifdef ORTHOGRAPHIC_CAMERA
|
||
z=projection[2].z*depth+projection[3].z;
|
||
#else
|
||
z=projection[2].z+projection[3].z/depth;
|
||
#endif
|
||
#endif
|
||
var w=1.0;var ndc=vec4f(xy,z,w);var eyePos: vec4f=invProjectionMatrix*ndc;var result=eyePos.xyz/eyePos.w;return result;}
|
||
`},79574:(r,t,e)=>{e.r(t),e.d(t,{shadowMapFragmentWGSL:()=>o});var n="shadowMapFragment",i=`var depthSM: f32=fragmentInputs.vDepthMetricSM;
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
#if SM_USEDISTANCE==1
|
||
depthSM=(length(fragmentInputs.vPositionWSM-uniforms.lightDataSM)+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x;
|
||
#else
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
depthSM=(-fragmentInputs.zSM+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x;
|
||
#else
|
||
depthSM=(fragmentInputs.zSM+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x;
|
||
#endif
|
||
#endif
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
fragmentOutputs.fragDepth=clamp(1.0-depthSM,0.0,1.0);
|
||
#else
|
||
fragmentOutputs.fragDepth=clamp(depthSM,0.0,1.0);
|
||
#endif
|
||
#elif SM_USEDISTANCE==1
|
||
depthSM=(length(fragmentInputs.vPositionWSM-uniforms.lightDataSM)+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x;
|
||
#endif
|
||
#if SM_ESM==1
|
||
depthSM=clamp(exp(-min(87.,uniforms.biasAndScaleSM.z*depthSM)),0.,1.);
|
||
#endif
|
||
#if SM_FLOAT==1
|
||
fragmentOutputs.color= vec4f(depthSM,1.0,1.0,1.0);
|
||
#else
|
||
fragmentOutputs.color=pack(depthSM);
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},14654:(r,t,e)=>{e.r(t),e.d(t,{shadowMapFragmentSoftTransparentShadowWGSL:()=>o});var n="shadowMapFragmentSoftTransparentShadow",i=`#if SM_SOFTTRANSPARENTSHADOW==1
|
||
if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.softTransparentShadowSM.x*alpha) {discard;}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},28924:(r,t,e)=>{e.r(t),e.d(t,{shadowMapVertexMetricWGSL:()=>o});var n="shadowMapVertexMetric",i=`#if SM_USEDISTANCE==1
|
||
vertexOutputs.vPositionWSM=worldPos.xyz;
|
||
#endif
|
||
#if SM_DEPTHTEXTURE==1
|
||
#ifdef IS_NDC_HALF_ZRANGE
|
||
#define BIASFACTOR 0.5
|
||
#else
|
||
#define BIASFACTOR 1.0
|
||
#endif
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.position.z-=uniforms.biasAndScaleSM.x*vertexOutputs.position.w*BIASFACTOR;
|
||
#else
|
||
vertexOutputs.position.z+=uniforms.biasAndScaleSM.x*vertexOutputs.position.w*BIASFACTOR;
|
||
#endif
|
||
#endif
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
vertexOutputs.zSM=vertexOutputs.position.z;vertexOutputs.position.z=0.0;
|
||
#elif SM_USEDISTANCE==0
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.vDepthMetricSM=(-vertexOutputs.position.z+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x;
|
||
#else
|
||
vertexOutputs.vDepthMetricSM=(vertexOutputs.position.z+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x;
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},32532:(r,t,e)=>{e.r(t),e.d(t,{shadowsFragmentFunctionsWGSL:()=>o});var n="shadowsFragmentFunctions",i=`#ifdef SHADOWS
|
||
#ifndef SHADOWFLOAT
|
||
fn unpack(color: vec4f)->f32
|
||
{const bit_shift: vec4f= vec4f(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);}
|
||
#endif
|
||
fn computeFallOff(value: f32,clipSpace: vec2f,frustumEdgeFalloff: f32)->f32
|
||
{var mask: f32=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
|
||
fn computeShadowCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthValues: vec2f)->f32
|
||
{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
|
||
#ifndef SHADOWFLOAT
|
||
var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
|
||
#else
|
||
var shadow: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
|
||
#endif
|
||
return select(darkness,1.0,depth>shadow);}
|
||
fn computeShadowWithPoissonSamplingCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,mapSize: f32,darkness: f32,depthValues: vec2f)->f32
|
||
{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;var visibility: f32=1.;var poissonDisk: array<vec3f,4>;poissonDisk[0]= vec3f(-1.0,1.0,-1.0);poissonDisk[1]= vec3f(1.0,-1.0,-1.0);poissonDisk[2]= vec3f(-1.0,-1.0,-1.0);poissonDisk[3]= vec3f(1.0,-1.0,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) {visibility-=0.25;};
|
||
#else
|
||
if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) {visibility-=0.25;};
|
||
#endif
|
||
return min(1.0,visibility+darkness);}
|
||
fn computeShadowWithESMCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32
|
||
{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
|
||
#ifndef SHADOWFLOAT
|
||
var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
|
||
#else
|
||
var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
|
||
#endif
|
||
var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
|
||
fn computeShadowWithCloseESMCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32
|
||
{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
|
||
#ifndef SHADOWFLOAT
|
||
var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
|
||
#else
|
||
var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
|
||
#endif
|
||
var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
|
||
fn computeShadowCSM(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d_array<f32>,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,uv,layer));
|
||
#else
|
||
var shadow: f32=textureSample(shadowTexture,shadowSampler,uv,layer).x;
|
||
#endif
|
||
return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );}
|
||
fn computeShadow(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
|
||
{return 1.0;}
|
||
else
|
||
{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
var shadow: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
|
||
#else
|
||
var shadow: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
|
||
#endif
|
||
return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );}}
|
||
fn computeShadowWithPoissonSampling(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,mapSize: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
|
||
{return 1.0;}
|
||
else
|
||
{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);var visibility: f32=1.;var poissonDisk: array<vec2f,4>;poissonDisk[0]= vec2f(-0.94201624,-0.39906216);poissonDisk[1]= vec2f(0.94558609,-0.76890725);poissonDisk[2]= vec2f(-0.094184101,-0.92938870);poissonDisk[3]= vec2f(0.34495938,0.29387760);
|
||
#ifndef SHADOWFLOAT
|
||
if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
|
||
if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
|
||
if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
|
||
if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
|
||
#else
|
||
if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
|
||
if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
|
||
if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
|
||
if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
|
||
#endif
|
||
return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
|
||
fn computeShadowWithESM(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
|
||
{return 1.0;}
|
||
else
|
||
{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
|
||
#else
|
||
var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
|
||
#endif
|
||
var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
|
||
fn computeShadowWithCloseESM(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
|
||
{return 1.0;}
|
||
else
|
||
{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
|
||
#ifndef SHADOWFLOAT
|
||
var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
|
||
#else
|
||
var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
|
||
#endif
|
||
var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
|
||
fn getZInClip(clipSpace: vec3f,uvDepth: vec3f)->f32
|
||
{
|
||
#ifdef IS_NDC_HALF_ZRANGE
|
||
return clipSpace.z;
|
||
#else
|
||
return uvDepth.z;
|
||
#endif
|
||
}
|
||
const GREATEST_LESS_THAN_ONE: f32=0.99999994;
|
||
#define DISABLE_UNIFORMITY_ANALYSIS
|
||
fn computeShadowWithCSMPCF1(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var shadow: f32=textureSampleCompare(shadowTexture,shadowSampler,uvDepth.xy,layer,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
|
||
fn computeShadowWithCSMPCF3(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
var st: vec2f=fract(uv);
|
||
var base_uv: vec2f=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
|
||
fn computeShadowWithCSMPCF5(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
var st: vec2f=fract(uv);
|
||
var base_uv: vec2f=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),layer,uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),layer,uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),layer,uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),layer,uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
|
||
fn computeShadowWithPCF1(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
|
||
else
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var shadow: f32=textureSampleCompareLevel(shadowTexture,shadowSampler,uvDepth.xy,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
|
||
fn computeShadowWithPCF3(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
|
||
else
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
var st: vec2f=fract(uv);
|
||
var base_uv: vec2f=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
|
||
fn computeShadowWithPCF5(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
|
||
else
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
|
||
uv+=0.5;
|
||
var st: vec2f=fract(uv);
|
||
var base_uv: vec2f=floor(uv)-0.5;
|
||
base_uv*=shadowMapSizeAndInverse.y;
|
||
var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
|
||
const PoissonSamplers32: array<vec3f,64>=array<vec3f,64> (
|
||
vec3f(0.06407013,0.05409927,0.),
|
||
vec3f(0.7366577,0.5789394,0.),
|
||
vec3f(-0.6270542,-0.5320278,0.),
|
||
vec3f(-0.4096107,0.8411095,0.),
|
||
vec3f(0.6849564,-0.4990818,0.),
|
||
vec3f(-0.874181,-0.04579735,0.),
|
||
vec3f(0.9989998,0.0009880066,0.),
|
||
vec3f(-0.004920578,-0.9151649,0.),
|
||
vec3f(0.1805763,0.9747483,0.),
|
||
vec3f(-0.2138451,0.2635818,0.),
|
||
vec3f(0.109845,0.3884785,0.),
|
||
vec3f(0.06876755,-0.3581074,0.),
|
||
vec3f(0.374073,-0.7661266,0.),
|
||
vec3f(0.3079132,-0.1216763,0.),
|
||
vec3f(-0.3794335,-0.8271583,0.),
|
||
vec3f(-0.203878,-0.07715034,0.),
|
||
vec3f(0.5912697,0.1469799,0.),
|
||
vec3f(-0.88069,0.3031784,0.),
|
||
vec3f(0.5040108,0.8283722,0.),
|
||
vec3f(-0.5844124,0.5494877,0.),
|
||
vec3f(0.6017799,-0.1726654,0.),
|
||
vec3f(-0.5554981,0.1559997,0.),
|
||
vec3f(-0.3016369,-0.3900928,0.),
|
||
vec3f(-0.5550632,-0.1723762,0.),
|
||
vec3f(0.925029,0.2995041,0.),
|
||
vec3f(-0.2473137,0.5538505,0.),
|
||
vec3f(0.9183037,-0.2862392,0.),
|
||
vec3f(0.2469421,0.6718712,0.),
|
||
vec3f(0.3916397,-0.4328209,0.),
|
||
vec3f(-0.03576927,-0.6220032,0.),
|
||
vec3f(-0.04661255,0.7995201,0.),
|
||
vec3f(0.4402924,0.3640312,0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.),
|
||
vec3f(0.)
|
||
);const PoissonSamplers64: array<vec3f,64>=array<vec3f,64> (
|
||
vec3f(-0.613392,0.617481,0.),
|
||
vec3f(0.170019,-0.040254,0.),
|
||
vec3f(-0.299417,0.791925,0.),
|
||
vec3f(0.645680,0.493210,0.),
|
||
vec3f(-0.651784,0.717887,0.),
|
||
vec3f(0.421003,0.027070,0.),
|
||
vec3f(-0.817194,-0.271096,0.),
|
||
vec3f(-0.705374,-0.668203,0.),
|
||
vec3f(0.977050,-0.108615,0.),
|
||
vec3f(0.063326,0.142369,0.),
|
||
vec3f(0.203528,0.214331,0.),
|
||
vec3f(-0.667531,0.326090,0.),
|
||
vec3f(-0.098422,-0.295755,0.),
|
||
vec3f(-0.885922,0.215369,0.),
|
||
vec3f(0.566637,0.605213,0.),
|
||
vec3f(0.039766,-0.396100,0.),
|
||
vec3f(0.751946,0.453352,0.),
|
||
vec3f(0.078707,-0.715323,0.),
|
||
vec3f(-0.075838,-0.529344,0.),
|
||
vec3f(0.724479,-0.580798,0.),
|
||
vec3f(0.222999,-0.215125,0.),
|
||
vec3f(-0.467574,-0.405438,0.),
|
||
vec3f(-0.248268,-0.814753,0.),
|
||
vec3f(0.354411,-0.887570,0.),
|
||
vec3f(0.175817,0.382366,0.),
|
||
vec3f(0.487472,-0.063082,0.),
|
||
vec3f(-0.084078,0.898312,0.),
|
||
vec3f(0.488876,-0.783441,0.),
|
||
vec3f(0.470016,0.217933,0.),
|
||
vec3f(-0.696890,-0.549791,0.),
|
||
vec3f(-0.149693,0.605762,0.),
|
||
vec3f(0.034211,0.979980,0.),
|
||
vec3f(0.503098,-0.308878,0.),
|
||
vec3f(-0.016205,-0.872921,0.),
|
||
vec3f(0.385784,-0.393902,0.),
|
||
vec3f(-0.146886,-0.859249,0.),
|
||
vec3f(0.643361,0.164098,0.),
|
||
vec3f(0.634388,-0.049471,0.),
|
||
vec3f(-0.688894,0.007843,0.),
|
||
vec3f(0.464034,-0.188818,0.),
|
||
vec3f(-0.440840,0.137486,0.),
|
||
vec3f(0.364483,0.511704,0.),
|
||
vec3f(0.034028,0.325968,0.),
|
||
vec3f(0.099094,-0.308023,0.),
|
||
vec3f(0.693960,-0.366253,0.),
|
||
vec3f(0.678884,-0.204688,0.),
|
||
vec3f(0.001801,0.780328,0.),
|
||
vec3f(0.145177,-0.898984,0.),
|
||
vec3f(0.062655,-0.611866,0.),
|
||
vec3f(0.315226,-0.604297,0.),
|
||
vec3f(-0.780145,0.486251,0.),
|
||
vec3f(-0.371868,0.882138,0.),
|
||
vec3f(0.200476,0.494430,0.),
|
||
vec3f(-0.494552,-0.711051,0.),
|
||
vec3f(0.612476,0.705252,0.),
|
||
vec3f(-0.578845,-0.768792,0.),
|
||
vec3f(-0.772454,-0.090976,0.),
|
||
vec3f(0.504440,0.372295,0.),
|
||
vec3f(0.155736,0.065157,0.),
|
||
vec3f(0.391522,0.849605,0.),
|
||
vec3f(-0.620106,-0.328104,0.),
|
||
vec3f(0.789239,-0.419965,0.),
|
||
vec3f(-0.545396,0.538133,0.),
|
||
vec3f(-0.178564,-0.596057,0.)
|
||
);fn computeShadowWithCSMPCSS(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array<vec3f,64>,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uvDepthLayer: vec4f= vec4f(uvDepth.x,uvDepth.y,f32(layer),uvDepth.z);var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;for (var i: i32=0; i<searchTapCount; i ++) {blockerDepth=textureSample(depthTexture,depthSampler, uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer).r;numBlocker+=select(0.,1.,blockerDepth<depthMetric);sumBlockerDepth+=select(0.,blockerDepth,blockerDepth<depthMetric);}
|
||
var avgBlockerDepth: f32=sumBlockerDepth/numBlocker;var AAOffset: f32=shadowMapSizeInverse*10.;var penumbraRatio: f32=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);var filterRadius: vec4f= vec4f(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);var random: f32=getRand(vPositionFromLight.xy);var rotationAngle: f32=random*3.1415926;var rotationVector: vec2f= vec2f(cos(rotationAngle),sin(rotationAngle));var shadow: f32=0.;for (var i: i32=0; i<pcfTapCount; i++) {var offset: vec4f= vec4f(poissonSamplers[i],0.);offset= vec4f(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);let coords=uvDepthLayer+offset*filterRadius;shadow+=textureSampleCompare(shadowTexture,shadowSampler,coords.xy,i32(coords.z),coords.w);}
|
||
shadow/= f32(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);return select(computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff),1.0,numBlocker<1.0);}
|
||
fn computeShadowWithPCSS(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array<vec3f,64>)->f32
|
||
{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;var exitCondition: bool=depthMetric>1.0 || depthMetric<0.0;for (var i: i32=0; i<searchTapCount; i ++) {if (exitCondition) {break;}
|
||
blockerDepth=textureSampleLevel(depthTexture,depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0).r;numBlocker+=select(0.,1.,blockerDepth<depthMetric);sumBlockerDepth+=select(0.,blockerDepth,blockerDepth<depthMetric);}
|
||
exitCondition=exitCondition || numBlocker<1.0;var avgBlockerDepth: f32=sumBlockerDepth/numBlocker;var AAOffset: f32=shadowMapSizeInverse*10.;var penumbraRatio: f32=((depthMetric-avgBlockerDepth)+AAOffset);var filterRadius: f32=penumbraRatio*lightSizeUV*shadowMapSizeInverse;var random: f32=getRand(vPositionFromLight.xy);var rotationAngle: f32=random*3.1415926;var rotationVector: vec2f= vec2f(cos(rotationAngle),sin(rotationAngle));var shadow: f32=0.;for (var i: i32=0; i<pcfTapCount; i++) {if (exitCondition) {break;}
|
||
var offset: vec3f=poissonSamplers[i];offset= vec3f(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);let coords=uvDepth+offset*filterRadius;shadow+=textureSampleCompareLevel(shadowTexture,shadowSampler,coords.xy,coords.z);}
|
||
shadow/= f32(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return select(computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff),1.0,exitCondition);}
|
||
fn computeShadowWithPCSS16(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
|
||
fn computeShadowWithPCSS32(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
|
||
fn computeShadowWithPCSS64(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
|
||
{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
|
||
fn computeShadowWithCSMPCSS16(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
|
||
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
|
||
fn computeShadowWithCSMPCSS32(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
|
||
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
|
||
fn computeShadowWithCSMPCSS64(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
|
||
{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},59115:(r,t,e)=>{e.r(t),e.d(t,{shadowsVertexWGSL:()=>o});var n="shadowsVertex",i=`#ifdef SHADOWS
|
||
#if defined(SHADOWCSM{X})
|
||
vertexOutputs.vPositionFromCamera{X}=scene.view*worldPos;
|
||
#if SHADOWCSMNUM_CASCADES{X}>0
|
||
vertexOutputs.vPositionFromLight{X}_0=uniforms.lightMatrix{X}[0]*worldPos;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.vDepthMetric{X}_0=(-vertexOutputs.vPositionFromLight{X}_0.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#else
|
||
vertexOutputs.vDepthMetric{X}_0= (vertexOutputs.vPositionFromLight{X}_0.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#endif
|
||
#endif
|
||
#if SHADOWCSMNUM_CASCADES{X}>1
|
||
vertexOutputs.vPositionFromLight{X}_1=uniforms.lightMatrix{X}[1]*worldPos;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.vDepthMetric{X}_1=(-vertexOutputs.vPositionFromLight{X}_1.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#else
|
||
vertexOutputs.vDepthMetric{X}_1= (vertexOutputs.vPositionFromLight{X}_1.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#endif
|
||
#endif
|
||
#if SHADOWCSMNUM_CASCADES{X}>2
|
||
vertexOutputs.vPositionFromLight{X}_2=uniforms.lightMatrix{X}[2]*worldPos;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.vDepthMetric{X}_2=(-vertexOutputs.vPositionFromLight{X}_2.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#else
|
||
vertexOutputs.vDepthMetric{X}_2= (vertexOutputs.vPositionFromLight{X}_2.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#endif
|
||
#endif
|
||
#if SHADOWCSMNUM_CASCADES{X}>3
|
||
vertexOutputs.vPositionFromLight{X}_3=uniforms.lightMatrix{X}[3]*worldPos;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.vDepthMetric{X}_3=(-vertexOutputs.vPositionFromLight{X}_3.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#else
|
||
vertexOutputs.vDepthMetric{X}_3= (vertexOutputs.vPositionFromLight{X}_3.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#endif
|
||
#endif
|
||
#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})
|
||
vertexOutputs.vPositionFromLight{X}=uniforms.lightMatrix{X}*worldPos;
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.vDepthMetric{X}=(-vertexOutputs.vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#else
|
||
vertexOutputs.vDepthMetric{X}=(vertexOutputs.vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.IncludesShadersStoreWGSL[n]=i;var o={name:n,shader:i}},56213:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.uvAttributeDeclaration=`#ifdef UV{X}
|
||
attribute uv{X}: vec2f;
|
||
#endif
|
||
`},28981:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.uvVariableDeclaration=`#ifdef MAINUV{X}
|
||
#if !defined(UV{X})
|
||
var uv{X}: vec2f=vec2f(0.,0.);
|
||
#else
|
||
var uv{X}: vec2f=vertexInputs.uv{X};
|
||
#endif
|
||
vertexOutputs.vMainUV{X}=uv{X};
|
||
#endif
|
||
`},50615:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.vertexColorMixing=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
vertexOutputs.vColor=vec4f(1.0);
|
||
#ifdef VERTEXCOLOR
|
||
#ifdef VERTEXALPHA
|
||
vertexOutputs.vColor*=vertexInputs.color;
|
||
#else
|
||
vertexOutputs.vColor=vec4f(vertexOutputs.vColor.rgb*vertexInputs.color.rgb,vertexOutputs.vColor.a);
|
||
#endif
|
||
#endif
|
||
#ifdef INSTANCESCOLOR
|
||
vertexOutputs.vColor*=vertexInputs.instanceColor;
|
||
#endif
|
||
#endif
|
||
`},89111:(r,t,e)=>{e.r(t),e.d(t,{anaglyphPixelShaderWGSL:()=>o});var n="anaglyphPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var leftSamplerSampler: sampler;var leftSampler: texture_2d<f32>;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var leftFrag: vec4f=textureSample(leftSampler,leftSamplerSampler,input.vUV);leftFrag= vec4f(1.0,leftFrag.g,leftFrag.b,1.0);var rightFrag: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);rightFrag= vec4f(rightFrag.r,1.0,1.0,1.0);fragmentOutputs.color= vec4f(rightFrag.rgb*leftFrag.rgb,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},40387:(r,t,e)=>{e.r(t),e.d(t,{backgroundPixelShaderWGSL:()=>a});var n=e(98519),i=(e(66138),e(17393),e(61439),e(86320),e(10896),e(53378),e(32532),e(4661),e(38197),e(20502),e(98318),e(30032),e(84192),e(56897),e(83512),"backgroundPixelShader"),o=`#include<backgroundUboDeclaration>
|
||
#include<helperFunctions>
|
||
varying vPositionW: vec3f;
|
||
#ifdef MAINUV1
|
||
varying vMainUV1: vec2f;
|
||
#endif
|
||
#ifdef MAINUV2
|
||
varying vMainUV2: vec2f;
|
||
#endif
|
||
#ifdef NORMAL
|
||
varying vNormalW: vec3f;
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
#if DIFFUSEDIRECTUV==1
|
||
#define vDiffuseUV vMainUV1
|
||
#elif DIFFUSEDIRECTUV==2
|
||
#define vDiffuseUV vMainUV2
|
||
#else
|
||
varying vDiffuseUV: vec2f;
|
||
#endif
|
||
var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef REFLECTIONMAP_3D
|
||
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
|
||
#ifdef TEXTURELODSUPPORT
|
||
#else
|
||
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
|
||
#endif
|
||
#else
|
||
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
|
||
#ifdef TEXTURELODSUPPORT
|
||
#else
|
||
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vPositionUVW: vec3f;
|
||
#else
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vDirectionW: vec3f;
|
||
#endif
|
||
#endif
|
||
#include<reflectionFunction>
|
||
#endif
|
||
#ifndef FROMLINEARSPACE
|
||
#define FROMLINEARSPACE;
|
||
#endif
|
||
#ifndef SHADOWONLY
|
||
#define SHADOWONLY;
|
||
#endif
|
||
#include<imageProcessingDeclaration>
|
||
#include<lightUboDeclaration>[0..maxSimultaneousLights]
|
||
#include<lightsFragmentFunctions>
|
||
#include<shadowsFragmentFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#include<logDepthDeclaration>
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#ifdef REFLECTIONFRESNEL
|
||
#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
|
||
fn fresnelSchlickEnvironmentGGX(VdotN: f32,reflectance0: vec3f,reflectance90: vec3f,smoothness: f32)->vec3f
|
||
{var weight: f32=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
|
||
#endif
|
||
#ifdef PROJECTED_GROUND
|
||
fn diskIntersectWithBackFaceCulling(ro: vec3f,rd: vec3f,c: vec3f,r: f32)->f32 {var d: f32=rd.y;if(d>0.0) { return 1e6; }
|
||
var o: vec3f=ro-c;var t: f32=-o.y/d;var q: vec3f=o+rd*t;return select(1e6,t,(dot(q,q)<r*r));}
|
||
fn sphereIntersect(ro: vec3f,rd: vec3f,ra: f32)->f32 {var b: f32=dot(ro,rd);var c: f32=dot(ro,ro)-ra*ra;var h: f32=b*b-c;if(h<0.0) { return -1.0; }
|
||
h=sqrt(h);return-b+h;}
|
||
fn project(viewDirectionW: vec3f,eyePosition: vec3f)->vec3f {var radius: f32=uniforms.projectedGroundInfos.x;var height: f32=uniforms.projectedGroundInfos.y;var camDir: vec3f=-viewDirectionW;var skySphereDistance: f32=sphereIntersect(eyePosition,camDir,radius);var skySpherePositionW: vec3f=eyePosition+camDir*skySphereDistance;var p: vec3f=normalize(skySpherePositionW);var upEyePosition=vec3f(eyePosition.x,eyePosition.y-height,eyePosition.z);var sIntersection: f32=sphereIntersect(upEyePosition,p,radius);var h: vec3f= vec3f(0.0,-height,0.0);var dIntersection: f32=diskIntersectWithBackFaceCulling(upEyePosition,p,h,radius);p=(upEyePosition+min(sIntersection,dIntersection)*p);return p;}
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW);
|
||
#ifdef NORMAL
|
||
var normalW: vec3f=normalize(fragmentInputs.vNormalW);
|
||
#else
|
||
var normalW: vec3f= vec3f(0.0,1.0,0.0);
|
||
#endif
|
||
var shadow: f32=1.;var globalShadow: f32=0.;var shadowLightCount: f32=0.;var aggShadow: f32=0.;var numLights: f32=0.;
|
||
#include<lightFragment>[0..maxSimultaneousLights]
|
||
#ifdef SHADOWINUSE
|
||
globalShadow/=shadowLightCount;
|
||
#else
|
||
globalShadow=1.0;
|
||
#endif
|
||
#ifndef BACKMAT_SHADOWONLY
|
||
var reflectionColor: vec4f= vec4f(1.,1.,1.,1.);
|
||
#ifdef REFLECTION
|
||
#ifdef PROJECTED_GROUND
|
||
var reflectionVector: vec3f=project(viewDirectionW,scene.vEyePosition.xyz);reflectionVector= (uniforms.reflectionMatrix*vec4f(reflectionVector,1.)).xyz;
|
||
#else
|
||
var reflectionVector: vec3f=computeReflectionCoords( vec4f(fragmentInputs.vPositionW,1.0),normalW);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
reflectionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
var reflectionCoords: vec3f=reflectionVector;
|
||
#else
|
||
var reflectionCoords: vec2f=reflectionVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
reflectionCoords/=reflectionVector.z;
|
||
#endif
|
||
reflectionCoords.y=1.0-reflectionCoords.y;
|
||
#endif
|
||
#ifdef REFLECTIONBLUR
|
||
var reflectionLOD: f32=uniforms.vReflectionInfos.y;
|
||
#ifdef TEXTURELODSUPPORT
|
||
reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;reflectionColor=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
|
||
#else
|
||
var lodReflectionNormalized: f32=saturate(reflectionLOD);var lodReflectionNormalizedDoubled: f32=lodReflectionNormalized*2.0;var reflectionSpecularMid: vec4f=textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords);if(lodReflectionNormalizedDoubled<1.0){reflectionColor=mix(
|
||
textureSample(reflectionrHighSampler,reflectionrHighSamplerSampler,reflectionCoords),
|
||
reflectionSpecularMid,
|
||
lodReflectionNormalizedDoubled
|
||
);} else {reflectionColor=mix(
|
||
reflectionSpecularMid,
|
||
textureSample(reflectionLowSampler,reflectionLowSamplerSampler,reflectionCoords),
|
||
lodReflectionNormalizedDoubled-1.0
|
||
);}
|
||
#endif
|
||
#else
|
||
var reflectionSample: vec4f=textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords);reflectionColor=reflectionSample;
|
||
#endif
|
||
#ifdef RGBDREFLECTION
|
||
reflectionColor=vec4f(fromRGBD(reflectionColor).rgb,reflectionColor.a);
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
reflectionColor=vec4f(toLinearSpaceVec3(reflectionColor.rgb),reflectionColor.a);
|
||
#endif
|
||
#ifdef REFLECTIONBGR
|
||
reflectionColor=vec4f(reflectionColor.bgr,reflectionColor.a);
|
||
#endif
|
||
reflectionColor=vec4f(reflectionColor.rgb*uniforms.vReflectionInfos.x,reflectionColor.a);
|
||
#endif
|
||
var diffuseColor: vec3f= vec3f(1.,1.,1.);var finalAlpha: f32=uniforms.alpha;
|
||
#ifdef DIFFUSE
|
||
var diffuseMap: vec4f=textureSample(diffuseSampler,diffuseSamplerSampler,input.vDiffuseUV);
|
||
#ifdef GAMMADIFFUSE
|
||
diffuseMap=vec4f(toLinearSpaceVec3(diffuseMap.rgb),diffuseMap.a);
|
||
#endif
|
||
diffuseMap=vec4f(diffuseMap.rgb *uniforms.vDiffuseInfos.y,diffuseMap.a);
|
||
#ifdef DIFFUSEHASALPHA
|
||
finalAlpha*=diffuseMap.a;
|
||
#endif
|
||
diffuseColor=diffuseMap.rgb;
|
||
#endif
|
||
#ifdef REFLECTIONFRESNEL
|
||
var colorBase: vec3f=diffuseColor;
|
||
#else
|
||
var colorBase: vec3f=reflectionColor.rgb*diffuseColor;
|
||
#endif
|
||
colorBase=max(colorBase,vec3f(0.0));
|
||
#ifdef USERGBCOLOR
|
||
var finalColor: vec3f=colorBase;
|
||
#else
|
||
#ifdef USEHIGHLIGHTANDSHADOWCOLORS
|
||
var mainColor: vec3f=mix(uniforms.vPrimaryColorShadow.rgb,uniforms.vPrimaryColor.rgb,colorBase);
|
||
#else
|
||
var mainColor: vec3f=uniforms.vPrimaryColor.rgb;
|
||
#endif
|
||
var finalColor: vec3f=colorBase*mainColor;
|
||
#endif
|
||
#ifdef REFLECTIONFRESNEL
|
||
var reflectionAmount: vec3f=uniforms.vReflectionControl.xxx;var reflectionReflectance0: vec3f=uniforms.vReflectionControl.yyy;var reflectionReflectance90: vec3f=uniforms.vReflectionControl.zzz;var VdotN: f32=dot(normalize(scene.vEyePosition.xyz),normalW);var planarReflectionFresnel: vec3f=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);reflectionAmount*=planarReflectionFresnel;
|
||
#ifdef REFLECTIONFALLOFF
|
||
var reflectionDistanceFalloff: f32=1.0-saturate(length(vPositionW.xyz-uniforms.vBackgroundCenter)*uniforms.vReflectionControl.w);reflectionDistanceFalloff*=reflectionDistanceFalloff;reflectionAmount*=reflectionDistanceFalloff;
|
||
#endif
|
||
finalColor=mix(finalColor,reflectionColor.rgb,saturateVec3(reflectionAmount));
|
||
#endif
|
||
#ifdef OPACITYFRESNEL
|
||
var viewAngleToFloor: f32=dot(normalW,normalize(scene.vEyePosition.xyz-uniforms.vBackgroundCenter));const startAngle: f32=0.1;var fadeFactor: f32=saturate(viewAngleToFloor/startAngle);finalAlpha*=fadeFactor*fadeFactor;
|
||
#endif
|
||
#ifdef SHADOWINUSE
|
||
finalColor=mix(finalColor*uniforms.shadowLevel,finalColor,globalShadow);
|
||
#endif
|
||
var color: vec4f= vec4f(finalColor,finalAlpha);
|
||
#else
|
||
var color: vec4f= vec4f(uniforms.vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*uniforms.alpha);
|
||
#endif
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>
|
||
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
#if !defined(SKIPFINALCOLORCLAMP)
|
||
color=vec4f(clamp(color.rgb,vec3f(0.),vec3f(30.0)),color.a);
|
||
#endif
|
||
#else
|
||
color=applyImageProcessing(color);
|
||
#endif
|
||
#ifdef PREMULTIPLYALPHA
|
||
color=vec4f(color.rgb *color.a,color.a);
|
||
#endif
|
||
#ifdef NOISE
|
||
color=vec4f(color.rgb+dither(fragmentInputs.vPositionW.xy,0.5),color.a);color=max(color,vec4f(0.0));
|
||
#endif
|
||
fragmentOutputs.color=color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},71433:(r,t,e)=>{e.r(t),e.d(t,{backgroundVertexShaderWGSL:()=>a});var n=e(98519),i=(e(66138),e(17393),e(45699),e(27279),e(63866),e(9436),e(79716),e(58902),e(38197),e(21310),e(3641),e(86615),e(63002),e(70898),e(59115),e(55607),"backgroundVertexShader"),o=`#include<backgroundUboDeclaration>
|
||
#include<helperFunctions>
|
||
attribute position: vec3f;
|
||
#ifdef NORMAL
|
||
attribute normal: vec3f;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<instancesDeclaration>
|
||
varying vPositionW: vec3f;
|
||
#ifdef NORMAL
|
||
varying vNormalW: vec3f;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute uv2: vec2f;
|
||
#endif
|
||
#ifdef MAINUV1
|
||
varying vMainUV1: vec2f;
|
||
#endif
|
||
#ifdef MAINUV2
|
||
varying vMainUV2: vec2f;
|
||
#endif
|
||
#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0
|
||
varying vDiffuseUV: vec2f;
|
||
#endif
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<lightVxUboDeclaration>[0..maxSimultaneousLights]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vPositionUVW: vec3f;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vDirectionW: vec3f;
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
vertexOutputs.vPositionUVW=input.position;
|
||
#endif
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {vertexOutputs.position=scene.viewProjection*finalWorld* vec4f(input.position,1.0);} else {vertexOutputs.position=scene.viewProjectionR*finalWorld* vec4f(input.position,1.0);}
|
||
#else
|
||
vertexOutputs.position=scene.viewProjection*finalWorld* vec4f(input.position,1.0);
|
||
#endif
|
||
var worldPos: vec4f=finalWorld* vec4f(input.position,1.0);vertexOutputs.vPositionW= worldPos.xyz;
|
||
#ifdef NORMAL
|
||
var normalWorld: mat3x3f=mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz);
|
||
#ifdef NONUNIFORMSCALING
|
||
normalWorld=transposeMat3(inverseMat3(normalWorld));
|
||
#endif
|
||
vertexOutputs.vNormalW=normalize(normalWorld*input.normal);
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
vertexOutputs.vDirectionW=normalize((finalWorld*vec4f(input.position,0.0)).xyz);
|
||
#ifdef EQUIRECTANGULAR_RELFECTION_FOV
|
||
var screenToWorld: mat3x3f=inverseMat3( mat3x3f(finalWorld*scene.viewProjection));var segment: vec3f=mix(vertexOutputs.vDirectionW,screenToWorld* vec3f(0.0,0.0,1.0),abs(fFovMultiplier-1.0));if (fFovMultiplier<=1.0) {vertexOutputs.vDirectionW=normalize(segment);} else {vertexOutputs.vDirectionW=normalize(vertexOutputs.vDirectionW+(vertexOutputs.vDirectionW-segment));}
|
||
#endif
|
||
#endif
|
||
#ifndef UV1
|
||
var uv: vec2f=vec2f(0.,0.);
|
||
#else
|
||
var uv=input.uv;
|
||
#endif
|
||
#ifndef UV2
|
||
var uv2: vec2f=vec2f(0.,0.);
|
||
#else
|
||
var uv2=input.uv2;
|
||
#endif
|
||
#ifdef MAINUV1
|
||
vertexOutputs.vMainUV1=uv;
|
||
#endif
|
||
#ifdef MAINUV2
|
||
vertexOutputs.vMainUV2=uv2;
|
||
#endif
|
||
#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0
|
||
if (uniforms.vDiffuseInfos.x==0.)
|
||
{vertexOutputs.vDiffuseUV= (uniforms.diffuseMatrix* vec4f(uv,1.0,0.0)).xy;}
|
||
else
|
||
{vertexOutputs.vDiffuseUV= (uniforms.diffuseMatrix* vec4f(uv2,1.0,0.0)).xy;}
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<shadowsVertex>[0..maxSimultaneousLights]
|
||
#ifdef VERTEXCOLOR
|
||
vertexOutputs.vColor=color;
|
||
#endif
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},38884:(r,t,e)=>{e.r(t),e.d(t,{bilateralBlurPixelShaderWGSL:()=>o});var n="bilateralBlurPixelShader",i=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var normalSamplerSampler: sampler;var normalSampler: texture_2d<f32>;var depthSamplerSampler: sampler;var depthSampler: texture_2d<f32>;uniform filterSize: i32;uniform blurDir: vec2f;uniform depthThreshold: f32;uniform normalThreshold: f32;varying vUV: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var color: vec3f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.).rgb;var depth: f32=textureSampleLevel(depthSampler,depthSamplerSampler,input.vUV,0.).x;if (depth>=1e6 || depth<=0.) {fragmentOutputs.color= vec4f(color,1.);return fragmentOutputs;}
|
||
var normal: vec3f=textureSampleLevel(normalSampler,normalSamplerSampler,input.vUV,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
normal=normal*2.0-1.0;
|
||
#endif
|
||
var sigma: f32= f32(uniforms.filterSize);var two_sigma2: f32=2.0*sigma*sigma;var sigmaDepth: f32=uniforms.depthThreshold;var two_sigmaDepth2: f32=2.0*sigmaDepth*sigmaDepth;var sigmaNormal: f32=uniforms.normalThreshold;var two_sigmaNormal2: f32=2.0*sigmaNormal*sigmaNormal;var sum: vec3f= vec3f(0.);var wsum: f32=0.;for (var x: i32=-uniforms.filterSize; x<=uniforms.filterSize; x++) {var coords=vec2f(f32(x));var sampleColor: vec3f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV+coords*uniforms.blurDir,0.).rgb;var sampleDepth: f32=textureSampleLevel(depthSampler,depthSamplerSampler,input.vUV+coords*uniforms.blurDir,0.).r;var sampleNormal: vec3f=textureSampleLevel(normalSampler,normalSamplerSampler,input.vUV+coords*uniforms.blurDir,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
sampleNormal=sampleNormal*2.0-1.0;
|
||
#endif
|
||
var r: f32=dot(coords,coords);var w: f32=exp(-r/two_sigma2);var depthDelta: f32=abs(sampleDepth-depth);var wd: f32=step(depthDelta,uniforms.depthThreshold);var normalDelta: vec3f=abs(sampleNormal-normal);var wn: f32=step(normalDelta.x+normalDelta.y+normalDelta.z,uniforms.normalThreshold);sum+=sampleColor*w*wd*wn;wsum+=w*wd*wn;}
|
||
fragmentOutputs.color= vec4f(sum/wsum,1.);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},15229:(r,t,e)=>{e.r(t),e.d(t,{bilateralBlurQualityPixelShaderWGSL:()=>o});var n="bilateralBlurQualityPixelShader",i=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var normalSamplerSampler: sampler;var normalSampler: texture_2d<f32>;var depthSamplerSampler: sampler;var depthSampler: texture_2d<f32>;uniform filterSize: i32;uniform blurDir: vec2f;uniform depthThreshold: f32;uniform normalThreshold: f32;varying vUV: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var color: vec3f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.).rgb;var depth: f32=textureSampleLevel(depthSampler,depthSamplerSampler,input.vUV,0.).x;if (depth>=1e6 || depth<=0.) {fragmentOutputs.color= vec4f(color,1.);return fragmentOutputs;}
|
||
var normal: vec3f=textureSampleLevel(normalSampler,normalSamplerSampler,input.vUV,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
normal=normal*2.0-1.0;
|
||
#endif
|
||
var sigma: f32= f32(uniforms.filterSize);var two_sigma2: f32=2.0*sigma*sigma;var sigmaDepth: f32=uniforms.depthThreshold;var two_sigmaDepth2: f32=2.0*sigmaDepth*sigmaDepth;var sigmaNormal: f32=uniforms.normalThreshold;var two_sigmaNormal2: f32=2.0*sigmaNormal*sigmaNormal;var sum: vec3f= vec3f(0.);var wsum: f32=0.;for (var x: i32=-uniforms.filterSize; x<=uniforms.filterSize; x++) {for (var y: i32=-uniforms.filterSize; y<=uniforms.filterSize; y++) {var coords: vec2f= vec2f(x,y)*uniforms.blurDir;var sampleColor: vec3f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV+coords,0.).rgb;var sampleDepth: f32=textureSampleLevel(depthSampler,depthSamplerSampler,input.vUV+coords,0.).r;var sampleNormal: vec3f=textureSampleLevel(normalSampler,normalSamplerSampler,input.vUV+coords,0.).rgb;
|
||
#ifdef DECODE_NORMAL
|
||
sampleNormal=sampleNormal*2.0-1.0;
|
||
#endif
|
||
var r: f32=dot(coords,coords);var w: f32=exp(-r/two_sigma2);var rDepth: f32=sampleDepth-depth;var wd: f32=exp(-rDepth*rDepth/two_sigmaDepth2);var rNormal: f32=abs(sampleNormal.x-normal.x)+abs(sampleNormal.y-normal.y)+abs(sampleNormal.z-normal.z);var wn: f32=exp(-rNormal*rNormal/two_sigmaNormal2);sum+=sampleColor*w*wd*wn;wsum+=w*wd*wn;}}
|
||
fragmentOutputs.color= vec4f(sum/wsum,1.);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},44520:(r,t,e)=>{e.r(t),e.d(t,{blackAndWhitePixelShaderWGSL:()=>o});var n="blackAndWhitePixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform degree: f32;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var color: vec3f=textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb;var luminance: f32=dot(color, vec3f(0.3,0.59,0.11));
|
||
var blackAndWhite: vec3f= vec3f(luminance,luminance,luminance);fragmentOutputs.color= vec4f(color-((color-blackAndWhite)*uniforms.degree),1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},92008:(r,t,e)=>{e.r(t),e.d(t,{bloomMergePixelShaderWGSL:()=>o});var n="bloomMergePixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var bloomBlurSampler: sampler;var bloomBlur: texture_2d<f32>;uniform bloomWeight: f32;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);var blurred: vec3f=textureSample(bloomBlur,bloomBlurSampler,input.vUV).rgb;fragmentOutputs.color=vec4f(fragmentOutputs.color.rgb+(blurred.rgb*uniforms.bloomWeight),fragmentOutputs.color.a);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},30025:(r,t,e)=>{e.r(t),e.d(t,{boundingBoxRendererPixelShaderWGSL:()=>o});var n="boundingBoxRendererPixelShader",i=`uniform color: vec4f;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
fragmentOutputs.color=uniforms.color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},34063:(r,t,e)=>{e.r(t),e.d(t,{boundingBoxRendererVertexShaderWGSL:()=>o});var n="boundingBoxRendererVertexShader",i=`attribute position: vec3f;uniform world: mat4x4f;uniform viewProjection: mat4x4f;
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
var worldPos: vec4f=uniforms.world* vec4f(input.position,1.0);vertexOutputs.position=uniforms.viewProjection*worldPos;
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},58036:(r,t,e)=>{e.r(t),e.d(t,{chromaticAberrationPixelShaderWGSL:()=>o});var n="chromaticAberrationPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform chromatic_aberration: f32;uniform radialIntensity: f32;uniform direction: vec2f;uniform centerPosition: vec2f;uniform screen_width: f32;uniform screen_height: f32;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var centered_screen_pos: vec2f= vec2f(input.vUV.x-uniforms.centerPosition.x,input.vUV.y-uniforms.centerPosition.y);var directionOfEffect: vec2f=uniforms.direction;if(directionOfEffect.x==0. && directionOfEffect.y==0.){directionOfEffect=normalize(centered_screen_pos);}
|
||
var radius2: f32=centered_screen_pos.x*centered_screen_pos.x
|
||
+ centered_screen_pos.y*centered_screen_pos.y;var radius: f32=sqrt(radius2);var ref_indices: vec3f= vec3f(-0.3,0.0,0.3);var ref_shiftX: f32=uniforms.chromatic_aberration*pow(radius,uniforms.radialIntensity)*directionOfEffect.x/uniforms.screen_width;var ref_shiftY: f32=uniforms.chromatic_aberration*pow(radius,uniforms.radialIntensity)*directionOfEffect.y/uniforms.screen_height;var ref_coords_r: vec2f=vec2f(input.vUV.x+ref_indices.r*ref_shiftX,input.vUV.y+ref_indices.r*ref_shiftY*0.5);var ref_coords_g: vec2f=vec2f(input.vUV.x+ref_indices.g*ref_shiftX,input.vUV.y+ref_indices.g*ref_shiftY*0.5);var ref_coords_b: vec2f=vec2f(input.vUV.x+ref_indices.b*ref_shiftX,input.vUV.y+ref_indices.b*ref_shiftY*0.5);var r=textureSample(textureSampler,textureSamplerSampler,ref_coords_r);var g=textureSample(textureSampler,textureSamplerSampler,ref_coords_g);var b=textureSample(textureSampler,textureSamplerSampler,ref_coords_b);var a=clamp(r.a+g.a+b.a,0.,1.);fragmentOutputs.color=vec4f(r.r,g.g,b.b,a);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},78642:(r,t,e)=>{e.r(t),e.d(t,{circleOfConfusionPixelShaderWGSL:()=>o});var n="circleOfConfusionPixelShader",i=`varying vUV: vec2f;var depthSamplerSampler: sampler;var depthSampler: texture_2d<f32>;uniform cameraMinMaxZ: vec2f;uniform focusDistance: f32;uniform cocPrecalculation: f32;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var depth: f32=textureSample(depthSampler,depthSamplerSampler,input.vUV).r;
|
||
#define CUSTOM_COC_DEPTH
|
||
var pixelDistance: f32=(uniforms.cameraMinMaxZ.x+uniforms.cameraMinMaxZ.y*depth)*1000.0;
|
||
#define CUSTOM_COC_PIXELDISTANCE
|
||
var coc: f32=abs(uniforms.cocPrecalculation*((uniforms.focusDistance-pixelDistance)/pixelDistance));coc=clamp(coc,0.0,1.0);fragmentOutputs.color= vec4f(coc,coc,coc,1.0);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},47590:(r,t,e)=>{e.r(t),e.d(t,{colorPixelShaderWGSL:()=>a});var n=e(98519),i=(e(20502),e(98318),e(30032),e(83512),"colorPixelShader"),o=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
#define VERTEXCOLOR
|
||
varying vColor: vec4f;
|
||
#else
|
||
uniform color: vec4f;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
fragmentOutputs.color=input.vColor;
|
||
#else
|
||
fragmentOutputs.color=uniforms.color;
|
||
#endif
|
||
#include<fogFragment>(color,fragmentOutputs.color)
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},69512:(r,t,e)=>{e.r(t),e.d(t,{colorVertexShaderWGSL:()=>a});var n=e(98519),i=(e(45699),e(27279),e(9436),e(79716),e(63866),e(21310),e(3641),e(86615),e(63002),e(70898),e(50615),"colorVertexShader"),o=`attribute position: vec3f;
|
||
#ifdef VERTEXCOLOR
|
||
attribute color: vec4f;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#ifdef FOG
|
||
uniform view: mat4x4f;
|
||
#endif
|
||
#include<instancesDeclaration>
|
||
uniform viewProjection: mat4x4f;
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vColor: vec4f;
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld* vec4f(input.position,1.0);vertexOutputs.position=uniforms.viewProjection*worldPos;
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<vertexColorMixing>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},31342:(r,t,e)=>{e.r(t),e.d(t,{colorCorrectionPixelShaderWGSL:()=>o});var n="colorCorrectionPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;varying vUV: vec2f;var colorTableSampler: sampler;var colorTable: texture_2d<f32>;const SLICE_COUNT: f32=16.0;
|
||
fn sampleAs3DTexture(uv: vec3f,width: f32)->vec4f {var sliceSize: f32=1.0/width;
|
||
var slicePixelSize: f32=sliceSize/width;
|
||
var sliceInnerSize: f32=slicePixelSize*(width-1.0);
|
||
var zSlice0: f32=min(floor(uv.z*width),width-1.0);var zSlice1: f32=min(zSlice0+1.0,width-1.0);var xOffset: f32=slicePixelSize*0.5+uv.x*sliceInnerSize;var s0: f32=xOffset+(zSlice0*sliceSize);var s1: f32=xOffset+(zSlice1*sliceSize);var slice0Color: vec4f=textureSample(colorTable,colorTableSampler,vec2f(s0,uv.y));var slice1Color: vec4f=textureSample(colorTable,colorTableSampler,vec2f(s1,uv.y));var zOffset: f32=((uv.z*width)%(1.0));return mix(slice0Color,slice1Color,zOffset);}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var screen_color: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);fragmentOutputs.color=sampleAs3DTexture(screen_color.rgb,SLICE_COUNT);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},44993:(r,t,e)=>{e.r(t),e.d(t,{convolutionPixelShaderWGSL:()=>o});var n="convolutionPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform screenSize: vec2f;uniform kernel: array<f32,9>;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var onePixel: vec2f= vec2f(1.0,1.0)/uniforms.screenSize;var colorSum: vec4f =
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(-1,-1))*uniforms.kernel[0] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(0,-1))*uniforms.kernel[1] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(1,-1))*uniforms.kernel[2] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(-1,0))*uniforms.kernel[3] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(0,0))*uniforms.kernel[4] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(1,0))*uniforms.kernel[5] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(-1,1))*uniforms.kernel[6] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(0,1))*uniforms.kernel[7] +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel* vec2f(1,1))*uniforms.kernel[8];var kernelWeight: f32 =
|
||
uniforms.kernel[0] +
|
||
uniforms.kernel[1] +
|
||
uniforms.kernel[2] +
|
||
uniforms.kernel[3] +
|
||
uniforms.kernel[4] +
|
||
uniforms.kernel[5] +
|
||
uniforms.kernel[6] +
|
||
uniforms.kernel[7] +
|
||
uniforms.kernel[8];if (kernelWeight<=0.0) {kernelWeight=1.0;}
|
||
fragmentOutputs.color= vec4f((colorSum/kernelWeight).rgb,1);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},79147:(r,t,e)=>{e.r(t),e.d(t,{copyTexture3DLayerToTexturePixelShaderWGSL:()=>o});var n="copyTexture3DLayerToTexturePixelShader",i=`var textureSampler: texture_3d<f32>;uniform layerNum: i32;varying vUV: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec3f(vec2f(input.vUV.x,input.vUV.y)*vec2f(textureDimensions(textureSampler,0).xy),f32(uniforms.layerNum));let color=textureLoad(textureSampler,vec3i(coord),0).rgb;fragmentOutputs.color= vec4f(color,1);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},70051:(r,t,e)=>{e.r(t),e.d(t,{copyTextureToTexturePixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),"copyTextureToTexturePixelShader"),o=`uniform conversion: f32;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;varying vUV: vec2f;
|
||
#include<helperFunctions>
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var color: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);
|
||
#ifdef DEPTH_TEXTURE
|
||
fragmentOutputs.fragDepth=color.r;
|
||
#else
|
||
if (uniforms.conversion==1.) {color=toLinearSpaceVec4(color);} else if (uniforms.conversion==2.) {color=toGammaSpace(color);}
|
||
fragmentOutputs.color=color;
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},85588:(r,t,e)=>{e.r(t),e.d(t,{defaultPixelShaderWGSL:()=>a});var n=e(98519),i=(e(76941),e(78710),e(76778),e(14188),e(17393),e(10896),e(53378),e(32532),e(338),e(92331),e(61439),e(86320),e(4661),e(96830),e(66633),e(20502),e(38197),e(98318),e(30032),e(20274),e(65969),e(25757),e(84192),e(56897),e(83512),e(73876),"defaultPixelShader"),o=`#include<defaultUboDeclaration>
|
||
#include<prePassDeclaration>[SCENE_MRT_COUNT]
|
||
#include<oitDeclaration>
|
||
#define CUSTOM_FRAGMENT_BEGIN
|
||
varying vPositionW: vec3f;
|
||
#ifdef NORMAL
|
||
varying vNormalW: vec3f;
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vColor: vec4f;
|
||
#endif
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#include<helperFunctions>
|
||
#include<lightUboDeclaration>[0..maxSimultaneousLights]
|
||
#include<lightsFragmentFunctions>
|
||
#include<shadowsFragmentFunctions>
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
||
#ifdef REFRACTION
|
||
#ifdef REFRACTIONMAP_3D
|
||
var refractionCubeSamplerSampler: sampler;var refractionCubeSampler: texture_cube<f32>;
|
||
#else
|
||
var refraction2DSamplerSampler: sampler;var refraction2DSampler: texture_2d<f32>;
|
||
#endif
|
||
#endif
|
||
#if defined(SPECULARTERM)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
|
||
#endif
|
||
#include<fresnelFunction>
|
||
#ifdef REFLECTION
|
||
#ifdef REFLECTIONMAP_3D
|
||
var reflectionCubeSamplerSampler: sampler;var reflectionCubeSampler: texture_cube<f32>;
|
||
#else
|
||
var reflection2DSamplerSampler: sampler;var reflection2DSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vPositionUVW: vec3f;
|
||
#else
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vDirectionW: vec3f;
|
||
#endif
|
||
#endif
|
||
#include<reflectionFunction>
|
||
#endif
|
||
#include<imageProcessingDeclaration>
|
||
#include<imageProcessingFunctions>
|
||
#include<bumpFragmentMainFunctions>
|
||
#include<bumpFragmentFunctions>
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-fragmentInputs.vPositionW);var baseColor: vec4f= vec4f(1.,1.,1.,1.);var diffuseColor: vec3f=uniforms.vDiffuseColor.rgb;var alpha: f32=uniforms.vDiffuseColor.a;
|
||
#ifdef NORMAL
|
||
var normalW: vec3f=normalize(fragmentInputs.vNormalW);
|
||
#else
|
||
var normalW: vec3f=normalize(-cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)));
|
||
#endif
|
||
#include<bumpFragment>
|
||
#ifdef TWOSIDEDLIGHTING
|
||
normalW=select(-normalW,normalW,fragmentInputs.frontFacing);
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
baseColor=textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vDiffuseUV+uvOffset);
|
||
#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
|
||
if (baseColor.a<uniforms.alphaCutOff) {discard;}
|
||
#endif
|
||
#ifdef ALPHAFROMDIFFUSE
|
||
alpha*=baseColor.a;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
|
||
baseColor=vec4f(baseColor.rgb*uniforms.vDiffuseInfos.y,baseColor.a);
|
||
#endif
|
||
#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)
|
||
var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
|
||
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
|
||
#endif
|
||
#include<depthPrePass>
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
baseColor=vec4f(baseColor.rgb*fragmentInputs.vColor.rgb,baseColor.a);
|
||
#endif
|
||
#ifdef DETAIL
|
||
baseColor=vec4f(baseColor.rgb*2.0*mix(0.5,detailColor.r,uniforms.vDetailInfos.y),baseColor.a);
|
||
#endif
|
||
#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)
|
||
var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
|
||
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
|
||
var baseAmbientColor: vec3f= vec3f(1.,1.,1.);
|
||
#ifdef AMBIENT
|
||
baseAmbientColor=textureSample(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb*uniforms.vAmbientInfos.y;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
||
#ifdef SPECULARTERM
|
||
var glossiness: f32=uniforms.vSpecularColor.a;var specularColor: vec3f=uniforms.vSpecularColor.rgb;
|
||
#ifdef SPECULAR
|
||
var specularMapColor: vec4f=textureSample(specularSampler,specularSamplerSampler,fragmentInputs.vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;
|
||
#ifdef GLOSSINESS
|
||
glossiness=glossiness*specularMapColor.a;
|
||
#endif
|
||
#endif
|
||
#else
|
||
var glossiness: f32=0.;
|
||
#endif
|
||
var diffuseBase: vec3f= vec3f(0.,0.,0.);var info: lightingInfo;
|
||
#ifdef SPECULARTERM
|
||
var specularBase: vec3f= vec3f(0.,0.,0.);
|
||
#endif
|
||
var shadow: f32=1.;var aggShadow: f32=0.;var numLights: f32=0.;
|
||
#ifdef LIGHTMAP
|
||
var lightmapColor: vec4f=textureSample(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset);
|
||
#ifdef RGBDLIGHTMAP
|
||
lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a);
|
||
#endif
|
||
lightmapColor=vec4f(lightmapColor.rgb*vLightmapInfos.y,lightmapColor.a);
|
||
#endif
|
||
#include<lightFragment>[0..maxSimultaneousLights]
|
||
aggShadow=aggShadow/numLights;var refractionColor: vec4f= vec4f(0.,0.,0.,1.);
|
||
#ifdef REFRACTION
|
||
var refractionVector: vec3f=normalize(refract(-viewDirectionW,normalW,uniforms.vRefractionInfos.y));
|
||
#ifdef REFRACTIONMAP_3D
|
||
#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
refractionVector=parallaxCorrectNormal(fragmentInputs.vPositionW,refractionVector,uniforms.vRefractionSize,uniforms.vRefractionPosition);
|
||
#endif
|
||
refractionVector.y=refractionVector.y*uniforms.vRefractionInfos.w;var refractionLookup: vec4f=textureSample(refractionCubeSampler,refractionCubeSamplerSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}
|
||
#else
|
||
var vRefractionUVW: vec3f= (uniforms.refractionMatrix*(scene.view* vec4f(fragmentInputs.vPositionW+refractionVector*uniforms.vRefractionInfos.z,1.0))).xyz;var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=textureSample(refraction2DSampler,refraction2DSamplerSampler,refractionCoords);
|
||
#endif
|
||
#ifdef RGBDREFRACTION
|
||
refractionColor=vec4f(fromRGBD(refractionColor),refractionColor.a);
|
||
#endif
|
||
#ifdef IS_REFRACTION_LINEAR
|
||
refractionColor=vec4f(toGammaSpaceVec3(refractionColor.rgb),refractionColor.a);
|
||
#endif
|
||
refractionColor=vec4f(refractionColor.rgb*uniforms.vRefractionInfos.x,refractionColor.a);
|
||
#endif
|
||
var reflectionColor: vec4f= vec4f(0.,0.,0.,1.);
|
||
#ifdef REFLECTION
|
||
var vReflectionUVW: vec3f=computeReflectionCoords( vec4f(fragmentInputs.vPositionW,1.0),normalW);
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
vReflectionUVW=vec3f(vReflectionUVW.x,vReflectionUVW.y,vReflectionUVW.z*-1.0);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
#ifdef ROUGHNESS
|
||
var bias: f32=uniforms.vReflectionInfos.y;
|
||
#ifdef SPECULARTERM
|
||
#ifdef SPECULAR
|
||
#ifdef GLOSSINESS
|
||
bias*=(1.0-specularMapColor.a);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
reflectionColor=textureSampleLevel(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW,bias);
|
||
#else
|
||
reflectionColor=textureSample(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW);
|
||
#endif
|
||
#else
|
||
var coords: vec2f=vReflectionUVW.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
coords/=vReflectionUVW.z;
|
||
#endif
|
||
coords.y=1.0-coords.y;reflectionColor=textureSample(reflection2DSampler,reflection2DSamplerSampler,coords);
|
||
#endif
|
||
#ifdef RGBDREFLECTION
|
||
reflectionColor=vec4f(fromRGBD(reflectionColor),reflectionColor.a);
|
||
#endif
|
||
#ifdef IS_REFLECTION_LINEAR
|
||
reflectionColor=vec4f(toGammaSpaceVec3(reflectionColor.rgb),reflectionColor.a);
|
||
#endif
|
||
reflectionColor=vec4f(reflectionColor.rgb*uniforms.vReflectionInfos.x,reflectionColor.a);
|
||
#ifdef REFLECTIONFRESNEL
|
||
var reflectionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.reflectionRightColor.a,uniforms.reflectionLeftColor.a);
|
||
#ifdef REFLECTIONFRESNELFROMSPECULAR
|
||
#ifdef SPECULARTERM
|
||
reflectionColor=vec4f(reflectionColor.rgb*specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
|
||
#else
|
||
reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
|
||
#endif
|
||
#else
|
||
reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef REFRACTIONFRESNEL
|
||
var refractionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.refractionRightColor.a,uniforms.refractionLeftColor.a);refractionColor=vec4f(refractionColor.rgb*uniforms.refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*uniforms.refractionRightColor.rgb,refractionColor.a);
|
||
#endif
|
||
#ifdef OPACITY
|
||
var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset);
|
||
#ifdef OPACITYRGB
|
||
opacityMap=vec4f(opacityMap.rgb* vec3f(0.3,0.59,0.11),opacityMap.a);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* uniforms.vOpacityInfos.y;
|
||
#else
|
||
alpha*=opacityMap.a*uniforms.vOpacityInfos.y;
|
||
#endif
|
||
#endif
|
||
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
alpha*=fragmentInputs.vColor.a;
|
||
#endif
|
||
#ifdef OPACITYFRESNEL
|
||
var opacityFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.opacityParts.z,uniforms.opacityParts.w);alpha+=uniforms.opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*uniforms.opacityParts.y;
|
||
#endif
|
||
#ifdef ALPHATEST
|
||
#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
|
||
if (alpha<uniforms.alphaCutOff) {discard;}
|
||
#endif
|
||
#ifndef ALPHABLEND
|
||
alpha=1.0;
|
||
#endif
|
||
#endif
|
||
var emissiveColor: vec3f=uniforms.vEmissiveColor;
|
||
#ifdef EMISSIVE
|
||
emissiveColor+=textureSample(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vEmissiveUV+uvOffset).rgb*uniforms.vEmissiveInfos.y;
|
||
#endif
|
||
#ifdef EMISSIVEFRESNEL
|
||
var emissiveFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.emissiveRightColor.a,uniforms.emissiveLeftColor.a);emissiveColor*=uniforms.emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*uniforms.emissiveRightColor.rgb;
|
||
#endif
|
||
#ifdef DIFFUSEFRESNEL
|
||
var diffuseFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.diffuseRightColor.a,uniforms.diffuseLeftColor.a);diffuseBase*=uniforms.diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*uniforms.diffuseRightColor.rgb;
|
||
#endif
|
||
#ifdef EMISSIVEASILLUMINATION
|
||
var finalDiffuse: vec3f=clamp(diffuseBase*diffuseColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
|
||
#else
|
||
#ifdef LINKEMISSIVEWITHDIFFUSE
|
||
var finalDiffuse: vec3f=clamp((diffuseBase+emissiveColor)*diffuseColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
|
||
#else
|
||
var finalDiffuse: vec3f=clamp(diffuseBase*diffuseColor+emissiveColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
|
||
#endif
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
var finalSpecular: vec3f=specularBase*specularColor;
|
||
#ifdef SPECULAROVERALPHA
|
||
alpha=clamp(alpha+dot(finalSpecular, vec3f(0.3,0.59,0.11)),0.0,1.0);
|
||
#endif
|
||
#else
|
||
var finalSpecular: vec3f= vec3f(0.0);
|
||
#endif
|
||
#ifdef REFLECTIONOVERALPHA
|
||
alpha=clamp(alpha+dot(reflectionColor.rgb, vec3f(0.3,0.59,0.11)),0.0,1.0);
|
||
#endif
|
||
#ifdef EMISSIVEASILLUMINATION
|
||
var color: vec4f= vec4f(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
|
||
#else
|
||
var color: vec4f= vec4f(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
|
||
#endif
|
||
#ifdef LIGHTMAP
|
||
#ifndef LIGHTMAPEXCLUDED
|
||
#ifdef USELIGHTMAPASSHADOWMAP
|
||
color=vec4f(color.rgb*lightmapColor.rgb,color.a);
|
||
#else
|
||
color=vec4f(color.rgb+lightmapColor.rgb,color.a);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_BEFORE_FOG
|
||
color=vec4f(max(color.rgb,vec3f(0.)),color.a);
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>
|
||
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
color=vec4f(toLinearSpaceVec3(color.rgb),color.a);
|
||
#else
|
||
#ifdef IMAGEPROCESSING
|
||
color=vec4f(toLinearSpaceVec3(color.rgb),color.a);color=applyImageProcessing(color);
|
||
#endif
|
||
#endif
|
||
color=vec4f(color.rgb,color.a*mesh.visibility);
|
||
#ifdef PREMULTIPLYALPHA
|
||
color=vec4f(color.rgb*color.a, color.a);
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
|
||
#ifdef PREPASS
|
||
var writeGeometryInfo: f32=select(0.0,1.0,color.a>0.4);var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;fragData[0]=color;
|
||
#ifdef PREPASS_POSITION
|
||
fragData[PREPASS_POSITION_INDEX]= vec4f(fragmentInputs.vPositionW,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
fragData[PREPASS_LOCAL_POSITION_INDEX] =
|
||
vec4f(fragmentInputs.vPosition,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_VELOCITY
|
||
var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo);
|
||
#elif defined(PREPASS_VELOCITY_LINEAR)
|
||
var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy /
|
||
fragmentInputs.vPreviousPosition.w) -
|
||
(fragmentInputs.vCurrentPosition.xy /
|
||
fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX] =
|
||
vec4f(velocity,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_IRRADIANCE
|
||
fragData[PREPASS_IRRADIANCE_INDEX] =
|
||
vec4f(0.0,0.0,0.0,
|
||
writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,
|
||
writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_SCREENSPACE_DEPTH
|
||
fragData[PREPASS_SCREENSPACE_DEPTH_INDEX] =
|
||
vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_NORMAL
|
||
#ifdef PREPASS_NORMAL_WORLDSPACE
|
||
fragData[PREPASS_NORMAL_INDEX] =
|
||
vec4f(normalW,writeGeometryInfo);
|
||
#else
|
||
fragData[PREPASS_NORMAL_INDEX] =
|
||
vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),
|
||
writeGeometryInfo);
|
||
#endif
|
||
#endif
|
||
#ifdef PREPASS_WORLD_NORMAL
|
||
fragData[PREPASS_WORLD_NORMAL_INDEX] =
|
||
vec4f(normalW*0.5+0.5,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_ALBEDO_SQRT
|
||
fragData[PREPASS_ALBEDO_SQRT_INDEX] =
|
||
vec4f(0.0,0.0,0.0,
|
||
writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_REFLECTIVITY
|
||
#if defined(SPECULARTERM)
|
||
#if defined(SPECULAR)
|
||
fragData[PREPASS_REFLECTIVITY_INDEX] =
|
||
vec4f(toLinearSpaceVec4(specularMapColor)) *
|
||
writeGeometryInfo;
|
||
#else
|
||
fragData[PREPASS_REFLECTIVITY_INDEX] =
|
||
vec4f(toLinearSpaceVec3(specularColor),1.0)*writeGeometryInfo;
|
||
#endif
|
||
#else
|
||
fragData[PREPASS_REFLECTIVITY_INDEX] =
|
||
vec4f(0.0,0.0,0.0,1.0)*writeGeometryInfo;
|
||
#endif
|
||
#endif
|
||
#if SCENE_MRT_COUNT>0
|
||
fragmentOutputs.fragData0=fragData[0];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>1
|
||
fragmentOutputs.fragData1=fragData[1];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>2
|
||
fragmentOutputs.fragData2=fragData[2];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>3
|
||
fragmentOutputs.fragData3=fragData[3];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>4
|
||
fragmentOutputs.fragData4=fragData[4];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>5
|
||
fragmentOutputs.fragData5=fragData[5];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>6
|
||
fragmentOutputs.fragData6=fragData[6];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>7
|
||
fragmentOutputs.fragData7=fragData[7];
|
||
#endif
|
||
#endif
|
||
#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY)
|
||
fragmentOutputs.color=color;
|
||
#endif
|
||
#include<oitFragment>
|
||
#if ORDER_INDEPENDENT_TRANSPARENCY
|
||
if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+color.rgb*color.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-color.a));} else {fragmentOutputs.backColor+=color;}
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},66904:(r,t,e)=>{e.r(t),e.d(t,{defaultVertexShaderWGSL:()=>s});var n=e(98519),i=(e(76941),e(56213),e(17393),e(45699),e(27279),e(63866),e(84020),e(14188),e(12520),e(33330),e(9436),e(79716),"lightVxFragmentDeclaration");n.l.IncludesShadersStoreWGSL[i]=`#ifdef LIGHT{X}
|
||
uniform vLightData{X}: vec4f;uniform vLightDiffuse{X}: vec4f;
|
||
#ifdef SPECULARTERM
|
||
uniform vLightSpecular{X}: vec4f;
|
||
#else
|
||
var vLightSpecular{X}: vec4f= vec4f(0.);
|
||
#endif
|
||
#ifdef SHADOW{X}
|
||
#ifdef SHADOWCSM{X}
|
||
uniform lightMatrix{X}: mat4x4f[SHADOWCSMNUM_CASCADES{X}];varying var vPositionFromLight{X}: vec4f[SHADOWCSMNUM_CASCADES{X}];varying var vDepthMetric{X}: f32[SHADOWCSMNUM_CASCADES{X}];varying var vPositionFromCamera{X}: vec4f;
|
||
#elif defined(SHADOWCUBE{X})
|
||
#else
|
||
varying var vPositionFromLight{X}: vec4f;varying var vDepthMetric{X}: f32;uniform lightMatrix{X}: mat4x4f;
|
||
#endif
|
||
uniform shadowsInfo{X}: vec4f;uniform depthValues{X}: vec2f;
|
||
#endif
|
||
#ifdef SPOTLIGHT{X}
|
||
uniform vLightDirection{X}: vec4f;uniform vLightFalloff{X}: vec4f;
|
||
#elif defined(POINTLIGHT{X})
|
||
uniform vLightFalloff{X}: vec4f;
|
||
#elif defined(HEMILIGHT{X})
|
||
uniform vLightGround{X}: vec3f;
|
||
#endif
|
||
#endif
|
||
`,e(58902),e(73683),e(68478),e(38197),e(98819),e(77320),e(21310),e(3641),e(86615),e(21954),e(28981),e(88380),e(19748),e(63002),e(70898),e(59115),e(50615),e(55607);var o="defaultVertexShader",a=`#include<defaultUboDeclaration>
|
||
#define CUSTOM_VERTEX_BEGIN
|
||
attribute position: vec3f;
|
||
#ifdef NORMAL
|
||
attribute normal: vec3f;
|
||
#endif
|
||
#ifdef TANGENT
|
||
attribute tangent: vec4f;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#include<uvAttributeDeclaration>[2..7]
|
||
#ifdef VERTEXCOLOR
|
||
attribute color: vec4f;
|
||
#endif
|
||
#include<helperFunctions>
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<instancesDeclaration>
|
||
#include<prePassVertexDeclaration>
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
|
||
#if defined(SPECULARTERM)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)
|
||
#endif
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
|
||
varying vPositionW: vec3f;
|
||
#ifdef NORMAL
|
||
varying vNormalW: vec3f;
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vColor: vec4f;
|
||
#endif
|
||
#include<bumpVertexDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<__decl__lightVxFragment>[0..maxSimultaneousLights]
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vPositionUVW: vec3f;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vDirectionW: vec3f;
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
var positionUpdated: vec3f=vertexInputs.position;
|
||
#ifdef NORMAL
|
||
var normalUpdated: vec3f=vertexInputs.normal;
|
||
#endif
|
||
#ifdef TANGENT
|
||
var tangentUpdated: vec4f=vertexInputs.tangent;
|
||
#endif
|
||
#ifdef UV1
|
||
var uvUpdated: vec2f=vertexInputs.uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
vertexOutputs.vPositionUVW=positionUpdated;
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_POSITION
|
||
#define CUSTOM_VERTEX_UPDATE_NORMAL
|
||
#include<instancesVertex>
|
||
#if defined(PREPASS) && (defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED) || defined(PREPASS_VELOCITY_LINEAR))
|
||
vertexOutputs.vCurrentPosition =
|
||
scene.viewProjection*finalWorld*vec4f(positionUpdated,1.0);vertexOutputs.vPreviousPosition=uniforms.previousViewProjection *
|
||
finalPreviousWorld *
|
||
vec4f(positionUpdated,1.0);
|
||
#endif
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld*vec4f(positionUpdated,1.0);
|
||
#ifdef NORMAL
|
||
var normalWorld: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz);
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
vertexOutputs.vNormalW=normalUpdated/ vec3f(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vertexOutputs.vNormalW=normalize(normalWorld*vertexOutputs.vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normalWorld=transposeMat3(inverseMat3(normalWorld));
|
||
#endif
|
||
vertexOutputs.vNormalW=normalize(normalWorld*normalUpdated);
|
||
#endif
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_WORLDPOS
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {vertexOutputs.position=scene.viewProjection*worldPos;} else {vertexOutputs.position=scene.viewProjectionR*worldPos;}
|
||
#else
|
||
vertexOutputs.position=scene.viewProjection*worldPos;
|
||
#endif
|
||
vertexOutputs.vPositionW= worldPos.xyz;
|
||
#include<prePassVertex>
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
vertexOutputs.vDirectionW=normalize((finalWorld* vec4f(positionUpdated,0.0)).xyz);
|
||
#endif
|
||
#ifndef UV1
|
||
var uvUpdated: vec2f=vec2f(0.,0.);
|
||
#endif
|
||
#ifdef MAINUV1
|
||
vertexOutputs.vMainUV1=uvUpdated;
|
||
#endif
|
||
#include<uvVariableDeclaration>[2..7]
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
|
||
#if defined(SPECULARTERM)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)
|
||
#endif
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
|
||
#include<bumpVertex>
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<shadowsVertex>[0..maxSimultaneousLights]
|
||
#include<vertexColorMixing>
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`;n.l.ShadersStoreWGSL[o]=a;var s={name:o,shader:a}},62004:(r,t,e)=>{e.r(t),e.d(t,{depthPixelShaderWGSL:()=>a});var n=e(98519),i=(e(20502),e(68298),e(30032),"depthPixelShader"),o=`#ifdef ALPHATEST
|
||
varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
varying vDepthMetric: f32;
|
||
#ifdef PACKED
|
||
#include<packingFunctions>
|
||
#endif
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
varying vViewPos: vec4f;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEST
|
||
if (textureSample(diffuseSampler,diffuseSamplerSampler,input.vUV).a<0.4) {discard;}
|
||
#endif
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
#ifdef PACKED
|
||
fragmentOutputs.color=pack(input.vViewPos.z);
|
||
#else
|
||
fragmentOutputs.color= vec4f(input.vViewPos.z,0.0,0.0,1.0);
|
||
#endif
|
||
#else
|
||
#ifdef NONLINEARDEPTH
|
||
#ifdef PACKED
|
||
fragmentOutputs.color=pack(input.position.z);
|
||
#else
|
||
fragmentOutputs.color= vec4f(input.position.z,0.0,0.0,0.0);
|
||
#endif
|
||
#else
|
||
#ifdef PACKED
|
||
fragmentOutputs.color=pack(input.vDepthMetric);
|
||
#else
|
||
fragmentOutputs.color= vec4f(input.vDepthMetric,0.0,0.0,1.0);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},31086:(r,t,e)=>{e.r(t),e.d(t,{depthVertexShaderWGSL:()=>a});var n=e(98519),i=(e(45699),e(27279),e(73683),e(68478),e(9436),e(63866),e(98819),e(77320),e(21310),e(3641),e(86615),e(63002),"depthVertexShader"),o=`attribute position: vec3f;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<instancesDeclaration>
|
||
uniform viewProjection: mat4x4f;uniform depthValues: vec2f;
|
||
#if defined(ALPHATEST) || defined(NEED_UV)
|
||
varying vUV: vec2f;uniform diffuseMatrix: mat4x4f;
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute uv2: vec2f;
|
||
#endif
|
||
#endif
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
uniform view: mat4x4f;varying vViewPos: vec4f;
|
||
#endif
|
||
varying vDepthMetric: f32;
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=input.position;
|
||
#ifdef UV1
|
||
var uvUpdated: vec2f=input.uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);
|
||
#include<clipPlaneVertex>
|
||
vertexOutputs.position=uniforms.viewProjection*worldPos;
|
||
#ifdef STORE_CAMERASPACE_Z
|
||
vertexOutputs.vViewPos=uniforms.view*worldPos;
|
||
#else
|
||
#ifdef USE_REVERSE_DEPTHBUFFER
|
||
vertexOutputs.vDepthMetric=((-vertexOutputs.position.z+uniforms.depthValues.x)/(uniforms.depthValues.y));
|
||
#else
|
||
vertexOutputs.vDepthMetric=((vertexOutputs.position.z+uniforms.depthValues.x)/(uniforms.depthValues.y));
|
||
#endif
|
||
#endif
|
||
#if defined(ALPHATEST) || defined(BASIC_RENDER)
|
||
#ifdef UV1
|
||
vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef UV2
|
||
vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},71666:(r,t,e)=>{e.r(t),e.d(t,{depthBoxBlurPixelShaderWGSL:()=>o});var n="depthBoxBlurPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform screenSize: vec2f;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var colorDepth: vec4f=vec4f(0.0);for (var x: i32=-OFFSET; x<=OFFSET; x++) {for (var y: i32=-OFFSET; y<=OFFSET; y++) {colorDepth+=textureSample(textureSampler,textureSamplerSampler,input.vUV+ vec2f(f32(x),f32(y))/uniforms.screenSize);}}
|
||
fragmentOutputs.color=(colorDepth/ f32((OFFSET*2+1)*(OFFSET*2+1)));}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},80239:(r,t,e)=>{e.r(t),e.d(t,{depthOfFieldMergePixelShaderWGSL:()=>o});var n="depthOfFieldMergePixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var circleOfConfusionSamplerSampler: sampler;var circleOfConfusionSampler: texture_2d<f32>;var blurStep0Sampler: sampler;var blurStep0: texture_2d<f32>;
|
||
#if BLUR_LEVEL>0
|
||
var blurStep1Sampler: sampler;var blurStep1: texture_2d<f32>;
|
||
#endif
|
||
#if BLUR_LEVEL>1
|
||
var blurStep2Sampler: sampler;var blurStep2: texture_2d<f32>;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var coc: f32=textureSampleLevel(circleOfConfusionSampler,circleOfConfusionSamplerSampler,input.vUV,0.0).r;
|
||
#if BLUR_LEVEL==0
|
||
var original: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0);var blurred0: vec4f=textureSampleLevel(blurStep0,blurStep0Sampler,input.vUV,0.0);fragmentOutputs.color=mix(original,blurred0,coc);
|
||
#endif
|
||
#if BLUR_LEVEL==1
|
||
if(coc<0.5){var original: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0);var blurred1: vec4f=textureSampleLevel(blurStep1,blurStep1Sampler,input.vUV,0.0);fragmentOutputs.color=mix(original,blurred1,coc/0.5);}else{var blurred0: vec4f=textureSampleLevel(blurStep0,blurStep0Sampler,input.vUV,0.0);var blurred1: vec4f=textureSampleLevel(blurStep1,blurStep1Sampler,input.vUV,0.0);fragmentOutputs.color=mix(blurred1,blurred0,(coc-0.5)/0.5);}
|
||
#endif
|
||
#if BLUR_LEVEL==2
|
||
if(coc<0.33){var original: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0);var blurred2: vec4f=textureSampleLevel(blurStep2,blurStep2Sampler,input.vUV,0.0);fragmentOutputs.color=mix(original,blurred2,coc/0.33);}else if(coc<0.66){var blurred1: vec4f=textureSampleLevel(blurStep1,blurStep1Sampler,input.vUV,0.0);var blurred2: vec4f=textureSampleLevel(blurStep2,blurStep2Sampler,input.vUV,0.0);fragmentOutputs.color=mix(blurred2,blurred1,(coc-0.33)/0.33);}else{var blurred0: vec4f=textureSampleLevel(blurStep0,blurStep0Sampler,input.vUV,0.0);var blurred1: vec4f=textureSampleLevel(blurStep1,blurStep1Sampler,input.vUV,0.0);fragmentOutputs.color=mix(blurred1,blurred0,(coc-0.66)/0.34);}
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},25910:(r,t,e)=>{e.r(t),e.d(t,{displayPassPixelShaderWGSL:()=>o});var n="displayPassPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var passSamplerSampler: sampler;var passSampler: texture_2d<f32>;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureSample(passSampler,passSamplerSampler,input.vUV);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},71263:(r,t,e)=>{e.r(t),e.d(t,{extractHighlightsPixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),"extractHighlightsPixelShader"),o=`#include<helperFunctions>
|
||
varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform threshold: f32;uniform exposure: f32;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);var luma: f32=dot(LuminanceEncodeApprox,fragmentOutputs.color.rgb*uniforms.exposure);fragmentOutputs.color=vec4f(step(uniforms.threshold,luma)*fragmentOutputs.color.rgb,fragmentOutputs.color.a);}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},27401:(r,t,e)=>{e.r(t),e.d(t,{filterPixelShaderWGSL:()=>o});var n="filterPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform kernelMatrix: mat4x4f;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var baseColor: vec3f=textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb;var updatedColor: vec3f=(uniforms.kernelMatrix* vec4f(baseColor,1.0)).rgb;fragmentOutputs.color= vec4f(updatedColor,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},7060:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingBilateralBlurPixelShaderWGSL:()=>o});var n="fluidRenderingBilateralBlurPixelShader",i=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform maxFilterSize: i32;uniform blurDir: vec2f;uniform projectedParticleConstant: f32;uniform depthThreshold: f32;varying vUV: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var depth: f32=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.).x;if (depth>=1e6 || depth<=0.) {fragmentOutputs.color=vec4f(vec3f(depth),1.);return fragmentOutputs;}
|
||
var filterSize: i32=min(uniforms.maxFilterSize,i32(ceil(uniforms.projectedParticleConstant/depth)));var sigma: f32=f32(filterSize)/3.0;var two_sigma2: f32=2.0*sigma*sigma;var sigmaDepth: f32=uniforms.depthThreshold/3.0;var two_sigmaDepth2: f32=2.0*sigmaDepth*sigmaDepth;var sum: f32=0.;var wsum: f32=0.;var sumVel: f32=0.;for (var x: i32=-filterSize; x<=filterSize; x++) {var coords: vec2f=vec2f(f32(x));var sampleDepthVel: vec2f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV+coords*uniforms.blurDir,0.).rg;var r: f32=dot(coords,coords);var w: f32=exp(-r/two_sigma2);var rDepth: f32=sampleDepthVel.r-depth;var wd: f32=exp(-rDepth*rDepth/two_sigmaDepth2);sum+=sampleDepthVel.r*w*wd;sumVel+=sampleDepthVel.g*w*wd;wsum+=w*wd;}
|
||
fragmentOutputs.color=vec4f(sum/wsum,sumVel/wsum,0.,1.);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},76138:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleDepthPixelShaderWGSL:()=>o});var n="fluidRenderingParticleDepthPixelShader",i=`uniform projection: mat4x4f;varying uv: vec2f;varying viewPos: vec3f;varying sphereRadius: f32;
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
varying velocityNorm: f32;
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var normalxy: vec2f=input.uv*2.0-1.0;var r2: f32=dot(normalxy,normalxy);if (r2>1.0) {discard;}
|
||
var normal: vec3f=vec3f(normalxy,sqrt(1.0-r2));
|
||
#ifndef FLUIDRENDERING_RHS
|
||
normal.z=-normal.z;
|
||
#endif
|
||
var realViewPos: vec4f=vec4f(input.viewPos+normal*input.sphereRadius,1.0);var clipSpacePos: vec4f=uniforms.projection*realViewPos;fragmentOutputs.fragDepth=clipSpacePos.z/clipSpacePos.w;
|
||
#ifdef FLUIDRENDERING_RHS
|
||
realViewPos.z=-realViewPos.z;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
fragmentOutputs.color=vec4f(realViewPos.z,input.velocityNorm,0.,1.);
|
||
#else
|
||
fragmentOutputs.color=vec4f(realViewPos.z,0.,0.,1.);
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},64780:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleDepthVertexShaderWGSL:()=>o});var n="fluidRenderingParticleDepthVertexShader",i=`attribute position: vec3f;attribute offset: vec2f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform size: vec2f;varying uv: vec2f;varying viewPos: vec3f;varying sphereRadius: f32;
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
attribute velocity: vec3f;varying velocityNorm: f32;
|
||
#endif
|
||
@vertex
|
||
fn main(input: VertexInputs)->FragmentInputs {var cornerPos: vec3f=vec3f(
|
||
vec2f(input.offset.x-0.5,input.offset.y-0.5)*uniforms.size,
|
||
0.0
|
||
);vertexOutputs.viewPos=(uniforms.view*vec4f(input.position,1.0)).xyz;vertexOutputs.position=uniforms.projection*vec4f(vertexOutputs.viewPos+cornerPos,1.0);vertexOutputs.uv=input.offset;vertexOutputs.sphereRadius=uniforms.size.x/2.0;
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
vertexOutputs.velocityNorm=length(velocity);
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},70183:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleDiffusePixelShaderWGSL:()=>o});var n="fluidRenderingParticleDiffusePixelShader",i=`uniform particleAlpha: f32;varying uv: vec2f;varying diffuseColor: vec3f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var normalxy: vec2f=input.uv*2.0-1.0;var r2: f32=dot(normalxy,normalxy);if (r2>1.0) {discard;}
|
||
fragmentOutputs.color=vec4f(input.diffuseColor,1.0);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},2835:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleThicknessPixelShaderWGSL:()=>o});var n="fluidRenderingParticleThicknessPixelShader",i=`uniform particleAlpha: f32;varying uv: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var normalxy: vec2f=input.uv*2.0-1.0;var r2: f32=dot(normalxy,normalxy);if (r2>1.0) {discard;}
|
||
var thickness: f32=sqrt(1.0-r2);fragmentOutputs.color=vec4f(vec3f(uniforms.particleAlpha*thickness),1.0);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},37113:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingParticleThicknessVertexShaderWGSL:()=>o});var n="fluidRenderingParticleThicknessVertexShader",i=`attribute position: vec3f;attribute offset: vec2f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform size: vec2f;varying uv: vec2f;@vertex
|
||
fn main(input: VertexInputs)->FragmentInputs {var cornerPos: vec3f=vec3f(
|
||
vec2f(input.offset.x-0.5,input.offset.y-0.5)*uniforms.size,
|
||
0.0
|
||
);var viewPos: vec3f=(uniforms.view*vec4f(input.position,1.0)).xyz+cornerPos;vertexOutputs.position=uniforms.projection*vec4f(viewPos,1.0);vertexOutputs.uv=input.offset;}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},94727:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingRenderPixelShaderWGSL:()=>o});var n="fluidRenderingRenderPixelShader",i=`#define DISABLE_UNIFORMITY_ANALYSIS
|
||
#define IOR 1.333
|
||
#define ETA 1.0/IOR
|
||
#define F0 0.02
|
||
var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var depthSamplerSampler: sampler;var depthSampler: texture_2d<f32>;
|
||
#ifdef FLUIDRENDERING_DIFFUSETEXTURE
|
||
var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#else
|
||
uniform diffuseColor: vec3f;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_FIXED_THICKNESS
|
||
uniform thickness: f32;var bgDepthSamplerSampler: sampler;var bgDepthSampler: texture_2d<f32>;
|
||
#else
|
||
uniform minimumThickness: f32;var thicknessSamplerSampler: sampler;var thicknessSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_ENVIRONMENT
|
||
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
|
||
#endif
|
||
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)
|
||
var debugSamplerSampler: sampler;var debugSampler: texture_2d<f32>;
|
||
#endif
|
||
uniform viewMatrix: mat4x4f;uniform projectionMatrix: mat4x4f;uniform invProjectionMatrix: mat4x4f;uniform texelSize: vec2f;uniform dirLight: vec3f;uniform cameraFar: f32;uniform density: f32;uniform refractionStrength: f32;uniform fresnelClamp: f32;uniform specularPower: f32;varying vUV: vec2f;fn computeViewPosFromUVDepth(texCoord: vec2f,depth: f32)->vec3f {var ndc: vec4f=vec4f(texCoord*2.0-1.0,0.0,1.0);
|
||
#ifdef FLUIDRENDERING_RHS
|
||
ndc.z=-uniforms.projectionMatrix[2].z+uniforms.projectionMatrix[3].z/depth;
|
||
#else
|
||
ndc.z=uniforms.projectionMatrix[2].z+uniforms.projectionMatrix[3].z/depth;
|
||
#endif
|
||
ndc.w=1.0;var eyePos: vec4f=uniforms.invProjectionMatrix*ndc;return eyePos.xyz/eyePos.w;}
|
||
fn getViewPosFromTexCoord(texCoord: vec2f)->vec3f {var depth: f32=textureSampleLevel(depthSampler,depthSamplerSampler,texCoord,0.).x;return computeViewPosFromUVDepth(texCoord,depth);}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var texCoord: vec2f=input.vUV;
|
||
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE)
|
||
var color: vec4f=textureSample(debugSampler,debugSamplerSampler,texCoord);
|
||
#ifdef FLUIDRENDERING_DEBUG_DEPTH
|
||
fragmentOutputs.color=vec4f(color.rgb/vec3f(2.0),1.);if (color.r>0.999 && color.g>0.999) {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,texCoord);}
|
||
#else
|
||
fragmentOutputs.color=vec4f(color.rgb,1.);if (color.r<0.001 && color.g<0.001 && color.b<0.001) {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,texCoord);}
|
||
#endif
|
||
return fragmentOutputs;
|
||
#endif
|
||
var depthVel: vec2f=textureSampleLevel(depthSampler,depthSamplerSampler,texCoord,0.).rg;var depth: f32=depthVel.r;
|
||
#ifndef FLUIDRENDERING_FIXED_THICKNESS
|
||
var thickness: f32=textureSample(thicknessSampler,thicknessSamplerSampler,texCoord).x;
|
||
#else
|
||
var thickness: f32=uniforms.thickness;var bgDepth: f32=textureSample(bgDepthSampler,bgDepthSamplerSampler,texCoord).x;var depthNonLinear: f32=uniforms.projectionMatrix[2].z+uniforms.projectionMatrix[3].z/depth;depthNonLinear=depthNonLinear*0.5+0.5;
|
||
#endif
|
||
var backColor: vec4f=textureSample(textureSampler,textureSamplerSampler,texCoord);
|
||
#ifndef FLUIDRENDERING_FIXED_THICKNESS
|
||
if (depth>=uniforms.cameraFar || depth<=0. || thickness<=uniforms.minimumThickness) {
|
||
#else
|
||
if (depth>=uniforms.cameraFar || depth<=0. || bgDepth<=depthNonLinear) {
|
||
#endif
|
||
#ifdef FLUIDRENDERING_COMPOSITE_MODE
|
||
fragmentOutputs.color=vec4f(backColor.rgb*backColor.a,backColor.a);
|
||
#else
|
||
fragmentOutputs.color=backColor;
|
||
#endif
|
||
return fragmentOutputs;}
|
||
var viewPos: vec3f=computeViewPosFromUVDepth(texCoord,depth);var ddx: vec3f=getViewPosFromTexCoord(texCoord+vec2f(uniforms.texelSize.x,0.))-viewPos;var ddy: vec3f=getViewPosFromTexCoord(texCoord+vec2f(0.,uniforms.texelSize.y))-viewPos;var ddx2: vec3f=viewPos-getViewPosFromTexCoord(texCoord+vec2f(-uniforms.texelSize.x,0.));if (abs(ddx.z)>abs(ddx2.z)) {ddx=ddx2;}
|
||
var ddy2: vec3f=viewPos-getViewPosFromTexCoord(texCoord+vec2f(0.,-uniforms.texelSize.y));if (abs(ddy.z)>abs(ddy2.z)) {ddy=ddy2;}
|
||
var normal: vec3f=normalize(cross(ddy,ddx));
|
||
#ifdef FLUIDRENDERING_RHS
|
||
normal=-normal;
|
||
#endif
|
||
#if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_SHOWNORMAL)
|
||
fragmentOutputs.color=vec4f(normal*0.5+0.5,1.0);return fragmentOutputs;
|
||
#endif
|
||
var rayDir: vec3f=normalize(viewPos);
|
||
#ifdef FLUIDRENDERING_DIFFUSETEXTURE
|
||
var diffuseColor: vec3f=textureSampleLevel(diffuseSampler,diffuseSamplerSampler,texCoord,0.0).rgb;
|
||
#else
|
||
var diffuseColor: vec3f=uniforms.diffuseColor;
|
||
#endif
|
||
var lightDir: vec3f=normalize((uniforms.viewMatrix*vec4f(-uniforms.dirLight,0.)).xyz);var H: vec3f =normalize(lightDir-rayDir);var specular: f32 =pow(max(0.0,dot(H,normal)),uniforms.specularPower);
|
||
#ifdef FLUIDRENDERING_DEBUG_DIFFUSERENDERING
|
||
var diffuse: f32 =max(0.0,dot(lightDir,normal))*1.0;fragmentOutputs.color=vec4f(vec3f(0.1) /*ambient*/+vec3f(0.42,0.50,1.00)*diffuse+vec3f(0,0,0.2)+specular,1.);return fragmentOutputs;
|
||
#endif
|
||
var refractionDir: vec3f=refract(rayDir,normal,ETA);var transmitted: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,vec2f(texCoord+refractionDir.xy*thickness*uniforms.refractionStrength),0.0);
|
||
#ifdef FLUIDRENDERING_COMPOSITE_MODE
|
||
if (transmitted.a==0.) {transmitted.a=thickness;}
|
||
#endif
|
||
var transmittance: vec3f=exp(-uniforms.density*thickness*(1.0-diffuseColor));
|
||
var refractionColor: vec3f=transmitted.rgb*transmittance;
|
||
#ifdef FLUIDRENDERING_ENVIRONMENT
|
||
var reflectionDir: vec3f=reflect(rayDir,normal);var reflectionColor: vec3f=(textureSample(reflectionSampler,reflectionSamplerSampler,reflectionDir).rgb);var fresnel: f32=clamp(F0+(1.0-F0)*pow(1.0-dot(normal,-rayDir),5.0),0.,uniforms.fresnelClamp);var finalColor: vec3f=mix(refractionColor,reflectionColor,fresnel)+specular;
|
||
#else
|
||
var finalColor: vec3f=refractionColor+specular;
|
||
#endif
|
||
#ifdef FLUIDRENDERING_VELOCITY
|
||
var velocity: f32=depthVel.g;finalColor=mix(finalColor,vec3f(1.0),smoothstep(0.3,1.0,velocity/6.0));
|
||
#endif
|
||
fragmentOutputs.color=vec4f(finalColor,transmitted.a);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},52063:(r,t,e)=>{e.r(t),e.d(t,{fluidRenderingStandardBlurPixelShaderWGSL:()=>o});var n="fluidRenderingStandardBlurPixelShader",i=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform filterSize: i32;uniform blurDir: vec2f;varying vUV: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var s: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.);if (s.r==0.) {fragmentOutputs.color=vec4f(0.,0.,0.,1.);return fragmentOutputs;}
|
||
var sigma: f32=f32(uniforms.filterSize)/3.0;var twoSigma2: f32=2.0*sigma*sigma;var sum: vec4f=vec4f(0.);var wsum: f32=0.;for (var x: i32=-uniforms.filterSize; x<=uniforms.filterSize; x++) {var coords: vec2f=vec2f(f32(x));var sampl: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV+coords*uniforms.blurDir,0.);var w: f32=exp(-coords.x*coords.x/twoSigma2);sum+=sampl*w;wsum+=w;}
|
||
sum/=wsum;fragmentOutputs.color=vec4f(sum.rgb,1.);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},23459:(r,t,e)=>{e.r(t),e.d(t,{fxaaPixelShaderWGSL:()=>o});var n="fxaaPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform texelSize: vec2f;varying sampleCoordS: vec2f;varying sampleCoordE: vec2f;varying sampleCoordN: vec2f;varying sampleCoordW: vec2f;varying sampleCoordNW: vec2f;varying sampleCoordSE: vec2f;varying sampleCoordNE: vec2f;varying sampleCoordSW: vec2f;const fxaaQualitySubpix: f32=1.0;const fxaaQualityEdgeThreshold: f32=0.166;const fxaaQualityEdgeThresholdMin: f32=0.0833;const kLumaCoefficients: vec3f= vec3f(0.2126,0.7152,0.0722);fn FxaaLuma(rgba: vec4f)->f32 {return dot(rgba.rgb,kLumaCoefficients);}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var posM: vec2f;posM.x=input.vUV.x;posM.y=input.vUV.y;var rgbyM: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0);var lumaM: f32=FxaaLuma(rgbyM);var lumaS: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordS,0.0));var lumaE: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordE,0.0));var lumaN: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordN,0.0));var lumaW: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordW,0.0));var maxSM: f32=max(lumaS,lumaM);var minSM: f32=min(lumaS,lumaM);var maxESM: f32=max(lumaE,maxSM);var minESM: f32=min(lumaE,minSM);var maxWN: f32=max(lumaN,lumaW);var minWN: f32=min(lumaN,lumaW);var rangeMax: f32=max(maxWN,maxESM);var rangeMin: f32=min(minWN,minESM);var rangeMaxScaled: f32=rangeMax*fxaaQualityEdgeThreshold;var range: f32=rangeMax-rangeMin;var rangeMaxClamped: f32=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);
|
||
#ifndef MALI
|
||
if(range<rangeMaxClamped)
|
||
{fragmentOutputs.color=rgbyM;return fragmentOutputs;}
|
||
#endif
|
||
var lumaNW: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordNW,0.0));var lumaSE: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordSE,0.0));var lumaNE: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordNE,0.0));var lumaSW: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,input.sampleCoordSW,0.0));var lumaNS: f32=lumaN+lumaS;var lumaWE: f32=lumaW+lumaE;var subpixRcpRange: f32=1.0/range;var subpixNSWE: f32=lumaNS+lumaWE;var edgeHorz1: f32=(-2.0*lumaM)+lumaNS;var edgeVert1: f32=(-2.0*lumaM)+lumaWE;var lumaNESE: f32=lumaNE+lumaSE;var lumaNWNE: f32=lumaNW+lumaNE;var edgeHorz2: f32=(-2.0*lumaE)+lumaNESE;var edgeVert2: f32=(-2.0*lumaN)+lumaNWNE;var lumaNWSW: f32=lumaNW+lumaSW;var lumaSWSE: f32=lumaSW+lumaSE;var edgeHorz4: f32=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);var edgeVert4: f32=(abs(edgeVert1)*2.0)+abs(edgeVert2);var edgeHorz3: f32=(-2.0*lumaW)+lumaNWSW;var edgeVert3: f32=(-2.0*lumaS)+lumaSWSE;var edgeHorz: f32=abs(edgeHorz3)+edgeHorz4;var edgeVert: f32=abs(edgeVert3)+edgeVert4;var subpixNWSWNESE: f32=lumaNWSW+lumaNESE;var lengthSign: f32=uniforms.texelSize.x;var horzSpan: bool=edgeHorz>=edgeVert;var subpixA: f32=subpixNSWE*2.0+subpixNWSWNESE;if (!horzSpan)
|
||
{lumaN=lumaW;}
|
||
if (!horzSpan)
|
||
{lumaS=lumaE;}
|
||
if (horzSpan)
|
||
{lengthSign=uniforms.texelSize.y;}
|
||
var subpixB: f32=(subpixA*(1.0/12.0))-lumaM;var gradientN: f32=lumaN-lumaM;var gradientS: f32=lumaS-lumaM;var lumaNN: f32=lumaN+lumaM;var lumaSS: f32=lumaS+lumaM;var pairN: bool=abs(gradientN)>=abs(gradientS);var gradient: f32=max(abs(gradientN),abs(gradientS));if (pairN)
|
||
{lengthSign=-lengthSign;}
|
||
var subpixC: f32=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);var posB: vec2f;posB.x=posM.x;posB.y=posM.y;var offNP: vec2f;offNP.x=select(uniforms.texelSize.x,0.0,(!horzSpan));offNP.y=select(uniforms.texelSize.y,0.0,(horzSpan));if (!horzSpan)
|
||
{posB.x+=lengthSign*0.5;}
|
||
if (horzSpan)
|
||
{posB.y+=lengthSign*0.5;}
|
||
var posN: vec2f;posN.x=posB.x-offNP.x*1.5;posN.y=posB.y-offNP.y*1.5;var posP: vec2f;posP.x=posB.x+offNP.x*1.5;posP.y=posB.y+offNP.y*1.5;var subpixD: f32=((-2.0)*subpixC)+3.0;var lumaEndN: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,posN,0.0));var subpixE: f32=subpixC*subpixC;var lumaEndP: f32=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,posP,0.0));if (!pairN)
|
||
{lumaNN=lumaSS;}
|
||
var gradientScaled: f32=gradient*1.0/4.0;var lumaMM: f32=lumaM-lumaNN*0.5;var subpixF: f32=subpixD*subpixE;var lumaMLTZero: bool=lumaMM<0.0;lumaEndN-=lumaNN*0.5;lumaEndP-=lumaNN*0.5;var doneN: bool=abs(lumaEndN)>=gradientScaled;var doneP: bool=abs(lumaEndP)>=gradientScaled;if (!doneN)
|
||
{posN.x-=offNP.x*3.0;}
|
||
if (!doneN)
|
||
{posN.y-=offNP.y*3.0;}
|
||
var doneNP: bool=(!doneN) || (!doneP);if (!doneP)
|
||
{posP.x+=offNP.x*3.0;}
|
||
if (!doneP)
|
||
{posP.y+=offNP.y*3.0;}
|
||
if (doneNP)
|
||
{if (!doneN) {lumaEndN=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,posN.xy,0.0));}
|
||
if (!doneP) {lumaEndP=FxaaLuma(textureSampleLevel(textureSampler,textureSamplerSampler,posP.xy,0.0));}
|
||
if (!doneN) {lumaEndN=lumaEndN-lumaNN*0.5;}
|
||
if (!doneP) {lumaEndP=lumaEndP-lumaNN*0.5;}
|
||
doneN=abs(lumaEndN)>=gradientScaled;doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) {posN.x-=offNP.x*12.0;}
|
||
if (!doneN) {posN.y-=offNP.y*12.0;}
|
||
doneNP=(!doneN) || (!doneP);if (!doneP) {posP.x+=offNP.x*12.0;}
|
||
if (!doneP) {posP.y+=offNP.y*12.0;}}
|
||
var dstN: f32=posM.x-posN.x;var dstP: f32=posP.x-posM.x;if (!horzSpan)
|
||
{dstN=posM.y-posN.y;}
|
||
if (!horzSpan)
|
||
{dstP=posP.y-posM.y;}
|
||
var goodSpanN: bool=(lumaEndN<0.0) != lumaMLTZero;var spanLength: f32=(dstP+dstN);var goodSpanP: bool=(lumaEndP<0.0) != lumaMLTZero;var spanLengthRcp: f32=1.0/spanLength;var directionN: bool=dstN<dstP;var dst: f32=min(dstN,dstP);var goodSpan: bool=select(goodSpanP,goodSpanN,directionN);var subpixG: f32=subpixF*subpixF;var pixelOffset: f32=(dst*(-spanLengthRcp))+0.5;var subpixH: f32=subpixG*fxaaQualitySubpix;var pixelOffsetGood: f32=select(0.0,pixelOffset,goodSpan);var pixelOffsetSubpix: f32=max(pixelOffsetGood,subpixH);if (!horzSpan)
|
||
{posM.x+=pixelOffsetSubpix*lengthSign;}
|
||
if (horzSpan)
|
||
{posM.y+=pixelOffsetSubpix*lengthSign;}
|
||
#ifdef MALI
|
||
if(range<rangeMaxClamped)
|
||
{fragmentOutputs.color=rgbyM;}
|
||
else
|
||
{fragmentOutputs.color=textureSampleLevel(textureSampler,textureSamplerSampler,posM,0.0);}
|
||
#else
|
||
fragmentOutputs.color=textureSampleLevel(textureSampler,textureSamplerSampler,posM,0.0);
|
||
#endif
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},13481:(r,t,e)=>{e.r(t),e.d(t,{fxaaVertexShaderWGSL:()=>o});var n="fxaaVertexShader",i=`attribute position: vec2f;uniform texelSize: vec2f;varying vUV: vec2f;varying sampleCoordS: vec2f;varying sampleCoordE: vec2f;varying sampleCoordN: vec2f;varying sampleCoordW: vec2f;varying sampleCoordNW: vec2f;varying sampleCoordSE: vec2f;varying sampleCoordNE: vec2f;varying sampleCoordSW: vec2f;const madd: vec2f= vec2f(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vertexOutputs.vUV=(input.position*madd+madd);vertexOutputs.sampleCoordS=vertexOutputs.vUV+ vec2f( 0.0,1.0)*uniforms.texelSize;vertexOutputs.sampleCoordE=vertexOutputs.vUV+ vec2f( 1.0,0.0)*uniforms.texelSize;vertexOutputs.sampleCoordN=vertexOutputs.vUV+ vec2f( 0.0,-1.0)*uniforms.texelSize;vertexOutputs.sampleCoordW=vertexOutputs.vUV+ vec2f(-1.0,0.0)*uniforms.texelSize;vertexOutputs.sampleCoordNW=vertexOutputs.vUV+ vec2f(-1.0,-1.0)*uniforms.texelSize;vertexOutputs.sampleCoordSE=vertexOutputs.vUV+ vec2f( 1.0,1.0)*uniforms.texelSize;vertexOutputs.sampleCoordNE=vertexOutputs.vUV+ vec2f( 1.0,-1.0)*uniforms.texelSize;vertexOutputs.sampleCoordSW=vertexOutputs.vUV+ vec2f(-1.0,1.0)*uniforms.texelSize;vertexOutputs.position=vec4f(input.position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},51319:(r,t,e)=>{e.r(t),e.d(t,{geometryPixelShaderWGSL:()=>a});var n=e(98519),i=(e(20502),e(96830),e(66633),e(17393),e(30032),e(20274),"geometryPixelShader"),o=`#ifdef BUMP
|
||
varying vWorldView: mat4x4f;varying vNormalW: vec3f;
|
||
#else
|
||
varying vNormalV: vec3f;
|
||
#endif
|
||
varying vViewPos: vec4f;
|
||
#if defined(POSITION) || defined(BUMP)
|
||
varying vPositionW: vec3f;
|
||
#endif
|
||
#ifdef VELOCITY
|
||
varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
|
||
#endif
|
||
#ifdef NEED_UV
|
||
varying vUV: vec2f;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform vBumpInfos: vec3f;uniform vTangentSpaceParams: vec2f;
|
||
#endif
|
||
#if defined(REFLECTIVITY)
|
||
#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
||
var reflectivitySamplerSampler: sampler;var reflectivitySampler: texture_2d<f32>;varying vReflectivityUV: vec2f;
|
||
#endif
|
||
#ifdef ALBEDOTEXTURE
|
||
varying vAlbedoUV: vec2f;var albedoSamplerSampler: sampler;var albedoSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef REFLECTIVITYCOLOR
|
||
uniform reflectivityColor: vec3f;
|
||
#endif
|
||
#ifdef ALBEDOCOLOR
|
||
uniform albedoColor: vec3f;
|
||
#endif
|
||
#ifdef METALLIC
|
||
uniform metallic: f32;
|
||
#endif
|
||
#if defined(ROUGHNESS) || defined(GLOSSINESS)
|
||
uniform glossiness: f32;
|
||
#endif
|
||
#endif
|
||
#if defined(ALPHATEST) && defined(NEED_UV)
|
||
var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<bumpFragmentMainFunctions>
|
||
#include<bumpFragmentFunctions>
|
||
#include<helperFunctions>
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEST
|
||
if (textureSample(diffuseSampler,diffuseSamplerSampler,input.vUV).a<0.4) {discard;}
|
||
#endif
|
||
var normalOutput: vec3f;
|
||
#ifdef BUMP
|
||
var normalW: vec3f=normalize(input.vNormalW);
|
||
#include<bumpFragment>
|
||
#ifdef NORMAL_WORLDSPACE
|
||
normalOutput=normalW;
|
||
#else
|
||
normalOutput=normalize( vec3f(input.vWorldView* vec4f(normalW,0.0)));
|
||
#endif
|
||
#else
|
||
normalOutput=normalize(input.vNormalV);
|
||
#endif
|
||
#ifdef ENCODE_NORMAL
|
||
normalOutput=normalOutput*0.5+0.5;
|
||
#endif
|
||
var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
|
||
#ifdef PREPASS
|
||
#ifdef PREPASS_DEPTH
|
||
fragData[DEPTH_INDEX]= vec4f(input.vViewPos.z/input.vViewPos.w,0.0,0.0,1.0);
|
||
#endif
|
||
#if defined(PREPASS_NORMAL) || defined(PREPASS_WORLD_NORMAL)
|
||
fragData[NORMAL_INDEX]= vec4f(normalOutput,1.0);
|
||
#endif
|
||
#else
|
||
fragData[0]= vec4f(input.vViewPos.z/input.vViewPos.w,0.0,0.0,1.0);fragData[1]= vec4f(normalOutput,1.0);
|
||
#endif
|
||
#ifdef POSITION
|
||
fragData[POSITION_INDEX]= vec4f(input.vPositionW,1.0);
|
||
#endif
|
||
#ifdef VELOCITY
|
||
var a: vec2f=(input.vCurrentPosition.xy/input.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(input.vPreviousPosition.xy/input.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[VELOCITY_INDEX]= vec4f(velocity,0.0,1.0);
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
var reflectivity: vec4f= vec4f(0.0,0.0,0.0,1.0);
|
||
#ifdef METALLICWORKFLOW
|
||
var metal: f32=1.0;var roughness: f32=1.0;
|
||
#ifdef ORMTEXTURE
|
||
metal*=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV).b;roughness*=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV).g;
|
||
#endif
|
||
#ifdef METALLIC
|
||
metal*=uniforms.metallic;
|
||
#endif
|
||
#ifdef ROUGHNESS
|
||
roughness*=(1.0-uniforms.glossiness);
|
||
#endif
|
||
reflectivity=vec4f(reflectivity.rgb,reflectivity.a-roughness);var color: vec3f= vec3f(1.0);
|
||
#ifdef ALBEDOTEXTURE
|
||
color=textureSample(albedoSampler,albedoSamplerSampler,input.vAlbedoUV).rgb;
|
||
#ifdef GAMMAALBEDO
|
||
color=toLinearSpaceVec4(color);
|
||
#endif
|
||
#endif
|
||
#ifdef ALBEDOCOLOR
|
||
color*=uniforms.albedoColor.xyz;
|
||
#endif
|
||
reflectivity=vec4f(mix( vec3f(0.04),color,metal),reflectivity.a);
|
||
#else
|
||
#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
||
reflectivity=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV);
|
||
#ifdef GAMMAREFLECTIVITYTEXTURE
|
||
reflectivity=vec4f(toLinearSpaceVec3(reflectivity.rgb),reflectivity.a);
|
||
#endif
|
||
#else
|
||
#ifdef REFLECTIVITYCOLOR
|
||
reflectivity=vec4f(toLinearSpaceVec3(uniforms.reflectivityColor.xyz),1.0);
|
||
#endif
|
||
#endif
|
||
#ifdef GLOSSINESSS
|
||
reflectivity=vec4f(reflectivity.rgb,reflectivity.a*glossiness);
|
||
#endif
|
||
#endif
|
||
fragData[REFLECTIVITY_INDEX]=reflectivity;
|
||
#endif
|
||
#if SCENE_MRT_COUNT>0
|
||
fragmentOutputs.fragData0=fragData[0];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>1
|
||
fragmentOutputs.fragData1=fragData[1];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>2
|
||
fragmentOutputs.fragData2=fragData[2];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>3
|
||
fragmentOutputs.fragData3=fragData[3];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>4
|
||
fragmentOutputs.fragData4=fragData[4];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>5
|
||
fragmentOutputs.fragData5=fragData[5];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>6
|
||
fragmentOutputs.fragData6=fragData[6];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>7
|
||
fragmentOutputs.fragData7=fragData[7];
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},40877:(r,t,e)=>{e.r(t),e.d(t,{geometryVertexShaderWGSL:()=>a});var n=e(98519),i=(e(45699),e(27279),e(73683),e(68478),e(63866),e(36644),e(9436),e(98819),e(77320),e(21310),e(3641),e(86615),e(63002),e(19748),"geometryVertexShader"),o=`#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesDeclaration>
|
||
#include<sceneUboDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
attribute position: vec3f;attribute normal: vec3f;
|
||
#ifdef NEED_UV
|
||
varying vUV: vec2f;
|
||
#ifdef ALPHATEST
|
||
uniform diffuseMatrix: mat4x4f;
|
||
#endif
|
||
#ifdef BUMP
|
||
uniform bumpMatrix: mat4x4f;varying vBumpUV: vec2f;
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
uniform reflectivityMatrix: mat4x4f;uniform albedoMatrix: mat4x4f;varying vReflectivityUV: vec2f;varying vAlbedoUV: vec2f;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute uv2: vec2f;
|
||
#endif
|
||
#endif
|
||
#ifdef BUMP
|
||
varying vWorldView: mat4x4f;
|
||
#endif
|
||
#ifdef BUMP
|
||
varying vNormalW: vec3f;
|
||
#else
|
||
varying vNormalV: vec3f;
|
||
#endif
|
||
varying vViewPos: vec4f;
|
||
#if defined(POSITION) || defined(BUMP)
|
||
varying vPositionW: vec3f;
|
||
#endif
|
||
#ifdef VELOCITY
|
||
uniform previousViewProjection: mat4x4f;varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=input.position;var normalUpdated: vec3f=input.normal;
|
||
#ifdef UV1
|
||
var uvUpdated: vec2f=input.uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
|
||
vCurrentPosition=scene.viewProjection*finalWorld*vec4f(positionUpdated,1.0);vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0);
|
||
#endif
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f= vec4f(finalWorld* vec4f(positionUpdated,1.0));
|
||
#ifdef BUMP
|
||
vertexOutputs.vWorldView=scene.view*finalWorld;vertexOutputs.vNormalW=normalUpdated;
|
||
#else
|
||
#ifdef NORMAL_WORLDSPACE
|
||
vertexOutputs.vNormalV=normalize((finalWorld* vec4f(normalUpdated,0.0)).xyz);
|
||
#else
|
||
vertexOutputs.vNormalV=normalize(((scene.view*finalWorld)* vec4f(normalUpdated,0.0)).xyz);
|
||
#endif
|
||
#endif
|
||
vertexOutputs.vViewPos=scene.view*worldPos;
|
||
#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)
|
||
vertexOutputs.vCurrentPosition=scene.viewProjection*finalWorld* vec4f(positionUpdated,1.0);
|
||
#if NUM_BONE_INFLUENCERS>0
|
||
var previousInfluence: mat4x4f;previousInfluence=mPreviousBones[ i32(matricesIndices[0])]*matricesWeights[0];
|
||
#if NUM_BONE_INFLUENCERS>1
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndices[1])]*matricesWeights[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>2
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndices[2])]*matricesWeights[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>3
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndices[3])]*matricesWeights[3];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>4
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>5
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>6
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
|
||
#endif
|
||
#if NUM_BONE_INFLUENCERS>7
|
||
previousInfluence+=mPreviousBones[ i32(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
|
||
#endif
|
||
vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*previousInfluence* vec4f(positionUpdated,1.0);
|
||
#else
|
||
vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0);
|
||
#endif
|
||
#endif
|
||
#if defined(POSITION) || defined(BUMP)
|
||
vertexOutputs.vPositionW=worldPos.xyz/worldPos.w;
|
||
#endif
|
||
vertexOutputs.position=scene.viewProjection*finalWorld* vec4f(positionUpdated,1.0);
|
||
#include<clipPlaneVertex>
|
||
#ifdef NEED_UV
|
||
#ifdef UV1
|
||
#if defined(ALPHATEST) && defined(ALPHATEST_UV1)
|
||
vertexOutputs.vUV=(uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#else
|
||
vertexOutputs.vUV=input.uv;
|
||
#endif
|
||
#ifdef BUMP_UV1
|
||
vertexOutputs.vBumpUV=(uniforms.bumpMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef REFLECTIVITY_UV1
|
||
vertexOutputs.vReflectivityUV=(uniforms.reflectivityMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef ALBEDO_UV1
|
||
vertexOutputs.vAlbedoUV=(uniforms.albedoMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
#ifdef UV2
|
||
#if defined(ALPHATEST) && defined(ALPHATEST_UV2)
|
||
vertexOutputs.vUV=(uniforms.diffuseMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#else
|
||
vertexOutputs.vUV=input.uv2;
|
||
#endif
|
||
#ifdef BUMP_UV2
|
||
vertexOutputs.vBumpUV=(uniforms.bumpMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef REFLECTIVITY_UV2
|
||
vertexOutputs.vReflectivityUV=(uniforms.reflectivityMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef ALBEDO_UV2
|
||
vertexOutputs.vAlbedoUV=(uniforms.albedoMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#include<bumpVertex>
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},68442:(r,t,e)=>{e.r(t),e.d(t,{glowBlurPostProcessPixelShaderWGSL:()=>o});var n="glowBlurPostProcessPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform screenSize: vec2f;uniform direction: vec2f;uniform blurWidth: f32;fn getLuminance(color: vec3f)->f32
|
||
{return dot(color, vec3f(0.2126,0.7152,0.0722));}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var weights: array<f32 ,7>;weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;var texelSize: vec2f= vec2f(1.0/uniforms.screenSize.x,1.0/uniforms.screenSize.y);var texelStep: vec2f=texelSize*uniforms.direction*uniforms.blurWidth;var start: vec2f=input.vUV-3.0*texelStep;var baseColor: vec4f= vec4f(0.,0.,0.,0.);var texelOffset: vec2f= vec2f(0.,0.);for (var i: i32=0; i<7; i++)
|
||
{var texel: vec4f=textureSample(textureSampler,textureSamplerSampler,start+texelOffset);baseColor=vec4f(baseColor.rgb,baseColor.a+texel.a*weights[i]);var luminance: f32=getLuminance(baseColor.rgb);var luminanceTexel: f32=getLuminance(texel.rgb);var choice: f32=step(luminanceTexel,luminance);baseColor=vec4f(choice*baseColor.rgb+(1.0-choice)*texel.rgb,baseColor.a);texelOffset+=texelStep;}
|
||
fragmentOutputs.color=baseColor;}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},35750:(r,t,e)=>{e.r(t),e.d(t,{glowMapGenerationPixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),e(20502),e(30032),"glowMapGenerationPixelShader"),o=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)
|
||
#include<helperFunctions>
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
varying vUVDiffuse: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef OPACITY
|
||
varying vUVOpacity: vec2f;var opacitySamplerSampler: sampler;var opacitySampler: texture_2d<f32>;uniform var opacityIntensity: f32;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
varying vUVEmissive: vec2f;var emissiveSamplerSampler: sampler;var emissiveSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
varying vColor: vec4f;
|
||
#endif
|
||
uniform glowColor: vec4f;uniform glowIntensity: f32;
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#include<clipPlaneFragment>
|
||
var finalColor: vec4f=uniforms.glowColor;
|
||
#ifdef DIFFUSE
|
||
var albedoTexture: vec4f=textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vUVDiffuse);
|
||
#ifdef DIFFUSE_ISLINEAR
|
||
albedoTexture=toGammaSpace(albedoTexture);
|
||
#endif
|
||
#ifdef GLOW
|
||
finalColor=vec4f(finalColor.rgb,finalColor.a*albedoTexture.a);
|
||
#endif
|
||
#ifdef HIGHLIGHT
|
||
finalColor=vec4f(finalColor.rgb,albedoTexture.a);
|
||
#endif
|
||
#endif
|
||
#ifdef OPACITY
|
||
var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vUVOpacity);
|
||
#ifdef OPACITYRGB
|
||
finalColor=vec4f(finalColor.rgb,finalColor.a*getLuminance(opacityMap.rgb));
|
||
#else
|
||
finalColor=vec4f(finalColor.rgb,finalColor.a*opacityMap.a);
|
||
#endif
|
||
finalColor=vec4f(finalColor.rgb,finalColor.a*opacityIntensity);
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
finalColor=vec4f(finalColor.rgb,finalColor.a*vColor.a);
|
||
#endif
|
||
#ifdef ALPHATEST
|
||
if (finalColor.a<ALPHATESTVALUE)
|
||
discard;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
var emissive: vec4f=textureSample(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vUVEmissive);
|
||
#ifdef EMISSIVE_ISLINEAR
|
||
emissive=toGammaSpace(emissive);
|
||
#endif
|
||
fragmentOutputs.color=emissive*finalColor*uniforms.glowIntensity;
|
||
#else
|
||
fragmentOutputs.color=finalColor*uniforms.glowIntensity;
|
||
#endif
|
||
#ifdef HIGHLIGHT
|
||
fragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,uniforms.glowColor.a);
|
||
#endif
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},97e3:(r,t,e)=>{e.r(t),e.d(t,{glowMapGenerationVertexShaderWGSL:()=>a});var n=e(98519),i=(e(45699),e(27279),e(73683),e(68478),e(9436),e(63866),e(98819),e(77320),e(21310),e(3641),e(86615),e(63002),"glowMapGenerationVertexShader"),o=`attribute position: vec3f;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<instancesDeclaration>
|
||
uniform viewProjection: mat4x4f;varying vPosition: vec4f;
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute uv2: vec2f;
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
varying vUVDiffuse: vec2f;uniform diffuseMatrix: mat4x4f;
|
||
#endif
|
||
#ifdef OPACITY
|
||
varying vUVOpacity: vec2f;uniform opacityMatrix: mat4x4f;
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
varying vUVEmissive: vec2f;uniform emissiveMatrix: mat4x4f;
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
attribute color: vec4f;varying vColor: vec4f;
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=input.position;
|
||
#ifdef UV1
|
||
var uvUpdated: vec2f=input.uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);
|
||
#ifdef CUBEMAP
|
||
vertexOutputs.vPosition=worldPos;vertexOutputs.position=uniforms.viewProjection*finalWorld* vec4f(input.position,1.0);
|
||
#else
|
||
vertexOutputs.vPosition=uniforms.viewProjection*worldPos;vertexOutputs.position=vertexOutputs.vPosition;
|
||
#endif
|
||
#ifdef DIFFUSE
|
||
#ifdef DIFFUSEUV1
|
||
vertexOutputs.vUVDiffuse= (uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef DIFFUSEUV2
|
||
vertexOutputs.vUVDiffuse= (uniforms.diffuseMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
#ifdef OPACITY
|
||
#ifdef OPACITYUV1
|
||
vertexOutputs.vUVOpacity= (uniforms.opacityMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef OPACITYUV2
|
||
vertexOutputs.vUVOpacity= (uniforms.opacityMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
#ifdef EMISSIVE
|
||
#ifdef EMISSIVEUV1
|
||
vertexOutputs.vUVEmissive= (uniforms.emissiveMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef EMISSIVEUV2
|
||
vertexOutputs.vUVEmissive= (uniforms.emissiveMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
#ifdef VERTEXALPHA
|
||
vertexOutputs.vColor=color;
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},15638:(r,t,e)=>{e.r(t),e.d(t,{glowMapMergePixelShaderWGSL:()=>o});var n="glowMapMergePixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
#ifdef EMISSIVE
|
||
var textureSampler2Sampler: sampler;var textureSampler2: texture_2d<f32>;
|
||
#endif
|
||
uniform offset: f32;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
var baseColor: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);
|
||
#ifdef EMISSIVE
|
||
baseColor+=textureSample(textureSampler2,textureSampler2Sampler,input.vUV);baseColor*=uniforms.offset;
|
||
#else
|
||
baseColor=vec4f(baseColor.rgb,abs(uniforms.offset-baseColor.a));
|
||
#ifdef STROKE
|
||
var alpha: f32=smoothstep(.0,.1,baseColor.a);baseColor=vec4f(baseColor.rgb*alpha,alpha);
|
||
#endif
|
||
#endif
|
||
#if LDR
|
||
baseColor=clamp(baseColor,0.,1.0);
|
||
#endif
|
||
fragmentOutputs.color=baseColor;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},67064:(r,t,e)=>{e.r(t),e.d(t,{glowMapMergeVertexShaderWGSL:()=>o});var n="glowMapMergeVertexShader",i=`attribute position: vec2f;varying vUV: vec2f;
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {const madd: vec2f= vec2f(0.5,0.5);
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vertexOutputs.vUV=input.position*madd+madd;vertexOutputs.position= vec4f(input.position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},78138:(r,t,e)=>{e.r(t),e.d(t,{grainPixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),"grainPixelShader"),o=`#include<helperFunctions>
|
||
varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform intensity: f32;uniform animatedSeed: f32;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);var seed: vec2f=input.vUV*uniforms.animatedSeed;var grain: f32=dither(seed,uniforms.intensity);var lum: f32=getLuminance(fragmentOutputs.color.rgb);var grainAmount: f32=(cos(-PI+(lum*PI*2.))+1.)/2.;fragmentOutputs.color=vec4f(fragmentOutputs.color.rgb+grain*grainAmount,fragmentOutputs.color.a);fragmentOutputs.color=vec4f(max(fragmentOutputs.color.rgb,vec3f(0.0)),fragmentOutputs.color.a);}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},76459:(r,t,e)=>{e.r(t),e.d(t,{hdrFilteringPixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),e(28469),e(61669),e(31321),"hdrFilteringPixelShader"),o=`#include<helperFunctions>
|
||
#include<importanceSampling>
|
||
#include<pbrBRDFFunctions>
|
||
#include<hdrFilteringFunctions>
|
||
uniform alphaG: f32;var inputTextureSampler: sampler;var inputTexture: texture_cube<f32>;uniform vFilteringInfo: vec2f;uniform hdrScale: f32;varying direction: vec3f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var color: vec3f=radiance(uniforms.alphaG,inputTexture,inputTextureSampler,input.direction,uniforms.vFilteringInfo);fragmentOutputs.color= vec4f(color*uniforms.hdrScale,1.0);}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},34593:(r,t,e)=>{e.r(t),e.d(t,{hdrFilteringVertexShaderWGSL:()=>o});var n="hdrFilteringVertexShader",i=`attribute position: vec2f;varying direction: vec3f;uniform up: vec3f;uniform right: vec3f;uniform front: vec3f;
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
var view: mat3x3f= mat3x3f(uniforms.up,uniforms.right,uniforms.front);vertexOutputs.direction=view*vec3f(input.position,1.0);vertexOutputs.position= vec4f(input.position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},40856:(r,t,e)=>{e.r(t),e.d(t,{highlightsPixelShaderWGSL:()=>o});var n="highlightsPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;const RGBLuminanceCoefficients: vec3f= vec3f(0.2126,0.7152,0.0722);
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var tex: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);var c: vec3f=tex.rgb;var luma: f32=dot(c.rgb,RGBLuminanceCoefficients);fragmentOutputs.color= vec4f(pow(c, vec3f(25.0-luma*15.0)),tex.a); }`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},8866:(r,t,e)=>{e.r(t),e.d(t,{iblCombineVoxelGridsPixelShaderWGSL:()=>o});var n="iblCombineVoxelGridsPixelShader",i=`varying vUV: vec2f;var voxelXaxisSamplerSampler: sampler;var voxelXaxisSampler: texture_3d<f32>;var voxelYaxisSamplerSampler: sampler;var voxelYaxisSampler: texture_3d<f32>;var voxelZaxisSamplerSampler: sampler;var voxelZaxisSampler: texture_3d<f32>;uniform layer: f32;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var coordZ: vec3f= vec3f(fragmentInputs.vUV.x,fragmentInputs.vUV.y,uniforms.layer);var voxelZ: f32=textureSample(voxelZaxisSampler,voxelZaxisSamplerSampler,coordZ).r;var coordX: vec3f= vec3f(1.0-uniforms.layer,fragmentInputs.vUV.y,fragmentInputs.vUV.x);var voxelX: f32=textureSample(voxelXaxisSampler,voxelXaxisSamplerSampler,coordX).r;var coordY: vec3f= vec3f(uniforms.layer,fragmentInputs.vUV.x,fragmentInputs.vUV.y);var voxelY: f32=textureSample(voxelYaxisSampler,voxelYaxisSamplerSampler,coordY).r;var voxel=select(0.0,1.0,(voxelX>0.0 || voxelY>0.0 || voxelZ>0.0));fragmentOutputs.color= vec4f( vec3f(voxel),1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},52651:(r,t,e)=>{e.r(t),e.d(t,{iblGenerateVoxelMipPixelShaderWGSL:()=>o});var n="iblGenerateVoxelMipPixelShader",i=`varying vUV: vec2f;var srcMip: texture_3d<f32>;uniform layerNum: i32;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var Coords=vec3i(2)*vec3i(vec2i(fragmentInputs.position.xy),uniforms.layerNum);var tex =
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(0,0,0),0).x>0.0f))
|
||
<< 0u) |
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(1,0,0),0).x>0.0f))
|
||
<< 1u) |
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(0,1,0),0).x>0.0f))
|
||
<< 2u) |
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(1,1,0),0).x>0.0f))
|
||
<< 3u) |
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(0,0,1),0).x>0.0f))
|
||
<< 4u) |
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(1,0,1),0).x>0.0f))
|
||
<< 5u) |
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(0,1,1),0).x>0.0f))
|
||
<< 6u) |
|
||
(u32(select(0u,1u,textureLoad(srcMip,Coords+vec3i(1,1,1),0).x>0.0f))
|
||
<< 7u);fragmentOutputs.color=vec4f( f32(tex)/255.0f,0.0f,0.0f,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},21181:(r,t,e)=>{e.r(t),e.d(t,{iblShadowAccumulationPixelShaderWGSL:()=>o});var n="iblShadowAccumulationPixelShader",i=`varying vUV: vec2f;uniform accumulationParameters: vec4f;
|
||
#define remanence uniforms.accumulationParameters.x
|
||
#define resetb uniforms.accumulationParameters.y
|
||
var motionSampler: texture_2d<f32>;
|
||
var localPositionSampler: texture_2d<f32>;
|
||
var textureSampler: texture_2d<f32>;
|
||
var oldAccumulationSamplerSampler: sampler;var oldAccumulationSampler: texture_2d<f32>;
|
||
var prevLocalPositionSamplerSampler: sampler;var prevLocalPositionSampler: texture_2d<f32>;
|
||
fn max2(v: vec2f,w: vec2f)->vec2f {
|
||
return vec2f(max(v.x,w.x),max(v.y,w.y)); }
|
||
fn lessThan(x: vec2f,y: vec2f)->vec2<bool> {return x<y;}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var reset: bool= bool(resetb);var Resolution: vec2f= vec2f(textureDimensions(textureSampler,0));var currentPixel: vec2i= vec2i(input.vUV*Resolution);var LP: vec4f=textureLoad(localPositionSampler,currentPixel,0);if (0.0==LP.w) {fragmentOutputs.color=vec4f(1.0,0.0,0.0,1.0);return fragmentOutputs;}
|
||
var velocityColor: vec2f=textureLoad(motionSampler,currentPixel,0).xy;var prevCoord: vec2f=input.vUV+velocityColor;var PrevLP: vec3f=textureSampleLevel(prevLocalPositionSampler,prevLocalPositionSamplerSampler,prevCoord,0.0).xyz;var PrevShadows: vec2f=textureSampleLevel(oldAccumulationSampler,oldAccumulationSamplerSampler,prevCoord,0.0).xy;var newShadows: f32=textureLoad(textureSampler,currentPixel,0).x;PrevShadows.y=select(1.0,max(PrevShadows.y/(1.0+PrevShadows.y),1.0-remanence),!reset && all(lessThan(abs(prevCoord- vec2f(0.5)), vec2f(0.5))) &&
|
||
distance(LP.xyz,PrevLP)<5e-2);PrevShadows=max( vec2f(0.0),PrevShadows);fragmentOutputs.color= vec4f(mix(PrevShadows.x,newShadows,PrevShadows.y),
|
||
PrevShadows.y,0,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},35139:(r,t,e)=>{e.r(t),e.d(t,{iblShadowDebugPixelShaderWGSL:()=>o});var n="iblShadowDebugPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var debugSamplerSampler: sampler;var debugSampler: texture_2d<f32>;uniform sizeParams: vec4f;
|
||
#define offsetX uniforms.sizeParams.x
|
||
#define offsetY uniforms.sizeParams.y
|
||
#define widthScale uniforms.sizeParams.z
|
||
#define heightScale uniforms.sizeParams.w
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var uv: vec2f =
|
||
vec2f((offsetX+fragmentInputs.vUV.x)*widthScale,(offsetY+fragmentInputs.vUV.y)*heightScale);var background: vec4f=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.vUV);var debugColour: vec4f=textureSample(debugSampler,debugSamplerSampler,fragmentInputs.vUV);if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {fragmentOutputs.color=background;} else {fragmentOutputs.color=vec4f(mix(debugColour.rgb,background.rgb,0.0),1.0);}}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},75866:(r,t,e)=>{e.r(t),e.d(t,{iblShadowGBufferDebugPixelShaderWGSL:()=>o});var n="iblShadowGBufferDebugPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var prePass_NdcDepthSampler: sampler;var prePass_NdcDepth: texture_2d<f32>;var prePass_WorldNormalSampler: sampler;var prePass_WorldNormal: texture_2d<f32>;var prePass_PositionSampler: sampler;var prePass_Position: texture_2d<f32>;var prePass_LocalPositionSampler: sampler;var prePass_LocalPosition: texture_2d<f32>;var prePass_VelocityLinearSampler: sampler;var prePass_VelocityLinear: texture_2d<f32>;uniform sizeParams: vec4f;uniform maxDepth: f32;
|
||
#define offsetX uniforms.sizeParams.x
|
||
#define offsetY uniforms.sizeParams.y
|
||
#define widthScale uniforms.sizeParams.z
|
||
#define heightScale uniforms.sizeParams.w
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var uv: vec2f =
|
||
vec2f((offsetX+input.vUV.x)*widthScale,(offsetY+input.vUV.y)*heightScale);var backgroundColour: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV).rgba;var depth: vec4f=textureSample(prePass_NdcDepth,prePass_NdcDepthSampler,input.vUV);var worldNormal: vec4f=textureSample(prePass_WorldNormal,prePass_WorldNormalSampler,input.vUV);var worldPosition: vec4f=textureSample(prePass_Position,prePass_PositionSampler,input.vUV);var localPosition: vec4f=textureSample(prePass_LocalPosition,prePass_LocalPositionSampler,input.vUV);var velocityLinear: vec4f=textureSample(prePass_VelocityLinear,prePass_VelocityLinearSampler,input.vUV);if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {fragmentOutputs.color=backgroundColour;} else {if (uv.x<=0.2) {
|
||
fragmentOutputs.color=vec4f(depth.rgb,1.0);} else if (uv.x<=0.4) {velocityLinear=vec4f(velocityLinear.r*0.5+0.5,velocityLinear.g*0.5+0.5,velocityLinear.b,velocityLinear.a);fragmentOutputs.color=vec4f(velocityLinear.rgb,1.0);} else if (uv.x<=0.6) {fragmentOutputs.color=vec4f(worldPosition.rgb,1.0);} else if (uv.x<=0.8) {fragmentOutputs.color=vec4f(localPosition.rgb,1.0);} else {fragmentOutputs.color=vec4f(worldNormal.rgb,1.0);}}}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},79401:(r,t,e)=>{e.r(t),e.d(t,{iblShadowSpatialBlurPixelShaderWGSL:()=>o});var n="iblShadowSpatialBlurPixelShader",i=`#define PI 3.1415927
|
||
varying vUV: vec2f;var linearDepthSampler: texture_2d<f32>;var worldNormalSampler: texture_2d<f32>;var textureSampler: texture_2d<f32>;uniform blurParameters: vec4f;
|
||
#define stridef uniforms.blurParameters.x
|
||
#define worldScale uniforms.blurParameters.y
|
||
const weights=array<f32,5>(0.0625,0.25,0.375,0.25,0.0625);const nbWeights: i32=5;fn max2(v: vec2f,w: vec2f)->vec2f {return vec2f(max(v.x,w.x),max(v.y,w.y));}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var Resolution=vec2f(textureDimensions(linearDepthSampler,0));var PixelCoord= vec2i(fragmentInputs.vUV*Resolution);var N: vec3f=textureLoad(worldNormalSampler,PixelCoord,0).xyz;if (length(N)<0.01) {fragmentOutputs.color=vec4f(1.0,1.0,0.0,1.0);return fragmentOutputs;}
|
||
var depth: f32=-textureLoad(linearDepthSampler,PixelCoord,0).x;var X: vec2f= vec2f(0.0);for(var y: i32=0; y<nbWeights; y++) {for(var x: i32=0; x<nbWeights; x++) {var Coords: vec2i=PixelCoord+i32(stridef)*vec2i(x-(nbWeights>>1),y-(nbWeights>>1));var T: vec2f=textureLoad(textureSampler,Coords,0).xy;var ddepth: f32=-textureLoad(linearDepthSampler,Coords,0).x-depth;var dN: vec3f=textureLoad(worldNormalSampler,Coords,0).xyz-N;var w: f32=weights[x]*weights[y] *
|
||
exp2(max(-1000.0/(worldScale*worldScale),-0.5) *
|
||
(ddepth*ddepth) -
|
||
1e1*dot(dN,dN));X+= vec2f(w*T.x,w);}}
|
||
fragmentOutputs.color= vec4f(X.x/X.y,1.0,0.0,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},75626:(r,t,e)=>{e.r(t),e.d(t,{iblShadowVoxelTracingPixelShaderWGSL:()=>o});var n="iblShadowVoxelTracingPixelShader",i=`#define PI 3.1415927
|
||
varying vUV: vec2f;
|
||
#define DISABLE_UNIFORMITY_ANALYSIS
|
||
var depthSampler: texture_2d<f32>;var worldNormalSampler: texture_2d<f32>;var worldPositionSampler: texture_2d<f32>;var blueNoiseSampler: texture_2d<f32>;var icdfxSamplerSampler: sampler;var icdfxSampler: texture_2d<f32>;var icdfySamplerSampler: sampler;var icdfySampler: texture_2d<f32>;var voxelGridSamplerSampler: sampler;var voxelGridSampler: texture_3d<f32>;uniform shadowParameters: vec4f;
|
||
#define SHADOWdirs uniforms.shadowParameters.x
|
||
#define SHADOWframe uniforms.shadowParameters.y
|
||
#define SHADOWdownscale uniforms.shadowParameters.z
|
||
#define SHADOWenvRot uniforms.shadowParameters.w
|
||
uniform offsetDataParameters: vec4f;
|
||
#define PixelOffset uniforms.offsetDataParameters.xy
|
||
#define highestMipLevel uniforms.offsetDataParameters.z
|
||
uniform sssParameters: vec4f;
|
||
#define SSSsamples uniforms.sssParameters.x
|
||
#define SSSstride uniforms.sssParameters.y
|
||
#define SSSmaxDistance uniforms.sssParameters.z
|
||
#define SSSthickness uniforms.sssParameters.w
|
||
uniform shadowOpacity: vec4f;uniform projMtx: mat4x4f;uniform viewMtx: mat4x4f;uniform invProjMtx: mat4x4f;uniform invViewMtx: mat4x4f;uniform wsNormalizationMtx: mat4x4f;uniform invVPMtx: mat4x4f;
|
||
#define PI 3.1415927
|
||
#define GOLD 0.618034
|
||
struct AABB3f {m_min: vec3f,
|
||
m_max: vec3f,};struct Ray {orig: vec3f,
|
||
dir: vec3f,
|
||
dir_rcp: vec3f,
|
||
t_min: f32,
|
||
t_max: f32,};fn make_ray(origin: vec3f,direction: vec3f,tmin: f32,
|
||
tmax: f32)->Ray {var ray: Ray;ray.orig=origin;ray.dir=direction;ray.dir_rcp=1.0f/direction;ray.t_min=tmin;ray.t_max=tmax;return ray;}
|
||
fn ray_box_intersection(aabb: AABB3f,ray: Ray ,
|
||
distance_near: ptr<function,f32>,distance_far: ptr<function,f32>)->bool{var tbot: vec3f=ray.dir_rcp*(aabb.m_min-ray.orig);var ttop: vec3f=ray.dir_rcp*(aabb.m_max-ray.orig);var tmin: vec3f=min(ttop,tbot);var tmax: vec3f=max(ttop,tbot);*distance_near=max(ray.t_min,max(tmin.x,max(tmin.y,tmin.z)));*distance_far=min(ray.t_max,min(tmax.x,min(tmax.y,tmax.z)));return *distance_near<=*distance_far;}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
struct VoxelMarchDiagnosticInfo {heat: f32,
|
||
voxel_intersect_coords: vec3i,};
|
||
#endif
|
||
fn hash(i: u32)->u32 {var temp=i ^ (i>>16u);temp*=0x7FEB352Du;temp ^= temp>>15u;temp*=0x846CA68Bu;temp ^= temp>>16u;return temp;}
|
||
fn uintBitsToFloat(x: u32)->f32 {return bitcast<f32>(x);}
|
||
fn uint2float(i: u32)->f32 {return uintBitsToFloat(0x3F800000u | (i>>9u))-1.0;}
|
||
fn uv_to_normal(uv: vec2f)->vec3f {var N: vec3f;var uvRange: vec2f=uv;var theta: f32=uvRange.x*2.0*PI;var phi: f32=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}
|
||
fn plasticSequence(rstate: u32)->vec2f {return vec2f(uint2float(rstate*3242174889u),
|
||
uint2float(rstate*2447445414u));}
|
||
fn goldenSequence(rstate: u32)->f32 {return uint2float(rstate*2654435769u);}
|
||
fn distanceSquared(a: vec2f,b: vec2f)->f32 {var diff: vec2f=a-b;return dot(diff,diff);}
|
||
fn genTB(N: vec3f,T: ptr<function,vec3f>,B: ptr<function,vec3f>) {var s: f32=select(1.0,-1.0,N.z<0.0);var a: f32=-1.0/(s+N.z);var b: f32=N.x*N.y*a;*T= vec3f(1.0+s*N.x*N.x*a,s*b,-s*N.x);*B= vec3f(b,s+N.y*N.y*a,-N.y);}
|
||
fn lessThan(x: vec3f,y: vec3f)->vec3<bool> {return x<y;}
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
fn anyHitVoxels(ray_vs: Ray,
|
||
voxel_march_diagnostic_info: ptr<function,VoxelMarchDiagnosticInfo>)->bool {
|
||
#else
|
||
fn anyHitVoxels(ray_vs: Ray)->bool {
|
||
#endif
|
||
var stack=array<i32,24>();
|
||
var invD: vec3f=ray_vs.dir_rcp;var D: vec3f=ray_vs.dir;var O: vec3f=ray_vs.orig;var negD=vec3i(lessThan(D, vec3f(0,0,0)));var voxel0: i32=negD.x | (negD.y<<1) | (negD.z<<2);var t0: vec3f=-O*invD;var t1=(vec3f(1.0)-O)*invD;var maxLod: i32= i32(highestMipLevel);var stackLevel: i32=0;
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
var steps: u32=0u;
|
||
#endif
|
||
stack[stackLevel]=maxLod<<24;stackLevel++;while (stackLevel>0) {stackLevel=stackLevel-1;var elem: i32=stack[stackLevel];var Coords: vec4i =
|
||
vec4i(elem & 0xFF,(elem>>8) & 0xFF,(elem>>16) & 0xFF,elem>>24);if (Coords.w==0) {
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
*voxel_march_diagnostic_info.heat= f32(steps)/24.0;
|
||
#endif
|
||
return true;}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
++steps;
|
||
#endif
|
||
var invRes: f32=exp2(f32(Coords.w-maxLod));var bbmin: vec3f=invRes*vec3f(Coords.xyz+negD);var bbmax: vec3f=invRes*vec3f(Coords.xyz-negD+vec3i(1));var mint: vec3f=mix(t0,t1,bbmin);var maxt: vec3f=mix(t0,t1,bbmax);var midt: vec3f=0.5*(mint+maxt);mint.x=max(0.0,mint.x);midt.x=max(0.0,midt.x);var nodeMask: u32= u32(
|
||
round(textureLoad(voxelGridSampler,Coords.xyz,Coords.w).x*255.0));Coords.w--;var voxelBit: u32=u32(voxel0);Coords=vec4i((Coords.xyz<<vec3u(1))+negD,Coords.w);var packedCoords: i32 =
|
||
Coords.x | (Coords.y<<8) | (Coords.z<<16) | (Coords.w<<24);if (max(mint.x,max(mint.y,mint.z))<min(midt.x,min(midt.y,midt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}
|
||
voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(mint.y,mint.z))<min(maxt.x,min(midt.y,midt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}
|
||
voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(midt.y,mint.z))<min(maxt.x,min(maxt.y,midt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}
|
||
voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(midt.y,mint.z))<min(midt.x,min(maxt.y,midt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}
|
||
voxelBit ^= 0x4;packedCoords ^= 0x10000;if (max(mint.x,max(midt.y,midt.z))<min(midt.x,min(maxt.y,maxt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}
|
||
voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(midt.x,max(midt.y,midt.z))<min(maxt.x,min(maxt.y,maxt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}
|
||
voxelBit ^= 0x2;packedCoords ^= 0x00100;if (max(midt.x,max(mint.y,midt.z))<min(maxt.x,min(midt.y,maxt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}
|
||
voxelBit ^= 0x1;packedCoords ^= 0x00001;if (max(mint.x,max(mint.y,midt.z))<min(midt.x,min(midt.y,maxt.z)) &&
|
||
((1u<<voxelBit) & nodeMask) != 0) {stack[stackLevel]=packedCoords;stackLevel++;}}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
*voxel_march_diagnostic_info.heat= f32(steps)/24.0;
|
||
#endif
|
||
return false;}
|
||
fn screenSpaceShadow(csOrigin: vec3f,csDirection: vec3f,csZBufferSize: vec2f,
|
||
nearPlaneZ: f32,noise: f32)->f32 {var csZDir: f32=select(-1.0,1.0,uniforms.projMtx[2][2]>0.0);var ssSamples: f32=SSSsamples;var ssMaxDist: f32=SSSmaxDistance;var ssStride: f32=SSSstride;var ssThickness: f32=SSSthickness;var rayLength: f32 =
|
||
select(ssMaxDist,(nearPlaneZ-csOrigin.z)/csDirection.z,
|
||
csZDir*(csOrigin.z+ssMaxDist*csDirection.z)<csZDir*nearPlaneZ);var csEndPoint: vec3f=csOrigin+rayLength*csDirection;var H0: vec4f=uniforms.projMtx* vec4f(csOrigin,1.0);var H1: vec4f=uniforms.projMtx* vec4f(csEndPoint,1.0);
|
||
#ifndef IS_NDC_HALF_ZRANGE
|
||
var Z0=(0.5*H0.z/H0.w+0.5);var Z1=(0.5*H1.z/H1.w+0.5);
|
||
#else
|
||
var Z0=(H0.z/H0.w);var Z1=(H1.z/H1.w);
|
||
#endif
|
||
var P0=csZBufferSize*(0.5*H0.xy/H0.w+0.5);var P1=csZBufferSize*(0.5*H1.xy/H1.w+0.5);P1+= vec2f(select(0.0,0.01,distanceSquared(P0,P1)<0.0001));var delta: vec2f=P1-P0;var permute: bool=false;if (abs(delta.x)<abs(delta.y)) {permute=true;P0=P0.yx;P1=P1.yx;delta=delta.yx;}
|
||
var stepDirection: f32=sign(delta.x);var invdx: f32=stepDirection/delta.x;var dP: vec2f=ssStride* vec2f(stepDirection,invdx*delta.y);var dZ=ssStride*invdx*(Z1-Z0);var opacity: f32=0.0;var P: vec2f=P0+noise*dP;var Z=Z0+noise*dZ;var end: f32=P1.x*stepDirection;Z+=dZ;for (var stepCount: f32=0.0;
|
||
opacity<1.0 && P.x*stepDirection<end && stepCount<ssSamples;stepCount+=1) {
|
||
var coords=vec2i(select(P,P.yx,permute));var sceneDepth=textureLoad(depthSampler,coords,0).x;var thicknessScale=pow(1.0-sceneDepth,1.6);opacity +=
|
||
max(opacity,step(Z+dZ,sceneDepth+thicknessScale*ssThickness) *
|
||
step(sceneDepth,Z));P+=dP;Z+=dZ;}
|
||
return opacity;}
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
fn voxelShadow(wsOrigin: vec3f,wsDirection: vec3f,wsNormal: vec3f,
|
||
DitherNoise: vec2f,
|
||
voxel_march_diagnostic_info: ptr<function,VoxelMarchDiagnosticInfo>)->f32 {
|
||
#else
|
||
fn voxelShadow(wsOrigin: vec3f,wsDirection: vec3f,wsNormal: vec3f,
|
||
DitherNoise: vec2f)->f32 {
|
||
#endif
|
||
var vxResolution: f32=f32(textureDimensions(voxelGridSampler,0).x);var T: vec3f;var B: vec3f;genTB(wsDirection,&T,&B);var DitherXY: vec2f=sqrt(DitherNoise.x)* vec2f(cos(2.0*PI*DitherNoise.y),
|
||
sin(2.0*PI*DitherNoise.y));var Dithering: vec3f =
|
||
(2.0*wsNormal+3.0*wsDirection+DitherXY.x*T+DitherXY.y*B) /
|
||
vxResolution;var O: vec3f=0.5*wsOrigin+0.5+Dithering;var ray_vs=make_ray(O,wsDirection,0.0,10.0);var voxel_aabb: AABB3f;voxel_aabb.m_min=vec3f(0);voxel_aabb.m_max=vec3f(1);var near: f32=0;var far: f32=0;if (!ray_box_intersection(voxel_aabb,ray_vs,&near,&far)) {return 0.0;}
|
||
ray_vs.t_min=max(ray_vs.t_min,near);ray_vs.t_max=min(ray_vs.t_max,far);
|
||
#if VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
return select(0.0f,1.0f,anyHitVoxels(ray_vs,voxel_march_diagnostic_info));
|
||
#else
|
||
return select(0.0f,1.0f,anyHitVoxels(ray_vs));
|
||
#endif
|
||
}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var nbDirs=u32(SHADOWdirs);var frameId=u32(SHADOWframe);var downscale=i32(SHADOWdownscale);var envRot: f32=SHADOWenvRot;var Resolution: vec2f= vec2f(textureDimensions(depthSampler,0));var currentPixel=vec2i(fragmentInputs.vUV*Resolution);var PixelCoord=vec2i(vec2f(currentPixel*downscale)+PixelOffset.xy);var GlobalIndex =
|
||
(frameId*u32(Resolution.y)+u32(PixelCoord.y))*u32(Resolution.x) +
|
||
u32(PixelCoord.x);var N: vec3f=textureLoad(worldNormalSampler,PixelCoord,0).xyz;N=N* vec3f(2.0)-vec3f(1.0);if (length(N)<0.01) {fragmentOutputs.color=vec4f(1.0,1.0,0.0,1.0);return fragmentOutputs;}
|
||
var normalizedRotation: f32=envRot/(2.0*PI);var depth: f32=textureLoad(depthSampler,PixelCoord,0).x;
|
||
#ifndef IS_NDC_HALF_ZRANGE
|
||
depth=depth*2.0-1.0;
|
||
#endif
|
||
var temp: vec2f=(vec2f(PixelCoord)+vec2f(0.5))*2.0/Resolution-vec2f(1.0);var temp2: vec2f=fragmentInputs.vUV*vec2f(2.0)-vec2f(1.0);var VP: vec4f=uniforms.invProjMtx*vec4f(temp.x,-temp.y,depth,1.0);VP/=VP.w;N=normalize(N);var noise: vec3f=textureLoad(blueNoiseSampler,PixelCoord & vec2i(0xFF),0).xyz;noise.z=fract(noise.z+goldenSequence(frameId*nbDirs));
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
var heat: f32=0.0f;
|
||
#endif
|
||
var shadowAccum: f32=0.0;for (var i: u32=0; i<nbDirs; i++) {var dirId: u32=nbDirs*GlobalIndex+i;var L: vec4f;{var r: vec2f=plasticSequence(frameId*nbDirs+i);r=fract(r+ vec2f(2.0)*abs(noise.xy- vec2f(0.5)));var T: vec2f;T.x=textureSampleLevel(icdfxSampler,icdfxSamplerSampler,vec2f(r.x,0.0),0.0).x;T.y=textureSampleLevel(icdfySampler,icdfySamplerSampler,vec2f(T.x,r.y),0.0).x;T.x-=normalizedRotation;L= vec4f(uv_to_normal(T),0);}
|
||
var edge_tint_const=-0.001;var cosNL: f32=dot(N,L.xyz);var opacity: f32=select(0.0,1.0,cosNL<edge_tint_const);if (cosNL>edge_tint_const) {var VP2: vec4f=VP;VP2.y*=-1.0;var unormWP: vec4f=uniforms.invViewMtx*VP2;var WP: vec3f=(uniforms.wsNormalizationMtx*unormWP).xyz;var vxNoise: vec2f =
|
||
vec2f(uint2float(hash(dirId*2)),uint2float(hash(dirId*2+1)));
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
VoxelMarchDiagnosticInfo voxel_march_diagnostic_info;opacity=max(opacity,
|
||
uniforms.shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise,
|
||
voxel_march_diagnostic_info));heat+=voxel_march_diagnostic_info.heat;
|
||
#else
|
||
opacity =
|
||
max(opacity,uniforms.shadowOpacity.x*voxelShadow(WP,L.xyz,N,vxNoise));
|
||
#endif
|
||
var VL: vec3f=(uniforms.viewMtx*L).xyz;var nearPlaneZ: f32 =
|
||
-uniforms.projMtx[3][2]/uniforms.projMtx[2][2];
|
||
var ssShadow: f32=uniforms.shadowOpacity.y *
|
||
screenSpaceShadow(VP2.xyz,VL,Resolution,nearPlaneZ,
|
||
abs(2.0*noise.z-1.0));opacity=max(opacity,ssShadow);shadowAccum+=min(1.0-opacity,smoothstep(-0.1,0.2,cosNL));} else {shadowAccum+=min(1.0-opacity,smoothstep(-0.1,0.2,cosNL));}
|
||
noise.z=fract(noise.z+GOLD);}
|
||
#ifdef VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION
|
||
fragmentOutputs.color =
|
||
vec4f(shadowAccum/ f32(nbDirs),heat/ f32(nbDirs),0.0,1.0);
|
||
#else
|
||
fragmentOutputs.color= vec4f(shadowAccum/ f32(nbDirs),0.0,0.0,1.0);
|
||
#endif
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},24726:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsCdfxPixelShaderWGSL:()=>o});var n="iblShadowsCdfxPixelShader",i=`#define PI 3.1415927
|
||
varying vUV: vec2f;var cdfy: texture_2d<f32>;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var cdfyRes=textureDimensions(cdfy,0);var currentPixel=vec2u(fragmentInputs.position.xy);var cdfx: f32=0.0;for (var x: u32=1; x<=currentPixel.x; x++) {cdfx+=textureLoad(cdfy, vec2u(x-1,cdfyRes.y-1),0).x;}
|
||
fragmentOutputs.color= vec4f( vec3f(cdfx),1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},23387:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsCdfyPixelShaderWGSL:()=>o});var n="iblShadowsCdfyPixelShader",i=`#define PI 3.1415927
|
||
varying vUV: vec2f;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
var iblSourceSampler: sampler;var iblSource: texture_cube<f32>;
|
||
#else
|
||
var iblSourceSampler: sampler;var iblSource: texture_2d<f32>;
|
||
#endif
|
||
uniform iblHeight: i32;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
fn equirectangularToCubemapDirection(uv: vec2f)->vec3f {var longitude: f32=uv.x*2.0*PI-PI;var latitude: f32=PI*0.5-uv.y*PI;var direction: vec3f;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}
|
||
fn fetchCube(uv: vec2f)->f32 {var direction: vec3f=equirectangularToCubemapDirection(uv);return sin(PI*uv.y)*dot(textureSampleLevel(iblSource,iblSourceSampler,direction,0.0).rgb,
|
||
vec3f(0.3,0.6,0.1));}
|
||
#else
|
||
fn fetchPanoramic(Coords: vec2i,envmapHeight: f32)->f32 {return sin(PI*( f32(Coords.y)+0.5)/envmapHeight) *
|
||
dot(textureLoad(iblSource,Coords,0).rgb, vec3f(0.3,0.6,0.1));}
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var coords: vec2i= vec2i(fragmentInputs.position.xy);var cdfy: f32=0.0;for (var y: i32=1; y<=coords.y; y++) {
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
var uv: vec2f= vec2f(input.vUV.x,( f32(y-1)+0.5)/ f32(uniforms.iblHeight));cdfy+=fetchCube(uv);
|
||
#else
|
||
cdfy+=fetchPanoramic( vec2i(coords.x,y-1), f32(uniforms.iblHeight));
|
||
#endif
|
||
}
|
||
fragmentOutputs.color= vec4f(cdfy,0.0,0.0,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},83898:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsCombinePixelShaderWGSL:()=>o});var n="iblShadowsCombinePixelShader",i=`varying vUV: vec2f;var sceneTextureSampler: sampler;var sceneTexture: texture_2d<f32>;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform shadowOpacity: f32;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var color: vec3f=textureSample(sceneTexture,sceneTextureSampler,input.vUV).rgb;var shadow: vec3f=textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb;var shadowValue: f32=mix(1.0,shadow.x,uniforms.shadowOpacity);fragmentOutputs.color=vec4f(color*shadowValue,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},84659:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsIcdfxPixelShaderWGSL:()=>o});var n="iblShadowsIcdfxPixelShader",i=`#define PI 3.1415927
|
||
varying vUV: vec2f;var cdfx: texture_2d<f32>;fn fetchCDF(x: u32)->f32 {return textureLoad(cdfx, vec2u(x,0),0).x;}
|
||
fn bisect(size: u32,targetValue: f32)->f32
|
||
{var a: u32=0;var b=size-1;while (b-a>1) {var c: u32=(a+b)>>1;if (fetchCDF(c)<targetValue) {a=c;}
|
||
else {b=c;}}
|
||
return mix( f32(a), f32(b),(targetValue-fetchCDF(a))/(fetchCDF(b)-fetchCDF(a)))/ f32(size-1);}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var cdfSize: vec2u=textureDimensions(cdfx,0);var cdfWidth: u32=cdfSize.x;var icdfWidth: u32=cdfWidth-1;var currentPixel: vec2u= vec2u(fragmentInputs.position.xy);if (currentPixel.x==0)
|
||
{fragmentOutputs.color= vec4f(0.0);}
|
||
else if (currentPixel.x==icdfWidth-1) {fragmentOutputs.color= vec4f(1.0);} else {var targetValue: f32=fetchCDF(cdfWidth-1)*input.vUV.x;fragmentOutputs.color= vec4f( vec3f(bisect(cdfWidth,targetValue)),1.0);}}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},37326:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsIcdfyPixelShaderWGSL:()=>o});var n="iblShadowsIcdfyPixelShader",i=`#define PI 3.1415927
|
||
varying vUV: vec2f;var cdfy: texture_2d<f32>;fn fetchCDF(y: u32,invocationId: u32)->f32 {return textureLoad(cdfy, vec2u(invocationId,y),0).x;}
|
||
fn bisect(size: u32,targetValue: f32,invocationId: u32)->f32
|
||
{var a: u32=0;var b=size-1;while (b-a>1) {var c=(a+b)>>1;if (fetchCDF(c,invocationId)<targetValue) {a=c;}
|
||
else {b=c;}}
|
||
return mix( f32(a), f32(b),(targetValue-fetchCDF(a,invocationId))/(fetchCDF(b,invocationId)-fetchCDF(a,invocationId)))/ f32(size-1);}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var cdfSize: vec2u=textureDimensions(cdfy,0);var cdfHeight: u32=cdfSize.y;var currentPixel: vec2u= vec2u(fragmentInputs.position.xy);if (currentPixel.y==0) {fragmentOutputs.color= vec4f(0.0);}
|
||
else if (currentPixel.y==cdfHeight-2) {fragmentOutputs.color= vec4f(1.0);} else {var targetValue: f32=fetchCDF(cdfHeight-1,currentPixel.x)*input.vUV.y;fragmentOutputs.color= vec4f( vec3f(bisect(cdfHeight,targetValue,currentPixel.x)),1.0);}}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},55627:(r,t,e)=>{e.r(t),e.d(t,{iblShadowsImportanceSamplingDebugPixelShaderWGSL:()=>o});var n="iblShadowsImportanceSamplingDebugPixelShader",i=`#define PI 3.1415927
|
||
varying vUV: vec2f;var cdfySampler: sampler;var cdfy: texture_2d<f32>;var icdfySampler: sampler;var icdfy: texture_2d<f32>;var cdfxSampler: sampler;var cdfx: texture_2d<f32>;var icdfxSampler: sampler;var icdfx: texture_2d<f32>;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
var iblSourceSampler: sampler;var iblSource: texture_cube<f32>;
|
||
#else
|
||
var iblSourceSampler: sampler;var iblSource: texture_2d<f32>;
|
||
#endif
|
||
var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
#define cdfyVSize 0.4
|
||
#define cdfxVSize 0.1
|
||
#define cdfyHSize 0.5
|
||
uniform sizeParams: vec4f;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
fn equirectangularToCubemapDirection(uv: vec2f)->vec3f {var longitude: f32=uv.x*2.0*PI-PI;var latitude: f32=PI*0.5-uv.y*PI;var direction: vec3f;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
var colour: vec3f= vec3f(0.0);var uv: vec2f =
|
||
vec2f((uniforms.sizeParams.x+input.vUV.x)*uniforms.sizeParams.z,(uniforms.sizeParams.y+input.vUV.y)*uniforms.sizeParams.w);var backgroundColour: vec3f=textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb;const iblStart: f32=1.0-cdfyVSize;const cdfyStart: f32=1.0-2.0*cdfyVSize;const cdfxStart: f32=1.0-2.0*cdfyVSize-cdfxVSize;const icdfxStart: f32=1.0-2.0*cdfyVSize-2.0*cdfxVSize;
|
||
#ifdef IBL_USE_CUBE_MAP
|
||
var direction: vec3f=equirectangularToCubemapDirection(
|
||
(uv- vec2f(0.0,iblStart))* vec2f(1.0,1.0/cdfyVSize));var iblColour: vec3f=textureSampleLevel(iblSource,iblSourceSampler,direction,0.0).rgb;
|
||
#else
|
||
var iblColour: vec3f=textureSample(iblSource,iblSourceSampler,(uv- vec2f(0.0,iblStart)) *
|
||
vec2f(1.0,1.0/cdfyVSize))
|
||
.rgb;
|
||
#endif
|
||
var cdfyColour: f32 =
|
||
textureSample(cdfy,cdfySampler,(uv- vec2f(0.0,cdfyStart))* vec2f(2.0,1.0/cdfyVSize)).r;var icdfyColour: f32 =
|
||
textureSample(icdfy,icdfySampler,(uv- vec2f(0.5,cdfyStart))* vec2f(2.0,1.0/cdfyVSize)).r;var cdfxColour: f32 =
|
||
textureSample(cdfx,cdfxSampler,(uv- vec2f(0.0,cdfxStart))* vec2f(1.0,1.0/cdfxVSize)).r;var icdfxColour: f32=textureSample(icdfx,icdfxSampler,(uv- vec2f(0.0,icdfxStart)) *
|
||
vec2f(1.0,1.0/cdfxVSize)).r;if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {colour=backgroundColour;} else if (uv.y>iblStart) {colour+=iblColour;} else if (uv.y>cdfyStart && uv.x<0.5) {colour.r+=0.003*cdfyColour;} else if (uv.y>cdfyStart && uv.x>0.5) {colour.r+=icdfyColour;} else if (uv.y>cdfxStart) {colour.r+=0.00003*cdfxColour;} else if (uv.y>icdfxStart) {colour.r+=icdfxColour;}
|
||
fragmentOutputs.color =vec4(mix(colour,backgroundColour,0.5),1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},30738:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGridPixelShaderWGSL:()=>o});var n="iblVoxelGridPixelShader",i=`varying vNormalizedPosition: vec3f;uniform nearPlane: f32;uniform farPlane: f32;uniform stepSize: f32;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var normPos: vec3f=input.vNormalizedPosition.xyz;if (normPos.z<uniforms.nearPlane || normPos.z>uniforms.farPlane) {discard;}
|
||
fragmentOutputs.fragData0=select(vec4f(0.0),vec4f(1.0),normPos.z<uniforms.nearPlane+uniforms.stepSize);fragmentOutputs.fragData1=select(vec4f(0.0),vec4f(1.0),normPos.z>=uniforms.nearPlane+uniforms.stepSize && normPos.z<uniforms.nearPlane+2.0*uniforms.stepSize);fragmentOutputs.fragData2=select(vec4f(0.0),vec4f(1.0),normPos.z>=uniforms.nearPlane+2.0*uniforms.stepSize && normPos.z<uniforms.nearPlane+3.0*uniforms.stepSize);fragmentOutputs.fragData3=select(vec4f(0.0),vec4f(1.0),normPos.z>=uniforms.nearPlane+3.0*uniforms.stepSize && normPos.z<uniforms.nearPlane+4.0*uniforms.stepSize);
|
||
#if MAX_DRAW_BUFFERS>4
|
||
fragmentOutputs.fragData4=select(vec4f(0.0),vec4f(1.0),normPos.z>=uniforms.nearPlane+4.0*uniforms.stepSize && normPos.z<uniforms.nearPlane+5.0*uniforms.stepSize);fragmentOutputs.fragData5=select(vec4f(0.0),vec4f(1.0),normPos.z>=uniforms.nearPlane+5.0*uniforms.stepSize && normPos.z<uniforms.nearPlane+6.0*uniforms.stepSize);fragmentOutputs.fragData6=select(vec4f(0.0),vec4f(1.0),normPos.z>=uniforms.nearPlane+6.0*uniforms.stepSize && normPos.z<uniforms.nearPlane+7.0*uniforms.stepSize);fragmentOutputs.fragData7=select(vec4f(0.0),vec4f(1.0),normPos.z>=uniforms.nearPlane+7.0*uniforms.stepSize && normPos.z<uniforms.nearPlane+8.0*uniforms.stepSize);
|
||
#endif
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},90564:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGridVertexShaderWGSL:()=>o});var n="iblVoxelGridVertexShader",i=`attribute position: vec3f;attribute normal: vec3f;varying vNormalizedPosition: vec3f;uniform world: mat4x4f;uniform invWorldScale: mat4x4f;uniform viewMatrix: mat4x4f;@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {vertexOutputs.position=uniforms.viewMatrix*uniforms.invWorldScale*uniforms.world* vec4f(input.position,1.);vertexOutputs.vNormalizedPosition=vertexOutputs.position.xyz*0.5+0.5;
|
||
#ifdef IS_NDC_HALF_ZRANGE
|
||
vertexOutputs.position=vec4f(vertexOutputs.position.x,vertexOutputs.position.y,vertexOutputs.position.z*0.5+0.5,vertexOutputs.position.w);
|
||
#endif
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},39768:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGrid2dArrayDebugPixelShaderWGSL:()=>o});var n="iblVoxelGrid2dArrayDebugPixelShader",i=`varying vUV: vec2f;var voxelTextureSampler: sampler;var voxelTexture: texture_3d<f32>;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform slice: i32;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var size: vec3u=textureDimensions(voxelTexture,0);var dimension: f32=sqrt( f32(size.z));var samplePos: vec2f=fract(input.vUV.xy* vec2f(dimension));var sampleIndex: u32= u32(floor(input.vUV.x* f32(dimension))+floor(input.vUV.y* f32(dimension))*dimension);var color=textureSample(voxelTexture,voxelTextureSampler, vec3f(samplePos.xy,sampleIndex)).rrr;color+=textureSample(textureSampler,textureSamplerSampler,input.vUV.xy).rgb;fragmentOutputs.color=vec4f(color,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},42362:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelGrid3dDebugPixelShaderWGSL:()=>o});var n="iblVoxelGrid3dDebugPixelShader",i=`varying vUV: vec2f;var voxelTextureSampler: sampler;var voxelTexture: texture_3d<f32>;var voxelSlabTextureSampler: sampler;var voxelSlabTexture: texture_2d<f32>;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform sizeParams: vec4f;
|
||
#define offsetX uniforms.sizeParams.x
|
||
#define offsetY uniforms.sizeParams.y
|
||
#define widthScale uniforms.sizeParams.z
|
||
#define heightScale uniforms.sizeParams.w
|
||
uniform mipNumber: f32;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var uv: vec2f =
|
||
vec2f((offsetX+input.vUV.x)*widthScale,(offsetY+input.vUV.y)*heightScale);var background: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);var voxelSlab: vec4f=textureSample(voxelSlabTexture,voxelSlabTextureSampler,input.vUV);var size: vec3u=textureDimensions(voxelTexture, i32(uniforms.mipNumber));var dimension: f32=ceil(sqrt( f32(size.z)));var samplePos: vec2f=fract(uv.xy* vec2f(dimension));var sampleIndex: u32= u32(floor(uv.x* f32(dimension)) +
|
||
floor(uv.y* f32(dimension))*dimension);var mip_separator: f32=0.0;if (samplePos.x<0.01 || samplePos.y<0.01) {mip_separator=1.0;}
|
||
var outBounds: bool=select(false,true,sampleIndex>size.z-1);sampleIndex=clamp(sampleIndex,0,size.z-1);var samplePosInt: vec2i= vec2i(samplePos.xy* vec2f(size.xy));var voxel: vec3f=textureLoad(voxelTexture,
|
||
vec3i(i32(samplePosInt.x),i32(samplePosInt.y),i32(sampleIndex)),
|
||
i32(uniforms.mipNumber)).rgb;if (uv.x<0.0 || uv.x>1.0 || uv.y<0.0 || uv.y>1.0) {fragmentOutputs.color=background;} else {if (outBounds) {voxel= vec3f(0.15,0.0,0.0);} else {if (voxel.r>0.001) {voxel.g=1.0;}
|
||
voxel.r+=mip_separator;}
|
||
fragmentOutputs.color=vec4f(mix(background.rgb,voxelSlab.rgb,voxelSlab.a)+voxel,1.0);}}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},56809:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelSlabDebugPixelShaderWGSL:()=>o});var n="iblVoxelSlabDebugPixelShader",i=`varying vNormalizedPosition: vec3f;uniform nearPlane: f32;uniform farPlane: f32;uniform stepSize: f32;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var normPos: vec3f=input.vNormalizedPosition.xyz;var chunkSize: f32=uniforms.stepSize* f32(MAX_DRAW_BUFFERS);var numChunks: f32=1.0/chunkSize;var positionInChunk: f32=fract(normPos.z/chunkSize);var slab: f32=floor(positionInChunk* f32(MAX_DRAW_BUFFERS)) /
|
||
f32(MAX_DRAW_BUFFERS);if (normPos.x<0.0 || normPos.y<0.0 || normPos.z<0.0 ||
|
||
normPos.x>1.0 || normPos.y>1.0 || normPos.z>1.0) {fragmentOutputs.color= vec4f(0.0,0.0,0.0,0.0);} else {fragmentOutputs.color= vec4f(slab,0.0,0.0,0.75);}}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},64015:(r,t,e)=>{e.r(t),e.d(t,{iblVoxelSlabDebugVertexShaderWGSL:()=>o});var n="iblVoxelSlabDebugVertexShader",i=`attribute position: vec3f;varying vNormalizedPosition: vec3f;uniform world: mat4x4f;uniform invWorldScale: mat4x4f;uniform cameraViewMatrix: mat4x4f;uniform projection: mat4x4f;uniform viewMatrix: mat4x4f;@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {var worldPosition: vec4f=(uniforms.world* vec4f(input.position,1.));vertexOutputs.position=uniforms.projection*uniforms.cameraViewMatrix*worldPosition;vertexOutputs.vNormalizedPosition=(uniforms.viewMatrix*uniforms.invWorldScale*worldPosition).rgb;vertexOutputs.vNormalizedPosition=vertexOutputs.vNormalizedPosition* vec3f(0.5)+ vec3f(0.5);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},68805:(r,t,e)=>{e.r(t),e.d(t,{imageProcessingPixelShaderWGSL:()=>a});var n=e(98519),i=(e(86320),e(17393),e(4661),"imageProcessingPixelShader"),o=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
#include<imageProcessingDeclaration>
|
||
#include<helperFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var result: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);
|
||
#ifdef IMAGEPROCESSING
|
||
#ifndef FROMLINEARSPACE
|
||
result=vec4f(toLinearSpaceVec3(result.rgb),result.a);
|
||
#endif
|
||
result=applyImageProcessing(result);
|
||
#else
|
||
#ifdef FROMLINEARSPACE
|
||
result=applyImageProcessing(result);
|
||
#endif
|
||
#endif
|
||
fragmentOutputs.color=result;}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},76832:(r,t,e)=>{e.r(t),e.d(t,{kernelBlurPixelShaderWGSL:()=>s});var n=e(98519),i=(e(14782),e(68298),"kernelBlurFragment");n.l.IncludesShadersStoreWGSL[i]=`#ifdef DOF
|
||
factor=sampleCoC(fragmentInputs.sampleCoord{X});
|
||
computedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight;
|
||
#else
|
||
computedWeight=KERNEL_WEIGHT{X};
|
||
#endif
|
||
#ifdef PACKEDFLOAT
|
||
blend+=unpack(textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCoord{X}))*computedWeight;
|
||
#else
|
||
blend+=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCoord{X})*computedWeight;
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.kernelBlurFragment2=`#ifdef DOF
|
||
factor=sampleCoC(fragmentInputs.sampleCenter+uniforms.delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight;
|
||
#else
|
||
computedWeight=KERNEL_DEP_WEIGHT{X};
|
||
#endif
|
||
#ifdef PACKEDFLOAT
|
||
blend+=unpack(textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCenter+uniforms.delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
|
||
#else
|
||
blend+=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCenter+uniforms.delta*KERNEL_DEP_OFFSET{X})*computedWeight;
|
||
#endif
|
||
`;var o="kernelBlurPixelShader",a=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform delta: vec2f;varying sampleCenter: vec2f;
|
||
#ifdef DOF
|
||
var circleOfConfusionSamplerSampler: sampler;var circleOfConfusionSampler: texture_2d<f32>;fn sampleCoC(offset: vec2f)->f32 {var coc: f32=textureSample(circleOfConfusionSampler,circleOfConfusionSamplerSampler,offset).r;return coc; }
|
||
#endif
|
||
#include<kernelBlurVaryingDeclaration>[0..varyingCount]
|
||
#ifdef PACKEDFLOAT
|
||
#include<packingFunctions>
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var computedWeight: f32=0.0;
|
||
#ifdef PACKEDFLOAT
|
||
var blend: f32=0.;
|
||
#else
|
||
var blend: vec4f= vec4f(0.);
|
||
#endif
|
||
#ifdef DOF
|
||
var sumOfWeights: f32=CENTER_WEIGHT;
|
||
var factor: f32=0.0;
|
||
#ifdef PACKEDFLOAT
|
||
blend+=unpack(textureSample(textureSampler,textureSamplerSampler,input.sampleCenter))*CENTER_WEIGHT;
|
||
#else
|
||
blend+=textureSample(textureSampler,textureSamplerSampler,input.sampleCenter)*CENTER_WEIGHT;
|
||
#endif
|
||
#endif
|
||
#include<kernelBlurFragment>[0..varyingCount]
|
||
#include<kernelBlurFragment2>[0..depCount]
|
||
#ifdef PACKEDFLOAT
|
||
fragmentOutputs.color=pack(blend);
|
||
#else
|
||
fragmentOutputs.color=blend;
|
||
#endif
|
||
#ifdef DOF
|
||
fragmentOutputs.color/=sumOfWeights;
|
||
#endif
|
||
}`;n.l.ShadersStoreWGSL[o]=a;var s={name:o,shader:a}},7621:(r,t,e)=>{e.r(t),e.d(t,{kernelBlurVertexShaderWGSL:()=>s});var n=e(98519),i=(e(14782),"kernelBlurVertex");n.l.IncludesShadersStoreWGSL[i]="vertexOutputs.sampleCoord{X}=vertexOutputs.sampleCenter+uniforms.delta*KERNEL_OFFSET{X};";var o="kernelBlurVertexShader",a=`attribute position: vec2f;uniform delta: vec2f;varying sampleCenter: vec2f;
|
||
#include<kernelBlurVaryingDeclaration>[0..varyingCount]
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {const madd: vec2f= vec2f(0.5,0.5);
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vertexOutputs.sampleCenter=(input.position*madd+madd);
|
||
#include<kernelBlurVertex>[0..varyingCount]
|
||
vertexOutputs.position= vec4f(input.position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[o]=a;var s={name:o,shader:a}},2652:(r,t,e)=>{e.r(t),e.d(t,{layerPixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),"layerPixelShader"),o=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform color: vec4f;
|
||
#include<helperFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
var baseColor: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);
|
||
#ifdef LINEAR
|
||
baseColor=vec4f(toGammaSpace(baseColor.rgb),baseColor.a);
|
||
#endif
|
||
#ifdef ALPHATEST
|
||
if (baseColor.a<0.4)
|
||
discard;
|
||
#endif
|
||
fragmentOutputs.color=baseColor*uniforms.color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},34438:(r,t,e)=>{e.r(t),e.d(t,{layerVertexShaderWGSL:()=>o});var n="layerVertexShader",i=`attribute position: vec2f;uniform scale: vec2f;uniform offset: vec2f;uniform textureMatrix: mat4x4f;varying vUV: vec2f;const madd: vec2f= vec2f(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
var shiftedPosition: vec2f=input.position*uniforms.scale+uniforms.offset;vertexOutputs.vUV=(uniforms.textureMatrix* vec4f(shiftedPosition*madd+madd,1.0,0.0)).xy;vertexOutputs.position= vec4f(shiftedPosition,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},89967:(r,t,e)=>{e.r(t),e.d(t,{lensFlarePixelShaderWGSL:()=>o});var n="lensFlarePixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform color: vec4f;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
var baseColor: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);fragmentOutputs.color=baseColor*uniforms.color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},51093:(r,t,e)=>{e.r(t),e.d(t,{lensFlareVertexShaderWGSL:()=>o});var n="lensFlareVertexShader",i=`attribute position: vec2f;uniform viewportMatrix: mat4x4f;varying vUV: vec2f;const madd: vec2f= vec2f(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vertexOutputs.vUV=input.position*madd+madd;vertexOutputs.position=uniforms.viewportMatrix* vec4f(input.position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},34873:(r,t,e)=>{e.r(t),e.d(t,{linePixelShaderWGSL:()=>a});var n=e(98519),i=(e(20502),e(38197),e(56897),e(30032),"linePixelShader"),o=`#include<clipPlaneFragmentDeclaration>
|
||
uniform color: vec4f;
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<logDepthFragment>
|
||
#include<clipPlaneFragment>
|
||
fragmentOutputs.color=uniforms.color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},63327:(r,t,e)=>{e.r(t),e.d(t,{lineVertexShaderWGSL:()=>a});var n=e(98519),i=(e(63866),e(9436),e(36644),e(40647),e(38197),e(21310),e(63002),e(55607),"lineVertexShader"),o=`#define ADDITIONAL_VERTEX_DECLARATION
|
||
#include<instancesDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
attribute position: vec3f;attribute normal: vec4f;uniform width: f32;uniform aspectRatio: f32;
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
#include<instancesVertex>
|
||
var worldViewProjection: mat4x4f=scene.viewProjection*finalWorld;var viewPosition: vec4f=worldViewProjection* vec4f(input.position,1.0);var viewPositionNext: vec4f=worldViewProjection* vec4f(input.normal.xyz,1.0);var currentScreen: vec2f=viewPosition.xy/viewPosition.w;var nextScreen: vec2f=viewPositionNext.xy/viewPositionNext.w;currentScreen=vec2f(currentScreen.x*uniforms.aspectRatio,currentScreen.y);nextScreen=vec2f(nextScreen.x*uniforms.aspectRatio,nextScreen.y);var dir: vec2f=normalize(nextScreen-currentScreen);var normalDir: vec2f= vec2f(-dir.y,dir.x);normalDir*=uniforms.width/2.0;normalDir=vec2f(normalDir.x/uniforms.aspectRatio,normalDir.y);var offset: vec4f= vec4f(normalDir*input.normal.w,0.0,0.0);vertexOutputs.position=viewPosition+offset;
|
||
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
|
||
var worldPos: vec4f=finalWorld*vec4f(input.position,1.0);
|
||
#include<clipPlaneVertex>
|
||
#endif
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},40002:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererPixelShaderWGSL:()=>o});var n="meshUVSpaceRendererPixelShader",i=`varying vDecalTC: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {if (input.vDecalTC.x<0. || input.vDecalTC.x>1. || input.vDecalTC.y<0. || input.vDecalTC.y>1.) {discard;}
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vDecalTC);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},12436:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererVertexShaderWGSL:()=>a});var n=e(98519),i=(e(45699),e(27279),e(73683),e(68478),e(63866),e(98819),e(77320),e(21310),e(3641),e(86615),"meshUVSpaceRendererVertexShader"),o=`attribute position: vec3f;attribute normal: vec3f;attribute uv: vec2f;uniform projMatrix: mat4x4f;varying vDecalTC: vec2f;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesDeclaration>
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=input.position;var normalUpdated: vec3f=input.normal;
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);var normWorldSM: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz);var vNormalW: vec3f;
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
vNormalW=normalUpdated/ vec3f(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normWorldSM=transposeMat3(inverseMat3(normWorldSM));
|
||
#endif
|
||
vNormalW=normalize(normWorldSM*normalUpdated);
|
||
#endif
|
||
var normalView: vec3f=normalize((uniforms.projMatrix* vec4f(vNormalW,0.0)).xyz);var decalTC: vec3f=(uniforms.projMatrix*worldPos).xyz;vertexOutputs.vDecalTC=decalTC.xy;vertexOutputs.position=vec4f(input.uv*2.0-1.0,select(decalTC.z,2.,normalView.z>0.0),1.0);}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},42769:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererFinaliserPixelShaderWGSL:()=>o});var n="meshUVSpaceRendererFinaliserPixelShader",i=`#define DISABLE_UNIFORMITY_ANALYSIS
|
||
varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var maskTextureSamplerSampler: sampler;var maskTextureSampler: texture_2d<f32>;uniform textureSize: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var mask: vec4f=textureSample(maskTextureSampler,maskTextureSamplerSampler,input.vUV).rgba;if (mask.r>0.5) {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);} else {var texelSize: vec2f=4.0/uniforms.textureSize;var uv_p01: vec2f=input.vUV+ vec2f(-1.0,0.0)*texelSize;var uv_p21: vec2f=input.vUV+ vec2f(1.0,0.0)*texelSize;var uv_p10: vec2f=input.vUV+ vec2f(0.0,-1.0)*texelSize;var uv_p12: vec2f=input.vUV+ vec2f(0.0,1.0)*texelSize;var mask_p01: f32=textureSample(maskTextureSampler,maskTextureSamplerSampler,uv_p01).r;var mask_p21: f32=textureSample(maskTextureSampler,maskTextureSamplerSampler,uv_p21).r;var mask_p10: f32=textureSample(maskTextureSampler,maskTextureSamplerSampler,uv_p10).r;var mask_p12: f32=textureSample(maskTextureSampler,maskTextureSamplerSampler,uv_p12).r;var col: vec4f= vec4f(0.0,0.0,0.0,0.0);var total_weight: f32=0.0;if (mask_p01>0.5) {col+=textureSample(textureSampler,textureSamplerSampler,uv_p01);total_weight+=1.0;}
|
||
if (mask_p21>0.5) {col+=textureSample(textureSampler,textureSamplerSampler,uv_p21);total_weight+=1.0;}
|
||
if (mask_p10>0.5) {col+=textureSample(textureSampler,textureSamplerSampler,uv_p10);total_weight+=1.0;}
|
||
if (mask_p12>0.5) {col+=textureSample(textureSampler,textureSamplerSampler,uv_p12);total_weight+=1.0;}
|
||
if (total_weight>0.0) {fragmentOutputs.color=col/total_weight;} else {fragmentOutputs.color=col;}}}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},583:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererFinaliserVertexShaderWGSL:()=>o});var n="meshUVSpaceRendererFinaliserVertexShader",i=`attribute position: vec3f;attribute uv: vec2f;uniform worldViewProjection: mat4x4f;varying vUV: vec2f;@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {vertexOutputs.position=uniforms.worldViewProjection* vec4f(input.position,1.0);vertexOutputs.positionvUV=input.uv;}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},55139:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererMaskerPixelShaderWGSL:()=>o});var n="meshUVSpaceRendererMaskerPixelShader",i=`varying vUV: vec2f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color= vec4f(1.0,1.0,1.0,1.0);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},39721:(r,t,e)=>{e.r(t),e.d(t,{meshUVSpaceRendererMaskerVertexShaderWGSL:()=>o});var n="meshUVSpaceRendererMaskerVertexShader",i=`attribute uv: vec2f;varying vUV: vec2f;@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {vertexOutputs.position= vec4f( vec2f(input.uv.x,input.uv.y)*2.0-1.0,0.,1.0);vertexOutputs.vUV=input.uv;}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},70154:(r,t,e)=>{e.r(t),e.d(t,{motionBlurPixelShaderWGSL:()=>o});var n="motionBlurPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform motionStrength: f32;uniform motionScale: f32;uniform screenSize: vec2f;
|
||
#ifdef OBJECT_BASED
|
||
var velocitySamplerSampler: sampler;var velocitySampler: texture_2d<f32>;
|
||
#else
|
||
var depthSamplerSampler: sampler;var depthSampler: texture_2d<f32>;uniform inverseViewProjection: mat4x4f;uniform prevViewProjection: mat4x4f;uniform projection: mat4x4f;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#ifdef GEOMETRY_SUPPORTED
|
||
#ifdef OBJECT_BASED
|
||
var texelSize: vec2f=1.0/uniforms.screenSize;var velocityColor: vec4f=textureSample(velocitySampler,velocitySamplerSampler,input.vUV);velocityColor=vec4f(velocityColor.rg*2.0- vec2f(1.0),velocityColor.b,velocityColor.a);var velocity: vec2f= vec2f(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0))*velocityColor.a;velocity*=uniforms.motionScale*uniforms.motionStrength;var speed: f32=length(velocity/texelSize);var samplesCount: i32= i32(clamp(speed,1.0,SAMPLES));velocity=normalize(velocity)*texelSize;var hlim: f32= f32(-samplesCount)*0.5+0.5;var result: vec4f=textureSample(textureSampler,textureSamplerSampler, input.vUV);for (var i: i32=1; i< i32(SAMPLES); i++)
|
||
{if (i>=samplesCount) {break;}
|
||
var offset: vec2f=input.vUV+velocity*(hlim+ f32(i));
|
||
#if defined(WEBGPU)
|
||
result+=textureSampleLevel(textureSampler,textureSamplerSampler, offset,0.0);
|
||
#else
|
||
result+=textureSample(textureSampler,textureSamplerSampler, offset);
|
||
#endif
|
||
}
|
||
fragmentOutputs.color=vec4f(result.rgb/ f32(samplesCount),1.0);
|
||
#else
|
||
var texelSize: vec2f=1.0/uniforms.screenSize;var depth: f32=textureSample(depthSampler,depthSamplerSampler,input.vUV).r;depth=uniforms.projection[2].z+uniforms.projection[3].z/depth;
|
||
var cpos: vec4f= vec4f(input.vUV*2.0-1.0,depth,1.0);cpos=uniforms.inverseViewProjection*cpos;cpos/=cpos.w;var ppos: vec4f=uniforms.prevViewProjection*cpos;ppos/=ppos.w;ppos.xy=ppos.xy*0.5+0.5;var velocity: vec2f=(ppos.xy-input.vUV)*uniforms.motionScale*uniforms.motionStrength;var speed: f32=length(velocity/texelSize);var nSamples: i32= i32(clamp(speed,1.0,SAMPLES));var result: vec4f=textureSample(textureSampler,textureSamplerSampler, input.vUV);for (var i: i32=1; i< i32(SAMPLES); i++) {if (i>=nSamples) {break;}
|
||
var offset1: vec2f=input.vUV+velocity*( f32(i)/ f32(nSamples-1)-0.5);
|
||
#if defined(WEBGPU)
|
||
result+=textureSampleLevel(textureSampler,textureSamplerSampler, offset1,0.0);
|
||
#else
|
||
result+=textureSample(textureSampler,textureSamplerSampler, offset1);
|
||
#endif
|
||
}
|
||
fragmentOutputs.color=result/ f32(nSamples);
|
||
#endif
|
||
#else
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler, input.vUV);
|
||
#endif
|
||
}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},27993:(r,t,e)=>{e.r(t),e.d(t,{oitBackBlendPixelShaderWGSL:()=>o});var n="oitBackBlendPixelShader",i=`var uBackColor: texture_2d<f32>;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureLoad(uBackColor,vec2i(fragmentInputs.position.xy),0);if (fragmentOutputs.color.a==0.0) {discard;}}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},5519:(r,t,e)=>{e.r(t),e.d(t,{oitFinalPixelShaderWGSL:()=>o});var n="oitFinalPixelShader",i=`var uFrontColor: texture_2d<f32>;var uBackColor: texture_2d<f32>;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var fragCoord: vec2i=vec2i(fragmentInputs.position.xy);var frontColor: vec4f=textureLoad(uFrontColor,fragCoord,0);var backColor: vec4f=textureLoad(uBackColor,fragCoord,0);var alphaMultiplier: f32=1.0-frontColor.a;fragmentOutputs.color=vec4f(
|
||
frontColor.rgb+alphaMultiplier*backColor.rgb,
|
||
frontColor.a+backColor.a
|
||
);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},61189:(r,t,e)=>{e.r(t),e.d(t,{outlinePixelShaderWGSL:()=>a});var n=e(98519),i=(e(20502),e(38197),e(30032),e(56897),"outlinePixelShader"),o=`uniform color: vec4f;
|
||
#ifdef ALPHATEST
|
||
varying vUV: vec2;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEST
|
||
if (textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vUV).a<0.4) {discard;}
|
||
#endif
|
||
#include<logDepthFragment>
|
||
fragmentOutputs.color=uniforms.color;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},27179:(r,t,e)=>{e.r(t),e.d(t,{outlineVertexShaderWGSL:()=>a});var n=e(98519),i=(e(45699),e(27279),e(73683),e(68478),e(9436),e(63866),e(38197),e(98819),e(77320),e(21310),e(3641),e(86615),e(63002),e(55607),"outlineVertexShader"),o=`attribute position: vec3f;attribute normal: vec3f;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<clipPlaneVertexDeclaration>
|
||
uniform offset: f32;
|
||
#include<instancesDeclaration>
|
||
uniform viewProjection: mat4x4f;
|
||
#ifdef ALPHATEST
|
||
varying vUV: vec2f;uniform diffuseMatrix: mat4x4f;
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute uv2: vec2f;
|
||
#endif
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input: VertexInputs)->FragmentInputs {var positionUpdated: vec3f=vertexInputs.position;var normalUpdated: vec3f=vertexInputs.normal;
|
||
#ifdef UV1
|
||
var uvUpdated: vec2f=vertexInputs.uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
var offsetPosition: vec3f=positionUpdated+(normalUpdated*uniforms.offset);
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld*vec4f(offsetPosition,1.0);vertexOutputs.position=uniforms.viewProjection*worldPos;
|
||
#ifdef ALPHATEST
|
||
#ifdef UV1
|
||
vertexOutputs.vUV=(uniforms.diffuseMatrix*vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef UV2
|
||
vertexOutputs.vUV=(uniforms.diffuseMatrix*vec4f(vertexInputs.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<logDepthVertex>
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},45514:(r,t,e)=>{e.r(t),e.d(t,{particlesPixelShaderWGSL:()=>a});var n=e(98519),i=(e(20502),e(86320),e(38197),e(17393),e(4661),e(98318),e(30032),e(56897),e(83512),"particlesPixelShader"),o=`varying vUV: vec2f;varying vColor: vec4f;uniform textureMask: vec4f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<imageProcessingDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<helperFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#ifdef RAMPGRADIENT
|
||
varying remapRanges: vec4f;var rampSamplerSampler: sampler;var rampSampler: texture_2d<f32>;
|
||
#endif
|
||
#include<fogFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
var textureColor: vec4f=textureSample(diffuseSampler,diffuseSamplerSampler,input.vUV);var baseColor: vec4f=(textureColor*uniforms.textureMask+( vec4f(1.,1.,1.,1.)-uniforms.textureMask))*input.vColor;
|
||
#ifdef RAMPGRADIENT
|
||
var alpha: f32=baseColor.a;var remappedColorIndex: f32=clamp((alpha-input.remapRanges.x)/input.remapRanges.y,0.0,1.0);var rampColor: vec4f=textureSample(rampSampler,rampSamplerSampler,vec2f(1.0-remappedColorIndex,0.));baseColor=vec4f(baseColor.rgb*rampColor.rgb,baseColor.a);var finalAlpha: f32=baseColor.a;baseColor.a=clamp((alpha*rampColor.a-input.remapRanges.z)/input.remapRanges.w,0.0,1.0);
|
||
#endif
|
||
#ifdef BLENDMULTIPLYMODE
|
||
var sourceAlpha: f32=input.vColor.a*textureColor.a;baseColor=vec4f(baseColor.rgb*sourceAlpha+ vec3f(1.0)*(1.0-sourceAlpha),baseColor.a);
|
||
#endif
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>(color,baseColor)
|
||
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
baseColor=vec4f(toLinearSpaceVec3(baseColor.rgb),baseColor.a);
|
||
#else
|
||
#ifdef IMAGEPROCESSING
|
||
baseColor=vec4f(toLinearSpaceVec3(baseColor.rgb),baseColor.a);baseColor=applyImageProcessing(baseColor);
|
||
#endif
|
||
#endif
|
||
fragmentOutputs.color=baseColor;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},66348:(r,t,e)=>{e.r(t),e.d(t,{particlesVertexShaderWGSL:()=>a});var n=e(98519),i=(e(9436),e(79716),e(38197),e(63002),e(70898),e(55607),"particlesVertexShader"),o=`attribute position: vec3f;attribute color: vec4f;attribute angle: f32;attribute size: vec2f;
|
||
#ifdef ANIMATESHEET
|
||
attribute cellIndex: f32;
|
||
#endif
|
||
#ifndef BILLBOARD
|
||
attribute direction: vec3f;
|
||
#endif
|
||
#ifdef BILLBOARDSTRETCHED
|
||
attribute direction: vec3f;
|
||
#endif
|
||
#ifdef RAMPGRADIENT
|
||
attribute remapData: vec4f;
|
||
#endif
|
||
attribute offset: vec2f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform translationPivot: vec2f;
|
||
#ifdef ANIMATESHEET
|
||
uniform particlesInfos: vec3f;
|
||
#endif
|
||
varying vUV: vec2f;varying vColor: vec4f;varying vPositionW: vec3f;
|
||
#ifdef RAMPGRADIENT
|
||
varying remapRanges: vec4f;
|
||
#endif
|
||
#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
|
||
uniform invView: mat4x4f;
|
||
#endif
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#ifdef BILLBOARD
|
||
uniform eyePosition: vec3f;
|
||
#endif
|
||
fn rotate(yaxis: vec3f,rotatedCorner: vec3f)->vec3f {var xaxis: vec3f=normalize(cross( vec3f(0.,1.0,0.),yaxis));var zaxis: vec3f=normalize(cross(yaxis,xaxis));var row0: vec3f= vec3f(xaxis.x,xaxis.y,xaxis.z);var row1: vec3f= vec3f(yaxis.x,yaxis.y,yaxis.z);var row2: vec3f= vec3f(zaxis.x,zaxis.y,zaxis.z);var rotMatrix: mat3x3f= mat3x3f(row0,row1,row2);var alignedCorner: vec3f=rotMatrix*rotatedCorner;return vertexInputs.position+alignedCorner;}
|
||
#ifdef BILLBOARDSTRETCHED
|
||
fn rotateAlign(toCamera: vec3f,rotatedCorner: vec3f)->vec3f {var normalizedToCamera: vec3f=normalize(toCamera);var normalizedCrossDirToCamera: vec3f=normalize(cross(normalize(vertexInputs.direction),normalizedToCamera));var row0: vec3f= vec3f(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);var row2: vec3f= vec3f(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
|
||
#ifdef BILLBOARDSTRETCHED_LOCAL
|
||
var row1: vec3f=vertexInputs.direction;
|
||
#else
|
||
var crossProduct: vec3f=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));var row1: vec3f= vec3f(crossProduct.x,crossProduct.y,crossProduct.z);
|
||
#endif
|
||
var rotMatrix: mat3x3f= mat3x3f(row0,row1,row2);var alignedCorner: vec3f=rotMatrix*rotatedCorner;return input.position+alignedCorner;}
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
var cornerPos: vec2f;cornerPos=( vec2f(input.offset.x-0.5,input.offset.y -0.5)-uniforms.translationPivot)*input.size;
|
||
#ifdef BILLBOARD
|
||
var rotatedCorner: vec3f;
|
||
#ifdef BILLBOARDY
|
||
rotatedCorner.x=cornerPos.x*cos(input.angle)-cornerPos.y*sin(input.angle)+uniforms.translationPivot.x;rotatedCorner.z=cornerPos.x*sin(input.angle)+cornerPos.y*cos(input.angle)+uniforms.translationPivot.y;rotatedCorner.y=0.;var yaxis: vec3f=input.position-uniforms.eyePosition;yaxis.y=0.;vertexOutputs.vPositionW=rotate(normalize(yaxis),rotatedCorner);var viewPos: vec3f=(uniforms.view* vec4f(vertexOutputs.vPositionW,1.0)).xyz;
|
||
#elif defined(BILLBOARDSTRETCHED)
|
||
rotatedCorner.x=cornerPos.x*cos(input.angle)-cornerPos.y*sin(input.angle)+uniforms.translationPivot.x;rotatedCorner.y=cornerPos.x*sin(input.angle)+cornerPos.y*cos(input.angle)+uniforms.translationPivot.y;rotatedCorner.z=0.;var toCamera: vec3f=input.position-uniforms.eyePosition;vertexOutputs.vPositionW=rotateAlign(toCamera,rotatedCorner);var viewPos: vec3f=(uniforms.view* vec4f(vertexOutputs.vPositionW,1.0)).xyz;
|
||
#else
|
||
rotatedCorner.x=cornerPos.x*cos(input.angle)-cornerPos.y*sin(input.angle)+uniforms.translationPivot.x;rotatedCorner.y=cornerPos.x*sin(input.angle)+cornerPos.y*cos(input.angle)+uniforms.translationPivot.y;rotatedCorner.z=0.;var viewPos: vec3f=(uniforms.view* vec4f(input.position,1.0)).xyz+rotatedCorner;vertexOutputs.vPositionW=(uniforms.invView* vec4f(viewPos,1)).xyz;
|
||
#endif
|
||
#ifdef RAMPGRADIENT
|
||
vertexOutputs.remapRanges=input.remapData;
|
||
#endif
|
||
vertexOutputs.position=uniforms.projection* vec4f(viewPos,1.0);
|
||
#else
|
||
var rotatedCorner: vec3f;rotatedCorner.x=cornerPos.x*cos(input.angle)-cornerPos.y*sin(input.angle)+uniforms.translationPivot.x;rotatedCorner.z=cornerPos.x*sin(input.angle)+cornerPos.y*cos(input.angle)+uniforms.translationPivot.y;rotatedCorner.y=0.;var yaxis: vec3f=normalize(vertexInputs.direction);vertexOutputs.vPositionW=rotate(yaxis,rotatedCorner);vertexOutputs.position=uniforms.projection*uniforms.view* vec4f(vertexOutputs.vPositionW,1.0);
|
||
#endif
|
||
vertexOutputs.vColor=input.color;
|
||
#ifdef ANIMATESHEET
|
||
var rowOffset: f32=floor(input.cellIndex*uniforms.particlesInfos.z);var columnOffset: f32=input.cellIndex-rowOffset/uniforms.particlesInfos.z;var uvScale: vec2f=uniforms.particlesInfos.xy;var uvOffset: vec2f= vec2f(input.offset.x ,1.0-input.offset.y);vertexOutputs.vUV=(uvOffset+ vec2f(columnOffset,rowOffset))*uvScale;
|
||
#else
|
||
vertexOutputs.vUV=input.offset;
|
||
#endif
|
||
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) || defined(FOG)
|
||
var worldPos: vec4f= vec4f(vertexOutputs.vPositionW,1.0);
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},59448:(r,t,e)=>{e.r(t),e.d(t,{passPixelShaderWGSL:()=>o});var n="passPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},33739:(r,t,e)=>{e.r(t),e.d(t,{passCubePixelShaderWGSL:()=>o});var n="passCubePixelShader",i=`varying var vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_cube<f32>;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var uv: vec2f=input.vUV*2.0-1.0;
|
||
#ifdef POSITIVEX
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(1.001,uv.y,uv.x));
|
||
#endif
|
||
#ifdef NEGATIVEX
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(-1.001,uv.y,uv.x));
|
||
#endif
|
||
#ifdef POSITIVEY
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv.y,1.001,uv.x));
|
||
#endif
|
||
#ifdef NEGATIVEY
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv.y,-1.001,uv.x));
|
||
#endif
|
||
#ifdef POSITIVEZ
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv,1.001));
|
||
#endif
|
||
#ifdef NEGATIVEZ
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv,-1.001));
|
||
#endif
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},36934:(r,t,e)=>{e.r(t),e.d(t,{pbrPixelShaderWGSL:()=>s});var n=e(98519),i=(e(78710),e(76778),e(14052),e(14188),"pbrFragmentExtraDeclaration");n.l.IncludesShadersStoreWGSL[i]=`varying vPositionW: vec3f;
|
||
#if DEBUGMODE>0
|
||
varying vClipSpacePosition: vec4f;
|
||
#endif
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#ifdef NORMAL
|
||
varying vNormalW: vec3f;
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
varying vEnvironmentIrradiance: vec3f;
|
||
#endif
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vColor: vec4f;
|
||
#endif
|
||
`,e(10896),e(338),n.l.IncludesShadersStoreWGSL.samplerFragmentAlternateDeclaration=`#ifdef _DEFINENAME_
|
||
#if _DEFINENAME_DIRECTUV==1
|
||
#define v_VARYINGNAME_UV vMainUV1
|
||
#elif _DEFINENAME_DIRECTUV==2
|
||
#define v_VARYINGNAME_UV vMainUV2
|
||
#elif _DEFINENAME_DIRECTUV==3
|
||
#define v_VARYINGNAME_UV vMainUV3
|
||
#elif _DEFINENAME_DIRECTUV==4
|
||
#define v_VARYINGNAME_UV vMainUV4
|
||
#elif _DEFINENAME_DIRECTUV==5
|
||
#define v_VARYINGNAME_UV vMainUV5
|
||
#elif _DEFINENAME_DIRECTUV==6
|
||
#define v_VARYINGNAME_UV vMainUV6
|
||
#else
|
||
varying v_VARYINGNAME_UV: vec2f;
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrFragmentSamplersDeclaration=`#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
||
#ifdef CLEARCOAT
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
|
||
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
|
||
var clearCoatRoughnessSamplerSampler: sampler;var clearCoatRoughnessSampler: texture_2d<f32>;
|
||
#endif
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
|
||
#endif
|
||
#ifdef SHEEN
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
|
||
#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
|
||
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS)
|
||
var sheenRoughnessSamplerSampler: sampler;var sheenRoughnessSampler: texture_2d<f32>;
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef REFLECTIONMAP_3D
|
||
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#else
|
||
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;
|
||
#endif
|
||
#else
|
||
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#else
|
||
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vPositionUVW: vec3f;
|
||
#else
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vDirectionW: vec3f;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_REFRACTION
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
var refractionSamplerSampler: sampler;var refractionSampler: texture_cube<f32>;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#else
|
||
var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_cube<f32>;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_cube<f32>;
|
||
#endif
|
||
#else
|
||
var refractionSamplerSampler: sampler;var refractionSampler: texture_2d<f32>;
|
||
#ifdef LODBASEDMICROSFURACE
|
||
#else
|
||
var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_2d<f32>;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_2d<f32>;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
|
||
#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor)
|
||
#endif
|
||
`,e(86320),e(20502),e(38197),e(98318),e(17393),n.l.IncludesShadersStoreWGSL.subSurfaceScatteringFunctions=`fn testLightingForSSS(diffusionProfile: f32)->bool
|
||
{return diffusionProfile<1.;}`,e(28469),n.l.IncludesShadersStoreWGSL.pbrHelperFunctions=`#define MINIMUMVARIANCE 0.0005
|
||
fn convertRoughnessToAverageSlope(roughness: f32)->f32
|
||
{return roughness*roughness+MINIMUMVARIANCE;}
|
||
fn fresnelGrazingReflectance(reflectance0: f32)->f32 {var reflectance90: f32=saturate(reflectance0*25.0);return reflectance90;}
|
||
fn getAARoughnessFactors(normalVector: vec3f)->vec2f {
|
||
#ifdef SPECULARAA
|
||
var nDfdx: vec3f=dpdx(normalVector.xyz);var nDfdy: vec3f=dpdy(normalVector.xyz);var slopeSquare: f32=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));var geometricRoughnessFactor: f32=pow(saturate(slopeSquare),0.333);var geometricAlphaGFactor: f32=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2f(geometricRoughnessFactor,geometricAlphaGFactor);
|
||
#else
|
||
return vec2f(0.);
|
||
#endif
|
||
}
|
||
#ifdef ANISOTROPIC
|
||
#ifdef ANISOTROPIC_LEGACY
|
||
fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2f(alphaT,alphaB);}
|
||
fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var anisotropicFrameDirection: vec3f=select(T,B,anisotropy>=0.0);var anisotropicFrameTangent: vec3f=cross(normalize(anisotropicFrameDirection),V);var anisotropicFrameNormal: vec3f=cross(anisotropicFrameTangent,anisotropicFrameDirection);var anisotropicNormal: vec3f=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;}
|
||
#else
|
||
fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG,MINIMUMVARIANCE);return vec2f(alphaT,alphaB);}
|
||
fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var bentNormal: vec3f=cross(B,V);bentNormal=normalize(cross(bentNormal,B));var sq=1.0-anisotropy*(1.0-roughness);var a: f32=sq*sq*sq*sq;bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;}
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT) || defined(SS_REFRACTION)
|
||
fn cocaLambertVec3(alpha: vec3f,distance: f32)->vec3f {return exp(-alpha*distance);}
|
||
fn cocaLambert(NdotVRefract: f32,NdotLRefract: f32,alpha: vec3f,thickness: f32)->vec3f {return cocaLambertVec3(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}
|
||
fn computeColorAtDistanceInMedia(color: vec3f,distance: f32)->vec3f {return -log(color)/distance;}
|
||
fn computeClearCoatAbsorption(NdotVRefract: f32,NdotLRefract: f32,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var clearCoatAbsorption: vec3f=mix( vec3f(1.0),
|
||
cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
|
||
clearCoatIntensity);return clearCoatAbsorption;}
|
||
#endif
|
||
#ifdef MICROSURFACEAUTOMATIC
|
||
fn computeDefaultMicroSurface(microSurface: f32,reflectivityColor: vec3f)->f32
|
||
{const kReflectivityNoAlphaWorkflow_SmoothnessMax: f32=0.95;var reflectivityLuminance: f32=getLuminance(reflectivityColor);var reflectivityLuma: f32=sqrt(reflectivityLuminance);var resultMicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return resultMicroSurface;}
|
||
#endif
|
||
`,e(4661),e(32532),e(44467),n.l.IncludesShadersStoreWGSL.pbrDirectLightingSetupFunctions=`struct preLightingInfo
|
||
{lightOffset: vec3f,
|
||
lightDistanceSquared: f32,
|
||
lightDistance: f32,
|
||
attenuation: f32,
|
||
L: vec3f,
|
||
H: vec3f,
|
||
NdotV: f32,
|
||
NdotLUnclamped: f32,
|
||
NdotL: f32,
|
||
VdotH: f32,
|
||
roughness: f32,
|
||
#ifdef IRIDESCENCE
|
||
iridescenceIntensity: f32
|
||
#endif
|
||
};fn computePointAndSpotPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f,posW: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
|
||
fn computeDirectionalPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
|
||
fn computeHemisphericPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL;
|
||
#ifdef SPECULARTERM
|
||
result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));
|
||
#endif
|
||
return result;}`,n.l.IncludesShadersStoreWGSL.pbrDirectLightingFalloffFunctions=`fn computeDistanceLightFalloff_Standard(lightOffset: vec3f,range: f32)->f32
|
||
{return max(0.,1.0-length(lightOffset)/range);}
|
||
fn computeDistanceLightFalloff_Physical(lightDistanceSquared: f32)->f32
|
||
{return 1.0/maxEps(lightDistanceSquared);}
|
||
fn computeDistanceLightFalloff_GLTF(lightDistanceSquared: f32,inverseSquaredRange: f32)->f32
|
||
{var lightDistanceFalloff: f32=1.0/maxEps(lightDistanceSquared);var factor: f32=lightDistanceSquared*inverseSquaredRange;var attenuation: f32=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;}
|
||
fn computeDistanceLightFalloff(lightOffset: vec3f,lightDistanceSquared: f32,range: f32,inverseSquaredRange: f32)->f32
|
||
{
|
||
#ifdef USEPHYSICALLIGHTFALLOFF
|
||
return computeDistanceLightFalloff_Physical(lightDistanceSquared);
|
||
#elif defined(USEGLTFLIGHTFALLOFF)
|
||
return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
|
||
#else
|
||
return computeDistanceLightFalloff_Standard(lightOffset,range);
|
||
#endif
|
||
}
|
||
fn computeDirectionalLightFalloff_Standard(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32)->f32
|
||
{var falloff: f32=0.0;var cosAngle: f32=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)
|
||
{falloff=max(0.,pow(cosAngle,exponent));}
|
||
return falloff;}
|
||
fn computeDirectionalLightFalloff_Physical(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32)->f32
|
||
{const kMinusLog2ConeAngleIntensityRatio: f32=6.64385618977;
|
||
var concentrationKappa: f32=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);var lightDirectionSpreadSG: vec4f= vec4f(-lightDirection*concentrationKappa,-concentrationKappa);var falloff: f32=exp2(dot( vec4f(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;}
|
||
fn computeDirectionalLightFalloff_GLTF(lightDirection: vec3f,directionToLightCenterW: vec3f,lightAngleScale: f32,lightAngleOffset: f32)->f32
|
||
{var cd: f32=dot(-lightDirection,directionToLightCenterW);var falloff: f32=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}
|
||
fn computeDirectionalLightFalloff(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32,lightAngleScale: f32,lightAngleOffset: f32)->f32
|
||
{
|
||
#ifdef USEPHYSICALLIGHTFALLOFF
|
||
return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
|
||
#elif defined(USEGLTFLIGHTFALLOFF)
|
||
return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
|
||
#else
|
||
return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
|
||
#endif
|
||
}`,e(61669),e(31321),n.l.IncludesShadersStoreWGSL.pbrDirectLightingFunctions=`#define CLEARCOATREFLECTANCE90 1.0
|
||
struct lightingInfo
|
||
{diffuse: vec3f,
|
||
#ifdef SPECULARTERM
|
||
specular: vec3f,
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
clearCoat: vec4f,
|
||
#endif
|
||
#ifdef SHEEN
|
||
sheen: vec3f
|
||
#endif
|
||
};fn adjustRoughnessFromLightProperties(roughness: f32,lightRadius: f32,lightDistance: f32)->f32 {
|
||
#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
|
||
var lightRoughness: f32=lightRadius/lightDistance;var totalRoughness: f32=saturate(lightRoughness+roughness);return totalRoughness;
|
||
#else
|
||
return roughness;
|
||
#endif
|
||
}
|
||
fn computeHemisphericDiffuseLighting(info: preLightingInfo,lightColor: vec3f,groundColor: vec3f)->vec3f {return mix(groundColor,lightColor,info.NdotL);}
|
||
fn computeDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {var diffuseTerm: f32=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*info.attenuation*info.NdotL*lightColor;}
|
||
fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f{var strq: vec4f=textureProjectionMatrix* vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return toLinearSpaceVec3(textureColor);}
|
||
#ifdef SS_TRANSLUCENCY
|
||
fn computeDiffuseAndTransmittedLighting(info: preLightingInfo,lightColor: vec3f,transmittance: vec3f)->vec3f {var NdotL: f32=absEps(info.NdotLUnclamped);var wrapNdotL: f32=computeWrappedDiffuseNdotL(NdotL,0.02);var trAdapt: f32=step(0.,info.NdotLUnclamped);var transmittanceNdotL: vec3f=mix(transmittance*wrapNdotL, vec3f(wrapNdotL),trAdapt);var diffuseTerm: f32=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;}
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
fn computeSpecularLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var fresnel: vec3f=fresnelSchlickGGXVec3(info.VdotH,reflectance0,reflectance90);
|
||
#ifdef IRIDESCENCE
|
||
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
|
||
#endif
|
||
var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
|
||
#ifdef BRDF_V_HEIGHT_CORRELATED
|
||
var smithVisibility: f32=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
|
||
#else
|
||
var smithVisibility: f32=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
|
||
#endif
|
||
var specTerm: vec3f=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
fn computeAnisotropicSpecularLighting(info: preLightingInfo,V: vec3f,N: vec3f,T: vec3f,B: vec3f,anisotropy: f32,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var TdotH: f32=dot(T,info.H);var BdotH: f32=dot(B,info.H);var TdotV: f32=dot(T,V);var BdotV: f32=dot(B,V);var TdotL: f32=dot(T,info.L);var BdotL: f32=dot(B,info.L);var alphaG: f32=convertRoughnessToAverageSlope(info.roughness);var alphaTB: vec2f=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,vec2f(geometricRoughnessFactor*geometricRoughnessFactor));var fresnel: vec3f=fresnelSchlickGGXVec3(info.VdotH,reflectance0,reflectance90);
|
||
#ifdef IRIDESCENCE
|
||
fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
|
||
#endif
|
||
var distribution: f32=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);var smithVisibility: f32=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);var specTerm: vec3f=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
fn computeClearCoatLighting(info: preLightingInfo,Ncc: vec3f,geometricRoughnessFactor: f32,clearCoatIntensity: f32,lightColor: vec3f)->vec4f {var NccdotL: f32=saturateEps(dot(Ncc,info.L));var NccdotH: f32=saturateEps(dot(Ncc,info.H));var clearCoatRoughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness);var fresnel: f32=fresnelSchlickGGX(info.VdotH,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);var kelemenVisibility: f32=visibility_Kelemen(info.VdotH);var clearCoatTerm: f32=fresnel*distribution*kelemenVisibility;return vec4f(
|
||
clearCoatTerm*info.attenuation*NccdotL*lightColor,
|
||
1.0-fresnel
|
||
);}
|
||
fn computeClearCoatLightingAbsorption(NdotVRefract: f32,L: vec3f,Ncc: vec3f,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var LRefract: vec3f=-refract(L,Ncc,uniforms.vClearCoatRefractionParams.y);var NdotLRefract: f32=saturateEps(dot(Ncc,LRefract));var absorption: vec3f=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;}
|
||
#endif
|
||
#ifdef SHEEN
|
||
fn computeSheenLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var fresnel: f32=1.;var distribution: f32=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER
|
||
var visibility: f32=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);
|
||
#else */
|
||
var visibility: f32=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */
|
||
var sheenTerm: f32=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;}
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrIBLFunctions=`#if defined(REFLECTION) || defined(SS_REFRACTION)
|
||
fn getLodFromAlphaG(cubeMapDimensionPixels: f32,microsurfaceAverageSlope: f32)->f32 {var microsurfaceAverageSlopeTexels: f32=cubeMapDimensionPixels*microsurfaceAverageSlope;var lod: f32=log2(microsurfaceAverageSlopeTexels);return lod;}
|
||
fn getLinearLodFromRoughness(cubeMapDimensionPixels: f32,roughness: f32)->f32 {var lod: f32=log2(cubeMapDimensionPixels)*roughness;return lod;}
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
|
||
fn environmentRadianceOcclusion(ambientOcclusion: f32,NdotVUnclamped: f32)->f32 {var temp: f32=NdotVUnclamped+ambientOcclusion;return saturate(temp*temp-1.0+ambientOcclusion);}
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
|
||
fn environmentHorizonOcclusion(view: vec3f,normal: vec3f,geometricNormal: vec3f)->f32 {var reflection: vec3f=reflect(view,normal);var temp: f32=saturate(1.0+1.1*dot(reflection,geometricNormal));return temp*temp;}
|
||
#endif
|
||
#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
|
||
fn UNPACK_LOD(x: f32)->f32 {return (1.0-x)*255.0;}
|
||
fn getLodFromAlphaGNdotV(cubeMapDimensionPixels: f32,alphaG: f32,NdotV: f32)->f32 {var microsurfaceAverageSlope: f32=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
|
||
#endif
|
||
`,e(96830),e(66633),e(61439),e(65969),n.l.IncludesShadersStoreWGSL.pbrBlockAlbedoOpacity=`struct albedoOpacityOutParams
|
||
{surfaceAlbedo: vec3f,
|
||
alpha: f32};
|
||
#define pbr_inline
|
||
fn albedoOpacityBlock(
|
||
vAlbedoColor: vec4f
|
||
#ifdef ALBEDO
|
||
,albedoTexture: vec4f
|
||
,albedoInfos: vec2f
|
||
#endif
|
||
#ifdef OPACITY
|
||
,opacityMap: vec4f
|
||
,vOpacityInfos: vec2f
|
||
#endif
|
||
#ifdef DETAIL
|
||
,detailColor: vec4f
|
||
,vDetailInfos: vec4f
|
||
#endif
|
||
#ifdef DECAL
|
||
,decalColor: vec4f
|
||
,vDecalInfos: vec4f
|
||
#endif
|
||
)->albedoOpacityOutParams
|
||
{var outParams: albedoOpacityOutParams;var surfaceAlbedo: vec3f=vAlbedoColor.rgb;var alpha: f32=vAlbedoColor.a;
|
||
#ifdef ALBEDO
|
||
#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
|
||
alpha*=albedoTexture.a;
|
||
#endif
|
||
#ifdef GAMMAALBEDO
|
||
surfaceAlbedo*=toLinearSpaceVec3(albedoTexture.rgb);
|
||
#else
|
||
surfaceAlbedo*=albedoTexture.rgb;
|
||
#endif
|
||
surfaceAlbedo*=albedoInfos.y;
|
||
#endif
|
||
#ifndef DECAL_AFTER_DETAIL
|
||
#include<decalFragment>
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
surfaceAlbedo*=fragmentInputs.vColor.rgb;
|
||
#endif
|
||
#ifdef DETAIL
|
||
var detailAlbedo: f32=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
|
||
#endif
|
||
#ifdef DECAL_AFTER_DETAIL
|
||
#include<decalFragment>
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
|
||
#ifdef OPACITY
|
||
#ifdef OPACITYRGB
|
||
alpha=getLuminance(opacityMap.rgb);
|
||
#else
|
||
alpha*=opacityMap.a;
|
||
#endif
|
||
alpha*=vOpacityInfos.y;
|
||
#endif
|
||
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
alpha*=fragmentInputs.vColor.a;
|
||
#endif
|
||
#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
|
||
#ifdef ALPHATEST
|
||
#if DEBUGMODE != 88
|
||
if (alpha<ALPHATESTVALUE) {discard;}
|
||
#endif
|
||
#ifndef ALPHABLEND
|
||
alpha=1.0;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;}
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockReflectivity=`struct reflectivityOutParams
|
||
{microSurface: f32,
|
||
roughness: f32,
|
||
surfaceReflectivityColor: vec3f,
|
||
#ifdef METALLICWORKFLOW
|
||
surfaceAlbedo: vec3f,
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
ambientOcclusionColor: vec3f,
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef METALLICWORKFLOW
|
||
metallicRoughness: vec2f,
|
||
#ifdef REFLECTIVITY
|
||
surfaceMetallicColorMap: vec4f,
|
||
#endif
|
||
#ifndef FROSTBITE_REFLECTANCE
|
||
metallicF0: vec3f,
|
||
#endif
|
||
#else
|
||
#ifdef REFLECTIVITY
|
||
surfaceReflectivityColorMap: vec4f,
|
||
#endif
|
||
#endif
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
fn reflectivityBlock(
|
||
vReflectivityColor: vec4f
|
||
#ifdef METALLICWORKFLOW
|
||
,surfaceAlbedo: vec3f
|
||
,metallicReflectanceFactors: vec4f
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
,reflectivityInfos: vec3f
|
||
,surfaceMetallicOrReflectivityColorMap: vec4f
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
,ambientOcclusionColorIn: vec3f
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
,microSurfaceTexel: vec4f
|
||
#endif
|
||
#ifdef DETAIL
|
||
,detailColor: vec4f
|
||
,vDetailInfos: vec4f
|
||
#endif
|
||
)->reflectivityOutParams
|
||
{var outParams: reflectivityOutParams;var microSurface: f32=vReflectivityColor.a;var surfaceReflectivityColor: vec3f=vReflectivityColor.rgb;
|
||
#ifdef METALLICWORKFLOW
|
||
var metallicRoughness: vec2f=surfaceReflectivityColor.rg;
|
||
#ifdef REFLECTIVITY
|
||
#if DEBUGMODE>0
|
||
outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
|
||
#endif
|
||
#ifdef AOSTOREINMETALMAPRED
|
||
var aoStoreInMetalMap: vec3f= vec3f(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
|
||
#endif
|
||
#ifdef METALLNESSSTOREINMETALMAPBLUE
|
||
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
|
||
#else
|
||
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
|
||
#endif
|
||
#ifdef ROUGHNESSSTOREINMETALMAPALPHA
|
||
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
|
||
#else
|
||
#ifdef ROUGHNESSSTOREINMETALMAPGREEN
|
||
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef DETAIL
|
||
var detailRoughness: f32=mix(0.5,detailColor.b,vDetailInfos.w);var loLerp: f32=mix(0.,metallicRoughness.g,detailRoughness*2.);var hiLerp: f32=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
metallicRoughness.g*=microSurfaceTexel.r;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.metallicRoughness=metallicRoughness;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
|
||
microSurface=1.0-metallicRoughness.g;var baseColor: vec3f=surfaceAlbedo;
|
||
#ifdef FROSTBITE_REFLECTANCE
|
||
outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
|
||
#else
|
||
var metallicF0: vec3f=metallicReflectanceFactors.rgb;
|
||
#if DEBUGMODE>0
|
||
outParams.metallicF0=metallicF0;
|
||
#endif
|
||
outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0), vec3f(0.,0.,0.),metallicRoughness.r);surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
|
||
#endif
|
||
#else
|
||
#ifdef REFLECTIVITY
|
||
surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
|
||
#if DEBUGMODE>0
|
||
outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
|
||
#endif
|
||
#ifdef MICROSURFACEFROMREFLECTIVITYMAP
|
||
microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
|
||
#else
|
||
#ifdef MICROSURFACEAUTOMATIC
|
||
microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
microSurface*=microSurfaceTexel.r;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
|
||
#endif
|
||
#endif
|
||
#endif
|
||
microSurface=saturate(microSurface);var roughness: f32=1.-microSurface;outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.surfaceReflectivityColor=surfaceReflectivityColor;return outParams;}
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockAmbientOcclusion=`struct ambientOcclusionOutParams
|
||
{ambientOcclusionColor: vec3f,
|
||
#if DEBUGMODE>0 && defined(AMBIENT)
|
||
ambientOcclusionColorMap: vec3f
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
fn ambientOcclusionBlock(
|
||
#ifdef AMBIENT
|
||
ambientOcclusionColorMap_: vec3f,
|
||
vAmbientInfos: vec4f
|
||
#endif
|
||
)->ambientOcclusionOutParams
|
||
{
|
||
var outParams: ambientOcclusionOutParams;var ambientOcclusionColor: vec3f= vec3f(1.,1.,1.);
|
||
#ifdef AMBIENT
|
||
var ambientOcclusionColorMap: vec3f=ambientOcclusionColorMap_*vAmbientInfos.y;
|
||
#ifdef AMBIENTINGRAYSCALE
|
||
ambientOcclusionColorMap= vec3f(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
|
||
#endif
|
||
ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
|
||
#if DEBUGMODE>0
|
||
outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
|
||
#endif
|
||
#endif
|
||
outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;}
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockAlphaFresnel=`#ifdef ALPHAFRESNEL
|
||
#if defined(ALPHATEST) || defined(ALPHABLEND)
|
||
struct alphaFresnelOutParams
|
||
{alpha: f32};fn faceforward(N: vec3<f32>,I: vec3<f32>,Nref: vec3<f32>)->vec3<f32> {return select(N,-N,dot(Nref,I)>0.0);}
|
||
#define pbr_inline
|
||
fn alphaFresnelBlock(
|
||
normalW: vec3f,
|
||
viewDirectionW: vec3f,
|
||
alpha: f32,
|
||
microSurface: f32
|
||
)->alphaFresnelOutParams
|
||
{var outParams: alphaFresnelOutParams;var opacityPerceptual: f32=alpha;
|
||
#ifdef LINEARALPHAFRESNEL
|
||
var opacity0: f32=opacityPerceptual;
|
||
#else
|
||
var opacity0: f32=opacityPerceptual*opacityPerceptual;
|
||
#endif
|
||
var opacity90: f32=fresnelGrazingReflectance(opacity0);var normalForward: vec3f=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)), vec3f(opacity0), vec3f(opacity90),sqrt(microSurface)).x;
|
||
#ifdef ALPHATEST
|
||
if (outParams.alpha<ALPHATESTVALUE) {discard;}
|
||
#ifndef ALPHABLEND
|
||
outParams.alpha=1.0;
|
||
#endif
|
||
#endif
|
||
return outParams;}
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockAnisotropic=`#ifdef ANISOTROPIC
|
||
struct anisotropicOutParams
|
||
{anisotropy: f32,
|
||
anisotropicTangent: vec3f,
|
||
anisotropicBitangent: vec3f,
|
||
anisotropicNormal: vec3f,
|
||
#if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
|
||
anisotropyMapData: vec3f
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
fn anisotropicBlock(
|
||
vAnisotropy: vec3f,
|
||
roughness: f32,
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
anisotropyMapData: vec3f,
|
||
#endif
|
||
TBN: mat3x3f,
|
||
normalW: vec3f,
|
||
viewDirectionW: vec3f
|
||
)->anisotropicOutParams
|
||
{
|
||
var outParams: anisotropicOutParams;var anisotropy: f32=vAnisotropy.b;var anisotropyDirection: vec3f= vec3f(vAnisotropy.xy,0.);
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
var amd=anisotropyMapData.rg;anisotropy*=anisotropyMapData.b;
|
||
#if DEBUGMODE>0
|
||
outParams.anisotropyMapData=anisotropyMapData;
|
||
#endif
|
||
amd=amd*2.0-1.0;
|
||
#ifdef ANISOTROPIC_LEGACY
|
||
anisotropyDirection=vec3f(anisotropyDirection.xy*amd,anisotropyDirection.z);
|
||
#else
|
||
anisotropyDirection=vec3f(mat2x2f(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(amd),anisotropyDirection.z);
|
||
#endif
|
||
#endif
|
||
var anisoTBN: mat3x3f= mat3x3f(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));var anisotropicTangent: vec3f=normalize(anisoTBN*anisotropyDirection);var anisotropicBitangent: vec3f=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockReflection=`#ifdef REFLECTION
|
||
struct reflectionOutParams
|
||
{environmentRadiance: vec4f
|
||
,environmentIrradiance: vec3f
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionCoords: vec3f
|
||
#else
|
||
,reflectionCoords: vec2f
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,irradianceVector: vec3f
|
||
#endif
|
||
#endif
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
#ifdef REFLECTIONMAP_3D
|
||
fn createReflectionCoords(
|
||
vPositionW: vec3f,
|
||
normalW: vec3f,
|
||
#ifdef ANISOTROPIC
|
||
anisotropicOut: anisotropicOutParams,
|
||
#endif
|
||
)->vec3f
|
||
{var reflectionCoords: vec3f;
|
||
#else
|
||
fn createReflectionCoords(
|
||
vPositionW: vec3f,
|
||
normalW: vec3f,
|
||
#ifdef ANISOTROPIC
|
||
anisotropicOut: anisotropicOutParams,
|
||
#endif
|
||
)->vec2f
|
||
{
|
||
var reflectionCoords: vec2f;
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),anisotropicOut.anisotropicNormal);
|
||
#else
|
||
var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),normalW);
|
||
#endif
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
reflectionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
reflectionCoords=reflectionVector;
|
||
#else
|
||
reflectionCoords=reflectionVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
reflectionCoords/=reflectionVector.z;
|
||
#endif
|
||
reflectionCoords.y=1.0-reflectionCoords.y;
|
||
#endif
|
||
return reflectionCoords;}
|
||
#define pbr_inline
|
||
fn sampleReflectionTexture(
|
||
alphaG: f32
|
||
,vReflectionMicrosurfaceInfos: vec3f
|
||
,vReflectionInfos: vec2f
|
||
,vReflectionColor: vec3f
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,NdotVUnclamped: f32
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,roughness: f32
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionSampler: texture_cube<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
,reflectionCoords: vec3f
|
||
#else
|
||
,reflectionSampler: texture_2d<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
,reflectionCoords: vec2f
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionLowSampler: texture_cube<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_cube<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#else
|
||
,reflectionLowSampler: texture_2d<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_2d<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo: vec2f
|
||
#endif
|
||
)->vec4f
|
||
{var environmentRadiance: vec4f;
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
var reflectionLOD: f32=getLodFromAlphaGNdotV(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
|
||
#elif defined(LINEARSPECULARREFLECTION)
|
||
var reflectionLOD: f32=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
|
||
#else
|
||
var reflectionLOD: f32=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
|
||
#endif
|
||
#ifdef LODBASEDMICROSFURACE
|
||
reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
|
||
#ifdef LODINREFLECTIONALPHA
|
||
var automaticReflectionLOD: f32=UNPACK_LOD(textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords).a);var requestedReflectionLOD: f32=max(automaticReflectionLOD,reflectionLOD);
|
||
#else
|
||
var requestedReflectionLOD: f32=reflectionLOD;
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
environmentRadiance= vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
|
||
#else
|
||
environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
|
||
#endif
|
||
#else
|
||
var lodReflectionNormalized: f32=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));var lodReflectionNormalizedDoubled: f32=lodReflectionNormalized*2.0;var environmentMid: vec4f=textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
|
||
textureSample(reflectionHighSampler,reflectionHighSamplerSampler,reflectionCoords),
|
||
environmentMid,
|
||
lodReflectionNormalizedDoubled
|
||
);} else {environmentRadiance=mix(
|
||
environmentMid,
|
||
textureSample(reflectionLowSampler,reflectionLowSamplerSampler,reflectionCoords),
|
||
lodReflectionNormalizedDoubled-1.0
|
||
);}
|
||
#endif
|
||
var envRadiance=environmentRadiance.rgb;
|
||
#ifdef RGBDREFLECTION
|
||
envRadiance=fromRGBD(environmentRadiance);
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
envRadiance=toLinearSpaceVec3(environmentRadiance.rgb);
|
||
#endif
|
||
envRadiance*=vReflectionInfos.x;envRadiance*=vReflectionColor.rgb;return vec4f(envRadiance,environmentRadiance.a);}
|
||
#define pbr_inline
|
||
fn reflectionBlock(
|
||
vPositionW: vec3f
|
||
,normalW: vec3f
|
||
,alphaG: f32
|
||
,vReflectionMicrosurfaceInfos: vec3f
|
||
,vReflectionInfos: vec2f
|
||
,vReflectionColor: vec3f
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut: anisotropicOutParams
|
||
#endif
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,NdotVUnclamped: f32
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,roughness: f32
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionSampler: texture_cube<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
#else
|
||
,reflectionSampler: texture_2d<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
#endif
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
||
,vEnvironmentIrradiance: vec3f
|
||
#endif
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,reflectionMatrix: mat4x4f
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
#ifdef REFLECTIONMAP_3D
|
||
,irradianceSampler: texture_cube<f32>
|
||
,irradianceSamplerSampler: sampler
|
||
#else
|
||
,irradianceSampler: texture_2d<f32>
|
||
,irradianceSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionLowSampler: texture_cube<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_cube<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#else
|
||
,reflectionLowSampler: texture_2d<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_2d<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo: vec2f
|
||
#endif
|
||
)->reflectionOutParams
|
||
{var outParams: reflectionOutParams;var environmentRadiance: vec4f= vec4f(0.,0.,0.,0.);
|
||
#ifdef REFLECTIONMAP_3D
|
||
var reflectionCoords: vec3f= vec3f(0.);
|
||
#else
|
||
var reflectionCoords: vec2f= vec2f(0.);
|
||
#endif
|
||
reflectionCoords=createReflectionCoords(
|
||
vPositionW,
|
||
normalW,
|
||
#ifdef ANISOTROPIC
|
||
anisotropicOut,
|
||
#endif
|
||
);environmentRadiance=sampleReflectionTexture(
|
||
alphaG
|
||
,vReflectionMicrosurfaceInfos
|
||
,vReflectionInfos
|
||
,vReflectionColor
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,NdotVUnclamped
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,roughness
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
,reflectionCoords
|
||
#else
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
,reflectionCoords
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionLowSampler
|
||
,reflectionLowSamplerSampler
|
||
,reflectionHighSampler
|
||
,reflectionHighSamplerSampler
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
);var environmentIrradiance: vec3f= vec3f(0.,0.,0.);
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
||
environmentIrradiance=vEnvironmentIrradiance;
|
||
#else
|
||
#ifdef ANISOTROPIC
|
||
var irradianceVector: vec3f= (reflectionMatrix* vec4f(anisotropicOut.anisotropicNormal,0)).xyz;
|
||
#else
|
||
var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
irradianceVector.z*=-1.0;
|
||
#endif
|
||
#ifdef INVERTCUBICMAP
|
||
irradianceVector.y*=-1.0;
|
||
#endif
|
||
#if defined(REALTIME_FILTERING)
|
||
environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,vReflectionFilteringInfo);
|
||
#else
|
||
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
outParams.irradianceVector=irradianceVector;
|
||
#endif
|
||
#endif
|
||
#elif defined(USEIRRADIANCEMAP)
|
||
var environmentIrradiance4: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords);environmentIrradiance=environmentIrradiance4.rgb;
|
||
#ifdef RGBDREFLECTION
|
||
environmentIrradiance=fromRGBD(environmentIrradiance4);
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
environmentIrradiance=toLinearSpaceVec3(environmentIrradiance.rgb);
|
||
#endif
|
||
#endif
|
||
environmentIrradiance*=vReflectionColor.rgb;outParams.environmentRadiance=environmentRadiance;outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockSheen=`#ifdef SHEEN
|
||
struct sheenOutParams
|
||
{sheenIntensity: f32
|
||
,sheenColor: vec3f
|
||
,sheenRoughness: f32
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
,surfaceAlbedo: vec3f
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
,sheenAlbedoScaling: f32
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
,finalSheenRadianceScaled: vec3f
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef SHEEN_TEXTURE
|
||
,sheenMapData: vec4f
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
,sheenEnvironmentReflectance: vec3f
|
||
#endif
|
||
#endif
|
||
};
|
||
#define pbr_inline
|
||
fn sheenBlock(
|
||
vSheenColor: vec4f
|
||
#ifdef SHEEN_ROUGHNESS
|
||
,vSheenRoughness: f32
|
||
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,sheenMapRoughnessData: vec4f
|
||
#endif
|
||
#endif
|
||
,roughness: f32
|
||
#ifdef SHEEN_TEXTURE
|
||
,sheenMapData: vec4f
|
||
,sheenMapLevel: f32
|
||
#endif
|
||
,reflectance: f32
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
,baseColor: vec3f
|
||
,surfaceAlbedo: vec3f
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
,NdotV: f32
|
||
,environmentBrdf: vec3f
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
,AARoughnessFactors: vec2f
|
||
,vReflectionMicrosurfaceInfos: vec3f
|
||
,vReflectionInfos: vec2f
|
||
,vReflectionColor: vec3f
|
||
,vLightingIntensity: vec4f
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionSampler: texture_cube<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
,reflectionCoords: vec3f
|
||
#else
|
||
,reflectionSampler: texture_2d<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
,reflectionCoords: vec2f
|
||
#endif
|
||
,NdotVUnclamped: f32
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionLowSampler: texture_cube<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_cube<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#else
|
||
,reflectionLowSampler: texture_2d<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_2d<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo: vec2f
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
||
,seo: f32
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
,eho: f32
|
||
#endif
|
||
#endif
|
||
)->sheenOutParams
|
||
{var outParams: sheenOutParams;var sheenIntensity: f32=vSheenColor.a;
|
||
#ifdef SHEEN_TEXTURE
|
||
#if DEBUGMODE>0
|
||
outParams.sheenMapData=sheenMapData;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
var sheenFactor: f32=pow5(1.0-sheenIntensity);var sheenColor: vec3f=baseColor.rgb*(1.0-sheenFactor);var sheenRoughness: f32=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
|
||
#ifdef SHEEN_TEXTURE
|
||
sheenIntensity*=sheenMapData.a;
|
||
#endif
|
||
#else
|
||
var sheenColor: vec3f=vSheenColor.rgb;
|
||
#ifdef SHEEN_TEXTURE
|
||
#ifdef SHEEN_GAMMATEXTURE
|
||
sheenColor*=toLinearSpaceVec3(sheenMapData.rgb);
|
||
#else
|
||
sheenColor*=sheenMapData.rgb;
|
||
#endif
|
||
sheenColor*=sheenMapLevel;
|
||
#endif
|
||
#ifdef SHEEN_ROUGHNESS
|
||
var sheenRoughness: f32=vSheenRoughness;
|
||
#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
|
||
#if defined(SHEEN_TEXTURE)
|
||
sheenRoughness*=sheenMapData.a;
|
||
#endif
|
||
#elif defined(SHEEN_TEXTURE_ROUGHNESS)
|
||
sheenRoughness*=sheenMapRoughnessData.a;
|
||
#endif
|
||
#else
|
||
var sheenRoughness: f32=roughness;
|
||
#ifdef SHEEN_TEXTURE
|
||
sheenIntensity*=sheenMapData.a;
|
||
#endif
|
||
#endif
|
||
#if !defined(SHEEN_ALBEDOSCALING)
|
||
sheenIntensity*=(1.-reflectance);
|
||
#endif
|
||
sheenColor*=sheenIntensity;
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
/*#ifdef SHEEN_SOFTER
|
||
var environmentSheenBrdf: vec3f= vec3f(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
|
||
#else*/
|
||
#ifdef SHEEN_ROUGHNESS
|
||
var environmentSheenBrdf: vec3f=getBRDFLookup(NdotV,sheenRoughness);
|
||
#else
|
||
var environmentSheenBrdf: vec3f=environmentBrdf;
|
||
#endif
|
||
/*#endif*/
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
var sheenAlphaG: f32=convertRoughnessToAverageSlope(sheenRoughness);
|
||
#ifdef SPECULARAA
|
||
sheenAlphaG+=AARoughnessFactors.y;
|
||
#endif
|
||
var environmentSheenRadiance: vec4f= vec4f(0.,0.,0.,0.);environmentSheenRadiance=sampleReflectionTexture(
|
||
sheenAlphaG
|
||
,vReflectionMicrosurfaceInfos
|
||
,vReflectionInfos
|
||
,vReflectionColor
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,NdotVUnclamped
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,sheenRoughness
|
||
#endif
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
,reflectionCoords
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionLowSampler
|
||
,reflectionLowSamplerSampler
|
||
,reflectionHighSampler
|
||
,reflectionHighSamplerSampler
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
);var sheenEnvironmentReflectance: vec3f=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
||
sheenEnvironmentReflectance*=seo;
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
sheenEnvironmentReflectance*=eho;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
|
||
#endif
|
||
outParams.finalSheenRadianceScaled=
|
||
environmentSheenRadiance.rgb *
|
||
sheenEnvironmentReflectance *
|
||
vLightingIntensity.z;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
|
||
#endif
|
||
outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockClearcoat=`struct clearcoatOutParams
|
||
{specularEnvironmentR0: vec3f,
|
||
conservationFactor: f32,
|
||
clearCoatNormalW: vec3f,
|
||
clearCoatAARoughnessFactors: vec2f,
|
||
clearCoatIntensity: f32,
|
||
clearCoatRoughness: f32,
|
||
#ifdef REFLECTION
|
||
finalClearCoatRadianceScaled: vec3f,
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
absorption: vec3f,
|
||
clearCoatNdotVRefract: f32,
|
||
clearCoatColor: vec3f,
|
||
clearCoatThickness: f32,
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
energyConservationFactorClearCoat: vec3f,
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef CLEARCOAT_BUMP
|
||
TBNClearCoat: mat3x3f,
|
||
#endif
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
clearCoatMapData: vec2f,
|
||
#endif
|
||
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
||
clearCoatTintMapData: vec4f,
|
||
#endif
|
||
#ifdef REFLECTION
|
||
environmentClearCoatRadiance: vec4f,
|
||
clearCoatEnvironmentReflectance: vec3f,
|
||
#endif
|
||
clearCoatNdotV: f32
|
||
#endif
|
||
};
|
||
#ifdef CLEARCOAT
|
||
#define pbr_inline
|
||
fn clearcoatBlock(
|
||
vPositionW: vec3f
|
||
,geometricNormalW: vec3f
|
||
,viewDirectionW: vec3f
|
||
,vClearCoatParams: vec2f
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,clearCoatMapRoughnessData: vec4f
|
||
#endif
|
||
,specularEnvironmentR0: vec3f
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,clearCoatMapData: vec2f
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
,vClearCoatTintParams: vec4f
|
||
,clearCoatColorAtDistance: f32
|
||
,vClearCoatRefractionParams: vec4f
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
,clearCoatTintMapData: vec4f
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
,vClearCoatBumpInfos: vec2f
|
||
,clearCoatBumpMapData: vec4f
|
||
,vClearCoatBumpUV: vec2f
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
,vTBN: mat3x3f
|
||
#else
|
||
,vClearCoatTangentSpaceParams: vec2f
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
,normalMatrix: mat4x4f
|
||
#endif
|
||
#endif
|
||
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
,faceNormal: vec3f
|
||
#endif
|
||
#ifdef REFLECTION
|
||
,vReflectionMicrosurfaceInfos: vec3f
|
||
,vReflectionInfos: vec2f
|
||
,vReflectionColor: vec3f
|
||
,vLightingIntensity: vec4f
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionSampler: texture_cube<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
#else
|
||
,reflectionSampler: texture_2d<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef REFLECTIONMAP_3D
|
||
,reflectionLowSampler: texture_cube<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_cube<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#else
|
||
,reflectionLowSampler: texture_2d<f32>
|
||
,reflectionLowSamplerSampler: sampler
|
||
,reflectionHighSampler: texture_2d<f32>
|
||
,reflectionHighSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo: vec2f
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
|
||
,frontFacingMultiplier: f32
|
||
#endif
|
||
)->clearcoatOutParams
|
||
{var outParams: clearcoatOutParams;var clearCoatIntensity: f32=vClearCoatParams.x;var clearCoatRoughness: f32=vClearCoatParams.y;
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
clearCoatIntensity*=clearCoatMapData.x;
|
||
#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
|
||
clearCoatRoughness*=clearCoatMapData.y;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatMapData=clearCoatMapData;
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
clearCoatRoughness*=clearCoatMapRoughnessData.y;
|
||
#endif
|
||
outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
|
||
#ifdef CLEARCOAT_TINT
|
||
var clearCoatColor: vec3f=vClearCoatTintParams.rgb;var clearCoatThickness: f32=vClearCoatTintParams.a;
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
#ifdef CLEARCOAT_TINT_GAMMATEXTURE
|
||
clearCoatColor*=toLinearSpaceVec3(clearCoatTintMapData.rgb);
|
||
#else
|
||
clearCoatColor*=clearCoatTintMapData.rgb;
|
||
#endif
|
||
clearCoatThickness*=clearCoatTintMapData.a;
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatTintMapData=clearCoatTintMapData;
|
||
#endif
|
||
#endif
|
||
outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
|
||
#endif
|
||
#ifdef CLEARCOAT_REMAP_F0
|
||
var specularEnvironmentR0Updated: vec3f=getR0RemappedForClearCoat(specularEnvironmentR0);
|
||
#else
|
||
var specularEnvironmentR0Updated: vec3f=specularEnvironmentR0;
|
||
#endif
|
||
outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);var clearCoatNormalW: vec3f=geometricNormalW;
|
||
#ifdef CLEARCOAT_BUMP
|
||
#ifdef NORMALXYSCALE
|
||
var clearCoatNormalScale: f32=1.0;
|
||
#else
|
||
var clearCoatNormalScale: f32=vClearCoatBumpInfos.y;
|
||
#endif
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
var TBNClearCoat: mat3x3f=vTBN;
|
||
#else
|
||
var TBNClearCoatUV: vec2f=vClearCoatBumpUV*frontFacingMultiplier;var TBNClearCoat: mat3x3f=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.TBNClearCoat=TBNClearCoat;
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize( mat3x3f(normalMatrix[0].xyz,normalMatrix[1].xyz,normalMatrix[2].xyz)*clearCoatNormalW);
|
||
#else
|
||
clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
|
||
#endif
|
||
#endif
|
||
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
|
||
#endif
|
||
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
||
clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
|
||
#endif
|
||
outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);var clearCoatNdotVUnclamped: f32=dot(clearCoatNormalW,viewDirectionW);var clearCoatNdotV: f32=absEps(clearCoatNdotVUnclamped);
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatNdotV=clearCoatNdotV;
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
var clearCoatVRefract: vec3f=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
|
||
var environmentClearCoatBrdf: vec3f=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
|
||
#endif
|
||
#if defined(REFLECTION)
|
||
var clearCoatAlphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness);
|
||
#ifdef SPECULARAA
|
||
clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
|
||
#endif
|
||
var environmentClearCoatRadiance: vec4f= vec4f(0.,0.,0.,0.);var clearCoatReflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),clearCoatNormalW);
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
clearCoatReflectionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef REFLECTIONMAP_3D
|
||
var clearCoatReflectionCoords: vec3f=clearCoatReflectionVector;
|
||
#else
|
||
var clearCoatReflectionCoords: vec2f=clearCoatReflectionVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
clearCoatReflectionCoords/=clearCoatReflectionVector.z;
|
||
#endif
|
||
clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
|
||
#endif
|
||
environmentClearCoatRadiance=sampleReflectionTexture(
|
||
clearCoatAlphaG
|
||
,vReflectionMicrosurfaceInfos
|
||
,vReflectionInfos
|
||
,vReflectionColor
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,clearCoatNdotVUnclamped
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,clearCoatRoughness
|
||
#endif
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
,clearCoatReflectionCoords
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionLowSampler
|
||
,reflectionLowSamplerSampler
|
||
,reflectionHighSampler
|
||
,reflectionHighSamplerSampler
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
);
|
||
#if DEBUGMODE>0
|
||
outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromBRDFLookup(vec3f(uniforms.vClearCoatRefractionParams.x),environmentClearCoatBrdf);
|
||
#ifdef HORIZONOCCLUSION
|
||
#ifdef BUMP
|
||
#ifdef REFLECTIONMAP_3D
|
||
var clearCoatEho: f32=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#else
|
||
var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV, vec3f(1.), vec3f(1.),sqrt(1.-clearCoatRoughness));
|
||
#endif
|
||
clearCoatEnvironmentReflectance*=clearCoatIntensity;
|
||
#if DEBUGMODE>0
|
||
outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
|
||
#endif
|
||
outParams.finalClearCoatRadianceScaled=
|
||
environmentClearCoatRadiance.rgb *
|
||
clearCoatEnvironmentReflectance *
|
||
vLightingIntensity.z;
|
||
#endif
|
||
#if defined(CLEARCOAT_TINT)
|
||
outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
|
||
#endif
|
||
var fresnelIBLClearCoat: f32=fresnelSchlickGGX(clearCoatNdotV,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
|
||
#endif
|
||
return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockIridescence=`struct iridescenceOutParams
|
||
{iridescenceIntensity: f32,
|
||
iridescenceIOR: f32,
|
||
iridescenceThickness: f32,
|
||
specularEnvironmentR0: vec3f};
|
||
#ifdef IRIDESCENCE
|
||
fn iridescenceBlock(
|
||
vIridescenceParams: vec4f
|
||
,viewAngle: f32
|
||
,specularEnvironmentR0: vec3f
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
,iridescenceMapData: vec2f
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
,iridescenceThicknessMapData: vec2f
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
,NdotVUnclamped: f32
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,clearCoatMapData: vec2f
|
||
#endif
|
||
#endif
|
||
)->iridescenceOutParams
|
||
{var outParams: iridescenceOutParams;var iridescenceIntensity: f32=vIridescenceParams.x;var iridescenceIOR: f32=vIridescenceParams.y;var iridescenceThicknessMin: f32=vIridescenceParams.z;var iridescenceThicknessMax: f32=vIridescenceParams.w;var iridescenceThicknessWeight: f32=1.;
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
iridescenceIntensity*=iridescenceMapData.x;
|
||
#endif
|
||
#if defined(IRIDESCENCE_THICKNESS_TEXTURE)
|
||
iridescenceThicknessWeight=iridescenceThicknessMapData.g;
|
||
#endif
|
||
var iridescenceThickness: f32=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);var topIor: f32=1.;
|
||
#ifdef CLEARCOAT
|
||
var clearCoatIntensity: f32=vClearCoatParams.x;
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
clearCoatIntensity*=clearCoatMapData.x;
|
||
#endif
|
||
topIor=mix(1.0,uniforms.vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+((1.0/topIor)*(1.0/topIor))*((NdotVUnclamped*NdotVUnclamped)-1.0));
|
||
#endif
|
||
var iridescenceFresnel: vec3f=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;}
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockSubSurface=`struct subSurfaceOutParams
|
||
{specularEnvironmentReflectance: vec3f,
|
||
#ifdef SS_REFRACTION
|
||
finalRefraction: vec3f,
|
||
surfaceAlbedo: vec3f,
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
alpha: f32,
|
||
#endif
|
||
#ifdef REFLECTION
|
||
refractionFactorForIrradiance: f32,
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
transmittance: vec3f,
|
||
translucencyIntensity: f32,
|
||
#ifdef REFLECTION
|
||
refractionIrradiance: vec3f,
|
||
#endif
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
thicknessMap: vec4f,
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
environmentRefraction: vec4f,
|
||
refractionTransmittance: vec3f
|
||
#endif
|
||
#endif
|
||
};
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_REFRACTION
|
||
#define pbr_inline
|
||
fn sampleEnvironmentRefraction(
|
||
ior: f32
|
||
,thickness: f32
|
||
,refractionLOD: f32
|
||
,normalW: vec3f
|
||
,vPositionW: vec3f
|
||
,viewDirectionW: vec3f
|
||
,view: mat4x4f
|
||
,vRefractionInfos: vec4f
|
||
,refractionMatrix: mat4x4f
|
||
,vRefractionMicrosurfaceInfos: vec4f
|
||
,alphaG: f32
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
,refractionSampler: texture_cube<f32>
|
||
,refractionSamplerSampler: sampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionLowSampler: texture_cube<f32>
|
||
,refractionLowSamplerSampler: sampler
|
||
,refractionHighSampler: texture_cube<f32>
|
||
,refractionHighSamplerSampler: sampler
|
||
#endif
|
||
#else
|
||
,refractionSampler: texture_2d<f32>
|
||
,refractionSamplerSampler: sampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionLowSampler: texture_2d<f32>
|
||
,refractionLowSamplerSampler: sampler
|
||
,refractionHighSampler: texture_2d<f32>
|
||
,refractionHighSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut: anisotropicOutParams
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vRefractionFilteringInfo: vec2f
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,refractionPosition: vec3f
|
||
,refractionSize: vec3f
|
||
#endif
|
||
)->vec4f {var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.);
|
||
#ifdef ANISOTROPIC
|
||
var refractionVector: vec3f=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior);
|
||
#else
|
||
var refractionVector: vec3f=refract(-viewDirectionW,normalW,ior);
|
||
#endif
|
||
#ifdef SS_REFRACTIONMAP_OPPOSITEZ
|
||
refractionVector.z*=-1.0;
|
||
#endif
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
|
||
#endif
|
||
refractionVector.y=refractionVector.y*vRefractionInfos.w;var refractionCoords: vec3f=refractionVector;refractionCoords= (refractionMatrix* vec4f(refractionCoords,0)).xyz;
|
||
#else
|
||
#ifdef SS_USE_THICKNESS_AS_DEPTH
|
||
var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*thickness,1.0))).xyz;
|
||
#else
|
||
var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*vRefractionInfos.z,1.0))).xyz;
|
||
#endif
|
||
var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
|
||
#endif
|
||
#ifdef LODBASEDMICROSFURACE
|
||
var lod=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
var automaticRefractionLOD: f32=UNPACK_LOD(textureSample(refractionSampler,refractionSamplerSampler,refractionCoords).a);var requestedRefractionLOD: f32=max(automaticRefractionLOD,lod);
|
||
#else
|
||
var requestedRefractionLOD: f32=lod;
|
||
#endif
|
||
#if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
|
||
environmentRefraction= vec4f(radiance(alphaG,refractionSampler,refractionSamplerSampler,refractionCoords,vRefractionFilteringInfo),1.0);
|
||
#else
|
||
environmentRefraction=textureSampleLevel(refractionSampler,refractionSamplerSampler,refractionCoords,requestedRefractionLOD);
|
||
#endif
|
||
#else
|
||
var lodRefractionNormalized: f32=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));var lodRefractionNormalizedDoubled: f32=lodRefractionNormalized*2.0;var environmentRefractionMid: vec4f=textureSample(refractionSampler,refractionSamplerSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
|
||
textureSample(refractionHighSampler,refractionHighSamplerSampler,refractionCoords),
|
||
environmentRefractionMid,
|
||
lodRefractionNormalizedDoubled
|
||
);} else {environmentRefraction=mix(
|
||
environmentRefractionMid,
|
||
textureSample(refractionLowSampler,refractionLowSamplerSampler,refractionCoords),
|
||
lodRefractionNormalizedDoubled-1.0
|
||
);}
|
||
#endif
|
||
var refraction=environmentRefraction.rgb;
|
||
#ifdef SS_RGBDREFRACTION
|
||
refraction=fromRGBD(environmentRefraction);
|
||
#endif
|
||
#ifdef SS_GAMMAREFRACTION
|
||
refraction=toLinearSpaceVec3(environmentRefraction.rgb);
|
||
#endif
|
||
return vec4f(refraction,environmentRefraction.a);}
|
||
#endif
|
||
#define pbr_inline
|
||
fn subSurfaceBlock(
|
||
vSubSurfaceIntensity: vec3f
|
||
,vThicknessParam: vec2f
|
||
,vTintColor: vec4f
|
||
,normalW: vec3f
|
||
,specularEnvironmentReflectance: vec3f
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
,thicknessMap: vec4f
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
,refractionIntensityMap: vec4f
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
,translucencyIntensityMap: vec4f
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef SS_TRANSLUCENCY
|
||
,reflectionMatrix: mat4x4f
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,irradianceVector_: vec3f
|
||
#endif
|
||
#if defined(REALTIME_FILTERING)
|
||
,reflectionSampler: texture_cube<f32>
|
||
,reflectionSamplerSampler: sampler
|
||
,vReflectionFilteringInfo: vec2f
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
#ifdef REFLECTIONMAP_3D
|
||
,irradianceSampler: texture_cube<f32>
|
||
,irradianceSamplerSampler: sampler
|
||
#else
|
||
,irradianceSampler: texture_2d<f32>
|
||
,irradianceSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
|
||
,surfaceAlbedo: vec3f
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
,vPositionW: vec3f
|
||
,viewDirectionW: vec3f
|
||
,view: mat4x4f
|
||
,vRefractionInfos: vec4f
|
||
,refractionMatrix: mat4x4f
|
||
,vRefractionMicrosurfaceInfos: vec4f
|
||
,vLightingIntensity: vec4f
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
,alpha: f32
|
||
#endif
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
,NdotVUnclamped: f32
|
||
#endif
|
||
#ifdef SS_LINEARSPECULARREFRACTION
|
||
,roughness: f32
|
||
#endif
|
||
,alphaG: f32
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
,refractionSampler: texture_cube<f32>
|
||
,refractionSamplerSampler: sampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionLowSampler: texture_cube<f32>
|
||
,refractionLowSamplerSampler: sampler
|
||
,refractionHighSampler: texture_cube<f32>
|
||
,refractionHighSamplerSampler: sampler
|
||
#endif
|
||
#else
|
||
,refractionSampler: texture_2d<f32>
|
||
,refractionSamplerSampler: sampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionLowSampler: texture_2d<f32>
|
||
,refractionLowSamplerSampler: sampler
|
||
,refractionHighSampler: texture_2d<f32>
|
||
,refractionHighSamplerSampler: sampler
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut: anisotropicOutParams
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vRefractionFilteringInfo: vec2f
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,refractionPosition: vec3f
|
||
,refractionSize: vec3f
|
||
#endif
|
||
#ifdef SS_DISPERSION
|
||
,dispersion: f32
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
,vDiffusionDistance: vec3f
|
||
,vTranslucencyColor: vec4f
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
,translucencyColorMap: vec4f
|
||
#endif
|
||
#endif
|
||
)->subSurfaceOutParams
|
||
{var outParams: subSurfaceOutParams;outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
|
||
#ifdef SS_REFRACTION
|
||
var refractionIntensity: f32=vSubSurfaceIntensity.x;
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
var translucencyIntensity: f32=vSubSurfaceIntensity.y;
|
||
#endif
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
var thickness: f32=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
|
||
#else
|
||
var thickness: f32=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
outParams.thicknessMap=thicknessMap;
|
||
#endif
|
||
#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
refractionIntensity*=thicknessMap.r;
|
||
#else
|
||
refractionIntensity*=thicknessMap.g;
|
||
#endif
|
||
#endif
|
||
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
translucencyIntensity*=thicknessMap.a;
|
||
#else
|
||
translucencyIntensity*=thicknessMap.b;
|
||
#endif
|
||
#endif
|
||
#else
|
||
var thickness: f32=vThicknessParam.y;
|
||
#endif
|
||
#if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
refractionIntensity*=refractionIntensityMap.r;
|
||
#else
|
||
refractionIntensity*=refractionIntensityMap.g;
|
||
#endif
|
||
#endif
|
||
#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE)
|
||
#ifdef SS_USE_GLTF_TEXTURES
|
||
translucencyIntensity*=translucencyIntensityMap.a;
|
||
#else
|
||
translucencyIntensity*=translucencyIntensityMap.b;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
thickness=maxEps(thickness);var translucencyColor: vec4f=vTranslucencyColor;
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
translucencyColor*=translucencyColorMap;
|
||
#endif
|
||
var transmittance: vec3f=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.);
|
||
#ifdef SS_HAS_THICKNESS
|
||
var ior: f32=vRefractionInfos.y;
|
||
#else
|
||
var ior: f32=vRefractionMicrosurfaceInfos.w;
|
||
#endif
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaGNdotV(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
|
||
#elif defined(SS_LINEARSPECULARREFRACTION)
|
||
var refractionRoughness: f32=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
|
||
#else
|
||
var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
|
||
#endif
|
||
var refraction_ior: f32=vRefractionInfos.y;
|
||
#ifdef SS_DISPERSION
|
||
var realIOR: f32=1.0/refraction_ior;var iorDispersionSpread: f32=0.04*dispersion*(realIOR-1.0);var iors: vec3f= vec3f(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (var i: i32=0; i<3; i++) {refraction_ior=iors[i];
|
||
#endif
|
||
var envSample: vec4f=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG
|
||
#ifdef SS_REFRACTIONMAP_3D
|
||
,refractionSampler
|
||
,refractionSamplerSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionLowSampler
|
||
,refractionLowSamplerSampler
|
||
,refractionHighSampler
|
||
,refractionHighSamplerSampler
|
||
#endif
|
||
#else
|
||
,refractionSampler
|
||
,refractionSamplerSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionLowSampler
|
||
,refractionLowSamplerSampler
|
||
,refractionHighSampler
|
||
,refractionHighSamplerSampler
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vRefractionFilteringInfo
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,refractionPosition
|
||
,refractionSize
|
||
#endif
|
||
);
|
||
#ifdef SS_DISPERSION
|
||
environmentRefraction[i]=envSample[i];}
|
||
#else
|
||
environmentRefraction=envSample;
|
||
#endif
|
||
environmentRefraction=vec4f(environmentRefraction.rgb*vRefractionInfos.x,environmentRefraction.a);
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
var refractionTransmittance: vec3f= vec3f(refractionIntensity);
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,thickness);
|
||
#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
|
||
var maxChannel: f32=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);var volumeAlbedo: vec3f=saturateVec3(maxChannel*surfaceAlbedo);environmentRefraction=vec4f(environmentRefraction.rgb*volumeAlbedo,environmentRefraction.a);
|
||
#else
|
||
var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,vThicknessParam.y);
|
||
#endif
|
||
#ifdef SS_ALBEDOFORREFRACTIONTINT
|
||
environmentRefraction=vec4f(environmentRefraction.rgb*surfaceAlbedo.rgb,environmentRefraction.a);
|
||
#endif
|
||
outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
|
||
#ifdef REFLECTION
|
||
outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
|
||
#endif
|
||
#ifdef UNUSED_MULTIPLEBOUNCES
|
||
var bounceSpecularEnvironmentReflectance: vec3f=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
|
||
#endif
|
||
refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
|
||
#if DEBUGMODE>0
|
||
outParams.refractionTransmittance=refractionTransmittance;
|
||
#endif
|
||
outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
|
||
#if DEBUGMODE>0
|
||
outParams.environmentRefraction=environmentRefraction;
|
||
#endif
|
||
#endif
|
||
#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
|
||
var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz;
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
irradianceVector.z*=-1.0;
|
||
#endif
|
||
#ifdef INVERTCUBICMAP
|
||
irradianceVector.y*=-1.0;
|
||
#endif
|
||
#else
|
||
var irradianceVector: vec3f=irradianceVector_;
|
||
#endif
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP)
|
||
#if defined(REALTIME_FILTERING)
|
||
var refractionIrradiance: vec3f=irradiance(reflectionSampler,reflectionSamplerSampler,-irradianceVector,vReflectionFilteringInfo);
|
||
#else
|
||
var refractionIrradiance: vec3f=computeEnvironmentIrradiance(-irradianceVector);
|
||
#endif
|
||
#elif defined(USEIRRADIANCEMAP)
|
||
#ifdef REFLECTIONMAP_3D
|
||
var irradianceCoords: vec3f=irradianceVector;
|
||
#else
|
||
var irradianceCoords: vec2f=irradianceVector.xy;
|
||
#ifdef REFLECTIONMAP_PROJECTION
|
||
irradianceCoords/=irradianceVector.z;
|
||
#endif
|
||
irradianceCoords.y=1.0-irradianceCoords.y;
|
||
#endif
|
||
var temp: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,-irradianceCoords);var refractionIrradiance=temp.rgb;
|
||
#ifdef RGBDREFLECTION
|
||
refractionIrradiance=fromRGBD(temp).rgb;
|
||
#endif
|
||
#ifdef GAMMAREFLECTION
|
||
refractionIrradiance=toLinearSpaceVec3(refractionIrradiance);
|
||
#endif
|
||
#else
|
||
var refractionIrradiance: vec3f= vec3f(0.);
|
||
#endif
|
||
refractionIrradiance*=transmittance;
|
||
#ifdef SS_ALBEDOFORTRANSLUCENCYTINT
|
||
refractionIrradiance*=surfaceAlbedo.rgb;
|
||
#endif
|
||
outParams.refractionIrradiance=refractionIrradiance;
|
||
#endif
|
||
return outParams;}
|
||
#endif
|
||
`,e(30032),n.l.IncludesShadersStoreWGSL.pbrBlockNormalGeometric=`var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW);
|
||
#ifdef NORMAL
|
||
var normalW: vec3f=normalize(input.vNormalW);
|
||
#else
|
||
var normalW: vec3f=normalize(cross(dpdx(input.vPositionW),dpdy(input.vPositionW)))*scene.vEyePosition.w;
|
||
#endif
|
||
var geometricNormalW: vec3f=normalW;
|
||
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
||
geometricNormalW=select(-geometricNormalW,geometricNormalW,fragmentInputs.frontFacing);
|
||
#endif
|
||
`,e(20274),n.l.IncludesShadersStoreWGSL.pbrBlockNormalFinal=`#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
var faceNormal: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))*scene.vEyePosition.w;
|
||
#if defined(TWOSIDEDLIGHTING)
|
||
faceNormal=select(-faceNormal,faceNormal,fragmentInputs.frontFacing);
|
||
#endif
|
||
normalW*=sign(dot(normalW,faceNormal));
|
||
#endif
|
||
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
||
normalW=select(-normalW,normalW,fragmentInputs.frontFacing);
|
||
#endif
|
||
`,e(25757),n.l.IncludesShadersStoreWGSL.pbrBlockLightmapInit=`#ifdef LIGHTMAP
|
||
var lightmapColor: vec4f=textureSample(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset);
|
||
#ifdef RGBDLIGHTMAP
|
||
lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a);
|
||
#endif
|
||
#ifdef GAMMALIGHTMAP
|
||
lightmapColor=vec4f(toLinearSpaceVec3(lightmapColor.rgb),lightmapColor.a);
|
||
#endif
|
||
lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a);
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockGeometryInfo=`var NdotVUnclamped: f32=dot(normalW,viewDirectionW);var NdotV: f32=absEps(NdotVUnclamped);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var AARoughnessFactors: vec2f=getAARoughnessFactors(normalW.xyz);
|
||
#ifdef SPECULARAA
|
||
alphaG+=AARoughnessFactors.y;
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF)
|
||
var environmentBrdf: vec3f=getBRDFLookup(NdotV,roughness);
|
||
#endif
|
||
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
#ifdef RADIANCEOCCLUSION
|
||
#ifdef AMBIENTINGRAYSCALE
|
||
var ambientMonochrome: f32=aoOut.ambientOcclusionColor.r;
|
||
#else
|
||
var ambientMonochrome: f32=getLuminance(aoOut.ambientOcclusionColor);
|
||
#endif
|
||
var seo: f32=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
|
||
#endif
|
||
#ifdef HORIZONOCCLUSION
|
||
#ifdef BUMP
|
||
#ifdef REFLECTIONMAP_3D
|
||
var eho: f32=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockReflectance0=`var reflectance: f32=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);var specularEnvironmentR0: vec3f=reflectivityOut.surfaceReflectivityColor.rgb;
|
||
#ifdef METALLICWORKFLOW
|
||
var specularEnvironmentR90: vec3f= vec3f(metallicReflectanceFactors.a);
|
||
#else
|
||
var specularEnvironmentR90: vec3f= vec3f(1.0,1.0,1.0);
|
||
#endif
|
||
#ifdef ALPHAFRESNEL
|
||
var reflectance90: f32=fresnelGrazingReflectance(reflectance);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockReflectance=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
var specularEnvironmentReflectance: vec3f=getReflectanceFromBRDFWithEnvLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
|
||
#ifdef RADIANCEOCCLUSION
|
||
specularEnvironmentReflectance*=seo;
|
||
#endif
|
||
#ifdef HORIZONOCCLUSION
|
||
#ifdef BUMP
|
||
#ifdef REFLECTIONMAP_3D
|
||
specularEnvironmentReflectance*=eho;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#else
|
||
var specularEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
|
||
#if defined(CLEARCOAT_TINT)
|
||
specularEnvironmentReflectance*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockDirectLighting=`var diffuseBase: vec3f=vec3f(0.,0.,0.);
|
||
#ifdef SPECULARTERM
|
||
var specularBase: vec3f=vec3f(0.,0.,0.);
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
var clearCoatBase: vec3f=vec3f(0.,0.,0.);
|
||
#endif
|
||
#ifdef SHEEN
|
||
var sheenBase: vec3f=vec3f(0.,0.,0.);
|
||
#endif
|
||
var preInfo: preLightingInfo;var info: lightingInfo;var shadow: f32=1.;
|
||
var aggShadow: f32=0.;var numLights: f32=0.;
|
||
#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
|
||
var absorption: vec3f=vec3f(0.);
|
||
#endif
|
||
`,e(84192),n.l.IncludesShadersStoreWGSL.pbrBlockFinalLitComponents=`aggShadow=aggShadow/numLights;
|
||
#if defined(ENVIRONMENTBRDF)
|
||
#ifdef MS_BRDF_ENERGY_CONSERVATION
|
||
var energyConservationFactor: vec3f=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
|
||
#endif
|
||
#endif
|
||
#ifndef METALLICWORKFLOW
|
||
#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
|
||
surfaceAlbedo=(1.-reflectance)*surfaceAlbedo.rgb;
|
||
#endif
|
||
#endif
|
||
#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
|
||
surfaceAlbedo=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
|
||
#endif
|
||
#ifdef REFLECTION
|
||
var finalIrradiance: vec3f=reflectionOut.environmentIrradiance;
|
||
#if defined(CLEARCOAT)
|
||
finalIrradiance*=clearcoatOut.conservationFactor;
|
||
#if defined(CLEARCOAT_TINT)
|
||
finalIrradiance*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION)
|
||
finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
|
||
#endif
|
||
#if defined(SS_TRANSLUCENCY)
|
||
finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
|
||
#endif
|
||
finalIrradiance*=surfaceAlbedo.rgb;finalIrradiance*=uniforms.vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
var finalSpecular: vec3f=specularBase;finalSpecular=max(finalSpecular,vec3f(0.0));var finalSpecularScaled: vec3f=finalSpecular*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
finalSpecularScaled*=energyConservationFactor;
|
||
#endif
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
|
||
#endif
|
||
#endif
|
||
#ifdef REFLECTION
|
||
var finalRadiance: vec3f=reflectionOut.environmentRadiance.rgb;finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;var finalRadianceScaled: vec3f=finalRadiance*uniforms.vLightingIntensity.z;
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
finalRadianceScaled*=energyConservationFactor;
|
||
#endif
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
||
finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
|
||
#endif
|
||
#endif
|
||
#ifdef SHEEN
|
||
var finalSheen: vec3f=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,vec3f(0.0));var finalSheenScaled: vec3f=finalSheen*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
|
||
#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
|
||
#if defined(CLEARCOAT_TINT)
|
||
sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
var finalClearCoat: vec3f=clearCoatBase;finalClearCoat=max(finalClearCoat,vec3f(0.0));var finalClearCoatScaled: vec3f=finalClearCoat*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
|
||
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
|
||
#ifdef CLEARCOAT_TINT
|
||
subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#ifdef ALPHABLEND
|
||
var luminanceOverAlpha: f32=0.0;
|
||
#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
|
||
luminanceOverAlpha+=getLuminance(finalRadianceScaled);
|
||
#if defined(CLEARCOAT)
|
||
luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
|
||
#endif
|
||
#endif
|
||
#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
|
||
luminanceOverAlpha+=getLuminance(finalSpecularScaled);
|
||
#endif
|
||
#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
|
||
luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
|
||
#endif
|
||
#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
|
||
alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
|
||
#endif
|
||
#endif
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockFinalUnlitComponents=`var finalDiffuse: vec3f=diffuseBase;finalDiffuse*=surfaceAlbedo.rgb;finalDiffuse=max(finalDiffuse,vec3f(0.0));finalDiffuse*=uniforms.vLightingIntensity.x;var finalAmbient: vec3f=uniforms.vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;var finalEmissive: vec3f=uniforms.vEmissiveColor;
|
||
#ifdef EMISSIVE
|
||
var emissiveColorTex: vec3f=textureSample(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vEmissiveUV+uvOffset).rgb;
|
||
#ifdef GAMMAEMISSIVE
|
||
finalEmissive*=toLinearSpaceVec3(emissiveColorTex.rgb);
|
||
#else
|
||
finalEmissive*=emissiveColorTex.rgb;
|
||
#endif
|
||
finalEmissive*= uniforms.vEmissiveInfos.y;
|
||
#endif
|
||
finalEmissive*=uniforms.vLightingIntensity.y;
|
||
#ifdef AMBIENT
|
||
var ambientOcclusionForDirectDiffuse: vec3f=mix( vec3f(1.),aoOut.ambientOcclusionColor,uniforms.vAmbientInfos.w);
|
||
#else
|
||
var ambientOcclusionForDirectDiffuse: vec3f=aoOut.ambientOcclusionColor;
|
||
#endif
|
||
finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
|
||
`,n.l.IncludesShadersStoreWGSL.pbrBlockFinalColorComposition=`var finalColor: vec4f= vec4f(
|
||
#ifndef UNLIT
|
||
#ifdef REFLECTION
|
||
finalIrradiance +
|
||
#endif
|
||
#ifdef SPECULARTERM
|
||
finalSpecularScaled +
|
||
#endif
|
||
#ifdef SHEEN
|
||
finalSheenScaled +
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
finalClearCoatScaled +
|
||
#endif
|
||
#ifdef REFLECTION
|
||
finalRadianceScaled +
|
||
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
||
sheenOut.finalSheenRadianceScaled +
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
clearcoatOut.finalClearCoatRadianceScaled +
|
||
#endif
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
subSurfaceOut.finalRefraction +
|
||
#endif
|
||
#endif
|
||
finalAmbient +
|
||
finalDiffuse,
|
||
alpha);
|
||
#ifdef LIGHTMAP
|
||
#ifndef LIGHTMAPEXCLUDED
|
||
#ifdef USELIGHTMAPASSHADOWMAP
|
||
finalColor=vec4f(finalColor.rgb*lightmapColor.rgb,finalColor.a);
|
||
#else
|
||
finalColor=vec4f(finalColor.rgb+lightmapColor.rgb,finalColor.a);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
finalColor=vec4f(finalColor.rgb+finalEmissive,finalColor.a);
|
||
#define CUSTOM_FRAGMENT_BEFORE_FOG
|
||
finalColor=max(finalColor,vec4f(0.0));
|
||
`,e(56897),e(83512),n.l.IncludesShadersStoreWGSL.pbrBlockImageProcessing=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
|
||
#if !defined(SKIPFINALCOLORCLAMP)
|
||
finalColor=vec4f(clamp(finalColor.rgb,vec3f(0.),vec3f(30.0)),finalColor.a);
|
||
#endif
|
||
#else
|
||
finalColor=applyImageProcessing(finalColor);
|
||
#endif
|
||
finalColor=vec4f(finalColor.rgb,finalColor.a*mesh.visibility);
|
||
#ifdef PREMULTIPLYALPHA
|
||
finalColor=vec4f(finalColor.rgb*finalColor.a,finalColor.a);;
|
||
#endif
|
||
`,e(73876),n.l.IncludesShadersStoreWGSL.pbrDebug=`#if DEBUGMODE>0
|
||
if (input.vClipSpacePosition.x/input.vClipSpacePosition.w>=uniforms.vDebugMode.x) {var color: vec3f;
|
||
#if DEBUGMODE==1
|
||
color=fragmentInputs.vPositionW.rgb;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==2 && defined(NORMAL)
|
||
color=fragmentInputs.vNormalW.rgb;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
|
||
color=TBN[0];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
|
||
color=TBN[1];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==5
|
||
color=normalW;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==6 && defined(MAINUV1)
|
||
color= vec3f(input.vMainUV1,0.0);
|
||
#elif DEBUGMODE==7 && defined(MAINUV2)
|
||
color= vec3f(input.vMainUV2,0.0);
|
||
#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
|
||
color=clearcoatOut.TBNClearCoat[0];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
|
||
color=clearcoatOut.TBNClearCoat[1];
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==10 && defined(CLEARCOAT)
|
||
color=clearcoatOut.clearCoatNormalW;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==11 && defined(ANISOTROPIC)
|
||
color=anisotropicOut.anisotropicNormal;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==12 && defined(ANISOTROPIC)
|
||
color=anisotropicOut.anisotropicTangent;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==13 && defined(ANISOTROPIC)
|
||
color=anisotropicOut.anisotropicBitangent;
|
||
#define DEBUGMODE_NORMALIZE
|
||
#elif DEBUGMODE==20 && defined(ALBEDO)
|
||
color=albedoTexture.rgb;
|
||
#ifndef GAMMAALBEDO
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==21 && defined(AMBIENT)
|
||
color=aoOut.ambientOcclusionColorMap.rgb;
|
||
#elif DEBUGMODE==22 && defined(OPACITY)
|
||
color=opacityMap.rgb;
|
||
#elif DEBUGMODE==23 && defined(EMISSIVE)
|
||
color=emissiveColorTex.rgb;
|
||
#ifndef GAMMAEMISSIVE
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==24 && defined(LIGHTMAP)
|
||
color=lightmapColor;
|
||
#ifndef GAMMALIGHTMAP
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
|
||
color=reflectivityOut.surfaceMetallicColorMap.rgb;
|
||
#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
|
||
color=reflectivityOut.surfaceReflectivityColorMap.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
|
||
color= vec3f(clearcoatOut.clearCoatMapData.rg,0.0);
|
||
#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
||
color=clearcoatOut.clearCoatTintMapData.rgb;
|
||
#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
|
||
color=sheenOut.sheenMapData.rgb;
|
||
#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
|
||
color=anisotropicOut.anisotropyMapData.rgb;
|
||
#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
|
||
color=subSurfaceOut.thicknessMap.rgb;
|
||
#elif DEBUGMODE==32 && defined(BUMP)
|
||
color=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).rgb;
|
||
#elif DEBUGMODE==40 && defined(SS_REFRACTION)
|
||
color=subSurfaceOut.environmentRefraction.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==41 && defined(REFLECTION)
|
||
color=reflectionOut.environmentRadiance.rgb;
|
||
#ifndef GAMMAREFLECTION
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
|
||
color=clearcoatOut.environmentClearCoatRadiance.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==50
|
||
color=diffuseBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==51 && defined(SPECULARTERM)
|
||
color=specularBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==52 && defined(CLEARCOAT)
|
||
color=clearCoatBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==53 && defined(SHEEN)
|
||
color=sheenBase.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==54 && defined(REFLECTION)
|
||
color=reflectionOut.environmentIrradiance.rgb;
|
||
#ifndef GAMMAREFLECTION
|
||
#define DEBUGMODE_GAMMA
|
||
#endif
|
||
#elif DEBUGMODE==60
|
||
color=surfaceAlbedo.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==61
|
||
color=clearcoatOut.specularEnvironmentR0;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
|
||
color= vec3f(reflectivityOut.metallicRoughness.r);
|
||
#elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
|
||
color=reflectivityOut.metallicF0;
|
||
#elif DEBUGMODE==63
|
||
color= vec3f(roughness);
|
||
#elif DEBUGMODE==64
|
||
color= vec3f(alphaG);
|
||
#elif DEBUGMODE==65
|
||
color= vec3f(NdotV);
|
||
#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
|
||
color=clearcoatOut.clearCoatColor;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==67 && defined(CLEARCOAT)
|
||
color= vec3f(clearcoatOut.clearCoatRoughness);
|
||
#elif DEBUGMODE==68 && defined(CLEARCOAT)
|
||
color= vec3f(clearcoatOut.clearCoatNdotV);
|
||
#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
|
||
color=subSurfaceOut.transmittance;
|
||
#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
|
||
color=subSurfaceOut.refractionTransmittance;
|
||
#elif DEBUGMODE==72
|
||
color= vec3f(microSurface);
|
||
#elif DEBUGMODE==73
|
||
color=uniforms.vAlbedoColor.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
|
||
color=uniforms.vReflectivityColor.rgb;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==75
|
||
color=uniforms.vEmissiveColor;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
|
||
color= vec3f(seo);
|
||
#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
color= vec3f(eho);
|
||
#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
|
||
color= vec3f(energyConservationFactor);
|
||
#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
color=specularEnvironmentReflectance;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
||
color=clearcoatOut.clearCoatEnvironmentReflectance;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
|
||
color=sheenOut.sheenEnvironmentReflectance;
|
||
#define DEBUGMODE_GAMMA
|
||
#elif DEBUGMODE==86 && defined(ALPHABLEND)
|
||
color= vec3f(luminanceOverAlpha);
|
||
#elif DEBUGMODE==87
|
||
color= vec3f(alpha);
|
||
#elif DEBUGMODE==88 && defined(ALBEDO)
|
||
color= vec3f(albedoTexture.a);
|
||
#elif DEBUGMODE==89
|
||
color=aoOut.ambientOcclusionColor;
|
||
#else
|
||
var stripeWidth: f32=30.;var stripePos: f32=abs(floor(input.position.x/stripeWidth));var whichColor: f32=((stripePos)%(2.));var color1: vec3f= vec3f(.6,.2,.2);var color2: vec3f= vec3f(.3,.1,.1);color=mix(color1,color2,whichColor);
|
||
#endif
|
||
color*=uniforms.vDebugMode.y;
|
||
#ifdef DEBUGMODE_NORMALIZE
|
||
color=normalize(color)*0.5+0.5;
|
||
#endif
|
||
#ifdef DEBUGMODE_GAMMA
|
||
color=toGammaSpaceVec3(color);
|
||
#endif
|
||
fragmentOutputs.color=vec4f(color,1.0);
|
||
#ifdef PREPASS
|
||
fragmentOutputs.fragData0=toLinearSpaceVec3(color);
|
||
fragmentOutputs.fragData1=vec4f(0.,0.,0.,0.);
|
||
#endif
|
||
#ifdef DEBUGMODE_FORCERETURN
|
||
return fragmentOutputs;
|
||
#endif
|
||
}
|
||
#endif
|
||
`;var o="pbrPixelShader",a=`#define CUSTOM_FRAGMENT_BEGIN
|
||
#include<prePassDeclaration>[SCENE_MRT_COUNT]
|
||
#include<oitDeclaration>
|
||
#ifndef FROMLINEARSPACE
|
||
#define FROMLINEARSPACE
|
||
#endif
|
||
#include<pbrUboDeclaration>
|
||
#include<pbrFragmentExtraDeclaration>
|
||
#include<lightUboDeclaration>[0..maxSimultaneousLights]
|
||
#include<pbrFragmentSamplersDeclaration>
|
||
#include<imageProcessingDeclaration>
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
#include<helperFunctions>
|
||
#include<subSurfaceScatteringFunctions>
|
||
#include<importanceSampling>
|
||
#include<pbrHelperFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#include<shadowsFragmentFunctions>
|
||
#include<harmonicsFunctions>
|
||
#include<pbrDirectLightingSetupFunctions>
|
||
#include<pbrDirectLightingFalloffFunctions>
|
||
#include<pbrBRDFFunctions>
|
||
#include<hdrFilteringFunctions>
|
||
#include<pbrDirectLightingFunctions>
|
||
#include<pbrIBLFunctions>
|
||
#include<bumpFragmentMainFunctions>
|
||
#include<bumpFragmentFunctions>
|
||
#ifdef REFLECTION
|
||
#include<reflectionFunction>
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
#include<pbrBlockAlbedoOpacity>
|
||
#include<pbrBlockReflectivity>
|
||
#include<pbrBlockAmbientOcclusion>
|
||
#include<pbrBlockAlphaFresnel>
|
||
#include<pbrBlockAnisotropic>
|
||
#include<pbrBlockReflection>
|
||
#include<pbrBlockSheen>
|
||
#include<pbrBlockClearcoat>
|
||
#include<pbrBlockIridescence>
|
||
#include<pbrBlockSubSurface>
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#include<clipPlaneFragment>
|
||
#include<pbrBlockNormalGeometric>
|
||
#include<bumpFragment>
|
||
#include<pbrBlockNormalFinal>
|
||
var albedoOpacityOut: albedoOpacityOutParams;
|
||
#ifdef ALBEDO
|
||
var albedoTexture: vec4f=textureSample(albedoSampler,albedoSamplerSampler,fragmentInputs.vAlbedoUV+uvOffset);
|
||
#endif
|
||
#ifdef OPACITY
|
||
var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset);
|
||
#endif
|
||
#ifdef DECAL
|
||
var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
|
||
#endif
|
||
albedoOpacityOut=albedoOpacityBlock(
|
||
uniforms.vAlbedoColor
|
||
#ifdef ALBEDO
|
||
,albedoTexture
|
||
,uniforms.vAlbedoInfos
|
||
#endif
|
||
#ifdef OPACITY
|
||
,opacityMap
|
||
,uniforms.vOpacityInfos
|
||
#endif
|
||
#ifdef DETAIL
|
||
,detailColor
|
||
,uniforms.vDetailInfos
|
||
#endif
|
||
#ifdef DECAL
|
||
,decalColor
|
||
,uniforms.vDecalInfos
|
||
#endif
|
||
);var surfaceAlbedo: vec3f=albedoOpacityOut.surfaceAlbedo;var alpha: f32=albedoOpacityOut.alpha;
|
||
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
|
||
#include<depthPrePass>
|
||
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
||
var aoOut: ambientOcclusionOutParams;
|
||
#ifdef AMBIENT
|
||
var ambientOcclusionColorMap: vec3f=textureSample(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb;
|
||
#endif
|
||
aoOut=ambientOcclusionBlock(
|
||
#ifdef AMBIENT
|
||
ambientOcclusionColorMap,
|
||
uniforms.vAmbientInfos
|
||
#endif
|
||
);
|
||
#include<pbrBlockLightmapInit>
|
||
#ifdef UNLIT
|
||
var diffuseBase: vec3f= vec3f(1.,1.,1.);
|
||
#else
|
||
var baseColor: vec3f=surfaceAlbedo;var reflectivityOut: reflectivityOutParams;
|
||
#if defined(REFLECTIVITY)
|
||
var surfaceMetallicOrReflectivityColorMap: vec4f=textureSample(reflectivitySampler,reflectivitySamplerSampler,fragmentInputs.vReflectivityUV+uvOffset);var baseReflectivity: vec4f=surfaceMetallicOrReflectivityColorMap;
|
||
#ifndef METALLICWORKFLOW
|
||
#ifdef REFLECTIVITY_GAMMA
|
||
surfaceMetallicOrReflectivityColorMap=toLinearSpaceVec4(surfaceMetallicOrReflectivityColorMap);
|
||
#endif
|
||
surfaceMetallicOrReflectivityColorMap=vec4f(surfaceMetallicOrReflectivityColorMap.rgb*uniforms.vReflectivityInfos.y,surfaceMetallicOrReflectivityColorMap.a);
|
||
#endif
|
||
#endif
|
||
#if defined(MICROSURFACEMAP)
|
||
var microSurfaceTexel: vec4f=textureSample(microSurfaceSampler,microSurfaceSamplerSampler,fragmentInputs.vMicroSurfaceSamplerUV+uvOffset)*uniforms.vMicroSurfaceSamplerInfos.y;
|
||
#endif
|
||
#ifdef METALLICWORKFLOW
|
||
var metallicReflectanceFactors: vec4f=uniforms.vMetallicReflectanceFactors;
|
||
#ifdef REFLECTANCE
|
||
var reflectanceFactorsMap: vec4f=textureSample(reflectanceSampler,reflectanceSamplerSampler,fragmentInputs.vReflectanceUV+uvOffset);
|
||
#ifdef REFLECTANCE_GAMMA
|
||
reflectanceFactorsMap=toLinearSpaceVec4(reflectanceFactorsMap);
|
||
#endif
|
||
metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*reflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
|
||
#endif
|
||
#ifdef METALLIC_REFLECTANCE
|
||
var metallicReflectanceFactorsMap: vec4f=textureSample(metallicReflectanceSampler,metallicReflectanceSamplerSampler,fragmentInputs.vMetallicReflectanceUV+uvOffset);
|
||
#ifdef METALLIC_REFLECTANCE_GAMMA
|
||
metallicReflectanceFactorsMap=toLinearSpaceVec4(metallicReflectanceFactorsMap);
|
||
#endif
|
||
#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
|
||
metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*reflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
|
||
#endif
|
||
metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
|
||
#endif
|
||
#endif
|
||
reflectivityOut=reflectivityBlock(
|
||
uniforms.vReflectivityColor
|
||
#ifdef METALLICWORKFLOW
|
||
,surfaceAlbedo
|
||
,metallicReflectanceFactors
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
,uniforms.vReflectivityInfos
|
||
,surfaceMetallicOrReflectivityColorMap
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
,aoOut.ambientOcclusionColor
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
,microSurfaceTexel
|
||
#endif
|
||
#ifdef DETAIL
|
||
,detailColor
|
||
,uniforms.vDetailInfos
|
||
#endif
|
||
);var microSurface: f32=reflectivityOut.microSurface;var roughness: f32=reflectivityOut.roughness;
|
||
#ifdef METALLICWORKFLOW
|
||
surfaceAlbedo=reflectivityOut.surfaceAlbedo;
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
|
||
#endif
|
||
#ifdef ALPHAFRESNEL
|
||
#if defined(ALPHATEST) || defined(ALPHABLEND)
|
||
var alphaFresnelOut: alphaFresnelOutParams;alphaFresnelOut=alphaFresnelBlock(
|
||
normalW,
|
||
viewDirectionW,
|
||
alpha,
|
||
microSurface
|
||
);alpha=alphaFresnelOut.alpha;
|
||
#endif
|
||
#endif
|
||
#include<pbrBlockGeometryInfo>
|
||
#ifdef ANISOTROPIC
|
||
var anisotropicOut: anisotropicOutParams;
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
var anisotropyMapData: vec3f=textureSample(anisotropySampler,anisotropySamplerSampler,fragmentInputs.vAnisotropyUV+uvOffset).rgb*uniforms.vAnisotropyInfos.y;
|
||
#endif
|
||
anisotropicOut=anisotropicBlock(
|
||
uniforms.vAnisotropy,
|
||
roughness,
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
anisotropyMapData,
|
||
#endif
|
||
TBN,
|
||
normalW,
|
||
viewDirectionW
|
||
);
|
||
#endif
|
||
#ifdef REFLECTION
|
||
var reflectionOut: reflectionOutParams;
|
||
#ifndef USE_CUSTOM_REFLECTION
|
||
reflectionOut=reflectionBlock(
|
||
fragmentInputs.vPositionW
|
||
,normalW
|
||
,alphaG
|
||
,uniforms.vReflectionMicrosurfaceInfos
|
||
,uniforms.vReflectionInfos
|
||
,uniforms.vReflectionColor
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut
|
||
#endif
|
||
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
||
,NdotVUnclamped
|
||
#endif
|
||
#ifdef LINEARSPECULARREFLECTION
|
||
,roughness
|
||
#endif
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
||
,fragmentInputs.vEnvironmentIrradiance
|
||
#endif
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,uniforms.reflectionMatrix
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
,irradianceSampler
|
||
,irradianceSamplerSampler
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionLowSampler
|
||
,reflectionLowSamplerSampler
|
||
,reflectionHighSampler
|
||
,reflectionHighSamplerSampler
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,uniforms.vReflectionFilteringInfo
|
||
#endif
|
||
);
|
||
#else
|
||
#define CUSTOM_REFLECTION
|
||
#endif
|
||
#endif
|
||
#include<pbrBlockReflectance0>
|
||
#ifdef SHEEN
|
||
var sheenOut: sheenOutParams;
|
||
#ifdef SHEEN_TEXTURE
|
||
var sheenMapData: vec4f=textureSample(sheenSampler,sheenSamplerSampler,fragmentInputs.vSheenUV+uvOffset);
|
||
#endif
|
||
#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
var sheenMapRoughnessData: vec4f=textureSample(sheenRoughnessSampler,sheenRoughnessSamplerSampler,fragmentInputs.vSheenRoughnessUV+uvOffset)*uniforms.vSheenInfos.w;
|
||
#endif
|
||
sheenOut=sheenBlock(
|
||
uniforms.vSheenColor
|
||
#ifdef SHEEN_ROUGHNESS
|
||
,uniforms.vSheenRoughness
|
||
#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,sheenMapRoughnessData
|
||
#endif
|
||
#endif
|
||
,roughness
|
||
#ifdef SHEEN_TEXTURE
|
||
,sheenMapData
|
||
,uniforms.vSheenInfos.y
|
||
#endif
|
||
,reflectance
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
,baseColor
|
||
,surfaceAlbedo
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
,NdotV
|
||
,environmentBrdf
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
,AARoughnessFactors
|
||
,uniforms.vReflectionMicrosurfaceInfos
|
||
,uniforms.vReflectionInfos
|
||
,uniforms.vReflectionColor
|
||
,uniforms.vLightingIntensity
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
,reflectionOut.reflectionCoords
|
||
,NdotVUnclamped
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionLowSampler
|
||
,reflectionLowSamplerSampler
|
||
,reflectionHighSampler
|
||
,reflectionHighSamplerSampler
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
|
||
,seo
|
||
#endif
|
||
#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
|
||
,eho
|
||
#endif
|
||
#endif
|
||
);
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
surfaceAlbedo=sheenOut.surfaceAlbedo;
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
var clearCoatMapData: vec2f=textureSample(clearCoatSampler,clearCoatSamplerSampler,fragmentInputs.vClearCoatUV+uvOffset).rg*uniforms.vClearCoatInfos.y;
|
||
#endif
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
var iridescenceOut: iridescenceOutParams;
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
var iridescenceMapData: vec2f=textureSample(iridescenceSampler,iridescenceSamplerSampler,fragmentInputs.vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
var iridescenceThicknessMapData: vec2f=textureSample(iridescenceThicknessSampler,iridescenceThicknessSamplerSampler,fragmentInputs.vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
|
||
#endif
|
||
iridescenceOut=iridescenceBlock(
|
||
uniforms.vIridescenceParams
|
||
,NdotV
|
||
,specularEnvironmentR0
|
||
#ifdef IRIDESCENCE_TEXTURE
|
||
,iridescenceMapData
|
||
#endif
|
||
#ifdef IRIDESCENCE_THICKNESS_TEXTURE
|
||
,iridescenceThicknessMapData
|
||
#endif
|
||
#ifdef CLEARCOAT
|
||
,NdotVUnclamped
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,clearCoatMapData
|
||
#endif
|
||
#endif
|
||
);var iridescenceIntensity: f32=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
|
||
#endif
|
||
var clearcoatOut: clearcoatOutParams;
|
||
#ifdef CLEARCOAT
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
var clearCoatMapRoughnessData: vec4f=textureSample(clearCoatRoughnessSampler,clearCoatRoughnessSamplerSampler,fragmentInputs.vClearCoatRoughnessUV+uvOffset)*uniforms.vClearCoatInfos.w;
|
||
#endif
|
||
#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
|
||
var clearCoatTintMapData: vec4f=textureSample(clearCoatTintSampler,clearCoatTintSamplerSampler,fragmentInputs.vClearCoatTintUV+uvOffset);
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
var clearCoatBumpMapData: vec4f=textureSample(clearCoatBumpSampler,clearCoatBumpSamplerSampler,fragmentInputs.vClearCoatBumpUV+uvOffset);
|
||
#endif
|
||
clearcoatOut=clearcoatBlock(
|
||
fragmentInputs.vPositionW
|
||
,geometricNormalW
|
||
,viewDirectionW
|
||
,uniforms.vClearCoatParams
|
||
#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
|
||
,clearCoatMapRoughnessData
|
||
#endif
|
||
,specularEnvironmentR0
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
,clearCoatMapData
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
,uniforms.vClearCoatTintParams
|
||
,uniforms.clearCoatColorAtDistance
|
||
,uniforms.vClearCoatRefractionParams
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
,clearCoatTintMapData
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
,uniforms.vClearCoatBumpInfos
|
||
,clearCoatBumpMapData
|
||
,fragmentInputs.vClearCoatBumpUV
|
||
#if defined(TANGENT) && defined(NORMAL)
|
||
,vTBN
|
||
#else
|
||
,uniforms.vClearCoatTangentSpaceParams
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
,uniforms.normalMatrix
|
||
#endif
|
||
#endif
|
||
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
,faceNormal
|
||
#endif
|
||
#ifdef REFLECTION
|
||
,uniforms.vReflectionMicrosurfaceInfos
|
||
,uniforms.vReflectionInfos
|
||
,uniforms.vReflectionColor
|
||
,uniforms.vLightingIntensity
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,reflectionLowSampler
|
||
,reflectionLowSamplerSampler
|
||
,reflectionHighSampler
|
||
,reflectionHighSamplerSampler
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,uniforms.vReflectionFilteringInfo
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
|
||
,select(-1.,1.,fragmentInputs.frontFacing)
|
||
#endif
|
||
);
|
||
#else
|
||
clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
|
||
#endif
|
||
#include<pbrBlockReflectance>
|
||
var subSurfaceOut: subSurfaceOutParams;
|
||
#ifdef SUBSURFACE
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
var thicknessMap: vec4f=textureSample(thicknessSampler,thicknessSamplerSampler,fragmentInputs.vThicknessUV+uvOffset);
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
var refractionIntensityMap: vec4f=textureSample(refractionIntensitySampler,refractionIntensitySamplerSampler,fragmentInputs.vRefractionIntensityUV+uvOffset);
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
var translucencyIntensityMap: vec4f=textureSample(translucencyIntensitySampler,translucencyIntensitySamplerSampler,fragmentInputs.vTranslucencyIntensityUV+uvOffset);
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
var translucencyColorMap: vec4f=textureSample(translucencyColorSampler,translucencyColorSamplerSampler,fragmentInputs.vTranslucencyColorUV+uvOffset);
|
||
#endif
|
||
subSurfaceOut=subSurfaceBlock(
|
||
uniforms.vSubSurfaceIntensity
|
||
,uniforms.vThicknessParam
|
||
,uniforms.vTintColor
|
||
,normalW
|
||
,specularEnvironmentReflectance
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
,thicknessMap
|
||
#endif
|
||
#ifdef SS_REFRACTIONINTENSITY_TEXTURE
|
||
,refractionIntensityMap
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
|
||
,translucencyIntensityMap
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef SS_TRANSLUCENCY
|
||
,uniforms.reflectionMatrix
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
,reflectionOut.irradianceVector
|
||
#endif
|
||
#if defined(REALTIME_FILTERING)
|
||
,reflectionSampler
|
||
,reflectionSamplerSampler
|
||
,vReflectionFilteringInfo
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
,irradianceSampler
|
||
,irradianceSamplerSampler
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
|
||
,surfaceAlbedo
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
,fragmentInputs.vPositionW
|
||
,viewDirectionW
|
||
,scene.view
|
||
,uniforms.vRefractionInfos
|
||
,uniforms.refractionMatrix
|
||
,uniforms.vRefractionMicrosurfaceInfos
|
||
,uniforms.vLightingIntensity
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
,alpha
|
||
#endif
|
||
#ifdef SS_LODINREFRACTIONALPHA
|
||
,NdotVUnclamped
|
||
#endif
|
||
#ifdef SS_LINEARSPECULARREFRACTION
|
||
,roughness
|
||
#endif
|
||
,alphaG
|
||
,refractionSampler
|
||
,refractionSamplerSampler
|
||
#ifndef LODBASEDMICROSFURACE
|
||
,refractionLowSampler
|
||
,refractionLowSamplerSampler
|
||
,refractionHighSampler
|
||
,refractionHighSamplerSampler
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
,uniforms.vRefractionFilteringInfo
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
,uniforms.vRefractionPosition
|
||
,uniforms.vRefractionSize
|
||
#endif
|
||
#ifdef SS_DISPERSION
|
||
,dispersion
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
,uniforms.vDiffusionDistance
|
||
,uniforms.vTranslucencyColor
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
,translucencyColorMap
|
||
#endif
|
||
#endif
|
||
);
|
||
#ifdef SS_REFRACTION
|
||
surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
alpha=subSurfaceOut.alpha;
|
||
#endif
|
||
#endif
|
||
#else
|
||
subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
|
||
#endif
|
||
#include<pbrBlockDirectLighting>
|
||
#include<lightFragment>[0..maxSimultaneousLights]
|
||
#include<pbrBlockFinalLitComponents>
|
||
#endif
|
||
#include<pbrBlockFinalUnlitComponents>
|
||
#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
|
||
#include<pbrBlockFinalColorComposition>
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>(color,finalColor)
|
||
#include<pbrBlockImageProcessing>
|
||
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
|
||
#ifdef PREPASS
|
||
var writeGeometryInfo: f32=select(0.0,1.0,finalColor.a>ALPHATESTVALUE);var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
|
||
#ifdef PREPASS_POSITION
|
||
fragData[PREPASS_POSITION_INDEX]= vec4f(fragmentInputs.vPositionW,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_LOCAL_POSITION
|
||
fragData[PREPASS_LOCAL_POSITION_INDEX] =
|
||
vec4f(fragmentInputs.vPosition,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_VELOCITY
|
||
var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo);
|
||
#elif defined(PREPASS_VELOCITY_LINEAR)
|
||
var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy /
|
||
fragmentInputs.vPreviousPosition.w) -
|
||
(fragmentInputs.vCurrentPosition.xy /
|
||
fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX] =
|
||
vec4f(velocity,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_ALBEDO_SQRT
|
||
var sqAlbedo : vec3f=sqrt(surfaceAlbedo);
|
||
#endif
|
||
#ifdef PREPASS_IRRADIANCE
|
||
var irradiance : vec3f=finalDiffuse;
|
||
#ifndef UNLIT
|
||
#ifdef REFLECTION
|
||
irradiance+=finalIrradiance;
|
||
#endif
|
||
#endif
|
||
#ifdef SS_SCATTERING
|
||
fragData[0]=vec4f(finalColor.rgb-irradiance,
|
||
finalColor.a);
|
||
irradiance/=sqAlbedo;
|
||
#else
|
||
fragData[0]=finalColor;
|
||
var scatteringDiffusionProfile : f32=255.;
|
||
#endif
|
||
fragData[PREPASS_IRRADIANCE_INDEX] =
|
||
vec4f(clamp(irradiance,vec3f(0.),vec3f(1.)),
|
||
writeGeometryInfo*scatteringDiffusionProfile /
|
||
255.);
|
||
#else
|
||
fragData[0]=vec4f(finalColor.rgb,finalColor.a);
|
||
#endif
|
||
#ifdef PREPASS_DEPTH
|
||
fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,
|
||
writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_SCREENSPACE_DEPTH
|
||
fragData[PREPASS_SCREENSPACE_DEPTH_INDEX] =
|
||
vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_NORMAL
|
||
#ifdef PREPASS_NORMAL_WORLDSPACE
|
||
fragData[PREPASS_NORMAL_INDEX] =
|
||
vec4f(normalW,writeGeometryInfo);
|
||
#else
|
||
fragData[PREPASS_NORMAL_INDEX] =
|
||
vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),
|
||
writeGeometryInfo);
|
||
#endif
|
||
#endif
|
||
#ifdef PREPASS_WORLD_NORMAL
|
||
fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_ALBEDO_SQRT
|
||
fragData[PREPASS_ALBEDO_SQRT_INDEX] =
|
||
vec4f(sqAlbedo,writeGeometryInfo);
|
||
#endif
|
||
#ifdef PREPASS_REFLECTIVITY
|
||
#ifndef UNLIT
|
||
fragData[PREPASS_REFLECTIVITY_INDEX] =
|
||
vec4f(specularEnvironmentR0,microSurface)*writeGeometryInfo;
|
||
#else
|
||
fragData[PREPASS_REFLECTIVITY_INDEX] =
|
||
vec4f(0.0,0.0,0.0,1.0)*writeGeometryInfo;
|
||
#endif
|
||
#endif
|
||
#if SCENE_MRT_COUNT>0
|
||
fragmentOutputs.fragData0=fragData[0];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>1
|
||
fragmentOutputs.fragData1=fragData[1];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>2
|
||
fragmentOutputs.fragData2=fragData[2];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>3
|
||
fragmentOutputs.fragData3=fragData[3];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>4
|
||
fragmentOutputs.fragData4=fragData[4];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>5
|
||
fragmentOutputs.fragData5=fragData[5];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>6
|
||
fragmentOutputs.fragData6=fragData[6];
|
||
#endif
|
||
#if SCENE_MRT_COUNT>7
|
||
fragmentOutputs.fragData7=fragData[7];
|
||
#endif
|
||
#endif
|
||
#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY)
|
||
fragmentOutputs.color=finalColor;
|
||
#endif
|
||
#include<oitFragment>
|
||
#if ORDER_INDEPENDENT_TRANSPARENCY
|
||
if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+finalColor.rgb*finalColor.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-finalColor.a));} else {fragmentOutputs.backColor+=finalColor;}
|
||
#endif
|
||
#include<pbrDebug>
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[o]=a;var s={name:o,shader:a}},10721:(r,t,e)=>{e.r(t),e.d(t,{pbrVertexShaderWGSL:()=>a});var n=e(98519),i=(e(14052),e(56213),e(14188),e(17393),e(45699),e(27279),e(63866),e(84020),e(12520),e(44467),e(33330),e(9436),e(79716),e(58902),e(73683),e(68478),e(38197),e(98819),e(77320),e(21310),e(3641),e(86615),e(21954),e(28981),e(88380),e(19748),e(63002),e(70898),e(59115),e(50615),e(55607),"pbrVertexShader"),o=`#include<pbrUboDeclaration>
|
||
#define CUSTOM_VERTEX_BEGIN
|
||
attribute position: vec3f;
|
||
#ifdef NORMAL
|
||
attribute normal: vec3f;
|
||
#endif
|
||
#ifdef TANGENT
|
||
attribute tangent: vec4f;
|
||
#endif
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#include<uvAttributeDeclaration>[2..7]
|
||
#include<mainUVVaryingDeclaration>[1..7]
|
||
#ifdef VERTEXCOLOR
|
||
attribute color: vec4f;
|
||
#endif
|
||
#include<helperFunctions>
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<instancesDeclaration>
|
||
#include<prePassVertexDeclaration>
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
|
||
#ifdef CLEARCOAT
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness)
|
||
#endif
|
||
#ifdef SHEEN
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)
|
||
#include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor)
|
||
#endif
|
||
varying vPositionW: vec3f;
|
||
#if DEBUGMODE>0
|
||
varying vClipSpacePosition: vec4f;
|
||
#endif
|
||
#ifdef NORMAL
|
||
varying vNormalW: vec3f;
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
varying vEnvironmentIrradiance: vec3f;
|
||
#include<harmonicsFunctions>
|
||
#endif
|
||
#endif
|
||
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
||
varying vColor: vec4f;
|
||
#endif
|
||
#include<bumpVertexDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<lightVxUboDeclaration>[0..maxSimultaneousLights]
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
varying vPositionUVW: vec3f;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
varying vDirectionW: vec3f;
|
||
#endif
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
var positionUpdated: vec3f=vertexInputs.position;
|
||
#ifdef NORMAL
|
||
var normalUpdated: vec3f=vertexInputs.normal;
|
||
#endif
|
||
#ifdef TANGENT
|
||
var tangentUpdated: vec4f=vertexInputs.tangent;
|
||
#endif
|
||
#ifdef UV1
|
||
var uvUpdated: vec2f=vertexInputs.uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#ifdef REFLECTIONMAP_SKYBOX
|
||
vertexOutputs.vPositionUVW=positionUpdated;
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_POSITION
|
||
#define CUSTOM_VERTEX_UPDATE_NORMAL
|
||
#include<instancesVertex>
|
||
#if defined(PREPASS) && (defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED) || defined(PREPASS_VELOCITY_LINEAR))
|
||
vertexOutputs.vCurrentPosition=scene.viewProjection*finalWorld* vec4f(positionUpdated,1.0);vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0);
|
||
#endif
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);vertexOutputs.vPositionW= worldPos.xyz;
|
||
#include<prePassVertex>
|
||
#ifdef NORMAL
|
||
var normalWorld: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz);
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
vertexOutputs.vNormalW=normalUpdated/ vec3f(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vertexOutputs.vNormalW=normalize(normalWorld*vertexOutputs.vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normalWorld=transposeMat3(inverseMat3(normalWorld));
|
||
#endif
|
||
vertexOutputs.vNormalW=normalize(normalWorld*normalUpdated);
|
||
#endif
|
||
#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
var reflectionVector: vec3f= (uniforms.reflectionMatrix* vec4f(vertexOutputs.vNormalW,0)).xyz;
|
||
#ifdef REFLECTIONMAP_OPPOSITEZ
|
||
reflectionVector.z*=-1.0;
|
||
#endif
|
||
vertexOutputs.vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
|
||
#endif
|
||
#endif
|
||
#define CUSTOM_VERTEX_UPDATE_WORLDPOS
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {vertexOutputs.position=scene.viewProjection*worldPos;} else {vertexOutputs.position=scene.viewProjectionR*worldPos;}
|
||
#else
|
||
vertexOutputs.position=scene.viewProjection*worldPos;
|
||
#endif
|
||
#if DEBUGMODE>0
|
||
vertexOutputs.vClipSpacePosition=vertexOutputs.position;
|
||
#endif
|
||
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
||
vertexOutputs.vDirectionW=normalize((finalWorld*vec4f(positionUpdated,0.0)).xyz);
|
||
#endif
|
||
#ifndef UV1
|
||
var uvUpdated: vec2f= vec2f(0.,0.);
|
||
#endif
|
||
#ifdef MAINUV1
|
||
vertexOutputs.vMainUV1=uvUpdated;
|
||
#endif
|
||
#include<uvVariableDeclaration>[2..7]
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
|
||
#ifdef CLEARCOAT
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)
|
||
#endif
|
||
#ifdef IRIDESCENCE
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z)
|
||
#endif
|
||
#ifdef SHEEN
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheenRoughness,_INFONAME_,SheenInfos.z)
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)
|
||
#endif
|
||
#ifdef SUBSURFACE
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)
|
||
#include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_MATRIXNAME_,translucencyColor,_INFONAME_,TranslucencyColorInfos.x)
|
||
#endif
|
||
#include<bumpVertex>
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<shadowsVertex>[0..maxSimultaneousLights]
|
||
#include<vertexColorMixing>
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},72014:(r,t,e)=>{e.r(t),e.d(t,{pickingPixelShaderWGSL:()=>o});var n="pickingPixelShader",i=`#if defined(INSTANCES)
|
||
varying vMeshID: vec4f;
|
||
#else
|
||
uniform meshID: vec4f;
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#if defined(INSTANCES)
|
||
fragmentOutputs.color=input.vMeshID;
|
||
#else
|
||
fragmentOutputs.color=uniforms.meshID;
|
||
#endif
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},96672:(r,t,e)=>{e.r(t),e.d(t,{pickingVertexShaderWGSL:()=>a});var n=e(98519),i=(e(45699),e(27279),e(73683),e(68478),e(63866),e(98819),e(77320),e(21310),e(3641),e(86615),"pickingVertexShader"),o=`attribute position: vec3f;
|
||
#if defined(INSTANCES)
|
||
attribute instanceMeshID: vec4f;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesDeclaration>
|
||
uniform viewProjection: mat4x4f;
|
||
#if defined(INSTANCES)
|
||
varying vMeshID: vec4f;
|
||
#endif
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld*vec4f(input.position,1.0);vertexOutputs.position=uniforms.viewProjection*worldPos;
|
||
#if defined(INSTANCES)
|
||
vertexOutputs.vMeshID=input.instanceMeshID;
|
||
#endif
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},3072:(r,t,e)=>{e.r(t),e.d(t,{postprocessVertexShaderWGSL:()=>o});var n="postprocessVertexShader",i=`attribute position: vec2<f32>;uniform scale: vec2<f32>;varying vUV: vec2<f32>;const madd=vec2(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;vertexOutputs.position=vec4(vertexInputs.position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},67400:(r,t,e)=>{e.r(t),e.d(t,{proceduralVertexShaderWGSL:()=>o});var n="proceduralVertexShader",i=`attribute position: vec2f;varying vPosition: vec2f;varying vUV: vec2f;const madd: vec2f= vec2f(0.5,0.5);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vertexOutputs.vPosition=input.position;vertexOutputs.vUV=input.position*madd+madd;vertexOutputs.position= vec4f(input.position,0.0,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},37494:(r,t,e)=>{e.r(t),e.d(t,{rgbdDecodePixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),"rgbdDecodePixelShader"),o=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
#include<helperFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(fromRGBD(textureSample(textureSampler,textureSamplerSampler,input.vUV)),1.0);}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},86558:(r,t,e)=>{e.r(t),e.d(t,{rgbdEncodePixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),"rgbdEncodePixelShader"),o=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
#include<helperFunctions>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=toRGBD(textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb);}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},97666:(r,t,e)=>{e.r(t),e.d(t,{rsmFullGlobalIlluminationPixelShaderWGSL:()=>o});var n="rsmFullGlobalIlluminationPixelShader",i=`/**
|
||
* The implementation is a direct application of the formula found in http:
|
||
*/
|
||
varying vUV: vec2f;uniform rsmLightMatrix: mat4x4f;uniform rsmInfo: vec4f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var normalSamplerSampler: sampler;var normalSampler: texture_2d<f32>;var rsmPositionW: texture_2d<f32>;var rsmNormalW: texture_2d<f32>;var rsmFlux: texture_2d<f32>;
|
||
#ifdef TRANSFORM_NORMAL
|
||
uniform invView: mat4x4f;
|
||
#endif
|
||
fn computeIndirect(p: vec3f,n: vec3f)->vec3f {var indirectDiffuse: vec3f= vec3f(0.);var intensity: f32=uniforms.rsmInfo.z;var edgeArtifactCorrection: f32=uniforms.rsmInfo.w;var texRSM: vec4f=uniforms.rsmLightMatrix* vec4f(p,1.);texRSM=vec4f(texRSM.xy/texRSM.w,texRSM.z,texRSM.w);texRSM=vec4f(texRSM.xy*0.5+0.5,texRSM.z,texRSM.w);var width: i32= i32(uniforms.rsmInfo.x);var height: i32= i32(uniforms.rsmInfo.y);for (var j: i32=0; j<height; j++) {for (var i: i32=0; i<width; i++) {var uv=vec2<i32>(i,j);var vplPositionW: vec3f=textureLoad(rsmPositionW,uv,0).xyz;var vplNormalW: vec3f=textureLoad(rsmNormalW,uv,0).xyz*2.0-1.0;var vplFlux: vec3f=textureLoad(rsmFlux,uv,0).rgb;vplPositionW-=vplNormalW*edgeArtifactCorrection;
|
||
var dist2: f32=dot(vplPositionW-p,vplPositionW-p);indirectDiffuse+=vplFlux*max(0.,dot(n,vplPositionW-p))*max(0.,dot(vplNormalW,p-vplPositionW))/(dist2*dist2);}}
|
||
return clamp(indirectDiffuse*intensity,0.0,1.0);}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var positionW: vec3f=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.vUV).xyz;var normalW: vec3f=textureSample(normalSampler,normalSamplerSampler,fragmentInputs.vUV).xyz;
|
||
#ifdef DECODE_NORMAL
|
||
normalW=normalW*2.0-1.0;
|
||
#endif
|
||
#ifdef TRANSFORM_NORMAL
|
||
normalW=(uniforms.invView* vec4f(normalW,0.)).xyz;
|
||
#endif
|
||
fragmentOutputs.color=vec4f(computeIndirect(positionW,normalW),1.0);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},47257:(r,t,e)=>{e.r(t),e.d(t,{rsmGlobalIlluminationPixelShaderWGSL:()=>o});var n="rsmGlobalIlluminationPixelShader",i=`/**
|
||
* The implementation is an application of the formula found in http:
|
||
* For better results,it also adds a random (noise) rotation to the RSM samples (the noise artifacts are easier to remove than the banding artifacts).
|
||
*/
|
||
varying vUV: vec2f;uniform rsmLightMatrix: mat4x4f;uniform rsmInfo: vec4f;uniform rsmInfo2: vec4f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var normalSamplerSampler: sampler;var normalSampler: texture_2d<f32>;var rsmPositionWSampler: sampler;var rsmPositionW: texture_2d<f32>;var rsmNormalWSampler: sampler;var rsmNormalW: texture_2d<f32>;var rsmFluxSampler: sampler;var rsmFlux: texture_2d<f32>;var rsmSamples: texture_2d<f32>;
|
||
#ifdef TRANSFORM_NORMAL
|
||
uniform invView: mat4x4f;
|
||
#endif
|
||
fn mod289(x: f32)->f32{return x-floor(x*(1.0/289.0))*289.0;}
|
||
fn mod289Vec4(x: vec4f)->vec4f {return x-floor(x*(1.0/289.0))* 289.0;}
|
||
fn perm(x: vec4f)->vec4f {return mod289Vec4(((x*34.0)+1.0)*x) ;}
|
||
fn noise(p: vec3f)->f32{var a: vec3f=floor(p);var d: vec3f=p-a;d=d*d*(3.0-2.0*d);var b: vec4f=a.xxyy+ vec4f(0.0,1.0,0.0,1.0);var k1: vec4f=perm(b.xyxy);var k2: vec4f=perm(k1.xyxy+b.zzww);var c: vec4f=k2+a.zzzz;var k3: vec4f=perm(c);var k4: vec4f=perm(c+1.0);var o1: vec4f=fract(k3*(1.0/41.0));var o2: vec4f=fract(k4*(1.0/41.0));var o3: vec4f=o2*d.z+o1*(1.0-d.z);var o4: vec2f=o3.yw*d.x+o3.xz*(1.0-d.x);return o4.y*d.y+o4.x*(1.0-d.y);}
|
||
fn computeIndirect(p: vec3f,n: vec3f)->vec3f {var indirectDiffuse: vec3f= vec3f(0.);var numSamples: i32= i32(uniforms.rsmInfo.x);var radius: f32=uniforms.rsmInfo.y;var intensity: f32=uniforms.rsmInfo.z;var edgeArtifactCorrection: f32=uniforms.rsmInfo.w;var texRSM: vec4f=uniforms.rsmLightMatrix* vec4f(p,1.);texRSM=vec4f(texRSM.xy/texRSM.w,texRSM.z,texRSM.w);texRSM=vec4f(texRSM.xy*0.5+0.5,texRSM.z,texRSM.w);var angle: f32=noise(p*uniforms.rsmInfo2.x);var c: f32=cos(angle);var s: f32=sin(angle);for (var i: i32=0; i<numSamples; i++) {var rsmSample: vec3f=textureLoad(rsmSamples,vec2<i32>(i,0),0).xyz;var weightSquare: f32=rsmSample.z;if (uniforms.rsmInfo2.y==1.0){rsmSample=vec3f(rsmSample.x*c+rsmSample.y*s,-rsmSample.x*s+rsmSample.y*c,rsmSample.z);}
|
||
var uv: vec2f=texRSM.xy+rsmSample.xy*radius;if (uv.x<0. || uv.x>1. || uv.y<0. || uv.y>1.) {continue;}
|
||
var vplPositionW: vec3f=textureSampleLevel(rsmPositionW,rsmPositionWSampler,uv,0.).xyz;var vplNormalW: vec3f=textureSampleLevel(rsmNormalW,rsmNormalWSampler,uv,0.).xyz*2.0-1.0;var vplFlux: vec3f=textureSampleLevel(rsmFlux,rsmFluxSampler,uv,0.).rgb;vplPositionW-=vplNormalW*edgeArtifactCorrection;
|
||
var dist2: f32=dot(vplPositionW-p,vplPositionW-p);indirectDiffuse+=vplFlux*weightSquare*max(0.,dot(n,vplPositionW-p))*max(0.,dot(vplNormalW,p-vplPositionW))/(dist2*dist2);}
|
||
return clamp(indirectDiffuse*intensity,vec3f(0.0),vec3f(1.0));}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var positionW: vec3f=textureSample(textureSampler,textureSamplerSampler,input.vUV).xyz;var normalW: vec3f=textureSample(normalSampler,normalSamplerSampler,input.vUV).xyz;
|
||
#ifdef DECODE_NORMAL
|
||
normalW=normalW*2.0-1.0;
|
||
#endif
|
||
#ifdef TRANSFORM_NORMAL
|
||
normalW=(uniforms.invView* vec4f(normalW,0.)).xyz;
|
||
#endif
|
||
fragmentOutputs.color=vec4f(computeIndirect(positionW,normalW),1.0);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},78850:(r,t,e)=>{e.r(t),e.d(t,{screenSpaceReflection2PixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),e(61669),e(7779),"screenSpaceReflection2PixelShader"),o=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;varying vUV: vec2f;
|
||
#ifdef SSR_SUPPORTED
|
||
var reflectivitySamplerSampler: sampler;var reflectivitySampler: texture_2d<f32>;var normalSampler: texture_2d<f32>;var depthSampler: texture_2d<f32>;
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
var backDepthSampler: texture_2d<f32>;uniform backSizeFactor: f32;
|
||
#endif
|
||
#ifdef SSR_USE_ENVIRONMENT_CUBE
|
||
var envCubeSamplerSampler: sampler;var envCubeSampler: texture_cube<f32>;
|
||
#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC
|
||
uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;
|
||
#endif
|
||
#endif
|
||
uniform view: mat4x4f;uniform invView: mat4x4f;uniform projection: mat4x4f;uniform invProjectionMatrix: mat4x4f;uniform projectionPixel: mat4x4f;uniform nearPlaneZ: f32;uniform stepSize: f32;uniform maxSteps: f32;uniform strength: f32;uniform thickness: f32;uniform roughnessFactor: f32;uniform reflectionSpecularFalloffExponent: f32;uniform maxDistance: f32;uniform selfCollisionNumSkip: f32;uniform reflectivityThreshold: f32;
|
||
#include<helperFunctions>
|
||
#include<pbrBRDFFunctions>
|
||
#include<screenSpaceRayTrace>
|
||
fn hash(a: vec3f)->vec3f
|
||
{var result=fract(a*0.8);result+=dot(result,result.yxz+19.19);return fract((result.xxy+result.yxx)*result.zyx);}
|
||
fn computeAttenuationForIntersection(ihitPixel: vec2f,hitUV: vec2f,vsRayOrigin: vec3f,vsHitPoint: vec3f,reflectionVector: vec3f,maxRayDistance: f32,numIterations: f32)->f32 {var attenuation: f32=1.0;
|
||
#ifdef SSR_ATTENUATE_SCREEN_BORDERS
|
||
var dCoords: vec2f=smoothstep(vec2f(0.2),vec2f(0.6),abs( vec2f(0.5,0.5)-hitUV.xy));attenuation*=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_INTERSECTION_DISTANCE
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_INTERSECTION_NUMITERATIONS
|
||
attenuation*=1.0-(numIterations/uniforms.maxSteps);
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_BACKFACE_REFLECTION
|
||
var reflectionNormal: vec3f=texelFetch(normalSampler,hitPixel,0).xyz;var directionBasedAttenuation: f32=smoothstep(-0.17,0.0,dot(reflectionNormal,-reflectionVector));attenuation*=directionBasedAttenuation;
|
||
#endif
|
||
return attenuation;}
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#ifdef SSR_SUPPORTED
|
||
var colorFull: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0);var color: vec3f=colorFull.rgb;var reflectivity: vec4f=textureSampleLevel(reflectivitySampler,reflectivitySamplerSampler,input.vUV,0.0);
|
||
#ifndef SSR_DISABLE_REFLECTIVITY_TEST
|
||
if (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=uniforms.reflectivityThreshold) {
|
||
#ifdef SSR_USE_BLUR
|
||
fragmentOutputs.color= vec4f(0.);
|
||
#else
|
||
fragmentOutputs.color=colorFull;
|
||
#endif
|
||
return fragmentOutputs;}
|
||
#endif
|
||
#ifdef SSR_INPUT_IS_GAMMA_SPACE
|
||
color=toLinearSpaceVec3(color);
|
||
#endif
|
||
var texSize: vec2f= vec2f(textureDimensions(depthSampler,0));var csNormal: vec3f=textureLoad(normalSampler,vec2<i32>(input.vUV*texSize),0).xyz;
|
||
#ifdef SSR_DECODE_NORMAL
|
||
csNormal=csNormal*2.0-1.0;
|
||
#endif
|
||
#ifdef SSR_NORMAL_IS_IN_WORLDSPACE
|
||
csNormal=(uniforms.view* vec4f(csNormal,0.0)).xyz;
|
||
#endif
|
||
var depth: f32=textureLoad(depthSampler,vec2<i32>(input.vUV*texSize),0).r;var csPosition: vec3f=computeViewPosFromUVDepth(input.vUV,depth,uniforms.projection,uniforms.invProjectionMatrix);
|
||
#ifdef ORTHOGRAPHIC_CAMERA
|
||
var csViewDirection: vec3f= vec3f(0.,0.,1.);
|
||
#else
|
||
var csViewDirection: vec3f=normalize(csPosition);
|
||
#endif
|
||
var csReflectedVector: vec3f=reflect(csViewDirection,csNormal);
|
||
#ifdef SSR_USE_ENVIRONMENT_CUBE
|
||
var wReflectedVector: vec3f=(uniforms.invView* vec4f(csReflectedVector,0.0)).xyz;
|
||
#ifdef SSR_USE_LOCAL_REFLECTIONMAP_CUBIC
|
||
var worldPos: vec4f=uniforms.invView* vec4f(csPosition,1.0);wReflectedVector=parallaxCorrectNormal(worldPos.xyz,normalize(wReflectedVector),uniforms.vReflectionSize,uniforms.vReflectionPosition);
|
||
#endif
|
||
#ifdef SSR_INVERTCUBICMAP
|
||
wReflectedVector.y*=-1.0;
|
||
#endif
|
||
#ifdef SSRAYTRACE_RIGHT_HANDED_SCENE
|
||
wReflectedVector.z*=-1.0;
|
||
#endif
|
||
var envColor: vec3f=textureSampleLevel(envCubeSampler,envCubeSamplerSampler,wReflectedVector,0.0).xyz;
|
||
#ifdef SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE
|
||
envColor=toLinearSpaceVec3(envColor);
|
||
#endif
|
||
#else
|
||
var envColor: vec3f=color;
|
||
#endif
|
||
var reflectionAttenuation: f32=1.0;var rayHasHit: bool=false;var startPixel: vec2f;var hitPixel: vec2f;var hitPoint: vec3f;var numIterations: f32;
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
var debugColor: vec3f;
|
||
#endif
|
||
#ifdef SSR_ATTENUATE_FACING_CAMERA
|
||
reflectionAttenuation*=1.0-smoothstep(0.25,0.5,dot(-csViewDirection,csReflectedVector));
|
||
#endif
|
||
if (reflectionAttenuation>0.0) {
|
||
#ifdef SSR_USE_BLUR
|
||
var jitt: vec3f= vec3f(0.);
|
||
#else
|
||
var roughness: f32=1.0-reflectivity.a;var jitt: vec3f=mix( vec3f(0.0),hash(csPosition)- vec3f(0.5),roughness)*uniforms.roughnessFactor;
|
||
#endif
|
||
var uv2: vec2f=input.vUV*texSize;var c: f32=(uv2.x+uv2.y)*0.25;var jitter: f32=((c)%(1.0));
|
||
rayHasHit=traceScreenSpaceRay1(
|
||
csPosition,
|
||
normalize(csReflectedVector+jitt),
|
||
uniforms.projectionPixel,
|
||
depthSampler,
|
||
texSize,
|
||
#ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER
|
||
backDepthSampler,
|
||
uniforms.backSizeFactor,
|
||
#endif
|
||
uniforms.thickness,
|
||
uniforms.nearPlaneZ,
|
||
uniforms.stepSize,
|
||
jitter,
|
||
uniforms.maxSteps,
|
||
uniforms.maxDistance,
|
||
uniforms.selfCollisionNumSkip,
|
||
&startPixel,
|
||
&hitPixel,
|
||
&hitPoint,
|
||
&numIterations
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
,&debugColor
|
||
#endif
|
||
);}
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
fragmentOutputs.color= vec4f(debugColor,1.);return fragmentOutputs;
|
||
#endif
|
||
var F0: vec3f=reflectivity.rgb;var fresnel: vec3f=fresnelSchlickGGXVec3(max(dot(csNormal,-csViewDirection),0.0),F0, vec3f(1.));var SSR: vec3f=envColor;if (rayHasHit) {var reflectedColor: vec3f=textureLoad(textureSampler,vec2<i32>(hitPixel),0).rgb;
|
||
#ifdef SSR_INPUT_IS_GAMMA_SPACE
|
||
reflectedColor=toLinearSpaceVec3(reflectedColor);
|
||
#endif
|
||
reflectionAttenuation*=computeAttenuationForIntersection(hitPixel,hitPixel/texSize,csPosition,hitPoint,csReflectedVector,uniforms.maxDistance,numIterations);SSR=reflectedColor*reflectionAttenuation+(1.0-reflectionAttenuation)*envColor;}
|
||
#ifndef SSR_BLEND_WITH_FRESNEL
|
||
SSR*=fresnel;
|
||
#endif
|
||
#ifdef SSR_USE_BLUR
|
||
var blur_radius: f32=0.0;var roughness: f32=1.0-reflectivity.a*(1.0-uniforms.roughnessFactor);if (roughness>0.001) {var cone_angle: f32=min(roughness,0.999)*3.14159265*0.5;var cone_len: f32=distance(startPixel,hitPixel);var op_len: f32=2.0*tan(cone_angle)*cone_len;
|
||
var a: f32=op_len;var h: f32=cone_len;var a2: f32=a*a;var fh2: f32=4.0f*h*h;blur_radius=(a*(sqrt(a2+fh2)-a))/(4.0f*h);}
|
||
fragmentOutputs.color= vec4f(SSR,blur_radius/255.0);
|
||
#else
|
||
#ifdef SSR_BLEND_WITH_FRESNEL
|
||
var reflectionMultiplier: vec3f=clamp(pow(fresnel*uniforms.strength, vec3f(uniforms.reflectionSpecularFalloffExponent)),vec3f(0.0),vec3f(1.0));
|
||
#else
|
||
var reflectionMultiplier: vec3f=clamp(pow(reflectivity.rgb*uniforms.strength, vec3f(uniforms.reflectionSpecularFalloffExponent)),vec3f(0.0),vec3f(1.0));
|
||
#endif
|
||
var colorMultiplier: vec3f=1.0-reflectionMultiplier;var finalColor: vec3f=(color*colorMultiplier)+(SSR*reflectionMultiplier);
|
||
#ifdef SSR_OUTPUT_IS_GAMMA_SPACE
|
||
finalColor=toGammaSpaceVec3(finalColor);
|
||
#endif
|
||
fragmentOutputs.color= vec4f(finalColor,colorFull.a);
|
||
#endif
|
||
#else
|
||
fragmentOutputs.color=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0);
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},88101:(r,t,e)=>{e.r(t),e.d(t,{screenSpaceReflection2BlurPixelShaderWGSL:()=>o});var n="screenSpaceReflection2BlurPixelShader",i=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;varying vUV: vec2f;uniform texelOffsetScale: vec2f;const weights: array<f32,8>=array<f32,8>(0.071303,0.131514,0.189879,0.321392,0.452906, 0.584419,0.715932,0.847445);fn processSample(uv: vec2f,i: f32,stepSize: vec2f,accumulator: ptr<function,vec4f>,denominator: ptr<function,f32>)
|
||
{var offsetUV: vec2f=stepSize*i+uv;var coefficient: f32=weights[ i32(2.0-abs(i))];*accumulator+=textureSampleLevel(textureSampler,textureSamplerSampler,offsetUV,0.0)*coefficient;*denominator+=coefficient;}
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var colorFull: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0);if (dot(colorFull, vec4f(1.0))==0.0) {fragmentOutputs.color=colorFull;return fragmentOutputs;}
|
||
var blurRadius: f32=colorFull.a*255.0;
|
||
var stepSize: vec2f=uniforms.texelOffsetScale.xy*blurRadius;var accumulator: vec4f=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0)*0.214607;var denominator: f32=0.214607;processSample(input.vUV,1.0,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*0.2,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*0.4,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*0.6,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*0.8,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*1.2,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*1.4,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*1.6,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*1.8,stepSize,&accumulator,&denominator);processSample(input.vUV,1.0*2.0,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*0.2,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*0.4,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*0.6,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*0.8,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*1.2,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*1.4,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*1.6,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*1.8,stepSize,&accumulator,&denominator);processSample(input.vUV,-1.0*2.0,stepSize,&accumulator,&denominator);fragmentOutputs.color= vec4f(accumulator.rgb/denominator,colorFull.a);}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},93050:(r,t,e)=>{e.r(t),e.d(t,{screenSpaceReflection2BlurCombinerPixelShaderWGSL:()=>a});var n=e(98519),i=(e(17393),e(61669),e(7779),"screenSpaceReflection2BlurCombinerPixelShader"),o=`var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
var mainSamplerSampler: sampler;var mainSampler: texture_2d<f32>;var reflectivitySamplerSampler: sampler;var reflectivitySampler: texture_2d<f32>;uniform strength: f32;uniform reflectionSpecularFalloffExponent: f32;uniform reflectivityThreshold: f32;varying vUV: vec2f;
|
||
#include<helperFunctions>
|
||
#ifdef SSR_BLEND_WITH_FRESNEL
|
||
#include<pbrBRDFFunctions>
|
||
#include<screenSpaceRayTrace>
|
||
uniform projection: mat4x4f;uniform invProjectionMatrix: mat4x4f;var normalSampler: texture_2d<f32>;var depthSampler: texture_2d<f32>;
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#ifdef SSRAYTRACE_DEBUG
|
||
fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);
|
||
#else
|
||
var SSR: vec3f=textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb;var color: vec4f=textureSample(mainSampler,textureSamplerSampler,input.vUV);var reflectivity: vec4f=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vUV);
|
||
#ifndef SSR_DISABLE_REFLECTIVITY_TEST
|
||
if (max(reflectivity.r,max(reflectivity.g,reflectivity.b))<=uniforms.reflectivityThreshold) {fragmentOutputs.color=color;return fragmentOutputs;}
|
||
#endif
|
||
#ifdef SSR_INPUT_IS_GAMMA_SPACE
|
||
color=toLinearSpaceVec4(color);
|
||
#endif
|
||
#ifdef SSR_BLEND_WITH_FRESNEL
|
||
var texSize: vec2f= vec2f(textureDimensions(depthSampler,0));var csNormal: vec3f=textureLoad(normalSampler,vec2<i32>(input.vUV*texSize),0).xyz;var depth: f32=textureLoad(depthSampler,vec2<i32>(input.vUV*texSize),0).r;var csPosition: vec3f=computeViewPosFromUVDepth(input.vUV,depth,uniforms.projection,uniforms.invProjectionMatrix);var csViewDirection: vec3f=normalize(csPosition);var F0: vec3f=reflectivity.rgb;var fresnel: vec3f=fresnelSchlickGGXVec3(max(dot(csNormal,-csViewDirection),0.0),F0, vec3f(1.));var reflectionMultiplier: vec3f=clamp(pow(fresnel*uniforms.strength, vec3f(uniforms.reflectionSpecularFalloffExponent)),vec3f(0.0),vec3f(1.0));
|
||
#else
|
||
var reflectionMultiplier: vec3f=clamp(pow(reflectivity.rgb*uniforms.strength, vec3f(uniforms.reflectionSpecularFalloffExponent)),vec3f(0.0),vec3f(1.0));
|
||
#endif
|
||
var colorMultiplier: vec3f=1.0-reflectionMultiplier;var finalColor: vec3f=(color.rgb*colorMultiplier)+(SSR*reflectionMultiplier);
|
||
#ifdef SSR_OUTPUT_IS_GAMMA_SPACE
|
||
finalColor=toGammaSpaceVec3(finalColor);
|
||
#endif
|
||
fragmentOutputs.color= vec4f(finalColor,color.a);
|
||
#endif
|
||
}
|
||
`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},65465:(r,t,e)=>{e.r(t),e.d(t,{shadowMapPixelShaderWGSL:()=>s});var n=e(98519),i=(e(68298),"bayerDitherFunctions");n.l.IncludesShadersStoreWGSL[i]=`fn bayerDither2(_P: vec2f)->f32 {return ((2.0*_P.y+_P.x+1.0)%(4.0));}
|
||
fn bayerDither4(_P: vec2f)->f32 {var P1: vec2f=((_P)%(2.0));
|
||
var P2: vec2f=floor(0.5*((_P)%(4.0)));
|
||
return 4.0*bayerDither2(P1)+bayerDither2(P2);}
|
||
fn bayerDither8(_P: vec2f)->f32 {var P1: vec2f=((_P)%(2.0));
|
||
var P2: vec2f=floor(0.5 *((_P)%(4.0)));
|
||
var P4: vec2f=floor(0.25*((_P)%(8.0)));
|
||
return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);}
|
||
`,n.l.IncludesShadersStoreWGSL.shadowMapFragmentExtraDeclaration=`#if SM_FLOAT==0
|
||
#include<packingFunctions>
|
||
#endif
|
||
#if SM_SOFTTRANSPARENTSHADOW==1
|
||
#include<bayerDitherFunctions>
|
||
uniform softTransparentShadowSM: vec2f;
|
||
#endif
|
||
varying vDepthMetricSM: f32;
|
||
#if SM_USEDISTANCE==1
|
||
uniform lightDataSM: vec3f;varying vPositionWSM: vec3f;
|
||
#endif
|
||
uniform biasAndScaleSM: vec3f;uniform depthValuesSM: vec2f;
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
varying zSM: f32;
|
||
#endif
|
||
`,e(20502),e(30032),e(79574);var o="shadowMapPixelShader",a=`#include<shadowMapFragmentExtraDeclaration>
|
||
#ifdef ALPHATEXTURE
|
||
varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#endif
|
||
#include<clipPlaneFragmentDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#include<clipPlaneFragment>
|
||
#ifdef ALPHATEXTURE
|
||
var opacityMap: vec4f=textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vUV);var alphaFromAlphaTexture: f32=opacityMap.a;
|
||
#if SM_SOFTTRANSPARENTSHADOW==1
|
||
if (uniforms.softTransparentShadowSM.y==1.0) {opacityMap=vec4f(opacityMap.rgb* vec3f(0.3,0.59,0.11),opacityMap.a);alphaFromAlphaTexture=opacityMap.x+opacityMap.y+opacityMap.z;}
|
||
#endif
|
||
#ifdef ALPHATESTVALUE
|
||
if (alphaFromAlphaTexture<ALPHATESTVALUE) {discard;}
|
||
#endif
|
||
#endif
|
||
#if SM_SOFTTRANSPARENTSHADOW==1
|
||
#ifdef ALPHATEXTURE
|
||
if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.softTransparentShadowSM.x*alphaFromAlphaTexture) {discard;}
|
||
#else
|
||
if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.softTransparentShadowSM.x) {discard;}
|
||
#endif
|
||
#endif
|
||
#include<shadowMapFragment>
|
||
}`;n.l.ShadersStoreWGSL[o]=a;var s={name:o,shader:a}},15455:(r,t,e)=>{e.r(t),e.d(t,{shadowMapVertexShaderWGSL:()=>s});var n=e(98519),i=(e(45699),e(27279),e(73683),e(68478),e(17393),e(36644),e(40647),"shadowMapVertexExtraDeclaration");n.l.IncludesShadersStoreWGSL[i]=`#if SM_NORMALBIAS==1
|
||
uniform lightDataSM: vec3f;
|
||
#endif
|
||
uniform biasAndScaleSM: vec3f;uniform depthValuesSM: vec2f;varying vDepthMetricSM: f32;
|
||
#if SM_USEDISTANCE==1
|
||
varying vPositionWSM: vec3f;
|
||
#endif
|
||
#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1
|
||
varying zSM: f32;
|
||
#endif
|
||
`,e(9436),e(98819),e(77320),e(21310),e(3641),e(86615),n.l.IncludesShadersStoreWGSL.shadowMapVertexNormalBias=`#if SM_NORMALBIAS==1
|
||
#if SM_DIRECTIONINLIGHTDATA==1
|
||
var worldLightDirSM: vec3f=normalize(-uniforms.lightDataSM.xyz);
|
||
#else
|
||
var directionToLightSM: vec3f=uniforms.lightDataSM.xyz-worldPos.xyz;var worldLightDirSM: vec3f=normalize(directionToLightSM);
|
||
#endif
|
||
var ndlSM: f32=dot(vNormalW,worldLightDirSM);var sinNLSM: f32=sqrt(1.0-ndlSM*ndlSM);var normalBiasSM: f32=uniforms.biasAndScaleSM.y*sinNLSM;worldPos=vec4f(worldPos.xyz-vNormalW*normalBiasSM,worldPos.w);
|
||
#endif
|
||
`,e(28924),e(63002);var o="shadowMapVertexShader",a=`attribute position: vec3f;
|
||
#ifdef NORMAL
|
||
attribute normal: vec3f;
|
||
#endif
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#ifdef INSTANCES
|
||
attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;
|
||
#endif
|
||
#include<helperFunctions>
|
||
#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
#ifdef ALPHATEXTURE
|
||
varying vUV: vec2f;uniform diffuseMatrix: mat4x4f;
|
||
#ifdef UV1
|
||
attribute uv: vec2f;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute uv2: vec2f;
|
||
#endif
|
||
#endif
|
||
#include<shadowMapVertexExtraDeclaration>
|
||
#include<clipPlaneVertexDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=input.position;
|
||
#ifdef UV1
|
||
var uvUpdated: vec2f=input.uv;
|
||
#endif
|
||
#ifdef NORMAL
|
||
var normalUpdated: vec3f=input.normal;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);
|
||
#ifdef NORMAL
|
||
var normWorldSM: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz);
|
||
#if defined(INSTANCES) && defined(THIN_INSTANCES)
|
||
var vNormalW: vec3f=normalUpdated/ vec3f(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);
|
||
#else
|
||
#ifdef NONUNIFORMSCALING
|
||
normWorldSM=transposeMat3(inverseMat3(normWorldSM));
|
||
#endif
|
||
var vNormalW: vec3f=normalize(normWorldSM*normalUpdated);
|
||
#endif
|
||
#endif
|
||
#include<shadowMapVertexNormalBias>
|
||
vertexOutputs.position=scene.viewProjection*worldPos;
|
||
#include<shadowMapVertexMetric>
|
||
#ifdef ALPHATEXTURE
|
||
#ifdef UV1
|
||
vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
|
||
#endif
|
||
#ifdef UV2
|
||
vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(input.uv2,1.0,0.0)).xy;
|
||
#endif
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
}`;n.l.ShadersStoreWGSL[o]=a;var s={name:o,shader:a}},89950:(r,t,e)=>{e.r(t),e.d(t,{sharpenPixelShaderWGSL:()=>o});var n="sharpenPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform screenSize: vec2f;uniform sharpnessAmounts: vec2f;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var onePixel: vec2f= vec2f(1.0,1.0)/uniforms.screenSize;var color: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);var edgeDetection: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel*vec2f(0,-1)) +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel*vec2f(-1,0)) +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel*vec2f(1,0)) +
|
||
textureSample(textureSampler,textureSamplerSampler,input.vUV+onePixel*vec2f(0,1)) -
|
||
color*4.0;fragmentOutputs.color=max(vec4f(color.rgb*uniforms.sharpnessAmounts.y,color.a)-(uniforms.sharpnessAmounts.x* vec4f(edgeDetection.rgb,0)),vec4f(0.));}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},89493:(r,t,e)=>{e.r(t),e.d(t,{spritesPixelShaderWGSL:()=>s});var n=e(98519),i=(e(98318),e(38197),e(56897),e(83512),"imageProcessingCompatibility");n.l.IncludesShadersStoreWGSL[i]=`#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
fragmentOutputs.color=vec4f(pow(fragmentOutputs.color.rgb, vec3f(2.2)),fragmentOutputs.color.a);
|
||
#endif
|
||
`;var o="spritesPixelShader",a=`uniform alphaTest: i32;varying vColor: vec4f;varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
||
#include<fogFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
#ifdef PIXEL_PERFECT
|
||
fn uvPixelPerfect(uv: vec2f)->vec2f {var res: vec2f= vec2f(textureDimensions(diffuseSampler,0));var uvTemp=uv*res;var seam: vec2f=floor(uvTemp+0.5);uvTemp=seam+clamp((uvTemp-seam)/fwidth(uvTemp),vec2f(-0.5),vec2f(0.5));return uvTemp/res;}
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
#ifdef PIXEL_PERFECT
|
||
var uv: vec2f=uvPixelPerfect(input.vUV);
|
||
#else
|
||
var uv: vec2f=input.vUV;
|
||
#endif
|
||
var color: vec4f=textureSample(diffuseSampler,diffuseSamplerSampler,uv);var fAlphaTest: f32= f32(uniforms.alphaTest);if (fAlphaTest != 0.)
|
||
{if (color.a<0.95) {discard;}}
|
||
color*=input.vColor;
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>
|
||
fragmentOutputs.color=color;
|
||
#include<imageProcessingCompatibility>
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[o]=a;var s={name:o,shader:a}},98179:(r,t,e)=>{e.r(t),e.d(t,{spritesVertexShaderWGSL:()=>a});var n=e(98519),i=(e(79716),e(38197),e(55607),"spritesVertexShader"),o=`attribute position: vec4f;attribute options: vec2f;attribute offsets: vec2f;attribute inverts: vec2f;attribute cellInfo: vec4f;attribute color: vec4f;uniform view: mat4x4f;uniform projection: mat4x4f;varying vUV: vec2f;varying vColor: vec4f;
|
||
#include<fogVertexDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
var viewPos: vec3f=(uniforms.view* vec4f(input.position.xyz,1.0)).xyz;
|
||
var cornerPos: vec2f;var angle: f32=input.position.w;var size: vec2f= vec2f(input.options.x,input.options.y);var offset: vec2f=input.offsets.xy;cornerPos= vec2f(offset.x-0.5,offset.y -0.5)*size;var rotatedCorner: vec3f;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;viewPos+=rotatedCorner;vertexOutputs.position=uniforms.projection*vec4f(viewPos,1.0);
|
||
vertexOutputs.vColor=input.color;var uvOffset: vec2f= vec2f(abs(offset.x-input.inverts.x),abs(1.0-offset.y-input.inverts.y));var uvPlace: vec2f=input.cellInfo.xy;var uvSize: vec2f=input.cellInfo.zw;vertexOutputs.vUV.x=uvPlace.x+uvSize.x*uvOffset.x;vertexOutputs.vUV.y=uvPlace.y+uvSize.y*uvOffset.y;
|
||
#ifdef FOG
|
||
vertexOutputs.vFogDistance=viewPos;
|
||
#endif
|
||
#include<logDepthVertex>
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;n.l.ShadersStoreWGSL[i]=o;var a={name:i,shader:o}},29059:(r,t,e)=>{e.r(t),e.d(t,{ssao2PixelShaderWGSL:()=>o});var n="ssao2PixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;
|
||
#ifdef SSAO
|
||
const scales: array<f32,16>=array<f32,16>(
|
||
0.1,
|
||
0.11406250000000001,
|
||
0.131640625,
|
||
0.15625,
|
||
0.187890625,
|
||
0.2265625,
|
||
0.272265625,
|
||
0.325,
|
||
0.384765625,
|
||
0.4515625,
|
||
0.525390625,
|
||
0.60625,
|
||
0.694140625,
|
||
0.7890625,
|
||
0.891015625,
|
||
1.0
|
||
);uniform near: f32;uniform radius: f32;var depthSamplerSampler: sampler;var depthSampler: texture_2d<f32>;var randomSamplerSampler: sampler;var randomSampler: texture_2d<f32>;var normalSamplerSampler: sampler;var normalSampler: texture_2d<f32>;uniform randTextureTiles: f32;uniform samplesFactor: f32;uniform sampleSphere: array<vec3f,SAMPLES>;uniform totalStrength: f32;uniform base: f32;uniform xViewport: f32;uniform yViewport: f32;uniform depthProjection: mat3x3f;uniform maxZ: f32;uniform minZAspect: f32;uniform texelSize: vec2f;uniform projection: mat4x4f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var random: vec3f=textureSampleLevel(randomSampler,randomSamplerSampler,input.vUV*uniforms.randTextureTiles,0.0).rgb;var depth: f32=textureSampleLevel(depthSampler,depthSamplerSampler,input.vUV,0.0).r;var depthSign: f32=sign(depth);depth=depth*depthSign;var normal: vec3f=textureSampleLevel(normalSampler,normalSamplerSampler,input.vUV,0.0).rgb;var occlusion: f32=0.0;var correctedRadius: f32=min(uniforms.radius,uniforms.minZAspect*depth/uniforms.near);var vViewRay: vec3f= vec3f((input.vUV.x*2.0-1.0)*uniforms.xViewport,(input.vUV.y*2.0-1.0)*uniforms.yViewport,depthSign);var vDepthFactor: vec3f=uniforms.depthProjection* vec3f(1.0,1.0,depth);var origin: vec3f=vViewRay*vDepthFactor;var rvec: vec3f=random*2.0-1.0;rvec.z=0.0;var dotProduct: f32=dot(rvec,normal);rvec=select( vec3f(-rvec.y,0.0,rvec.x),rvec,1.0-abs(dotProduct)>1e-2);var tangent: vec3f=normalize(rvec-normal*dot(rvec,normal));var bitangent: vec3f=cross(normal,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,normal);var difference: f32;for (var i: i32=0; i<SAMPLES; i++) {var samplePosition: vec3f=scales[(i+ i32(random.x*16.0)) % 16]*tbn*uniforms.sampleSphere[(i+ i32(random.y*16.0)) % 16];samplePosition=samplePosition*correctedRadius+origin;var offset: vec4f= vec4f(samplePosition,1.0);offset=uniforms.projection*offset;offset=vec4f(offset.xyz/offset.w,offset.w);offset=vec4f(offset.xy*0.5+0.5,offset.z,offset.w);if (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {continue;}
|
||
var sampleDepth: f32=abs(textureSampleLevel(depthSampler,depthSamplerSampler,offset.xy,0.0).r);difference=depthSign*samplePosition.z-sampleDepth;var rangeCheck: f32=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);occlusion+=step(EPSILON,difference)*rangeCheck;}
|
||
occlusion=occlusion*(1.0-smoothstep(uniforms.maxZ*0.75,uniforms.maxZ,depth));var ao: f32=1.0-uniforms.totalStrength*occlusion*uniforms.samplesFactor;var result: f32=clamp(ao+uniforms.base,0.0,1.0);fragmentOutputs.color= vec4f( vec3f(result),1.0);}
|
||
#else
|
||
#ifdef BLUR
|
||
uniform outSize: f32;uniform soften: f32;uniform tolerance: f32;uniform samples: i32;
|
||
#ifndef BLUR_BYPASS
|
||
var depthSamplerSampler: sampler;var depthSampler: texture_2d<f32>;
|
||
#ifdef BLUR_LEGACY
|
||
fn blur13Bilateral(image: texture_2d<f32>,imageSampler: sampler,uv: vec2f,step: vec2f)->f32 {var result: f32=0.0;var off1: vec2f= vec2f(1.411764705882353)*step;var off2: vec2f= vec2f(3.2941176470588234)*step;var off3: vec2f= vec2f(5.176470588235294)*step;var compareDepth: f32=abs(textureSampleLevel(depthSampler,depthSamplerSampler,uv,0.0).r);var sampleDepth: f32;var weight: f32;var weightSum: f32=30.0;result+=textureSampleLevel(image,imageSampler,uv,0.0).r*30.0;sampleDepth=abs(textureSampleLevel(depthSampler,depthSamplerSampler,uv+off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureSampleLevel(image,imageSampler,uv+off1,0.0).r*weight;sampleDepth=abs(textureSampleLevel(depthSampler,depthSamplerSampler,uv-off1,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+= weight;result+=textureSampleLevel(image,imageSampler,uv-off1,0.0).r*weight;sampleDepth=abs(textureSampleLevel(depthSampler,depthSamplerSampler,uv+off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureSampleLevel(image,imageSampler,uv+off2,0.0).r*weight;sampleDepth=abs(textureSampleLevel(depthSampler,depthSamplerSampler,uv-off2,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureSampleLevel(image,imageSampler,uv-off2,0.0).r*weight;sampleDepth=abs(textureSampleLevel(depthSampler,depthSamplerSampler,uv+off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureSampleLevel(image,imageSampler,uv+off3,0.0).r*weight;sampleDepth=abs(textureSampleLevel(depthSampler,depthSamplerSampler,uv-off3,0.0).r);weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);weightSum+=weight;result+=textureSampleLevel(image,imageSampler,uv-off3,0.0).r*weight;return result/weightSum;}
|
||
#endif
|
||
#endif
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var result: f32=0.0;
|
||
#ifdef BLUR_BYPASS
|
||
result=textureSampleLevel(textureSampler,textureSamplerSampler,input.vUV,0.0).r;
|
||
#else
|
||
#ifdef BLUR_H
|
||
var step: vec2f= vec2f(1.0/uniforms.outSize,0.0);
|
||
#else
|
||
var step: vec2f= vec2f(0.0,1.0/uniforms.outSize);
|
||
#endif
|
||
#ifdef BLUR_LEGACY
|
||
result=blur13Bilateral(textureSampler,textureSamplerSampler,input.vUV,step);
|
||
#else
|
||
var compareDepth: f32=abs(textureSampleLevel(depthSampler,depthSamplerSampler,input.vUV,0.0).r);var weightSum: f32=0.0;for (var i: i32=-uniforms.samples; i<uniforms.samples; i+=2)
|
||
{var samplePos: vec2f=input.vUV+step*( f32(i)+0.5);var sampleDepth: f32=abs(textureSampleLevel(depthSampler,depthSamplerSampler,samplePos,0.0).r);var falloff: f32=smoothstep(0.0,
|
||
f32(uniforms.samples),
|
||
f32(uniforms.samples)-abs( f32(i))*uniforms.soften);var minDivider: f32=uniforms.tolerance*0.5+0.003;var weight: f32=falloff/( minDivider+abs(compareDepth-sampleDepth));result+=textureSampleLevel(textureSampler,textureSamplerSampler,samplePos,0.0).r*weight;weightSum+=weight;}
|
||
result/=weightSum;
|
||
#endif
|
||
#endif
|
||
fragmentOutputs.color=vec4f(result,result,result,1.0);}
|
||
#endif
|
||
#endif
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},61186:(r,t,e)=>{e.r(t),e.d(t,{ssaoCombinePixelShaderWGSL:()=>o});var n="ssaoCombinePixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;var originalColorSampler: sampler;var originalColor: texture_2d<f32>;uniform viewport: vec4f;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
var ssaoColor: vec4f=textureSample(textureSampler,textureSamplerSampler,uniforms.viewport.xy+input.vUV*uniforms.viewport.zw);var sceneColor: vec4f=textureSample(originalColor,originalColorSampler,input.vUV);fragmentOutputs.color=sceneColor*ssaoColor;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},31197:(r,t,e)=>{e.r(t),e.d(t,{tonemapPixelShaderWGSL:()=>o});var n="tonemapPixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform _ExposureAdjustment: f32;
|
||
#if defined(HABLE_TONEMAPPING)
|
||
const A: f32=0.15;const B: f32=0.50;const C: f32=0.10;const D: f32=0.20;const E: f32=0.02;const F: f32=0.30;const W: f32=11.2;
|
||
#endif
|
||
fn Luminance(c: vec3f)->f32
|
||
{return dot(c, vec3f(0.22,0.707,0.071));}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var colour: vec3f=textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb;
|
||
#if defined(REINHARD_TONEMAPPING)
|
||
var lum: f32=Luminance(colour.rgb);
|
||
var lumTm: f32=lum*uniforms._ExposureAdjustment;var scale: f32=lumTm/(1.0+lumTm);
|
||
colour*=scale/lum;
|
||
#elif defined(HABLE_TONEMAPPING)
|
||
colour*=uniforms._ExposureAdjustment;const ExposureBias: f32=2.0;var x: vec3f=ExposureBias*colour;var curr: vec3f=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;x= vec3f(W,W,W);var whiteScale: vec3f=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);colour=curr*whiteScale;
|
||
#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)
|
||
colour*=uniforms._ExposureAdjustment;var X: vec3f=max( vec3f(0.0,0.0,0.0),colour-0.004);var retColor: vec3f=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);colour=retColor*retColor;
|
||
#elif defined(PHOTOGRAPHIC_TONEMAPPING)
|
||
colour= vec3f(1.0,1.0,1.0)-exp2(-uniforms._ExposureAdjustment*colour);
|
||
#endif
|
||
fragmentOutputs.color= vec4f(colour.rgb,1.0);}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},15390:(r,t,e)=>{e.r(t),e.d(t,{vrDistortionCorrectionPixelShaderWGSL:()=>o});var n="vrDistortionCorrectionPixelShader",i=`#define DISABLE_UNIFORMITY_ANALYSIS
|
||
varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;uniform LensCenter: vec2f;uniform Scale: vec2f;uniform ScaleIn: vec2f;uniform HmdWarpParam: vec4f;fn HmdWarp(in01: vec2f)->vec2f {var theta: vec2f=(in01-uniforms.LensCenter)*uniforms.ScaleIn;
|
||
var rSq: f32=theta.x*theta.x+theta.y*theta.y;var rvector: vec2f=theta*(uniforms.HmdWarpParam.x+uniforms.HmdWarpParam.y*rSq+uniforms.HmdWarpParam.z*rSq*rSq+uniforms.HmdWarpParam.w*rSq*rSq*rSq);return uniforms.LensCenter+uniforms.Scale*rvector;}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {var tc: vec2f=HmdWarp(input.vUV);if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0) {fragmentOutputs.color=vec4f(0.0,0.0,0.0,0.0);}
|
||
else{fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,tc);}}`;e(98519).l.ShadersStoreWGSL[n]=i;var o={name:n,shader:i}},69329:(r,t,e)=>{e.d(t,{i:()=>n});var n=function(){function i(){this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}return Object.defineProperty(i.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(o){this._alphaBlend!==o&&(this._alphaBlend=o,this._isAlphaBlendDirty=!0)},enumerable:!1,configurable:!0}),i.prototype.setAlphaBlendConstants=function(o,a,s,l){this._blendConstants[0]===o&&this._blendConstants[1]===a&&this._blendConstants[2]===s&&this._blendConstants[3]===l||(this._blendConstants[0]=o,this._blendConstants[1]=a,this._blendConstants[2]=s,this._blendConstants[3]=l,this._isBlendConstantsDirty=!0)},i.prototype.setAlphaBlendFunctionParameters=function(o,a,s,l){this._blendFunctionParameters[0]===o&&this._blendFunctionParameters[1]===a&&this._blendFunctionParameters[2]===s&&this._blendFunctionParameters[3]===l||(this._blendFunctionParameters[0]=o,this._blendFunctionParameters[1]=a,this._blendFunctionParameters[2]=s,this._blendFunctionParameters[3]=l,this._isBlendFunctionParametersDirty=!0)},i.prototype.setAlphaEquationParameters=function(o,a){this._blendEquationParameters[0]===o&&this._blendEquationParameters[1]===a||(this._blendEquationParameters[0]=o,this._blendEquationParameters[1]=a,this._isBlendEquationParametersDirty=!0)},i.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1},i.prototype.apply=function(o){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?o.enable(o.BLEND):o.disable(o.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(o.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(o.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(o.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},i}()},48424:(r,t,e)=>{e.d(t,{N:()=>n});var n=function(){function i(o){o===void 0&&(o=!0),this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,o&&this.reset()}return Object.defineProperty(i.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"zOffset",{get:function(){return this._zOffset},set:function(o){this._zOffset!==o&&(this._zOffset=o,this._isZOffsetDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"zOffsetUnits",{get:function(){return this._zOffsetUnits},set:function(o){this._zOffsetUnits!==o&&(this._zOffsetUnits=o,this._isZOffsetDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cullFace",{get:function(){return this._cullFace},set:function(o){this._cullFace!==o&&(this._cullFace=o,this._isCullFaceDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cull",{get:function(){return this._cull},set:function(o){this._cull!==o&&(this._cull=o,this._isCullDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(o){this._depthFunc!==o&&(this._depthFunc=o,this._isDepthFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthMask",{get:function(){return this._depthMask},set:function(o){this._depthMask!==o&&(this._depthMask=o,this._isDepthMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthTest",{get:function(){return this._depthTest},set:function(o){this._depthTest!==o&&(this._depthTest=o,this._isDepthTestDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"frontFace",{get:function(){return this._frontFace},set:function(o){this._frontFace!==o&&(this._frontFace=o,this._isFrontFaceDirty=!0)},enumerable:!1,configurable:!0}),i.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._zOffsetUnits=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!0,this._isFrontFaceDirty=!1},i.prototype.apply=function(o){this.isDirty&&(this._isCullDirty&&(this.cull?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(o.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(o.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(o.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset||this.zOffsetUnits?(o.enable(o.POLYGON_OFFSET_FILL),o.polygonOffset(this.zOffset,this.zOffsetUnits)):o.disable(o.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(o.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},i}()},3911:(r,t,e)=>{e.d(t,{K:()=>i});var n=e(81152),i=function(){function o(){this.reset()}return o.prototype.reset=function(){this.enabled=!1,this.mask=255,this.func=o.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=o.KEEP,this.opDepthFail=o.KEEP,this.opStencilDepthPass=o.REPLACE},Object.defineProperty(o.prototype,"stencilFunc",{get:function(){return this.func},set:function(a){this.func=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"stencilFuncRef",{get:function(){return this.funcRef},set:function(a){this.funcRef=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"stencilFuncMask",{get:function(){return this.funcMask},set:function(a){this.funcMask=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"stencilOpStencilFail",{get:function(){return this.opStencilFail},set:function(a){this.opStencilFail=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"stencilOpDepthFail",{get:function(){return this.opDepthFail},set:function(a){this.opDepthFail=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"stencilOpStencilDepthPass",{get:function(){return this.opStencilDepthPass},set:function(a){this.opStencilDepthPass=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"stencilMask",{get:function(){return this.mask},set:function(a){this.mask=a},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"stencilTest",{get:function(){return this.enabled},set:function(a){this.enabled=a},enumerable:!1,configurable:!0}),o.ALWAYS=n.Y.ALWAYS,o.KEEP=n.Y.KEEP,o.REPLACE=n.Y.REPLACE,o}()},75781:(r,t,e)=>{e.d(t,{u:()=>n});var n=function(){function i(o){o===void 0&&(o=!0),this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,o&&this.reset()}return Object.defineProperty(i.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"func",{get:function(){return this._func},set:function(o){this._func!==o&&(this._func=o,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"funcRef",{get:function(){return this._funcRef},set:function(o){this._funcRef!==o&&(this._funcRef=o,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"funcMask",{get:function(){return this._funcMask},set:function(o){this._funcMask!==o&&(this._funcMask=o,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"opStencilFail",{get:function(){return this._opStencilFail},set:function(o){this._opStencilFail!==o&&(this._opStencilFail=o,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"opDepthFail",{get:function(){return this._opDepthFail},set:function(o){this._opDepthFail!==o&&(this._opDepthFail=o,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"opStencilDepthPass",{get:function(){return this._opStencilDepthPass},set:function(o){this._opStencilDepthPass!==o&&(this._opStencilDepthPass=o,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"mask",{get:function(){return this._mask},set:function(o){this._mask!==o&&(this._mask=o,this._isStencilMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"enabled",{get:function(){return this._enabled},set:function(o){this._enabled!==o&&(this._enabled=o,this._isStencilTestDirty=!0)},enumerable:!1,configurable:!0}),i.prototype.reset=function(){var o;this.stencilMaterial=void 0,(o=this.stencilGlobal)===null||o===void 0||o.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},i.prototype.apply=function(o){var a;if(o){var s=!this.useStencilGlobalOnly&&!!(!((a=this.stencilMaterial)===null||a===void 0)&&a.enabled);this.enabled=s?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.func=s?this.stencilMaterial.func:this.stencilGlobal.func,this.funcRef=s?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=s?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=s?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=s?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=s?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.mask=s?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(o.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(o.stencilFunc(this.func,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(o.stencilOp(this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),this._isStencilOpDirty=!1))}},i}()},94671:(r,t,e)=>{e.d(t,{d:()=>i});var n=e(34623),i=function(){function o(){this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[]}return o.AddParser=function(a,s){this._BabylonFileParsers[a]=s},o.GetParser=function(a){return this._BabylonFileParsers[a]?this._BabylonFileParsers[a]:null},o.AddIndividualParser=function(a,s){this._IndividualBabylonFileParsers[a]=s},o.GetIndividualParser=function(a){return this._IndividualBabylonFileParsers[a]?this._IndividualBabylonFileParsers[a]:null},o.Parse=function(a,s,l,c){for(var u in this._BabylonFileParsers)Object.prototype.hasOwnProperty.call(this._BabylonFileParsers,u)&&this._BabylonFileParsers[u](a,s,l,c)},Object.defineProperty(o.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(a){this._environmentTexture=a},enumerable:!1,configurable:!0}),o.prototype.getNodes=function(){var a=[];return a=(a=(a=(a=a.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes),this.skeletons.forEach(function(s){return a=a.concat(s.bones)}),a},o._BabylonFileParsers={},o._IndividualBabylonFileParsers={},o}();(0,n.Y5)("BABYLON.AbstractScene",i)},76170:(r,t,e)=>{e.d(t,{Z:()=>Te,F:()=>n});var n,i=e(78322),o=e(44957),a=e(85258),s=e(66377),l=e(53770),c=e(59437),u=e(31985),d=e(8046),h=e(94671),p=e(81914),m=e(75482),v=e(8004),b=e(35747),E=e(63639),C=e(7931),T=e(52366),f=e(81152),g=e(5153),S=e(66614),y=e(41190),x=e(64391),R=e(82966),I=e(6451),M=e(45158),D=e(67925),B=function(){function ue(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}return Object.defineProperty(ue.prototype,"singleClick",{get:function(){return this._singleClick},set:function(U){this._singleClick=U},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"doubleClick",{get:function(){return this._doubleClick},set:function(U){this._doubleClick=U},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"hasSwiped",{get:function(){return this._hasSwiped},set:function(U){this._hasSwiped=U},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"ignore",{get:function(){return this._ignore},set:function(U){this._ignore=U},enumerable:!1,configurable:!0}),ue}(),F=function(){function ue(U){this._alreadyAttached=!1,this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._totalPointersPressed=0,this._doubleClickOccured=!1,this._isSwiping=!1,this._swipeButtonPressed=-1,this._skipPointerTap=!1,this._isMultiTouchGesture=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new d.I9(0,0),this._previousStartingPointerPosition=new d.I9(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._meshUnderPointerId={},this._movePointerInfo=null,this._cameraObserverCount=0,this._delayedClicks=[null,null,null,null,null],this._deviceSourceManager=null,this._scene=U||S.q.LastCreatedScene,this._scene}return Object.defineProperty(ue.prototype,"meshUnderPointer",{get:function(){return this._movePointerInfo&&(this._movePointerInfo._generatePickInfo(),this._movePointerInfo=null),this._pointerOverMesh},enumerable:!1,configurable:!0}),ue.prototype.getMeshUnderPointerByPointerId=function(U){return this._meshUnderPointerId[U]||null},Object.defineProperty(ue.prototype,"unTranslatedPointer",{get:function(){return new d.I9(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"pointerX",{get:function(){return this._pointerX},set:function(U){this._pointerX=U},enumerable:!1,configurable:!0}),Object.defineProperty(ue.prototype,"pointerY",{get:function(){return this._pointerY},set:function(U){this._pointerY=U},enumerable:!1,configurable:!0}),ue.prototype._updatePointerPosition=function(U){var N=this._scene.getEngine().getInputElementClientRect();N&&(this._pointerX=U.clientX-N.left,this._pointerY=U.clientY-N.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)},ue.prototype._processPointerMove=function(U,N){var w=this._scene,k=w.getEngine(),J=k.getInputElement();J&&(J.tabIndex=k.canvasTabIndex,w.doNotHandleCursors||(J.style.cursor=w.defaultCursor)),this._setCursorAndPointerOverMesh(U,N,w);for(var le=0,be=w._pointerMoveStage;le<be.length;le++){var ve=be[le],ye=!!((U=U||this._pickMove(N))!=null&&U.pickedMesh);U=ve.action(this._unTranslatedPointerX,this._unTranslatedPointerY,U,ye,J)}var Me,we=N.inputIndex>=M.ST.MouseWheelX&&N.inputIndex<=M.ST.MouseWheelZ?x.Zp.POINTERWHEEL:x.Zp.POINTERMOVE;w.onPointerMove&&(U=U||this._pickMove(N),w.onPointerMove(N,U,we)),U?(Me=new x.mx(we,N,U),this._setRayOnPointerInfo(U,N)):(Me=new x.mx(we,N,null,this),this._movePointerInfo=Me),w.onPointerObservable.hasObservers()&&w.onPointerObservable.notifyObservers(Me,we)},ue.prototype._setRayOnPointerInfo=function(U,N){var w=this._scene;U&&w._pickingAvailable&&(U.ray||(U.ray=w.createPickingRay(N.offsetX,N.offsetY,d.uq.Identity(),w.activeCamera)))},ue.prototype._addCameraPointerObserver=function(U,N){return this._cameraObserverCount++,this._scene.onPointerObservable.add(U,N)},ue.prototype._removeCameraPointerObserver=function(U){return this._cameraObserverCount--,this._scene.onPointerObservable.remove(U)},ue.prototype._checkForPicking=function(){return!!(this._scene.onPointerObservable.observers.length>this._cameraObserverCount||this._scene.onPointerPick)},ue.prototype._checkPrePointerObservable=function(U,N,w){var k=this._scene,J=new x.tT(w,N,this._unTranslatedPointerX,this._unTranslatedPointerY);return U&&(J.originalPickingInfo=U,J.ray=U.ray,N.pointerType==="xr-near"&&U.originMesh&&(J.nearInteractionPickingInfo=U)),k.onPrePointerObservable.notifyObservers(J,w),!!J.skipOnPointerObservable},ue.prototype._pickMove=function(U){var N=this._scene,w=N.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,N.pointerMovePredicate,N.pointerMoveFastCheck,N.cameraToUseForPointers,N.pointerMoveTrianglePredicate);return this._setCursorAndPointerOverMesh(w,U,N),w},ue.prototype._setCursorAndPointerOverMesh=function(U,N,w){var k=w.getEngine().getInputElement();if(U?.pickedMesh){if(this.setPointerOverMesh(U.pickedMesh,N.pointerId,U,N),!w.doNotHandleCursors&&k&&this._pointerOverMesh){var J=this._pointerOverMesh._getActionManagerForTrigger();J&&J.hasPointerTriggers&&(k.style.cursor=J.hoverCursor||w.hoverCursor)}}else this.setPointerOverMesh(null,N.pointerId,U,N)},ue.prototype.simulatePointerMove=function(U,N){var w=new PointerEvent("pointermove",N);w.inputIndex=M.ST.Move,this._checkPrePointerObservable(U,w,x.Zp.POINTERMOVE)||this._processPointerMove(U,w)},ue.prototype.simulatePointerDown=function(U,N){var w=new PointerEvent("pointerdown",N);w.inputIndex=w.button+2,this._checkPrePointerObservable(U,w,x.Zp.POINTERDOWN)||this._processPointerDown(U,w)},ue.prototype._processPointerDown=function(U,N){var w,k=this,J=this._scene;if(U?.pickedMesh){this._pickedDownMesh=U.pickedMesh;var le=U.pickedMesh._getActionManagerForTrigger();if(le){if(le.hasPickTriggers)switch(le.processTrigger(f.Y.ACTION_OnPickDownTrigger,b.X.CreateNew(U.pickedMesh,N,U)),N.button){case 0:le.processTrigger(f.Y.ACTION_OnLeftPickTrigger,b.X.CreateNew(U.pickedMesh,N,U));break;case 1:le.processTrigger(f.Y.ACTION_OnCenterPickTrigger,b.X.CreateNew(U.pickedMesh,N,U));break;case 2:le.processTrigger(f.Y.ACTION_OnRightPickTrigger,b.X.CreateNew(U.pickedMesh,N,U))}le.hasSpecificTrigger(f.Y.ACTION_OnLongPressTrigger)&&window.setTimeout(function(){var Me=J.pick(k._unTranslatedPointerX,k._unTranslatedPointerY,function(we){return we.isPickable&&we.isVisible&&we.isReady()&&we.actionManager&&we.actionManager.hasSpecificTrigger(f.Y.ACTION_OnLongPressTrigger)&&we===k._pickedDownMesh},!1,J.cameraToUseForPointers);Me?.pickedMesh&&le&&k._totalPointersPressed!==0&&Date.now()-k._startingPointerTime>ue.LongPressDelay&&!k._isPointerSwiping()&&(k._startingPointerTime=0,le.processTrigger(f.Y.ACTION_OnLongPressTrigger,b.X.CreateNew(Me.pickedMesh,N)))},ue.LongPressDelay)}}else for(var be=0,ve=J._pointerDownStage;be<ve.length;be++)U=ve[be].action(this._unTranslatedPointerX,this._unTranslatedPointerY,U,N,!1);var ye=x.Zp.POINTERDOWN;U?(J.onPointerDown&&J.onPointerDown(N,U,ye),w=new x.mx(ye,N,U),this._setRayOnPointerInfo(U,N)):w=new x.mx(ye,N,null,this),J.onPointerObservable.hasObservers()&&J.onPointerObservable.notifyObservers(w,ye)},ue.prototype._isPointerSwiping=function(){return this._isSwiping},ue.prototype.simulatePointerUp=function(U,N,w){var k=new PointerEvent("pointerup",N);k.inputIndex=M.ST.Move;var J=new B;w?J.doubleClick=!0:J.singleClick=!0,this._checkPrePointerObservable(U,k,x.Zp.POINTERUP)||this._processPointerUp(U,k,J)},ue.prototype._processPointerUp=function(U,N,w){var k=this._scene;if(U?.pickedMesh){if(this._pickedUpMesh=U.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(k.onPointerPick&&k.onPointerPick(N,U),w.singleClick&&!w.ignore&&k.onPointerObservable.observers.length>this._cameraObserverCount)){var J=x.Zp.POINTERPICK,le=new x.mx(J,N,U);this._setRayOnPointerInfo(U,N),k.onPointerObservable.notifyObservers(le,J)}var be=U.pickedMesh._getActionManagerForTrigger();if(be&&!w.ignore){be.processTrigger(f.Y.ACTION_OnPickUpTrigger,b.X.CreateNew(U.pickedMesh,N,U)),!w.hasSwiped&&w.singleClick&&be.processTrigger(f.Y.ACTION_OnPickTrigger,b.X.CreateNew(U.pickedMesh,N,U));var ve=U.pickedMesh._getActionManagerForTrigger(f.Y.ACTION_OnDoublePickTrigger);w.doubleClick&&ve&&ve.processTrigger(f.Y.ACTION_OnDoublePickTrigger,b.X.CreateNew(U.pickedMesh,N,U))}}else if(!w.ignore)for(var ye=0,Me=k._pointerUpStage;ye<Me.length;ye++)U=Me[ye].action(this._unTranslatedPointerX,this._unTranslatedPointerY,U,N,w.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){var we=this._pickedDownMesh._getActionManagerForTrigger(f.Y.ACTION_OnPickOutTrigger);we&&we.processTrigger(f.Y.ACTION_OnPickOutTrigger,b.X.CreateNew(this._pickedDownMesh,N))}if(!w.ignore&&(le=new x.mx(x.Zp.POINTERUP,N,U),this._setRayOnPointerInfo(U,N),k.onPointerObservable.notifyObservers(le,x.Zp.POINTERUP),k.onPointerUp&&k.onPointerUp(N,U,x.Zp.POINTERUP),!w.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture&&(J=0,w.singleClick?J=x.Zp.POINTERTAP:w.doubleClick&&(J=x.Zp.POINTERDOUBLETAP),J))){var He=new x.mx(J,N,U);k.onPointerObservable.hasObservers()&&k.onPointerObservable.hasSpecificMask(J)&&k.onPointerObservable.notifyObservers(He,J)}},ue.prototype.isPointerCaptured=function(U){return U===void 0&&(U=0),this._pointerCaptures[U]},ue.prototype.attachControl=function(U,N,w,k){var J=this;U===void 0&&(U=!0),N===void 0&&(N=!0),w===void 0&&(w=!0),k===void 0&&(k=null);var le=this._scene,be=le.getEngine();k||(k=be.getInputElement()),this._alreadyAttached&&this.detachControl(),k&&(this._alreadyAttachedTo=k),this._deviceSourceManager=new D.Z(be),this._initActionManager=function(ve){if(!J._meshPickProceed){var ye=le.skipPointerUpPicking||le._registeredActions===0&&!J._checkForPicking()&&!le.onPointerUp?null:le.pick(J._unTranslatedPointerX,J._unTranslatedPointerY,le.pointerUpPredicate,le.pointerUpFastCheck,le.cameraToUseForPointers,le.pointerUpTrianglePredicate);J._currentPickResult=ye,ye&&(ve=ye.hit&&ye.pickedMesh?ye.pickedMesh._getActionManagerForTrigger():null),J._meshPickProceed=!0}return ve},this._delayedSimpleClick=function(ve,ye,Me){if((Date.now()-J._previousStartingPointerTime>ue.DoubleClickDelay&&!J._doubleClickOccured||ve!==J._previousButtonPressed)&&(J._doubleClickOccured=!1,ye.singleClick=!0,ye.ignore=!1,J._delayedClicks[ve])){var we=J._delayedClicks[ve].evt,He=x.Zp.POINTERTAP,Ke=new x.mx(He,we,J._currentPickResult);le.onPointerObservable.hasObservers()&&le.onPointerObservable.hasSpecificMask(He)&&le.onPointerObservable.notifyObservers(Ke,He),J._delayedClicks[ve]=null}},this._initClickEvent=function(ve,ye,Me,we){var He,Ke,Qe=new B;J._currentPickResult=null;var Je=null,ht=ve.hasSpecificMask(x.Zp.POINTERPICK)||ye.hasSpecificMask(x.Zp.POINTERPICK)||ve.hasSpecificMask(x.Zp.POINTERTAP)||ye.hasSpecificMask(x.Zp.POINTERTAP)||ve.hasSpecificMask(x.Zp.POINTERDOUBLETAP)||ye.hasSpecificMask(x.Zp.POINTERDOUBLETAP);!ht&&R.G&&(Je=J._initActionManager(Je,Qe))&&(ht=Je.hasPickTriggers);var mt=!1;if(ht){var yt=Me.button;if(Qe.hasSwiped=J._isPointerSwiping(),!Qe.hasSwiped){var zt=!ue.ExclusiveDoubleClickMode;if(zt||(zt=!ve.hasSpecificMask(x.Zp.POINTERDOUBLETAP)&&!ye.hasSpecificMask(x.Zp.POINTERDOUBLETAP))&&!R.G.HasSpecificTrigger(f.Y.ACTION_OnDoublePickTrigger)&&(Je=J._initActionManager(Je,Qe))&&(zt=!Je.hasSpecificTrigger(f.Y.ACTION_OnDoublePickTrigger)),zt)(Date.now()-J._previousStartingPointerTime>ue.DoubleClickDelay||yt!==J._previousButtonPressed)&&(Qe.singleClick=!0,we(Qe,J._currentPickResult),mt=!0);else{var $t={evt:Me,clickInfo:Qe,timeoutId:window.setTimeout(J._delayedSimpleClick.bind(J,yt,Qe,we),ue.DoubleClickDelay)};J._delayedClicks[yt]=$t}var St=ve.hasSpecificMask(x.Zp.POINTERDOUBLETAP)||ye.hasSpecificMask(x.Zp.POINTERDOUBLETAP);!St&&R.G.HasSpecificTrigger(f.Y.ACTION_OnDoublePickTrigger)&&(Je=J._initActionManager(Je,Qe))&&(St=Je.hasSpecificTrigger(f.Y.ACTION_OnDoublePickTrigger)),St&&(yt===J._previousButtonPressed&&Date.now()-J._previousStartingPointerTime<ue.DoubleClickDelay&&!J._doubleClickOccured?(Qe.hasSwiped||J._isPointerSwiping()?(J._doubleClickOccured=!1,J._previousStartingPointerTime=J._startingPointerTime,J._previousStartingPointerPosition.x=J._startingPointerPosition.x,J._previousStartingPointerPosition.y=J._startingPointerPosition.y,J._previousButtonPressed=yt,ue.ExclusiveDoubleClickMode?(J._delayedClicks[yt]&&(clearTimeout((Ke=J._delayedClicks[yt])===null||Ke===void 0?void 0:Ke.timeoutId),J._delayedClicks[yt]=null),we(Qe,J._previousPickResult)):we(Qe,J._currentPickResult)):(J._previousStartingPointerTime=0,J._doubleClickOccured=!0,Qe.doubleClick=!0,Qe.ignore=!1,ue.ExclusiveDoubleClickMode&&J._delayedClicks[yt]&&(clearTimeout((He=J._delayedClicks[yt])===null||He===void 0?void 0:He.timeoutId),J._delayedClicks[yt]=null),we(Qe,J._currentPickResult)),mt=!0):(J._doubleClickOccured=!1,J._previousStartingPointerTime=J._startingPointerTime,J._previousStartingPointerPosition.x=J._startingPointerPosition.x,J._previousStartingPointerPosition.y=J._startingPointerPosition.y,J._previousButtonPressed=yt))}}mt||we(Qe,J._currentPickResult)},this._onPointerMove=function(ve){if(J._updatePointerPosition(ve),J._isSwiping||J._swipeButtonPressed===-1||(J._isSwiping=Math.abs(J._startingPointerPosition.x-J._pointerX)>ue.DragMovementThreshold||Math.abs(J._startingPointerPosition.y-J._pointerY)>ue.DragMovementThreshold),be.isPointerLock&&be._verifyPointerLock(),!J._checkPrePointerObservable(null,ve,ve.inputIndex>=M.ST.MouseWheelX&&ve.inputIndex<=M.ST.MouseWheelZ?x.Zp.POINTERWHEEL:x.Zp.POINTERMOVE)&&(le.cameraToUseForPointers||le.activeCamera))if(le.skipPointerMovePicking)J._processPointerMove(new v.G,ve);else{le.pointerMovePredicate||(le.pointerMovePredicate=function(Me){return Me.isPickable&&Me.isVisible&&Me.isReady()&&Me.isEnabled()&&(Me.enablePointerMoveEvents||le.constantlyUpdateMeshUnderPointer||Me._getActionManagerForTrigger()!==null)&&(!le.cameraToUseForPointers||!!(le.cameraToUseForPointers.layerMask&Me.layerMask))});var ye=le._registeredActions>0||le.constantlyUpdateMeshUnderPointer?J._pickMove(ve):null;J._processPointerMove(ye,ve)}},this._onPointerDown=function(ve){var ye,Me;if(J._totalPointersPressed++,J._pickedDownMesh=null,J._meshPickProceed=!1,ue.ExclusiveDoubleClickMode){for(var we=0;we<J._delayedClicks.length;we++)if(J._delayedClicks[we])if(ve.button===we)clearTimeout((ye=J._delayedClicks[we])===null||ye===void 0?void 0:ye.timeoutId);else{var He=J._delayedClicks[we].clickInfo;J._doubleClickOccured=!1,He.singleClick=!0,He.ignore=!1;var Ke=J._delayedClicks[we].evt,Qe=x.Zp.POINTERTAP,Je=new x.mx(Qe,Ke,J._currentPickResult);le.onPointerObservable.hasObservers()&&le.onPointerObservable.hasSpecificMask(Qe)&&le.onPointerObservable.notifyObservers(Je,Qe),J._delayedClicks[we]=null}}J._updatePointerPosition(ve),J._swipeButtonPressed===-1&&(J._swipeButtonPressed=ve.button),le.preventDefaultOnPointerDown&&k&&(ve.preventDefault(),k.focus()),J._startingPointerPosition.x=J._pointerX,J._startingPointerPosition.y=J._pointerY,J._startingPointerTime=Date.now(),J._checkPrePointerObservable(null,ve,x.Zp.POINTERDOWN)||(le.cameraToUseForPointers||le.activeCamera)&&(J._pointerCaptures[ve.pointerId]=!0,le.pointerDownPredicate||(le.pointerDownPredicate=function(ht){return ht.isPickable&&ht.isVisible&&ht.isReady()&&ht.isEnabled()&&(!le.cameraToUseForPointers||!!(le.cameraToUseForPointers.layerMask&ht.layerMask))}),J._pickedDownMesh=null,Me=le.skipPointerDownPicking||le._registeredActions===0&&!J._checkForPicking()&&!le.onPointerDown?new v.G:le.pick(J._unTranslatedPointerX,J._unTranslatedPointerY,le.pointerDownPredicate,le.pointerDownFastCheck,le.cameraToUseForPointers,le.pointerDownTrianglePredicate),J._processPointerDown(Me,ve))},this._onPointerUp=function(ve){J._totalPointersPressed!==0&&(J._totalPointersPressed--,J._pickedUpMesh=null,J._meshPickProceed=!1,J._updatePointerPosition(ve),le.preventDefaultOnPointerUp&&k&&(ve.preventDefault(),k.focus()),J._initClickEvent(le.onPrePointerObservable,le.onPointerObservable,ve,function(ye,Me){if(le.onPrePointerObservable.hasObservers()&&(J._skipPointerTap=!1,!ye.ignore)){if(J._checkPrePointerObservable(null,ve,x.Zp.POINTERUP))return J._swipeButtonPressed===ve.button&&(J._isSwiping=!1,J._swipeButtonPressed=-1),void(ve.buttons===0&&(J._pointerCaptures[ve.pointerId]=!1));ye.hasSwiped||(ye.singleClick&&le.onPrePointerObservable.hasSpecificMask(x.Zp.POINTERTAP)&&J._checkPrePointerObservable(null,ve,x.Zp.POINTERTAP)&&(J._skipPointerTap=!0),ye.doubleClick&&le.onPrePointerObservable.hasSpecificMask(x.Zp.POINTERDOUBLETAP)&&J._checkPrePointerObservable(null,ve,x.Zp.POINTERDOUBLETAP)&&(J._skipPointerTap=!0))}J._pointerCaptures[ve.pointerId]?(ve.buttons===0&&(J._pointerCaptures[ve.pointerId]=!1),(le.cameraToUseForPointers||le.activeCamera)&&(le.pointerUpPredicate||(le.pointerUpPredicate=function(we){return we.isPickable&&we.isVisible&&we.isReady()&&we.isEnabled()&&(!le.cameraToUseForPointers||!!(le.cameraToUseForPointers.layerMask&we.layerMask))}),!J._meshPickProceed&&(R.G&&R.G.HasTriggers||J._checkForPicking()||le.onPointerUp)&&J._initActionManager(null,ye),Me||(Me=J._currentPickResult),J._processPointerUp(Me,ve,ye),J._previousPickResult=J._currentPickResult,J._swipeButtonPressed===ve.button&&(J._isSwiping=!1,J._swipeButtonPressed=-1))):J._swipeButtonPressed===ve.button&&(J._isSwiping=!1,J._swipeButtonPressed=-1)}))},this._onKeyDown=function(ve){var ye=I.TB.KEYDOWN;if(le.onPreKeyboardObservable.hasObservers()){var Me=new I.Bu(ye,ve);if(le.onPreKeyboardObservable.notifyObservers(Me,ye),Me.skipOnKeyboardObservable)return}le.onKeyboardObservable.hasObservers()&&(Me=new I.W0(ye,ve),le.onKeyboardObservable.notifyObservers(Me,ye)),le.actionManager&&le.actionManager.processTrigger(f.Y.ACTION_OnKeyDownTrigger,b.X.CreateNewFromScene(le,ve))},this._onKeyUp=function(ve){var ye=I.TB.KEYUP;if(le.onPreKeyboardObservable.hasObservers()){var Me=new I.Bu(ye,ve);if(le.onPreKeyboardObservable.notifyObservers(Me,ye),Me.skipOnKeyboardObservable)return}le.onKeyboardObservable.hasObservers()&&(Me=new I.W0(ye,ve),le.onKeyboardObservable.notifyObservers(Me,ye)),le.actionManager&&le.actionManager.processTrigger(f.Y.ACTION_OnKeyUpTrigger,b.X.CreateNewFromScene(le,ve))},this._deviceSourceManager.onDeviceConnectedObservable.add(function(ve){ve.deviceType===M.bq.Mouse?ve.onInputChangedObservable.add(function(ye){J._originMouseEvent=ye,ye.inputIndex===M.ST.LeftClick||ye.inputIndex===M.ST.MiddleClick||ye.inputIndex===M.ST.RightClick||ye.inputIndex===M.ST.BrowserBack||ye.inputIndex===M.ST.BrowserForward?N&&ve.getInput(ye.inputIndex)===1?J._onPointerDown(ye):U&&ve.getInput(ye.inputIndex)===0&&J._onPointerUp(ye):w&&(ye.inputIndex===M.ST.Move?J._onPointerMove(ye):ye.inputIndex!==M.ST.MouseWheelX&&ye.inputIndex!==M.ST.MouseWheelY&&ye.inputIndex!==M.ST.MouseWheelZ||J._onPointerMove(ye))}):ve.deviceType===M.bq.Touch?ve.onInputChangedObservable.add(function(ye){ye.inputIndex===M.ST.LeftClick&&(N&&ve.getInput(ye.inputIndex)===1?(J._onPointerDown(ye),J._totalPointersPressed>1&&(J._isMultiTouchGesture=!0)):U&&ve.getInput(ye.inputIndex)===0&&(J._onPointerUp(ye),J._totalPointersPressed===0&&(J._isMultiTouchGesture=!1))),w&&ye.inputIndex===M.ST.Move&&J._onPointerMove(ye)}):ve.deviceType===M.bq.Keyboard&&ve.onInputChangedObservable.add(function(ye){ye.type==="keydown"?J._onKeyDown(ye):ye.type==="keyup"&&J._onKeyUp(ye)})}),this._alreadyAttached=!0},ue.prototype.detachControl=function(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)},ue.prototype.setPointerOverMesh=function(U,N,w,k){if(N===void 0&&(N=0),this._meshUnderPointerId[N]!==U||U&&U._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting){var J,le=this._meshUnderPointerId[N];le&&(J=le._getActionManagerForTrigger(f.Y.ACTION_OnPointerOutTrigger))&&J.processTrigger(f.Y.ACTION_OnPointerOutTrigger,b.X.CreateNew(le,k,{pointerId:N})),U?(this._meshUnderPointerId[N]=U,this._pointerOverMesh=U,(J=U._getActionManagerForTrigger(f.Y.ACTION_OnPointerOverTrigger))&&J.processTrigger(f.Y.ACTION_OnPointerOverTrigger,b.X.CreateNew(U,k,{pointerId:N,pickResult:w}))):(delete this._meshUnderPointerId[N],this._pointerOverMesh=null)}},ue.prototype.getPointerOverMesh=function(){return this.meshUnderPointer},ue.prototype._invalidateMesh=function(U){for(var N in this._pointerOverMesh===U&&(this._pointerOverMesh=null),this._pickedDownMesh===U&&(this._pickedDownMesh=null),this._pickedUpMesh===U&&(this._pickedUpMesh=null),this._meshUnderPointerId)this._meshUnderPointerId[N]===U&&delete this._meshUnderPointerId[N]},ue.DragMovementThreshold=10,ue.LongPressDelay=500,ue.DoubleClickDelay=300,ue.ExclusiveDoubleClickMode=!1,ue}(),X=e(70511),$=e(64726),Q=e(36359),ie=e(62273),q=e(17347),ee=e(91946),te=e(11296),ce=function(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1},fe=e(7164),de=e(34623);(function(ue){ue[ue.BackwardCompatible=0]="BackwardCompatible",ue[ue.Intermediate=1]="Intermediate",ue[ue.Aggressive=2]="Aggressive"})(n||(n={}));var Te=function(ue){function U(N,w){var k=ue.call(this)||this;k._inputManager=new F(k),k.cameraToUseForPointers=null,k._isScene=!0,k._blockEntityCollection=!1,k.autoClear=!0,k.autoClearDepthAndStencil=!0,k.clearColor=new $.ov(.2,.2,.3,1),k.ambientColor=new $.v9(0,0,0),k.environmentIntensity=1,k._performancePriority=0,k.onScenePerformancePriorityChangedObservable=new s.cP,k._forceWireframe=!1,k._skipFrustumClipping=!1,k._forcePointsCloud=!1,k.animationsEnabled=!0,k._animationPropertiesOverride=null,k.useConstantAnimationDeltaTime=!1,k.constantlyUpdateMeshUnderPointer=!1,k.hoverCursor="pointer",k.defaultCursor="",k.doNotHandleCursors=!1,k.preventDefaultOnPointerDown=!0,k.preventDefaultOnPointerUp=!0,k.metadata=null,k.reservedDataStore=null,k.disableOfflineSupportExceptionRules=[],k.onDisposeObservable=new s.cP,k._onDisposeObserver=null,k.onBeforeRenderObservable=new s.cP,k._onBeforeRenderObserver=null,k.onAfterRenderObservable=new s.cP,k.onAfterRenderCameraObservable=new s.cP,k._onAfterRenderObserver=null,k.onBeforeAnimationsObservable=new s.cP,k.onAfterAnimationsObservable=new s.cP,k.onBeforeDrawPhaseObservable=new s.cP,k.onAfterDrawPhaseObservable=new s.cP,k.onReadyObservable=new s.cP,k.onBeforeCameraRenderObservable=new s.cP,k._onBeforeCameraRenderObserver=null,k.onAfterCameraRenderObservable=new s.cP,k._onAfterCameraRenderObserver=null,k.onBeforeActiveMeshesEvaluationObservable=new s.cP,k.onAfterActiveMeshesEvaluationObservable=new s.cP,k.onBeforeParticlesRenderingObservable=new s.cP,k.onAfterParticlesRenderingObservable=new s.cP,k.onDataLoadedObservable=new s.cP,k.onNewCameraAddedObservable=new s.cP,k.onCameraRemovedObservable=new s.cP,k.onNewLightAddedObservable=new s.cP,k.onLightRemovedObservable=new s.cP,k.onNewGeometryAddedObservable=new s.cP,k.onGeometryRemovedObservable=new s.cP,k.onNewTransformNodeAddedObservable=new s.cP,k.onTransformNodeRemovedObservable=new s.cP,k.onNewMeshAddedObservable=new s.cP,k.onMeshRemovedObservable=new s.cP,k.onNewSkeletonAddedObservable=new s.cP,k.onSkeletonRemovedObservable=new s.cP,k.onNewMaterialAddedObservable=new s.cP,k.onNewMultiMaterialAddedObservable=new s.cP,k.onMaterialRemovedObservable=new s.cP,k.onMultiMaterialRemovedObservable=new s.cP,k.onNewTextureAddedObservable=new s.cP,k.onTextureRemovedObservable=new s.cP,k.onBeforeRenderTargetsRenderObservable=new s.cP,k.onAfterRenderTargetsRenderObservable=new s.cP,k.onBeforeStepObservable=new s.cP,k.onAfterStepObservable=new s.cP,k.onActiveCameraChanged=new s.cP,k.onActiveCamerasChanged=new s.cP,k.onBeforeRenderingGroupObservable=new s.cP,k.onAfterRenderingGroupObservable=new s.cP,k.onMeshImportedObservable=new s.cP,k.onAnimationFileImportedObservable=new s.cP,k._registeredForLateAnimationBindings=new l.b(256),k._pointerPickingConfiguration=new ce,k.onPrePointerObservable=new s.cP,k.onPointerObservable=new s.cP,k.onPreKeyboardObservable=new s.cP,k.onKeyboardObservable=new s.cP,k._useRightHandedSystem=!1,k._timeAccumulator=0,k._currentStepId=0,k._currentInternalStep=0,k._fogEnabled=!0,k._fogMode=U.FOGMODE_NONE,k.fogColor=new $.v9(.2,.2,.3),k.fogDensity=.1,k.fogStart=0,k.fogEnd=1e3,k.needsPreviousWorldMatrices=!1,k._shadowsEnabled=!0,k._lightsEnabled=!0,k._unObserveActiveCameras=null,k._texturesEnabled=!0,k.physicsEnabled=!0,k.particlesEnabled=!0,k.spritesEnabled=!0,k._skeletonsEnabled=!0,k.lensFlaresEnabled=!0,k.collisionsEnabled=!0,k.gravity=new d.Pq(0,-9.807,0),k.postProcessesEnabled=!0,k.renderTargetsEnabled=!0,k.dumpNextRenderTargets=!1,k.customRenderTargets=[],k.importedMeshesFiles=[],k.probesEnabled=!0,k._meshesForIntersections=new l.b(256),k.proceduralTexturesEnabled=!0,k._totalVertices=new X.A,k._activeIndices=new X.A,k._activeParticles=new X.A,k._activeBones=new X.A,k._animationTime=0,k.animationTimeScale=1,k._renderId=0,k._frameId=0,k._executeWhenReadyTimeoutId=null,k._intermediateRendering=!1,k._defaultFrameBufferCleared=!1,k._viewUpdateFlag=-1,k._projectionUpdateFlag=-1,k._toBeDisposed=new Array(256),k._activeRequests=new Array,k._pendingData=new Array,k._isDisposed=!1,k.dispatchAllSubMeshesOfActiveMeshes=!1,k._activeMeshes=new l.L(256),k._processedMaterials=new l.L(256),k._renderTargets=new l.b(256),k._materialsRenderTargets=new l.b(256),k._activeParticleSystems=new l.L(256),k._activeSkeletons=new l.b(32),k._softwareSkinnedMeshes=new l.b(32),k._activeAnimatables=new Array,k._transformMatrix=d.uq.Zero(),k.requireLightSorting=!1,k._components=[],k._serializableComponents=[],k._transientComponents=[],k._beforeCameraUpdateStage=T.B.Create(),k._beforeClearStage=T.B.Create(),k._beforeRenderTargetClearStage=T.B.Create(),k._gatherRenderTargetsStage=T.B.Create(),k._gatherActiveCameraRenderTargetsStage=T.B.Create(),k._isReadyForMeshStage=T.B.Create(),k._beforeEvaluateActiveMeshStage=T.B.Create(),k._evaluateSubMeshStage=T.B.Create(),k._preActiveMeshStage=T.B.Create(),k._cameraDrawRenderTargetStage=T.B.Create(),k._beforeCameraDrawStage=T.B.Create(),k._beforeRenderTargetDrawStage=T.B.Create(),k._beforeRenderingGroupDrawStage=T.B.Create(),k._beforeRenderingMeshStage=T.B.Create(),k._afterRenderingMeshStage=T.B.Create(),k._afterRenderingGroupDrawStage=T.B.Create(),k._afterCameraDrawStage=T.B.Create(),k._afterCameraPostProcessStage=T.B.Create(),k._afterRenderTargetDrawStage=T.B.Create(),k._afterRenderTargetPostProcessStage=T.B.Create(),k._afterRenderStage=T.B.Create(),k._pointerMoveStage=T.B.Create(),k._pointerDownStage=T.B.Create(),k._pointerUpStage=T.B.Create(),k._geometriesByUniqueId=null,k._defaultMeshCandidates={data:[],length:0},k._defaultSubMeshCandidates={data:[],length:0},k._preventFreeActiveMeshesAndRenderingGroups=!1,k._activeMeshesFrozen=!1,k._activeMeshesFrozenButKeepClipping=!1,k._skipEvaluateActiveMeshesCompletely=!1,k._allowPostProcessClearColor=!0,k.getDeterministicFrameTime=function(){return k._engine.getTimeStep()},k._registeredActions=0,k._blockMaterialDirtyMechanism=!1,k._perfCollector=null,k.activeCameras=[];var J=(0,i.Cl)({useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1},w);return N=k._engine=N||S.q.LastCreatedEngine,J.virtual?N._virtualScenes.push(k):(S.q._LastCreatedScene=k,N.scenes.push(k)),k._uid=null,k._renderingManager=new C.m(k),E.X&&(k.postProcessManager=new E.X(k)),(0,g.BA)()&&k.attachControl(),k._createUbo(),p.p&&(k._imageProcessingConfiguration=new p.p),k.setDefaultCandidateProviders(),J.useGeometryUniqueIdsMap&&(k._geometriesByUniqueId={}),k.useMaterialMeshMap=J.useMaterialMeshMap,k.useClonedMeshMap=J.useClonedMeshMap,w&&w.virtual||N.onNewSceneAddedObservable.notifyObservers(k),k}return(0,i.C6)(U,ue),U.DefaultMaterialFactory=function(N){throw(0,y.n)("StandardMaterial")},U.CollisionCoordinatorFactory=function(){throw(0,y.n)("DefaultCollisionCoordinator")},Object.defineProperty(U.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(N){this._environmentTexture!==N&&(this._environmentTexture=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"performancePriority",{get:function(){return this._performancePriority},set:function(N){if(N!==this._performancePriority){switch(this._performancePriority=N,N){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1}this.onScenePerformancePriorityChangedObservable.notifyObservers(N)}},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(N){this._forceWireframe!==N&&(this._forceWireframe=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"skipFrustumClipping",{get:function(){return this._skipFrustumClipping},set:function(N){this._skipFrustumClipping!==N&&(this._skipFrustumClipping=N)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(N){this._forcePointsCloud!==N&&(this._forcePointsCloud=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(N){this._animationPropertiesOverride=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"onDispose",{set:function(N){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(N)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"beforeRender",{set:function(N){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),N&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(N))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"afterRender",{set:function(N){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),N&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(N))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"beforeCameraRender",{set:function(N){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(N)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"afterCameraRender",{set:function(N){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(N)},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerDownPredicate",{get:function(){return this._pointerPickingConfiguration.pointerDownPredicate},set:function(N){this._pointerPickingConfiguration.pointerDownPredicate=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerUpPredicate",{get:function(){return this._pointerPickingConfiguration.pointerUpPredicate},set:function(N){this._pointerPickingConfiguration.pointerUpPredicate=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerMovePredicate",{get:function(){return this._pointerPickingConfiguration.pointerMovePredicate},set:function(N){this._pointerPickingConfiguration.pointerMovePredicate=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerDownFastCheck",{get:function(){return this._pointerPickingConfiguration.pointerDownFastCheck},set:function(N){this._pointerPickingConfiguration.pointerDownFastCheck=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerUpFastCheck",{get:function(){return this._pointerPickingConfiguration.pointerUpFastCheck},set:function(N){this._pointerPickingConfiguration.pointerUpFastCheck=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerMoveFastCheck",{get:function(){return this._pointerPickingConfiguration.pointerMoveFastCheck},set:function(N){this._pointerPickingConfiguration.pointerMoveFastCheck=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"skipPointerMovePicking",{get:function(){return this._pointerPickingConfiguration.skipPointerMovePicking},set:function(N){this._pointerPickingConfiguration.skipPointerMovePicking=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"skipPointerDownPicking",{get:function(){return this._pointerPickingConfiguration.skipPointerDownPicking},set:function(N){this._pointerPickingConfiguration.skipPointerDownPicking=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"skipPointerUpPicking",{get:function(){return this._pointerPickingConfiguration.skipPointerUpPicking},set:function(N){this._pointerPickingConfiguration.skipPointerUpPicking=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"unTranslatedPointer",{get:function(){return this._inputManager.unTranslatedPointer},enumerable:!1,configurable:!0}),Object.defineProperty(U,"DragMovementThreshold",{get:function(){return F.DragMovementThreshold},set:function(N){F.DragMovementThreshold=N},enumerable:!1,configurable:!0}),Object.defineProperty(U,"LongPressDelay",{get:function(){return F.LongPressDelay},set:function(N){F.LongPressDelay=N},enumerable:!1,configurable:!0}),Object.defineProperty(U,"DoubleClickDelay",{get:function(){return F.DoubleClickDelay},set:function(N){F.DoubleClickDelay=N},enumerable:!1,configurable:!0}),Object.defineProperty(U,"ExclusiveDoubleClickMode",{get:function(){return F.ExclusiveDoubleClickMode},set:function(N){F.ExclusiveDoubleClickMode=N},enumerable:!1,configurable:!0}),U.prototype.bindEyePosition=function(N,w,k){w===void 0&&(w="vEyePosition"),k===void 0&&(k=!1);var J=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:this.activeCamera.globalPosition,le=this.useRightHandedSystem===(this._mirroredCameraPosition!=null);return d.AA.Vector4[0].set(J.x,J.y,J.z,le?-1:1),N&&(k?N.setFloat3(w,d.AA.Vector4[0].x,d.AA.Vector4[0].y,d.AA.Vector4[0].z):N.setVector4(w,d.AA.Vector4[0])),d.AA.Vector4[0]},U.prototype.finalizeSceneUbo=function(){var N=this.getSceneUniformBuffer(),w=this.bindEyePosition(null);return N.updateFloat4("vEyePosition",w.x,w.y,w.z,w.w),N.update(),N},Object.defineProperty(U.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(N){this._useRightHandedSystem!==N&&(this._useRightHandedSystem=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),U.prototype.setStepId=function(N){this._currentStepId=N},U.prototype.getStepId=function(){return this._currentStepId},U.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(U.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(N){this._fogEnabled!==N&&(this._fogEnabled=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"fogMode",{get:function(){return this._fogMode},set:function(N){this._fogMode!==N&&(this._fogMode=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"prePass",{get:function(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(N){this._shadowsEnabled!==N&&(this._shadowsEnabled=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_LightDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(N){this._lightsEnabled!==N&&(this._lightsEnabled=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_LightDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"activeCameras",{get:function(){return this._activeCameras},set:function(N){var w=this;this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),N&&(this._unObserveActiveCameras=(0,te.lL)(N,function(){w.onActiveCamerasChanged.notifyObservers(w)})),this._activeCameras=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"activeCamera",{get:function(){return this._activeCamera},set:function(N){N!==this._activeCamera&&(this._activeCamera=N,this.onActiveCameraChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=U.DefaultMaterialFactory(this)),this._defaultMaterial},set:function(N){this._defaultMaterial=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(N){this._texturesEnabled!==N&&(this._texturesEnabled=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(N){this._skeletonsEnabled!==N&&(this._skeletonsEnabled=N,this.markAllMaterialsAsDirty(f.Y.MATERIAL_AttributesDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"collisionCoordinator",{get:function(){return this._collisionCoordinator||(this._collisionCoordinator=U.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"renderingManager",{get:function(){return this._renderingManager},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!1,configurable:!0}),U.prototype._registerTransientComponents=function(){if(this._transientComponents.length>0){for(var N=0,w=this._transientComponents;N<w.length;N++)w[N].register();this._transientComponents.length=0}},U.prototype._addComponent=function(N){this._components.push(N),this._transientComponents.push(N);var w=N;w.addFromContainer&&w.serialize&&this._serializableComponents.push(w)},U.prototype._getComponent=function(N){for(var w=0,k=this._components;w<k.length;w++){var J=k[w];if(J.name===N)return J}return null},U.prototype.getClassName=function(){return"Scene"},U.prototype._getDefaultMeshCandidates=function(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates},U.prototype._getDefaultSubMeshCandidates=function(N){return this._defaultSubMeshCandidates.data=N.subMeshes,this._defaultSubMeshCandidates.length=N.subMeshes.length,this._defaultSubMeshCandidates},U.prototype.setDefaultCandidateProviders=function(){var N=this;this.getActiveMeshCandidates=function(){return N._getDefaultMeshCandidates()},this.getActiveSubMeshCandidates=function(w){return N._getDefaultSubMeshCandidates(w)},this.getIntersectingSubMeshCandidates=function(w,k){return N._getDefaultSubMeshCandidates(w)},this.getCollidingSubMeshCandidates=function(w,k){return N._getDefaultSubMeshCandidates(w)}},Object.defineProperty(U.prototype,"meshUnderPointer",{get:function(){return this._inputManager.meshUnderPointer},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerX",{get:function(){return this._inputManager.pointerX},set:function(N){this._inputManager.pointerX=N},enumerable:!1,configurable:!0}),Object.defineProperty(U.prototype,"pointerY",{get:function(){return this._inputManager.pointerY},set:function(N){this._inputManager.pointerY=N},enumerable:!1,configurable:!0}),U.prototype.getCachedMaterial=function(){return this._cachedMaterial},U.prototype.getCachedEffect=function(){return this._cachedEffect},U.prototype.getCachedVisibility=function(){return this._cachedVisibility},U.prototype.isCachedMaterialInvalid=function(N,w,k){return k===void 0&&(k=1),this._cachedEffect!==w||this._cachedMaterial!==N||this._cachedVisibility!==k},U.prototype.getEngine=function(){return this._engine},U.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(U.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!1,configurable:!0}),U.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(U.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!1,configurable:!0}),U.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(U.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!1,configurable:!0}),U.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(U.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!1,configurable:!0}),U.prototype.getActiveMeshes=function(){return this._activeMeshes},U.prototype.getAnimationRatio=function(){return this._animationRatio!==void 0?this._animationRatio:1},U.prototype.getRenderId=function(){return this._renderId},U.prototype.getFrameId=function(){return this._frameId},U.prototype.incrementRenderId=function(){this._renderId++},U.prototype._createUbo=function(){this.setSceneUniformBuffer(this.createSceneUniformBuffer())},U.prototype.simulatePointerMove=function(N,w){return this._inputManager.simulatePointerMove(N,w),this},U.prototype.simulatePointerDown=function(N,w){return this._inputManager.simulatePointerDown(N,w),this},U.prototype.simulatePointerUp=function(N,w,k){return this._inputManager.simulatePointerUp(N,w,k),this},U.prototype.isPointerCaptured=function(N){return N===void 0&&(N=0),this._inputManager.isPointerCaptured(N)},U.prototype.attachControl=function(N,w,k){N===void 0&&(N=!0),w===void 0&&(w=!0),k===void 0&&(k=!0),this._inputManager.attachControl(N,w,k)},U.prototype.detachControl=function(){this._inputManager.detachControl()},U.prototype.isReady=function(N){var w,k,J,le;if(N===void 0&&(N=!0),this._isDisposed)return!1;var be=this.getEngine(),ve=be.currentRenderPassId;be.currentRenderPassId=(k=(w=this.activeCamera)===null||w===void 0?void 0:w.renderPassId)!==null&&k!==void 0?k:ve;var ye=!0;for(this._pendingData.length>0&&(ye=!1),(J=this.prePassRenderer)===null||J===void 0||J.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&ye&&(ye=this.depthPeelingRenderer.isReady()),N&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),le=0;le<this.meshes.length;le++){var Me=this.meshes[le];if(Me.subMeshes&&Me.subMeshes.length!==0)if(Me.isReady(!0)){for(var we=Me.hasThinInstances||Me.getClassName()==="InstancedMesh"||Me.getClassName()==="InstancedLinesMesh"||be.getCaps().instancedArrays&&Me.instances.length>0,He=0,Ke=this._isReadyForMeshStage;He<Ke.length;He++)Ke[He].action(Me,we)||(ye=!1);if(N){var Qe=Me.material||this.defaultMaterial;if(Qe)if(Qe._storeEffectOnSubMeshes)for(var Je=0,ht=Me.subMeshes;Je<ht.length;Je++){var mt=ht[Je].getMaterial();mt&&mt.hasRenderTargetTextures&&mt.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(mt)===-1&&(this._processedMaterials.push(mt),this._materialsRenderTargets.concatWithNoDuplicate(mt.getRenderTargetTextures()))}else Qe.hasRenderTargetTextures&&Qe.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(Qe)===-1&&(this._processedMaterials.push(Qe),this._materialsRenderTargets.concatWithNoDuplicate(Qe.getRenderTargetTextures()))}}else ye=!1}if(N)for(le=0;le<this._materialsRenderTargets.length;++le)this._materialsRenderTargets.data[le].isReadyForRendering()||(ye=!1);for(le=0;le<this.geometries.length;le++)this.geometries[le].delayLoadState===f.Y.DELAYLOADSTATE_LOADING&&(ye=!1);if(this.activeCameras&&this.activeCameras.length>0)for(var yt=0,zt=this.activeCameras;yt<zt.length;yt++)zt[yt].isReady(!0)||(ye=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(ye=!1));for(var $t=0,St=this.particleSystems;$t<St.length;$t++)St[$t].isReady()||(ye=!1);if(this.layers)for(var Ot=0,Et=this.layers;Ot<Et.length;Ot++)Et[Ot].isReady()||(ye=!1);return be.areAllEffectsReady()||(ye=!1),be.currentRenderPassId=ve,ye},U.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},U.prototype.registerBeforeRender=function(N){this.onBeforeRenderObservable.add(N)},U.prototype.unregisterBeforeRender=function(N){this.onBeforeRenderObservable.removeCallback(N)},U.prototype.registerAfterRender=function(N){this.onAfterRenderObservable.add(N)},U.prototype.unregisterAfterRender=function(N){this.onAfterRenderObservable.removeCallback(N)},U.prototype._executeOnceBeforeRender=function(N){var w=this,k=function(){N(),setTimeout(function(){w.unregisterBeforeRender(k)})};this.registerBeforeRender(k)},U.prototype.executeOnceBeforeRender=function(N,w){var k=this;w!==void 0?setTimeout(function(){k._executeOnceBeforeRender(N)},w):this._executeOnceBeforeRender(N)},U.prototype.addPendingData=function(N){this._pendingData.push(N)},U.prototype.removePendingData=function(N){var w=this.isLoading,k=this._pendingData.indexOf(N);k!==-1&&this._pendingData.splice(k,1),w&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)},U.prototype.getWaitingItemsCount=function(){return this._pendingData.length},Object.defineProperty(U.prototype,"isLoading",{get:function(){return this._pendingData.length>0},enumerable:!1,configurable:!0}),U.prototype.executeWhenReady=function(N,w){w===void 0&&(w=!1),this.onReadyObservable.addOnce(N),this._executeWhenReadyTimeoutId===null&&this._checkIsReady(w)},U.prototype.whenReadyAsync=function(N){var w=this;return N===void 0&&(N=!1),new Promise(function(k){w.executeWhenReady(function(){k()},N)})},U.prototype._checkIsReady=function(N){var w=this;return N===void 0&&(N=!1),this._registerTransientComponents(),this.isReady(N)?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):void(this._executeWhenReadyTimeoutId=setTimeout(function(){w.incrementRenderId(),w._checkIsReady(N)},100))},Object.defineProperty(U.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!1,configurable:!0}),U.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=a.j.Now},U.prototype.getViewMatrix=function(){return this._viewMatrix},U.prototype.getProjectionMatrix=function(){return this._projectionMatrix},U.prototype.getTransformMatrix=function(){return this._transformMatrix},U.prototype.setTransformMatrix=function(N,w,k,J){k||J||!this._multiviewSceneUbo||(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),this._viewUpdateFlag===N.updateFlag&&this._projectionUpdateFlag===w.updateFlag||(this._viewUpdateFlag=N.updateFlag,this._projectionUpdateFlag=w.updateFlag,this._viewMatrix=N,this._projectionMatrix=w,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?Q.P.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Q.P.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(k,J):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))},U.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},U.prototype.createSceneUniformBuffer=function(N){var w=new m.D(this._engine,void 0,!1,N??"scene");return w.addUniform("viewProjection",16),w.addUniform("view",16),w.addUniform("projection",16),w.addUniform("vEyePosition",4),w},U.prototype.setSceneUniformBuffer=function(N){this._sceneUbo=N,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1},U.prototype.getUniqueId=function(){return ie.K.UniqueId},U.prototype.addMesh=function(N,w){var k=this;w===void 0&&(w=!1),this._blockEntityCollection||(this.meshes.push(N),N._resyncLightSources(),N.parent||N._addToSceneRootNodes(),this.onNewMeshAddedObservable.notifyObservers(N),w&&N.getChildMeshes().forEach(function(J){k.addMesh(J)}))},U.prototype.removeMesh=function(N,w){var k=this;w===void 0&&(w=!1);var J=this.meshes.indexOf(N);return J!==-1&&(this.meshes.splice(J,1),N.parent||N._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(N),this.onMeshRemovedObservable.notifyObservers(N),w&&N.getChildMeshes().forEach(function(le){k.removeMesh(le)}),J},U.prototype.addTransformNode=function(N){this._blockEntityCollection||N.getScene()===this&&N._indexInSceneTransformNodesArray!==-1||(N._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(N),N.parent||N._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(N))},U.prototype.removeTransformNode=function(N){var w=N._indexInSceneTransformNodesArray;if(w!==-1){if(w!==this.transformNodes.length-1){var k=this.transformNodes[this.transformNodes.length-1];this.transformNodes[w]=k,k._indexInSceneTransformNodesArray=w}N._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),N.parent||N._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(N),w},U.prototype.removeSkeleton=function(N){var w=this.skeletons.indexOf(N);return w!==-1&&(this.skeletons.splice(w,1),this.onSkeletonRemovedObservable.notifyObservers(N),this._executeActiveContainerCleanup(this._activeSkeletons)),w},U.prototype.removeMorphTargetManager=function(N){var w=this.morphTargetManagers.indexOf(N);return w!==-1&&this.morphTargetManagers.splice(w,1),w},U.prototype.removeLight=function(N){var w=this.lights.indexOf(N);if(w!==-1){for(var k=0,J=this.meshes;k<J.length;k++)J[k]._removeLightSource(N,!1);this.lights.splice(w,1),this.sortLightsByPriority(),N.parent||N._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(N),w},U.prototype.removeCamera=function(N){var w=this.cameras.indexOf(N);if(w!==-1&&(this.cameras.splice(w,1),N.parent||N._removeFromSceneRootNodes()),this.activeCameras){var k=this.activeCameras.indexOf(N);k!==-1&&this.activeCameras.splice(k,1)}return this.activeCamera===N&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(N),w},U.prototype.removeParticleSystem=function(N){var w=this.particleSystems.indexOf(N);return w!==-1&&(this.particleSystems.splice(w,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),w},U.prototype.removeAnimation=function(N){var w=this.animations.indexOf(N);return w!==-1&&this.animations.splice(w,1),w},U.prototype.stopAnimation=function(N,w,k){},U.prototype.removeAnimationGroup=function(N){var w=this.animationGroups.indexOf(N);return w!==-1&&this.animationGroups.splice(w,1),w},U.prototype.removeMultiMaterial=function(N){var w=this.multiMaterials.indexOf(N);return w!==-1&&this.multiMaterials.splice(w,1),this.onMultiMaterialRemovedObservable.notifyObservers(N),w},U.prototype.removeMaterial=function(N){var w=N._indexInSceneMaterialArray;if(w!==-1&&w<this.materials.length){if(w!==this.materials.length-1){var k=this.materials[this.materials.length-1];this.materials[w]=k,k._indexInSceneMaterialArray=w}N._indexInSceneMaterialArray=-1,this.materials.pop()}return this.onMaterialRemovedObservable.notifyObservers(N),w},U.prototype.removeActionManager=function(N){var w=this.actionManagers.indexOf(N);return w!==-1&&this.actionManagers.splice(w,1),w},U.prototype.removeTexture=function(N){var w=this.textures.indexOf(N);return w!==-1&&this.textures.splice(w,1),this.onTextureRemovedObservable.notifyObservers(N),w},U.prototype.addLight=function(N){if(!this._blockEntityCollection){this.lights.push(N),this.sortLightsByPriority(),N.parent||N._addToSceneRootNodes();for(var w=0,k=this.meshes;w<k.length;w++){var J=k[w];J.lightSources.indexOf(N)===-1&&(J.lightSources.push(N),J._resyncLightSources())}this.onNewLightAddedObservable.notifyObservers(N)}},U.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(ee.c.CompareLightsPriority)},U.prototype.addCamera=function(N){this._blockEntityCollection||(this.cameras.push(N),this.onNewCameraAddedObservable.notifyObservers(N),N.parent||N._addToSceneRootNodes())},U.prototype.addSkeleton=function(N){this._blockEntityCollection||(this.skeletons.push(N),this.onNewSkeletonAddedObservable.notifyObservers(N))},U.prototype.addParticleSystem=function(N){this._blockEntityCollection||this.particleSystems.push(N)},U.prototype.addAnimation=function(N){this._blockEntityCollection||this.animations.push(N)},U.prototype.addAnimationGroup=function(N){this._blockEntityCollection||this.animationGroups.push(N)},U.prototype.addMultiMaterial=function(N){this._blockEntityCollection||(this.multiMaterials.push(N),this.onNewMultiMaterialAddedObservable.notifyObservers(N))},U.prototype.addMaterial=function(N){this._blockEntityCollection||N.getScene()===this&&N._indexInSceneMaterialArray!==-1||(N._indexInSceneMaterialArray=this.materials.length,this.materials.push(N),this.onNewMaterialAddedObservable.notifyObservers(N))},U.prototype.addMorphTargetManager=function(N){this._blockEntityCollection||this.morphTargetManagers.push(N)},U.prototype.addGeometry=function(N){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[N.uniqueId]=this.geometries.length),this.geometries.push(N))},U.prototype.addActionManager=function(N){this.actionManagers.push(N)},U.prototype.addTexture=function(N){this._blockEntityCollection||(this.textures.push(N),this.onNewTextureAddedObservable.notifyObservers(N))},U.prototype.switchActiveCamera=function(N,w){w===void 0&&(w=!0),this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=N,w&&N.attachControl())},U.prototype.setActiveCameraById=function(N){var w=this.getCameraById(N);return w?(this.activeCamera=w,w):null},U.prototype.setActiveCameraByName=function(N){var w=this.getCameraByName(N);return w?(this.activeCamera=w,w):null},U.prototype.getAnimationGroupByName=function(N){for(var w=0;w<this.animationGroups.length;w++)if(this.animationGroups[w].name===N)return this.animationGroups[w];return null},U.prototype._getMaterial=function(N,w){for(var k=0;k<this.materials.length;k++)if(w(J=this.materials[k]))return J;if(N)for(k=0;k<this.multiMaterials.length;k++){var J;if(w(J=this.multiMaterials[k]))return J}return null},U.prototype.getMaterialByUniqueID=function(N,w){return w===void 0&&(w=!1),this._getMaterial(w,function(k){return k.uniqueId===N})},U.prototype.getMaterialById=function(N,w){return w===void 0&&(w=!1),this._getMaterial(w,function(k){return k.id===N})},U.prototype.getMaterialByName=function(N,w){return w===void 0&&(w=!1),this._getMaterial(w,function(k){return k.name===N})},U.prototype.getLastMaterialById=function(N,w){w===void 0&&(w=!1);for(var k=this.materials.length-1;k>=0;k--)if(this.materials[k].id===N)return this.materials[k];if(w){for(k=this.multiMaterials.length-1;k>=0;k--)if(this.multiMaterials[k].id===N)return this.multiMaterials[k]}return null},U.prototype.getTextureByUniqueId=function(N){for(var w=0;w<this.textures.length;w++)if(this.textures[w].uniqueId===N)return this.textures[w];return null},U.prototype.getTextureByName=function(N){for(var w=0;w<this.textures.length;w++)if(this.textures[w].name===N)return this.textures[w];return null},U.prototype.getCameraById=function(N){for(var w=0;w<this.cameras.length;w++)if(this.cameras[w].id===N)return this.cameras[w];return null},U.prototype.getCameraByUniqueId=function(N){for(var w=0;w<this.cameras.length;w++)if(this.cameras[w].uniqueId===N)return this.cameras[w];return null},U.prototype.getCameraByName=function(N){for(var w=0;w<this.cameras.length;w++)if(this.cameras[w].name===N)return this.cameras[w];return null},U.prototype.getBoneById=function(N){for(var w=0;w<this.skeletons.length;w++)for(var k=this.skeletons[w],J=0;J<k.bones.length;J++)if(k.bones[J].id===N)return k.bones[J];return null},U.prototype.getBoneByName=function(N){for(var w=0;w<this.skeletons.length;w++)for(var k=this.skeletons[w],J=0;J<k.bones.length;J++)if(k.bones[J].name===N)return k.bones[J];return null},U.prototype.getLightByName=function(N){for(var w=0;w<this.lights.length;w++)if(this.lights[w].name===N)return this.lights[w];return null},U.prototype.getLightById=function(N){for(var w=0;w<this.lights.length;w++)if(this.lights[w].id===N)return this.lights[w];return null},U.prototype.getLightByUniqueId=function(N){for(var w=0;w<this.lights.length;w++)if(this.lights[w].uniqueId===N)return this.lights[w];return null},U.prototype.getParticleSystemById=function(N){for(var w=0;w<this.particleSystems.length;w++)if(this.particleSystems[w].id===N)return this.particleSystems[w];return null},U.prototype.getGeometryById=function(N){for(var w=0;w<this.geometries.length;w++)if(this.geometries[w].id===N)return this.geometries[w];return null},U.prototype._getGeometryByUniqueId=function(N){if(this._geometriesByUniqueId){if((w=this._geometriesByUniqueId[N])!==void 0)return this.geometries[w]}else for(var w=0;w<this.geometries.length;w++)if(this.geometries[w].uniqueId===N)return this.geometries[w];return null},U.prototype.pushGeometry=function(N,w){return!(!w&&this._getGeometryByUniqueId(N.uniqueId)||(this.addGeometry(N),this.onNewGeometryAddedObservable.notifyObservers(N),0))},U.prototype.removeGeometry=function(N){var w;if(this._geometriesByUniqueId){if((w=this._geometriesByUniqueId[N.uniqueId])===void 0)return!1}else if((w=this.geometries.indexOf(N))<0)return!1;if(w!==this.geometries.length-1){var k=this.geometries[this.geometries.length-1];k&&(this.geometries[w]=k,this._geometriesByUniqueId&&(this._geometriesByUniqueId[k.uniqueId]=w))}return this._geometriesByUniqueId&&(this._geometriesByUniqueId[N.uniqueId]=void 0),this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(N),!0},U.prototype.getGeometries=function(){return this.geometries},U.prototype.getMeshById=function(N){for(var w=0;w<this.meshes.length;w++)if(this.meshes[w].id===N)return this.meshes[w];return null},U.prototype.getMeshesById=function(N){return this.meshes.filter(function(w){return w.id===N})},U.prototype.getTransformNodeById=function(N){for(var w=0;w<this.transformNodes.length;w++)if(this.transformNodes[w].id===N)return this.transformNodes[w];return null},U.prototype.getTransformNodeByUniqueId=function(N){for(var w=0;w<this.transformNodes.length;w++)if(this.transformNodes[w].uniqueId===N)return this.transformNodes[w];return null},U.prototype.getTransformNodesById=function(N){return this.transformNodes.filter(function(w){return w.id===N})},U.prototype.getMeshByUniqueId=function(N){for(var w=0;w<this.meshes.length;w++)if(this.meshes[w].uniqueId===N)return this.meshes[w];return null},U.prototype.getLastMeshById=function(N){for(var w=this.meshes.length-1;w>=0;w--)if(this.meshes[w].id===N)return this.meshes[w];return null},U.prototype.getLastTransformNodeById=function(N){for(var w=this.transformNodes.length-1;w>=0;w--)if(this.transformNodes[w].id===N)return this.transformNodes[w];return null},U.prototype.getLastEntryById=function(N){var w;for(w=this.meshes.length-1;w>=0;w--)if(this.meshes[w].id===N)return this.meshes[w];for(w=this.transformNodes.length-1;w>=0;w--)if(this.transformNodes[w].id===N)return this.transformNodes[w];for(w=this.cameras.length-1;w>=0;w--)if(this.cameras[w].id===N)return this.cameras[w];for(w=this.lights.length-1;w>=0;w--)if(this.lights[w].id===N)return this.lights[w];return null},U.prototype.getNodeById=function(N){var w=this.getMeshById(N);if(w)return w;var k=this.getTransformNodeById(N);if(k)return k;var J=this.getLightById(N);if(J)return J;var le=this.getCameraById(N);return le||this.getBoneById(N)||null},U.prototype.getNodeByName=function(N){var w=this.getMeshByName(N);if(w)return w;var k=this.getTransformNodeByName(N);if(k)return k;var J=this.getLightByName(N);if(J)return J;var le=this.getCameraByName(N);return le||this.getBoneByName(N)||null},U.prototype.getMeshByName=function(N){for(var w=0;w<this.meshes.length;w++)if(this.meshes[w].name===N)return this.meshes[w];return null},U.prototype.getTransformNodeByName=function(N){for(var w=0;w<this.transformNodes.length;w++)if(this.transformNodes[w].name===N)return this.transformNodes[w];return null},U.prototype.getLastSkeletonById=function(N){for(var w=this.skeletons.length-1;w>=0;w--)if(this.skeletons[w].id===N)return this.skeletons[w];return null},U.prototype.getSkeletonByUniqueId=function(N){for(var w=0;w<this.skeletons.length;w++)if(this.skeletons[w].uniqueId===N)return this.skeletons[w];return null},U.prototype.getSkeletonById=function(N){for(var w=0;w<this.skeletons.length;w++)if(this.skeletons[w].id===N)return this.skeletons[w];return null},U.prototype.getSkeletonByName=function(N){for(var w=0;w<this.skeletons.length;w++)if(this.skeletons[w].name===N)return this.skeletons[w];return null},U.prototype.getMorphTargetManagerById=function(N){for(var w=0;w<this.morphTargetManagers.length;w++)if(this.morphTargetManagers[w].uniqueId===N)return this.morphTargetManagers[w];return null},U.prototype.getMorphTargetById=function(N){for(var w=0;w<this.morphTargetManagers.length;++w)for(var k=this.morphTargetManagers[w],J=0;J<k.numTargets;++J){var le=k.getTarget(J);if(le.id===N)return le}return null},U.prototype.getMorphTargetByName=function(N){for(var w=0;w<this.morphTargetManagers.length;++w)for(var k=this.morphTargetManagers[w],J=0;J<k.numTargets;++J){var le=k.getTarget(J);if(le.name===N)return le}return null},U.prototype.getPostProcessByName=function(N){for(var w=0;w<this.postProcesses.length;++w){var k=this.postProcesses[w];if(k.name===N)return k}return null},U.prototype.isActiveMesh=function(N){return this._activeMeshes.indexOf(N)!==-1},Object.defineProperty(U.prototype,"uid",{get:function(){return this._uid||(this._uid=o.S0.RandomId()),this._uid},enumerable:!1,configurable:!0}),U.prototype.addExternalData=function(N,w){return this._externalData||(this._externalData=new c.w),this._externalData.add(N,w)},U.prototype.getExternalData=function(N){return this._externalData?this._externalData.get(N):null},U.prototype.getOrAddExternalDataWithFactory=function(N,w){return this._externalData||(this._externalData=new c.w),this._externalData.getOrAddWithFactory(N,w)},U.prototype.removeExternalData=function(N){return this._externalData.remove(N)},U.prototype._evaluateSubMesh=function(N,w,k,J){if(J||N.isInFrustum(this._frustumPlanes)){for(var le=0,be=this._evaluateSubMeshStage;le<be.length;le++)be[le].action(w,N);var ve=N.getMaterial();ve!=null&&(ve.hasRenderTargetTextures&&ve.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(ve)===-1&&(this._processedMaterials.push(ve),this._materialsRenderTargets.concatWithNoDuplicate(ve.getRenderTargetTextures())),this._renderingManager.dispatch(N,w,ve))}},U.prototype.freeProcessedMaterials=function(){this._processedMaterials.dispose()},Object.defineProperty(U.prototype,"blockfreeActiveMeshesAndRenderingGroups",{get:function(){return this._preventFreeActiveMeshesAndRenderingGroups},set:function(N){this._preventFreeActiveMeshesAndRenderingGroups!==N&&(N&&(this.freeActiveMeshes(),this.freeRenderingGroups()),this._preventFreeActiveMeshesAndRenderingGroups=N)},enumerable:!1,configurable:!0}),U.prototype.freeActiveMeshes=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras))for(var N=0;N<this.activeCameras.length;N++){var w=this.activeCameras[N];w&&w._activeMeshes&&w._activeMeshes.dispose()}},U.prototype.freeRenderingGroups=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures))for(var N=0;N<this.textures.length;N++){var w=this.textures[N];w&&w.renderList&&w.freeRenderingGroups()}},U.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},U.prototype.freezeActiveMeshes=function(N,w,k,J,le){var be=this;return N===void 0&&(N=!1),J===void 0&&(J=!0),le===void 0&&(le=!1),this.executeWhenReady(function(){if(be.activeCamera){if(be._frustumPlanes||be.updateTransformMatrix(),be._evaluateActiveMeshes(),be._activeMeshesFrozen=!0,be._activeMeshesFrozenButKeepClipping=le,be._skipEvaluateActiveMeshesCompletely=N,J)for(var ve=0;ve<be._activeMeshes.length;ve++)be._activeMeshes.data[ve]._freeze();w&&w()}else k&&k("No active camera found")}),this},U.prototype.unfreezeActiveMeshes=function(){for(var N=0;N<this.meshes.length;N++){var w=this.meshes[N];w._internalAbstractMeshDataInfo&&(w._internalAbstractMeshDataInfo._isActive=!1)}for(N=0;N<this._activeMeshes.length;N++)this._activeMeshes.data[N]._unFreeze();return this._activeMeshesFrozen=!1,this},U.prototype._executeActiveContainerCleanup=function(N){(!this._engine.snapshotRendering||this._engine.snapshotRenderingMode!==f.Y.SNAPSHOTRENDERING_FAST)&&this._activeMeshesFrozen&&this._activeMeshes.length||this.onBeforeRenderObservable.addOnce(function(){return N.dispose()})},U.prototype._evaluateActiveMeshes=function(){var N;if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===f.Y.SNAPSHOTRENDERING_FAST)this._activeMeshes.length>0&&((N=this.activeCamera)===null||N===void 0||N._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset());else if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely)for(var w=this._activeMeshes.length,k=0;k<w;k++)(Me=this._activeMeshes.data[k]).computeWorldMatrix();if(this._activeParticleSystems){var J=this._activeParticleSystems.length;for(k=0;k<J;k++)this._activeParticleSystems.data[k].animate()}this._renderingManager.resetSprites()}else if(this.activeCamera){this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._materialsRenderTargets.reset();for(var le=0,be=this._beforeEvaluateActiveMeshStage;le<be.length;le++)be[le].action();var ve=this.getActiveMeshCandidates(),ye=ve.length;for(k=0;k<ye;k++){var Me;if((Me=ve.data[k])._internalAbstractMeshDataInfo._currentLODIsUpToDate=!1,!Me.isBlocked&&(this._totalVertices.addCount(Me.getTotalVertices(),!1),Me.isReady()&&Me.isEnabled()&&!Me.scaling.hasAZeroComponent)){Me.computeWorldMatrix(),Me.actionManager&&Me.actionManager.hasSpecificTriggers2(f.Y.ACTION_OnIntersectionEnterTrigger,f.Y.ACTION_OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNoDuplicate(Me);var we=this.customLODSelector?this.customLODSelector(Me,this.activeCamera):Me.getLOD(this.activeCamera);if(Me._internalAbstractMeshDataInfo._currentLOD=we,Me._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,we!=null&&(we!==Me&&we.billboardMode!==0&&we.computeWorldMatrix(),Me._preActivate(),Me.isVisible&&Me.visibility>0&&Me.layerMask&this.activeCamera.layerMask&&(this._skipFrustumClipping||Me.alwaysSelectAsActiveMesh||Me.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(Me),this.activeCamera._activeMeshes.push(Me),we!==Me&&we._activate(this._renderId,!1);for(var He=0,Ke=this._preActiveMeshStage;He<Ke.length;He++)Ke[He].action(Me);Me._activate(this._renderId,!1)&&(Me.isAnInstance?Me._internalAbstractMeshDataInfo._actAsRegularMesh&&(we=Me):we._internalAbstractMeshDataInfo._onlyForInstances=!1,we._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(Me,we)),Me._postActivate()}}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var Qe=0;Qe<this.particleSystems.length;Qe++){var Je=this.particleSystems[Qe];if(Je.isStarted()&&Je.emitter){var ht=Je.emitter;ht.position&&!ht.isEnabled()||(this._activeParticleSystems.push(Je),Je.animate(),this._renderingManager.dispatchParticles(Je))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},U.prototype._activeMesh=function(N,w){this._skeletonsEnabled&&w.skeleton!==null&&w.skeleton!==void 0&&(this._activeSkeletons.pushNoDuplicate(w.skeleton)&&(w.skeleton.prepare(),this._activeBones.addCount(w.skeleton.bones.length,!1)),w.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(w));var k=N.hasInstances||N.isAnInstance||this.dispatchAllSubMeshesOfActiveMeshes||this._skipFrustumClipping||w.alwaysSelectAsActiveMesh;if(w&&w.subMeshes&&w.subMeshes.length>0){var J=this.getActiveSubMeshCandidates(w),le=J.length;k=k||le===1;for(var be=0;be<le;be++){var ve=J.data[be];this._evaluateSubMesh(ve,w,N,k)}}},U.prototype.updateTransformMatrix=function(N){var w=this.activeCamera;if(w)if(w._renderingMultiview){var k=w._rigCameras[0],J=w._rigCameras[1];this.setTransformMatrix(k.getViewMatrix(),k.getProjectionMatrix(N),J.getViewMatrix(),J.getProjectionMatrix(N))}else this.setTransformMatrix(w.getViewMatrix(),w.getProjectionMatrix(N))},U.prototype._bindFrameBuffer=function(N,w){w===void 0&&(w=!0),N&&N._multiviewTexture?N._multiviewTexture._bindFrameBuffer():N&&N.outputRenderTarget?N.outputRenderTarget._bindFrameBuffer():this._engine._currentFrameBufferIsDefaultFrameBuffer()||this._engine.restoreDefaultFramebuffer(),w&&this._clearFrameBuffer(N)},U.prototype._clearFrameBuffer=function(N){if(!(N&&N._multiviewTexture))if(N&&N.outputRenderTarget&&!N._renderingMultiview){var w=N.outputRenderTarget;w.onClearObservable.hasObservers()?w.onClearObservable.notifyObservers(this._engine):w.skipInitialClear||N.isRightCamera||(this.autoClear&&this._engine.clear(w.clearColor||this.clearColor,!w._cleared,!0,!0),w._cleared=!0)}else this._defaultFrameBufferCleared?this._engine.clear(null,!1,!0,!0):(this._defaultFrameBufferCleared=!0,this._clear())},U.prototype._renderForCamera=function(N,w,k){var J,le,be;if(k===void 0&&(k=!0),!N||!N._skipRendering){var ve=this._engine;if(this._activeCamera=N,!this.activeCamera)throw new Error("Active camera not set");if(ve.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,!this.prePass&&k){var ye=!0;N._renderingMultiview&&N.outputRenderTarget&&(ye=N.outputRenderTarget.skipInitialClear,this.autoClear&&(this._defaultFrameBufferCleared=!1,N.outputRenderTarget.skipInitialClear=!1)),this._bindFrameBuffer(this._activeCamera),N._renderingMultiview&&N.outputRenderTarget&&(N.outputRenderTarget.skipInitialClear=ye)}this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var Me=0;Me<this._softwareSkinnedMeshes.length;Me++){var we=this._softwareSkinnedMeshes.data[Me];we.applySkeleton(we.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets),N.customRenderTargets&&N.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(N.customRenderTargets),w&&w.customRenderTargets&&w.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(w.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(var He=0,Ke=this._gatherActiveCameraRenderTargetsStage;He<Ke.length;He++)Ke[He].action(this._renderTargets);var Qe=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){o.S0.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var Je=0;Je<this._renderTargets.length;Je++){var ht=this._renderTargets.data[Je];if(ht._shouldRender()){this._renderId++;var mt=ht.activeCamera&&ht.activeCamera!==this.activeCamera;ht.render(mt,this.dumpNextRenderTargets),Qe=!0}}o.S0.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(var yt=0,zt=this._cameraDrawRenderTargetStage;yt<zt.length;yt++)Qe=zt[yt].action(this.activeCamera)||Qe;this._intermediateRendering=!1}this._engine.currentRenderPassId=(be=(le=(J=N.outputRenderTarget)===null||J===void 0?void 0:J.renderPassId)!==null&&le!==void 0?le:N.renderPassId)!==null&&be!==void 0?be:f.Y.RENDERPASS_MAIN,Qe&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),!this.postProcessManager||N._multiviewTexture||this.prePass||this.postProcessManager._prepareFrame();for(var $t=0,St=this._beforeCameraDrawStage;$t<St.length;$t++)St[$t].action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this),ve.snapshotRendering&&ve.snapshotRenderingMode===f.Y.SNAPSHOTRENDERING_FAST&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(var Ot=0,Et=this._afterCameraDrawStage;Ot<Et.length;Ot++)Et[Ot].action(this.activeCamera);if(this.postProcessManager&&!N._multiviewTexture){var Vt=N.outputRenderTarget?N.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(N.isIntermediate,Vt)}for(var ln=0,Yt=this._afterCameraPostProcessStage;ln<Yt.length;ln++)Yt[ln].action(this.activeCamera);this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}},U.prototype._processSubCameras=function(N,w){if(w===void 0&&(w=!0),N.cameraRigMode===f.Y.RIG_MODE_NONE||N._renderingMultiview)return N._renderingMultiview&&!this._multiviewSceneUbo&&this._createMultiviewUbo(),this._renderForCamera(N,void 0,w),void this.onAfterRenderCameraObservable.notifyObservers(N);if(N._useMultiviewToSingleView)this._renderMultiviewToSingleView(N);else{this.onBeforeCameraRenderObservable.notifyObservers(N);for(var k=0;k<N._rigCameras.length;k++)this._renderForCamera(N._rigCameras[k],N)}this._activeCamera=N,this.updateTransformMatrix(),this.onAfterRenderCameraObservable.notifyObservers(N)},U.prototype._checkIntersections=function(){for(var N=0;N<this._meshesForIntersections.length;N++){var w=this._meshesForIntersections.data[N];if(w.actionManager)for(var k=function(le){var be=w.actionManager.actions[le];if(be.trigger===f.Y.ACTION_OnIntersectionEnterTrigger||be.trigger===f.Y.ACTION_OnIntersectionExitTrigger){var ve=be.getTriggerParameter(),ye=ve.mesh?ve.mesh:ve,Me=ye.intersectsMesh(w,ve.usePreciseIntersection),we=w._intersectionsInProgress.indexOf(ye);Me&&we===-1?be.trigger===f.Y.ACTION_OnIntersectionEnterTrigger?(be._executeCurrent(b.X.CreateNew(w,void 0,ye)),w._intersectionsInProgress.push(ye)):be.trigger===f.Y.ACTION_OnIntersectionExitTrigger&&w._intersectionsInProgress.push(ye):!Me&&we>-1&&(be.trigger===f.Y.ACTION_OnIntersectionExitTrigger&&be._executeCurrent(b.X.CreateNew(w,void 0,ye)),w.actionManager.hasSpecificTrigger(f.Y.ACTION_OnIntersectionExitTrigger,function(He){var Ke=He.mesh?He.mesh:He;return ye===Ke})&&be.trigger!==f.Y.ACTION_OnIntersectionExitTrigger||w._intersectionsInProgress.splice(we,1))}},J=0;w.actionManager&&J<w.actionManager.actions.length;J++)k(J)}},U.prototype._advancePhysicsEngineStep=function(N){},U.prototype._animate=function(N){},U.prototype.animate=function(){if(this._engine.isDeterministicLockStep()){var N=Math.max(U.MinDeltaTime,Math.min(this._engine.getDeltaTime(),U.MaxDeltaTime))+this._timeAccumulator,w=this._engine.getTimeStep(),k=1e3/w/1e3,J=0,le=this._engine.getLockstepMaxSteps(),be=Math.floor(N/w);for(be=Math.min(be,le);N>0&&J<be;)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=w*k,this._animate(w),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(w),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,J++,N-=w;this._timeAccumulator=N<0?0:N}else N=this.useConstantAnimationDeltaTime?16:Math.max(U.MinDeltaTime,Math.min(this._engine.getDeltaTime(),U.MaxDeltaTime)),this._animationRatio=.06*N,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(N)},U.prototype._clear=function(){(this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil)},U.prototype._checkCameraRenderTarget=function(N){var w;if(N?.outputRenderTarget&&!N?.isRigCamera&&(N.outputRenderTarget._cleared=!1),(w=N?.rigCameras)===null||w===void 0?void 0:w.length)for(var k=0;k<N.rigCameras.length;++k){var J=N.rigCameras[k].outputRenderTarget;J&&(J._cleared=!1)}},U.prototype.resetDrawCache=function(N){if(this.meshes)for(var w=0,k=this.meshes;w<k.length;w++)k[w].resetDrawCache(N)},U.prototype.render=function(N,w){var k,J,le;if(N===void 0&&(N=!0),w===void 0&&(w=!1),!this.isDisposed){this.onReadyObservable.hasObservers()&&this._executeWhenReadyTimeoutId===null&&this._checkIsReady(),this._frameId++,this._defaultFrameBufferCleared=!1,this._checkCameraRenderTarget(this.activeCamera),!((k=this.activeCameras)===null||k===void 0)&&k.length&&this.activeCameras.forEach(this._checkCameraRenderTarget),this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(f.Y.ACTION_OnEveryFrameTrigger),w||this.animate();for(var be=0,ve=this._beforeCameraUpdateStage;be<ve.length;be++)ve[be].action();if(N){if(this.activeCameras&&this.activeCameras.length>0)for(var ye=0;ye<this.activeCameras.length;ye++){var Me=this.activeCameras[ye];if(Me.update(),Me.cameraRigMode!==f.Y.RIG_MODE_NONE)for(var we=0;we<Me._rigCameras.length;we++)Me._rigCameras[we].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==f.Y.RIG_MODE_NONE))for(we=0;we<this.activeCamera._rigCameras.length;we++)this.activeCamera._rigCameras[we].update()}this.onBeforeRenderObservable.notifyObservers(this);var He=this.getEngine();this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var Ke=!((J=this.activeCameras)===null||J===void 0)&&J.length?this.activeCameras[0]:this.activeCamera;if(this.renderTargetsEnabled){o.S0.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var Qe=0;Qe<this.customRenderTargets.length;Qe++){var Je=this.customRenderTargets[Qe];if(Je._shouldRender()){if(this._renderId++,this.activeCamera=Je.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");He.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),Je.render(Ke!==this.activeCamera,this.dumpNextRenderTargets)}}o.S0.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=(le=Ke?.renderPassId)!==null&&le!==void 0?le:f.Y.RENDERPASS_MAIN,this.activeCamera=Ke,this._activeCamera&&this._activeCamera.cameraRigMode!==f.Y.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var ht=0,mt=this._beforeClearStage;ht<mt.length;ht++)mt[ht].action();this._clearFrameBuffer(this.activeCamera);for(var yt=0,zt=this._gatherRenderTargetsStage;yt<zt.length;yt++)zt[yt].action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(ye=0;ye<this.activeCameras.length;ye++)this._processSubCameras(this.activeCameras[ye],ye>0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}this._checkIntersections();for(var $t=0,St=this._afterRenderStage;$t<St.length;$t++)St[$t].action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(we=0;we<this._toBeDisposed.length;we++){var Ot=this._toBeDisposed[we];Ot&&Ot.dispose()}this._toBeDisposed.length=0}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0),this._engine.restoreDefaultFramebuffer()}},U.prototype.freezeMaterials=function(){for(var N=0;N<this.materials.length;N++)this.materials[N].freeze()},U.prototype.unfreezeMaterials=function(){for(var N=0;N<this.materials.length;N++)this.materials[N].unfreeze()},U.prototype.dispose=function(){if(!this.isDisposed){this.beforeRender=null,this.afterRender=null,this.metadata=null,this.skeletons.length=0,this.morphTargetManagers.length=0,this._transientComponents.length=0,this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._preActiveMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderTargetDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderTargetDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear(),this.importedMeshesFiles=[],this.stopAllAnimations&&(this._activeAnimatables.forEach(function(be){be.onAnimationEndObservable.clear(),be.onAnimationEnd=null}),this.stopAllAnimations()),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this.activeCameras=null,this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._materialsRenderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.length=0;for(var N=0,w=this._activeRequests.slice();N<w.length;N++)w[N].abort();this._activeRequests.length=0;try{this.onDisposeObservable.notifyObservers(this)}catch(be){fe.V.Error("An error occurred while calling onDisposeObservable!",be)}if(this.detachControl(),this._engine.getInputElement())for(var k=0;k<this.cameras.length;k++)this.cameras[k].detachControl();this._disposeList(this.animationGroups),this._disposeList(this.lights),this._disposeList(this.meshes,function(be){return be.dispose(!0)}),this._disposeList(this.transformNodes,function(be){return be.dispose(!0)});var J=this.cameras;this._disposeList(J),this._defaultMaterial&&this._defaultMaterial.dispose(),this._disposeList(this.multiMaterials),this._disposeList(this.materials),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);var le=this._engine.scenes.indexOf(this);le>-1&&this._engine.scenes.splice(le,1),S.q._LastCreatedScene===this&&(this._engine.scenes.length>0?S.q._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:S.q._LastCreatedScene=null),(le=this._engine._virtualScenes.indexOf(this))>-1&&this._engine._virtualScenes.splice(le,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this._isDisposed=!0}},U.prototype._disposeList=function(N,w){w=w??function(le){return le.dispose()};for(var k=0,J=N.slice(0);k<J.length;k++)w(J[k]);N.length=0},Object.defineProperty(U.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),U.prototype.clearCachedVertexData=function(){for(var N=0;N<this.meshes.length;N++){var w=this.meshes[N].geometry;w&&w.clearCachedData()}},U.prototype.cleanCachedTextureBuffer=function(){for(var N=0,w=this.textures;N<w.length;N++){var k=w[N];k._buffer&&(k._buffer=null)}},U.prototype.getWorldExtends=function(N){var w=new d.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),k=new d.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return N=N||function(){return!0},this.meshes.filter(N).forEach(function(J){if(J.computeWorldMatrix(!0),J.subMeshes&&J.subMeshes.length!==0&&!J.infiniteDistance){var le=J.getBoundingInfo(),be=le.boundingBox.minimumWorld,ve=le.boundingBox.maximumWorld;d.Pq.CheckExtends(be,w,k),d.Pq.CheckExtends(ve,w,k)}}),{min:w,max:k}},U.prototype.createPickingRay=function(N,w,k,J,le){throw(0,y.n)("Ray")},U.prototype.createPickingRayToRef=function(N,w,k,J,le,be,ve){throw(0,y.n)("Ray")},U.prototype.createPickingRayInCameraSpace=function(N,w,k){throw(0,y.n)("Ray")},U.prototype.createPickingRayInCameraSpaceToRef=function(N,w,k,J){throw(0,y.n)("Ray")},Object.defineProperty(U.prototype,"_pickingAvailable",{get:function(){return!1},enumerable:!1,configurable:!0}),U.prototype.pick=function(N,w,k,J,le,be){var ve=(0,y.n)("Ray",!0);return ve&&fe.V.Warn(ve),new v.G},U.prototype.pickWithBoundingInfo=function(N,w,k,J,le){var be=(0,y.n)("Ray",!0);return be&&fe.V.Warn(be),new v.G},U.prototype.pickWithRay=function(N,w,k,J){throw(0,y.n)("Ray")},U.prototype.multiPick=function(N,w,k,J,le){throw(0,y.n)("Ray")},U.prototype.multiPickWithRay=function(N,w,k){throw(0,y.n)("Ray")},U.prototype.setPointerOverMesh=function(N,w,k){this._inputManager.setPointerOverMesh(N,w,k)},U.prototype.getPointerOverMesh=function(){return this._inputManager.getPointerOverMesh()},U.prototype._rebuildGeometries=function(){for(var N=0,w=this.geometries;N<w.length;N++)w[N]._rebuild();for(var k=0,J=this.meshes;k<J.length;k++)J[k]._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(var le=0,be=this._components;le<be.length;le++)be[le].rebuild();for(var ve=0,ye=this.particleSystems;ve<ye.length;ve++)ye[ve].rebuild();if(this.spriteManagers)for(var Me=0,we=this.spriteManagers;Me<we.length;Me++)we[Me].rebuild()},U.prototype._rebuildTextures=function(){for(var N=0,w=this.textures;N<w.length;N++)w[N]._rebuild(!0);this.markAllMaterialsAsDirty(f.Y.MATERIAL_TextureDirtyFlag)},U.prototype._getByTags=function(N,w,k){if(w===void 0)return N;var J=[];for(var le in N){var be=N[le];u.Y&&u.Y.MatchesQuery(be,w)&&(!k||k(be))&&J.push(be)}return J},U.prototype.getMeshesByTags=function(N,w){return this._getByTags(this.meshes,N,w)},U.prototype.getCamerasByTags=function(N,w){return this._getByTags(this.cameras,N,w)},U.prototype.getLightsByTags=function(N,w){return this._getByTags(this.lights,N,w)},U.prototype.getMaterialByTags=function(N,w){return this._getByTags(this.materials,N,w).concat(this._getByTags(this.multiMaterials,N,w))},U.prototype.getTransformNodesByTags=function(N,w){return this._getByTags(this.transformNodes,N,w)},U.prototype.setRenderingOrder=function(N,w,k,J){w===void 0&&(w=null),k===void 0&&(k=null),J===void 0&&(J=null),this._renderingManager.setRenderingOrder(N,w,k,J)},U.prototype.setRenderingAutoClearDepthStencil=function(N,w,k,J){k===void 0&&(k=!0),J===void 0&&(J=!0),this._renderingManager.setRenderingAutoClearDepthStencil(N,w,k,J)},U.prototype.getAutoClearDepthStencilSetup=function(N){return this._renderingManager.getAutoClearDepthStencilSetup(N)},U.prototype._forceBlockMaterialDirtyMechanism=function(N){this._blockMaterialDirtyMechanism=N},Object.defineProperty(U.prototype,"blockMaterialDirtyMechanism",{get:function(){return this._blockMaterialDirtyMechanism},set:function(N){this._blockMaterialDirtyMechanism!==N&&(this._blockMaterialDirtyMechanism=N,N||this.markAllMaterialsAsDirty(f.Y.MATERIAL_AllDirtyFlag))},enumerable:!1,configurable:!0}),U.prototype.markAllMaterialsAsDirty=function(N,w){if(!this._blockMaterialDirtyMechanism)for(var k=0,J=this.materials;k<J.length;k++){var le=J[k];w&&!w(le)||le.markAsDirty(N)}},U.prototype._loadFile=function(N,w,k,J,le,be,ve){var ye=this,Me=(0,q.zU)(N,w,k,J?this.offlineProvider:void 0,le,be,ve);return this._activeRequests.push(Me),Me.onCompleteObservable.add(function(we){ye._activeRequests.splice(ye._activeRequests.indexOf(we),1)}),Me},U.prototype._loadFileAsync=function(N,w,k,J,le){var be=this;return new Promise(function(ve,ye){be._loadFile(N,function(Me){ve(Me)},w,k,J,function(Me,we){ye(we)},le)})},U.prototype._requestFile=function(N,w,k,J,le,be,ve){var ye=this,Me=(0,q.sh)(N,w,k,J?this.offlineProvider:void 0,le,be,ve);return this._activeRequests.push(Me),Me.onCompleteObservable.add(function(we){ye._activeRequests.splice(ye._activeRequests.indexOf(we),1)}),Me},U.prototype._requestFileAsync=function(N,w,k,J,le){var be=this;return new Promise(function(ve,ye){be._requestFile(N,function(Me){ve(Me)},w,k,J,function(Me){ye(Me)},le)})},U.prototype._readFile=function(N,w,k,J,le){var be=this,ve=(0,q.NJ)(N,w,k,J,le);return this._activeRequests.push(ve),ve.onCompleteObservable.add(function(ye){be._activeRequests.splice(be._activeRequests.indexOf(ye),1)}),ve},U.prototype._readFileAsync=function(N,w,k){var J=this;return new Promise(function(le,be){J._readFile(N,function(ve){le(ve)},w,k,function(ve){be(ve)})})},U.prototype.getPerfCollector=function(){throw(0,y.n)("performanceViewerSceneExtension")},U.prototype.setActiveCameraByID=function(N){return this.setActiveCameraById(N)},U.prototype.getMaterialByID=function(N){return this.getMaterialById(N)},U.prototype.getLastMaterialByID=function(N){return this.getLastMaterialById(N)},U.prototype.getTextureByUniqueID=function(N){return this.getTextureByUniqueId(N)},U.prototype.getCameraByID=function(N){return this.getCameraById(N)},U.prototype.getCameraByUniqueID=function(N){return this.getCameraByUniqueId(N)},U.prototype.getBoneByID=function(N){return this.getBoneById(N)},U.prototype.getLightByID=function(N){return this.getLightById(N)},U.prototype.getLightByUniqueID=function(N){return this.getLightByUniqueId(N)},U.prototype.getParticleSystemByID=function(N){return this.getParticleSystemById(N)},U.prototype.getGeometryByID=function(N){return this.getGeometryById(N)},U.prototype.getMeshByID=function(N){return this.getMeshById(N)},U.prototype.getMeshByUniqueID=function(N){return this.getMeshByUniqueId(N)},U.prototype.getLastMeshByID=function(N){return this.getLastMeshById(N)},U.prototype.getMeshesByID=function(N){return this.getMeshesById(N)},U.prototype.getTransformNodeByID=function(N){return this.getTransformNodeById(N)},U.prototype.getTransformNodeByUniqueID=function(N){return this.getTransformNodeByUniqueId(N)},U.prototype.getTransformNodesByID=function(N){return this.getTransformNodesById(N)},U.prototype.getNodeByID=function(N){return this.getNodeById(N)},U.prototype.getLastEntryByID=function(N){return this.getLastEntryById(N)},U.prototype.getLastSkeletonByID=function(N){return this.getLastSkeletonById(N)},U.FOGMODE_NONE=f.Y.FOGMODE_NONE,U.FOGMODE_EXP=f.Y.FOGMODE_EXP,U.FOGMODE_EXP2=f.Y.FOGMODE_EXP2,U.FOGMODE_LINEAR=f.Y.FOGMODE_LINEAR,U.MinDeltaTime=1,U.MaxDeltaTime=1e3,U}(h.d);(0,de.Y5)("BABYLON.Scene",Te)},52366:(r,t,e)=>{e.d(t,{B:()=>o,v:()=>i});var n=e(78322),i=function(){function a(){}return a.NAME_EFFECTLAYER="EffectLayer",a.NAME_LAYER="Layer",a.NAME_LENSFLARESYSTEM="LensFlareSystem",a.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",a.NAME_PARTICLESYSTEM="ParticleSystem",a.NAME_GAMEPAD="Gamepad",a.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",a.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",a.NAME_PREPASSRENDERER="PrePassRenderer",a.NAME_DEPTHRENDERER="DepthRenderer",a.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer",a.NAME_IBLSHADOWSRENDERER="IblShadowsRenderer",a.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",a.NAME_SPRITE="Sprite",a.NAME_SUBSURFACE="SubSurface",a.NAME_OUTLINERENDERER="Outline",a.NAME_PROCEDURALTEXTURE="ProceduralTexture",a.NAME_SHADOWGENERATOR="ShadowGenerator",a.NAME_OCTREE="Octree",a.NAME_PHYSICSENGINE="PhysicsEngine",a.NAME_AUDIO="Audio",a.NAME_FLUIDRENDERER="FluidRenderer",a.STEP_ISREADYFORMESH_EFFECTLAYER=0,a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0,a.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,a.STEP_BEFORECAMERADRAW_PREPASS=0,a.STEP_BEFORECAMERADRAW_EFFECTLAYER=1,a.STEP_BEFORECAMERADRAW_LAYER=2,a.STEP_BEFORERENDERTARGETDRAW_PREPASS=0,a.STEP_BEFORERENDERTARGETDRAW_LAYER=1,a.STEP_BEFORERENDERINGMESH_PREPASS=0,a.STEP_BEFORERENDERINGMESH_OUTLINE=1,a.STEP_AFTERRENDERINGMESH_PREPASS=0,a.STEP_AFTERRENDERINGMESH_OUTLINE=1,a.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,a.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,a.STEP_BEFORECAMERAUPDATE_GAMEPAD=1,a.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,a.STEP_BEFORECLEAR_PREPASS=1,a.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0,a.STEP_AFTERRENDERTARGETDRAW_PREPASS=0,a.STEP_AFTERRENDERTARGETDRAW_LAYER=1,a.STEP_AFTERCAMERADRAW_PREPASS=0,a.STEP_AFTERCAMERADRAW_EFFECTLAYER=1,a.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2,a.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3,a.STEP_AFTERCAMERADRAW_LAYER=4,a.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5,a.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0,a.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0,a.STEP_AFTERRENDER_AUDIO=0,a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0,a.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,a.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2,a.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,a.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,a.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1,a.STEP_POINTERMOVE_SPRITE=0,a.STEP_POINTERDOWN_SPRITE=0,a.STEP_POINTERUP_SPRITE=0,a}(),o=function(a){function s(l){return a.apply(this,l)||this}return(0,n.C6)(s,a),s.Create=function(){return Object.create(s.prototype)},s.prototype.registerStep=function(l,c,u){var d=0;for(Number.MAX_VALUE;d<this.length&&!(l<this[d].index);d++);this.splice(d,0,{index:l,component:c,action:u.bind(c)})},s.prototype.clear=function(){this.length=0},s}(Array)},78322:(r,t,e)=>{e.d(t,{C6:()=>i,Cg:()=>a,Cl:()=>o,YH:()=>l,fX:()=>c,sH:()=>s});var n=function(u,d){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,p){h.__proto__=p}||function(h,p){for(var m in p)Object.prototype.hasOwnProperty.call(p,m)&&(h[m]=p[m])},n(u,d)};function i(u,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");function h(){this.constructor=u}n(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)}var o=function(){return o=Object.assign||function(u){for(var d,h=1,p=arguments.length;h<p;h++)for(var m in d=arguments[h])Object.prototype.hasOwnProperty.call(d,m)&&(u[m]=d[m]);return u},o.apply(this,arguments)};function a(u,d,h,p){var m,v=arguments.length,b=v<3?d:p===null?p=Object.getOwnPropertyDescriptor(d,h):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(u,d,h,p);else for(var E=u.length-1;E>=0;E--)(m=u[E])&&(b=(v<3?m(b):v>3?m(d,h,b):m(d,h))||b);return v>3&&b&&Object.defineProperty(d,h,b),b}function s(u,d,h,p){return new(h||(h=Promise))(function(m,v){function b(T){try{C(p.next(T))}catch(f){v(f)}}function E(T){try{C(p.throw(T))}catch(f){v(f)}}function C(T){var f;T.done?m(T.value):(f=T.value,f instanceof h?f:new h(function(g){g(f)})).then(b,E)}C((p=p.apply(u,d||[])).next())})}function l(u,d){var h,p,m,v={label:0,sent:function(){if(1&m[0])throw m[1];return m[1]},trys:[],ops:[]},b=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return b.next=E(0),b.throw=E(1),b.return=E(2),typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function E(C){return function(T){return function(f){if(h)throw new TypeError("Generator is already executing.");for(;b&&(b=0,f[0]&&(v=0)),v;)try{if(h=1,p&&(m=2&f[0]?p.return:f[0]?p.throw||((m=p.return)&&m.call(p),0):p.next)&&!(m=m.call(p,f[1])).done)return m;switch(p=0,m&&(f=[2&f[0],m.value]),f[0]){case 0:case 1:m=f;break;case 4:return v.label++,{value:f[1],done:!1};case 5:v.label++,p=f[1],f=[0];continue;case 7:f=v.ops.pop(),v.trys.pop();continue;default:if(!((m=(m=v.trys).length>0&&m[m.length-1])||f[0]!==6&&f[0]!==2)){v=0;continue}if(f[0]===3&&(!m||f[1]>m[0]&&f[1]<m[3])){v.label=f[1];break}if(f[0]===6&&v.label<m[1]){v.label=m[1],m=f;break}if(m&&v.label<m[2]){v.label=m[2],v.ops.push(f);break}m[2]&&v.ops.pop(),v.trys.pop();continue}f=d.call(u,v)}catch(g){f=[6,g],p=0}finally{h=m=0}if(5&f[0])throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}([C,T])}}}function c(u,d,h){if(h||arguments.length===2)for(var p,m=0,v=d.length;m<v;m++)!p&&m in d||(p||(p=Array.prototype.slice.call(d,0,m)),p[m]=d[m]);return u.concat(p||Array.prototype.slice.call(d))}typeof SuppressedError=="function"&&SuppressedError}},Zn={};function L(r){var t=Zn[r];if(t!==void 0)return t.exports;var e=Zn[r]={exports:{}};return Cn[r](e,e.exports,L),e.exports}L.d=(r,t)=>{for(var e in t)L.o(t,e)&&!L.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})},L.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),L.o=(r,t)=>Object.prototype.hasOwnProperty.call(r,t),L.r=r=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var Hn={};L.d(Hn,{default:()=>cL});var $i={};L.r($i),L.d($i,{AxesViewer:()=>ia,BoneAxesViewer:()=>Au,DebugLayer:()=>Cu,DebugLayerTab:()=>Hs,DirectionalLightFrustumViewer:()=>dg,PhysicsViewer:()=>Wu,RayHelper:()=>ug,SkeletonViewer:()=>Hu});var dr={};L.r(dr),L.d(dr,{AbstractActionManager:()=>Ne.G,AbstractAssetTask:()=>Rr,AbstractEngine:()=>Be.$,AbstractMesh:()=>cn,AbstractScene:()=>nt.d,AcquireNativeObjectAsync:()=>Eg,Action:()=>me,ActionEvent:()=>Se.X,ActionManager:()=>it,AddBlock:()=>dy,AddressMode:()=>od,AdvancedTimer:()=>dv,AlignBlock:()=>ib,AlphaState:()=>zO.i,AmmoJSPlugin:()=>gh,AnaglyphArcRotateCamera:()=>Tm,AnaglyphFreeCamera:()=>Sm,AnaglyphGamepadCamera:()=>Em,AnaglyphPostProcess:()=>au,AnaglyphUniversalCamera:()=>xm,Analyser:()=>BS,AndOrNotEvaluator:()=>HO.Z,Angle:()=>Ge.uM,Animatable:()=>bt,AnimatedInputBlockTypes:()=>jr,Animation:()=>Le,AnimationAssetTask:()=>YO,AnimationEvent:()=>xs,AnimationGroup:()=>wi,AnimationGroupMask:()=>LS,AnimationGroupMaskMode:()=>Ao,AnimationKeyInterpolation:()=>Rt,AnimationPropertiesOverride:()=>wt,AnimationRange:()=>kt,AnisotropyBlock:()=>Nh,ApplyLut:()=>Uo.Kq,ApplyPostProcess:()=>Si.Qs,Arc2:()=>Ge.Xy,ArcFollowCamera:()=>iu,ArcRotateCamera:()=>zr,ArcRotateCameraGamepadInput:()=>Lc,ArcRotateCameraInputsManager:()=>Os,ArcRotateCameraKeyboardMoveInput:()=>Fc,ArcRotateCameraMouseWheelInput:()=>wc,ArcRotateCameraPointersInput:()=>Bc,ArcRotateCameraVRDeviceOrientationInput:()=>Vc,ArcTan2Block:()=>Dy,AssetContainer:()=>tm,AssetTaskState:()=>Qf,AssetsManager:()=>XO,AssetsProgressEvent:()=>OT,AsyncLock:()=>_1,AsyncLoop:()=>ze.LV,AttachToBoxBehavior:()=>HS,AudioEngine:()=>nm,AudioSceneComponent:()=>nr,AutoLayoutMode:()=>md,AutoReleaseWorkerPool:()=>Il.h,AutoRotationBehavior:()=>rm,AxesViewer:()=>ia,Axis:()=>Ge._0,AxisDragGizmo:()=>Yr,AxisScaleGizmo:()=>Ha,BRDFTextureTools:()=>mx,BabylonFileLoaderConfiguration:()=>El,BackEase:()=>Yn,BackgroundMaterial:()=>ja,BakedVertexAnimationManager:()=>US,BallAndSocketConstraint:()=>gR,BaseCameraMouseWheelInput:()=>dm,BaseCameraPointersInput:()=>Nc,BaseError:()=>Bi.Cf,BaseParticleSystem:()=>Ei,BaseSixDofDragBehavior:()=>Dc,BaseTexture:()=>Ki.t,BasisFileInfo:()=>Hi.$e,BasisTools:()=>Hi.ED,BasisToolsOptions:()=>Hi.Sl,BasisTranscodeConfiguration:()=>Hi.SV,BezierCurve:()=>Ge.vr,BezierCurveEase:()=>fr,BiPlanarBlock:()=>t0,BinaryFileAssetTask:()=>FT,BindBonesParameters:()=>Re.f$,BindFogParameters:()=>Re.Yy,BindLight:()=>Re.Kd,BindLightProperties:()=>Re.L0,BindLights:()=>Re.RL,BindLogDepth:()=>Re.DL,BindMorphTargetParameters:()=>Re.nR,BindSceneUniformBuffer:()=>Re._8,BindTextureMatrix:()=>Re.mA,BlackAndWhitePostProcess:()=>eT,BlendFactor:()=>Td,BlendOperation:()=>Sd,BloomEffect:()=>Lf,BloomMergePostProcess:()=>Nf,BlurPostProcess:()=>ci,Bone:()=>Ct,BoneAxesViewer:()=>Au,BoneIKController:()=>QS,BoneLookController:()=>JS,BonesBlock:()=>Gv,BooleanGeometryBlock:()=>Sb,BooleanGeometryOperations:()=>Cr,BounceEase:()=>Kt,BouncingBehavior:()=>om,BoundingBlock:()=>Tb,BoundingBox:()=>To,BoundingBoxGizmo:()=>Fg,BoundingBoxRenderer:()=>gT,BoundingInfo:()=>tr,BoundingInfoHelper:()=>pE,BoundingSphere:()=>Zo,BoxBlock:()=>sf,BoxBuilder:()=>vE,BoxParticleEmitter:()=>Go,Buffer:()=>Y.h,BufferBindingType:()=>ud,BufferMapState:()=>Ju,BufferUsage:()=>nn,CSG:()=>jh,Camera:()=>Pt,CameraGizmo:()=>px,CameraInputTypes:()=>oi,CameraInputsManager:()=>Ca,CannonJSPlugin:()=>Sl,CanvasAlphaMode:()=>Dd,CapsuleBlock:()=>O0,CapsuleBuilder:()=>EE,CascadedShadowGenerator:()=>fh,ChromaticAberrationPostProcess:()=>Ff,CircleEase:()=>xn,CircleOfConfusionPostProcess:()=>wf,ClampBlock:()=>fy,ClearCoatBlock:()=>Al,ClipPlanesBlock:()=>sy,ClipboardEventTypes:()=>ll,ClipboardInfo:()=>ux,CloudBlock:()=>Jy,CloudPoint:()=>Kb,Collider:()=>Zm,Color3:()=>Ge.v9,Color3Gradient:()=>Yb,Color4:()=>Ge.ov,ColorCorrectionPostProcess:()=>tT,ColorCurves:()=>AP.Q,ColorGradient:()=>pf,ColorGradingTexture:()=>Fv,ColorMergerBlock:()=>vy,ColorSplitterBlock:()=>rh,ColorWrite:()=>bd,CombineAction:()=>Ae,CompareFunction:()=>ld,CompatibilityOptions:()=>Xt.p9,CompilationMessageType:()=>pd,CompleteGreasedLineColorTable:()=>T0,CompleteGreasedLineWidthTable:()=>b0,CompressionCodes:()=>Mn.he,ComputeBindingType:()=>Xu,ComputeEffect:()=>$m,ComputeNormalsBlock:()=>j0,ComputePassTimestampLocation:()=>Cd,ComputeShader:()=>eg.H,ComputeShaderBoundingHelper:()=>mE.ComputeShaderBoundingHelper,ComputeShaderParticleSystem:()=>Hb,Condition:()=>ne,ConditionBlock:()=>k0,ConditionBlockTests:()=>Kn,ConditionalBlock:()=>Qy,ConditionalBlockConditions:()=>Zi,ConeDirectedParticleEmitter:()=>lf,ConeParticleEmitter:()=>Ol,Constants:()=>P.Y,ContainerAssetTask:()=>DT,ConversionMode:()=>qf,ConvolutionPostProcess:()=>nT,Coordinate:()=>Ge.xp,CopyFloatData:()=>Z_,CopyTextureToTexture:()=>RT,CopyTools:()=>Ho.D8,CreateBox:()=>Oi,CreateBoxVertexData:()=>Ys,CreateCapsule:()=>Fa,CreateCapsuleVertexData:()=>js,CreateCylinder:()=>_i,CreateCylinderVertexData:()=>Ws,CreateDashedLines:()=>Zs,CreateDashedLinesVertexData:()=>wu,CreateDecal:()=>el,CreateDecoderAsync:()=>Ph.d,CreateDisc:()=>ra,CreateDiscVertexData:()=>qs,CreateEnvTextureAsync:()=>ni.Hx,CreateGeodesic:()=>og,CreateGoldberg:()=>sg,CreateGoldbergVertexData:()=>ag,CreateGreasedLine:()=>AC,CreateGreasedLineMaterial:()=>v0,CreateGround:()=>ta,CreateGroundFromHeightMap:()=>ks,CreateGroundFromHeightMapVertexData:()=>Su,CreateGroundVertexData:()=>Wr,CreateHemisphere:()=>Xa,CreateIcoSphere:()=>sa,CreateIcoSphereVertexData:()=>$s,CreateImageBitmapFromSource:()=>fu,CreateImageDataArrayBufferViews:()=>ni.$h,CreateLathe:()=>Qs,CreateLineSystem:()=>Do,CreateLineSystemVertexData:()=>Fu,CreateLines:()=>dn,CreatePlane:()=>Ur,CreatePlaneVertexData:()=>Is,CreatePolygon:()=>wa,CreatePolygonVertexData:()=>Bu,CreatePolyhedron:()=>No,CreatePolyhedronVertexData:()=>Vu,CreateResizedCopy:()=>Si.EE,CreateRibbon:()=>oo,CreateRibbonVertexData:()=>Iu,CreateScreenshot:()=>vs,CreateScreenshotAsync:()=>tp,CreateScreenshotUsingRenderTarget:()=>ys,CreateScreenshotUsingRenderTargetAsync:()=>np,CreateScreenshotWithResizeAsync:()=>XT,CreateSegmentedBoxVertexData:()=>ng,CreateSphere:()=>li,CreateSphereVertexData:()=>Xs,CreateText:()=>lg,CreateTextShapePaths:()=>zu,CreateTiledBox:()=>Du,CreateTiledBoxVertexData:()=>Ou,CreateTiledGround:()=>Gs,CreateTiledGroundVertexData:()=>Tu,CreateTiledPlane:()=>Mu,CreateTiledPlaneVertexData:()=>oa,CreateTorus:()=>Sr,CreateTorusKnot:()=>Ks,CreateTorusKnotVertexData:()=>Nu,CreateTorusVertexData:()=>zs,CreateTube:()=>Js,CrossBlock:()=>py,CubeMapToSphericalPolynomialTools:()=>Av.d,CubeTexture:()=>mr,CubeTextureAssetTask:()=>VT,CubicEase:()=>Sn,CullMode:()=>yd,CurrentScreenBlock:()=>Jd,Curve3:()=>Ge.jj,CurveBlock:()=>o0,CurveBlockTypes:()=>_n,CustomBlock:()=>_y,CustomOptimization:()=>WT,CustomParticleEmitter:()=>ko,CustomProceduralTexture:()=>Vv,CylinderBlock:()=>M0,CylinderBuilder:()=>gE,CylinderDirectedParticleEmitter:()=>cf,CylinderParticleEmitter:()=>Dl,DDSTools:()=>gg.D,DataBuffer:()=>$o.n,DataReader:()=>i1,DataStorage:()=>r1,Database:()=>kb,DebugBlock:()=>fb,DebugLayer:()=>Cu,DebugLayerTab:()=>Hs,DecalBuilder:()=>UE,DecalMapConfiguration:()=>Rl,DecalMapDefines:()=>a0,Decode:()=>fi.Tq,DecodeBase64ToBinary:()=>fi.yS,DecodeBase64ToString:()=>fi.AV,DecodeBase64UrlToBinary:()=>hn.rz,DecodeBase64UrlToString:()=>hn.dy,DecodeFloat32:()=>Mn.Sn,DecodeRunLength:()=>GP._,DeepCopier:()=>ot.r,DefaultCollisionCoordinator:()=>Qm,DefaultKTX2DecoderOptions:()=>rp.$,DefaultLoadingScreen:()=>xv,DefaultRenderingPipeline:()=>uT,Deferred:()=>kT,DepthCullingState:()=>Og.N,DepthOfFieldBlurPostProcess:()=>wl,DepthOfFieldEffect:()=>Vf,DepthOfFieldEffectBlurLevel:()=>Bf,DepthOfFieldMergePostProcess:()=>iT,DepthPeelingRenderer:()=>yT,DepthPeelingSceneComponent:()=>bT,DepthReducer:()=>Sv,DepthRenderer:()=>ls,DepthRendererSceneComponent:()=>vT,DepthSortedParticle:()=>jb,DerivativeBlock:()=>jv,DesaturateBlock:()=>Xy,DetailMapConfiguration:()=>Bs,DeviceInputEventType:()=>Aa.b,DeviceLostReason:()=>Nd,DeviceOrientationCamera:()=>Ds,DeviceSource:()=>GE.c,DeviceSourceManager:()=>kE.Z,DeviceType:()=>rr.bq,DirectionalLight:()=>Ya,DirectionalLightFrustumViewer:()=>dg,DiscBlock:()=>D0,DiscBuilder:()=>PE,DiscardBlock:()=>Yv,DisplayPassPostProcess:()=>rT,DistanceBlock:()=>Cy,DistanceConstraint:()=>vR,DistanceJoint:()=>bE,DivideBlock:()=>Ty,DoNothingAction:()=>Pe,DomManagement:()=>bi.Az,DotBlock:()=>my,DracoCompression:()=>vC,DrawWrapper:()=>jn.E,DualSenseInput:()=>rr.pI,DualShockButton:()=>ru,DualShockDpad:()=>ou,DualShockInput:()=>rr.h8,DualShockPad:()=>vm,DumpTools:()=>Hl.e9,DynamicFloat32Array:()=>ho,DynamicTexture:()=>Oo,EXROutputType:()=>xh.V,EasingFunction:()=>Wt,EdgesRenderer:()=>Yf,Effect:()=>ti.M,EffectFallbacks:()=>Tr,EffectLayer:()=>as,EffectLayerSceneComponent:()=>_v,EffectRenderer:()=>Ni.J,EffectWrapper:()=>Ni.$,ElasticEase:()=>Gn,ElbowBlock:()=>e0,EncodeArrayBufferToBase64:()=>fi.EL,EndsWith:()=>fi.jq,Engine:()=>Zt,EngineFactory:()=>cx,EngineFormat:()=>fs.GQ,EngineInstrumentation:()=>fv,EngineStore:()=>Ve.q,EngineView:()=>zE,EnvironmentHelper:()=>kd,EnvironmentTextureTools:()=>ni.qY,Epsilon:()=>Ge.bH,EquiRectangularCubeTexture:()=>Bv,EquiRectangularCubeTextureAssetTask:()=>GT,ErrorCodes:()=>Bi.tG,ErrorFilter:()=>Ld,EventConstants:()=>Aa.s,EventState:()=>K.qO,ExecuteCodeAction:()=>Ue,ExitFullscreen:()=>mu,ExitPointerlock:()=>gu,ExponentialEase:()=>Xn,ExrLoaderGlobalConfiguration:()=>xh.u,ExternalTexture:()=>Vd,ExtractHighlightsPostProcess:()=>Df,ExtrudePolygon:()=>Ba,ExtrudeShape:()=>Va,ExtrudeShapeCustom:()=>Ua,FactorGradient:()=>_f,FadeInOutBehavior:()=>YS,FeatureName:()=>Qu,FileTools:()=>hn.wS,FileToolsOptions:()=>hn.eC,FilesInput:()=>qO,FilesInputStore:()=>zT.T,FilterMode:()=>ad,FilterPostProcess:()=>oT,FlowGraph:()=>hp,FlowGraphAbsBlock:()=>Np,FlowGraphAcosBlock:()=>r_,FlowGraphAcoshBlock:()=>d_,FlowGraphAddBlock:()=>Ep,FlowGraphAsinBlock:()=>i_,FlowGraphAsinhBlock:()=>u_,FlowGraphAtan2Block:()=>a_,FlowGraphAtanBlock:()=>o_,FlowGraphAtanhBlock:()=>h_,FlowGraphBitwiseAndBlock:()=>M_,FlowGraphBitwiseLeftShiftBlock:()=>N_,FlowGraphBitwiseNotBlock:()=>I_,FlowGraphBitwiseOrBlock:()=>O_,FlowGraphBitwiseRightShiftBlock:()=>L_,FlowGraphBitwiseXorBlock:()=>D_,FlowGraphBlock:()=>_o,FlowGraphBranchBlock:()=>hS,FlowGraphCeilBlock:()=>Bp,FlowGraphClampBlock:()=>Wp,FlowGraphConditionalDataBlock:()=>xS,FlowGraphConnection:()=>cc,FlowGraphConnectionType:()=>lp,FlowGraphConsoleLogBlock:()=>fp,FlowGraphConstantBlock:()=>AS,FlowGraphContext:()=>up,FlowGraphContextLogger:()=>M1,FlowGraphCoordinateTransformBlock:()=>PS,FlowGraphCoordinator:()=>I1,FlowGraphCosBlock:()=>t_,FlowGraphCoshBlock:()=>l_,FlowGraphCountLeadingZerosBlock:()=>F_,FlowGraphCountOneBitsBlock:()=>B_,FlowGraphCountTrailingZerosBlock:()=>w_,FlowGraphCounterBlock:()=>yS,FlowGraphCrossBlock:()=>S_,FlowGraphCubeRootBlock:()=>v_,FlowGraphDataConnection:()=>dc,FlowGraphDebounceBlock:()=>bS,FlowGraphDegToRadBlock:()=>Jp,FlowGraphDeterminantBlock:()=>A_,FlowGraphDivideBlock:()=>Ap,FlowGraphDoNBlock:()=>mp,FlowGraphDotBlock:()=>Rp,FlowGraphEBlock:()=>Ip,FlowGraphEqBlock:()=>Xp,FlowGraphEventBlock:()=>ga,FlowGraphExecutionBlock:()=>Mr,FlowGraphExpBlock:()=>f_,FlowGraphFlipFlopBlock:()=>TS,FlowGraphFloorBlock:()=>wp,FlowGraphForLoopBlock:()=>fS,FlowGraphFractBlock:()=>Vp,FlowGraphGetPropertyBlock:()=>Tp,FlowGraphGetVariableBlock:()=>bp,FlowGraphGreaterThanBlock:()=>Kp,FlowGraphGreaterThanOrEqualBlock:()=>Zp,FlowGraphInfBlock:()=>Op,FlowGraphInterpolateBlock:()=>Yp,FlowGraphInvertMatrixBlock:()=>C_,FlowGraphIsInfBlock:()=>U1,FlowGraphIsNanBlock:()=>Qp,FlowGraphLengthBlock:()=>b_,FlowGraphLessThanBlock:()=>qp,FlowGraphLessThanOrEqualBlock:()=>V1,FlowGraphLog10Block:()=>m_,FlowGraphLog2Block:()=>__,FlowGraphLogBlock:()=>p_,FlowGraphLogicAndBlock:()=>CS,FlowGraphLogicNotBlock:()=>IS,FlowGraphLogicOrBlock:()=>RS,FlowGraphMatMulBlock:()=>R_,FlowGraphMaxBlock:()=>zp,FlowGraphMeshPickEventBlock:()=>fc,FlowGraphMinBlock:()=>kp,FlowGraphMultiGateBlock:()=>mS,FlowGraphMultiplyBlock:()=>Pp,FlowGraphNaNBlock:()=>Dp,FlowGraphNegBlock:()=>Up,FlowGraphNormalizeBlock:()=>T_,FlowGraphPauseAnimationBlock:()=>ES,FlowGraphPiBlock:()=>Mp,FlowGraphPlayAnimationBlock:()=>yp,FlowGraphPowBlock:()=>y_,FlowGraphRadToDegBlock:()=>$p,FlowGraphRandomBlock:()=>Cp,FlowGraphReceiveCustomEventBlock:()=>V_,FlowGraphRemainderBlock:()=>Gp,FlowGraphRotate2DBlock:()=>E_,FlowGraphRotate3DBlock:()=>x_,FlowGraphSaturateBlock:()=>Hp,FlowGraphSceneReadyEventBlock:()=>OS,FlowGraphSceneTickEventBlock:()=>U_,FlowGraphSendCustomEventBlock:()=>dS,FlowGraphSequenceBlock:()=>vp,FlowGraphSetPropertyBlock:()=>uS,FlowGraphSetVariableBlock:()=>pp,FlowGraphSignBlock:()=>Lp,FlowGraphSignalConnection:()=>hc,FlowGraphSinBlock:()=>e_,FlowGraphSinhBlock:()=>s_,FlowGraphSqrtBlock:()=>g_,FlowGraphState:()=>dp,FlowGraphStopAnimationBlock:()=>SS,FlowGraphSubtractBlock:()=>xp,FlowGraphSwitchBlock:()=>gS,FlowGraphTanBlock:()=>n_,FlowGraphTanhBlock:()=>c_,FlowGraphThrottleBlock:()=>pS,FlowGraphTimerBlock:()=>_S,FlowGraphTransposeBlock:()=>P_,FlowGraphTruncBlock:()=>Fp,FlowGraphWaitAllBlock:()=>vS,FlowGraphWhileLoopBlock:()=>gp,FluidRenderer:()=>MT,FluidRendererSceneComponent:()=>IT,FluidRenderingDebug:()=>Xf,FluidRenderingObject:()=>jf,FluidRenderingObjectCustomParticles:()=>CT,FluidRenderingObjectParticleSystem:()=>PT,FluidRenderingTargetRenderer:()=>Kf,FlyCamera:()=>_m,FlyCameraInputsManager:()=>pm,FlyCameraKeyboardInput:()=>Uc,FlyCameraMouseInput:()=>Gc,FogBlock:()=>ny,FollowBehavior:()=>KS,FollowCamera:()=>nu,FollowCameraInputsManager:()=>mm,FollowCameraKeyboardMoveInput:()=>kc,FollowCameraMouseWheelInput:()=>zc,FollowCameraPointersInput:()=>Wc,FragCoordBlock:()=>qv,FragDepthBlock:()=>$v,FragmentOutputBlock:()=>ca,FramingBehavior:()=>am,FreeCamera:()=>_r,FreeCameraDeviceOrientationInput:()=>qc,FreeCameraGamepadInput:()=>Kc,FreeCameraInputsManager:()=>Ra,FreeCameraKeyboardMoveInput:()=>Hc,FreeCameraMouseInput:()=>Yc,FreeCameraMouseWheelInput:()=>Xc,FreeCameraTouchInput:()=>jc,FreeCameraVirtualJoystickInput:()=>Jc,FresnelBlock:()=>xy,FresnelParameters:()=>Dv,FromHalfFloat:()=>Si.SX,FrontFace:()=>vd,FrontFacingBlock:()=>Xv,Frustum:()=>Ge.PP,FxaaPostProcess:()=>ms,GIRSM:()=>bM,GIRSMManager:()=>TM,GIRSMRenderPluginMaterial:()=>ma,GPUParticleSystem:()=>zo,GPUPicker:()=>cE,GUID:()=>Eo.S,Gamepad:()=>Ii,GamepadCamera:()=>Ns,GamepadManager:()=>ym,GamepadSystemSceneComponent:()=>bm,GaussianSplattingMaterial:()=>Hh,GaussianSplattingMesh:()=>RC,GenerateBase64StringFromPixelData:()=>Ho.c9,GenerateBase64StringFromTexture:()=>Ho.lP,GenerateBase64StringFromTextureAsync:()=>Ho.nh,GenericPad:()=>hm,GeodesicData:()=>Gu,Geometry:()=>Vi,GeometryArcTan2Block:()=>Eb,GeometryBufferRenderer:()=>zn,GeometryBufferRendererSceneComponent:()=>aT,GeometryClampBlock:()=>Mb,GeometryCollectionBlock:()=>Y0,GeometryCrossBlock:()=>Ob,GeometryCurveBlock:()=>Db,GeometryCurveBlockTypes:()=>Ft,GeometryDesaturateBlock:()=>Nb,GeometryDistanceBlock:()=>wb,GeometryDotBlock:()=>Bb,GeometryElbowBlock:()=>X0,GeometryInfoBlock:()=>pb,GeometryInputBlock:()=>Nn,GeometryLengthBlock:()=>Vb,GeometryLerpBlock:()=>xb,GeometryModBlock:()=>Rb,GeometryNLerpBlock:()=>Pb,GeometryOptimizeBlock:()=>E0,GeometryOutputBlock:()=>af,GeometryPosterizeBlock:()=>Lb,GeometryPowBlock:()=>Ib,GeometryReplaceColorBlock:()=>Fb,GeometryRotate2dBlock:()=>Ub,GeometrySmoothStepBlock:()=>Cb,GeometryStepBlock:()=>Ab,GeometryTextureBlock:()=>yb,GeometryTextureFetchBlock:()=>bb,GeometryTransformBlock:()=>J0,GeometryTrigonometryBlock:()=>Q0,GeometryTrigonometryBlockOperations:()=>Ht,GetClass:()=>j.n9,GetClassName:()=>j.Uu,GetDOMTextContent:()=>bi.Zl,GetEnvInfo:()=>ni.cU,GetEnvironmentBRDFTexture:()=>qa,GetExrHeader:()=>kP.V,GetFogState:()=>Re.qL,GetFontOffset:()=>hu,GetInternalFormatFromBasisFormat:()=>Hi.yT,GetPointsCount:()=>y0,GetTGAHeader:()=>fa.O_,GetTextureDataAsync:()=>Si.Oz,Gizmo:()=>Jn,GizmoAnchorPoint:()=>xu,GizmoCoordinatesMode:()=>Pu,GizmoManager:()=>dx,GlowLayer:()=>vl,GoldbergMesh:()=>ku,GradientBlock:()=>Vy,GradientBlockColorStep:()=>Pl,GradientHelper:()=>Wi,GrainPostProcess:()=>Uf,GreasedLineBaseMesh:()=>Jh,GreasedLineMaterialDefaults:()=>ui,GreasedLineMesh:()=>$h,GreasedLineMeshColorDistribution:()=>ef,GreasedLineMeshColorDistributionType:()=>kh,GreasedLineMeshColorMode:()=>Gh,GreasedLineMeshMaterialType:()=>Uh,GreasedLineMeshWidthDistribution:()=>tf,GreasedLinePluginMaterial:()=>ha,GreasedLineRibbonAutoDirectionMode:()=>Qh,GreasedLineRibbonFacesMode:()=>Zh,GreasedLineRibbonMesh:()=>Ml,GreasedLineRibbonPointsMode:()=>Kh,GreasedLineSimpleMaterial:()=>zh,GreasedLineTools:()=>On,GridBlock:()=>R0,GroundBuilder:()=>oE,GroundMesh:()=>Us,HDRCubeTexture:()=>bl,HDRCubeTextureAssetTask:()=>UT,HDRFiltering:()=>ph,HDRTools:()=>Pv.I9,Halton2DSequence:()=>c0,HandConstraintBehavior:()=>ZS,HandConstraintOrientation:()=>Mc,HandConstraintVisibility:()=>Oc,HandConstraintZone:()=>Ic,HandPart:()=>sh,HandleFallbacksForShadows:()=>Re.c4,HardwareScalingOptimization:()=>Jf,HavokPlugin:()=>MR,HeightToNormalBlock:()=>Jv,HemisphereBuilder:()=>hx,HemisphericLight:()=>na,HemisphericParticleEmitter:()=>uf,HighlightLayer:()=>uh,HighlightsPostProcess:()=>FR,Hinge2Joint:()=>SE,HingeConstraint:()=>yR,HingeJoint:()=>TE,HtmlElementTexture:()=>FP,HufUncompress:()=>Uo.ZR,IWebXRControllerPhysicsOptions:()=>S1,IblShadowsRenderPipeline:()=>qI,IcoSphereBlock:()=>A0,IcoSphereBuilder:()=>BE,ImageAssetTask:()=>wT,ImageProcessingBlock:()=>Wv,ImageProcessingConfiguration:()=>Ti.p,ImageProcessingPostProcess:()=>Gf,ImageSourceBlock:()=>sr,IncrementValueAction:()=>he,IndexFormat:()=>xd,InputBlock:()=>Mt,InspectableType:()=>ip,InstancedLinesMesh:()=>Lu,InstancedMesh:()=>Co,InstancesBlock:()=>kv,InstantiateBlock:()=>cb,InstantiateLinearBlock:()=>ub,InstantiateOnFacesBlock:()=>ab,InstantiateOnVerticesBlock:()=>ob,InstantiateOnVolumeBlock:()=>sb,InstantiateRadialBlock:()=>db,InstantiatedEntries:()=>em,IntFloatConverterBlock:()=>hb,InterleaveScalar:()=>Mn.KA,InternalTexture:()=>rn.h,InternalTextureSource:()=>rn.G,InterpolateValueAction:()=>Ye,IntersectionInfo:()=>Rs,IsBase64DataUrl:()=>hn.f2,IsDocumentAvailable:()=>bi.Nf,IsFileURL:()=>hn.my,IsNavigatorAvailable:()=>bi.XD,IsWindowObjectExist:()=>bi.BA,IsWrapper:()=>Yu.E,JoystickAxis:()=>Zc,KeepAssets:()=>$_,KeyboardEventTypes:()=>io.TB,KeyboardInfo:()=>io.W0,KeyboardInfoPre:()=>io.Bu,KhronosTextureContainer:()=>KO.H,KhronosTextureContainer2:()=>rp.Z,LatheBuilder:()=>LE,Layer:()=>gv,LayerSceneComponent:()=>mv,LengthBlock:()=>Ry,LensFlare:()=>vv,LensFlareSystem:()=>dh,LensFlareSystemSceneComponent:()=>yv,LensFlaresOptimization:()=>Gl,LensRenderingPipeline:()=>kR,LerpBlock:()=>by,Light:()=>hi,LightBlock:()=>iy,LightGizmo:()=>fx,LightInformationBlock:()=>zv,LineEdgesRenderer:()=>TT,LinesBuilder:()=>IE,LinesMesh:()=>aa,LoadFile:()=>hn.zU,LoadFileError:()=>hn.hX,LoadImage:()=>hn.W$,LoadImageConfiguration:()=>hn.qc,LoadOp:()=>Id,LoadTextureFromTranscodeResult:()=>Hi.aB,LockConstraint:()=>TR,Logger:()=>O.V,MapMode:()=>$u,MapRangeBlock:()=>G0,MappingBlock:()=>_b,MappingTypes:()=>Ar,Material:()=>Lt,MaterialAnisotropicDefines:()=>kg,MaterialClearCoatDefines:()=>Ug,MaterialDefines:()=>si,MaterialDetailMapDefines:()=>Gm,MaterialFlags:()=>$e,MaterialGreasedLineDefines:()=>s0,MaterialHelper:()=>CP,MaterialIridescenceDefines:()=>Gg,MaterialPluginBase:()=>qi,MaterialPluginEvent:()=>Vh,MaterialPluginManager:()=>Bm,MaterialSheenDefines:()=>zg,MaterialSubSurfaceDefines:()=>Wg,MathBlock:()=>U0,MathBlockOperations:()=>xi,Matrix:()=>Ge.uq,MatrixBuilderBlock:()=>Zy,MatrixComposeBlock:()=>mb,MatrixDeterminantBlock:()=>n0,MatrixTransposeBlock:()=>i0,MaxBlock:()=>Py,MergeGeometryBlock:()=>H0,MergeMeshesOptimization:()=>zl,Mesh:()=>xe,MeshAssetTask:()=>NT,MeshAttributeExistsBlock:()=>r0,MeshAttributeExistsBlockTypes:()=>Bh,MeshBlock:()=>P0,MeshBuilder:()=>cg,MeshDebugMode:()=>Wh,MeshDebugPluginMaterial:()=>l0,MeshExploder:()=>jO,MeshLODLevel:()=>J_,MeshParticleEmitter:()=>zb,MeshUVSpaceRenderer:()=>TC,MeshoptCompression:()=>yC,MinBlock:()=>Ay,MinMaxReducer:()=>Tv,MipmapFilterMode:()=>sd,MirrorTexture:()=>Gd,ModBlock:()=>Ky,ModelShape:()=>vf,MorphTarget:()=>Cv,MorphTargetManager:()=>Tl,MorphTargetsBlock:()=>Rh,MotionBlurPostProcess:()=>kf,MotorEnabledJoint:()=>Ru,MultiMaterial:()=>Vr,MultiObserver:()=>ZO,MultiPointerScaleBehavior:()=>jS,MultiRenderTarget:()=>Kr,MultiplyBlock:()=>ml,NLerpBlock:()=>Uy,NativeDataStream:()=>il,NativeEngine:()=>Ku,NativePointerInput:()=>rr.Ze,NativeXRFrame:()=>tS,NativeXRLayerRenderTargetTextureProvider:()=>jm,NativeXRLayerWrapper:()=>Xm,NativeXRRenderTarget:()=>qm,NegateBlock:()=>Iy,Node:()=>At,NodeGeometry:()=>CC,NodeGeometryBlock:()=>Tt,NodeGeometryBlockConnectionPointTypes:()=>se,NodeGeometryBuildState:()=>S0,NodeGeometryConnectionPoint:()=>of,NodeGeometryConnectionPointCompatibilityStates:()=>nf,NodeGeometryConnectionPointDirection:()=>rf,NodeGeometryContextualSources:()=>Qt,NodeMaterial:()=>so,NodeMaterialBlock:()=>ut,NodeMaterialBlockConnectionPointMode:()=>Ch,NodeMaterialBlockConnectionPointTypes:()=>G,NodeMaterialBlockTargets:()=>_e,NodeMaterialConnectionPoint:()=>pl,NodeMaterialConnectionPointCompatibilityStates:()=>Kd,NodeMaterialConnectionPointCustomObject:()=>bn,NodeMaterialConnectionPointDirection:()=>Zd,NodeMaterialDefines:()=>ts,NodeMaterialModes:()=>mi,NodeMaterialOptimizer:()=>tC,NodeMaterialSystemValues:()=>Nt,NodeMaterialTeleportInBlock:()=>cy,NodeMaterialTeleportOutBlock:()=>uy,NoiseBlock:()=>W0,NoiseProceduralTexture:()=>Uv,NormalBlendBlock:()=>zy,NormalizeBlock:()=>gy,NormalizeVectorBlock:()=>K0,NullBlock:()=>N0,NullEngine:()=>pg,NullEngineOptions:()=>fg,Observable:()=>K.cP,Observer:()=>K.nu,OcclusionMaterial:()=>MP,Octree:()=>La,OctreeBlock:()=>tg,OctreeSceneComponent:()=>Eu,OimoJSPlugin:()=>mh,OnAfterEnteringVRObservableEvent:()=>lE,OneMinusBlock:()=>Ih,Orientation:()=>Ge.t4,OutlineRenderer:()=>xT,PBRAnisotropicConfiguration:()=>Wd,PBRBaseMaterial:()=>Tn,PBRBaseSimpleMaterial:()=>Sh,PBRClearCoatConfiguration:()=>Ka,PBRIridescenceConfiguration:()=>Za,PBRMaterial:()=>fl,PBRMaterialDefines:()=>Xd,PBRMetallicRoughnessBlock:()=>qy,PBRMetallicRoughnessMaterial:()=>Nv,PBRSheenConfiguration:()=>Hd,PBRSpecularGlossinessMaterial:()=>Lv,PBRSubSurfaceConfiguration:()=>Yd,PHI:()=>Ge.a6,PadNumber:()=>fi.LW,PanoramaToCubeMapTools:()=>wv.D,ParseFloat16:()=>Mn.LD,ParseFloat32:()=>Mn.Ff,ParseInt32:()=>Mn.cL,ParseInt64:()=>Mn.tB,ParseNullTerminatedString:()=>Mn.T$,ParseUint16:()=>Mn.Jn,ParseUint32:()=>Mn.PX,ParseUint8:()=>Mn._S,ParseUint8Array:()=>Mn.fz,ParseValue:()=>Mn.zX,Particle:()=>Xb,ParticleBlendMultiplyBlock:()=>th,ParticleHelper:()=>eR,ParticleRampGradientBlock:()=>eh,ParticleSystem:()=>Pn,ParticleSystemSet:()=>Ll,ParticleTextureBlock:()=>$d,ParticlesOptimization:()=>kl,PassCubePostProcess:()=>ro.s,PassPostProcess:()=>ro.v,Path2:()=>Ge.Cu,Path3D:()=>Ge.tO,PathCursor:()=>Rn,PerfCollectionStrategy:()=>f1,PerfCounter:()=>Mi.A,PerformanceConfigurator:()=>hg.I,PerformanceMonitor:()=>lu,PerformanceViewerCollector:()=>KT,PerturbNormalBlock:()=>Hv,PhotoDome:()=>_x,Physics6DoFConstraint:()=>Jb,Physics6DoFLimit:()=>mR,PhysicsActivationControl:()=>Af,PhysicsAggregate:()=>$b,PhysicsBody:()=>Qb,PhysicsConstraint:()=>co,PhysicsConstraintAxis:()=>bf,PhysicsConstraintAxisLimitMode:()=>yf,PhysicsConstraintMotorType:()=>Ef,PhysicsConstraintType:()=>Tf,PhysicsEngine:()=>_h,PhysicsEngineV2:()=>Zb,PhysicsEventType:()=>xf,PhysicsHelper:()=>OR,PhysicsImpostor:()=>Dt,PhysicsJoint:()=>In,PhysicsMaterialCombineMode:()=>Cf,PhysicsMotionType:()=>Pf,PhysicsPrestepType:()=>Zr,PhysicsRadialExplosionEventOptions:()=>_a,PhysicsRadialImpulseFalloff:()=>Rf,PhysicsRaycastResult:()=>us,PhysicsShape:()=>gr,PhysicsShapeBox:()=>uR,PhysicsShapeCapsule:()=>lR,PhysicsShapeContainer:()=>fR,PhysicsShapeConvexHull:()=>dR,PhysicsShapeCylinder:()=>cR,PhysicsShapeGroundMesh:()=>_R,PhysicsShapeHeightField:()=>pR,PhysicsShapeMesh:()=>hR,PhysicsShapeSphere:()=>sR,PhysicsShapeType:()=>Sf,PhysicsUpdraftEventOptions:()=>Mf,PhysicsUpdraftMode:()=>If,PhysicsViewer:()=>Wu,PhysicsVortexEventOptions:()=>Of,PickingInfo:()=>ri.G,PipelineErrorReason:()=>_d,PivotTools:()=>Gi,Plane:()=>Ge.Zc,PlaneBlock:()=>x0,PlaneBuilder:()=>XS,PlaneDragGizmo:()=>ul,PlaneRotationGizmo:()=>cl,PlayAnimationAction:()=>Ee,PlaySoundAction:()=>ft,PointColor:()=>mf,PointLight:()=>yl,PointParticleEmitter:()=>df,PointerDragBehavior:()=>Gr,PointerEventTypes:()=>vt.Zp,PointerInfo:()=>vt.mx,PointerInfoBase:()=>vt.Vn,PointerInfoPre:()=>vt.tT,PointerInput:()=>rr.ST,PointsCloudSystem:()=>nR,PointsGroup:()=>Fl,Polar:()=>mC,Polygon:()=>ME,PolygonBuilder:()=>OE,PolygonMeshBuilder:()=>rg,PolyhedronBuilder:()=>wE,PolyhedronData:()=>tl,PositionGizmo:()=>Bg,PositionNormalTextureVertex:()=>Ge.k0,PositionNormalVertex:()=>Ge.B5,PostProcess:()=>_t.w,PostProcessManager:()=>bv.X,PostProcessRenderEffect:()=>Ut,PostProcessRenderPipeline:()=>uo,PostProcessRenderPipelineManager:()=>lT,PostProcessRenderPipelineManagerSceneComponent:()=>cT,PostProcessesOptimization:()=>Ul,PosterizeBlock:()=>wy,PowBlock:()=>My,PowerEase:()=>bo,PowerPreference:()=>Zu,PrePassOutputBlock:()=>ty,PrePassRenderer:()=>gs,PrePassRendererSceneComponent:()=>ST,PrePassTextureBlock:()=>ly,PrecisionDate:()=>et.j,PredicateCondition:()=>H,Predictor:()=>Mn.XE,PrepareAttributesForBakedVertexAnimation:()=>Re.J2,PrepareAttributesForBones:()=>Re.ni,PrepareAttributesForInstances:()=>Re.ER,PrepareAttributesForMorphTargets:()=>Re.IF,PrepareAttributesForMorphTargetsInfluencers:()=>Re.MF,PrepareDefinesForAttributes:()=>Re.qB,PrepareDefinesForBakedVertexAnimation:()=>Re.wu,PrepareDefinesForBones:()=>Re.IC,PrepareDefinesForCamera:()=>Re.Y7,PrepareDefinesForFrameBoundValues:()=>Re.OR,PrepareDefinesForLight:()=>Re.lo,PrepareDefinesForLights:()=>Re.az,PrepareDefinesForMergedUV:()=>Re.YT,PrepareDefinesForMisc:()=>Re.fm,PrepareDefinesForMorphTargets:()=>Re.Jz,PrepareDefinesForMultiview:()=>Re.VO,PrepareDefinesForOIT:()=>Re.Nc,PrepareDefinesForPrePass:()=>Re.N4,PrepareUniformsAndSamplersForLight:()=>Re.GD,PrepareUniformsAndSamplersList:()=>Re.Bb,PressureObserverWrapper:()=>qT,PrimitiveTopology:()=>gd,PrismaticConstraint:()=>SR,ProceduralTexture:()=>xr,ProceduralTextureSceneComponent:()=>av,PropertyTypeForEdition:()=>Qd,ProximityCastResult:()=>NR,PushAttributesForInstances:()=>Re.te,PushMaterial:()=>Ro,QuadraticEase:()=>Fi,QuadraticErrorSimplification:()=>m0,QuarticEase:()=>hr,Quaternion:()=>Ge.PT,QueryType:()=>Od,QueueNewFrame:()=>Be.r,QuinticEase:()=>Xi,RGBDTextureTools:()=>zd.G,RSMCreatePluginMaterial:()=>Zf,Ragdoll:()=>PR,RagdollBoneProperties:()=>xR,RandomBlock:()=>z0,RandomBlockLocks:()=>Qi,RandomGUID:()=>Eo.z,RandomNumberBlock:()=>Oy,RawCubeTexture:()=>WP,RawTexture:()=>Ln,RawTexture2DArray:()=>Rv,RawTexture3D:()=>HP,Ray:()=>fn,RayHelper:()=>ug,ReadFile:()=>hn.NJ,ReadFileError:()=>hn.VB,RecastJSCrowd:()=>Gb,RecastJSPlugin:()=>WC,ReciprocalBlock:()=>Ly,ReflectBlock:()=>Hy,ReflectionBlock:()=>Lh,ReflectionProbe:()=>vh,ReflectionTextureBaseBlock:()=>xl,ReflectionTextureBlock:()=>oy,ReflectiveShadowMap:()=>yM,Reflector:()=>u1,RefractBlock:()=>Yy,RefractionBlock:()=>Fh,RefractionPostProcess:()=>sT,RefractionTexture:()=>YP,RegisterClass:()=>j.Y5,RegisterMaterialPlugin:()=>iE,RegisterNativeTypeAsync:()=>xg,RemapBlock:()=>nh,RenderPassTimestampLocation:()=>Rd,RenderTargetTexture:()=>un.$,RenderTargetWrapper:()=>nl.v,RenderTargetsOptimization:()=>$f,RenderingGroup:()=>ZI.U,RenderingGroupInfo:()=>ss.o,RenderingManager:()=>ss.m,ReplaceColorBlock:()=>Fy,RequestFile:()=>hn.sh,RequestFileError:()=>hn.Mi,RequestFullscreen:()=>_u,RequestPointerlock:()=>Ls,ResizeImageBitmap:()=>pu,RetryStrategy:()=>n1.a,ReverseLutFromBitmap:()=>Uo.FG,RibbonBuilder:()=>xE,RichType:()=>Ji,RichTypeAny:()=>at,RichTypeBoolean:()=>ei,RichTypeColor3:()=>rS,RichTypeColor4:()=>oS,RichTypeFlowGraphInteger:()=>An,RichTypeMatrix:()=>po,RichTypeNumber:()=>sn,RichTypeQuaternion:()=>aS,RichTypeString:()=>nS,RichTypeVector2:()=>uc,RichTypeVector3:()=>Jr,RichTypeVector4:()=>iS,RollingAverage:()=>Om,Rotate2dBlock:()=>Wy,RotationGizmo:()=>wg,RotationXBlock:()=>$0,RotationYBlock:()=>eb,RotationZBlock:()=>tb,RuntimeAnimation:()=>ct,RuntimeError:()=>Bi.bu,SSAO2RenderingPipeline:()=>dT,SSAORenderingPipeline:()=>WR,SSRRenderingPipeline:()=>fT,SamplerBindingType:()=>dd,Scalar:()=>_C,ScaleBlock:()=>hy,ScaleGizmo:()=>Vg,ScalingBlock:()=>nb,ScanData:()=>Ph.u,Scene:()=>ke.Z,SceneComponentConstants:()=>lt.v,SceneDepthBlock:()=>ay,SceneInstrumentation:()=>pv,SceneLoader:()=>yn,SceneLoaderAnimationGroupLoadingMode:()=>jd,SceneLoaderFlags:()=>pr,SceneOptimization:()=>Qr,SceneOptimizer:()=>QO,SceneOptimizerOptions:()=>ep,ScenePerformancePriority:()=>ke.F,SceneRecorder:()=>o1,SceneSerializer:()=>Wl,ScreenSizeBlock:()=>Kv,ScreenSpaceBlock:()=>Zv,ScreenSpaceCurvaturePostProcess:()=>mT,ScreenSpaceReflectionPostProcess:()=>Wf,ScreenshotTools:()=>t1,SerializationHelper:()=>tt.p,SetBasisTranscoderWorker:()=>Hi.af,SetColorsBlock:()=>B0,SetCorsBehavior:()=>hn.M1,SetMaterialIDBlock:()=>Z0,SetNormalsBlock:()=>F0,SetParentAction:()=>je,SetPositionsBlock:()=>L0,SetStateAction:()=>re,SetTangentsBlock:()=>V0,SetUVsBlock:()=>w0,SetValueAction:()=>oe,ShaderCodeInliner:()=>Ga,ShaderLanguage:()=>Eh,ShaderMaterial:()=>pi,ShaderStage:()=>cd,ShaderStore:()=>Gt.l,ShadowDepthWrapper:()=>nC,ShadowGenerator:()=>zi,ShadowGeneratorSceneComponent:()=>Ev,ShadowLight:()=>dl,ShadowMapBlock:()=>ey,ShadowsOptimization:()=>Vl,ShapeBuilder:()=>NE,ShapeCastResult:()=>LR,SharpenPostProcess:()=>zf,SheenBlock:()=>Dh,SimplexPerlin3DBlock:()=>ky,SimplicationQueueSceneComponent:()=>g0,SimplificationQueue:()=>_0,SimplificationSettings:()=>SC,SimplificationType:()=>qh,SineEase:()=>Ci,SixDofDragBehavior:()=>lm,Size:()=>Ge.or,Skeleton:()=>xa,SkeletonViewer:()=>Hu,SliderConstraint:()=>bR,SmartArray:()=>er.L,SmartArrayNoDuplicate:()=>er.b,SmoothStepBlock:()=>Ny,SolidParticle:()=>gf,SolidParticleSystem:()=>tR,SolidParticleVertex:()=>qb,Sound:()=>Jo,SoundTrack:()=>im,SourceTextureFormat:()=>fs.Ok,Space:()=>Ge.$x,SphereBlock:()=>C0,SphereBuilder:()=>yE,SphereDirectedParticleEmitter:()=>hf,SphereParticleEmitter:()=>Nl,Spherical:()=>gC,SphericalHarmonics:()=>Lo.O,SphericalPolynomial:()=>Lo.Q,SpotLight:()=>hl,SpringConstraint:()=>ER,Sprite:()=>Mv,SpriteManager:()=>yh,SpriteMap:()=>wO,SpritePackedManager:()=>BO,SpriteSceneComponent:()=>Ov,Stage:()=>lt.B,StandardMaterial:()=>qt,StandardMaterialDefines:()=>zm,StandardRenderingPipeline:()=>hT,StartsWith:()=>fi.UH,StateCondition:()=>W,StencilOperation:()=>Ed,StencilState:()=>WO.K,StencilStateComposer:()=>Mg.u,StepBlock:()=>Ey,StereoscopicArcRotateCamera:()=>Am,StereoscopicFreeCamera:()=>Cm,StereoscopicGamepadCamera:()=>Rm,StereoscopicInterlacePostProcess:()=>eE,StereoscopicInterlacePostProcessI:()=>Pm,StereoscopicScreenUniversalCamera:()=>tE,StereoscopicUniversalCamera:()=>Im,StickValues:()=>$S,StopAnimationAction:()=>Oe,StopSoundAction:()=>xt,StorageBuffer:()=>um.K,StorageTextureAccess:()=>fd,StoreOp:()=>Md,StringDictionary:()=>fm.w,StringTools:()=>fi.nQ,SubEmitter:()=>_s,SubEmitterType:()=>ff,SubMesh:()=>yi,SubSurfaceBlock:()=>Cl,SubSurfaceSceneComponent:()=>ET,SubtractBlock:()=>Sy,SurfaceMagnetismBehavior:()=>qS,SwitchBooleanAction:()=>Z,SwitchInput:()=>rr.dR,TAARenderingPipeline:()=>pT,TBNBlock:()=>ps,TGATools:()=>fa.uT,Tags:()=>En.Y,TargetCamera:()=>kr,TargetedAnimation:()=>Ps,TeleportInBlock:()=>gb,TeleportOutBlock:()=>vb,TestBase64DataUrl:()=>hn.ZP,TextFileAssetTask:()=>LT,Texture:()=>Ie.g,TextureAspect:()=>id,TextureAssetTask:()=>BT,TextureBlock:()=>ry,TextureDimension:()=>ed,TextureFormat:()=>rd,TextureOptimization:()=>Bl,TexturePacker:()=>zP,TexturePackerFrame:()=>Ah,TextureSampleType:()=>hd,TextureSampler:()=>XP.u,TextureTools:()=>Si.LO,TextureUsage:()=>td,TextureViewDimension:()=>nd,ThinEngine:()=>an.w,ThinRenderTargetTexture:()=>jP,ThinTexture:()=>da.D,TiledBoxBuilder:()=>CE,TiledPlaneBuilder:()=>AE,TimerState:()=>ch,TmpColors:()=>Ge.IG,TmpVectors:()=>Ge.AA,ToGammaSpace:()=>Ge.rv,ToHalfFloat:()=>Si.LZ,ToLinearSpace:()=>Ge.tk,TonemapPostProcess:()=>$R,TonemappingOperator:()=>Hf,Tools:()=>ze.S0,TorusBlock:()=>I0,TorusBuilder:()=>aE,TorusKnotBuilder:()=>RE,TouchCamera:()=>$c,TrailMesh:()=>p0,Trajectory:()=>a1,TrajectoryClassifier:()=>c1,TranscodeAsync:()=>Hi.yk,TranscodeTarget:()=>fs.Xl,TransformBlock:()=>_l,TransformFeedbackBoundingHelper:()=>_E.TransformFeedbackBoundingHelper,TransformNode:()=>jt,TranslationBlock:()=>rb,TriPlanarBlock:()=>wh,TrigonometryBlock:()=>oh,TrigonometryBlockOperations:()=>Vn,TubeBuilder:()=>FE,TwirlBlock:()=>Qv,UncompressPIZ:()=>lo.tg,UncompressPXR:()=>lo._k,UncompressRAW:()=>lo.S4,UncompressRLE:()=>lo.r,UncompressZIP:()=>lo.VE,UniformBuffer:()=>Ui.D,UniversalCamera:()=>So,UnregisterAllMaterialPlugins:()=>vu,UnregisterMaterialPlugin:()=>rE,UploadContent:()=>fa.FA,UploadEnvLevelsAsync:()=>ni.o5,UploadEnvSpherical:()=>ni.ow,UploadLevelsAsync:()=>ni.bv,UtilityLayerRenderer:()=>Fn,VRCameraMetrics:()=>Oa,VRDeviceOrientationArcRotateCamera:()=>Fm,VRDeviceOrientationFreeCamera:()=>ws,VRDeviceOrientationGamepadCamera:()=>wm,VRDistortionCorrectionPostProcess:()=>su,VRExperienceHelper:()=>Km,VRMultiviewToSingleviewPostProcess:()=>Lm,ValidatedNativeDataStream:()=>Ag,ValueCondition:()=>ae,Vector2:()=>Ge.I9,Vector2ToFixed:()=>u0,Vector3:()=>Ge.Pq,Vector3ToFixed:()=>d0,Vector4:()=>Ge.IU,Vector4ToFixed:()=>h0,VectorConverterBlock:()=>q0,VectorMergerBlock:()=>es,VectorSplitterBlock:()=>yy,VertexAnimationBaker:()=>WS,VertexBuffer:()=>Y.R,VertexData:()=>rt,VertexDataMaterialInfo:()=>Ea,VertexFormat:()=>Pd,VertexOutputBlock:()=>$a,VertexStepMode:()=>Ad,VideoDome:()=>kx,VideoRecorder:()=>$O,VideoTexture:()=>gl,ViewDirectionBlock:()=>Mh,Viewport:()=>Ge.LM,VirtualJoystick:()=>Qc,VirtualJoysticksCamera:()=>Mm,VolumetricLightScatteringPostProcess:()=>_T,VoronoiNoiseBlock:()=>$y,Wav2Decode:()=>Uo.tb,WaveBlock:()=>By,WaveBlockKind:()=>Oh,WebGL2ParticleSystem:()=>Wb,WebGL2ShaderProcessor:()=>lx.B,WebGLDataBuffer:()=>Dm.A,WebGLHardwareTexture:()=>ea.d,WebGLPipelineContext:()=>sx.x,WebGPUCacheBindGroups:()=>Ud,WebGPUCacheRenderPipeline:()=>Rg,WebGPUCacheRenderPipelineTree:()=>ol,WebGPUCacheSampler:()=>wd,WebGPUDataBuffer:()=>Cg,WebGPUDrawContext:()=>Dg,WebGPUEngine:()=>It,WebGPURenderTargetWrapper:()=>Lg,WebGPUTintWASM:()=>Ng,WebRequest:()=>We.u,WebXRAbstractFeature:()=>qn,WebXRAbstractMotionController:()=>Bo,WebXRAnchorSystem:()=>Xl,WebXRBackgroundRemover:()=>ql,WebXRCamera:()=>Hg,WebXRControllerComponent:()=>Xr,WebXRControllerMovement:()=>tc,WebXRControllerPhysics:()=>Kl,WebXRControllerPointerSelection:()=>Ja,WebXRDefaultExperience:()=>hv,WebXRDefaultExperienceOptions:()=>Vx,WebXRDepthSensing:()=>ac,WebXRDomOverlay:()=>ec,WebXREnterExitUI:()=>cv,WebXREnterExitUIButton:()=>lv,WebXREnterExitUIOptions:()=>Bx,WebXRExperienceHelper:()=>Yg,WebXREyeTracking:()=>ic,WebXRFeatureName:()=>vn,WebXRFeaturePointSystem:()=>Ql,WebXRFeaturesManager:()=>kn,WebXRGenericHandController:()=>JT,WebXRGenericTriggerMotionController:()=>qd,WebXRHTCViveMotionController:()=>eS,WebXRHand:()=>uv,WebXRHandJoint:()=>lh,WebXRHandTracking:()=>is,WebXRHitTest:()=>Zl,WebXRHitTestLegacy:()=>Yl,WebXRImageTracking:()=>$l,WebXRInput:()=>rv,WebXRInputSource:()=>iv,WebXRLayerRenderTargetTextureProvider:()=>Vs,WebXRLayers:()=>oc,WebXRLightEstimation:()=>nc,WebXRManagedOutputCanvas:()=>Ym,WebXRManagedOutputCanvasOptions:()=>yu,WebXRMeshDetector:()=>Jl,WebXRMicrosoftMixedRealityController:()=>$T,WebXRMotionControllerManager:()=>Di,WebXRMotionControllerTeleportation:()=>os,WebXRNearControllerMode:()=>ah,WebXRNearInteraction:()=>ns,WebXROculusTouchMotionController:()=>sp,WebXRPlaneDetector:()=>jl,WebXRProfiledMotionController:()=>tv,WebXRRawCameraAccess:()=>lc,WebXRSessionManager:()=>bu,WebXRSpaceWarp:()=>sc,WebXRSpaceWarpRenderTargetTextureProvider:()=>QT,WebXRState:()=>op,WebXRTrackingState:()=>ap,WebXRWalkingLocomotion:()=>rc,WeightedSound:()=>VS,WorkerPool:()=>Il.T,WorleyNoise3DBlock:()=>Gy,XRSpaceWarpRenderTarget:()=>ZT,Xbox360Button:()=>eu,Xbox360Dpad:()=>tu,Xbox360Pad:()=>gm,XboxInput:()=>rr.sZ,_BabylonLoaderRegistered:()=>vP,_BasisTextureLoader:()=>VP._BasisTextureLoader,_CommonDispose:()=>du,_CommonInit:()=>uu,_CreationDataStorage:()=>Cc,_DDSTextureLoader:()=>vx._DDSTextureLoader,_ENVTextureLoader:()=>yx._ENVTextureLoader,_ExrTextureLoader:()=>UP._ExrTextureLoader,_GetCompatibleTextureLoader:()=>la.gT,_HDRTextureLoader:()=>BP._HDRTextureLoader,_InstancesBatch:()=>Rc,_KTXTextureLoader:()=>bx._KTXTextureLoader,_MeshCollisionData:()=>Q_,_OcclusionDataStorage:()=>_g,_PrimaryIsoTriangle:()=>Uu,_TGATextureLoader:()=>wP._TGATextureLoader,_TimeToken:()=>mg,_UpdateRGBDAsync:()=>ni.gW,_forceSceneHelpersToBundle:()=>Ux,_forceTransformFeedbackToBundle:()=>YE,_injectLTSFileTools:()=>hn.rh,_staticOffsetValueColor3:()=>Ce,_staticOffsetValueColor4:()=>De,_staticOffsetValueQuaternion:()=>Xe,_staticOffsetValueSize:()=>pe,_staticOffsetValueVector2:()=>ge,_staticOffsetValueVector3:()=>Ze,addClipPlaneUniforms:()=>tn.TV,allocateAndCopyTypedBuffer:()=>cu.k,anaglyphPixelShader:()=>DI.anaglyphPixelShader,anaglyphPixelShaderWGSL:()=>NI.anaglyphPixelShaderWGSL,appendSceneAsync:()=>Ax,backgroundPixelShader:()=>PP.backgroundPixelShader,backgroundPixelShaderWGSL:()=>EP.backgroundPixelShaderWGSL,backgroundVertexShader:()=>xP.backgroundVertexShader,backgroundVertexShaderWGSL:()=>SP.backgroundVertexShaderWGSL,bilateralBlurPixelShader:()=>SM.bilateralBlurPixelShader,bilateralBlurPixelShaderWGSL:()=>AM.bilateralBlurPixelShaderWGSL,bilateralBlurQualityPixelShader:()=>EM.bilateralBlurQualityPixelShader,bilateralBlurQualityPixelShaderWGSL:()=>CM.bilateralBlurQualityPixelShaderWGSL,bindClipPlane:()=>tn.gS,blackAndWhitePixelShader:()=>MI.blackAndWhitePixelShader,blackAndWhitePixelShaderWGSL:()=>OI.blackAndWhitePixelShaderWGSL,bloomMergePixelShader:()=>SI.bloomMergePixelShader,bloomMergePixelShaderWGSL:()=>EI.bloomMergePixelShaderWGSL,bonesDeclaration:()=>nA.bonesDeclaration,bonesDeclarationWGSL:()=>eA.bonesDeclarationWGSL,bonesVertex:()=>iA.bonesVertex,bonesVertexWGSL:()=>tA.bonesVertexWGSL,boundingBoxRendererPixelShader:()=>LM.boundingBoxRendererPixelShader,boundingBoxRendererPixelShaderWGSL:()=>wM.boundingBoxRendererPixelShaderWGSL,boundingBoxRendererVertexShader:()=>FM.boundingBoxRendererVertexShader,boundingBoxRendererVertexShaderWGSL:()=>BM.boundingBoxRendererVertexShaderWGSL,bumpFragment:()=>bA.bumpFragment,bumpFragmentFunctions:()=>SA.bumpFragmentFunctions,bumpFragmentFunctionsWGSL:()=>yA.bumpFragmentFunctionsWGSL,bumpFragmentMainFunctions:()=>TA.bumpFragmentMainFunctions,bumpFragmentMainFunctionsWGSL:()=>vA.bumpFragmentMainFunctionsWGSL,bumpFragmentWGSL:()=>gA.bumpFragmentWGSL,captureEquirectangularFromScene:()=>p1,chromaticAberrationPixelShader:()=>GR.chromaticAberrationPixelShader,chromaticAberrationPixelShaderWGSL:()=>gI.chromaticAberrationPixelShaderWGSL,circleOfConfusionPixelShader:()=>bI.circleOfConfusionPixelShader,circleOfConfusionPixelShaderWGSL:()=>TI.circleOfConfusionPixelShaderWGSL,className:()=>ze.s7,clipPlaneFragment:()=>NA.clipPlaneFragment,clipPlaneFragmentDeclaration:()=>LA.clipPlaneFragmentDeclaration,clipPlaneFragmentDeclarationWGSL:()=>MA.clipPlaneFragmentDeclarationWGSL,clipPlaneFragmentWGSL:()=>IA.clipPlaneFragmentWGSL,clipPlaneVertex:()=>FA.clipPlaneVertex,clipPlaneVertexDeclaration:()=>wA.clipPlaneVertexDeclaration,clipPlaneVertexDeclarationWGSL:()=>DA.clipPlaneVertexDeclarationWGSL,clipPlaneVertexWGSL:()=>OA.clipPlaneVertexWGSL,colorCorrectionPixelShader:()=>wI.colorCorrectionPixelShader,colorCorrectionPixelShaderWGSL:()=>BI.colorCorrectionPixelShaderWGSL,colorPixelShader:()=>RP.colorPixelShader,colorPixelShaderWGSL:()=>IC.colorPixelShaderWGSL,colorVertexShader:()=>IP.colorVertexShader,colorVertexShaderWGSL:()=>MC.colorVertexShaderWGSL,computeMaxExtents:()=>PC,convolutionPixelShader:()=>LI.convolutionPixelShader,convolutionPixelShaderWGSL:()=>FI.convolutionPixelShaderWGSL,copyTexture3DLayerToTexturePixelShader:()=>XM.copyTexture3DLayerToTexturePixelShader,copyTexture3DLayerToTexturePixelShaderWGSL:()=>jM.copyTexture3DLayerToTexturePixelShaderWGSL,copyTextureToTexturePixelShader:()=>b1.copyTextureToTexturePixelShader,copyTextureToTexturePixelShaderWGSL:()=>T1.copyTextureToTexturePixelShaderWGSL,createDetailMapPlugin:()=>cC,createPBRAnisotropicPlugin:()=>iC,createPBRBRDFPlugin:()=>rC,createPBRClearCoatPlugin:()=>oC,createPBRIridescencePlugin:()=>aC,createPBRSheenPlugin:()=>sC,createPBRSubSurfacePlugin:()=>lC,createYieldingScheduler:()=>Y_,defaultPixelShader:()=>dC.defaultPixelShader,defaultPixelShaderWGSL:()=>fC.defaultPixelShaderWGSL,defaultVertexShader:()=>hC.defaultVertexShader,defaultVertexShaderWGSL:()=>pC.defaultVertexShaderWGSL,depthBoxBlurPixelShader:()=>mP.depthBoxBlurPixelShader,depthBoxBlurPixelShaderWGSL:()=>hP.depthBoxBlurPixelShaderWGSL,depthOfFieldMergePixelShader:()=>vI.depthOfFieldMergePixelShader,depthOfFieldMergePixelShaderWGSL:()=>yI.depthOfFieldMergePixelShaderWGSL,depthPixelShader:()=>sP.depthPixelShader,depthPixelShaderWGSL:()=>MM.depthPixelShaderWGSL,depthVertexShader:()=>lP.depthVertexShader,depthVertexShaderWGSL:()=>OM.depthVertexShaderWGSL,displayPassPixelShader:()=>HI.displayPassPixelShader,displayPassPixelShaderWGSL:()=>YI.displayPassPixelShaderWGSL,editableInPropertyPage:()=>dt,expandToProperty:()=>V.$z,extractHighlightsPixelShader:()=>xI.extractHighlightsPixelShader,extractHighlightsPixelShaderWGSL:()=>PI.extractHighlightsPixelShaderWGSL,extractMinAndMax:()=>no.b,extractMinAndMaxIndexed:()=>no.c,filterPixelShader:()=>GI.filterPixelShader,filterPixelShaderWGSL:()=>kI.filterPixelShaderWGSL,fluidRenderingBilateralBlurPixelShader:()=>oM.fluidRenderingBilateralBlurPixelShader,fluidRenderingBilateralBlurPixelShaderWGSL:()=>mM.fluidRenderingBilateralBlurPixelShaderWGSL,fluidRenderingParticleDepthPixelShader:()=>JI.fluidRenderingParticleDepthPixelShader,fluidRenderingParticleDepthPixelShaderWGSL:()=>cM.fluidRenderingParticleDepthPixelShaderWGSL,fluidRenderingParticleDepthVertexShader:()=>QI.fluidRenderingParticleDepthVertexShader,fluidRenderingParticleDepthVertexShaderWGSL:()=>lM.fluidRenderingParticleDepthVertexShaderWGSL,fluidRenderingParticleDiffusePixelShader:()=>rM.fluidRenderingParticleDiffusePixelShader,fluidRenderingParticleDiffusePixelShaderWGSL:()=>_M.fluidRenderingParticleDiffusePixelShaderWGSL,fluidRenderingParticleDiffuseVertexShader:()=>iM,fluidRenderingParticleDiffuseVertexShaderWGSL:()=>pM,fluidRenderingParticleThicknessPixelShader:()=>eM.fluidRenderingParticleThicknessPixelShader,fluidRenderingParticleThicknessPixelShaderWGSL:()=>dM.fluidRenderingParticleThicknessPixelShaderWGSL,fluidRenderingParticleThicknessVertexShader:()=>$I.fluidRenderingParticleThicknessVertexShader,fluidRenderingParticleThicknessVertexShaderWGSL:()=>uM.fluidRenderingParticleThicknessVertexShaderWGSL,fluidRenderingRenderPixelShader:()=>sM.fluidRenderingRenderPixelShader,fluidRenderingRenderPixelShaderWGSL:()=>vM.fluidRenderingRenderPixelShaderWGSL,fluidRenderingStandardBlurPixelShader:()=>aM.fluidRenderingStandardBlurPixelShader,fluidRenderingStandardBlurPixelShaderWGSL:()=>gM.fluidRenderingStandardBlurPixelShaderWGSL,fogFragmentDeclaration:()=>VA.fogFragmentDeclaration,fogFragmentDeclarationWGSL:()=>BA.fogFragmentDeclarationWGSL,fxaaPixelShader:()=>AI.fxaaPixelShader,fxaaPixelShaderWGSL:()=>RI.fxaaPixelShaderWGSL,fxaaVertexShader:()=>CI.fxaaVertexShader,fxaaVertexShaderWGSL:()=>II.fxaaVertexShaderWGSL,geometryPixelShader:()=>wR.geometryPixelShader,geometryPixelShaderWGSL:()=>DM.geometryPixelShaderWGSL,geometryVertexShader:()=>BR.geometryVertexShader,geometryVertexShaderWGSL:()=>NM.geometryVertexShaderWGSL,getRichTypeFromValue:()=>sS,glowBlurPostProcessPixelShader:()=>Kx.glowBlurPostProcessPixelShader,glowBlurPostProcessPixelShaderWGSL:()=>Jx.glowBlurPostProcessPixelShaderWGSL,glowMapGenerationPixelShader:()=>Wx.glowMapGenerationPixelShader,glowMapGenerationPixelShaderWGSL:()=>Yx.glowMapGenerationPixelShaderWGSL,glowMapGenerationVertexShader:()=>Hx.glowMapGenerationVertexShader,glowMapGenerationVertexShaderWGSL:()=>Xx.glowMapGenerationVertexShaderWGSL,glowMapMergePixelShader:()=>jx.glowMapMergePixelShader,glowMapMergePixelShaderWGSL:()=>Zx.glowMapMergePixelShaderWGSL,glowMapMergeVertexShader:()=>qx.glowMapMergeVertexShader,glowMapMergeVertexShaderWGSL:()=>Qx.glowMapMergeVertexShaderWGSL,grainPixelShader:()=>_I.grainPixelShader,grainPixelShaderWGSL:()=>mI.grainPixelShaderWGSL,hdrFilteringPixelShader:()=>QP.hdrFilteringPixelShader,hdrFilteringPixelShaderWGSL:()=>$P.hdrFilteringPixelShaderWGSL,hdrFilteringVertexShader:()=>ZP.hdrFilteringVertexShader,hdrFilteringVertexShaderWGSL:()=>JP.hdrFilteringVertexShaderWGSL,helperFunctions:()=>pA.helperFunctions,helperFunctionsWGSL:()=>JE.helperFunctionsWGSL,highlightsPixelShader:()=>zI.highlightsPixelShader,highlightsPixelShaderWGSL:()=>WI.highlightsPixelShaderWGSL,iblCombineVoxelGridsPixelShader:()=>oO.iblCombineVoxelGridsPixelShader,iblCombineVoxelGridsPixelShaderWGSL:()=>rO.iblCombineVoxelGridsPixelShaderWGSL,iblGenerateVoxelMipPixelShader:()=>aO.iblGenerateVoxelMipPixelShader,iblGenerateVoxelMipPixelShaderWGSL:()=>sO.iblGenerateVoxelMipPixelShaderWGSL,iblShadowAccumulationPixelShader:()=>tO.iblShadowAccumulationPixelShader,iblShadowAccumulationPixelShaderWGSL:()=>eO.iblShadowAccumulationPixelShaderWGSL,iblShadowDebugPixelShader:()=>ZM.iblShadowDebugPixelShader,iblShadowDebugPixelShaderWGSL:()=>QM.iblShadowDebugPixelShaderWGSL,iblShadowGBufferDebugPixelShader:()=>lO.iblShadowGBufferDebugPixelShader,iblShadowGBufferDebugPixelShaderWGSL:()=>cO.iblShadowGBufferDebugPixelShaderWGSL,iblShadowSpatialBlurPixelShader:()=>$M.iblShadowSpatialBlurPixelShader,iblShadowSpatialBlurPixelShaderWGSL:()=>JM.iblShadowSpatialBlurPixelShaderWGSL,iblShadowVoxelTracingPixelShader:()=>qM.iblShadowVoxelTracingPixelShader,iblShadowVoxelTracingPixelShaderWGSL:()=>KM.iblShadowVoxelTracingPixelShaderWGSL,iblShadowsCdfxPixelShader:()=>dO.iblShadowsCdfxPixelShader,iblShadowsCdfxPixelShaderWGSL:()=>uO.iblShadowsCdfxPixelShaderWGSL,iblShadowsCdfyPixelShader:()=>fO.iblShadowsCdfyPixelShader,iblShadowsCdfyPixelShaderWGSL:()=>hO.iblShadowsCdfyPixelShaderWGSL,iblShadowsCombinePixelShader:()=>nO.iblShadowsCombinePixelShader,iblShadowsCombinePixelShaderWGSL:()=>iO.iblShadowsCombinePixelShaderWGSL,iblShadowsIcdfxPixelShader:()=>_O.iblShadowsIcdfxPixelShader,iblShadowsIcdfxPixelShaderWGSL:()=>pO.iblShadowsIcdfxPixelShaderWGSL,iblShadowsIcdfyPixelShader:()=>gO.iblShadowsIcdfyPixelShader,iblShadowsIcdfyPixelShaderWGSL:()=>mO.iblShadowsIcdfyPixelShaderWGSL,iblShadowsImportanceSamplingDebugPixelShader:()=>yO.iblShadowsImportanceSamplingDebugPixelShader,iblShadowsImportanceSamplingDebugPixelShaderWGSL:()=>vO.iblShadowsImportanceSamplingDebugPixelShaderWGSL,iblVoxelGrid2dArrayDebugPixelShader:()=>bO.iblVoxelGrid2dArrayDebugPixelShader,iblVoxelGrid2dArrayDebugPixelShaderWGSL:()=>TO.iblVoxelGrid2dArrayDebugPixelShaderWGSL,iblVoxelGrid3dDebugPixelShader:()=>AO.iblVoxelGrid3dDebugPixelShader,iblVoxelGrid3dDebugPixelShaderWGSL:()=>CO.iblVoxelGrid3dDebugPixelShaderWGSL,iblVoxelGridPixelShader:()=>SO.iblVoxelGridPixelShader,iblVoxelGridPixelShaderWGSL:()=>xO.iblVoxelGridPixelShaderWGSL,iblVoxelGridVertexShader:()=>EO.iblVoxelGridVertexShader,iblVoxelGridVertexShaderWGSL:()=>PO.iblVoxelGridVertexShaderWGSL,iblVoxelSlabDebugPixelShader:()=>IO.iblVoxelSlabDebugPixelShader,iblVoxelSlabDebugPixelShaderWGSL:()=>OO.iblVoxelSlabDebugPixelShaderWGSL,iblVoxelSlabDebugVertexShader:()=>RO.iblVoxelSlabDebugVertexShader,iblVoxelSlabDebugVertexShaderWGSL:()=>MO.iblVoxelSlabDebugVertexShaderWGSL,imageProcessingDeclaration:()=>_A.imageProcessingDeclaration,imageProcessingDeclarationWGSL:()=>hA.imageProcessingDeclarationWGSL,imageProcessingFunctions:()=>mA.imageProcessingFunctions,imageProcessingFunctionsWGSL:()=>fA.imageProcessingFunctionsWGSL,imageProcessingPixelShader:()=>fI.imageProcessingPixelShader,imageProcessingPixelShaderWGSL:()=>hI.imageProcessingPixelShaderWGSL,importAnimationsAsync:()=>Ox,inlineScheduler:()=>Sa,kernelBlurPixelShader:()=>nI.kernelBlurPixelShader,kernelBlurPixelShaderWGSL:()=>rI.kernelBlurPixelShaderWGSL,kernelBlurVertexShader:()=>iI.kernelBlurVertexShader,kernelBlurVertexShaderWGSL:()=>oI.kernelBlurVertexShaderWGSL,layerPixelShader:()=>$x.layerPixelShader,layerPixelShaderWGSL:()=>tP.layerPixelShaderWGSL,layerVertexShader:()=>eP.layerVertexShader,layerVertexShaderWGSL:()=>nP.layerVertexShaderWGSL,lensFlarePixelShader:()=>iP.lensFlarePixelShader,lensFlarePixelShaderWGSL:()=>oP.lensFlarePixelShaderWGSL,lensFlareVertexShader:()=>rP.lensFlareVertexShader,lensFlareVertexShaderWGSL:()=>aP.lensFlareVertexShaderWGSL,lightFragment:()=>XA.lightFragment,lightFragmentDeclaration:()=>YA.lightFragmentDeclaration,lightFragmentWGSL:()=>UA.lightFragmentWGSL,lightUboDeclaration:()=>jA.lightUboDeclaration,lightUboDeclarationWGSL:()=>GA.lightUboDeclarationWGSL,lightVxFragmentDeclaration:()=>KA.lightVxFragmentDeclaration,lightVxUboDeclaration:()=>qA.lightVxUboDeclaration,lightVxUboDeclarationWGSL:()=>kA.lightVxUboDeclarationWGSL,lightsFragmentFunctions:()=>ZA.lightsFragmentFunctions,lightsFragmentFunctionsWGSL:()=>zA.lightsFragmentFunctionsWGSL,linePixelShader:()=>VM.linePixelShader,linePixelShaderWGSL:()=>GM.linePixelShaderWGSL,lineVertexShader:()=>UM.lineVertexShader,lineVertexShaderWGSL:()=>kM.lineVertexShaderWGSL,loadAssetContainerAsync:()=>Rx,loadSceneAsync:()=>xx,makeAsyncFunction:()=>FS,makeSyncFunction:()=>X_,meshUVSpaceRendererFinaliserPixelShader:()=>FC.meshUVSpaceRendererFinaliserPixelShader,meshUVSpaceRendererFinaliserPixelShaderWGSL:()=>kC.meshUVSpaceRendererFinaliserPixelShaderWGSL,meshUVSpaceRendererFinaliserVertexShader:()=>wC.meshUVSpaceRendererFinaliserVertexShader,meshUVSpaceRendererFinaliserVertexShaderWGSL:()=>zC.meshUVSpaceRendererFinaliserVertexShaderWGSL,meshUVSpaceRendererMaskerPixelShader:()=>LC.meshUVSpaceRendererMaskerPixelShader,meshUVSpaceRendererMaskerPixelShaderWGSL:()=>GC.meshUVSpaceRendererMaskerPixelShaderWGSL,meshUVSpaceRendererMaskerVertexShader:()=>NC.meshUVSpaceRendererMaskerVertexShader,meshUVSpaceRendererMaskerVertexShaderWGSL:()=>UC.meshUVSpaceRendererMaskerVertexShaderWGSL,meshUVSpaceRendererPixelShader:()=>DC.meshUVSpaceRendererPixelShader,meshUVSpaceRendererPixelShaderWGSL:()=>VC.meshUVSpaceRendererPixelShaderWGSL,meshUVSpaceRendererVertexShader:()=>OC.meshUVSpaceRendererVertexShader,meshUVSpaceRendererVertexShaderWGSL:()=>BC.meshUVSpaceRendererVertexShaderWGSL,morphTargetsVertex:()=>lA.morphTargetsVertex,morphTargetsVertexDeclaration:()=>cA.morphTargetsVertexDeclaration,morphTargetsVertexDeclarationWGSL:()=>oA.morphTargetsVertexDeclarationWGSL,morphTargetsVertexGlobal:()=>uA.morphTargetsVertexGlobal,morphTargetsVertexGlobalDeclaration:()=>dA.morphTargetsVertexGlobalDeclaration,morphTargetsVertexGlobalDeclarationWGSL:()=>sA.morphTargetsVertexGlobalDeclarationWGSL,morphTargetsVertexGlobalWGSL:()=>aA.morphTargetsVertexGlobalWGSL,morphTargetsVertexWGSL:()=>rA.morphTargetsVertexWGSL,motionBlurPixelShader:()=>VI.motionBlurPixelShader,motionBlurPixelShaderWGSL:()=>UI.motionBlurPixelShaderWGSL,nativeOverride:()=>V.Cx,normalizeEnvInfo:()=>ni.RZ,oitBackBlendPixelShader:()=>DO.oitBackBlendPixelShader,oitBackBlendPixelShaderWGSL:()=>LO.oitBackBlendPixelShaderWGSL,oitFinalPixelShader:()=>NO.oitFinalPixelShader,oitFinalPixelShaderWGSL:()=>FO.oitFinalPixelShaderWGSL,outlinePixelShader:()=>zM.outlinePixelShader,outlinePixelShaderWGSL:()=>HM.outlinePixelShaderWGSL,outlineVertexShader:()=>WM.outlineVertexShader,outlineVertexShaderWGSL:()=>YM.outlineVertexShaderWGSL,packingFunctions:()=>CA.packingFunctions,packingFunctionsWGSL:()=>xA.packingFunctionsWGSL,particlesPixelShader:()=>iR.particlesPixelShader,particlesPixelShaderWGSL:()=>oR.particlesPixelShaderWGSL,particlesVertexShader:()=>rR.particlesVertexShader,particlesVertexShaderWGSL:()=>aR.particlesVertexShaderWGSL,passCubePixelShader:()=>sI.passCubePixelShader,passCubePixelShaderWGSL:()=>cI.passCubePixelShaderWGSL,passPixelShader:()=>aI.passPixelShader,passPixelShaderWGSL:()=>lI.passPixelShaderWGSL,pbrPixelShader:()=>LP.pbrPixelShader,pbrPixelShaderWGSL:()=>DP.pbrPixelShaderWGSL,pbrVertexShader:()=>NP.pbrVertexShader,pbrVertexShaderWGSL:()=>OP.pbrVertexShaderWGSL,pickingPixelShader:()=>uE.pickingPixelShader,pickingPixelShaderWGSL:()=>hE.pickingPixelShaderWGSL,pickingVertexShader:()=>dE.pickingVertexShader,pickingVertexShaderWGSL:()=>fE.pickingVertexShaderWGSL,postprocessVertexShader:()=>eI.postprocessVertexShader,postprocessVertexShaderWGSL:()=>tI.postprocessVertexShaderWGSL,prepareDefinesForClipPlanes:()=>tn.Eq,prepareStringDefinesForClipPlanes:()=>tn.tv,proceduralVertexShader:()=>KP.proceduralVertexShader,proceduralVertexShaderWGSL:()=>qP.proceduralVertexShaderWGSL,reflectionFunction:()=>eC.reflectionFunction,reflectionFunctionWGSL:()=>$A.reflectionFunctionWGSL,registerSceneLoaderPlugin:()=>Jg,registerTextureLoader:()=>la.kf,rgbdDecodePixelShader:()=>m1.rgbdDecodePixelShader,rgbdDecodePixelShaderWGSL:()=>v1.rgbdDecodePixelShaderWGSL,rgbdEncodePixelShader:()=>g1.rgbdEncodePixelShader,rgbdEncodePixelShaderWGSL:()=>y1.rgbdEncodePixelShaderWGSL,rsmFullGlobalIlluminationPixelShader:()=>PM.rsmFullGlobalIlluminationPixelShader,rsmFullGlobalIlluminationPixelShaderWGSL:()=>IM.rsmFullGlobalIlluminationPixelShaderWGSL,rsmGlobalIlluminationPixelShader:()=>xM.rsmGlobalIlluminationPixelShader,rsmGlobalIlluminationPixelShaderWGSL:()=>RM.rsmGlobalIlluminationPixelShaderWGSL,runCoroutine:()=>Ac,runCoroutineAsync:()=>Cs,runCoroutineSync:()=>As,screenSpaceReflection2BlurCombinerPixelShader:()=>KR.screenSpaceReflection2BlurCombinerPixelShader,screenSpaceReflection2BlurCombinerPixelShaderWGSL:()=>JR.screenSpaceReflection2BlurCombinerPixelShaderWGSL,screenSpaceReflection2BlurPixelShader:()=>qR.screenSpaceReflection2BlurPixelShader,screenSpaceReflection2BlurPixelShaderWGSL:()=>QR.screenSpaceReflection2BlurPixelShaderWGSL,screenSpaceReflection2PixelShader:()=>jR.screenSpaceReflection2PixelShader,screenSpaceReflection2PixelShaderWGSL:()=>ZR.screenSpaceReflection2PixelShaderWGSL,serialize:()=>V.lK,serializeAsCameraReference:()=>V.fW,serializeAsColor3:()=>V.jT,serializeAsColor4:()=>V.qK,serializeAsColorCurves:()=>V.wL,serializeAsFresnelParameters:()=>V.Y9,serializeAsImageProcessingConfiguration:()=>V.n1,serializeAsMatrix:()=>V.GG,serializeAsMeshReference:()=>V.xG,serializeAsQuaternion:()=>V.bR,serializeAsTexture:()=>V.uM,serializeAsVector2:()=>V.WM,serializeAsVector3:()=>V.P_,setAndStartTimer:()=>rs,setStereoscopicAnaglyphRigMode:()=>Ia,setStereoscopicRigMode:()=>Ma,setVRRigMode:()=>Fs,shadowMapFragment:()=>RA.shadowMapFragment,shadowMapFragmentSoftTransparentShadow:()=>gP.shadowMapFragmentSoftTransparentShadow,shadowMapFragmentSoftTransparentShadowWGSL:()=>fP.shadowMapFragmentSoftTransparentShadowWGSL,shadowMapFragmentWGSL:()=>PA.shadowMapFragmentWGSL,shadowMapPixelShader:()=>pP.shadowMapPixelShader,shadowMapPixelShaderWGSL:()=>uP.shadowMapPixelShaderWGSL,shadowMapVertexMetric:()=>AA.shadowMapVertexMetric,shadowMapVertexMetricWGSL:()=>EA.shadowMapVertexMetricWGSL,shadowMapVertexShader:()=>_P.shadowMapVertexShader,shadowMapVertexShaderWGSL:()=>dP.shadowMapVertexShaderWGSL,shadowsFragmentFunctions:()=>QA.shadowsFragmentFunctions,shadowsFragmentFunctionsWGSL:()=>WA.shadowsFragmentFunctionsWGSL,shadowsVertex:()=>JA.shadowsVertex,shadowsVertexWGSL:()=>HA.shadowsVertexWGSL,sharpenPixelShader:()=>UR.sharpenPixelShader,sharpenPixelShaderWGSL:()=>pI.sharpenPixelShaderWGSL,spritesPixelShader:()=>VO.spritesPixelShader,spritesPixelShaderWGSL:()=>GO.spritesPixelShaderWGSL,spritesVertexShader:()=>UO.spritesVertexShader,spritesVertexShaderWGSL:()=>kO.spritesVertexShaderWGSL,ssao2PixelShader:()=>HR.ssao2PixelShader,ssao2PixelShaderWGSL:()=>YR.ssao2PixelShaderWGSL,ssaoCombinePixelShader:()=>zR.ssaoCombinePixelShader,ssaoCombinePixelShaderWGSL:()=>XR.ssaoCombinePixelShaderWGSL,tonemapPixelShader:()=>XI.tonemapPixelShader,tonemapPixelShaderWGSL:()=>jI.tonemapPixelShaderWGSL,unregisterTextureLoader:()=>la.hy,vrDistortionCorrectionPixelShader:()=>uI.vrDistortionCorrectionPixelShader,vrDistortionCorrectionPixelShaderWGSL:()=>dI.vrDistortionCorrectionPixelShaderWGSL});var wr={};L.r(wr),L.d(wr,{AbstractActionManager:()=>Ne.G,AbstractAssetTask:()=>Rr,AbstractEngine:()=>Be.$,AbstractMesh:()=>cn,AbstractScene:()=>nt.d,AcquireNativeObjectAsync:()=>Eg,Action:()=>me,ActionEvent:()=>Se.X,ActionManager:()=>it,AddBlock:()=>dy,AddressMode:()=>od,AdvancedTimer:()=>dv,AlignBlock:()=>ib,AlphaState:()=>zO.i,AmmoJSPlugin:()=>gh,AnaglyphArcRotateCamera:()=>Tm,AnaglyphFreeCamera:()=>Sm,AnaglyphGamepadCamera:()=>Em,AnaglyphPostProcess:()=>au,AnaglyphUniversalCamera:()=>xm,Analyser:()=>BS,AndOrNotEvaluator:()=>HO.Z,Angle:()=>Ge.uM,Animatable:()=>bt,AnimatedInputBlockTypes:()=>jr,Animation:()=>Le,AnimationAssetTask:()=>YO,AnimationEvent:()=>xs,AnimationGroup:()=>wi,AnimationGroupMask:()=>LS,AnimationGroupMaskMode:()=>Ao,AnimationKeyInterpolation:()=>Rt,AnimationPropertiesOverride:()=>wt,AnimationRange:()=>kt,AnisotropyBlock:()=>Nh,ApplyLut:()=>Uo.Kq,ApplyPostProcess:()=>Si.Qs,Arc2:()=>Ge.Xy,ArcFollowCamera:()=>iu,ArcRotateCamera:()=>zr,ArcRotateCameraGamepadInput:()=>Lc,ArcRotateCameraInputsManager:()=>Os,ArcRotateCameraKeyboardMoveInput:()=>Fc,ArcRotateCameraMouseWheelInput:()=>wc,ArcRotateCameraPointersInput:()=>Bc,ArcRotateCameraVRDeviceOrientationInput:()=>Vc,ArcTan2Block:()=>Dy,AssetContainer:()=>tm,AssetTaskState:()=>Qf,AssetsManager:()=>XO,AssetsProgressEvent:()=>OT,AsyncLock:()=>_1,AsyncLoop:()=>ze.LV,AttachToBoxBehavior:()=>HS,AudioEngine:()=>nm,AudioSceneComponent:()=>nr,AutoLayoutMode:()=>md,AutoReleaseWorkerPool:()=>Il.h,AutoRotationBehavior:()=>rm,AxesViewer:()=>ia,Axis:()=>Ge._0,AxisDragGizmo:()=>Yr,AxisScaleGizmo:()=>Ha,BRDFTextureTools:()=>mx,BabylonFileLoaderConfiguration:()=>El,BackEase:()=>Yn,BackgroundMaterial:()=>ja,BakedVertexAnimationManager:()=>US,BallAndSocketConstraint:()=>gR,BaseCameraMouseWheelInput:()=>dm,BaseCameraPointersInput:()=>Nc,BaseError:()=>Bi.Cf,BaseParticleSystem:()=>Ei,BaseSixDofDragBehavior:()=>Dc,BaseTexture:()=>Ki.t,BasisFileInfo:()=>Hi.$e,BasisTools:()=>Hi.ED,BasisToolsOptions:()=>Hi.Sl,BasisTranscodeConfiguration:()=>Hi.SV,BezierCurve:()=>Ge.vr,BezierCurveEase:()=>fr,BiPlanarBlock:()=>t0,BinaryFileAssetTask:()=>FT,BindBonesParameters:()=>Re.f$,BindFogParameters:()=>Re.Yy,BindLight:()=>Re.Kd,BindLightProperties:()=>Re.L0,BindLights:()=>Re.RL,BindLogDepth:()=>Re.DL,BindMorphTargetParameters:()=>Re.nR,BindSceneUniformBuffer:()=>Re._8,BindTextureMatrix:()=>Re.mA,BlackAndWhitePostProcess:()=>eT,BlendFactor:()=>Td,BlendOperation:()=>Sd,BloomEffect:()=>Lf,BloomMergePostProcess:()=>Nf,BlurPostProcess:()=>ci,Bone:()=>Ct,BoneAxesViewer:()=>Au,BoneIKController:()=>QS,BoneLookController:()=>JS,BonesBlock:()=>Gv,BooleanGeometryBlock:()=>Sb,BooleanGeometryOperations:()=>Cr,BounceEase:()=>Kt,BouncingBehavior:()=>om,BoundingBlock:()=>Tb,BoundingBox:()=>To,BoundingBoxGizmo:()=>Fg,BoundingBoxRenderer:()=>gT,BoundingInfo:()=>tr,BoundingInfoHelper:()=>pE,BoundingSphere:()=>Zo,BoxBlock:()=>sf,BoxBuilder:()=>vE,BoxParticleEmitter:()=>Go,Buffer:()=>Y.h,BufferBindingType:()=>ud,BufferMapState:()=>Ju,BufferUsage:()=>nn,CSG:()=>jh,Camera:()=>Pt,CameraGizmo:()=>px,CameraInputTypes:()=>oi,CameraInputsManager:()=>Ca,CannonJSPlugin:()=>Sl,CanvasAlphaMode:()=>Dd,CapsuleBlock:()=>O0,CapsuleBuilder:()=>EE,CascadedShadowGenerator:()=>fh,ChromaticAberrationPostProcess:()=>Ff,CircleEase:()=>xn,CircleOfConfusionPostProcess:()=>wf,ClampBlock:()=>fy,ClearCoatBlock:()=>Al,ClipPlanesBlock:()=>sy,ClipboardEventTypes:()=>ll,ClipboardInfo:()=>ux,CloudBlock:()=>Jy,CloudPoint:()=>Kb,Collider:()=>Zm,Color3:()=>Ge.v9,Color3Gradient:()=>Yb,Color4:()=>Ge.ov,ColorCorrectionPostProcess:()=>tT,ColorCurves:()=>AP.Q,ColorGradient:()=>pf,ColorGradingTexture:()=>Fv,ColorMergerBlock:()=>vy,ColorSplitterBlock:()=>rh,ColorWrite:()=>bd,CombineAction:()=>Ae,CompareFunction:()=>ld,CompatibilityOptions:()=>Xt.p9,CompilationMessageType:()=>pd,CompleteGreasedLineColorTable:()=>T0,CompleteGreasedLineWidthTable:()=>b0,CompressionCodes:()=>Mn.he,ComputeBindingType:()=>Xu,ComputeEffect:()=>$m,ComputeNormalsBlock:()=>j0,ComputePassTimestampLocation:()=>Cd,ComputeShader:()=>eg.H,ComputeShaderBoundingHelper:()=>mE.ComputeShaderBoundingHelper,ComputeShaderParticleSystem:()=>Hb,Condition:()=>ne,ConditionBlock:()=>k0,ConditionBlockTests:()=>Kn,ConditionalBlock:()=>Qy,ConditionalBlockConditions:()=>Zi,ConeDirectedParticleEmitter:()=>lf,ConeParticleEmitter:()=>Ol,Constants:()=>P.Y,ContainerAssetTask:()=>DT,ConversionMode:()=>qf,ConvolutionPostProcess:()=>nT,Coordinate:()=>Ge.xp,CopyFloatData:()=>Z_,CopyTextureToTexture:()=>RT,CopyTools:()=>Ho.D8,CreateBox:()=>Oi,CreateBoxVertexData:()=>Ys,CreateCapsule:()=>Fa,CreateCapsuleVertexData:()=>js,CreateCylinder:()=>_i,CreateCylinderVertexData:()=>Ws,CreateDashedLines:()=>Zs,CreateDashedLinesVertexData:()=>wu,CreateDecal:()=>el,CreateDecoderAsync:()=>Ph.d,CreateDisc:()=>ra,CreateDiscVertexData:()=>qs,CreateEnvTextureAsync:()=>ni.Hx,CreateGeodesic:()=>og,CreateGoldberg:()=>sg,CreateGoldbergVertexData:()=>ag,CreateGreasedLine:()=>AC,CreateGreasedLineMaterial:()=>v0,CreateGround:()=>ta,CreateGroundFromHeightMap:()=>ks,CreateGroundFromHeightMapVertexData:()=>Su,CreateGroundVertexData:()=>Wr,CreateHemisphere:()=>Xa,CreateIcoSphere:()=>sa,CreateIcoSphereVertexData:()=>$s,CreateImageBitmapFromSource:()=>fu,CreateImageDataArrayBufferViews:()=>ni.$h,CreateLathe:()=>Qs,CreateLineSystem:()=>Do,CreateLineSystemVertexData:()=>Fu,CreateLines:()=>dn,CreatePlane:()=>Ur,CreatePlaneVertexData:()=>Is,CreatePolygon:()=>wa,CreatePolygonVertexData:()=>Bu,CreatePolyhedron:()=>No,CreatePolyhedronVertexData:()=>Vu,CreateResizedCopy:()=>Si.EE,CreateRibbon:()=>oo,CreateRibbonVertexData:()=>Iu,CreateScreenshot:()=>vs,CreateScreenshotAsync:()=>tp,CreateScreenshotUsingRenderTarget:()=>ys,CreateScreenshotUsingRenderTargetAsync:()=>np,CreateScreenshotWithResizeAsync:()=>XT,CreateSegmentedBoxVertexData:()=>ng,CreateSphere:()=>li,CreateSphereVertexData:()=>Xs,CreateText:()=>lg,CreateTextShapePaths:()=>zu,CreateTiledBox:()=>Du,CreateTiledBoxVertexData:()=>Ou,CreateTiledGround:()=>Gs,CreateTiledGroundVertexData:()=>Tu,CreateTiledPlane:()=>Mu,CreateTiledPlaneVertexData:()=>oa,CreateTorus:()=>Sr,CreateTorusKnot:()=>Ks,CreateTorusKnotVertexData:()=>Nu,CreateTorusVertexData:()=>zs,CreateTube:()=>Js,CrossBlock:()=>py,CubeMapToSphericalPolynomialTools:()=>Av.d,CubeTexture:()=>mr,CubeTextureAssetTask:()=>VT,CubicEase:()=>Sn,CullMode:()=>yd,CurrentScreenBlock:()=>Jd,Curve3:()=>Ge.jj,CurveBlock:()=>o0,CurveBlockTypes:()=>_n,CustomBlock:()=>_y,CustomOptimization:()=>WT,CustomParticleEmitter:()=>ko,CustomProceduralTexture:()=>Vv,CylinderBlock:()=>M0,CylinderBuilder:()=>gE,CylinderDirectedParticleEmitter:()=>cf,CylinderParticleEmitter:()=>Dl,DDSTools:()=>gg.D,DataBuffer:()=>$o.n,DataReader:()=>i1,DataStorage:()=>r1,Database:()=>kb,Debug:()=>lL,DebugBlock:()=>fb,DebugLayer:()=>Cu,DebugLayerTab:()=>Hs,DecalBuilder:()=>UE,DecalMapConfiguration:()=>Rl,DecalMapDefines:()=>a0,Decode:()=>fi.Tq,DecodeBase64ToBinary:()=>fi.yS,DecodeBase64ToString:()=>fi.AV,DecodeBase64UrlToBinary:()=>hn.rz,DecodeBase64UrlToString:()=>hn.dy,DecodeFloat32:()=>Mn.Sn,DecodeRunLength:()=>GP._,DeepCopier:()=>ot.r,DefaultCollisionCoordinator:()=>Qm,DefaultKTX2DecoderOptions:()=>rp.$,DefaultLoadingScreen:()=>xv,DefaultRenderingPipeline:()=>uT,Deferred:()=>kT,DepthCullingState:()=>Og.N,DepthOfFieldBlurPostProcess:()=>wl,DepthOfFieldEffect:()=>Vf,DepthOfFieldEffectBlurLevel:()=>Bf,DepthOfFieldMergePostProcess:()=>iT,DepthPeelingRenderer:()=>yT,DepthPeelingSceneComponent:()=>bT,DepthReducer:()=>Sv,DepthRenderer:()=>ls,DepthRendererSceneComponent:()=>vT,DepthSortedParticle:()=>jb,DerivativeBlock:()=>jv,DesaturateBlock:()=>Xy,DetailMapConfiguration:()=>Bs,DeviceInputEventType:()=>Aa.b,DeviceLostReason:()=>Nd,DeviceOrientationCamera:()=>Ds,DeviceSource:()=>GE.c,DeviceSourceManager:()=>kE.Z,DeviceType:()=>rr.bq,DirectionalLight:()=>Ya,DirectionalLightFrustumViewer:()=>dg,DiscBlock:()=>D0,DiscBuilder:()=>PE,DiscardBlock:()=>Yv,DisplayPassPostProcess:()=>rT,DistanceBlock:()=>Cy,DistanceConstraint:()=>vR,DistanceJoint:()=>bE,DivideBlock:()=>Ty,DoNothingAction:()=>Pe,DomManagement:()=>bi.Az,DotBlock:()=>my,DracoCompression:()=>vC,DrawWrapper:()=>jn.E,DualSenseInput:()=>rr.pI,DualShockButton:()=>ru,DualShockDpad:()=>ou,DualShockInput:()=>rr.h8,DualShockPad:()=>vm,DumpTools:()=>Hl.e9,DynamicFloat32Array:()=>ho,DynamicTexture:()=>Oo,EXROutputType:()=>xh.V,EasingFunction:()=>Wt,EdgesRenderer:()=>Yf,Effect:()=>ti.M,EffectFallbacks:()=>Tr,EffectLayer:()=>as,EffectLayerSceneComponent:()=>_v,EffectRenderer:()=>Ni.J,EffectWrapper:()=>Ni.$,ElasticEase:()=>Gn,ElbowBlock:()=>e0,EncodeArrayBufferToBase64:()=>fi.EL,EndsWith:()=>fi.jq,Engine:()=>Zt,EngineFactory:()=>cx,EngineFormat:()=>fs.GQ,EngineInstrumentation:()=>fv,EngineStore:()=>Ve.q,EngineView:()=>zE,EnvironmentHelper:()=>kd,EnvironmentTextureTools:()=>ni.qY,Epsilon:()=>Ge.bH,EquiRectangularCubeTexture:()=>Bv,EquiRectangularCubeTextureAssetTask:()=>GT,ErrorCodes:()=>Bi.tG,ErrorFilter:()=>Ld,EventConstants:()=>Aa.s,EventState:()=>K.qO,ExecuteCodeAction:()=>Ue,ExitFullscreen:()=>mu,ExitPointerlock:()=>gu,ExponentialEase:()=>Xn,ExrLoaderGlobalConfiguration:()=>xh.u,ExternalTexture:()=>Vd,ExtractHighlightsPostProcess:()=>Df,ExtrudePolygon:()=>Ba,ExtrudeShape:()=>Va,ExtrudeShapeCustom:()=>Ua,FactorGradient:()=>_f,FadeInOutBehavior:()=>YS,FeatureName:()=>Qu,FileTools:()=>hn.wS,FileToolsOptions:()=>hn.eC,FilesInput:()=>qO,FilesInputStore:()=>zT.T,FilterMode:()=>ad,FilterPostProcess:()=>oT,FlowGraph:()=>hp,FlowGraphAbsBlock:()=>Np,FlowGraphAcosBlock:()=>r_,FlowGraphAcoshBlock:()=>d_,FlowGraphAddBlock:()=>Ep,FlowGraphAsinBlock:()=>i_,FlowGraphAsinhBlock:()=>u_,FlowGraphAtan2Block:()=>a_,FlowGraphAtanBlock:()=>o_,FlowGraphAtanhBlock:()=>h_,FlowGraphBitwiseAndBlock:()=>M_,FlowGraphBitwiseLeftShiftBlock:()=>N_,FlowGraphBitwiseNotBlock:()=>I_,FlowGraphBitwiseOrBlock:()=>O_,FlowGraphBitwiseRightShiftBlock:()=>L_,FlowGraphBitwiseXorBlock:()=>D_,FlowGraphBlock:()=>_o,FlowGraphBranchBlock:()=>hS,FlowGraphCeilBlock:()=>Bp,FlowGraphClampBlock:()=>Wp,FlowGraphConditionalDataBlock:()=>xS,FlowGraphConnection:()=>cc,FlowGraphConnectionType:()=>lp,FlowGraphConsoleLogBlock:()=>fp,FlowGraphConstantBlock:()=>AS,FlowGraphContext:()=>up,FlowGraphContextLogger:()=>M1,FlowGraphCoordinateTransformBlock:()=>PS,FlowGraphCoordinator:()=>I1,FlowGraphCosBlock:()=>t_,FlowGraphCoshBlock:()=>l_,FlowGraphCountLeadingZerosBlock:()=>F_,FlowGraphCountOneBitsBlock:()=>B_,FlowGraphCountTrailingZerosBlock:()=>w_,FlowGraphCounterBlock:()=>yS,FlowGraphCrossBlock:()=>S_,FlowGraphCubeRootBlock:()=>v_,FlowGraphDataConnection:()=>dc,FlowGraphDebounceBlock:()=>bS,FlowGraphDegToRadBlock:()=>Jp,FlowGraphDeterminantBlock:()=>A_,FlowGraphDivideBlock:()=>Ap,FlowGraphDoNBlock:()=>mp,FlowGraphDotBlock:()=>Rp,FlowGraphEBlock:()=>Ip,FlowGraphEqBlock:()=>Xp,FlowGraphEventBlock:()=>ga,FlowGraphExecutionBlock:()=>Mr,FlowGraphExpBlock:()=>f_,FlowGraphFlipFlopBlock:()=>TS,FlowGraphFloorBlock:()=>wp,FlowGraphForLoopBlock:()=>fS,FlowGraphFractBlock:()=>Vp,FlowGraphGetPropertyBlock:()=>Tp,FlowGraphGetVariableBlock:()=>bp,FlowGraphGreaterThanBlock:()=>Kp,FlowGraphGreaterThanOrEqualBlock:()=>Zp,FlowGraphInfBlock:()=>Op,FlowGraphInterpolateBlock:()=>Yp,FlowGraphInvertMatrixBlock:()=>C_,FlowGraphIsInfBlock:()=>U1,FlowGraphIsNanBlock:()=>Qp,FlowGraphLengthBlock:()=>b_,FlowGraphLessThanBlock:()=>qp,FlowGraphLessThanOrEqualBlock:()=>V1,FlowGraphLog10Block:()=>m_,FlowGraphLog2Block:()=>__,FlowGraphLogBlock:()=>p_,FlowGraphLogicAndBlock:()=>CS,FlowGraphLogicNotBlock:()=>IS,FlowGraphLogicOrBlock:()=>RS,FlowGraphMatMulBlock:()=>R_,FlowGraphMaxBlock:()=>zp,FlowGraphMeshPickEventBlock:()=>fc,FlowGraphMinBlock:()=>kp,FlowGraphMultiGateBlock:()=>mS,FlowGraphMultiplyBlock:()=>Pp,FlowGraphNaNBlock:()=>Dp,FlowGraphNegBlock:()=>Up,FlowGraphNormalizeBlock:()=>T_,FlowGraphPauseAnimationBlock:()=>ES,FlowGraphPiBlock:()=>Mp,FlowGraphPlayAnimationBlock:()=>yp,FlowGraphPowBlock:()=>y_,FlowGraphRadToDegBlock:()=>$p,FlowGraphRandomBlock:()=>Cp,FlowGraphReceiveCustomEventBlock:()=>V_,FlowGraphRemainderBlock:()=>Gp,FlowGraphRotate2DBlock:()=>E_,FlowGraphRotate3DBlock:()=>x_,FlowGraphSaturateBlock:()=>Hp,FlowGraphSceneReadyEventBlock:()=>OS,FlowGraphSceneTickEventBlock:()=>U_,FlowGraphSendCustomEventBlock:()=>dS,FlowGraphSequenceBlock:()=>vp,FlowGraphSetPropertyBlock:()=>uS,FlowGraphSetVariableBlock:()=>pp,FlowGraphSignBlock:()=>Lp,FlowGraphSignalConnection:()=>hc,FlowGraphSinBlock:()=>e_,FlowGraphSinhBlock:()=>s_,FlowGraphSqrtBlock:()=>g_,FlowGraphState:()=>dp,FlowGraphStopAnimationBlock:()=>SS,FlowGraphSubtractBlock:()=>xp,FlowGraphSwitchBlock:()=>gS,FlowGraphTanBlock:()=>n_,FlowGraphTanhBlock:()=>c_,FlowGraphThrottleBlock:()=>pS,FlowGraphTimerBlock:()=>_S,FlowGraphTransposeBlock:()=>P_,FlowGraphTruncBlock:()=>Fp,FlowGraphWaitAllBlock:()=>vS,FlowGraphWhileLoopBlock:()=>gp,FluidRenderer:()=>MT,FluidRendererSceneComponent:()=>IT,FluidRenderingDebug:()=>Xf,FluidRenderingObject:()=>jf,FluidRenderingObjectCustomParticles:()=>CT,FluidRenderingObjectParticleSystem:()=>PT,FluidRenderingTargetRenderer:()=>Kf,FlyCamera:()=>_m,FlyCameraInputsManager:()=>pm,FlyCameraKeyboardInput:()=>Uc,FlyCameraMouseInput:()=>Gc,FogBlock:()=>ny,FollowBehavior:()=>KS,FollowCamera:()=>nu,FollowCameraInputsManager:()=>mm,FollowCameraKeyboardMoveInput:()=>kc,FollowCameraMouseWheelInput:()=>zc,FollowCameraPointersInput:()=>Wc,FragCoordBlock:()=>qv,FragDepthBlock:()=>$v,FragmentOutputBlock:()=>ca,FramingBehavior:()=>am,FreeCamera:()=>_r,FreeCameraDeviceOrientationInput:()=>qc,FreeCameraGamepadInput:()=>Kc,FreeCameraInputsManager:()=>Ra,FreeCameraKeyboardMoveInput:()=>Hc,FreeCameraMouseInput:()=>Yc,FreeCameraMouseWheelInput:()=>Xc,FreeCameraTouchInput:()=>jc,FreeCameraVirtualJoystickInput:()=>Jc,FresnelBlock:()=>xy,FresnelParameters:()=>Dv,FromHalfFloat:()=>Si.SX,FrontFace:()=>vd,FrontFacingBlock:()=>Xv,Frustum:()=>Ge.PP,FxaaPostProcess:()=>ms,GIRSM:()=>bM,GIRSMManager:()=>TM,GIRSMRenderPluginMaterial:()=>ma,GPUParticleSystem:()=>zo,GPUPicker:()=>cE,GUID:()=>Eo.S,Gamepad:()=>Ii,GamepadCamera:()=>Ns,GamepadManager:()=>ym,GamepadSystemSceneComponent:()=>bm,GaussianSplattingMaterial:()=>Hh,GaussianSplattingMesh:()=>RC,GenerateBase64StringFromPixelData:()=>Ho.c9,GenerateBase64StringFromTexture:()=>Ho.lP,GenerateBase64StringFromTextureAsync:()=>Ho.nh,GenericPad:()=>hm,GeodesicData:()=>Gu,Geometry:()=>Vi,GeometryArcTan2Block:()=>Eb,GeometryBufferRenderer:()=>zn,GeometryBufferRendererSceneComponent:()=>aT,GeometryClampBlock:()=>Mb,GeometryCollectionBlock:()=>Y0,GeometryCrossBlock:()=>Ob,GeometryCurveBlock:()=>Db,GeometryCurveBlockTypes:()=>Ft,GeometryDesaturateBlock:()=>Nb,GeometryDistanceBlock:()=>wb,GeometryDotBlock:()=>Bb,GeometryElbowBlock:()=>X0,GeometryInfoBlock:()=>pb,GeometryInputBlock:()=>Nn,GeometryLengthBlock:()=>Vb,GeometryLerpBlock:()=>xb,GeometryModBlock:()=>Rb,GeometryNLerpBlock:()=>Pb,GeometryOptimizeBlock:()=>E0,GeometryOutputBlock:()=>af,GeometryPosterizeBlock:()=>Lb,GeometryPowBlock:()=>Ib,GeometryReplaceColorBlock:()=>Fb,GeometryRotate2dBlock:()=>Ub,GeometrySmoothStepBlock:()=>Cb,GeometryStepBlock:()=>Ab,GeometryTextureBlock:()=>yb,GeometryTextureFetchBlock:()=>bb,GeometryTransformBlock:()=>J0,GeometryTrigonometryBlock:()=>Q0,GeometryTrigonometryBlockOperations:()=>Ht,GetClass:()=>j.n9,GetClassName:()=>j.Uu,GetDOMTextContent:()=>bi.Zl,GetEnvInfo:()=>ni.cU,GetEnvironmentBRDFTexture:()=>qa,GetExrHeader:()=>kP.V,GetFogState:()=>Re.qL,GetFontOffset:()=>hu,GetInternalFormatFromBasisFormat:()=>Hi.yT,GetPointsCount:()=>y0,GetTGAHeader:()=>fa.O_,GetTextureDataAsync:()=>Si.Oz,Gizmo:()=>Jn,GizmoAnchorPoint:()=>xu,GizmoCoordinatesMode:()=>Pu,GizmoManager:()=>dx,GlowLayer:()=>vl,GoldbergMesh:()=>ku,GradientBlock:()=>Vy,GradientBlockColorStep:()=>Pl,GradientHelper:()=>Wi,GrainPostProcess:()=>Uf,GreasedLineBaseMesh:()=>Jh,GreasedLineMaterialDefaults:()=>ui,GreasedLineMesh:()=>$h,GreasedLineMeshColorDistribution:()=>ef,GreasedLineMeshColorDistributionType:()=>kh,GreasedLineMeshColorMode:()=>Gh,GreasedLineMeshMaterialType:()=>Uh,GreasedLineMeshWidthDistribution:()=>tf,GreasedLinePluginMaterial:()=>ha,GreasedLineRibbonAutoDirectionMode:()=>Qh,GreasedLineRibbonFacesMode:()=>Zh,GreasedLineRibbonMesh:()=>Ml,GreasedLineRibbonPointsMode:()=>Kh,GreasedLineSimpleMaterial:()=>zh,GreasedLineTools:()=>On,GridBlock:()=>R0,GroundBuilder:()=>oE,GroundMesh:()=>Us,HDRCubeTexture:()=>bl,HDRCubeTextureAssetTask:()=>UT,HDRFiltering:()=>ph,HDRTools:()=>Pv.I9,Halton2DSequence:()=>c0,HandConstraintBehavior:()=>ZS,HandConstraintOrientation:()=>Mc,HandConstraintVisibility:()=>Oc,HandConstraintZone:()=>Ic,HandPart:()=>sh,HandleFallbacksForShadows:()=>Re.c4,HardwareScalingOptimization:()=>Jf,HavokPlugin:()=>MR,HeightToNormalBlock:()=>Jv,HemisphereBuilder:()=>hx,HemisphericLight:()=>na,HemisphericParticleEmitter:()=>uf,HighlightLayer:()=>uh,HighlightsPostProcess:()=>FR,Hinge2Joint:()=>SE,HingeConstraint:()=>yR,HingeJoint:()=>TE,HtmlElementTexture:()=>FP,HufUncompress:()=>Uo.ZR,IWebXRControllerPhysicsOptions:()=>S1,IblShadowsRenderPipeline:()=>qI,IcoSphereBlock:()=>A0,IcoSphereBuilder:()=>BE,ImageAssetTask:()=>wT,ImageProcessingBlock:()=>Wv,ImageProcessingConfiguration:()=>Ti.p,ImageProcessingPostProcess:()=>Gf,ImageSourceBlock:()=>sr,IncrementValueAction:()=>he,IndexFormat:()=>xd,InputBlock:()=>Mt,InspectableType:()=>ip,InstancedLinesMesh:()=>Lu,InstancedMesh:()=>Co,InstancesBlock:()=>kv,InstantiateBlock:()=>cb,InstantiateLinearBlock:()=>ub,InstantiateOnFacesBlock:()=>ab,InstantiateOnVerticesBlock:()=>ob,InstantiateOnVolumeBlock:()=>sb,InstantiateRadialBlock:()=>db,InstantiatedEntries:()=>em,IntFloatConverterBlock:()=>hb,InterleaveScalar:()=>Mn.KA,InternalTexture:()=>rn.h,InternalTextureSource:()=>rn.G,InterpolateValueAction:()=>Ye,IntersectionInfo:()=>Rs,IsBase64DataUrl:()=>hn.f2,IsDocumentAvailable:()=>bi.Nf,IsFileURL:()=>hn.my,IsNavigatorAvailable:()=>bi.XD,IsWindowObjectExist:()=>bi.BA,IsWrapper:()=>Yu.E,JoystickAxis:()=>Zc,KeepAssets:()=>$_,KeyboardEventTypes:()=>io.TB,KeyboardInfo:()=>io.W0,KeyboardInfoPre:()=>io.Bu,KhronosTextureContainer:()=>KO.H,KhronosTextureContainer2:()=>rp.Z,LatheBuilder:()=>LE,Layer:()=>gv,LayerSceneComponent:()=>mv,LengthBlock:()=>Ry,LensFlare:()=>vv,LensFlareSystem:()=>dh,LensFlareSystemSceneComponent:()=>yv,LensFlaresOptimization:()=>Gl,LensRenderingPipeline:()=>kR,LerpBlock:()=>by,Light:()=>hi,LightBlock:()=>iy,LightGizmo:()=>fx,LightInformationBlock:()=>zv,LineEdgesRenderer:()=>TT,LinesBuilder:()=>IE,LinesMesh:()=>aa,LoadFile:()=>hn.zU,LoadFileError:()=>hn.hX,LoadImage:()=>hn.W$,LoadImageConfiguration:()=>hn.qc,LoadOp:()=>Id,LoadTextureFromTranscodeResult:()=>Hi.aB,LockConstraint:()=>TR,Logger:()=>O.V,MapMode:()=>$u,MapRangeBlock:()=>G0,MappingBlock:()=>_b,MappingTypes:()=>Ar,Material:()=>Lt,MaterialAnisotropicDefines:()=>kg,MaterialClearCoatDefines:()=>Ug,MaterialDefines:()=>si,MaterialDetailMapDefines:()=>Gm,MaterialFlags:()=>$e,MaterialGreasedLineDefines:()=>s0,MaterialHelper:()=>CP,MaterialIridescenceDefines:()=>Gg,MaterialPluginBase:()=>qi,MaterialPluginEvent:()=>Vh,MaterialPluginManager:()=>Bm,MaterialSheenDefines:()=>zg,MaterialSubSurfaceDefines:()=>Wg,MathBlock:()=>U0,MathBlockOperations:()=>xi,Matrix:()=>Ge.uq,MatrixBuilderBlock:()=>Zy,MatrixComposeBlock:()=>mb,MatrixDeterminantBlock:()=>n0,MatrixTransposeBlock:()=>i0,MaxBlock:()=>Py,MergeGeometryBlock:()=>H0,MergeMeshesOptimization:()=>zl,Mesh:()=>xe,MeshAssetTask:()=>NT,MeshAttributeExistsBlock:()=>r0,MeshAttributeExistsBlockTypes:()=>Bh,MeshBlock:()=>P0,MeshBuilder:()=>cg,MeshDebugMode:()=>Wh,MeshDebugPluginMaterial:()=>l0,MeshExploder:()=>jO,MeshLODLevel:()=>J_,MeshParticleEmitter:()=>zb,MeshUVSpaceRenderer:()=>TC,MeshoptCompression:()=>yC,MinBlock:()=>Ay,MinMaxReducer:()=>Tv,MipmapFilterMode:()=>sd,MirrorTexture:()=>Gd,ModBlock:()=>Ky,ModelShape:()=>vf,MorphTarget:()=>Cv,MorphTargetManager:()=>Tl,MorphTargetsBlock:()=>Rh,MotionBlurPostProcess:()=>kf,MotorEnabledJoint:()=>Ru,MultiMaterial:()=>Vr,MultiObserver:()=>ZO,MultiPointerScaleBehavior:()=>jS,MultiRenderTarget:()=>Kr,MultiplyBlock:()=>ml,NLerpBlock:()=>Uy,NativeDataStream:()=>il,NativeEngine:()=>Ku,NativePointerInput:()=>rr.Ze,NativeXRFrame:()=>tS,NativeXRLayerRenderTargetTextureProvider:()=>jm,NativeXRLayerWrapper:()=>Xm,NativeXRRenderTarget:()=>qm,NegateBlock:()=>Iy,Node:()=>At,NodeGeometry:()=>CC,NodeGeometryBlock:()=>Tt,NodeGeometryBlockConnectionPointTypes:()=>se,NodeGeometryBuildState:()=>S0,NodeGeometryConnectionPoint:()=>of,NodeGeometryConnectionPointCompatibilityStates:()=>nf,NodeGeometryConnectionPointDirection:()=>rf,NodeGeometryContextualSources:()=>Qt,NodeMaterial:()=>so,NodeMaterialBlock:()=>ut,NodeMaterialBlockConnectionPointMode:()=>Ch,NodeMaterialBlockConnectionPointTypes:()=>G,NodeMaterialBlockTargets:()=>_e,NodeMaterialConnectionPoint:()=>pl,NodeMaterialConnectionPointCompatibilityStates:()=>Kd,NodeMaterialConnectionPointCustomObject:()=>bn,NodeMaterialConnectionPointDirection:()=>Zd,NodeMaterialDefines:()=>ts,NodeMaterialModes:()=>mi,NodeMaterialOptimizer:()=>tC,NodeMaterialSystemValues:()=>Nt,NodeMaterialTeleportInBlock:()=>cy,NodeMaterialTeleportOutBlock:()=>uy,NoiseBlock:()=>W0,NoiseProceduralTexture:()=>Uv,NormalBlendBlock:()=>zy,NormalizeBlock:()=>gy,NormalizeVectorBlock:()=>K0,NullBlock:()=>N0,NullEngine:()=>pg,NullEngineOptions:()=>fg,Observable:()=>K.cP,Observer:()=>K.nu,OcclusionMaterial:()=>MP,Octree:()=>La,OctreeBlock:()=>tg,OctreeSceneComponent:()=>Eu,OimoJSPlugin:()=>mh,OnAfterEnteringVRObservableEvent:()=>lE,OneMinusBlock:()=>Ih,Orientation:()=>Ge.t4,OutlineRenderer:()=>xT,PBRAnisotropicConfiguration:()=>Wd,PBRBaseMaterial:()=>Tn,PBRBaseSimpleMaterial:()=>Sh,PBRClearCoatConfiguration:()=>Ka,PBRIridescenceConfiguration:()=>Za,PBRMaterial:()=>fl,PBRMaterialDefines:()=>Xd,PBRMetallicRoughnessBlock:()=>qy,PBRMetallicRoughnessMaterial:()=>Nv,PBRSheenConfiguration:()=>Hd,PBRSpecularGlossinessMaterial:()=>Lv,PBRSubSurfaceConfiguration:()=>Yd,PHI:()=>Ge.a6,PadNumber:()=>fi.LW,PanoramaToCubeMapTools:()=>wv.D,ParseFloat16:()=>Mn.LD,ParseFloat32:()=>Mn.Ff,ParseInt32:()=>Mn.cL,ParseInt64:()=>Mn.tB,ParseNullTerminatedString:()=>Mn.T$,ParseUint16:()=>Mn.Jn,ParseUint32:()=>Mn.PX,ParseUint8:()=>Mn._S,ParseUint8Array:()=>Mn.fz,ParseValue:()=>Mn.zX,Particle:()=>Xb,ParticleBlendMultiplyBlock:()=>th,ParticleHelper:()=>eR,ParticleRampGradientBlock:()=>eh,ParticleSystem:()=>Pn,ParticleSystemSet:()=>Ll,ParticleTextureBlock:()=>$d,ParticlesOptimization:()=>kl,PassCubePostProcess:()=>ro.s,PassPostProcess:()=>ro.v,Path2:()=>Ge.Cu,Path3D:()=>Ge.tO,PathCursor:()=>Rn,PerfCollectionStrategy:()=>f1,PerfCounter:()=>Mi.A,PerformanceConfigurator:()=>hg.I,PerformanceMonitor:()=>lu,PerformanceViewerCollector:()=>KT,PerturbNormalBlock:()=>Hv,PhotoDome:()=>_x,Physics6DoFConstraint:()=>Jb,Physics6DoFLimit:()=>mR,PhysicsActivationControl:()=>Af,PhysicsAggregate:()=>$b,PhysicsBody:()=>Qb,PhysicsConstraint:()=>co,PhysicsConstraintAxis:()=>bf,PhysicsConstraintAxisLimitMode:()=>yf,PhysicsConstraintMotorType:()=>Ef,PhysicsConstraintType:()=>Tf,PhysicsEngine:()=>_h,PhysicsEngineV2:()=>Zb,PhysicsEventType:()=>xf,PhysicsHelper:()=>OR,PhysicsImpostor:()=>Dt,PhysicsJoint:()=>In,PhysicsMaterialCombineMode:()=>Cf,PhysicsMotionType:()=>Pf,PhysicsPrestepType:()=>Zr,PhysicsRadialExplosionEventOptions:()=>_a,PhysicsRadialImpulseFalloff:()=>Rf,PhysicsRaycastResult:()=>us,PhysicsShape:()=>gr,PhysicsShapeBox:()=>uR,PhysicsShapeCapsule:()=>lR,PhysicsShapeContainer:()=>fR,PhysicsShapeConvexHull:()=>dR,PhysicsShapeCylinder:()=>cR,PhysicsShapeGroundMesh:()=>_R,PhysicsShapeHeightField:()=>pR,PhysicsShapeMesh:()=>hR,PhysicsShapeSphere:()=>sR,PhysicsShapeType:()=>Sf,PhysicsUpdraftEventOptions:()=>Mf,PhysicsUpdraftMode:()=>If,PhysicsViewer:()=>Wu,PhysicsVortexEventOptions:()=>Of,PickingInfo:()=>ri.G,PipelineErrorReason:()=>_d,PivotTools:()=>Gi,Plane:()=>Ge.Zc,PlaneBlock:()=>x0,PlaneBuilder:()=>XS,PlaneDragGizmo:()=>ul,PlaneRotationGizmo:()=>cl,PlayAnimationAction:()=>Ee,PlaySoundAction:()=>ft,PointColor:()=>mf,PointLight:()=>yl,PointParticleEmitter:()=>df,PointerDragBehavior:()=>Gr,PointerEventTypes:()=>vt.Zp,PointerInfo:()=>vt.mx,PointerInfoBase:()=>vt.Vn,PointerInfoPre:()=>vt.tT,PointerInput:()=>rr.ST,PointsCloudSystem:()=>nR,PointsGroup:()=>Fl,Polar:()=>mC,Polygon:()=>ME,PolygonBuilder:()=>OE,PolygonMeshBuilder:()=>rg,PolyhedronBuilder:()=>wE,PolyhedronData:()=>tl,PositionGizmo:()=>Bg,PositionNormalTextureVertex:()=>Ge.k0,PositionNormalVertex:()=>Ge.B5,PostProcess:()=>_t.w,PostProcessManager:()=>bv.X,PostProcessRenderEffect:()=>Ut,PostProcessRenderPipeline:()=>uo,PostProcessRenderPipelineManager:()=>lT,PostProcessRenderPipelineManagerSceneComponent:()=>cT,PostProcessesOptimization:()=>Ul,PosterizeBlock:()=>wy,PowBlock:()=>My,PowerEase:()=>bo,PowerPreference:()=>Zu,PrePassOutputBlock:()=>ty,PrePassRenderer:()=>gs,PrePassRendererSceneComponent:()=>ST,PrePassTextureBlock:()=>ly,PrecisionDate:()=>et.j,PredicateCondition:()=>H,Predictor:()=>Mn.XE,PrepareAttributesForBakedVertexAnimation:()=>Re.J2,PrepareAttributesForBones:()=>Re.ni,PrepareAttributesForInstances:()=>Re.ER,PrepareAttributesForMorphTargets:()=>Re.IF,PrepareAttributesForMorphTargetsInfluencers:()=>Re.MF,PrepareDefinesForAttributes:()=>Re.qB,PrepareDefinesForBakedVertexAnimation:()=>Re.wu,PrepareDefinesForBones:()=>Re.IC,PrepareDefinesForCamera:()=>Re.Y7,PrepareDefinesForFrameBoundValues:()=>Re.OR,PrepareDefinesForLight:()=>Re.lo,PrepareDefinesForLights:()=>Re.az,PrepareDefinesForMergedUV:()=>Re.YT,PrepareDefinesForMisc:()=>Re.fm,PrepareDefinesForMorphTargets:()=>Re.Jz,PrepareDefinesForMultiview:()=>Re.VO,PrepareDefinesForOIT:()=>Re.Nc,PrepareDefinesForPrePass:()=>Re.N4,PrepareUniformsAndSamplersForLight:()=>Re.GD,PrepareUniformsAndSamplersList:()=>Re.Bb,PressureObserverWrapper:()=>qT,PrimitiveTopology:()=>gd,PrismaticConstraint:()=>SR,ProceduralTexture:()=>xr,ProceduralTextureSceneComponent:()=>av,PropertyTypeForEdition:()=>Qd,ProximityCastResult:()=>NR,PushAttributesForInstances:()=>Re.te,PushMaterial:()=>Ro,QuadraticEase:()=>Fi,QuadraticErrorSimplification:()=>m0,QuarticEase:()=>hr,Quaternion:()=>Ge.PT,QueryType:()=>Od,QueueNewFrame:()=>Be.r,QuinticEase:()=>Xi,RGBDTextureTools:()=>zd.G,RSMCreatePluginMaterial:()=>Zf,Ragdoll:()=>PR,RagdollBoneProperties:()=>xR,RandomBlock:()=>z0,RandomBlockLocks:()=>Qi,RandomGUID:()=>Eo.z,RandomNumberBlock:()=>Oy,RawCubeTexture:()=>WP,RawTexture:()=>Ln,RawTexture2DArray:()=>Rv,RawTexture3D:()=>HP,Ray:()=>fn,RayHelper:()=>ug,ReadFile:()=>hn.NJ,ReadFileError:()=>hn.VB,RecastJSCrowd:()=>Gb,RecastJSPlugin:()=>WC,ReciprocalBlock:()=>Ly,ReflectBlock:()=>Hy,ReflectionBlock:()=>Lh,ReflectionProbe:()=>vh,ReflectionTextureBaseBlock:()=>xl,ReflectionTextureBlock:()=>oy,ReflectiveShadowMap:()=>yM,Reflector:()=>u1,RefractBlock:()=>Yy,RefractionBlock:()=>Fh,RefractionPostProcess:()=>sT,RefractionTexture:()=>YP,RegisterClass:()=>j.Y5,RegisterMaterialPlugin:()=>iE,RegisterNativeTypeAsync:()=>xg,RemapBlock:()=>nh,RenderPassTimestampLocation:()=>Rd,RenderTargetTexture:()=>un.$,RenderTargetWrapper:()=>nl.v,RenderTargetsOptimization:()=>$f,RenderingGroup:()=>ZI.U,RenderingGroupInfo:()=>ss.o,RenderingManager:()=>ss.m,ReplaceColorBlock:()=>Fy,RequestFile:()=>hn.sh,RequestFileError:()=>hn.Mi,RequestFullscreen:()=>_u,RequestPointerlock:()=>Ls,ResizeImageBitmap:()=>pu,RetryStrategy:()=>n1.a,ReverseLutFromBitmap:()=>Uo.FG,RibbonBuilder:()=>xE,RichType:()=>Ji,RichTypeAny:()=>at,RichTypeBoolean:()=>ei,RichTypeColor3:()=>rS,RichTypeColor4:()=>oS,RichTypeFlowGraphInteger:()=>An,RichTypeMatrix:()=>po,RichTypeNumber:()=>sn,RichTypeQuaternion:()=>aS,RichTypeString:()=>nS,RichTypeVector2:()=>uc,RichTypeVector3:()=>Jr,RichTypeVector4:()=>iS,RollingAverage:()=>Om,Rotate2dBlock:()=>Wy,RotationGizmo:()=>wg,RotationXBlock:()=>$0,RotationYBlock:()=>eb,RotationZBlock:()=>tb,RuntimeAnimation:()=>ct,RuntimeError:()=>Bi.bu,SSAO2RenderingPipeline:()=>dT,SSAORenderingPipeline:()=>WR,SSRRenderingPipeline:()=>fT,SamplerBindingType:()=>dd,Scalar:()=>_C,ScaleBlock:()=>hy,ScaleGizmo:()=>Vg,ScalingBlock:()=>nb,ScanData:()=>Ph.u,Scene:()=>ke.Z,SceneComponentConstants:()=>lt.v,SceneDepthBlock:()=>ay,SceneInstrumentation:()=>pv,SceneLoader:()=>yn,SceneLoaderAnimationGroupLoadingMode:()=>jd,SceneLoaderFlags:()=>pr,SceneOptimization:()=>Qr,SceneOptimizer:()=>QO,SceneOptimizerOptions:()=>ep,ScenePerformancePriority:()=>ke.F,SceneRecorder:()=>o1,SceneSerializer:()=>Wl,ScreenSizeBlock:()=>Kv,ScreenSpaceBlock:()=>Zv,ScreenSpaceCurvaturePostProcess:()=>mT,ScreenSpaceReflectionPostProcess:()=>Wf,ScreenshotTools:()=>t1,SerializationHelper:()=>tt.p,SetBasisTranscoderWorker:()=>Hi.af,SetColorsBlock:()=>B0,SetCorsBehavior:()=>hn.M1,SetMaterialIDBlock:()=>Z0,SetNormalsBlock:()=>F0,SetParentAction:()=>je,SetPositionsBlock:()=>L0,SetStateAction:()=>re,SetTangentsBlock:()=>V0,SetUVsBlock:()=>w0,SetValueAction:()=>oe,ShaderCodeInliner:()=>Ga,ShaderLanguage:()=>Eh,ShaderMaterial:()=>pi,ShaderStage:()=>cd,ShaderStore:()=>Gt.l,ShadowDepthWrapper:()=>nC,ShadowGenerator:()=>zi,ShadowGeneratorSceneComponent:()=>Ev,ShadowLight:()=>dl,ShadowMapBlock:()=>ey,ShadowsOptimization:()=>Vl,ShapeBuilder:()=>NE,ShapeCastResult:()=>LR,SharpenPostProcess:()=>zf,SheenBlock:()=>Dh,SimplexPerlin3DBlock:()=>ky,SimplicationQueueSceneComponent:()=>g0,SimplificationQueue:()=>_0,SimplificationSettings:()=>SC,SimplificationType:()=>qh,SineEase:()=>Ci,SixDofDragBehavior:()=>lm,Size:()=>Ge.or,Skeleton:()=>xa,SkeletonViewer:()=>Hu,SliderConstraint:()=>bR,SmartArray:()=>er.L,SmartArrayNoDuplicate:()=>er.b,SmoothStepBlock:()=>Ny,SolidParticle:()=>gf,SolidParticleSystem:()=>tR,SolidParticleVertex:()=>qb,Sound:()=>Jo,SoundTrack:()=>im,SourceTextureFormat:()=>fs.Ok,Space:()=>Ge.$x,SphereBlock:()=>C0,SphereBuilder:()=>yE,SphereDirectedParticleEmitter:()=>hf,SphereParticleEmitter:()=>Nl,Spherical:()=>gC,SphericalHarmonics:()=>Lo.O,SphericalPolynomial:()=>Lo.Q,SpotLight:()=>hl,SpringConstraint:()=>ER,Sprite:()=>Mv,SpriteManager:()=>yh,SpriteMap:()=>wO,SpritePackedManager:()=>BO,SpriteSceneComponent:()=>Ov,Stage:()=>lt.B,StandardMaterial:()=>qt,StandardMaterialDefines:()=>zm,StandardRenderingPipeline:()=>hT,StartsWith:()=>fi.UH,StateCondition:()=>W,StencilOperation:()=>Ed,StencilState:()=>WO.K,StencilStateComposer:()=>Mg.u,StepBlock:()=>Ey,StereoscopicArcRotateCamera:()=>Am,StereoscopicFreeCamera:()=>Cm,StereoscopicGamepadCamera:()=>Rm,StereoscopicInterlacePostProcess:()=>eE,StereoscopicInterlacePostProcessI:()=>Pm,StereoscopicScreenUniversalCamera:()=>tE,StereoscopicUniversalCamera:()=>Im,StickValues:()=>$S,StopAnimationAction:()=>Oe,StopSoundAction:()=>xt,StorageBuffer:()=>um.K,StorageTextureAccess:()=>fd,StoreOp:()=>Md,StringDictionary:()=>fm.w,StringTools:()=>fi.nQ,SubEmitter:()=>_s,SubEmitterType:()=>ff,SubMesh:()=>yi,SubSurfaceBlock:()=>Cl,SubSurfaceSceneComponent:()=>ET,SubtractBlock:()=>Sy,SurfaceMagnetismBehavior:()=>qS,SwitchBooleanAction:()=>Z,SwitchInput:()=>rr.dR,TAARenderingPipeline:()=>pT,TBNBlock:()=>ps,TGATools:()=>fa.uT,Tags:()=>En.Y,TargetCamera:()=>kr,TargetedAnimation:()=>Ps,TeleportInBlock:()=>gb,TeleportOutBlock:()=>vb,TestBase64DataUrl:()=>hn.ZP,TextFileAssetTask:()=>LT,Texture:()=>Ie.g,TextureAspect:()=>id,TextureAssetTask:()=>BT,TextureBlock:()=>ry,TextureDimension:()=>ed,TextureFormat:()=>rd,TextureOptimization:()=>Bl,TexturePacker:()=>zP,TexturePackerFrame:()=>Ah,TextureSampleType:()=>hd,TextureSampler:()=>XP.u,TextureTools:()=>Si.LO,TextureUsage:()=>td,TextureViewDimension:()=>nd,ThinEngine:()=>an.w,ThinRenderTargetTexture:()=>jP,ThinTexture:()=>da.D,TiledBoxBuilder:()=>CE,TiledPlaneBuilder:()=>AE,TimerState:()=>ch,TmpColors:()=>Ge.IG,TmpVectors:()=>Ge.AA,ToGammaSpace:()=>Ge.rv,ToHalfFloat:()=>Si.LZ,ToLinearSpace:()=>Ge.tk,TonemapPostProcess:()=>$R,TonemappingOperator:()=>Hf,Tools:()=>ze.S0,TorusBlock:()=>I0,TorusBuilder:()=>aE,TorusKnotBuilder:()=>RE,TouchCamera:()=>$c,TrailMesh:()=>p0,Trajectory:()=>a1,TrajectoryClassifier:()=>c1,TranscodeAsync:()=>Hi.yk,TranscodeTarget:()=>fs.Xl,TransformBlock:()=>_l,TransformFeedbackBoundingHelper:()=>_E.TransformFeedbackBoundingHelper,TransformNode:()=>jt,TranslationBlock:()=>rb,TriPlanarBlock:()=>wh,TrigonometryBlock:()=>oh,TrigonometryBlockOperations:()=>Vn,TubeBuilder:()=>FE,TwirlBlock:()=>Qv,UncompressPIZ:()=>lo.tg,UncompressPXR:()=>lo._k,UncompressRAW:()=>lo.S4,UncompressRLE:()=>lo.r,UncompressZIP:()=>lo.VE,UniformBuffer:()=>Ui.D,UniversalCamera:()=>So,UnregisterAllMaterialPlugins:()=>vu,UnregisterMaterialPlugin:()=>rE,UploadContent:()=>fa.FA,UploadEnvLevelsAsync:()=>ni.o5,UploadEnvSpherical:()=>ni.ow,UploadLevelsAsync:()=>ni.bv,UtilityLayerRenderer:()=>Fn,VRCameraMetrics:()=>Oa,VRDeviceOrientationArcRotateCamera:()=>Fm,VRDeviceOrientationFreeCamera:()=>ws,VRDeviceOrientationGamepadCamera:()=>wm,VRDistortionCorrectionPostProcess:()=>su,VRExperienceHelper:()=>Km,VRMultiviewToSingleviewPostProcess:()=>Lm,ValidatedNativeDataStream:()=>Ag,ValueCondition:()=>ae,Vector2:()=>Ge.I9,Vector2ToFixed:()=>u0,Vector3:()=>Ge.Pq,Vector3ToFixed:()=>d0,Vector4:()=>Ge.IU,Vector4ToFixed:()=>h0,VectorConverterBlock:()=>q0,VectorMergerBlock:()=>es,VectorSplitterBlock:()=>yy,VertexAnimationBaker:()=>WS,VertexBuffer:()=>Y.R,VertexData:()=>rt,VertexDataMaterialInfo:()=>Ea,VertexFormat:()=>Pd,VertexOutputBlock:()=>$a,VertexStepMode:()=>Ad,VideoDome:()=>kx,VideoRecorder:()=>$O,VideoTexture:()=>gl,ViewDirectionBlock:()=>Mh,Viewport:()=>Ge.LM,VirtualJoystick:()=>Qc,VirtualJoysticksCamera:()=>Mm,VolumetricLightScatteringPostProcess:()=>_T,VoronoiNoiseBlock:()=>$y,Wav2Decode:()=>Uo.tb,WaveBlock:()=>By,WaveBlockKind:()=>Oh,WebGL2ParticleSystem:()=>Wb,WebGL2ShaderProcessor:()=>lx.B,WebGLDataBuffer:()=>Dm.A,WebGLHardwareTexture:()=>ea.d,WebGLPipelineContext:()=>sx.x,WebGPUCacheBindGroups:()=>Ud,WebGPUCacheRenderPipeline:()=>Rg,WebGPUCacheRenderPipelineTree:()=>ol,WebGPUCacheSampler:()=>wd,WebGPUDataBuffer:()=>Cg,WebGPUDrawContext:()=>Dg,WebGPUEngine:()=>It,WebGPURenderTargetWrapper:()=>Lg,WebGPUTintWASM:()=>Ng,WebRequest:()=>We.u,WebXRAbstractFeature:()=>qn,WebXRAbstractMotionController:()=>Bo,WebXRAnchorSystem:()=>Xl,WebXRBackgroundRemover:()=>ql,WebXRCamera:()=>Hg,WebXRControllerComponent:()=>Xr,WebXRControllerMovement:()=>tc,WebXRControllerPhysics:()=>Kl,WebXRControllerPointerSelection:()=>Ja,WebXRDefaultExperience:()=>hv,WebXRDefaultExperienceOptions:()=>Vx,WebXRDepthSensing:()=>ac,WebXRDomOverlay:()=>ec,WebXREnterExitUI:()=>cv,WebXREnterExitUIButton:()=>lv,WebXREnterExitUIOptions:()=>Bx,WebXRExperienceHelper:()=>Yg,WebXREyeTracking:()=>ic,WebXRFeatureName:()=>vn,WebXRFeaturePointSystem:()=>Ql,WebXRFeaturesManager:()=>kn,WebXRGenericHandController:()=>JT,WebXRGenericTriggerMotionController:()=>qd,WebXRHTCViveMotionController:()=>eS,WebXRHand:()=>uv,WebXRHandJoint:()=>lh,WebXRHandTracking:()=>is,WebXRHitTest:()=>Zl,WebXRHitTestLegacy:()=>Yl,WebXRImageTracking:()=>$l,WebXRInput:()=>rv,WebXRInputSource:()=>iv,WebXRLayerRenderTargetTextureProvider:()=>Vs,WebXRLayers:()=>oc,WebXRLightEstimation:()=>nc,WebXRManagedOutputCanvas:()=>Ym,WebXRManagedOutputCanvasOptions:()=>yu,WebXRMeshDetector:()=>Jl,WebXRMicrosoftMixedRealityController:()=>$T,WebXRMotionControllerManager:()=>Di,WebXRMotionControllerTeleportation:()=>os,WebXRNearControllerMode:()=>ah,WebXRNearInteraction:()=>ns,WebXROculusTouchMotionController:()=>sp,WebXRPlaneDetector:()=>jl,WebXRProfiledMotionController:()=>tv,WebXRRawCameraAccess:()=>lc,WebXRSessionManager:()=>bu,WebXRSpaceWarp:()=>sc,WebXRSpaceWarpRenderTargetTextureProvider:()=>QT,WebXRState:()=>op,WebXRTrackingState:()=>ap,WebXRWalkingLocomotion:()=>rc,WeightedSound:()=>VS,WorkerPool:()=>Il.T,WorleyNoise3DBlock:()=>Gy,XRSpaceWarpRenderTarget:()=>ZT,Xbox360Button:()=>eu,Xbox360Dpad:()=>tu,Xbox360Pad:()=>gm,XboxInput:()=>rr.sZ,_BabylonLoaderRegistered:()=>vP,_BasisTextureLoader:()=>VP._BasisTextureLoader,_CommonDispose:()=>du,_CommonInit:()=>uu,_CreationDataStorage:()=>Cc,_DDSTextureLoader:()=>vx._DDSTextureLoader,_ENVTextureLoader:()=>yx._ENVTextureLoader,_ExrTextureLoader:()=>UP._ExrTextureLoader,_GetCompatibleTextureLoader:()=>la.gT,_HDRTextureLoader:()=>BP._HDRTextureLoader,_InstancesBatch:()=>Rc,_KTXTextureLoader:()=>bx._KTXTextureLoader,_MeshCollisionData:()=>Q_,_OcclusionDataStorage:()=>_g,_PrimaryIsoTriangle:()=>Uu,_TGATextureLoader:()=>wP._TGATextureLoader,_TimeToken:()=>mg,_UpdateRGBDAsync:()=>ni.gW,_forceSceneHelpersToBundle:()=>Ux,_forceTransformFeedbackToBundle:()=>YE,_injectLTSFileTools:()=>hn.rh,_staticOffsetValueColor3:()=>Ce,_staticOffsetValueColor4:()=>De,_staticOffsetValueQuaternion:()=>Xe,_staticOffsetValueSize:()=>pe,_staticOffsetValueVector2:()=>ge,_staticOffsetValueVector3:()=>Ze,addClipPlaneUniforms:()=>tn.TV,allocateAndCopyTypedBuffer:()=>cu.k,anaglyphPixelShader:()=>DI.anaglyphPixelShader,anaglyphPixelShaderWGSL:()=>NI.anaglyphPixelShaderWGSL,appendSceneAsync:()=>Ax,backgroundPixelShader:()=>PP.backgroundPixelShader,backgroundPixelShaderWGSL:()=>EP.backgroundPixelShaderWGSL,backgroundVertexShader:()=>xP.backgroundVertexShader,backgroundVertexShaderWGSL:()=>SP.backgroundVertexShaderWGSL,bilateralBlurPixelShader:()=>SM.bilateralBlurPixelShader,bilateralBlurPixelShaderWGSL:()=>AM.bilateralBlurPixelShaderWGSL,bilateralBlurQualityPixelShader:()=>EM.bilateralBlurQualityPixelShader,bilateralBlurQualityPixelShaderWGSL:()=>CM.bilateralBlurQualityPixelShaderWGSL,bindClipPlane:()=>tn.gS,blackAndWhitePixelShader:()=>MI.blackAndWhitePixelShader,blackAndWhitePixelShaderWGSL:()=>OI.blackAndWhitePixelShaderWGSL,bloomMergePixelShader:()=>SI.bloomMergePixelShader,bloomMergePixelShaderWGSL:()=>EI.bloomMergePixelShaderWGSL,bonesDeclaration:()=>nA.bonesDeclaration,bonesDeclarationWGSL:()=>eA.bonesDeclarationWGSL,bonesVertex:()=>iA.bonesVertex,bonesVertexWGSL:()=>tA.bonesVertexWGSL,boundingBoxRendererPixelShader:()=>LM.boundingBoxRendererPixelShader,boundingBoxRendererPixelShaderWGSL:()=>wM.boundingBoxRendererPixelShaderWGSL,boundingBoxRendererVertexShader:()=>FM.boundingBoxRendererVertexShader,boundingBoxRendererVertexShaderWGSL:()=>BM.boundingBoxRendererVertexShaderWGSL,bumpFragment:()=>bA.bumpFragment,bumpFragmentFunctions:()=>SA.bumpFragmentFunctions,bumpFragmentFunctionsWGSL:()=>yA.bumpFragmentFunctionsWGSL,bumpFragmentMainFunctions:()=>TA.bumpFragmentMainFunctions,bumpFragmentMainFunctionsWGSL:()=>vA.bumpFragmentMainFunctionsWGSL,bumpFragmentWGSL:()=>gA.bumpFragmentWGSL,captureEquirectangularFromScene:()=>p1,chromaticAberrationPixelShader:()=>GR.chromaticAberrationPixelShader,chromaticAberrationPixelShaderWGSL:()=>gI.chromaticAberrationPixelShaderWGSL,circleOfConfusionPixelShader:()=>bI.circleOfConfusionPixelShader,circleOfConfusionPixelShaderWGSL:()=>TI.circleOfConfusionPixelShaderWGSL,className:()=>ze.s7,clipPlaneFragment:()=>NA.clipPlaneFragment,clipPlaneFragmentDeclaration:()=>LA.clipPlaneFragmentDeclaration,clipPlaneFragmentDeclarationWGSL:()=>MA.clipPlaneFragmentDeclarationWGSL,clipPlaneFragmentWGSL:()=>IA.clipPlaneFragmentWGSL,clipPlaneVertex:()=>FA.clipPlaneVertex,clipPlaneVertexDeclaration:()=>wA.clipPlaneVertexDeclaration,clipPlaneVertexDeclarationWGSL:()=>DA.clipPlaneVertexDeclarationWGSL,clipPlaneVertexWGSL:()=>OA.clipPlaneVertexWGSL,colorCorrectionPixelShader:()=>wI.colorCorrectionPixelShader,colorCorrectionPixelShaderWGSL:()=>BI.colorCorrectionPixelShaderWGSL,colorPixelShader:()=>RP.colorPixelShader,colorPixelShaderWGSL:()=>IC.colorPixelShaderWGSL,colorVertexShader:()=>IP.colorVertexShader,colorVertexShaderWGSL:()=>MC.colorVertexShaderWGSL,computeMaxExtents:()=>PC,convolutionPixelShader:()=>LI.convolutionPixelShader,convolutionPixelShaderWGSL:()=>FI.convolutionPixelShaderWGSL,copyTexture3DLayerToTexturePixelShader:()=>XM.copyTexture3DLayerToTexturePixelShader,copyTexture3DLayerToTexturePixelShaderWGSL:()=>jM.copyTexture3DLayerToTexturePixelShaderWGSL,copyTextureToTexturePixelShader:()=>b1.copyTextureToTexturePixelShader,copyTextureToTexturePixelShaderWGSL:()=>T1.copyTextureToTexturePixelShaderWGSL,createDetailMapPlugin:()=>cC,createPBRAnisotropicPlugin:()=>iC,createPBRBRDFPlugin:()=>rC,createPBRClearCoatPlugin:()=>oC,createPBRIridescencePlugin:()=>aC,createPBRSheenPlugin:()=>sC,createPBRSubSurfacePlugin:()=>lC,createYieldingScheduler:()=>Y_,defaultPixelShader:()=>dC.defaultPixelShader,defaultPixelShaderWGSL:()=>fC.defaultPixelShaderWGSL,defaultVertexShader:()=>hC.defaultVertexShader,defaultVertexShaderWGSL:()=>pC.defaultVertexShaderWGSL,depthBoxBlurPixelShader:()=>mP.depthBoxBlurPixelShader,depthBoxBlurPixelShaderWGSL:()=>hP.depthBoxBlurPixelShaderWGSL,depthOfFieldMergePixelShader:()=>vI.depthOfFieldMergePixelShader,depthOfFieldMergePixelShaderWGSL:()=>yI.depthOfFieldMergePixelShaderWGSL,depthPixelShader:()=>sP.depthPixelShader,depthPixelShaderWGSL:()=>MM.depthPixelShaderWGSL,depthVertexShader:()=>lP.depthVertexShader,depthVertexShaderWGSL:()=>OM.depthVertexShaderWGSL,displayPassPixelShader:()=>HI.displayPassPixelShader,displayPassPixelShaderWGSL:()=>YI.displayPassPixelShaderWGSL,editableInPropertyPage:()=>dt,expandToProperty:()=>V.$z,extractHighlightsPixelShader:()=>xI.extractHighlightsPixelShader,extractHighlightsPixelShaderWGSL:()=>PI.extractHighlightsPixelShaderWGSL,extractMinAndMax:()=>no.b,extractMinAndMaxIndexed:()=>no.c,filterPixelShader:()=>GI.filterPixelShader,filterPixelShaderWGSL:()=>kI.filterPixelShaderWGSL,fluidRenderingBilateralBlurPixelShader:()=>oM.fluidRenderingBilateralBlurPixelShader,fluidRenderingBilateralBlurPixelShaderWGSL:()=>mM.fluidRenderingBilateralBlurPixelShaderWGSL,fluidRenderingParticleDepthPixelShader:()=>JI.fluidRenderingParticleDepthPixelShader,fluidRenderingParticleDepthPixelShaderWGSL:()=>cM.fluidRenderingParticleDepthPixelShaderWGSL,fluidRenderingParticleDepthVertexShader:()=>QI.fluidRenderingParticleDepthVertexShader,fluidRenderingParticleDepthVertexShaderWGSL:()=>lM.fluidRenderingParticleDepthVertexShaderWGSL,fluidRenderingParticleDiffusePixelShader:()=>rM.fluidRenderingParticleDiffusePixelShader,fluidRenderingParticleDiffusePixelShaderWGSL:()=>_M.fluidRenderingParticleDiffusePixelShaderWGSL,fluidRenderingParticleDiffuseVertexShader:()=>iM,fluidRenderingParticleDiffuseVertexShaderWGSL:()=>pM,fluidRenderingParticleThicknessPixelShader:()=>eM.fluidRenderingParticleThicknessPixelShader,fluidRenderingParticleThicknessPixelShaderWGSL:()=>dM.fluidRenderingParticleThicknessPixelShaderWGSL,fluidRenderingParticleThicknessVertexShader:()=>$I.fluidRenderingParticleThicknessVertexShader,fluidRenderingParticleThicknessVertexShaderWGSL:()=>uM.fluidRenderingParticleThicknessVertexShaderWGSL,fluidRenderingRenderPixelShader:()=>sM.fluidRenderingRenderPixelShader,fluidRenderingRenderPixelShaderWGSL:()=>vM.fluidRenderingRenderPixelShaderWGSL,fluidRenderingStandardBlurPixelShader:()=>aM.fluidRenderingStandardBlurPixelShader,fluidRenderingStandardBlurPixelShaderWGSL:()=>gM.fluidRenderingStandardBlurPixelShaderWGSL,fogFragmentDeclaration:()=>VA.fogFragmentDeclaration,fogFragmentDeclarationWGSL:()=>BA.fogFragmentDeclarationWGSL,fxaaPixelShader:()=>AI.fxaaPixelShader,fxaaPixelShaderWGSL:()=>RI.fxaaPixelShaderWGSL,fxaaVertexShader:()=>CI.fxaaVertexShader,fxaaVertexShaderWGSL:()=>II.fxaaVertexShaderWGSL,geometryPixelShader:()=>wR.geometryPixelShader,geometryPixelShaderWGSL:()=>DM.geometryPixelShaderWGSL,geometryVertexShader:()=>BR.geometryVertexShader,geometryVertexShaderWGSL:()=>NM.geometryVertexShaderWGSL,getRichTypeFromValue:()=>sS,glowBlurPostProcessPixelShader:()=>Kx.glowBlurPostProcessPixelShader,glowBlurPostProcessPixelShaderWGSL:()=>Jx.glowBlurPostProcessPixelShaderWGSL,glowMapGenerationPixelShader:()=>Wx.glowMapGenerationPixelShader,glowMapGenerationPixelShaderWGSL:()=>Yx.glowMapGenerationPixelShaderWGSL,glowMapGenerationVertexShader:()=>Hx.glowMapGenerationVertexShader,glowMapGenerationVertexShaderWGSL:()=>Xx.glowMapGenerationVertexShaderWGSL,glowMapMergePixelShader:()=>jx.glowMapMergePixelShader,glowMapMergePixelShaderWGSL:()=>Zx.glowMapMergePixelShaderWGSL,glowMapMergeVertexShader:()=>qx.glowMapMergeVertexShader,glowMapMergeVertexShaderWGSL:()=>Qx.glowMapMergeVertexShaderWGSL,grainPixelShader:()=>_I.grainPixelShader,grainPixelShaderWGSL:()=>mI.grainPixelShaderWGSL,hdrFilteringPixelShader:()=>QP.hdrFilteringPixelShader,hdrFilteringPixelShaderWGSL:()=>$P.hdrFilteringPixelShaderWGSL,hdrFilteringVertexShader:()=>ZP.hdrFilteringVertexShader,hdrFilteringVertexShaderWGSL:()=>JP.hdrFilteringVertexShaderWGSL,helperFunctions:()=>pA.helperFunctions,helperFunctionsWGSL:()=>JE.helperFunctionsWGSL,highlightsPixelShader:()=>zI.highlightsPixelShader,highlightsPixelShaderWGSL:()=>WI.highlightsPixelShaderWGSL,iblCombineVoxelGridsPixelShader:()=>oO.iblCombineVoxelGridsPixelShader,iblCombineVoxelGridsPixelShaderWGSL:()=>rO.iblCombineVoxelGridsPixelShaderWGSL,iblGenerateVoxelMipPixelShader:()=>aO.iblGenerateVoxelMipPixelShader,iblGenerateVoxelMipPixelShaderWGSL:()=>sO.iblGenerateVoxelMipPixelShaderWGSL,iblShadowAccumulationPixelShader:()=>tO.iblShadowAccumulationPixelShader,iblShadowAccumulationPixelShaderWGSL:()=>eO.iblShadowAccumulationPixelShaderWGSL,iblShadowDebugPixelShader:()=>ZM.iblShadowDebugPixelShader,iblShadowDebugPixelShaderWGSL:()=>QM.iblShadowDebugPixelShaderWGSL,iblShadowGBufferDebugPixelShader:()=>lO.iblShadowGBufferDebugPixelShader,iblShadowGBufferDebugPixelShaderWGSL:()=>cO.iblShadowGBufferDebugPixelShaderWGSL,iblShadowSpatialBlurPixelShader:()=>$M.iblShadowSpatialBlurPixelShader,iblShadowSpatialBlurPixelShaderWGSL:()=>JM.iblShadowSpatialBlurPixelShaderWGSL,iblShadowVoxelTracingPixelShader:()=>qM.iblShadowVoxelTracingPixelShader,iblShadowVoxelTracingPixelShaderWGSL:()=>KM.iblShadowVoxelTracingPixelShaderWGSL,iblShadowsCdfxPixelShader:()=>dO.iblShadowsCdfxPixelShader,iblShadowsCdfxPixelShaderWGSL:()=>uO.iblShadowsCdfxPixelShaderWGSL,iblShadowsCdfyPixelShader:()=>fO.iblShadowsCdfyPixelShader,iblShadowsCdfyPixelShaderWGSL:()=>hO.iblShadowsCdfyPixelShaderWGSL,iblShadowsCombinePixelShader:()=>nO.iblShadowsCombinePixelShader,iblShadowsCombinePixelShaderWGSL:()=>iO.iblShadowsCombinePixelShaderWGSL,iblShadowsIcdfxPixelShader:()=>_O.iblShadowsIcdfxPixelShader,iblShadowsIcdfxPixelShaderWGSL:()=>pO.iblShadowsIcdfxPixelShaderWGSL,iblShadowsIcdfyPixelShader:()=>gO.iblShadowsIcdfyPixelShader,iblShadowsIcdfyPixelShaderWGSL:()=>mO.iblShadowsIcdfyPixelShaderWGSL,iblShadowsImportanceSamplingDebugPixelShader:()=>yO.iblShadowsImportanceSamplingDebugPixelShader,iblShadowsImportanceSamplingDebugPixelShaderWGSL:()=>vO.iblShadowsImportanceSamplingDebugPixelShaderWGSL,iblVoxelGrid2dArrayDebugPixelShader:()=>bO.iblVoxelGrid2dArrayDebugPixelShader,iblVoxelGrid2dArrayDebugPixelShaderWGSL:()=>TO.iblVoxelGrid2dArrayDebugPixelShaderWGSL,iblVoxelGrid3dDebugPixelShader:()=>AO.iblVoxelGrid3dDebugPixelShader,iblVoxelGrid3dDebugPixelShaderWGSL:()=>CO.iblVoxelGrid3dDebugPixelShaderWGSL,iblVoxelGridPixelShader:()=>SO.iblVoxelGridPixelShader,iblVoxelGridPixelShaderWGSL:()=>xO.iblVoxelGridPixelShaderWGSL,iblVoxelGridVertexShader:()=>EO.iblVoxelGridVertexShader,iblVoxelGridVertexShaderWGSL:()=>PO.iblVoxelGridVertexShaderWGSL,iblVoxelSlabDebugPixelShader:()=>IO.iblVoxelSlabDebugPixelShader,iblVoxelSlabDebugPixelShaderWGSL:()=>OO.iblVoxelSlabDebugPixelShaderWGSL,iblVoxelSlabDebugVertexShader:()=>RO.iblVoxelSlabDebugVertexShader,iblVoxelSlabDebugVertexShaderWGSL:()=>MO.iblVoxelSlabDebugVertexShaderWGSL,imageProcessingDeclaration:()=>_A.imageProcessingDeclaration,imageProcessingDeclarationWGSL:()=>hA.imageProcessingDeclarationWGSL,imageProcessingFunctions:()=>mA.imageProcessingFunctions,imageProcessingFunctionsWGSL:()=>fA.imageProcessingFunctionsWGSL,imageProcessingPixelShader:()=>fI.imageProcessingPixelShader,imageProcessingPixelShaderWGSL:()=>hI.imageProcessingPixelShaderWGSL,importAnimationsAsync:()=>Ox,inlineScheduler:()=>Sa,kernelBlurPixelShader:()=>nI.kernelBlurPixelShader,kernelBlurPixelShaderWGSL:()=>rI.kernelBlurPixelShaderWGSL,kernelBlurVertexShader:()=>iI.kernelBlurVertexShader,kernelBlurVertexShaderWGSL:()=>oI.kernelBlurVertexShaderWGSL,layerPixelShader:()=>$x.layerPixelShader,layerPixelShaderWGSL:()=>tP.layerPixelShaderWGSL,layerVertexShader:()=>eP.layerVertexShader,layerVertexShaderWGSL:()=>nP.layerVertexShaderWGSL,lensFlarePixelShader:()=>iP.lensFlarePixelShader,lensFlarePixelShaderWGSL:()=>oP.lensFlarePixelShaderWGSL,lensFlareVertexShader:()=>rP.lensFlareVertexShader,lensFlareVertexShaderWGSL:()=>aP.lensFlareVertexShaderWGSL,lightFragment:()=>XA.lightFragment,lightFragmentDeclaration:()=>YA.lightFragmentDeclaration,lightFragmentWGSL:()=>UA.lightFragmentWGSL,lightUboDeclaration:()=>jA.lightUboDeclaration,lightUboDeclarationWGSL:()=>GA.lightUboDeclarationWGSL,lightVxFragmentDeclaration:()=>KA.lightVxFragmentDeclaration,lightVxUboDeclaration:()=>qA.lightVxUboDeclaration,lightVxUboDeclarationWGSL:()=>kA.lightVxUboDeclarationWGSL,lightsFragmentFunctions:()=>ZA.lightsFragmentFunctions,lightsFragmentFunctionsWGSL:()=>zA.lightsFragmentFunctionsWGSL,linePixelShader:()=>VM.linePixelShader,linePixelShaderWGSL:()=>GM.linePixelShaderWGSL,lineVertexShader:()=>UM.lineVertexShader,lineVertexShaderWGSL:()=>kM.lineVertexShaderWGSL,loadAssetContainerAsync:()=>Rx,loadSceneAsync:()=>xx,makeAsyncFunction:()=>FS,makeSyncFunction:()=>X_,meshUVSpaceRendererFinaliserPixelShader:()=>FC.meshUVSpaceRendererFinaliserPixelShader,meshUVSpaceRendererFinaliserPixelShaderWGSL:()=>kC.meshUVSpaceRendererFinaliserPixelShaderWGSL,meshUVSpaceRendererFinaliserVertexShader:()=>wC.meshUVSpaceRendererFinaliserVertexShader,meshUVSpaceRendererFinaliserVertexShaderWGSL:()=>zC.meshUVSpaceRendererFinaliserVertexShaderWGSL,meshUVSpaceRendererMaskerPixelShader:()=>LC.meshUVSpaceRendererMaskerPixelShader,meshUVSpaceRendererMaskerPixelShaderWGSL:()=>GC.meshUVSpaceRendererMaskerPixelShaderWGSL,meshUVSpaceRendererMaskerVertexShader:()=>NC.meshUVSpaceRendererMaskerVertexShader,meshUVSpaceRendererMaskerVertexShaderWGSL:()=>UC.meshUVSpaceRendererMaskerVertexShaderWGSL,meshUVSpaceRendererPixelShader:()=>DC.meshUVSpaceRendererPixelShader,meshUVSpaceRendererPixelShaderWGSL:()=>VC.meshUVSpaceRendererPixelShaderWGSL,meshUVSpaceRendererVertexShader:()=>OC.meshUVSpaceRendererVertexShader,meshUVSpaceRendererVertexShaderWGSL:()=>BC.meshUVSpaceRendererVertexShaderWGSL,morphTargetsVertex:()=>lA.morphTargetsVertex,morphTargetsVertexDeclaration:()=>cA.morphTargetsVertexDeclaration,morphTargetsVertexDeclarationWGSL:()=>oA.morphTargetsVertexDeclarationWGSL,morphTargetsVertexGlobal:()=>uA.morphTargetsVertexGlobal,morphTargetsVertexGlobalDeclaration:()=>dA.morphTargetsVertexGlobalDeclaration,morphTargetsVertexGlobalDeclarationWGSL:()=>sA.morphTargetsVertexGlobalDeclarationWGSL,morphTargetsVertexGlobalWGSL:()=>aA.morphTargetsVertexGlobalWGSL,morphTargetsVertexWGSL:()=>rA.morphTargetsVertexWGSL,motionBlurPixelShader:()=>VI.motionBlurPixelShader,motionBlurPixelShaderWGSL:()=>UI.motionBlurPixelShaderWGSL,nativeOverride:()=>V.Cx,normalizeEnvInfo:()=>ni.RZ,oitBackBlendPixelShader:()=>DO.oitBackBlendPixelShader,oitBackBlendPixelShaderWGSL:()=>LO.oitBackBlendPixelShaderWGSL,oitFinalPixelShader:()=>NO.oitFinalPixelShader,oitFinalPixelShaderWGSL:()=>FO.oitFinalPixelShaderWGSL,outlinePixelShader:()=>zM.outlinePixelShader,outlinePixelShaderWGSL:()=>HM.outlinePixelShaderWGSL,outlineVertexShader:()=>WM.outlineVertexShader,outlineVertexShaderWGSL:()=>YM.outlineVertexShaderWGSL,packingFunctions:()=>CA.packingFunctions,packingFunctionsWGSL:()=>xA.packingFunctionsWGSL,particlesPixelShader:()=>iR.particlesPixelShader,particlesPixelShaderWGSL:()=>oR.particlesPixelShaderWGSL,particlesVertexShader:()=>rR.particlesVertexShader,particlesVertexShaderWGSL:()=>aR.particlesVertexShaderWGSL,passCubePixelShader:()=>sI.passCubePixelShader,passCubePixelShaderWGSL:()=>cI.passCubePixelShaderWGSL,passPixelShader:()=>aI.passPixelShader,passPixelShaderWGSL:()=>lI.passPixelShaderWGSL,pbrPixelShader:()=>LP.pbrPixelShader,pbrPixelShaderWGSL:()=>DP.pbrPixelShaderWGSL,pbrVertexShader:()=>NP.pbrVertexShader,pbrVertexShaderWGSL:()=>OP.pbrVertexShaderWGSL,pickingPixelShader:()=>uE.pickingPixelShader,pickingPixelShaderWGSL:()=>hE.pickingPixelShaderWGSL,pickingVertexShader:()=>dE.pickingVertexShader,pickingVertexShaderWGSL:()=>fE.pickingVertexShaderWGSL,postprocessVertexShader:()=>eI.postprocessVertexShader,postprocessVertexShaderWGSL:()=>tI.postprocessVertexShaderWGSL,prepareDefinesForClipPlanes:()=>tn.Eq,prepareStringDefinesForClipPlanes:()=>tn.tv,proceduralVertexShader:()=>KP.proceduralVertexShader,proceduralVertexShaderWGSL:()=>qP.proceduralVertexShaderWGSL,reflectionFunction:()=>eC.reflectionFunction,reflectionFunctionWGSL:()=>$A.reflectionFunctionWGSL,registerSceneLoaderPlugin:()=>Jg,registerTextureLoader:()=>la.kf,rgbdDecodePixelShader:()=>m1.rgbdDecodePixelShader,rgbdDecodePixelShaderWGSL:()=>v1.rgbdDecodePixelShaderWGSL,rgbdEncodePixelShader:()=>g1.rgbdEncodePixelShader,rgbdEncodePixelShaderWGSL:()=>y1.rgbdEncodePixelShaderWGSL,rsmFullGlobalIlluminationPixelShader:()=>PM.rsmFullGlobalIlluminationPixelShader,rsmFullGlobalIlluminationPixelShaderWGSL:()=>IM.rsmFullGlobalIlluminationPixelShaderWGSL,rsmGlobalIlluminationPixelShader:()=>xM.rsmGlobalIlluminationPixelShader,rsmGlobalIlluminationPixelShaderWGSL:()=>RM.rsmGlobalIlluminationPixelShaderWGSL,runCoroutine:()=>Ac,runCoroutineAsync:()=>Cs,runCoroutineSync:()=>As,screenSpaceReflection2BlurCombinerPixelShader:()=>KR.screenSpaceReflection2BlurCombinerPixelShader,screenSpaceReflection2BlurCombinerPixelShaderWGSL:()=>JR.screenSpaceReflection2BlurCombinerPixelShaderWGSL,screenSpaceReflection2BlurPixelShader:()=>qR.screenSpaceReflection2BlurPixelShader,screenSpaceReflection2BlurPixelShaderWGSL:()=>QR.screenSpaceReflection2BlurPixelShaderWGSL,screenSpaceReflection2PixelShader:()=>jR.screenSpaceReflection2PixelShader,screenSpaceReflection2PixelShaderWGSL:()=>ZR.screenSpaceReflection2PixelShaderWGSL,serialize:()=>V.lK,serializeAsCameraReference:()=>V.fW,serializeAsColor3:()=>V.jT,serializeAsColor4:()=>V.qK,serializeAsColorCurves:()=>V.wL,serializeAsFresnelParameters:()=>V.Y9,serializeAsImageProcessingConfiguration:()=>V.n1,serializeAsMatrix:()=>V.GG,serializeAsMeshReference:()=>V.xG,serializeAsQuaternion:()=>V.bR,serializeAsTexture:()=>V.uM,serializeAsVector2:()=>V.WM,serializeAsVector3:()=>V.P_,setAndStartTimer:()=>rs,setStereoscopicAnaglyphRigMode:()=>Ia,setStereoscopicRigMode:()=>Ma,setVRRigMode:()=>Fs,shadowMapFragment:()=>RA.shadowMapFragment,shadowMapFragmentSoftTransparentShadow:()=>gP.shadowMapFragmentSoftTransparentShadow,shadowMapFragmentSoftTransparentShadowWGSL:()=>fP.shadowMapFragmentSoftTransparentShadowWGSL,shadowMapFragmentWGSL:()=>PA.shadowMapFragmentWGSL,shadowMapPixelShader:()=>pP.shadowMapPixelShader,shadowMapPixelShaderWGSL:()=>uP.shadowMapPixelShaderWGSL,shadowMapVertexMetric:()=>AA.shadowMapVertexMetric,shadowMapVertexMetricWGSL:()=>EA.shadowMapVertexMetricWGSL,shadowMapVertexShader:()=>_P.shadowMapVertexShader,shadowMapVertexShaderWGSL:()=>dP.shadowMapVertexShaderWGSL,shadowsFragmentFunctions:()=>QA.shadowsFragmentFunctions,shadowsFragmentFunctionsWGSL:()=>WA.shadowsFragmentFunctionsWGSL,shadowsVertex:()=>JA.shadowsVertex,shadowsVertexWGSL:()=>HA.shadowsVertexWGSL,sharpenPixelShader:()=>UR.sharpenPixelShader,sharpenPixelShaderWGSL:()=>pI.sharpenPixelShaderWGSL,spritesPixelShader:()=>VO.spritesPixelShader,spritesPixelShaderWGSL:()=>GO.spritesPixelShaderWGSL,spritesVertexShader:()=>UO.spritesVertexShader,spritesVertexShaderWGSL:()=>kO.spritesVertexShaderWGSL,ssao2PixelShader:()=>HR.ssao2PixelShader,ssao2PixelShaderWGSL:()=>YR.ssao2PixelShaderWGSL,ssaoCombinePixelShader:()=>zR.ssaoCombinePixelShader,ssaoCombinePixelShaderWGSL:()=>XR.ssaoCombinePixelShaderWGSL,tonemapPixelShader:()=>XI.tonemapPixelShader,tonemapPixelShaderWGSL:()=>jI.tonemapPixelShaderWGSL,unregisterTextureLoader:()=>la.hy,vrDistortionCorrectionPixelShader:()=>uI.vrDistortionCorrectionPixelShader,vrDistortionCorrectionPixelShaderWGSL:()=>dI.vrDistortionCorrectionPixelShaderWGSL});var nt=L(94671),Ne=L(82966),K=L(66377),_=L(8046),z=L(64726),j=L(34623),me=function(){function r(t,e){this.triggerOptions=t,this.onBeforeExecuteObservable=new K.cP,t.parameter?(this.trigger=t.trigger,this._triggerParameter=t.parameter):t.trigger?this.trigger=t.trigger:this.trigger=t,this._nextActiveAction=this,this._condition=e}return r.prototype._prepare=function(){},r.prototype.getTriggerParameter=function(){return this._triggerParameter},r.prototype.setTriggerParameter=function(t){this._triggerParameter=t},r.prototype._evaluateConditionForCurrentFrame=function(){var t=this._condition;if(!t)return!0;var e=this._actionManager.getScene().getRenderId();return t._evaluationId!==e&&(t._evaluationId=e,t._currentResult=t.isValid()),t._currentResult},r.prototype._executeCurrent=function(t){this._evaluateConditionForCurrentFrame()&&(this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(t),this.skipToNextActiveAction())},r.prototype.execute=function(t){},r.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},r.prototype.then=function(t){return this._child=t,t._actionManager=this._actionManager,t._prepare(),t},r.prototype._getProperty=function(t){return this._actionManager._getProperty(t)},r.prototype._getEffectiveTarget=function(t,e){return this._actionManager._getEffectiveTarget(t,e)},r.prototype.serialize=function(t){return null},r.prototype._serialize=function(t,e){var n={type:1,children:[],name:t.name,properties:t.properties||[]};if(this._child&&this._child.serialize(n),this._condition){var i=this._condition.serialize();return i.children.push(n),e&&e.children.push(i),i}return e&&e.children.push(n),n},r._SerializeValueAsString=function(t){return typeof t=="number"?t.toString():typeof t=="boolean"?t?"true":"false":t instanceof _.I9?t.x+", "+t.y:t instanceof _.Pq?t.x+", "+t.y+", "+t.z:t instanceof z.v9?t.r+", "+t.g+", "+t.b:t instanceof z.ov?t.r+", "+t.g+", "+t.b+", "+t.a:t},r._GetTargetProperty=function(t){return{name:"target",targetType:t._isMesh?"MeshProperties":t._isLight?"LightProperties":t._isCamera?"CameraProperties":t._isMaterial?"MaterialProperties":"SceneProperties",value:t._isScene?"Scene":t.name}},r}();(0,j.Y5)("BABYLON.Action",me);var Se=L(35747),A=L(78322),ne=function(){function r(t){this._actionManager=t}return r.prototype.isValid=function(){return!0},r.prototype._getProperty=function(t){return this._actionManager._getProperty(t)},r.prototype._getEffectiveTarget=function(t,e){return this._actionManager._getEffectiveTarget(t,e)},r.prototype.serialize=function(){},r.prototype._serialize=function(t){return{type:2,children:[],name:t.name,properties:t.properties}},r}(),ae=function(r){function t(e,n,i,o,a){a===void 0&&(a=t.IsEqual);var s=r.call(this,e)||this;return s.propertyPath=i,s.value=o,s.operator=a,s._target=n,s._effectiveTarget=s._getEffectiveTarget(n,s.propertyPath),s._property=s._getProperty(s.propertyPath),s}return(0,A.C6)(t,r),Object.defineProperty(t,"IsEqual",{get:function(){return t._IsEqual},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsDifferent",{get:function(){return t._IsDifferent},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!1,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._effectiveTarget[this._property]>this.value;case t.IsLesser:return this._effectiveTarget[this._property]<this.value;case t.IsEqual:case t.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===t.IsEqual?e:!e}return!1},t.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[me._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:me._SerializeValueAsString(this.value)},{name:"operator",value:t.GetOperatorName(this.operator)}]})},t.GetOperatorName=function(e){switch(e){case t._IsEqual:return"IsEqual";case t._IsDifferent:return"IsDifferent";case t._IsGreater:return"IsGreater";case t._IsLesser:return"IsLesser";default:return""}},t._IsEqual=0,t._IsDifferent=1,t._IsGreater=2,t._IsLesser=3,t}(ne),H=function(r){function t(e,n){var i=r.call(this,e)||this;return i.predicate=n,i}return(0,A.C6)(t,r),t.prototype.isValid=function(){return this.predicate()},t}(ne),W=function(r){function t(e,n,i){var o=r.call(this,e)||this;return o.value=i,o._target=n,o}return(0,A.C6)(t,r),t.prototype.isValid=function(){return this._target.state===this.value},t.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[me._GetTargetProperty(this._target),{name:"value",value:this.value}]})},t}(ne);(0,j.Y5)("BABYLON.ValueCondition",ae),(0,j.Y5)("BABYLON.PredicateCondition",H),(0,j.Y5)("BABYLON.StateCondition",W);var O=L(7164),P=L(81152),Z=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a.propertyPath=i,a._target=a._effectiveTarget=n,a}return(0,A.C6)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[me._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},e)},t}(me),re=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a.value=i,a._target=n,a}return(0,A.C6)(t,r),t.prototype.execute=function(){this._target.state=this.value},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SetStateAction",properties:[me._GetTargetProperty(this._target),{name:"value",value:this.value}]},e)},t}(me),oe=function(r){function t(e,n,i,o,a){var s=r.call(this,e,a)||this;return s.propertyPath=i,s.value=o,s._target=s._effectiveTarget=n,s}return(0,A.C6)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SetValueAction",properties:[me._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:me._SerializeValueAsString(this.value)}]},e)},t}(me),he=function(r){function t(e,n,i,o,a){var s=r.call(this,e,a)||this;return s.propertyPath=i,s.value=o,s._target=s._effectiveTarget=n,s}return(0,A.C6)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),typeof this._effectiveTarget[this._property]!="number"&&O.V.Warn("Warning: IncrementValueAction can only be used with number values")},t.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[me._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:me._SerializeValueAsString(this.value)}]},e)},t}(me),Ee=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e,s)||this;return l.from=i,l.to=o,l.loop=a,l._target=n,l}return(0,A.C6)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[me._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:me._SerializeValueAsString(this.loop)||!1}]},e)},t}(me),Oe=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._target=n,o}return(0,A.C6)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[me._GetTargetProperty(this._target)]},e)},t}(me),Pe=function(r){function t(e,n){return e===void 0&&(e=P.Y.ACTION_NothingTrigger),r.call(this,e,n)||this}return(0,A.C6)(t,r),t.prototype.execute=function(){},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},e)},t}(me),Ae=function(r){function t(e,n,i,o){o===void 0&&(o=!0);var a=r.call(this,e,i)||this;return a.children=n,a.enableChildrenConditions=o,a}return(0,A.C6)(t,r),t.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},t.prototype.execute=function(e){for(var n=0,i=this.children;n<i.length;n++){var o=i[n];this.enableChildrenConditions&&!o._evaluateConditionForCurrentFrame()||o.execute(e)}},t.prototype.serialize=function(e){for(var n=r.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},e),i=0;i<this.children.length;i++)n.combine.push(this.children[i].serialize(null));return n},t}(me),Ue=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o.func=n,o}return(0,A.C6)(t,r),t.prototype.execute=function(e){this.func(e)},t}(me),je=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a._target=n,a._parent=i,a}return(0,A.C6)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){if(this._target.parent!==this._parent){var e=this._parent.getWorldMatrix().clone();e.invert(),this._target.position=_.Pq.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"SetParentAction",properties:[me._GetTargetProperty(this._target),me._GetTargetProperty(this._parent)]},e)},t}(me);(0,j.Y5)("BABYLON.SetParentAction",je),(0,j.Y5)("BABYLON.ExecuteCodeAction",Ue),(0,j.Y5)("BABYLON.DoNothingAction",Pe),(0,j.Y5)("BABYLON.StopAnimationAction",Oe),(0,j.Y5)("BABYLON.PlayAnimationAction",Ee),(0,j.Y5)("BABYLON.IncrementValueAction",he),(0,j.Y5)("BABYLON.SetValueAction",oe),(0,j.Y5)("BABYLON.SetStateAction",re),(0,j.Y5)("BABYLON.SetParentAction",je),(0,j.Y5)("BABYLON.SwitchBooleanAction",Z),(0,j.Y5)("BABYLON.CombineAction",Ae);var Ve=L(66614),ot=L(44576),it=function(r){function t(e){var n=r.call(this)||this;return(e=e||Ve.q.LastCreatedScene)&&(n._scene=e,e.actionManagers.push(n)),n}return(0,A.C6)(t,r),t.prototype.dispose=function(){for(var e=this,n=this._scene.actionManagers.indexOf(this),i=0;i<this.actions.length;i++){var o=this.actions[i];t.Triggers[o.trigger]--,t.Triggers[o.trigger]===0&&delete t.Triggers[o.trigger]}this.actions.length=0,n>-1&&this._scene.actionManagers.splice(n,1);for(var a=0,s=this._scene.meshes.filter(function(l){return l.actionManager===e});a<s.length;a++)s[a].actionManager=null},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var n=0;n<this.actions.length;n++){var i=this.actions[n];if(e.indexOf(i.trigger)>-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,n){for(var i=0;i<this.actions.length;i++){var o=this.actions[i];if(e==o.trigger||n==o.trigger)return!0}return!1},t.prototype.hasSpecificTrigger=function(e,n){for(var i=0;i<this.actions.length;i++){var o=this.actions[i];if(o.trigger===e&&(!n||n(o.getTriggerParameter())))return!0}return!1},Object.defineProperty(t.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var n=this.actions[e];if(n.trigger>=t.OnPickTrigger&&n.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var n=this.actions[e];if(n.trigger>=t.OnPickTrigger&&n.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(O.V.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),this.getScene()._registeredActions++,t.Triggers[e.trigger]?t.Triggers[e.trigger]++:t.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)},t.prototype.unregisterAction=function(e){var n=this.actions.indexOf(e);return n!==-1&&(this.actions.splice(n,1),t.Triggers[e.trigger]-=1,t.Triggers[e.trigger]===0&&delete t.Triggers[e.trigger],e._actionManager=null,this.getScene()._registeredActions--,!0)},t.prototype.processTrigger=function(e,n){for(var i=0;i<this.actions.length;i++){var o=this.actions[i];if(o.trigger===e){if(n&&(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger)){var a=o.getTriggerParameter();if(typeof a=="function"){if(!a(n))continue}else if(a&&a!==n.sourceEvent.keyCode){if(!a.toLowerCase)continue;var s=a.toLowerCase();if(s!==n.sourceEvent.key){var l=n.sourceEvent.charCode?n.sourceEvent.charCode:n.sourceEvent.keyCode;if(String.fromCharCode(l).toLowerCase()!==s)continue}}}o._executeCurrent(n)}}},t.prototype._getEffectiveTarget=function(e,n){for(var i=n.split("."),o=0;o<i.length-1;o++)e=e[i[o]];return e},t.prototype._getProperty=function(e){var n=e.split(".");return n[n.length-1]},t.prototype.serialize=function(e){for(var n={children:new Array,name:e,type:3,properties:new Array},i=0;i<this.actions.length;i++){var o={type:0,children:new Array,name:t.GetTriggerName(this.actions[i].trigger),properties:new Array},a=this.actions[i].triggerOptions;if(a&&typeof a!="number")if(a.parameter instanceof Node)o.properties.push(me._GetTargetProperty(a.parameter));else if(typeof a.parameter=="object"){var s={};ot.r.DeepCopy(a.parameter,s,["mesh"]),a.parameter&&a.parameter.mesh&&(s._meshId=a.parameter.mesh.id),o.properties.push({name:"parameter",targetType:null,value:s})}else o.properties.push({name:"parameter",targetType:null,value:a.parameter});this.actions[i].serialize(o),n.children.push(o)}return n},t.Parse=function(e,n,i){var o=new t(i);n===null?i.actionManager=o:n.actionManager=o;for(var a=function(m,v,b,E){if(E===null){var C=parseFloat(v);return v==="true"||v==="false"?v==="true":isNaN(C)?v:C}for(var T=E.split("."),f=v.split(","),g=0;g<T.length;g++)b=b[T[g]];if(typeof b=="boolean")return f[0]==="true";if(typeof b=="string")return f[0];var S=[];for(g=0;g<f.length;g++)S.push(parseFloat(f[g]));return b instanceof _.Pq?_.Pq.FromArray(S):b instanceof _.IU?_.IU.FromArray(S):b instanceof z.v9?z.v9.FromArray(S):b instanceof z.ov?z.ov.FromArray(S):parseFloat(f[0])},s=function(m,v,b,E,C){if(C===void 0&&(C=null),!m.detached){var T=[],f=null,g=null,S=m.combine&&m.combine.length>0;if(m.type===2?T.push(o):T.push(v),S){for(var y=[],x=0;x<m.combine.length;x++)s(m.combine[x],t.NothingTrigger,b,E,y);T.push(y)}else for(var R=0;R<m.properties.length;R++){var I=m.properties[R].value,M=m.properties[R].name,D=m.properties[R].targetType;M==="target"?I=f=D==="SceneProperties"?i:D==="MaterialProperties"?i.getMaterialByName(I):i.getNodeByName(I):M==="parent"?I=i.getNodeByName(I):M==="sound"?i.getSoundByName&&(I=i.getSoundByName(I)):M!=="propertyPath"?I=m.type===2&&M==="operator"?ae[I]:a(0,I,f,M==="value"?g:null):g=I,T.push(I)}if(C===null?T.push(b):T.push(null),m.name==="InterpolateValueAction"){var B=T[T.length-2];T[T.length-1]=B,T[T.length-2]=b}var F=function($,Q){var ie=(0,j.n9)("BABYLON."+$);return ie&&new(ie.bind.apply(ie,(0,A.fX)([void 0],Q,!1)))}(m.name,T);if(F instanceof ne&&b!==null){var X=new Pe(v,b);E?E.then(X):o.registerAction(X),E=X}for(C===null?F instanceof ne?(b=F,F=E):(b=null,E?E.then(F):o.registerAction(F)):C.push(F),R=0;R<m.children.length;R++)s(m.children[R],v,b,F,null)}},l=0;l<e.children.length;l++){var c=void 0,u=e.children[l];if(u.properties.length>0){var d=u.properties[0].value,h=u.properties[0].targetType===null?d:i.getMeshByName(d);h._meshId&&(h.mesh=i.getMeshById(h._meshId)),c={trigger:t[u.name],parameter:h}}else c=t[u.name];for(var p=0;p<u.children.length;p++)u.detached||s(u.children[p],c,null,null)}},t.GetTriggerName=function(e){switch(e){case P.Y.ACTION_NothingTrigger:return"NothingTrigger";case P.Y.ACTION_OnPickTrigger:return"OnPickTrigger";case P.Y.ACTION_OnLeftPickTrigger:return"OnLeftPickTrigger";case P.Y.ACTION_OnRightPickTrigger:return"OnRightPickTrigger";case P.Y.ACTION_OnCenterPickTrigger:return"OnCenterPickTrigger";case P.Y.ACTION_OnPickDownTrigger:return"OnPickDownTrigger";case P.Y.ACTION_OnDoublePickTrigger:return"OnDoublePickTrigger";case P.Y.ACTION_OnPickUpTrigger:return"OnPickUpTrigger";case P.Y.ACTION_OnLongPressTrigger:return"OnLongPressTrigger";case P.Y.ACTION_OnPointerOverTrigger:return"OnPointerOverTrigger";case P.Y.ACTION_OnPointerOutTrigger:return"OnPointerOutTrigger";case P.Y.ACTION_OnEveryFrameTrigger:return"OnEveryFrameTrigger";case P.Y.ACTION_OnIntersectionEnterTrigger:return"OnIntersectionEnterTrigger";case P.Y.ACTION_OnIntersectionExitTrigger:return"OnIntersectionExitTrigger";case P.Y.ACTION_OnKeyDownTrigger:return"OnKeyDownTrigger";case P.Y.ACTION_OnKeyUpTrigger:return"OnKeyUpTrigger";case P.Y.ACTION_OnPickOutTrigger:return"OnPickOutTrigger";default:return""}},t.NothingTrigger=P.Y.ACTION_NothingTrigger,t.OnPickTrigger=P.Y.ACTION_OnPickTrigger,t.OnLeftPickTrigger=P.Y.ACTION_OnLeftPickTrigger,t.OnRightPickTrigger=P.Y.ACTION_OnRightPickTrigger,t.OnCenterPickTrigger=P.Y.ACTION_OnCenterPickTrigger,t.OnPickDownTrigger=P.Y.ACTION_OnPickDownTrigger,t.OnDoublePickTrigger=P.Y.ACTION_OnDoublePickTrigger,t.OnPickUpTrigger=P.Y.ACTION_OnPickUpTrigger,t.OnPickOutTrigger=P.Y.ACTION_OnPickOutTrigger,t.OnLongPressTrigger=P.Y.ACTION_OnLongPressTrigger,t.OnPointerOverTrigger=P.Y.ACTION_OnPointerOverTrigger,t.OnPointerOutTrigger=P.Y.ACTION_OnPointerOutTrigger,t.OnEveryFrameTrigger=P.Y.ACTION_OnEveryFrameTrigger,t.OnIntersectionEnterTrigger=P.Y.ACTION_OnIntersectionEnterTrigger,t.OnIntersectionExitTrigger=P.Y.ACTION_OnIntersectionExitTrigger,t.OnKeyDownTrigger=P.Y.ACTION_OnKeyDownTrigger,t.OnKeyUpTrigger=P.Y.ACTION_OnKeyUpTrigger,t}(Ne.G),ft=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._sound=n,o}return(0,A.C6)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._sound!==void 0&&this._sound.play()},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"PlaySoundAction",properties:[{name:"sound",value:this._sound.name}]},e)},t}(me),xt=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._sound=n,o}return(0,A.C6)(t,r),t.prototype._prepare=function(){},t.prototype.execute=function(){this._sound!==void 0&&this._sound.stop()},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"StopSoundAction",properties:[{name:"sound",value:this._sound.name}]},e)},t}(me);(0,j.Y5)("BABYLON.PlaySoundAction",ft),(0,j.Y5)("BABYLON.StopSoundAction",xt);var qe=L(48810),kt=function(){function r(t,e,n){this.name=t,this.from=e,this.to=n}return r.prototype.clone=function(){return new r(this.name,this.from,this.to)},r}(),V=L(6174),gt=L(41190),tt=L(12028),Jt=function(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new K.cP,this._onClonedObservable=new K.cP},At=function(){function r(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!0),this._isDirty=!1,this._nodeDataStorage=new Jt,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new K.cP,this._parentContainer=null,this.animations=[],this._ranges={},this.onReady=null,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._waitingParentInstanceIndex=null,this._waitingParsedUniqueId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=_.uq.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new K.cP,this._onDisposeObserver=null,this._behaviors=new Array,this.name=t,this.id=t,this._scene=e||Ve.q.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),n&&this._addToSceneRootNodes()}return r.AddNodeConstructor=function(t,e){this._NodeConstructors[t]=e},r.Construct=function(t,e,n,i){var o=this._NodeConstructors[t];return o?o(e,n,i):null},Object.defineProperty(r.prototype,"accessibilityTag",{get:function(){return this._accessibilityTag},set:function(t){this._accessibilityTag=t,this.onAccessibilityTagChangedObservable.notifyObservers(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"doNotSerialize",{get:function(){return!!this._nodeDataStorage._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize},set:function(t){this._nodeDataStorage._doNotSerialize=t},enumerable:!1,configurable:!0}),r.prototype.isDisposed=function(){return this._nodeDataStorage._isDisposed},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parentNode},set:function(t){if(this._parentNode!==t){var e=this._parentNode;if(this._parentNode&&this._parentNode._children!==void 0&&this._parentNode._children!==null){var n=this._parentNode._children.indexOf(this);n!==-1&&this._parentNode._children.splice(n,1),t||this._nodeDataStorage._isDisposed||this._addToSceneRootNodes()}this._parentNode=t,this._isDirty=!0,this._parentNode&&(this._parentNode._children!==void 0&&this._parentNode._children!==null||(this._parentNode._children=new Array),this._parentNode._children.push(this),e||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!1,configurable:!0}),r.prototype._serializeAsParent=function(t){t.parentId=this.uniqueId},r.prototype._addToSceneRootNodes=function(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},r.prototype._removeFromSceneRootNodes=function(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){var t=this._scene.rootNodes,e=t.length-1;t[this._nodeDataStorage._sceneRootNodesIndex]=t[e],t[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex=this._nodeDataStorage._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._nodeDataStorage._sceneRootNodesIndex=-1}},Object.defineProperty(r.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(t){this._animationPropertiesOverride=t},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"Node"},Object.defineProperty(r.prototype,"onDispose",{set:function(t){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onEnabledStateChangedObservable",{get:function(){return this._nodeDataStorage._onEnabledStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onClonedObservable",{get:function(){return this._nodeDataStorage._onClonedObservable},enumerable:!1,configurable:!0}),r.prototype.getScene=function(){return this._scene},r.prototype.getEngine=function(){return this._scene.getEngine()},r.prototype.addBehavior=function(t,e){var n=this;return e===void 0&&(e=!1),this._behaviors.indexOf(t)!==-1||(t.init(),this._scene.isLoading&&!e?this._scene.onDataLoadedObservable.addOnce(function(){t.attach(n)}):t.attach(this),this._behaviors.push(t)),this},r.prototype.removeBehavior=function(t){var e=this._behaviors.indexOf(t);return e===-1||(this._behaviors[e].detach(),this._behaviors.splice(e,1)),this},Object.defineProperty(r.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),r.prototype.getBehaviorByName=function(t){for(var e=0,n=this._behaviors;e<n.length;e++){var i=n[e];if(i.name===t)return i}return null},r.prototype.getWorldMatrix=function(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},r.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant},Object.defineProperty(r.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!1,configurable:!0}),r.prototype._initCache=function(){this._cache={}},r.prototype.updateCache=function(t){!t&&this.isSynchronized()||this._updateCache()},r.prototype._getActionManagerForTrigger=function(t,e){return this.parent?this.parent._getActionManagerForTrigger(t,!1):null},r.prototype._updateCache=function(t){},r.prototype._isSynchronized=function(){return!0},r.prototype._markSyncedWithParent=function(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)},r.prototype.isSynchronizedWithParent=function(){return!this._parentNode||!this._parentNode._isDirty&&this._parentUpdateId===this._parentNode._childUpdateId&&this._parentNode.isSynchronized()},r.prototype.isSynchronized=function(){return!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()},r.prototype.isReady=function(t){return this._nodeDataStorage._isReady},r.prototype.markAsDirty=function(t){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},r.prototype.isEnabled=function(t){return t===void 0&&(t=!0),t===!1?this._nodeDataStorage._isEnabled:!!this._nodeDataStorage._isEnabled&&this._nodeDataStorage._isParentEnabled},r.prototype._syncParentEnabledState=function(){this._nodeDataStorage._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach(function(t){t._syncParentEnabledState()})},r.prototype.setEnabled=function(t){this._nodeDataStorage._isEnabled!==t&&(this._nodeDataStorage._isEnabled=t,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(t))},r.prototype.isDescendantOf=function(t){return!!this.parent&&(this.parent===t||this.parent.isDescendantOf(t))},r.prototype._getDescendants=function(t,e,n){if(e===void 0&&(e=!1),this._children)for(var i=0;i<this._children.length;i++){var o=this._children[i];n&&!n(o)||t.push(o),e||o._getDescendants(t,!1,n)}},r.prototype.getDescendants=function(t,e){var n=[];return this._getDescendants(n,t,e),n},r.prototype.getChildMeshes=function(t,e){var n=[];return this._getDescendants(n,t,function(i){return(!e||e(i))&&i.cullingStrategy!==void 0}),n},r.prototype.getChildren=function(t,e){return e===void 0&&(e=!0),this.getDescendants(e,t)},r.prototype._setReady=function(t){t!==this._nodeDataStorage._isReady&&(t?(this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0):this._nodeDataStorage._isReady=!1)},r.prototype.getAnimationByName=function(t){for(var e=0;e<this.animations.length;e++){var n=this.animations[e];if(n.name===t)return n}return null},r.prototype.createAnimationRange=function(t,e,n){if(!this._ranges[t]){this._ranges[t]=r._AnimationRangeFactory(t,e,n);for(var i=0,o=this.animations.length;i<o;i++)this.animations[i]&&this.animations[i].createRange(t,e,n)}},r.prototype.deleteAnimationRange=function(t,e){e===void 0&&(e=!0);for(var n=0,i=this.animations.length;n<i;n++)this.animations[n]&&this.animations[n].deleteRange(t,e);this._ranges[t]=null},r.prototype.getAnimationRange=function(t){return this._ranges[t]||null},r.prototype.clone=function(t,e,n){var i=this,o=tt.p.Clone(function(){return new r(t,i.getScene())},this);if(e&&(o.parent=e),!n)for(var a=this.getDescendants(!0),s=0;s<a.length;s++){var l=a[s];l.clone(t+"."+l.name,o)}return o},r.prototype.getAnimationRanges=function(){var t,e=[];for(t in this._ranges)e.push(this._ranges[t]);return e},r.prototype.beginAnimation=function(t,e,n,i){var o=this.getAnimationRange(t);return o?this._scene.beginAnimation(this,o.from,o.to,e,n,i):null},r.prototype.serializeAnimationRanges=function(){var t=[];for(var e in this._ranges){var n=this._ranges[e];if(n){var i={};i.name=e,i.from=n.from,i.to=n.to,t.push(i)}}return t},r.prototype.computeWorldMatrix=function(t){return this._worldMatrix||(this._worldMatrix=_.uq.Identity()),this._worldMatrix},r.prototype.dispose=function(t,e){if(e===void 0&&(e=!1),this._nodeDataStorage._isDisposed=!0,!t)for(var n=0,i=this.getDescendants(!0);n<i.length;n++)i[n].dispose(t,e);this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onEnabledStateChangedObservable.clear(),this.onClonedObservable.clear();for(var o=0,a=this._behaviors;o<a.length;o++)a[o].detach();this._behaviors.length=0,this.metadata=null},r.ParseAnimationRanges=function(t,e,n){if(e.ranges)for(var i=0;i<e.ranges.length;i++){var o=e.ranges[i];t.createAnimationRange(o.name,o.from,o.to)}},r.prototype.getHierarchyBoundingVectors=function(t,e){var n,i;t===void 0&&(t=!0),e===void 0&&(e=null),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);var o=this;if(o.getBoundingInfo&&o.subMeshes){var a=o.getBoundingInfo();n=a.boundingBox.minimumWorld.clone(),i=a.boundingBox.maximumWorld.clone()}else n=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new _.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(t)for(var s=0,l=this.getDescendants(!1);s<l.length;s++){var c=l[s];if(c.computeWorldMatrix(!0),(!e||e(c))&&c.getBoundingInfo&&c.getTotalVertices()!==0){var u=c.getBoundingInfo().boundingBox,d=u.minimumWorld,h=u.maximumWorld;_.Pq.CheckExtends(d,n,i),_.Pq.CheckExtends(h,n,i)}}return{min:n,max:i}},r._AnimationRangeFactory=function(t,e,n){throw(0,gt.n)("AnimationRange")},r._NodeConstructors={},(0,A.Cg)([(0,V.lK)()],r.prototype,"name",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"id",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"uniqueId",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"state",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"metadata",void 0),r}(),gn=L(73152),We=L(46799),Xe=Object.freeze(new _.PT(0,0,0,0)),Ze=Object.freeze(_.Pq.Zero()),ge=Object.freeze(_.I9.Zero()),pe=Object.freeze(gn.o.Zero()),Ce=Object.freeze(z.v9.Black()),De=Object.freeze(new z.ov(0,0,0,0)),Fe={key:0,repeatCount:0,loopMode:2},Le=function(){function r(t,e,n,i,o,a){this.name=t,this.targetProperty=e,this.framePerSecond=n,this.dataType=i,this.loopMode=o,this.enableBlending=a,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=e.split("."),this.dataType=i,this.loopMode=o===void 0?r.ANIMATIONLOOPMODE_CYCLE:o,this.uniqueId=r._UniqueIdGenerator++}return r._PrepareAnimation=function(t,e,n,i,o,a,s,l){var c=void 0;if(!isNaN(parseFloat(o))&&isFinite(o)?c=r.ANIMATIONTYPE_FLOAT:o instanceof _.PT?c=r.ANIMATIONTYPE_QUATERNION:o instanceof _.Pq?c=r.ANIMATIONTYPE_VECTOR3:o instanceof _.I9?c=r.ANIMATIONTYPE_VECTOR2:o instanceof z.v9?c=r.ANIMATIONTYPE_COLOR3:o instanceof z.ov?c=r.ANIMATIONTYPE_COLOR4:o instanceof gn.o&&(c=r.ANIMATIONTYPE_SIZE),c==null)return null;var u=new r(t,e,n,c,s),d=[{frame:0,value:o},{frame:i,value:a}];return u.setKeys(d),l!==void 0&&u.setEasingFunction(l),u},r.CreateAnimation=function(t,e,n,i){var o=new r(t+"Animation",t,n,e,r.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(i),o},r.CreateAndStartAnimation=function(t,e,n,i,o,a,s,l,c,u,d){var h=r._PrepareAnimation(t,n,i,o,a,s,l,c);return h?(e.getScene&&(d=e.getScene()),d?d.beginDirectAnimation(e,[h],0,o,h.loopMode===1,1,u):null):null},r.CreateAndStartHierarchyAnimation=function(t,e,n,i,o,a,s,l,c,u,d){var h=r._PrepareAnimation(t,i,o,a,s,l,c,u);return h?e.getScene().beginDirectHierarchyAnimation(e,n,[h],0,a,h.loopMode===1,1,d):null},r.CreateMergeAndStartAnimation=function(t,e,n,i,o,a,s,l,c,u){var d=r._PrepareAnimation(t,n,i,o,a,s,l,c);return d?(e.animations.push(d),e.getScene().beginAnimation(e,0,o,d.loopMode===1,1,u)):null},r.MakeAnimationAdditive=function(t,e,n,i,o){var a,s,l;i===void 0&&(i=!1);var c=t;if((l=typeof e=="object"?e:{referenceFrame:e??0,range:n,cloneOriginalAnimation:i,clonedAnimationName:o}).cloneOriginalAnimation&&((c=t.clone()).name=l.clonedAnimationName||c.name),!c._keys.length)return c;var u=l.referenceFrame&&l.referenceFrame>=0?l.referenceFrame:0,d=0,h=c._keys[0],p=c._keys.length-1,m=c._keys[p],v={referenceValue:h.value,referencePosition:_.AA.Vector3[0],referenceQuaternion:_.AA.Quaternion[0],referenceScaling:_.AA.Vector3[1],keyPosition:_.AA.Vector3[2],keyQuaternion:_.AA.Quaternion[1],keyScaling:_.AA.Vector3[3]},b=h.frame,E=m.frame;if(l.range){var C=c.getRange(l.range);C&&(b=C.from,E=C.to)}else b=(a=l.fromFrame)!==null&&a!==void 0?a:b,E=(s=l.toFrame)!==null&&s!==void 0?s:E;if(b!==h.frame&&(d=c.createKeyForFrame(b)),E!==m.frame&&(p=c.createKeyForFrame(E)),c._keys.length===1){var T=c._getKeyValue(c._keys[0]);v.referenceValue=T.clone?T.clone():T}else u<=h.frame?(T=c._getKeyValue(h.value),v.referenceValue=T.clone?T.clone():T):u>=m.frame?(T=c._getKeyValue(m.value),v.referenceValue=T.clone?T.clone():T):(Fe.key=0,T=c._interpolate(u,Fe),v.referenceValue=T.clone?T.clone():T);c.dataType===r.ANIMATIONTYPE_QUATERNION?v.referenceValue.normalize().conjugateInPlace():c.dataType===r.ANIMATIONTYPE_MATRIX&&(v.referenceValue.decompose(v.referenceScaling,v.referenceQuaternion,v.referencePosition),v.referenceQuaternion.normalize().conjugateInPlace());for(var f=Number.MAX_VALUE,g=l.clipKeys?[]:null,S=d;S<=p;S++){var y=c._keys[S];if((g||l.cloneOriginalAnimation)&&(y={frame:y.frame,value:y.value.clone?y.value.clone():y.value,inTangent:y.inTangent,outTangent:y.outTangent,interpolation:y.interpolation,lockedTangent:y.lockedTangent},g&&(f===Number.MAX_VALUE&&(f=y.frame),y.frame-=f,g.push(y))),!S||c.dataType===r.ANIMATIONTYPE_FLOAT||y.value!==h.value)switch(c.dataType){case r.ANIMATIONTYPE_MATRIX:y.value.decompose(v.keyScaling,v.keyQuaternion,v.keyPosition),v.keyPosition.subtractInPlace(v.referencePosition),v.keyScaling.divideInPlace(v.referenceScaling),v.referenceQuaternion.multiplyToRef(v.keyQuaternion,v.keyQuaternion),_.uq.ComposeToRef(v.keyScaling,v.keyQuaternion,v.keyPosition,y.value);break;case r.ANIMATIONTYPE_QUATERNION:v.referenceValue.multiplyToRef(y.value,y.value);break;case r.ANIMATIONTYPE_VECTOR2:case r.ANIMATIONTYPE_VECTOR3:case r.ANIMATIONTYPE_COLOR3:case r.ANIMATIONTYPE_COLOR4:y.value.subtractToRef(v.referenceValue,y.value);break;case r.ANIMATIONTYPE_SIZE:y.value.width-=v.referenceValue.width,y.value.height-=v.referenceValue.height;break;default:y.value-=v.referenceValue}}return g&&c.setKeys(g,!0),c},r.TransitionTo=function(t,e,n,i,o,a,s,l){if(l===void 0&&(l=null),s<=0)return n[t]=e,l&&l(),null;var c=o*(s/1e3);a.setKeys([{frame:0,value:n[t].clone?n[t].clone():n[t]},{frame:c,value:e}]),n.animations||(n.animations=[]),n.animations.push(a);var u=i.beginAnimation(n,0,c,!1);return u.onAnimationEnd=l,u},Object.defineProperty(r.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var t=0,e=this._runtimeAnimations;t<e.length;t++)if(!e[t].isStopped())return!0;return!1},enumerable:!1,configurable:!0}),r.prototype.toString=function(t){var e="Name: "+this.name+", property: "+this.targetProperty;if(e+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],e+=", nKeys: "+(this._keys?this._keys.length:"none"),e+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),t){e+=", Ranges: {";var n=!0;for(var i in this._ranges)n&&(e+=", ",n=!1),e+=i;e+="}"}return e},r.prototype.addEvent=function(t){this._events.push(t),this._events.sort(function(e,n){return e.frame-n.frame})},r.prototype.removeEvents=function(t){for(var e=0;e<this._events.length;e++)this._events[e].frame===t&&(this._events.splice(e,1),e--)},r.prototype.getEvents=function(){return this._events},r.prototype.createRange=function(t,e,n){this._ranges[t]||(this._ranges[t]=new kt(t,e,n))},r.prototype.deleteRange=function(t,e){e===void 0&&(e=!0);var n=this._ranges[t];if(n){if(e)for(var i=n.from,o=n.to,a=this._keys.length-1;a>=0;a--)this._keys[a].frame>=i&&this._keys[a].frame<=o&&this._keys.splice(a,1);this._ranges[t]=null}},r.prototype.getRange=function(t){return this._ranges[t]},r.prototype.getKeys=function(){return this._keys},r.prototype.getHighestFrame=function(){for(var t=0,e=0,n=this._keys.length;e<n;e++)t<this._keys[e].frame&&(t=this._keys[e].frame);return t},r.prototype.getEasingFunction=function(){return this._easingFunction},r.prototype.setEasingFunction=function(t){this._easingFunction=t},r.prototype.floatInterpolateFunction=function(t,e,n){return(0,qe.Lerp)(t,e,n)},r.prototype.floatInterpolateFunctionWithTangents=function(t,e,n,i,o){return(0,qe.Hermite)(t,e,n,i,o)},r.prototype.quaternionInterpolateFunction=function(t,e,n){return _.PT.Slerp(t,e,n)},r.prototype.quaternionInterpolateFunctionWithTangents=function(t,e,n,i,o){return _.PT.Hermite(t,e,n,i,o).normalize()},r.prototype.vector3InterpolateFunction=function(t,e,n){return _.Pq.Lerp(t,e,n)},r.prototype.vector3InterpolateFunctionWithTangents=function(t,e,n,i,o){return _.Pq.Hermite(t,e,n,i,o)},r.prototype.vector2InterpolateFunction=function(t,e,n){return _.I9.Lerp(t,e,n)},r.prototype.vector2InterpolateFunctionWithTangents=function(t,e,n,i,o){return _.I9.Hermite(t,e,n,i,o)},r.prototype.sizeInterpolateFunction=function(t,e,n){return gn.o.Lerp(t,e,n)},r.prototype.color3InterpolateFunction=function(t,e,n){return z.v9.Lerp(t,e,n)},r.prototype.color3InterpolateFunctionWithTangents=function(t,e,n,i,o){return z.v9.Hermite(t,e,n,i,o)},r.prototype.color4InterpolateFunction=function(t,e,n){return z.ov.Lerp(t,e,n)},r.prototype.color4InterpolateFunctionWithTangents=function(t,e,n,i,o){return z.ov.Hermite(t,e,n,i,o)},r.prototype._getKeyValue=function(t){return typeof t=="function"?t():t},r.prototype.evaluate=function(t){return Fe.key=0,this._interpolate(t,Fe)},r.prototype._interpolate=function(t,e,n){var i;if(n===void 0&&(n=!1),e.loopMode===r.ANIMATIONLOOPMODE_CONSTANT&&e.repeatCount>0)return e.highLimitValue.clone?e.highLimitValue.clone():e.highLimitValue;for(var o=this._keys,a=o.length,s=e.key;s>=0&&t<o[s].frame;)--s;for(;s+1<=a-1&&t>=o[s+1].frame;)++s;if(e.key=s,s<0)return n?void 0:this._getKeyValue(o[0].value);if(s+1>a-1)return n?void 0:this._getKeyValue(o[a-1].value);var l=o[s],c=o[s+1];if(!n||t!==l.frame&&t!==c.frame){var u=this._getKeyValue(l.value),d=this._getKeyValue(c.value);if(l.interpolation===1)return c.frame>t?u:d;var h=l.outTangent!==void 0&&c.inTangent!==void 0,p=c.frame-l.frame,m=(t-l.frame)/p,v=l.easingFunction||this.getEasingFunction();switch(v!==null&&(m=v.ease(m)),this.dataType){case r.ANIMATIONTYPE_FLOAT:var b=h?this.floatInterpolateFunctionWithTangents(u,l.outTangent*p,d,c.inTangent*p,m):this.floatInterpolateFunction(u,d,m);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return b;case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return((i=e.offsetValue)!==null&&i!==void 0?i:0)*e.repeatCount+b}break;case r.ANIMATIONTYPE_QUATERNION:var E=h?this.quaternionInterpolateFunctionWithTangents(u,l.outTangent.scale(p),d,c.inTangent.scale(p),m):this.quaternionInterpolateFunction(u,d,m);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return E;case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return E.addInPlace((e.offsetValue||Xe).scale(e.repeatCount))}return E;case r.ANIMATIONTYPE_VECTOR3:var C=h?this.vector3InterpolateFunctionWithTangents(u,l.outTangent.scale(p),d,c.inTangent.scale(p),m):this.vector3InterpolateFunction(u,d,m);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return C;case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return C.add((e.offsetValue||Ze).scale(e.repeatCount))}break;case r.ANIMATIONTYPE_VECTOR2:var T=h?this.vector2InterpolateFunctionWithTangents(u,l.outTangent.scale(p),d,c.inTangent.scale(p),m):this.vector2InterpolateFunction(u,d,m);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return T;case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return T.add((e.offsetValue||ge).scale(e.repeatCount))}break;case r.ANIMATIONTYPE_SIZE:switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(u,d,m);case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(u,d,m).add((e.offsetValue||pe).scale(e.repeatCount))}break;case r.ANIMATIONTYPE_COLOR3:var f=h?this.color3InterpolateFunctionWithTangents(u,l.outTangent.scale(p),d,c.inTangent.scale(p),m):this.color3InterpolateFunction(u,d,m);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return f;case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return f.add((e.offsetValue||Ce).scale(e.repeatCount))}break;case r.ANIMATIONTYPE_COLOR4:var g=h?this.color4InterpolateFunctionWithTangents(u,l.outTangent.scale(p),d,c.inTangent.scale(p),m):this.color4InterpolateFunction(u,d,m);switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return g;case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((e.offsetValue||De).scale(e.repeatCount))}break;case r.ANIMATIONTYPE_MATRIX:switch(e.loopMode){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:case r.ANIMATIONLOOPMODE_YOYO:return r.AllowMatricesInterpolation?this.matrixInterpolateFunction(u,d,m,e.workValue):u;case r.ANIMATIONLOOPMODE_RELATIVE:case r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return u}}return 0}},r.prototype.matrixInterpolateFunction=function(t,e,n,i){return r.AllowMatrixDecomposeForInterpolation?i?(_.uq.DecomposeLerpToRef(t,e,n,i),i):_.uq.DecomposeLerp(t,e,n):i?(_.uq.LerpToRef(t,e,n,i),i):_.uq.Lerp(t,e,n)},r.prototype.clone=function(){var t=new r(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys),this._ranges)for(var e in t._ranges={},this._ranges){var n=this._ranges[e];n&&(t._ranges[e]=n.clone())}return t},r.prototype.setKeys=function(t,e){e===void 0&&(e=!1),this._keys=e?t:t.slice(0)},r.prototype.createKeyForFrame=function(t){Fe.key=0;var e=this._interpolate(t,Fe,!0);if(!e)return this._keys[Fe.key].frame===t?Fe.key:Fe.key+1;var n={frame:t,value:e.clone?e.clone():e};return this._keys.splice(Fe.key+1,0,n),Fe.key+1},r.prototype.serialize=function(){var t={};t.name=this.name,t.property=this.targetProperty,t.framePerSecond=this.framePerSecond,t.dataType=this.dataType,t.loopBehavior=this.loopMode,t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed;var e=this.dataType;t.keys=[];for(var n=this.getKeys(),i=0;i<n.length;i++){var o=n[i],a={};switch(a.frame=o.frame,e){case r.ANIMATIONTYPE_FLOAT:a.values=[o.value],o.inTangent!==void 0&&a.values.push(o.inTangent),o.outTangent!==void 0&&(o.inTangent===void 0&&a.values.push(void 0),a.values.push(o.outTangent)),o.interpolation!==void 0&&(o.inTangent===void 0&&a.values.push(void 0),o.outTangent===void 0&&a.values.push(void 0),a.values.push(o.interpolation));break;case r.ANIMATIONTYPE_QUATERNION:case r.ANIMATIONTYPE_MATRIX:case r.ANIMATIONTYPE_VECTOR3:case r.ANIMATIONTYPE_COLOR3:case r.ANIMATIONTYPE_COLOR4:a.values=o.value.asArray(),o.inTangent!=null&&a.values.push(o.inTangent.asArray()),o.outTangent!=null&&(o.inTangent===void 0&&a.values.push(void 0),a.values.push(o.outTangent.asArray())),o.interpolation!==void 0&&(o.inTangent===void 0&&a.values.push(void 0),o.outTangent===void 0&&a.values.push(void 0),a.values.push(o.interpolation))}t.keys.push(a)}for(var s in t.ranges=[],this._ranges){var l=this._ranges[s];if(l){var c={};c.name=s,c.from=l.from,c.to=l.to,t.ranges.push(c)}}return t},r._UniversalLerp=function(t,e,n){var i=t.constructor;return i.Lerp?i.Lerp(t,e,n):i.Slerp?i.Slerp(t,e,n):t.toFixed?t*(1-n)+n*e:e},r.Parse=function(t){var e,n,i=new r(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),o=t.dataType,a=[];for(t.enableBlending&&(i.enableBlending=t.enableBlending),t.blendingSpeed&&(i.blendingSpeed=t.blendingSpeed),n=0;n<t.keys.length;n++){var s=t.keys[n],l=void 0,c=void 0,u=void 0;switch(o){case r.ANIMATIONTYPE_FLOAT:e=s.values[0],s.values.length>=2&&(l=s.values[1]),s.values.length>=3&&(c=s.values[2]),s.values.length>=4&&(u=s.values[3]);break;case r.ANIMATIONTYPE_QUATERNION:if(e=_.PT.FromArray(s.values),s.values.length>=8){var d=_.PT.FromArray(s.values.slice(4,8));d.equals(_.PT.Zero())||(l=d)}if(s.values.length>=12){var h=_.PT.FromArray(s.values.slice(8,12));h.equals(_.PT.Zero())||(c=h)}s.values.length>=13&&(u=s.values[12]);break;case r.ANIMATIONTYPE_MATRIX:e=_.uq.FromArray(s.values),s.values.length>=17&&(u=s.values[16]);break;case r.ANIMATIONTYPE_COLOR3:e=z.v9.FromArray(s.values),s.values[3]&&(l=z.v9.FromArray(s.values[3])),s.values[4]&&(c=z.v9.FromArray(s.values[4])),s.values[5]&&(u=s.values[5]);break;case r.ANIMATIONTYPE_COLOR4:e=z.ov.FromArray(s.values),s.values[4]&&(l=z.ov.FromArray(s.values[4])),s.values[5]&&(c=z.ov.FromArray(s.values[5])),s.values[6]&&(u=z.ov.FromArray(s.values[6]));break;case r.ANIMATIONTYPE_VECTOR3:default:e=_.Pq.FromArray(s.values),s.values[3]&&(l=_.Pq.FromArray(s.values[3])),s.values[4]&&(c=_.Pq.FromArray(s.values[4])),s.values[5]&&(u=s.values[5])}var p={};p.frame=s.frame,p.value=e,l!=null&&(p.inTangent=l),c!=null&&(p.outTangent=c),u!=null&&(p.interpolation=u),a.push(p)}if(i.setKeys(a),t.ranges)for(n=0;n<t.ranges.length;n++)e=t.ranges[n],i.createRange(e.name,e.from,e.to);return i},r.AppendSerializedAnimations=function(t,e){tt.p.AppendSerializedAnimations(t,e)},r.ParseFromFileAsync=function(t,e){var n=this;return new Promise(function(i,o){var a=new We.u;a.addEventListener("readystatechange",function(){if(a.readyState==4)if(a.status==200){var s=JSON.parse(a.responseText);if(s.animations&&(s=s.animations),s.length){for(var l=[],c=0,u=s;c<u.length;c++){var d=u[c];l.push(n.Parse(d))}i(l)}else l=n.Parse(s),t&&(l.name=t),i(l)}else o("Unable to load the animation")}),a.open("GET",e),a.send()})},r.ParseFromSnippetAsync=function(t){var e=this;return new Promise(function(n,i){var o=new We.u;o.addEventListener("readystatechange",function(){if(o.readyState==4)if(o.status==200){var a=JSON.parse(JSON.parse(o.responseText).jsonPayload);if(a.animations){for(var s=[],l=0,c=(h=JSON.parse(a.animations)).animations;l<c.length;l++){var u=c[l];(d=e.Parse(u)).snippetId=t,s.push(d)}n(s)}else{var d,h=JSON.parse(a.animation);(d=e.Parse(h)).snippetId=t,n(d)}}else i("Unable to load the snippet "+t)}),o.open("GET",e.SnippetUrl+"/"+t.replace(/#/g,"/")),o.send()})},r._UniqueIdGenerator=0,r.AllowMatricesInterpolation=!1,r.AllowMatrixDecomposeForInterpolation=!0,r.SnippetUrl=P.Y.SnippetUrl,r.ANIMATIONTYPE_FLOAT=0,r.ANIMATIONTYPE_VECTOR3=1,r.ANIMATIONTYPE_QUATERNION=2,r.ANIMATIONTYPE_MATRIX=3,r.ANIMATIONTYPE_COLOR3=4,r.ANIMATIONTYPE_COLOR4=7,r.ANIMATIONTYPE_VECTOR2=5,r.ANIMATIONTYPE_SIZE=6,r.ANIMATIONLOOPMODE_RELATIVE=0,r.ANIMATIONLOOPMODE_CYCLE=1,r.ANIMATIONLOOPMODE_CONSTANT=2,r.ANIMATIONLOOPMODE_YOYO=4,r.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5,r.CreateFromSnippetAsync=r.ParseFromSnippetAsync,r}();(0,j.Y5)("BABYLON.Animation",Le),At._AnimationRangeFactory=function(r,t,e){return new kt(r,t,e)};var Ye=function(r){function t(e,n,i,o,a,s,l,c){a===void 0&&(a=1e3);var u=r.call(this,e,s)||this;return u.duration=1e3,u.onInterpolationDoneObservable=new K.cP,u.propertyPath=i,u.value=o,u.duration=a,u.stopOtherAnimations=l,u.onInterpolationDone=c,u._target=u._effectiveTarget=n,u}return(0,A.C6)(t,r),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){var e,n=this,i=this._actionManager.getScene(),o=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if(typeof this.value=="number")e=Le.ANIMATIONTYPE_FLOAT;else if(this.value instanceof z.v9)e=Le.ANIMATIONTYPE_COLOR3;else if(this.value instanceof _.Pq)e=Le.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof _.uq)e=Le.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof _.PT))return void O.V.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");e=Le.ANIMATIONTYPE_QUATERNION}var a=new Le("InterpolateValueAction",this._property,1e3/this.duration*100,e,Le.ANIMATIONLOOPMODE_CONSTANT);a.setKeys(o),this.stopOtherAnimations&&i.stopAnimation(this._effectiveTarget),i.beginDirectAnimation(this._effectiveTarget,[a],0,100,!1,1,function(){n.onInterpolationDoneObservable.notifyObservers(n),n.onInterpolationDone&&n.onInterpolationDone()})},t.prototype.serialize=function(e){return r.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[me._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:me._SerializeValueAsString(this.value)},{name:"duration",value:me._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:me._SerializeValueAsString(this.stopOtherAnimations)||!1}]},e)},t}(me);(0,j.Y5)("BABYLON.InterpolateValueAction",Ye);var ct=function(){function r(t,e,n,i){var o=this;if(this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._originalBlendValue=null,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._currentValue=null,this._currentActiveTarget=null,this._directTarget=null,this._targetPath="",this._weight=1,this._absoluteFrameOffset=0,this._previousElapsedTime=0,this._yoyoDirection=1,this._previousAbsoluteFrame=0,this._targetIsArray=!1,this._animation=e,this._target=t,this._scene=n,this._host=i,this._activeTargets=[],e._runtimeAnimations.push(this),this._animationState={key:0,repeatCount:0,loopMode:this._getCorrectLoopMode()},this._animation.dataType===Le.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=_.uq.Zero()),this._keys=this._animation.getKeys(),this._minFrame=this._keys[0].frame,this._maxFrame=this._keys[this._keys.length-1].frame,this._minValue=this._keys[0].value,this._maxValue=this._keys[this._keys.length-1].value,this._minFrame!==0){var a={frame:0,value:this._minValue};this._keys.splice(0,0,a)}if(this._target instanceof Array){for(var s=0,l=0,c=this._target;l<c.length;l++){var u=c[l];this._preparePath(u,s),this._getOriginalValues(s),s++}this._targetIsArray=!0}else this._preparePath(this._target),this._getOriginalValues(),this._targetIsArray=!1,this._directTarget=this._activeTargets[0];var d=e.getEvents();d&&d.length>0&&d.forEach(function(h){o._events.push(h._clone())}),this._enableBlending=t&&t.animationPropertiesOverride?t.animationPropertiesOverride.enableBlending:this._animation.enableBlending}return Object.defineProperty(r.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"weight",{get:function(){return this._weight},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"target",{get:function(){return this._currentActiveTarget},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAdditive",{get:function(){return this._host&&this._host.isAdditive},enumerable:!1,configurable:!0}),r.prototype._preparePath=function(t,e){e===void 0&&(e=0);var n=this._animation.targetPropertyPath;if(n.length>1){for(var i=t,o=0;o<n.length-1;o++){var a=n[o];if((i=i[a])===void 0)throw new Error("Invalid property (".concat(a,") in property path (").concat(n.join("."),")"))}this._targetPath=n[n.length-1],this._activeTargets[e]=i}else this._targetPath=n[0],this._activeTargets[e]=t;if(this._activeTargets[e][this._targetPath]===void 0)throw new Error("Invalid property (".concat(this._targetPath,") in property path (").concat(n.join("."),")"))},Object.defineProperty(r.prototype,"animation",{get:function(){return this._animation},enumerable:!1,configurable:!0}),r.prototype.reset=function(t){if(t===void 0&&(t=!1),t)if(this._target instanceof Array)for(var e=0,n=0,i=this._target;n<i.length;n++){var o=i[n];this._originalValue[e]!==void 0&&this._setValue(o,this._activeTargets[e],this._originalValue[e],-1,e),e++}else this._originalValue[0]!==void 0&&this._setValue(this._target,this._directTarget,this._originalValue[0],-1,0);for(this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0,e=0;e<this._events.length;e++)this._events[e].isDone=!1},r.prototype.isStopped=function(){return this._stopped},r.prototype.dispose=function(){var t=this._animation.runtimeAnimations.indexOf(this);t>-1&&this._animation.runtimeAnimations.splice(t,1)},r.prototype.setValue=function(t,e){if(this._targetIsArray)for(var n=0;n<this._target.length;n++){var i=this._target[n];this._setValue(i,this._activeTargets[n],t,e,n)}else this._setValue(this._target,this._directTarget,t,e,0)},r.prototype._getOriginalValues=function(t){var e;t===void 0&&(t=0);var n=this._activeTargets[t];(e=n.getLocalMatrix&&this._targetPath==="_matrix"?n.getLocalMatrix():n[this._targetPath])&&e.clone?this._originalValue[t]=e.clone():this._originalValue[t]=e},r.prototype._setValue=function(t,e,n,i,o){if(this._currentActiveTarget=e,this._weight=i,this._enableBlending&&this._blendingFactor<=1){if(!this._originalBlendValue){var a=e[this._targetPath];a.clone?this._originalBlendValue=a.clone():this._originalBlendValue=a}this._originalBlendValue.m?Le.AllowMatrixDecomposeForInterpolation?this._currentValue?_.uq.DecomposeLerpToRef(this._originalBlendValue,n,this._blendingFactor,this._currentValue):this._currentValue=_.uq.DecomposeLerp(this._originalBlendValue,n,this._blendingFactor):this._currentValue?_.uq.LerpToRef(this._originalBlendValue,n,this._blendingFactor,this._currentValue):this._currentValue=_.uq.Lerp(this._originalBlendValue,n,this._blendingFactor):this._currentValue=Le._UniversalLerp(this._originalBlendValue,n,this._blendingFactor);var s=t&&t.animationPropertiesOverride?t.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=s}else this._currentValue?this._currentValue.copyFrom?this._currentValue.copyFrom(n):this._currentValue=n:n?.clone?this._currentValue=n.clone():this._currentValue=n;i!==-1?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[o]):this._animationState.loopMode===Le.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT?this._currentValue.addToRef?this._currentValue.addToRef(this._originalValue[o],e[this._targetPath]):e[this._targetPath]=this._originalValue[o]+this._currentValue:e[this._targetPath]=this._currentValue,t.markAsDirty&&t.markAsDirty(this._animation.targetProperty)},r.prototype._getCorrectLoopMode=function(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode},r.prototype.goToFrame=function(t,e){e===void 0&&(e=-1);var n=this._animation.getKeys();t<n[0].frame?t=n[0].frame:t>n[n.length-1].frame&&(t=n[n.length-1].frame);var i=this._events;if(i.length)for(var o=0;o<i.length;o++)i[o].onlyOnce||(i[o].isDone=i[o].frame<t);this._currentFrame=t;var a=this._animation._interpolate(t,this._animationState);this.setValue(a,e)},r.prototype._prepareForSpeedRatioChange=function(t){var e=this._previousElapsedTime*(this._animation.framePerSecond*t)/1e3;this._absoluteFrameOffset=this._previousAbsoluteFrame-e},r.prototype.animate=function(t,e,n,i,o,a){a===void 0&&(a=-1);var s=this._animation,l=s.targetPropertyPath;if(!l||l.length<1)return this._stopped=!0,!1;var c=!0;(e<this._minFrame||e>this._maxFrame)&&(e=this._minFrame),(n<this._minFrame||n>this._maxFrame)&&(n=this._maxFrame);var u,d,h=n-e,p=t*(s.framePerSecond*o)/1e3+this._absoluteFrameOffset,m=0,v=!1,b=i&&this._animationState.loopMode===Le.ANIMATIONLOOPMODE_YOYO;if(b){var E=(p-e)/h,C=Math.sin(E*Math.PI);p=Math.abs(C)*h+e;var T=C>=0?1:-1;this._yoyoDirection!==T&&(v=!0),this._yoyoDirection=T}if(this._previousElapsedTime=t,this._previousAbsoluteFrame=p,!i&&n>=e&&(p>=h&&o>0||p<=0&&o<0))c=!1,m=s._getKeyValue(this._maxValue);else if(!i&&e>=n&&(p<=h&&o<0||p>=0&&o>0))c=!1,m=s._getKeyValue(this._minValue);else if(this._animationState.loopMode!==Le.ANIMATIONLOOPMODE_CYCLE){var f=n.toString()+e.toString();if(!this._offsetsCache[f]){this._animationState.repeatCount=0,this._animationState.loopMode=Le.ANIMATIONLOOPMODE_CYCLE;var g=s._interpolate(e,this._animationState),S=s._interpolate(n,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),s.dataType){case Le.ANIMATIONTYPE_FLOAT:this._offsetsCache[f]=S-g;break;case Le.ANIMATIONTYPE_QUATERNION:case Le.ANIMATIONTYPE_VECTOR3:case Le.ANIMATIONTYPE_VECTOR2:case Le.ANIMATIONTYPE_SIZE:case Le.ANIMATIONTYPE_COLOR3:this._offsetsCache[f]=S.subtract(g)}this._highLimitsCache[f]=S}m=this._highLimitsCache[f],u=this._offsetsCache[f]}if(u===void 0)switch(s.dataType){case Le.ANIMATIONTYPE_FLOAT:u=0;break;case Le.ANIMATIONTYPE_QUATERNION:u=Xe;break;case Le.ANIMATIONTYPE_VECTOR3:u=Ze;break;case Le.ANIMATIONTYPE_VECTOR2:u=ge;break;case Le.ANIMATIONTYPE_SIZE:u=pe;break;case Le.ANIMATIONTYPE_COLOR3:u=Ce;break;case Le.ANIMATIONTYPE_COLOR4:u=De}if(this._host&&this._host.syncRoot){var y=this._host.syncRoot;d=e+h*((y.masterFrame-y.fromFrame)/(y.toFrame-y.fromFrame))}else d=p>0&&e>n||p<0&&e<n?c&&h!==0?n+p%h:e:c&&h!==0?e+p%h:n;var x=this._events;if(!b&&(o>0&&this.currentFrame>d||o<0&&this.currentFrame<d)||b&&v){this._onLoop();for(var R=0;R<x.length;R++)x[R].onlyOnce||(x[R].isDone=!1);this._animationState.key=o>0?0:s.getKeys().length-1}this._currentFrame=d,this._animationState.repeatCount=h===0?0:p/h|0,this._animationState.highLimitValue=m,this._animationState.offsetValue=u;var I=s._interpolate(d,this._animationState);if(this.setValue(I,a),x.length){for(R=0;R<x.length;R++)if(h>=0&&d>=x[R].frame&&x[R].frame>=e||h<0&&d<=x[R].frame&&x[R].frame<=e){var M=x[R];M.isDone||(M.onlyOnce&&(x.splice(R,1),R--),M.isDone=!0,M.action(d))}}return c||(this._stopped=!0),c},r}(),ke=L(76170),et=L(85258),st=L(11296),Ct=function(r){function t(e,n,i,o,a,s,l){i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),l===void 0&&(l=null);var c,u=this;return(u=r.call(this,e,n.getScene(),!1)||this).name=e,u.children=[],u.animations=[],u._index=null,u._scalingDeterminant=1,u._needToDecompose=!0,u._needToCompose=!1,u._linkedTransformNode=null,u._waitingTransformNodeId=null,u._skeleton=n,u._localMatrix=(c=o?.clone())!==null&&c!==void 0?c:_.uq.Identity(),u._restMatrix=a??u._localMatrix.clone(),u._bindMatrix=s??u._localMatrix.clone(),u._index=l,u._absoluteMatrix=new _.uq,u._absoluteBindMatrix=new _.uq,u._absoluteInverseBindMatrix=new _.uq,u._finalMatrix=new _.uq,n.bones.push(u),u.setParent(i,!1),u._updateAbsoluteBindMatrices(),u}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"_matrix",{get:function(){return this._compose(),this._localMatrix},set:function(e){(e.updateFlag!==this._localMatrix.updateFlag||this._needToCompose)&&(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Bone"},t.prototype.getSkeleton=function(){return this._skeleton},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){this.setParent(e)},enumerable:!1,configurable:!0}),t.prototype.getParent=function(){return this.parent},t.prototype.getChildren=function(){return this.children},t.prototype.getIndex=function(){return this._index===null?this.getSkeleton().bones.indexOf(this):this._index},t.prototype.setParent=function(e,n){if(n===void 0&&(n=!0),this.parent!==e){if(this.parent){var i=this.parent.children.indexOf(this);i!==-1&&this.parent.children.splice(i,1)}this._parentNode=e,this.parent&&this.parent.children.push(this),n&&this._updateAbsoluteBindMatrices(),this.markAsDirty()}},t.prototype.getLocalMatrix=function(){return this._compose(),this._localMatrix},t.prototype.getBindMatrix=function(){return this._bindMatrix},t.prototype.getBaseMatrix=function(){return this.getBindMatrix()},t.prototype.getRestMatrix=function(){return this._restMatrix},t.prototype.getRestPose=function(){return this.getRestMatrix()},t.prototype.setRestMatrix=function(e){this._restMatrix.copyFrom(e)},t.prototype.setRestPose=function(e){this.setRestMatrix(e)},t.prototype.getBindPose=function(){return this.getBindMatrix()},t.prototype.setBindMatrix=function(e){this.updateMatrix(e)},t.prototype.setBindPose=function(e){this.setBindMatrix(e)},t.prototype.getFinalMatrix=function(){return this._finalMatrix},t.prototype.getWorldMatrix=function(){return this.getFinalMatrix()},t.prototype.returnToRest=function(){var e;if(this._linkedTransformNode){var n=_.AA.Vector3[0],i=_.AA.Quaternion[0],o=_.AA.Vector3[1];this.getRestMatrix().decompose(n,i,o),this._linkedTransformNode.position.copyFrom(o),this._linkedTransformNode.rotationQuaternion=(e=this._linkedTransformNode.rotationQuaternion)!==null&&e!==void 0?e:_.PT.Identity(),this._linkedTransformNode.rotationQuaternion.copyFrom(i),this._linkedTransformNode.scaling.copyFrom(n)}else this._matrix=this._restMatrix},t.prototype.getAbsoluteInverseBindMatrix=function(){return this._absoluteInverseBindMatrix},t.prototype.getInvertedAbsoluteTransform=function(){return this.getAbsoluteInverseBindMatrix()},t.prototype.getAbsoluteMatrix=function(){return this._absoluteMatrix},t.prototype.getAbsoluteTransform=function(){return this._absoluteMatrix},t.prototype.linkTransformNode=function(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++},t.prototype.getTransformNode=function(){return this._linkedTransformNode},Object.defineProperty(t.prototype,"position",{get:function(){return this._decompose(),this._localPosition},set:function(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._decompose(),this._localRotation},set:function(e){this.setRotationQuaternion(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._skeleton.animationPropertiesOverride},enumerable:!1,configurable:!0}),t.prototype._decompose=function(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=_.Pq.Zero(),this._localRotation=_.PT.Zero(),this._localPosition=_.Pq.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},t.prototype._compose=function(){this._needToCompose&&(this._localScaling?(this._needToCompose=!1,_.uq.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)):this._needToCompose=!1)},t.prototype.updateMatrix=function(e,n,i){n===void 0&&(n=!0),i===void 0&&(i=!0),this._bindMatrix.copyFrom(e),n&&this._updateAbsoluteBindMatrices(),i?this._matrix=e:this.markAsDirty()},t.prototype._updateAbsoluteBindMatrices=function(e,n){if(n===void 0&&(n=!0),e||(e=this._bindMatrix),this.parent?e.multiplyToRef(this.parent._absoluteBindMatrix,this._absoluteBindMatrix):this._absoluteBindMatrix.copyFrom(e),this._absoluteBindMatrix.invertToRef(this._absoluteInverseBindMatrix),n)for(var i=0;i<this.children.length;i++)this.children[i]._updateAbsoluteBindMatrices();this._scalingDeterminant=this._absoluteBindMatrix.determinant()<0?-1:1},t.prototype.markAsDirty=function(){return this._currentRenderId++,this._childUpdateId++,this._skeleton._markAsDirty(),this},t.prototype._markAsDirtyAndCompose=function(){this.markAsDirty(),this._needToCompose=!0},t.prototype._markAsDirtyAndDecompose=function(){this.markAsDirty(),this._needToDecompose=!0},t.prototype._updatePosition=function(e,n,i,o){n===void 0&&(n=0),o===void 0&&(o=!0);var a=this.getLocalMatrix();if(n==0)o?(a.addAtIndex(12,e.x),a.addAtIndex(13,e.y),a.addAtIndex(14,e.z)):a.setTranslationFromFloats(e.x,e.y,e.z);else{var s=null;i&&(s=i.getWorldMatrix()),this._skeleton.computeAbsoluteMatrices();var l=t._TmpMats[0],c=t._TmpVecs[0];this.parent?i&&s?(l.copyFrom(this.parent.getAbsoluteMatrix()),l.multiplyToRef(s,l)):l.copyFrom(this.parent.getAbsoluteMatrix()):_.uq.IdentityToRef(l),o&&l.setTranslationFromFloats(0,0,0),l.invert(),_.Pq.TransformCoordinatesToRef(e,l,c),o?(a.addAtIndex(12,c.x),a.addAtIndex(13,c.y),a.addAtIndex(14,c.z)):a.setTranslationFromFloats(c.x,c.y,c.z)}this._markAsDirtyAndDecompose()},t.prototype.translate=function(e,n,i){n===void 0&&(n=0),this._updatePosition(e,n,i,!0)},t.prototype.setPosition=function(e,n,i){n===void 0&&(n=0),this._updatePosition(e,n,i,!1)},t.prototype.setAbsolutePosition=function(e,n){this.setPosition(e,1,n)},t.prototype.scale=function(e,n,i,o){o===void 0&&(o=!1);var a=this.getLocalMatrix(),s=t._TmpMats[0];_.uq.ScalingToRef(e,n,i,s),s.multiplyToRef(a,a),s.invert();for(var l=0,c=this.children;l<c.length;l++){var u=(p=c[l]).getLocalMatrix();u.multiplyToRef(s,u),u.multiplyAtIndex(12,e),u.multiplyAtIndex(13,n),u.multiplyAtIndex(14,i),p._markAsDirtyAndDecompose()}if(this._markAsDirtyAndDecompose(),o)for(var d=0,h=this.children;d<h.length;d++){var p;(p=h[d]).scale(e,n,i,o)}},t.prototype.setScale=function(e){this._decompose(),this._localScaling.copyFrom(e),this._markAsDirtyAndCompose()},t.prototype.getScale=function(){return this._decompose(),this._localScaling},t.prototype.getScaleToRef=function(e){this._decompose(),e.copyFrom(this._localScaling)},t.prototype.setYawPitchRoll=function(e,n,i,o,a){if(o===void 0&&(o=0),o===0){var s=t._TmpQuat;return _.PT.RotationYawPitchRollToRef(e,n,i,s),void this.setRotationQuaternion(s,o,a)}var l=t._TmpMats[0];if(this._getAbsoluteInverseMatrixUnscaledToRef(l,a)){var c=t._TmpMats[1];_.uq.RotationYawPitchRollToRef(e,n,i,c),l.multiplyToRef(c,c),this._rotateWithMatrix(c,o,a)}},t.prototype.rotate=function(e,n,i,o){i===void 0&&(i=0);var a=t._TmpMats[0];a.setTranslationFromFloats(0,0,0),_.uq.RotationAxisToRef(e,n,a),this._rotateWithMatrix(a,i,o)},t.prototype.setAxisAngle=function(e,n,i,o){if(i===void 0&&(i=0),i===0){var a=t._TmpQuat;return _.PT.RotationAxisToRef(e,n,a),void this.setRotationQuaternion(a,i,o)}var s=t._TmpMats[0];if(this._getAbsoluteInverseMatrixUnscaledToRef(s,o)){var l=t._TmpMats[1];_.uq.RotationAxisToRef(e,n,l),s.multiplyToRef(l,l),this._rotateWithMatrix(l,i,o)}},t.prototype.setRotation=function(e,n,i){n===void 0&&(n=0),this.setYawPitchRoll(e.y,e.x,e.z,n,i)},t.prototype.setRotationQuaternion=function(e,n,i){if(n===void 0&&(n=0),n===0)return this._decompose(),this._localRotation.copyFrom(e),void this._markAsDirtyAndCompose();var o=t._TmpMats[0];if(this._getAbsoluteInverseMatrixUnscaledToRef(o,i)){var a=t._TmpMats[1];_.uq.FromQuaternionToRef(e,a),o.multiplyToRef(a,a),this._rotateWithMatrix(a,n,i)}},t.prototype.setRotationMatrix=function(e,n,i){if(n===void 0&&(n=0),n===0){var o=t._TmpQuat;return _.PT.FromRotationMatrixToRef(e,o),void this.setRotationQuaternion(o,n,i)}var a=t._TmpMats[0];if(this._getAbsoluteInverseMatrixUnscaledToRef(a,i)){var s=t._TmpMats[1];s.copyFrom(e),a.multiplyToRef(e,s),this._rotateWithMatrix(s,n,i)}},t.prototype._rotateWithMatrix=function(e,n,i){n===void 0&&(n=0);var o=this.getLocalMatrix(),a=o.m[12],s=o.m[13],l=o.m[14],c=this.getParent(),u=t._TmpMats[3],d=t._TmpMats[4];c&&n==1?(i?(u.copyFrom(i.getWorldMatrix()),c.getAbsoluteMatrix().multiplyToRef(u,u)):u.copyFrom(c.getAbsoluteMatrix()),d.copyFrom(u),d.invert(),o.multiplyToRef(u,o),o.multiplyToRef(e,o),o.multiplyToRef(d,o)):n==1&&i?(u.copyFrom(i.getWorldMatrix()),d.copyFrom(u),d.invert(),o.multiplyToRef(u,o),o.multiplyToRef(e,o),o.multiplyToRef(d,o)):o.multiplyToRef(e,o),o.setTranslationFromFloats(a,s,l),this.computeAbsoluteMatrices(),this._markAsDirtyAndDecompose()},t.prototype._getAbsoluteInverseMatrixUnscaledToRef=function(e,n){var i=t._TmpMats[2];return e.copyFrom(this.getAbsoluteMatrix()),n?(e.multiplyToRef(n.getWorldMatrix(),e),_.uq.ScalingToRef(n.scaling.x,n.scaling.y,n.scaling.z,i)):_.uq.IdentityToRef(i),e.invert(),!isNaN(e.m[0])&&(i.multiplyAtIndex(0,this._scalingDeterminant),e.multiplyToRef(i,e),!0)},t.prototype.getPosition=function(e,n){e===void 0&&(e=0),n===void 0&&(n=null);var i=_.Pq.Zero();return this.getPositionToRef(e,n,i),i},t.prototype.getPositionToRef=function(e,n,i){if(e===void 0&&(e=0),e==0){var o=this.getLocalMatrix();i.x=o.m[12],i.y=o.m[13],i.z=o.m[14]}else{var a=null;n&&(a=n.getWorldMatrix()),this._skeleton.computeAbsoluteMatrices();var s=t._TmpMats[0];n&&a?(s.copyFrom(this.getAbsoluteMatrix()),s.multiplyToRef(a,s)):s=this.getAbsoluteMatrix(),i.x=s.m[12],i.y=s.m[13],i.z=s.m[14]}},t.prototype.getAbsolutePosition=function(e){e===void 0&&(e=null);var n=_.Pq.Zero();return this.getPositionToRef(1,e,n),n},t.prototype.getAbsolutePositionToRef=function(e,n){this.getPositionToRef(1,e,n)},t.prototype.computeAbsoluteMatrices=function(){if(this._compose(),this.parent)this._localMatrix.multiplyToRef(this.parent._absoluteMatrix,this._absoluteMatrix);else{this._absoluteMatrix.copyFrom(this._localMatrix);var e=this._skeleton.getPoseMatrix();e&&this._absoluteMatrix.multiplyToRef(e,this._absoluteMatrix)}for(var n=this.children,i=n.length,o=0;o<i;o++)n[o].computeAbsoluteMatrices()},t.prototype.computeAbsoluteTransforms=function(){this.computeAbsoluteMatrices()},t.prototype.getDirection=function(e,n){n===void 0&&(n=null);var i=_.Pq.Zero();return this.getDirectionToRef(e,n,i),i},t.prototype.getDirectionToRef=function(e,n,i){n===void 0&&(n=null);var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteMatrices();var a=t._TmpMats[0];a.copyFrom(this.getAbsoluteMatrix()),n&&o&&a.multiplyToRef(o,a),_.Pq.TransformNormalToRef(e,a,i),i.normalize()},t.prototype.getRotation=function(e,n){e===void 0&&(e=0),n===void 0&&(n=null);var i=_.Pq.Zero();return this.getRotationToRef(e,n,i),i},t.prototype.getRotationToRef=function(e,n,i){e===void 0&&(e=0),n===void 0&&(n=null);var o=t._TmpQuat;this.getRotationQuaternionToRef(e,n,o),o.toEulerAnglesToRef(i)},t.prototype.getRotationQuaternion=function(e,n){e===void 0&&(e=0),n===void 0&&(n=null);var i=_.PT.Identity();return this.getRotationQuaternionToRef(e,n,i),i},t.prototype.getRotationQuaternionToRef=function(e,n,i){if(e===void 0&&(e=0),n===void 0&&(n=null),e==0)this._decompose(),i.copyFrom(this._localRotation);else{var o=t._TmpMats[0],a=this.getAbsoluteMatrix();n?a.multiplyToRef(n.getWorldMatrix(),o):o.copyFrom(a),o.multiplyAtIndex(0,this._scalingDeterminant),o.multiplyAtIndex(1,this._scalingDeterminant),o.multiplyAtIndex(2,this._scalingDeterminant),o.decompose(void 0,i,void 0)}},t.prototype.getRotationMatrix=function(e,n){e===void 0&&(e=0);var i=_.uq.Identity();return this.getRotationMatrixToRef(e,n,i),i},t.prototype.getRotationMatrixToRef=function(e,n,i){if(e===void 0&&(e=0),e==0)this.getLocalMatrix().getRotationMatrixToRef(i);else{var o=t._TmpMats[0],a=this.getAbsoluteMatrix();n?a.multiplyToRef(n.getWorldMatrix(),o):o.copyFrom(a),o.multiplyAtIndex(0,this._scalingDeterminant),o.multiplyAtIndex(1,this._scalingDeterminant),o.multiplyAtIndex(2,this._scalingDeterminant),o.getRotationMatrixToRef(i)}},t.prototype.getAbsolutePositionFromLocal=function(e,n){n===void 0&&(n=null);var i=_.Pq.Zero();return this.getAbsolutePositionFromLocalToRef(e,n,i),i},t.prototype.getAbsolutePositionFromLocalToRef=function(e,n,i){n===void 0&&(n=null);var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteMatrices();var a=t._TmpMats[0];a.copyFrom(this.getAbsoluteMatrix()),n&&o&&a.multiplyToRef(o,a),_.Pq.TransformCoordinatesToRef(e,a,i)},t.prototype.getLocalPositionFromAbsolute=function(e,n){n===void 0&&(n=null);var i=_.Pq.Zero();return this.getLocalPositionFromAbsoluteToRef(e,n,i),i},t.prototype.getLocalPositionFromAbsoluteToRef=function(e,n,i){n===void 0&&(n=null);var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteMatrices();var a=t._TmpMats[0];a.copyFrom(this.getAbsoluteMatrix()),n&&o&&a.multiplyToRef(o,a),a.invert(),_.Pq.TransformCoordinatesToRef(e,a,i)},t.prototype.setCurrentPoseAsRest=function(){this.setRestMatrix(this.getLocalMatrix())},t._TmpVecs=(0,st.mI)(2,_.Pq.Zero),t._TmpQuat=_.PT.Identity(),t._TmpMats=(0,st.mI)(5,_.uq.Identity),t}(At),bt=function(){function r(t,e,n,i,o,a,s,l,c,u,d){n===void 0&&(n=0),i===void 0&&(i=100),o===void 0&&(o=!1),a===void 0&&(a=1),u===void 0&&(u=!1),d===void 0&&(d=0),this.target=e,this.fromFrame=n,this.toFrame=i,this.loopAnimation=o,this.onAnimationEnd=s,this.onAnimationLoop=c,this.isAdditive=u,this.playOrder=d,this._localDelayOffset=null,this._pausedDelay=null,this._manualJumpDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this._syncRoot=null,this._frameToSyncFromJump=null,this._goToFrame=null,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new K.cP,this.onAnimationLoopObservable=new K.cP,this._scene=t,l&&this.appendAnimations(e,l),this._speedRatio=a,t._activeAnimatables.push(this)}return Object.defineProperty(r.prototype,"syncRoot",{get:function(){return this._syncRoot},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"masterFrame",{get:function(){return this._runtimeAnimations.length===0?0:this._runtimeAnimations[0].currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"weight",{get:function(){return this._weight},set:function(t){this._weight=t!==-1?Math.min(Math.max(t,0),1):-1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(t){for(var e=0;e<this._runtimeAnimations.length;e++)this._runtimeAnimations[e]._prepareForSpeedRatioChange(t);this._speedRatio=t,this._goToFrame!==null&&this.goToFrame(this._goToFrame)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"elapsedTime",{get:function(){return this._localDelayOffset===null?0:this._scene._animationTime-this._localDelayOffset},enumerable:!1,configurable:!0}),r.prototype.syncWith=function(t){if(this._syncRoot=t,t){var e=this._scene._activeAnimatables.indexOf(this);e>-1&&(this._scene._activeAnimatables.splice(e,1),this._scene._activeAnimatables.push(this))}return this},r.prototype.getAnimations=function(){return this._runtimeAnimations},r.prototype.appendAnimations=function(t,e){for(var n=this,i=0;i<e.length;i++){var o=e[i],a=new ct(t,o,this._scene,this);a._onLoop=function(){n.onAnimationLoopObservable.notifyObservers(n),n.onAnimationLoop&&n.onAnimationLoop()},this._runtimeAnimations.push(a)}},r.prototype.getAnimationByTargetProperty=function(t){for(var e=this._runtimeAnimations,n=0;n<e.length;n++)if(e[n].animation.targetProperty===t)return e[n].animation;return null},r.prototype.getRuntimeAnimationByTargetProperty=function(t){for(var e=this._runtimeAnimations,n=0;n<e.length;n++)if(e[n].animation.targetProperty===t)return e[n];return null},r.prototype.reset=function(){for(var t=this._runtimeAnimations,e=0;e<t.length;e++)t[e].reset(!0);this._localDelayOffset=null,this._pausedDelay=null},r.prototype.enableBlending=function(t){for(var e=this._runtimeAnimations,n=0;n<e.length;n++)e[n].animation.enableBlending=!0,e[n].animation.blendingSpeed=t},r.prototype.disableBlending=function(){for(var t=this._runtimeAnimations,e=0;e<t.length;e++)t[e].animation.enableBlending=!1},r.prototype.goToFrame=function(t){var e,n=this._runtimeAnimations;if(n[0]){var i=n[0].animation.framePerSecond;this._frameToSyncFromJump=(e=this._frameToSyncFromJump)!==null&&e!==void 0?e:n[0].currentFrame;var o=this.speedRatio===0?0:(t-this._frameToSyncFromJump)/i*1e3/this.speedRatio;this._manualJumpDelay=-o}for(var a=0;a<n.length;a++)n[a].goToFrame(t,this._weight);this._goToFrame=t},Object.defineProperty(r.prototype,"paused",{get:function(){return this._paused},enumerable:!1,configurable:!0}),r.prototype.pause=function(){this._paused||(this._paused=!0)},r.prototype.restart=function(){this._paused=!1},r.prototype._raiseOnAnimationEnd=function(){this.onAnimationEnd&&this.onAnimationEnd(),this.onAnimationEndObservable.notifyObservers(this)},r.prototype.stop=function(t,e,n,i){if(n===void 0&&(n=!1),i===void 0&&(i=!1),t||e){var o=this._scene._activeAnimatables.indexOf(this);if(o>-1){for(var a=(l=this._runtimeAnimations).length-1;a>=0;a--){var s=l[a];t&&s.animation.name!=t||e&&!e(s.target)||(s.dispose(),l.splice(a,1))}l.length==0&&(n||this._scene._activeAnimatables.splice(o,1),i||this._raiseOnAnimationEnd())}}else if((a=this._scene._activeAnimatables.indexOf(this))>-1){n||this._scene._activeAnimatables.splice(a,1);for(var l=this._runtimeAnimations,c=0;c<l.length;c++)l[c].dispose();this._runtimeAnimations.length=0,i||this._raiseOnAnimationEnd()}},r.prototype.waitAsync=function(){var t=this;return new Promise(function(e){t.onAnimationEndObservable.add(function(){e(t)},void 0,void 0,t,!0)})},r.prototype._animate=function(t){if(this._paused)return this.animationStarted=!1,this._pausedDelay===null&&(this._pausedDelay=t),!0;if(this._localDelayOffset===null?(this._localDelayOffset=t,this._pausedDelay=null):this._pausedDelay!==null&&(this._localDelayOffset+=t-this._pausedDelay,this._pausedDelay=null),this._manualJumpDelay!==null&&(this._localDelayOffset+=this._manualJumpDelay,this._manualJumpDelay=null,this._frameToSyncFromJump=null),this._goToFrame=null,this._weight===0)return!0;var e,n=!1,i=this._runtimeAnimations;for(e=0;e<i.length;e++){var o=i[e].animate(t-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);n=n||o}if(this.animationStarted=n,!n){if(this.disposeOnEnd)for(e=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(e,1),e=0;e<i.length;e++)i[e].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationLoop=null,this.onAnimationLoopObservable.clear(),this.onAnimationEndObservable.clear())}return n},r}();ke.Z.prototype._animate=function(r){if(this.animationsEnabled){var t=et.j.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=t}this.deltaTime=r!==void 0?r:this.useConstantAnimationDeltaTime?16:(t-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=t;var e=this._activeAnimatables;if(e.length!==0){this._animationTime+=this.deltaTime;for(var n=this._animationTime,i=0;i<e.length;i++){var o=e[i];!o._animate(n)&&o.disposeOnEnd&&i--}this._processLateAnimationBindings()}}},ke.Z.prototype.sortActiveAnimatables=function(){this._activeAnimatables.sort(function(r,t){return r.playOrder-t.playOrder})},ke.Z.prototype.beginWeightedAnimation=function(r,t,e,n,i,o,a,s,l,c,u){n===void 0&&(n=1),o===void 0&&(o=1),u===void 0&&(u=!1);var d=this.beginAnimation(r,t,e,i,o,a,s,!1,l,c,u);return d.weight=n,d},ke.Z.prototype.beginAnimation=function(r,t,e,n,i,o,a,s,l,c,u){if(i===void 0&&(i=1),s===void 0&&(s=!0),u===void 0&&(u=!1),i<0){var d=t;t=e,e=d,i=-i}t>e&&(i=-i),s&&this.stopAnimation(r,void 0,l),a||(a=new bt(this,r,t,e,n,i,o,void 0,c,u));var h=!l||l(r);if(r.animations&&h&&a.appendAnimations(r,r.animations),r.getAnimatables)for(var p=r.getAnimatables(),m=0;m<p.length;m++)this.beginAnimation(p[m],t,e,n,i,o,a,s,l,c);return a.reset(),a},ke.Z.prototype.beginHierarchyAnimation=function(r,t,e,n,i,o,a,s,l,c,u,d){o===void 0&&(o=1),l===void 0&&(l=!0),d===void 0&&(d=!1);var h=r.getDescendants(t),p=[];p.push(this.beginAnimation(r,e,n,i,o,a,s,l,c,void 0,d));for(var m=0,v=h;m<v.length;m++){var b=v[m];p.push(this.beginAnimation(b,e,n,i,o,a,s,l,c,void 0,d))}return p},ke.Z.prototype.beginDirectAnimation=function(r,t,e,n,i,o,a,s,l){if(o===void 0&&(o=1),l===void 0&&(l=!1),o<0){var c=e;e=n,n=c,o=-o}return e>n&&(o=-o),new bt(this,r,e,n,i,o,a,t,s,l)},ke.Z.prototype.beginDirectHierarchyAnimation=function(r,t,e,n,i,o,a,s,l,c){c===void 0&&(c=!1);var u=r.getDescendants(t),d=[];d.push(this.beginDirectAnimation(r,e,n,i,o,a,s,l,c));for(var h=0,p=u;h<p.length;h++){var m=p[h];d.push(this.beginDirectAnimation(m,e,n,i,o,a,s,l,c))}return d},ke.Z.prototype.getAnimatableByTarget=function(r){for(var t=0;t<this._activeAnimatables.length;t++)if(this._activeAnimatables[t].target===r)return this._activeAnimatables[t];return null},ke.Z.prototype.getAllAnimatablesByTarget=function(r){for(var t=[],e=0;e<this._activeAnimatables.length;e++)this._activeAnimatables[e].target===r&&t.push(this._activeAnimatables[e]);return t},ke.Z.prototype.stopAnimation=function(r,t,e){for(var n=0,i=this.getAllAnimatablesByTarget(r);n<i.length;n++)i[n].stop(t,e)},ke.Z.prototype.stopAllAnimations=function(){if(this._activeAnimatables){for(var r=0;r<this._activeAnimatables.length;r++)this._activeAnimatables[r].stop(void 0,void 0,!0);this._activeAnimatables.length=0}for(var t=0,e=this.animationGroups;t<e.length;t++)e[t].stop()},ke.Z.prototype._registerTargetForLateAnimationBinding=function(r,t){var e=r.target;this._registeredForLateAnimationBindings.pushNoDuplicate(e),e._lateAnimationHolders||(e._lateAnimationHolders={}),e._lateAnimationHolders[r.targetPath]||(e._lateAnimationHolders[r.targetPath]={totalWeight:0,totalAdditiveWeight:0,animations:[],additiveAnimations:[],originalValue:t}),r.isAdditive?(e._lateAnimationHolders[r.targetPath].additiveAnimations.push(r),e._lateAnimationHolders[r.targetPath].totalAdditiveWeight+=r.weight):(e._lateAnimationHolders[r.targetPath].animations.push(r),e._lateAnimationHolders[r.targetPath].totalWeight+=r.weight)},ke.Z.prototype._processLateAnimationBindingsForMatrices=function(r){if(r.totalWeight===0&&r.totalAdditiveWeight===0)return r.originalValue;var t=1,e=_.AA.Vector3[0],n=_.AA.Vector3[1],i=_.AA.Quaternion[0],o=0,a=r.animations[0],s=r.originalValue,l=1,c=!1;if(r.totalWeight<1)l=1-r.totalWeight,s.decompose(n,i,e);else{if(o=1,t=r.totalWeight,(l=a.weight/t)==1){if(!r.totalAdditiveWeight)return a.currentValue;c=!0}a.currentValue.decompose(n,i,e)}if(!c){n.scaleInPlace(l),e.scaleInPlace(l),i.scaleInPlace(l);for(var u=o;u<r.animations.length;u++)if((m=r.animations[u]).weight!==0){l=m.weight/t;var d=_.AA.Vector3[2],h=_.AA.Vector3[3],p=_.AA.Quaternion[1];m.currentValue.decompose(h,p,d),h.scaleAndAddToRef(l,n),p.scaleAndAddToRef(_.PT.Dot(i,p)>0?l:-l,i),d.scaleAndAddToRef(l,e)}i.normalize()}for(u=0;u<r.additiveAnimations.length;u++){var m;(m=r.additiveAnimations[u]).weight!==0&&(d=_.AA.Vector3[2],h=_.AA.Vector3[3],p=_.AA.Quaternion[1],m.currentValue.decompose(h,p,d),h.multiplyToRef(n,h),_.Pq.LerpToRef(n,h,m.weight,n),i.multiplyToRef(p,p),_.PT.SlerpToRef(i,p,m.weight,i),d.scaleAndAddToRef(m.weight,e))}var v=a?a._animationState.workValue:_.AA.Matrix[0].clone();return _.uq.ComposeToRef(n,i,e,v),v},ke.Z.prototype._processLateAnimationBindingsForQuaternions=function(r,t){if(r.totalWeight===0&&r.totalAdditiveWeight===0)return t;var e=r.animations[0],n=r.originalValue,i=t;if(r.totalWeight===0&&r.totalAdditiveWeight>0)i.copyFrom(n);else if(r.animations.length===1){if(_.PT.SlerpToRef(n,e.currentValue,Math.min(1,r.totalWeight),i),r.totalAdditiveWeight===0)return i}else if(r.animations.length>1){var o=1,a=void 0,s=void 0;if(r.totalWeight<1){var l=1-r.totalWeight;s=[],(a=[]).push(n),s.push(l)}else{if(r.animations.length===2&&(_.PT.SlerpToRef(r.animations[0].currentValue,r.animations[1].currentValue,r.animations[1].weight/r.totalWeight,t),r.totalAdditiveWeight===0))return t;a=[],s=[],o=r.totalWeight}for(var c=0;c<r.animations.length;c++){var u=r.animations[c];a.push(u.currentValue),s.push(u.weight/o)}for(var d=0,h=0;h<a.length;)h?(d+=s[h],_.PT.SlerpToRef(i,a[h],s[h]/d,i),h++):(_.PT.SlerpToRef(a[h],a[h+1],s[h+1]/(s[h]+s[h+1]),t),i=t,d=s[h]+s[h+1],h+=2)}for(c=0;c<r.additiveAnimations.length;c++)(u=r.additiveAnimations[c]).weight!==0&&(i.multiplyToRef(u.currentValue,_.AA.Quaternion[0]),_.PT.SlerpToRef(i,_.AA.Quaternion[0],u.weight,i));return i},ke.Z.prototype._processLateAnimationBindings=function(){if(this._registeredForLateAnimationBindings.length){for(var r=0;r<this._registeredForLateAnimationBindings.length;r++){var t=this._registeredForLateAnimationBindings.data[r];for(var e in t._lateAnimationHolders){var n=t._lateAnimationHolders[e],i=n.animations[0],o=n.originalValue;if(o!=null){var a=Le.AllowMatrixDecomposeForInterpolation&&o.m,s=t[e];if(a)s=this._processLateAnimationBindingsForMatrices(n);else if(o.w!==void 0)s=this._processLateAnimationBindingsForQuaternions(n,s||_.PT.Identity());else{var l=0,c=1,u=i&&i._animationState.loopMode===Le.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT;n.totalWeight<1?s=u?o.clone?o.clone():o:i&&o.scale?o.scale(1-n.totalWeight):i?o*(1-n.totalWeight):o.clone?o.clone():o:i&&(c=n.totalWeight,s=(p=i.weight/c)!=1?i.currentValue.scale?i.currentValue.scale(p):i.currentValue*p:i.currentValue,u&&(s.addToRef?s.addToRef(o,s):s+=o),l=1);for(var d=l;d<n.animations.length;d++)(p=(h=n.animations[d]).weight/c)&&(h.currentValue.scaleAndAddToRef?h.currentValue.scaleAndAddToRef(p,s):s+=h.currentValue*p);for(d=0;d<n.additiveAnimations.length;d++){var h,p;(p=(h=n.additiveAnimations[d]).weight)&&(h.currentValue.scaleAndAddToRef?h.currentValue.scaleAndAddToRef(p,s):s+=h.currentValue*p)}}t[e]=s}}t._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},Ct.prototype.copyAnimationRange=function(r,t,e,n,i){n===void 0&&(n=!1),i===void 0&&(i=null),this.animations.length===0&&(this.animations.push(new Le(this.name,"_matrix",r.animations[0].framePerSecond,Le.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));var o=r.animations[0].getRange(t);if(!o)return!1;for(var a,s,l,c=o.from,u=o.to,d=r.animations[0].getKeys(),h=r.length,p=r.getParent(),m=this.getParent(),v=n&&p&&h&&this.length&&h!==this.length,b=v&&m&&p?m.length/p.length:1,E=n&&!m&&i&&(i.x!==1||i.y!==1||i.z!==1),C=this.animations[0].getKeys(),T=0,f=d.length;T<f;T++)(a=d[T]).frame>=c&&a.frame<=u&&(n?(l=a.value.clone(),v?(s=l.getTranslation(),l.setTranslation(s.scaleInPlace(b))):E&&i?(s=l.getTranslation(),l.setTranslation(s.multiplyInPlace(i))):l=a.value):l=a.value,C.push({frame:a.frame+e,value:l}));return this.animations[0].createRange(t,c+e,u+e),!0};var Rt,wt=function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=Le.ANIMATIONLOOPMODE_CYCLE},Bt=L(95318),Wt=function(){function r(){this._easingMode=r.EASINGMODE_EASEIN}return r.prototype.setEasingMode=function(t){var e=Math.min(Math.max(t,0),2);this._easingMode=e},r.prototype.getEasingMode=function(){return this._easingMode},r.prototype.easeInCore=function(t){throw new Error("You must implement this method")},r.prototype.ease=function(t){switch(this._easingMode){case r.EASINGMODE_EASEIN:return this.easeInCore(t);case r.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},r.EASINGMODE_EASEIN=0,r.EASINGMODE_EASEOUT=1,r.EASINGMODE_EASEINOUT=2,r}(),xn=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(Wt),Yn=function(r){function t(e){e===void 0&&(e=1);var n=r.call(this)||this;return n.amplitude=e,n}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){var n=Math.max(0,this.amplitude);return Math.pow(e,3)-e*n*Math.sin(3.141592653589793*e)},t}(Wt),Kt=function(r){function t(e,n){e===void 0&&(e=3),n===void 0&&(n=2);var i=r.call(this)||this;return i.bounces=e,i.bounciness=n,i}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){var n=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var o=Math.pow(i,n),a=1-i,s=(1-o)/a+.5*o,l=e*s,c=Math.log(-l*(1-i)+1)/Math.log(i),u=Math.floor(c),d=u+1,h=(1-Math.pow(i,u))/(a*s),p=.5*(h+(1-Math.pow(i,d))/(a*s)),m=e-p,v=p-h;return-Math.pow(1/i,n-u)/(v*v)*(m-v)*(m+v)},t}(Wt),Sn=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return e*e*e},t}(Wt),Gn=function(r){function t(e,n){e===void 0&&(e=3),n===void 0&&(n=3);var i=r.call(this)||this;return i.oscillations=e,i.springiness=n,i}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){var n=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(i==0?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*n+1.5707963267948966)*e)},t}(Wt),Xn=function(r){function t(e){e===void 0&&(e=2);var n=r.call(this)||this;return n.exponent=e,n}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(Wt),bo=function(r){function t(e){e===void 0&&(e=2);var n=r.call(this)||this;return n.power=e,n}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){var n=Math.max(0,this.power);return Math.pow(e,n)},t}(Wt),Fi=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return e*e},t}(Wt),hr=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return e*e*e*e},t}(Wt),Xi=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(Wt),Ci=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(Wt),fr=function(r){function t(e,n,i,o){e===void 0&&(e=0),n===void 0&&(n=0),i===void 0&&(i=1),o===void 0&&(o=1);var a=r.call(this)||this;return a.x1=e,a.y1=n,a.x2=i,a.y2=o,a}return(0,A.C6)(t,r),t.prototype.easeInCore=function(e){return Bt.vr.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(Wt),xs=function(){function r(t,e,n){this.frame=t,this.action=e,this.onlyOnce=n,this.isDone=!1}return r.prototype._clone=function(){return new r(this.frame,this.action,this.onlyOnce)},r}(),En=L(31985),Ps=function(){function r(){}return r.prototype.getClassName=function(){return"TargetedAnimation"},r.prototype.serialize=function(){var t={};return t.animation=this.animation.serialize(),t.targetId=this.target.id,t},r}(),wi=function(){function r(t,e,n,i){e===void 0&&(e=null),n===void 0&&(n=-1),i===void 0&&(i=0),this.name=t,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this._loopAnimation=!1,this._isAdditive=!1,this._weight=-1,this._playOrder=0,this._enableBlending=null,this._blendingSpeed=null,this._numActiveAnimatables=0,this._shouldStart=!0,this._parentContainer=null,this.onAnimationEndObservable=new K.cP,this.onAnimationLoopObservable=new K.cP,this.onAnimationGroupLoopObservable=new K.cP,this.onAnimationGroupEndObservable=new K.cP,this.onAnimationGroupPauseObservable=new K.cP,this.onAnimationGroupPlayObservable=new K.cP,this.metadata=null,this._mask=null,this._animationLoopFlags=[],this._scene=e||Ve.q.LastCreatedScene,this._weight=n,this._playOrder=i,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}return Object.defineProperty(r.prototype,"mask",{get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this.syncWithMask(!0))},enumerable:!1,configurable:!0}),r.prototype.syncWithMask=function(t){if(t===void 0&&(t=!1),this.mask||t){this._numActiveAnimatables=0;for(var e=0;e<this._animatables.length;++e){var n=this._animatables[e];!this.mask||this.mask.disabled||this.mask.retainsTarget(n.target.name)?(this._numActiveAnimatables++,n.paused&&n.restart()):n.paused||n.pause()}}else this._numActiveAnimatables=this._targetedAnimations.length},r.prototype.removeUnmaskedAnimations=function(){if(this.mask&&!this.mask.disabled){for(var t=0;t<this._animatables.length;++t){var e=this._animatables[t];this.mask.retainsTarget(e.target.name)||(e.stop(),this._animatables.splice(t,1),--t)}for(var n=0;n<this._targetedAnimations.length;n++){var i=this._targetedAnimations[n];this.mask.retainsTarget(i.target.name)||(this._targetedAnimations.splice(n,1),--n)}}},Object.defineProperty(r.prototype,"from",{get:function(){return this._from},set:function(t){if(this._from!==t){this._from=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].fromFrame=this._from}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"to",{get:function(){return this._to},set:function(t){if(this._to!==t){this._to=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].toFrame=this._to}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isPlaying",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(t){if(this._speedRatio!==t){this._speedRatio=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].speedRatio=this._speedRatio}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loopAnimation",{get:function(){return this._loopAnimation},set:function(t){if(this._loopAnimation!==t){this._loopAnimation=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].loopAnimation=this._loopAnimation}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAdditive",{get:function(){return this._isAdditive},set:function(t){if(this._isAdditive!==t){this._isAdditive=t;for(var e=0;e<this._animatables.length;e++)this._animatables[e].isAdditive=this._isAdditive}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"weight",{get:function(){return this._weight},set:function(t){this._weight!==t&&(this._weight=t,this.setWeightForAllAnimatables(this._weight))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"targetedAnimations",{get:function(){return this._targetedAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animatables",{get:function(){return this._animatables},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"children",{get:function(){return this._targetedAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"playOrder",{get:function(){return this._playOrder},set:function(t){if(this._playOrder!==t&&(this._playOrder=t,this._animatables.length>0)){for(var e=0;e<this._animatables.length;e++)this._animatables[e].playOrder=this._playOrder;this._scene.sortActiveAnimatables()}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableBlending",{get:function(){return this._enableBlending},set:function(t){if(this._enableBlending!==t&&(this._enableBlending=t,t!==null))for(var e=0;e<this._targetedAnimations.length;++e)this._targetedAnimations[e].animation.enableBlending=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blendingSpeed",{get:function(){return this._blendingSpeed},set:function(t){if(this._blendingSpeed!==t&&(this._blendingSpeed=t,t!==null))for(var e=0;e<this._targetedAnimations.length;++e)this._targetedAnimations[e].animation.blendingSpeed=t},enumerable:!1,configurable:!0}),r.prototype.getLength=function(t,e){return t=t??this._from,((e=e??this._to)-t)/(this.targetedAnimations[0].animation.framePerSecond*this._speedRatio)},r.MergeAnimationGroups=function(t,e,n,i){if(e===void 0&&(e=!0),n===void 0&&(n=!1),t.length===0)return null;i=i??t[0].weight;var o=Number.MAX_VALUE,a=-Number.MAX_VALUE;if(n)for(var s=0,l=t;s<l.length;s++)(h=l[s]).from<o&&(o=h.from),h.to>a&&(a=h.to);for(var c=new r(t[0].name+"_merged",t[0]._scene,i),u=0,d=t;u<d.length;u++){var h=d[u];n&&h.normalize(o,a);for(var p=0,m=h.targetedAnimations;p<m.length;p++){var v=m[p];c.addTargetedAnimation(v.animation,v.target)}e&&h.dispose()}return c},r.prototype.addTargetedAnimation=function(t,e){var n=new Ps;n.animation=t,n.target=e;var i=t.getKeys();return this._from>i[0].frame&&(this._from=i[0].frame),this._to<i[i.length-1].frame&&(this._to=i[i.length-1].frame),this._enableBlending!==null&&(t.enableBlending=this._enableBlending),this._blendingSpeed!==null&&(t.blendingSpeed=this._blendingSpeed),this._targetedAnimations.push(n),this._shouldStart=!0,n},r.prototype.removeTargetedAnimation=function(t){for(var e=this._targetedAnimations.length-1;e>-1;e--)this._targetedAnimations[e].animation===t&&this._targetedAnimations.splice(e,1)},r.prototype.normalize=function(t,e){t===void 0&&(t=null),e===void 0&&(e=null),t==null&&(t=this._from),e==null&&(e=this._to);for(var n=0;n<this._targetedAnimations.length;n++){var i=this._targetedAnimations[n].animation.getKeys(),o=i[0],a=i[i.length-1];if(o.frame>t){var s={frame:t,value:o.value,inTangent:o.inTangent,outTangent:o.outTangent,interpolation:o.interpolation};i.splice(0,0,s)}a.frame<e&&(s={frame:e,value:a.value,inTangent:a.inTangent,outTangent:a.outTangent,interpolation:a.interpolation},i.push(s))}return this._from=t,this._to=e,this},r.prototype._processLoop=function(t,e,n){var i=this;t.onAnimationLoop=function(){i.onAnimationLoopObservable.notifyObservers(e),i._animationLoopFlags[n]||(i._animationLoopFlags[n]=!0,i._animationLoopCount++,i._animationLoopCount===i._numActiveAnimatables&&(i.onAnimationGroupLoopObservable.notifyObservers(i),i._animationLoopCount=0,i._animationLoopFlags.length=0))}},r.prototype.start=function(t,e,n,i,o){var a=this;if(t===void 0&&(t=!1),e===void 0&&(e=1),this._isStarted||this._targetedAnimations.length===0)return this;this._loopAnimation=t,this._shouldStart=!1,this._animationLoopCount=0,this._animationLoopFlags.length=0;for(var s=function(u){var d=l._targetedAnimations[u],h=l._scene.beginDirectAnimation(d.target,[d.animation],n!==void 0?n:l._from,i!==void 0?i:l._to,t,e,void 0,void 0,o!==void 0?o:l._isAdditive);h.weight=l._weight,h.playOrder=l._playOrder,h.onAnimationEnd=function(){a.onAnimationEndObservable.notifyObservers(d),a._checkAnimationGroupEnded(h)},l._processLoop(h,d,u),l._animatables.push(h)},l=this,c=0;c<this._targetedAnimations.length;c++)s(c);return this.syncWithMask(),this._scene.sortActiveAnimatables(),this._speedRatio=e,this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},r.prototype.pause=function(){if(!this._isStarted)return this;this._isPaused=!0;for(var t=0;t<this._animatables.length;t++)this._animatables[t].pause();return this.onAnimationGroupPauseObservable.notifyObservers(this),this},r.prototype.play=function(t){return this.isStarted&&this._animatables.length&&!this._shouldStart?(t!==void 0&&(this.loopAnimation=t),this.restart()):(this.stop(),this.start(t,this._speedRatio)),this},r.prototype.reset=function(){if(!this._isStarted)return this.play(),this.goToFrame(0),this.stop(!0),this;for(var t=0;t<this._animatables.length;t++)this._animatables[t].reset();return this},r.prototype.restart=function(){if(!this._isStarted)return this;for(var t=0;t<this._animatables.length;t++)this._animatables[t].restart();return this.syncWithMask(),this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},r.prototype.stop=function(t){if(t===void 0&&(t=!1),!this._isStarted)return this;for(var e=this._animatables.slice(),n=0;n<e.length;n++)e[n].stop(void 0,void 0,!0,t);var i=0;for(n=0;n<this._scene._activeAnimatables.length;n++){var o=this._scene._activeAnimatables[n];o._runtimeAnimations.length>0?this._scene._activeAnimatables[i++]=o:t&&this._checkAnimationGroupEnded(o,t)}return this._scene._activeAnimatables.length=i,this._isStarted=!1,this},r.prototype.setWeightForAllAnimatables=function(t){for(var e=0;e<this._animatables.length;e++)this._animatables[e].weight=t;return this},r.prototype.syncAllAnimationsWith=function(t){for(var e=0;e<this._animatables.length;e++)this._animatables[e].syncWith(t);return this},r.prototype.goToFrame=function(t){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++)this._animatables[e].goToFrame(t);return this},r.prototype.getCurrentFrame=function(){var t;return((t=this.animatables[0])===null||t===void 0?void 0:t.masterFrame)||0},r.prototype.dispose=function(){this.isStarted&&this.stop(),this._targetedAnimations.length=0,this._animatables.length=0;var t=this._scene.animationGroups.indexOf(this);if(t>-1&&this._scene.animationGroups.splice(t,1),this._parentContainer){var e=this._parentContainer.animationGroups.indexOf(this);e>-1&&this._parentContainer.animationGroups.splice(e,1),this._parentContainer=null}this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()},r.prototype._checkAnimationGroupEnded=function(t,e){e===void 0&&(e=!1);var n=this._animatables.indexOf(t);n>-1&&this._animatables.splice(n,1),this._animatables.length===0&&(this._isStarted=!1,e||this.onAnimationGroupEndObservable.notifyObservers(this))},r.prototype.clone=function(t,e,n){n===void 0&&(n=!1);var i=new r(t||this.name,this._scene,this._weight,this._playOrder);i._from=this.from,i._to=this.to,i._speedRatio=this.speedRatio,i._loopAnimation=this.loopAnimation,i._isAdditive=this.isAdditive,i._enableBlending=this.enableBlending,i._blendingSpeed=this.blendingSpeed,i.metadata=this.metadata,i.mask=this.mask;for(var o=0,a=this._targetedAnimations;o<a.length;o++){var s=a[o];i.addTargetedAnimation(n?s.animation.clone():s.animation,e?e(s.target):s.target)}return i},r.prototype.serialize=function(){var t={};t.name=this.name,t.from=this.from,t.to=this.to,t.speedRatio=this.speedRatio,t.loopAnimation=this.loopAnimation,t.isAdditive=this.isAdditive,t.weight=this.weight,t.playOrder=this.playOrder,t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,t.targetedAnimations=[];for(var e=0;e<this.targetedAnimations.length;e++){var n=this.targetedAnimations[e];t.targetedAnimations[e]=n.serialize()}return En.Y&&En.Y.HasTags(this)&&(t.tags=En.Y.GetTags(this)),this.metadata&&(t.metadata=this.metadata),t},r.Parse=function(t,e){for(var n=new r(t.name,e,t.weight,t.playOrder),i=0;i<t.targetedAnimations.length;i++){var o=t.targetedAnimations[i],a=Le.Parse(o.animation),s=o.targetId;if(o.animation.property==="influence"){var l=e.getMorphTargetById(s);l&&n.addTargetedAnimation(a,l)}else{var c=e.getNodeById(s);c!=null&&n.addTargetedAnimation(a,c)}}return En.Y&&En.Y.AddTagsTo(n,t.tags),t.from!==null&&t.to!==null&&n.normalize(t.from,t.to),t.speedRatio!==void 0&&(n._speedRatio=t.speedRatio),t.loopAnimation!==void 0&&(n._loopAnimation=t.loopAnimation),t.isAdditive!==void 0&&(n._isAdditive=t.isAdditive),t.weight!==void 0&&(n._weight=t.weight),t.playOrder!==void 0&&(n._playOrder=t.playOrder),t.enableBlending!==void 0&&(n._enableBlending=t.enableBlending),t.blendingSpeed!==void 0&&(n._blendingSpeed=t.blendingSpeed),t.metadata!==void 0&&(n.metadata=t.metadata),n},r.MakeAnimationAdditive=function(t,e,n,i,o){var a;i===void 0&&(i=!1);var s=t;(a=typeof e=="object"?e:{referenceFrame:e,range:n,cloneOriginalAnimationGroup:i,clonedAnimationName:o}).cloneOriginalAnimationGroup&&(s=t.clone(a.clonedAnimationGroupName||s.name));for(var l=s.targetedAnimations,c=0;c<l.length;c++)(p=l[c]).animation=Le.MakeAnimationAdditive(p.animation,a);if(s.isAdditive=!0,a.clipKeys){var u=Number.MAX_VALUE,d=-Number.MAX_VALUE,h=s.targetedAnimations;for(c=0;c<h.length;c++){var p,m=(p=h[c]).animation.getKeys();u>m[0].frame&&(u=m[0].frame),d<m[m.length-1].frame&&(d=m[m.length-1].frame)}s._from=u,s._to=d}return s},r.ClipKeys=function(t,e,n,i,o){var a=t.clone(i||t.name);return r.ClipKeysInPlace(a,e,n,o)},r.ClipKeysInPlace=function(t,e,n,i){return r.ClipInPlace(t,e,n,i,!1)},r.ClipFrames=function(t,e,n,i,o){var a=t.clone(i||t.name);return r.ClipFramesInPlace(a,e,n,o)},r.ClipFramesInPlace=function(t,e,n,i){return r.ClipInPlace(t,e,n,i,!0)},r.ClipInPlace=function(t,e,n,i,o){o===void 0&&(o=!1);for(var a=Number.MAX_VALUE,s=-Number.MAX_VALUE,l=t.targetedAnimations,c=0;c<l.length;c++){var u=l[c],d=i?u.animation:u.animation.clone();o&&(d.createKeyForFrame(e),d.createKeyForFrame(n));for(var h=d.getKeys(),p=[],m=Number.MAX_VALUE,v=0;v<h.length;v++){var b=h[v];if(!o&&v>=e&&v<=n||o&&b.frame>=e&&b.frame<=n){var E={frame:b.frame,value:b.value.clone?b.value.clone():b.value,inTangent:b.inTangent,outTangent:b.outTangent,interpolation:b.interpolation,lockedTangent:b.lockedTangent};m===Number.MAX_VALUE&&(m=E.frame),E.frame-=m,p.push(E)}}p.length!==0?(a>p[0].frame&&(a=p[0].frame),s<p[p.length-1].frame&&(s=p[p.length-1].frame),d.setKeys(p,!0),u.animation=d):(l.splice(c,1),c--)}return t._from=a,t._to=s,t},r.prototype.getClassName=function(){return"AnimationGroup"},r.prototype.toString=function(t){var e="Name: "+this.name;return e+=", type: "+this.getClassName(),t&&(e+=", from: "+this._from,e+=", to: "+this._to,e+=", isStarted: "+this._isStarted,e+=", speedRatio: "+this._speedRatio,e+=", targetedAnimations length: "+this._targetedAnimations.length,e+=", animatables length: "+this._animatables),e},r}();(function(r){r[r.NONE=0]="NONE",r[r.STEP=1]="STEP"})(Rt||(Rt={}));var Ao,Rn=function(){function r(t){this._path=t,this._onchange=new Array,this.value=0,this.animations=[]}return r.prototype.getPoint=function(){var t=this._path.getPointAtLengthPosition(this.value);return new _.Pq(t.x,0,t.y)},r.prototype.moveAhead=function(t){return t===void 0&&(t=.002),this.move(t),this},r.prototype.moveBack=function(t){return t===void 0&&(t=.002),this.move(-t),this},r.prototype.move=function(t){if(Math.abs(t)>1)throw"step size should be less than 1.";return this.value+=t,this._ensureLimits(),this._raiseOnChange(),this},r.prototype._ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},r.prototype._raiseOnChange=function(){var t=this;return this._onchange.forEach(function(e){return e(t)}),this},r.prototype.onchange=function(t){return this._onchange.push(t),this},r}();(function(r){r[r.Include=0]="Include",r[r.Exclude=1]="Exclude"})(Ao||(Ao={}));var LS=function(){function r(t,e){e===void 0&&(e=0),this.mode=e,this.disabled=!1,this._targetNames=new Set,t&&this.addTargetName(t)}return r.prototype.addTargetName=function(t){if(Array.isArray(t))for(var e=0,n=t;e<n.length;e++){var i=n[e];this._targetNames.add(i)}else this._targetNames.add(t)},r.prototype.removeTargetName=function(t){if(Array.isArray(t))for(var e=0,n=t;e<n.length;e++){var i=n[e];this._targetNames.delete(i)}else this._targetNames.delete(t)},r.prototype.hasTarget=function(t){return this._targetNames.has(t)},r.prototype.retainsTarget=function(t){return this._targetNames.has(t)===(this.mode===0)},r}(),ze=L(44957);function Sa(r,t,e){try{var n=r.next();n.done?t(n):n.value?n.value.then(function(){n.value=void 0,t(n)},e):t(n)}catch(i){e(i)}}function Y_(r){var t;return r===void 0&&(r=25),function(e,n,i){var o=performance.now();t===void 0||o-t>r?(t=o,setTimeout(function(){Sa(e,n,i)},0)):Sa(e,n,i)}}function Ac(r,t,e,n,i){var o=function(){var a,s=function(l){l.done?e(l.value):a===void 0?a=!0:o()};do a=void 0,i&&i.aborted?n(new Error("Aborted")):t(r,s,n),a===void 0&&(a=!1);while(a)};o()}function As(r,t){var e;return Ac(r,Sa,function(n){return e=n},function(n){throw n},t),e}function Cs(r,t,e){return new Promise(function(n,i){Ac(r,t,n,i,e)})}function X_(r,t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return As(r.apply(void 0,e),t)}}function FS(r,t,e){return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return Cs(r.apply(void 0,n),t,e)}}var er=L(53770),Br=L(25187),j_=L(36359),Pt=function(r){function t(e,n,i,o){o===void 0&&(o=!0);var a=r.call(this,e,i,!1)||this;return a._position=_.Pq.Zero(),a._upVector=_.Pq.Up(),a.oblique=null,a._orthoLeft=null,a._orthoRight=null,a._orthoBottom=null,a._orthoTop=null,a.fov=.8,a.projectionPlaneTilt=0,a.minZ=1,a.maxZ=1e4,a.inertia=.9,a._mode=t.PERSPECTIVE_CAMERA,a.isIntermediate=!1,a.viewport=new Br.L(0,0,1,1),a.layerMask=268435455,a.fovMode=t.FOVMODE_VERTICAL_FIXED,a.cameraRigMode=t.RIG_MODE_NONE,a.customRenderTargets=[],a.outputRenderTarget=null,a.onViewMatrixChangedObservable=new K.cP,a.onProjectionMatrixChangedObservable=new K.cP,a.onAfterCheckInputsObservable=new K.cP,a.onRestoreStateObservable=new K.cP,a.isRigCamera=!1,a._hasMoved=!1,a._rigCameras=new Array,a._skipRendering=!1,a._projectionMatrix=new _.uq,a._postProcesses=new Array,a._activeMeshes=new er.L(256),a._globalPosition=_.Pq.Zero(),a._computedViewMatrix=_.uq.Identity(),a._doNotComputeProjectionMatrix=!1,a._transformMatrix=_.uq.Zero(),a._refreshFrustumPlanes=!0,a._absoluteRotation=_.PT.Identity(),a._isCamera=!0,a._isLeftCamera=!1,a._isRightCamera=!1,a.getScene().addCamera(a),o&&!a.getScene().activeCamera&&(a.getScene().activeCamera=a),a.position=n,a.renderPassId=a.getScene().getEngine().createRenderPassId("Camera ".concat(e)),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upVector=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screenArea",{get:function(){var e,n,i,o,a=0,s=0;if(this.mode===t.PERSPECTIVE_CAMERA)this.fovMode===t.FOVMODE_VERTICAL_FIXED?(s=2*this.minZ*Math.tan(this.fov/2),a=this.getEngine().getAspectRatio(this)*s):s=(a=2*this.minZ*Math.tan(this.fov/2))/this.getEngine().getAspectRatio(this);else{var l=this.getEngine().getRenderWidth()/2,c=this.getEngine().getRenderHeight()/2;a=((e=this.orthoRight)!==null&&e!==void 0?e:l)-((n=this.orthoLeft)!==null&&n!==void 0?n:-l),s=((i=this.orthoTop)!==null&&i!==void 0?i:c)-((o=this.orthoBottom)!==null&&o!==void 0?o:-c)}return a*s},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoLeft",{get:function(){return this._orthoLeft},set:function(e){this._orthoLeft=e;for(var n=0,i=this._rigCameras;n<i.length;n++)i[n].orthoLeft=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoRight",{get:function(){return this._orthoRight},set:function(e){this._orthoRight=e;for(var n=0,i=this._rigCameras;n<i.length;n++)i[n].orthoRight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoBottom",{get:function(){return this._orthoBottom},set:function(e){this._orthoBottom=e;for(var n=0,i=this._rigCameras;n<i.length;n++)i[n].orthoBottom=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoTop",{get:function(){return this._orthoTop},set:function(e){this._orthoTop=e;for(var n=0,i=this._rigCameras;n<i.length;n++)i[n].orthoTop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e;for(var n=0,i=this._rigCameras;n<i.length;n++)i[n].mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasMoved",{get:function(){return this._hasMoved},enumerable:!1,configurable:!0}),t.prototype.storeState=function(){return this._stateStored=!0,this._storedFov=this.fov,this},t.prototype.hasStateStored=function(){return!!this._stateStored},t.prototype._restoreStateValues=function(){return!!this._stateStored&&(this.fov=this._storedFov,!0)},t.prototype.restoreState=function(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)},t.prototype.getClassName=function(){return"Camera"},t.prototype.toString=function(e){var n="Name: "+this.name;if(n+=", type: "+this.getClassName(),this.animations)for(var i=0;i<this.animations.length;i++)n+=", animation[0]: "+this.animations[i].toString(e);return n},t.prototype.applyVerticalCorrection=function(){var e=this.absoluteRotation.toEulerAngles();this.projectionPlaneTilt=this._scene.useRightHandedSystem?-e.x:e.x},Object.defineProperty(t.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!1,configurable:!0}),t.prototype.getActiveMeshes=function(){return this._activeMeshes},t.prototype.isActiveMesh=function(e){return this._activeMeshes.indexOf(e)!==-1},t.prototype.isReady=function(e){if(e===void 0&&(e=!1),e)for(var n=0,i=this._postProcesses;n<i.length;n++){var o=i[n];if(o&&!o.isReady())return!1}return r.prototype.isReady.call(this,e)},t.prototype._initCache=function(){r.prototype._initCache.call(this),this._cache.position=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new _.Pq(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},t.prototype._updateCache=function(e){e||r.prototype._updateCache.call(this),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)},t.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},t.prototype._isSynchronizedViewMatrix=function(){return!!r.prototype._isSynchronized.call(this)&&this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent()},t.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var n=this.getEngine();return this.mode===t.PERSPECTIVE_CAMERA?e=this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===n.getAspectRatio(this)&&this._cache.projectionPlaneTilt===this.projectionPlaneTilt:(e=this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===n.getRenderWidth()&&this._cache.renderHeight===n.getRenderHeight(),this.oblique&&(e=e&&this._cache.obliqueAngle===this.oblique.angle&&this._cache.obliqueLength===this.oblique.length&&this._cache.obliqueOffset===this.oblique.offset)),e},t.prototype.attachControl=function(e,n){},t.prototype.detachControl=function(e){},t.prototype.update=function(){this._hasMoved=!1,this._checkInputs(),this.cameraRigMode!==t.RIG_MODE_NONE&&this._updateRigCameras(),this.getViewMatrix(),this.getProjectionMatrix()},t.prototype._checkInputs=function(){this.onAfterCheckInputsObservable.notifyObservers(this)},Object.defineProperty(t.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!1,configurable:!0}),t.prototype._getFirstPostProcess=function(){for(var e=0;e<this._postProcesses.length;e++)if(this._postProcesses[e]!==null)return this._postProcesses[e];return null},t.prototype._cascadePostProcessesToRigCams=function(){var e=this._getFirstPostProcess();e&&e.markTextureDirty();for(var n=0,i=this._rigCameras.length;n<i;n++){var o=this._rigCameras[n],a=o._rigPostProcess;a?(a.getEffectName()==="pass"&&(o.isIntermediate=this._postProcesses.length===0),o._postProcesses=this._postProcesses.slice(0).concat(a),a.markTextureDirty()):o._postProcesses=this._postProcesses.slice(0)}},t.prototype.attachPostProcess=function(e,n){return n===void 0&&(n=null),!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(O.V.Error("You're trying to reuse a post process not defined as reusable."),0):(n==null||n<0?this._postProcesses.push(e):this._postProcesses[n]===null?this._postProcesses[n]=e:this._postProcesses.splice(n,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var n=this._postProcesses.indexOf(e);n!==-1&&(this._postProcesses[n]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},t.prototype._getViewMatrix=function(){return _.uq.Identity()},t.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()||(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix)),this._computedViewMatrix},t.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,e!==void 0&&(this._projectionMatrix=e)},t.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},t.prototype.getProjectionMatrix=function(e){var n,i,o,a,s,l,c,u,d,h,p,m,v,b,E,C,T,f,g;if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var S=this.getEngine(),y=this.getScene(),x=S.useReverseDepthBuffer;if(this.mode===t.PERSPECTIVE_CAMERA)this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=S.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1),(y.useRightHandedSystem?_.uq.PerspectiveFovRHToRef:_.uq.PerspectiveFovLHToRef)(this.fov,S.getAspectRatio(this),x?this.maxZ:this.minZ,x?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED,S.isNDCHalfZRange,this.projectionPlaneTilt,x);else{var R=S.getRenderWidth()/2,I=S.getRenderHeight()/2;y.useRightHandedSystem?this.oblique?_.uq.ObliqueOffCenterRHToRef((n=this.orthoLeft)!==null&&n!==void 0?n:-R,(i=this.orthoRight)!==null&&i!==void 0?i:R,(o=this.orthoBottom)!==null&&o!==void 0?o:-I,(a=this.orthoTop)!==null&&a!==void 0?a:I,x?this.maxZ:this.minZ,x?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,S.isNDCHalfZRange):_.uq.OrthoOffCenterRHToRef((s=this.orthoLeft)!==null&&s!==void 0?s:-R,(l=this.orthoRight)!==null&&l!==void 0?l:R,(c=this.orthoBottom)!==null&&c!==void 0?c:-I,(u=this.orthoTop)!==null&&u!==void 0?u:I,x?this.maxZ:this.minZ,x?this.minZ:this.maxZ,this._projectionMatrix,S.isNDCHalfZRange):this.oblique?_.uq.ObliqueOffCenterLHToRef((d=this.orthoLeft)!==null&&d!==void 0?d:-R,(h=this.orthoRight)!==null&&h!==void 0?h:R,(p=this.orthoBottom)!==null&&p!==void 0?p:-I,(m=this.orthoTop)!==null&&m!==void 0?m:I,x?this.maxZ:this.minZ,x?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,S.isNDCHalfZRange):_.uq.OrthoOffCenterLHToRef((v=this.orthoLeft)!==null&&v!==void 0?v:-R,(b=this.orthoRight)!==null&&b!==void 0?b:R,(E=this.orthoBottom)!==null&&E!==void 0?E:-I,(C=this.orthoTop)!==null&&C!==void 0?C:I,x?this.maxZ:this.minZ,x?this.minZ:this.maxZ,this._projectionMatrix,S.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=(T=this.oblique)===null||T===void 0?void 0:T.angle,this._cache.obliqueLength=(f=this.oblique)===null||f===void 0?void 0:f.length,this._cache.obliqueOffset=(g=this.oblique)===null||g===void 0?void 0:g.offset,this._cache.renderWidth=S.getRenderWidth(),this._cache.renderHeight=S.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},t.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},t.prototype._computeObliqueDistance=function(e){return(this.radius||(this.target?_.Pq.Distance(this.position,this.target):this.position.length()))+e},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?j_.P.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=j_.P.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e,n){if(n===void 0&&(n=!1),this._updateFrustumPlanes(),n&&this.rigCameras.length>0){var i=!1;return this.rigCameras.forEach(function(o){o._updateFrustumPlanes(),i=i||e.isInFrustum(o._frustumPlanes)}),i}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,n,i){throw(0,gt.n)("Ray")},t.prototype.getForwardRayToRef=function(e,n,i,o){throw(0,gt.n)("Ray")},t.prototype.dispose=function(e,n){for(n===void 0&&(n=!1),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;){var i=this._rigCameras.pop();i&&i.dispose()}if(this._parentContainer){var o=this._parentContainer.cameras.indexOf(this);o>-1&&this._parentContainer.cameras.splice(o,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==t.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else for(var a=this._postProcesses.length;--a>=0;){var s=this._postProcesses[a];s&&s.dispose(this)}for(var l=this.customRenderTargets.length;--l>=0;)this.customRenderTargets[l].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),r.prototype.dispose.call(this,e,n)},Object.defineProperty(t.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!1,configurable:!0}),t.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},t.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},t.prototype.setCameraRigMode=function(e,n){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=n.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=ze.S0.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var o=this.createRigCamera(this.name+"_L",0);o&&(o._isLeftCamera=!0);var a=this.createRigCamera(this.name+"_R",1);a&&(a._isRightCamera=!0),o&&a&&(this._rigCameras.push(o),this._rigCameras.push(a))}this._setRigMode(n),this._cascadePostProcessesToRigCams(),this.update()}},t.prototype._setRigMode=function(e){},t.prototype._getVRProjectionMatrix=function(){return _.uq.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},t.prototype.setCameraRigParameter=function(e,n){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=n,e==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=ze.S0.ToRadians(n/.0637))},t.prototype.createRigCamera=function(e,n){return null},t.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov,this._rigCameras[e].upVector.copyFrom(this.upVector);this.cameraRigMode===t.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},t.prototype._setupInputs=function(){},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getClassName(),this.parent&&this.parent._serializeAsParent(e),this.inputs&&this.inputs.serialize(e),tt.p.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e},t.prototype.clone=function(e,n){n===void 0&&(n=null);var i=tt.p.Clone(t.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this);return i.name=e,i.parent=n,this.onClonedObservable.notifyObservers(i),i},t.prototype.getDirection=function(e){var n=_.Pq.Zero();return this.getDirectionToRef(e,n),n},Object.defineProperty(t.prototype,"absoluteRotation",{get:function(){return this.getWorldMatrix().decompose(void 0,this._absoluteRotation),this._absoluteRotation},enumerable:!1,configurable:!0}),t.prototype.getDirectionToRef=function(e,n){_.Pq.TransformNormalToRef(e,this.getWorldMatrix(),n)},t.GetConstructorFromName=function(e,n,i,o,a){return o===void 0&&(o=0),a===void 0&&(a=!0),At.Construct(e,n,i,{interaxial_distance:o,isStereoscopicSideBySide:a})||function(){return t._CreateDefaultParsedCamera(n,i)}},t.prototype.computeWorldMatrix=function(){return this.getWorldMatrix()},t.Parse=function(e,n){var i=e.type,o=t.GetConstructorFromName(i,e.name,n,e.interaxial_distance,e.isStereoscopicSideBySide),a=tt.p.Parse(o,e,n);if(e.parentId!==void 0&&(a._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(a._waitingParentInstanceIndex=e.parentInstanceIndex),a.inputs&&(a.inputs.parse(e),a._setupInputs()),e.upVector&&(a.upVector=_.Pq.FromArray(e.upVector)),a.setPosition&&(a.position.copyFromFloats(0,0,0),a.setPosition(_.Pq.FromArray(e.position))),e.target&&a.setTarget&&a.setTarget(_.Pq.FromArray(e.target)),e.cameraRigMode){var s=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};a.setCameraRigMode(e.cameraRigMode,s)}if(e.animations){for(var l=0;l<e.animations.length;l++){var c=e.animations[l],u=(0,j.n9)("BABYLON.Animation");u&&a.animations.push(u.Parse(c))}At.ParseAnimationRanges(a,e,n)}return e.autoAnimate&&n.beginAnimation(a,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.isEnabled!==void 0&&a.setEnabled(e.isEnabled),a},t.prototype._calculateHandednessMultiplier=function(){var e=this.getScene().useRightHandedSystem?-1:1;return this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(e*=-1),e},t._CreateDefaultParsedCamera=function(e,n){throw(0,gt.n)("UniversalCamera")},t.PERSPECTIVE_CAMERA=P.Y.PERSPECTIVE_CAMERA,t.ORTHOGRAPHIC_CAMERA=P.Y.ORTHOGRAPHIC_CAMERA,t.FOVMODE_VERTICAL_FIXED=P.Y.FOVMODE_VERTICAL_FIXED,t.FOVMODE_HORIZONTAL_FIXED=P.Y.FOVMODE_HORIZONTAL_FIXED,t.RIG_MODE_NONE=P.Y.RIG_MODE_NONE,t.RIG_MODE_STEREOSCOPIC_ANAGLYPH=P.Y.RIG_MODE_STEREOSCOPIC_ANAGLYPH,t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=P.Y.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=P.Y.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,t.RIG_MODE_STEREOSCOPIC_OVERUNDER=P.Y.RIG_MODE_STEREOSCOPIC_OVERUNDER,t.RIG_MODE_STEREOSCOPIC_INTERLACED=P.Y.RIG_MODE_STEREOSCOPIC_INTERLACED,t.RIG_MODE_VR=P.Y.RIG_MODE_VR,t.RIG_MODE_CUSTOM=P.Y.RIG_MODE_CUSTOM,t.ForceAttachControlToAlwaysPreventDefault=!1,(0,A.Cg)([(0,V.P_)("position")],t.prototype,"_position",void 0),(0,A.Cg)([(0,V.P_)("upVector")],t.prototype,"_upVector",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"orthoLeft",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"orthoRight",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"orthoBottom",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"orthoTop",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"fov",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"projectionPlaneTilt",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"minZ",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"maxZ",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"inertia",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"mode",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"layerMask",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"fovMode",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"cameraRigMode",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"interaxialDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"isStereoscopicSideBySide",void 0),t}(At),Y=L(62623),Bi=L(91016),Rs=function(r,t,e){this.bu=r,this.bv=t,this.distance=e,this.faceId=0,this.subMeshId=0},pt=L(56740),To=function(){function r(t,e,n){this.vectors=(0,st.mI)(8,_.Pq.Zero),this.center=_.Pq.Zero(),this.centerWorld=_.Pq.Zero(),this.extendSize=_.Pq.Zero(),this.extendSizeWorld=_.Pq.Zero(),this.directions=(0,st.mI)(3,_.Pq.Zero),this.vectorsWorld=(0,st.mI)(8,_.Pq.Zero),this.minimumWorld=_.Pq.Zero(),this.maximumWorld=_.Pq.Zero(),this.minimum=_.Pq.Zero(),this.maximum=_.Pq.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(t,e,n)}return r.prototype.reConstruct=function(t,e,n){var i=t.x,o=t.y,a=t.z,s=e.x,l=e.y,c=e.z,u=this.vectors;this.minimum.copyFromFloats(i,o,a),this.maximum.copyFromFloats(s,l,c),u[0].copyFromFloats(i,o,a),u[1].copyFromFloats(s,l,c),u[2].copyFromFloats(s,o,a),u[3].copyFromFloats(i,l,a),u[4].copyFromFloats(i,o,c),u[5].copyFromFloats(s,l,a),u[6].copyFromFloats(i,l,c),u[7].copyFromFloats(s,o,c),e.addToRef(t,this.center).scaleInPlace(.5),e.subtractToRef(t,this.extendSize).scaleInPlace(.5),this._worldMatrix=n||_.uq.IdentityReadOnly,this._update(this._worldMatrix)},r.prototype.scale=function(t){var e=r._TmpVector3,n=this.maximum.subtractToRef(this.minimum,e[0]),i=n.length();n.normalizeFromLength(i);var o=i*t,a=n.scaleInPlace(.5*o),s=this.center.subtractToRef(a,e[1]),l=this.center.addToRef(a,e[2]);return this.reConstruct(s,l,this._worldMatrix),this},r.prototype.getWorldMatrix=function(){return this._worldMatrix},r.prototype._update=function(t){var e=this.minimumWorld,n=this.maximumWorld,i=this.directions,o=this.vectorsWorld,a=this.vectors;if(t.isIdentity()){for(e.copyFrom(this.minimum),n.copyFrom(this.maximum),s=0;s<8;++s)o[s].copyFrom(a[s]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{e.setAll(Number.MAX_VALUE),n.setAll(-Number.MAX_VALUE);for(var s=0;s<8;++s){var l=o[s];_.Pq.TransformCoordinatesToRef(a[s],t,l),e.minimizeInPlace(l),n.maximizeInPlace(l)}n.subtractToRef(e,this.extendSizeWorld).scaleInPlace(.5),n.addToRef(e,this.centerWorld).scaleInPlace(.5)}_.Pq.FromArrayToRef(t.m,0,i[0]),_.Pq.FromArrayToRef(t.m,4,i[1]),_.Pq.FromArrayToRef(t.m,8,i[2]),this._worldMatrix=t},r.prototype.isInFrustum=function(t){return r.IsInFrustum(this.vectorsWorld,t)},r.prototype.isCompletelyInFrustum=function(t){return r.IsCompletelyInFrustum(this.vectorsWorld,t)},r.prototype.intersectsPoint=function(t){var e=this.minimumWorld,n=this.maximumWorld,i=e.x,o=e.y,a=e.z,s=n.x,l=n.y,c=n.z,u=t.x,d=t.y,h=t.z,p=-pt.bH;return!(s-u<p||p>u-i||l-d<p||p>d-o||c-h<p||p>h-a)},r.prototype.intersectsSphere=function(t){return r.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},r.prototype.intersectsMinMax=function(t,e){var n=this.minimumWorld,i=this.maximumWorld,o=n.x,a=n.y,s=n.z,l=i.x,c=i.y,u=i.z,d=t.x,h=t.y,p=t.z,m=e.x,v=e.y,b=e.z;return!(l<d||o>m||c<h||a>v||u<p||s>b)},r.prototype.dispose=function(){var t,e;(t=this._drawWrapperFront)===null||t===void 0||t.dispose(),(e=this._drawWrapperBack)===null||e===void 0||e.dispose()},r.Intersects=function(t,e){return t.intersectsMinMax(e.minimumWorld,e.maximumWorld)},r.IntersectsSphere=function(t,e,n,i){var o=r._TmpVector3[0];return _.Pq.ClampToRef(n,t,e,o),_.Pq.DistanceSquared(n,o)<=i*i},r.IsCompletelyInFrustum=function(t,e){for(var n=0;n<6;++n)for(var i=e[n],o=0;o<8;++o)if(i.dotCoordinate(t[o])<0)return!1;return!0},r.IsInFrustum=function(t,e){for(var n=0;n<6;++n){for(var i=!0,o=e[n],a=0;a<8;++a)if(o.dotCoordinate(t[a])>=0){i=!1;break}if(i)return!1}return!0},r._TmpVector3=(0,st.mI)(3,_.Pq.Zero),r}(),Zo=function(){function r(t,e,n){this.center=_.Pq.Zero(),this.centerWorld=_.Pq.Zero(),this.minimum=_.Pq.Zero(),this.maximum=_.Pq.Zero(),this.reConstruct(t,e,n)}return r.prototype.reConstruct=function(t,e,n){this.minimum.copyFrom(t),this.maximum.copyFrom(e);var i=_.Pq.Distance(t,e);e.addToRef(t,this.center).scaleInPlace(.5),this.radius=.5*i,this._update(n||_.uq.IdentityReadOnly)},r.prototype.scale=function(t){var e=this.radius*t,n=r._TmpVector3,i=n[0].setAll(e),o=this.center.subtractToRef(i,n[1]),a=this.center.addToRef(i,n[2]);return this.reConstruct(o,a,this._worldMatrix),this},r.prototype.getWorldMatrix=function(){return this._worldMatrix},r.prototype._update=function(t){if(t.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{_.Pq.TransformCoordinatesToRef(this.center,t,this.centerWorld);var e=r._TmpVector3[0];_.Pq.TransformNormalFromFloatsToRef(1,1,1,t,e),this.radiusWorld=Math.max(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z))*this.radius}},r.prototype.isInFrustum=function(t){for(var e=this.centerWorld,n=this.radiusWorld,i=0;i<6;i++)if(t[i].dotCoordinate(e)<=-n)return!1;return!0},r.prototype.isCenterInFrustum=function(t){for(var e=this.centerWorld,n=0;n<6;n++)if(t[n].dotCoordinate(e)<0)return!1;return!0},r.prototype.intersectsPoint=function(t){var e=_.Pq.DistanceSquared(this.centerWorld,t);return!(this.radiusWorld*this.radiusWorld<e)},r.Intersects=function(t,e){var n=_.Pq.DistanceSquared(t.centerWorld,e.centerWorld),i=t.radiusWorld+e.radiusWorld;return!(i*i<n)},r.CreateFromCenterAndRadius=function(t,e,n){this._TmpVector3[0].copyFrom(t),this._TmpVector3[1].copyFromFloats(0,0,e),this._TmpVector3[2].copyFrom(t),this._TmpVector3[0].addInPlace(this._TmpVector3[1]),this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);var i=new r(this._TmpVector3[0],this._TmpVector3[2]);return i._worldMatrix=n||_.uq.Identity(),i},r._TmpVector3=(0,st.mI)(3,_.Pq.Zero),r}(),q_={min:0,max:0},K_={min:0,max:0},wS=function(r,t,e){var n=_.Pq.Dot(t.centerWorld,r),i=Math.abs(_.Pq.Dot(t.directions[0],r))*t.extendSize.x+Math.abs(_.Pq.Dot(t.directions[1],r))*t.extendSize.y+Math.abs(_.Pq.Dot(t.directions[2],r))*t.extendSize.z;e.min=n-i,e.max=n+i},ji=function(r,t,e){return wS(r,t,q_),wS(r,e,K_),!(q_.min>K_.max||K_.min>q_.max)},tr=function(){function r(t,e,n){this._isLocked=!1,this.boundingBox=new To(t,e,n),this.boundingSphere=new Zo(t,e,n)}return r.prototype.reConstruct=function(t,e,n){this.boundingBox.reConstruct(t,e,n),this.boundingSphere.reConstruct(t,e,n)},Object.defineProperty(r.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isLocked",{get:function(){return this._isLocked},set:function(t){this._isLocked=t},enumerable:!1,configurable:!0}),r.prototype.update=function(t){this._isLocked||(this.boundingBox._update(t),this.boundingSphere._update(t))},r.prototype.centerOn=function(t,e){var n=r._TmpVector3[0].copyFrom(t).subtractInPlace(e),i=r._TmpVector3[1].copyFrom(t).addInPlace(e);return this.boundingBox.reConstruct(n,i,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(n,i,this.boundingBox.getWorldMatrix()),this},r.prototype.encapsulate=function(t){var e=_.Pq.Minimize(this.minimum,t),n=_.Pq.Maximize(this.maximum,t);return this.reConstruct(e,n,this.boundingBox.getWorldMatrix()),this},r.prototype.encapsulateBoundingInfo=function(t){var e=_.AA.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(e);var n=_.AA.Vector3[0];return _.Pq.TransformCoordinatesToRef(t.boundingBox.minimumWorld,e,n),this.encapsulate(n),_.Pq.TransformCoordinatesToRef(t.boundingBox.maximumWorld,e,n),this.encapsulate(n),this},r.prototype.scale=function(t){return this.boundingBox.scale(t),this.boundingSphere.scale(t),this},r.prototype.isInFrustum=function(t,e){return e===void 0&&(e=P.Y.MESHES_CULLINGSTRATEGY_STANDARD),!(e!==P.Y.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&e!==P.Y.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(t))||!!this.boundingSphere.isInFrustum(t)&&(!(e!==P.Y.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&e!==P.Y.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(t))},Object.defineProperty(r.prototype,"diagonalLength",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,r._TmpVector3[0]).length()},enumerable:!1,configurable:!0}),r.prototype.isCompletelyInFrustum=function(t){return this.boundingBox.isCompletelyInFrustum(t)},r.prototype._checkCollision=function(t){return t._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},r.prototype.intersectsPoint=function(t){return!!this.boundingSphere.centerWorld&&!!this.boundingSphere.intersectsPoint(t)&&!!this.boundingBox.intersectsPoint(t)},r.prototype.intersects=function(t,e){if(!Zo.Intersects(this.boundingSphere,t.boundingSphere)||!To.Intersects(this.boundingBox,t.boundingBox))return!1;if(!e)return!0;var n=this.boundingBox,i=t.boundingBox;return!!(ji(n.directions[0],n,i)&&ji(n.directions[1],n,i)&&ji(n.directions[2],n,i)&&ji(i.directions[0],n,i)&&ji(i.directions[1],n,i)&&ji(i.directions[2],n,i)&&ji(_.Pq.Cross(n.directions[0],i.directions[0]),n,i)&&ji(_.Pq.Cross(n.directions[0],i.directions[1]),n,i)&&ji(_.Pq.Cross(n.directions[0],i.directions[2]),n,i)&&ji(_.Pq.Cross(n.directions[1],i.directions[0]),n,i)&&ji(_.Pq.Cross(n.directions[1],i.directions[1]),n,i)&&ji(_.Pq.Cross(n.directions[1],i.directions[2]),n,i)&&ji(_.Pq.Cross(n.directions[2],i.directions[0]),n,i)&&ji(_.Pq.Cross(n.directions[2],i.directions[1]),n,i)&&ji(_.Pq.Cross(n.directions[2],i.directions[2]),n,i))},r._TmpVector3=(0,st.mI)(2,_.Pq.Zero),r}(),no=L(47424),jn=L(14777),yi=function(){function r(t,e,n,i,o,a,s,l,c){l===void 0&&(l=!0),c===void 0&&(c=!0),this.materialIndex=t,this.verticesStart=e,this.verticesCount=n,this.indexStart=i,this.indexCount=o,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=s||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))}return Object.defineProperty(r.prototype,"materialDefines",{get:function(){var t;return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:(t=this._getDrawWrapper())===null||t===void 0?void 0:t.defines},set:function(t){var e;((e=this._mainDrawWrapperOverride)!==null&&e!==void 0?e:this._getDrawWrapper(void 0,!0)).defines=t},enumerable:!1,configurable:!0}),r.prototype._getDrawWrapper=function(t,e){e===void 0&&(e=!1),t=t??this._engine.currentRenderPassId;var n=this._drawWrappers[t];return!n&&e&&(this._drawWrappers[t]=n=new jn.E(this._mesh.getScene().getEngine())),n},r.prototype._removeDrawWrapper=function(t,e){var n;e===void 0&&(e=!0),e&&((n=this._drawWrappers[t])===null||n===void 0||n.dispose()),this._drawWrappers[t]=void 0},Object.defineProperty(r.prototype,"effect",{get:function(){var t,e;return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.effect:(e=(t=this._getDrawWrapper())===null||t===void 0?void 0:t.effect)!==null&&e!==void 0?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_drawWrapper",{get:function(){var t;return(t=this._mainDrawWrapperOverride)!==null&&t!==void 0?t:this._getDrawWrapper(void 0,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_drawWrapperOverride",{get:function(){return this._mainDrawWrapperOverride},enumerable:!1,configurable:!0}),r.prototype._setMainDrawWrapperOverride=function(t){this._mainDrawWrapperOverride=t},r.prototype.setEffect=function(t,e,n,i){e===void 0&&(e=null),i===void 0&&(i=!0);var o=this._drawWrapper;o.setEffect(t,e,i),n!==void 0&&(o.materialContext=n),t||(o.defines=null,o.materialContext=void 0)},r.prototype.resetDrawCache=function(t){if(this._drawWrappers){if(t!==void 0)return void this._removeDrawWrapper(t);for(var e=0,n=this._drawWrappers;e<n.length;e++){var i=n[e];i?.dispose()}}this._drawWrappers=[]},r.AddToMesh=function(t,e,n,i,o,a,s,l){return l===void 0&&(l=!0),new r(t,e,n,i,o,a,s,l)},Object.defineProperty(r.prototype,"IsGlobal",{get:function(){return this.verticesStart===0&&this.verticesCount===this._mesh.getTotalVertices()&&this.indexStart===0&&this.indexCount===this._mesh.getTotalIndices()},enumerable:!1,configurable:!0}),r.prototype.getBoundingInfo=function(){return this.IsGlobal||this._mesh.hasThinInstances?this._mesh.getBoundingInfo():this._boundingInfo},r.prototype.setBoundingInfo=function(t){return this._boundingInfo=t,this},r.prototype.getMesh=function(){return this._mesh},r.prototype.getRenderingMesh=function(){return this._renderingMesh},r.prototype.getReplacementMesh=function(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null},r.prototype.getEffectiveMesh=function(){return(this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null)||this._renderingMesh},r.prototype.getMaterial=function(t){var e;t===void 0&&(t=!0);var n=(e=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId))!==null&&e!==void 0?e:this._renderingMesh.material;if(!n)return t?this._mesh.getScene().defaultMaterial:null;if(this._isMultiMaterial(n)){var i=n.getSubMaterial(this.materialIndex);return this._currentMaterial!==i&&(this._currentMaterial=i,this.resetDrawCache()),i}return n},r.prototype._isMultiMaterial=function(t){return t.getSubMaterial!==void 0},r.prototype.refreshBoundingInfo=function(t){if(t===void 0&&(t=null),this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(t||(t=this._renderingMesh.getVerticesData(Y.R.PositionKind)),!t)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var e,n=this._renderingMesh.getIndices();if(this.indexStart===0&&this.indexCount===n.length){var i=this._renderingMesh.getBoundingInfo();e={minimum:i.minimum.clone(),maximum:i.maximum.clone()}}else e=(0,no.c)(t,n,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(e.minimum,e.maximum):this._boundingInfo=new tr(e.minimum,e.maximum),this},r.prototype._checkCollision=function(t){return this.getBoundingInfo()._checkCollision(t)},r.prototype.updateBoundingInfo=function(t){var e=this.getBoundingInfo();return e||(this.refreshBoundingInfo(),e=this.getBoundingInfo()),e&&e.update(t),this},r.prototype.isInFrustum=function(t){var e=this.getBoundingInfo();return!!e&&e.isInFrustum(t,this._mesh.cullingStrategy)},r.prototype.isCompletelyInFrustum=function(t){var e=this.getBoundingInfo();return!!e&&e.isCompletelyInFrustum(t)},r.prototype.render=function(t){return this._renderingMesh.render(this,t,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this},r.prototype._getLinesIndexBuffer=function(t,e){if(!this._linesIndexBuffer){for(var n=[],i=this.indexStart;i<this.indexStart+this.indexCount;i+=3)n.push(t[i],t[i+1],t[i+1],t[i+2],t[i+2],t[i]);this._linesIndexBuffer=e.createIndexBuffer(n),this._linesIndexCount=n.length}return this._linesIndexBuffer},r.prototype.canIntersects=function(t){var e=this.getBoundingInfo();return!!e&&t.intersectsBox(e.boundingBox)},r.prototype.intersects=function(t,e,n,i,o){var a=this.getMaterial();if(!a)return null;var s=3,l=!1;switch(a.fillMode){case P.Y.MATERIAL_PointListDrawMode:case P.Y.MATERIAL_LineLoopDrawMode:case P.Y.MATERIAL_LineStripDrawMode:case P.Y.MATERIAL_TriangleFanDrawMode:return null;case P.Y.MATERIAL_TriangleStripDrawMode:s=1,l=!0}return a.fillMode===P.Y.MATERIAL_LineListDrawMode?n.length?this._intersectLines(t,e,n,this._mesh.intersectionThreshold,i):this._intersectUnIndexedLines(t,e,n,this._mesh.intersectionThreshold,i):!n.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(t,e,n,i,o):this._intersectTriangles(t,e,n,s,l,i,o)},r.prototype._intersectLines=function(t,e,n,i,o){for(var a=null,s=this.indexStart;s<this.indexStart+this.indexCount;s+=2){var l=e[n[s]],c=e[n[s+1]],u=t.intersectionSegment(l,c,i);if(!(u<0)&&(o||!a||u<a.distance)&&((a=new Rs(null,null,u)).faceId=s/2,o))break}return a},r.prototype._intersectUnIndexedLines=function(t,e,n,i,o){for(var a=null,s=this.verticesStart;s<this.verticesStart+this.verticesCount;s+=2){var l=e[s],c=e[s+1],u=t.intersectionSegment(l,c,i);if(!(u<0)&&(o||!a||u<a.distance)&&((a=new Rs(null,null,u)).faceId=s/2,o))break}return a},r.prototype._intersectTriangles=function(t,e,n,i,o,a,s){for(var l=null,c=-1,u=this.indexStart;u<this.indexStart+this.indexCount-(3-i);u+=i){c++;var d=n[u],h=n[u+1],p=n[u+2];if(o&&p===4294967295)u+=2;else{var m=e[d],v=e[h],b=e[p];if(m&&v&&b&&(!s||s(m,v,b,t,d,h,p))){var E=t.intersectsTriangle(m,v,b);if(E){if(E.distance<0)continue;if((a||!l||E.distance<l.distance)&&((l=E).faceId=c,a))break}}}}return l},r.prototype._intersectUnIndexedTriangles=function(t,e,n,i,o){for(var a=null,s=this.verticesStart;s<this.verticesStart+this.verticesCount;s+=3){var l=e[s],c=e[s+1],u=e[s+2];if(!o||o(l,c,u,t,-1,-1,-1)){var d=t.intersectsTriangle(l,c,u);if(d){if(d.distance<0)continue;if((i||!a||d.distance<a.distance)&&((a=d).faceId=s/3,i))break}}}return a},r.prototype._rebuild=function(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)},r.prototype.clone=function(t,e){var n=new r(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,e,!1);if(!this.IsGlobal){var i=this.getBoundingInfo();if(!i)return n;n._boundingInfo=new tr(i.minimum,i.maximum)}return n},r.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var t=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(t,1),this.resetDrawCache()},r.prototype.getClassName=function(){return"SubMesh"},r.CreateFromIndices=function(t,e,n,i,o,a){a===void 0&&(a=!0);for(var s=Number.MAX_VALUE,l=-Number.MAX_VALUE,c=(o||i).getIndices(),u=e;u<e+n;u++){var d=c[u];d<s&&(s=d),d>l&&(l=d)}return new r(t,s,l-s+1,e,n,i,o,a)},r}(),Ea=function(){},rt=function(){function r(){this.uniqueId=0,this.metadata={},this._applyTo=X_(this._applyToCoroutine.bind(this)),this.uniqueId=r._UniqueIDGenerator,r._UniqueIDGenerator++}return r.prototype.set=function(t,e){switch(t.length||O.V.Warn("Setting vertex data kind '".concat(e,"' with an empty array")),e){case Y.R.PositionKind:this.positions=t;break;case Y.R.NormalKind:this.normals=t;break;case Y.R.TangentKind:this.tangents=t;break;case Y.R.UVKind:this.uvs=t;break;case Y.R.UV2Kind:this.uvs2=t;break;case Y.R.UV3Kind:this.uvs3=t;break;case Y.R.UV4Kind:this.uvs4=t;break;case Y.R.UV5Kind:this.uvs5=t;break;case Y.R.UV6Kind:this.uvs6=t;break;case Y.R.ColorKind:this.colors=t;break;case Y.R.MatricesIndicesKind:this.matricesIndices=t;break;case Y.R.MatricesWeightsKind:this.matricesWeights=t;break;case Y.R.MatricesIndicesExtraKind:this.matricesIndicesExtra=t;break;case Y.R.MatricesWeightsExtraKind:this.matricesWeightsExtra=t}},r.prototype.applyToMesh=function(t,e){return this._applyTo(t,e,!1),this},r.prototype.applyToGeometry=function(t,e){return this._applyTo(t,e,!1),this},r.prototype.updateMesh=function(t){return this._update(t),this},r.prototype.updateGeometry=function(t){return this._update(t),this},r.prototype._applyToCoroutine=function(t,e,n){var i,o,a,s;return e===void 0&&(e=!1),(0,A.YH)(this,function(l){switch(l.label){case 0:return this.positions?(t.setVerticesData(Y.R.PositionKind,this.positions,e),n?[4]:[3,2]):[3,2];case 1:l.sent(),l.label=2;case 2:return this.normals?(t.setVerticesData(Y.R.NormalKind,this.normals,e),n?[4]:[3,4]):[3,4];case 3:l.sent(),l.label=4;case 4:return this.tangents?(t.setVerticesData(Y.R.TangentKind,this.tangents,e),n?[4]:[3,6]):[3,6];case 5:l.sent(),l.label=6;case 6:return this.uvs?(t.setVerticesData(Y.R.UVKind,this.uvs,e),n?[4]:[3,8]):[3,8];case 7:l.sent(),l.label=8;case 8:return this.uvs2?(t.setVerticesData(Y.R.UV2Kind,this.uvs2,e),n?[4]:[3,10]):[3,10];case 9:l.sent(),l.label=10;case 10:return this.uvs3?(t.setVerticesData(Y.R.UV3Kind,this.uvs3,e),n?[4]:[3,12]):[3,12];case 11:l.sent(),l.label=12;case 12:return this.uvs4?(t.setVerticesData(Y.R.UV4Kind,this.uvs4,e),n?[4]:[3,14]):[3,14];case 13:l.sent(),l.label=14;case 14:return this.uvs5?(t.setVerticesData(Y.R.UV5Kind,this.uvs5,e),n?[4]:[3,16]):[3,16];case 15:l.sent(),l.label=16;case 16:return this.uvs6?(t.setVerticesData(Y.R.UV6Kind,this.uvs6,e),n?[4]:[3,18]):[3,18];case 17:l.sent(),l.label=18;case 18:return this.colors?(t.setVerticesData(Y.R.ColorKind,this.colors,e),this.hasVertexAlpha&&t.hasVertexAlpha!==void 0&&(t.hasVertexAlpha=!0),n?[4]:[3,20]):[3,20];case 19:l.sent(),l.label=20;case 20:return this.matricesIndices?(t.setVerticesData(Y.R.MatricesIndicesKind,this.matricesIndices,e),n?[4]:[3,22]):[3,22];case 21:l.sent(),l.label=22;case 22:return this.matricesWeights?(t.setVerticesData(Y.R.MatricesWeightsKind,this.matricesWeights,e),n?[4]:[3,24]):[3,24];case 23:l.sent(),l.label=24;case 24:return this.matricesIndicesExtra?(t.setVerticesData(Y.R.MatricesIndicesExtraKind,this.matricesIndicesExtra,e),n?[4]:[3,26]):[3,26];case 25:l.sent(),l.label=26;case 26:return this.matricesWeightsExtra?(t.setVerticesData(Y.R.MatricesWeightsExtraKind,this.matricesWeightsExtra,e),n?[4]:[3,28]):[3,28];case 27:l.sent(),l.label=28;case 28:return this.indices?(t.setIndices(this.indices,null,e),n?[4]:[3,30]):[3,31];case 29:l.sent(),l.label=30;case 30:return[3,32];case 31:t.setIndices([],null),l.label=32;case 32:if(t.subMeshes&&this.materialInfos&&this.materialInfos.length>1)for((i=t).subMeshes=[],o=0,a=this.materialInfos;o<a.length;o++)s=a[o],new yi(s.materialIndex,s.verticesStart,s.verticesCount,s.indexStart,s.indexCount,i);return[2,this]}})},r.prototype._update=function(t,e,n){return this.positions&&t.updateVerticesData(Y.R.PositionKind,this.positions,e,n),this.normals&&t.updateVerticesData(Y.R.NormalKind,this.normals,e,n),this.tangents&&t.updateVerticesData(Y.R.TangentKind,this.tangents,e,n),this.uvs&&t.updateVerticesData(Y.R.UVKind,this.uvs,e,n),this.uvs2&&t.updateVerticesData(Y.R.UV2Kind,this.uvs2,e,n),this.uvs3&&t.updateVerticesData(Y.R.UV3Kind,this.uvs3,e,n),this.uvs4&&t.updateVerticesData(Y.R.UV4Kind,this.uvs4,e,n),this.uvs5&&t.updateVerticesData(Y.R.UV5Kind,this.uvs5,e,n),this.uvs6&&t.updateVerticesData(Y.R.UV6Kind,this.uvs6,e,n),this.colors&&t.updateVerticesData(Y.R.ColorKind,this.colors,e,n),this.matricesIndices&&t.updateVerticesData(Y.R.MatricesIndicesKind,this.matricesIndices,e,n),this.matricesWeights&&t.updateVerticesData(Y.R.MatricesWeightsKind,this.matricesWeights,e,n),this.matricesIndicesExtra&&t.updateVerticesData(Y.R.MatricesIndicesExtraKind,this.matricesIndicesExtra,e,n),this.matricesWeightsExtra&&t.updateVerticesData(Y.R.MatricesWeightsExtraKind,this.matricesWeightsExtra,e,n),this.indices&&t.setIndices(this.indices,null),this},r._TransformVector3Coordinates=function(t,e,n,i){n===void 0&&(n=0),i===void 0&&(i=t.length);for(var o=_.AA.Vector3[0],a=_.AA.Vector3[1],s=n;s<n+i;s+=3)_.Pq.FromArrayToRef(t,s,o),_.Pq.TransformCoordinatesToRef(o,e,a),t[s]=a.x,t[s+1]=a.y,t[s+2]=a.z},r._TransformVector3Normals=function(t,e,n,i){n===void 0&&(n=0),i===void 0&&(i=t.length);for(var o=_.AA.Vector3[0],a=_.AA.Vector3[1],s=n;s<n+i;s+=3)_.Pq.FromArrayToRef(t,s,o),_.Pq.TransformNormalToRef(o,e,a),t[s]=a.x,t[s+1]=a.y,t[s+2]=a.z},r._TransformVector4Normals=function(t,e,n,i){n===void 0&&(n=0),i===void 0&&(i=t.length);for(var o=_.AA.Vector4[0],a=_.AA.Vector4[1],s=n;s<n+i;s+=4)_.IU.FromArrayToRef(t,s,o),_.IU.TransformNormalToRef(o,e,a),t[s]=a.x,t[s+1]=a.y,t[s+2]=a.z,t[s+3]=a.w},r._FlipFaces=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=t.length);for(var i=e;i<e+n;i+=3){var o=t[i+1];t[i+1]=t[i+2],t[i+2]=o}},r.prototype.transform=function(t){var e=t.determinant()<0;return this.positions&&r._TransformVector3Coordinates(this.positions,t),this.normals&&r._TransformVector3Normals(this.normals,t),this.tangents&&r._TransformVector4Normals(this.tangents,t),e&&this.indices&&r._FlipFaces(this.indices),this},r.prototype.splitBasedOnMaterialID=function(){if(!this.materialInfos||this.materialInfos.length<2)return[this];for(var t=[],e=0,n=this.materialInfos;e<n.length;e++){var i=n[e],o=new r;if(this.positions&&(o.positions=this.positions.slice(3*i.verticesStart,3*(i.verticesCount+i.verticesStart))),this.normals&&(o.normals=this.normals.slice(3*i.verticesStart,3*(i.verticesCount+i.verticesStart))),this.tangents&&(o.tangents=this.tangents.slice(4*i.verticesStart,4*(i.verticesCount+i.verticesStart))),this.colors&&(o.colors=this.colors.slice(4*i.verticesStart,4*(i.verticesCount+i.verticesStart))),this.uvs&&(o.uvs=this.uvs.slice(2*i.verticesStart,2*(i.verticesCount+i.verticesStart))),this.uvs2&&(o.uvs2=this.uvs2.slice(2*i.verticesStart,2*(i.verticesCount+i.verticesStart))),this.uvs3&&(o.uvs3=this.uvs3.slice(2*i.verticesStart,2*(i.verticesCount+i.verticesStart))),this.uvs4&&(o.uvs4=this.uvs4.slice(2*i.verticesStart,2*(i.verticesCount+i.verticesStart))),this.uvs5&&(o.uvs5=this.uvs5.slice(2*i.verticesStart,2*(i.verticesCount+i.verticesStart))),this.uvs6&&(o.uvs6=this.uvs6.slice(2*i.verticesStart,2*(i.verticesCount+i.verticesStart))),this.matricesIndices&&(o.matricesIndices=this.matricesIndices.slice(4*i.verticesStart,4*(i.verticesCount+i.verticesStart))),this.matricesIndicesExtra&&(o.matricesIndicesExtra=this.matricesIndicesExtra.slice(4*i.verticesStart,4*(i.verticesCount+i.verticesStart))),this.matricesWeights&&(o.matricesWeights=this.matricesWeights.slice(4*i.verticesStart,4*(i.verticesCount+i.verticesStart))),this.matricesWeightsExtra&&(o.matricesWeightsExtra=this.matricesWeightsExtra.slice(4*i.verticesStart,4*(i.verticesCount+i.verticesStart))),this.indices){o.indices=[];for(var a=i.indexStart;a<i.indexStart+i.indexCount;a++)o.indices.push(this.indices[a]-i.verticesStart)}var s=new Ea;s.indexStart=0,s.indexCount=o.indices?o.indices.length:0,s.materialIndex=i.materialIndex,s.verticesStart=0,s.verticesCount=(o.positions?o.positions.length:0)/3,o.materialInfos=[s],t.push(o)}return t},r.prototype.merge=function(t,e,n,i,o){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=!1);var a=Array.isArray(t)?t.map(function(s){return{vertexData:s}}):[{vertexData:t}];return As(this._mergeCoroutine(void 0,a,e,!1,n,i,o))},r.prototype._mergeCoroutine=function(t,e,n,i,o,a,s){var l,c,u,d,h,p,m,v,b,E,C,T,f,g,S,y,x,R,I,M,D,B,F,X,$,Q,ie,q,ee,te,ce,fe,de,Te,ue,U,N,w,k,J,le,be;return n===void 0&&(n=!1),a===void 0&&(a=!1),s===void 0&&(s=!1),(0,A.YH)(this,function(ve){switch(ve.label){case 0:if(this._validate(),l=e.map(function(ye){return ye.vertexData}),c=this,s)for(u=0,d=l;u<d.length;u++)(U=d[u])&&(U._validate(),!this.normals&&U.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&U.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&U.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&U.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&U.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&U.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&U.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&U.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&U.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&U.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&U.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&U.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&U.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(h=0,p=l;h<p.length;h++)if(U=p[h]){if(s)this.normals&&!U.normals&&(U.normals=new Float32Array(U.positions.length)),this.tangents&&!U.tangents&&(U.tangents=new Float32Array(U.positions.length/3*4)),this.uvs&&!U.uvs&&(U.uvs=new Float32Array(U.positions.length/3*2)),this.uvs2&&!U.uvs2&&(U.uvs2=new Float32Array(U.positions.length/3*2)),this.uvs3&&!U.uvs3&&(U.uvs3=new Float32Array(U.positions.length/3*2)),this.uvs4&&!U.uvs4&&(U.uvs4=new Float32Array(U.positions.length/3*2)),this.uvs5&&!U.uvs5&&(U.uvs5=new Float32Array(U.positions.length/3*2)),this.uvs6&&!U.uvs6&&(U.uvs6=new Float32Array(U.positions.length/3*2)),this.colors&&!U.colors&&(U.colors=new Float32Array(U.positions.length/3*4),U.colors.fill(1)),this.matricesIndices&&!U.matricesIndices&&(U.matricesIndices=new Float32Array(U.positions.length/3*4)),this.matricesWeights&&!U.matricesWeights&&(U.matricesWeights=new Float32Array(U.positions.length/3*4)),this.matricesIndicesExtra&&!U.matricesIndicesExtra&&(U.matricesIndicesExtra=new Float32Array(U.positions.length/3*4)),this.matricesWeightsExtra&&!U.matricesWeightsExtra&&(U.matricesWeightsExtra=new Float32Array(U.positions.length/3*4));else if(U._validate(),!this.normals!=!U.normals||!this.tangents!=!U.tangents||!this.uvs!=!U.uvs||!this.uvs2!=!U.uvs2||!this.uvs3!=!U.uvs3||!this.uvs4!=!U.uvs4||!this.uvs5!=!U.uvs5||!this.uvs6!=!U.uvs6||!this.colors!=!U.colors||!this.matricesIndices!=!U.matricesIndices||!this.matricesWeights!=!U.matricesWeights||!this.matricesIndicesExtra!=!U.matricesIndicesExtra||!this.matricesWeightsExtra!=!U.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes")}if(a){for(m=0,v=0,b=0,E=[],C=null,T=[],f=0,g=this.splitBasedOnMaterialID();f<g.length;f++)M=g[f],T.push({vertexData:M,transform:t});for(S=0,y=e;S<y.length;S++)if((x=y[S]).vertexData)for(R=0,I=x.vertexData.splitBasedOnMaterialID();R<I.length;R++)M=I[R],T.push({vertexData:M,transform:x.transform});for(T.sort(function(ye,Me){var we=ye.vertexData.materialInfos?ye.vertexData.materialInfos[0].materialIndex:0,He=Me.vertexData.materialInfos?Me.vertexData.materialInfos[0].materialIndex:0;return we>He?1:we===He?0:-1}),D=0,B=T;D<B.length;D++)F=B[D],X=F.vertexData,m=X.materialInfos?X.materialInfos[0].materialIndex:0,C&&C.materialIndex===m?(C.indexCount+=X.indices.length,C.verticesCount+=X.positions.length/3):(($=new Ea).materialIndex=m,$.indexStart=v,$.indexCount=X.indices.length,$.verticesStart=b,$.verticesCount=X.positions.length/3,E.push($),C=$),v+=X.indices.length,b+=X.positions.length/3;Q=T.splice(0,1)[0],c=Q.vertexData,t=Q.transform,l=T.map(function(ye){return ye.vertexData}),e=T,this.materialInfos=E}if(ie=l.reduce(function(ye,Me){var we,He;return ye+((He=(we=Me.indices)===null||we===void 0?void 0:we.length)!==null&&He!==void 0?He:0)},(J=(k=c.indices)===null||k===void 0?void 0:k.length)!==null&&J!==void 0?J:0),q=o||l.some(function(ye){return ye.indices===c.indices}),ee=q?(le=c.indices)===null||le===void 0?void 0:le.slice():c.indices,!(ie>0))return[3,4];te=(be=ee?.length)!==null&&be!==void 0?be:0,ee||(ee=new Array(ie)),ee.length!==ie&&(Array.isArray(ee)?ee.length=ie:((ce=n||ee instanceof Uint32Array?new Uint32Array(ie):new Uint16Array(ie)).set(ee),ee=ce),t&&t.determinant()<0&&r._FlipFaces(ee,0,te)),fe=c.positions?c.positions.length/3:0,de=0,Te=e,ve.label=1;case 1:if(!(de<Te.length))return[3,4];if(ue=Te[de],U=ue.vertexData,N=ue.transform,!U.indices)return[3,3];for(w=0;w<U.indices.length;w++)ee[te+w]=U.indices[w]+fe;return N&&N.determinant()<0&&r._FlipFaces(ee,te,U.indices.length),fe+=U.positions.length/3,te+=U.indices.length,i?[4]:[3,3];case 2:ve.sent(),ve.label=3;case 3:return de++,[3,1];case 4:return this.indices=ee,this.positions=r._MergeElement(Y.R.PositionKind,c.positions,t,e.map(function(ye){return[ye.vertexData.positions,ye.transform]})),i?[4]:[3,6];case 5:ve.sent(),ve.label=6;case 6:return c.normals?(this.normals=r._MergeElement(Y.R.NormalKind,c.normals,t,e.map(function(ye){return[ye.vertexData.normals,ye.transform]})),i?[4]:[3,8]):[3,8];case 7:ve.sent(),ve.label=8;case 8:return c.tangents?(this.tangents=r._MergeElement(Y.R.TangentKind,c.tangents,t,e.map(function(ye){return[ye.vertexData.tangents,ye.transform]})),i?[4]:[3,10]):[3,10];case 9:ve.sent(),ve.label=10;case 10:return c.uvs?(this.uvs=r._MergeElement(Y.R.UVKind,c.uvs,t,e.map(function(ye){return[ye.vertexData.uvs,ye.transform]})),i?[4]:[3,12]):[3,12];case 11:ve.sent(),ve.label=12;case 12:return c.uvs2?(this.uvs2=r._MergeElement(Y.R.UV2Kind,c.uvs2,t,e.map(function(ye){return[ye.vertexData.uvs2,ye.transform]})),i?[4]:[3,14]):[3,14];case 13:ve.sent(),ve.label=14;case 14:return c.uvs3?(this.uvs3=r._MergeElement(Y.R.UV3Kind,c.uvs3,t,e.map(function(ye){return[ye.vertexData.uvs3,ye.transform]})),i?[4]:[3,16]):[3,16];case 15:ve.sent(),ve.label=16;case 16:return c.uvs4?(this.uvs4=r._MergeElement(Y.R.UV4Kind,c.uvs4,t,e.map(function(ye){return[ye.vertexData.uvs4,ye.transform]})),i?[4]:[3,18]):[3,18];case 17:ve.sent(),ve.label=18;case 18:return c.uvs5?(this.uvs5=r._MergeElement(Y.R.UV5Kind,c.uvs5,t,e.map(function(ye){return[ye.vertexData.uvs5,ye.transform]})),i?[4]:[3,20]):[3,20];case 19:ve.sent(),ve.label=20;case 20:return c.uvs6?(this.uvs6=r._MergeElement(Y.R.UV6Kind,c.uvs6,t,e.map(function(ye){return[ye.vertexData.uvs6,ye.transform]})),i?[4]:[3,22]):[3,22];case 21:ve.sent(),ve.label=22;case 22:return c.colors?(this.colors=r._MergeElement(Y.R.ColorKind,c.colors,t,e.map(function(ye){return[ye.vertexData.colors,ye.transform]})),(c.hasVertexAlpha!==void 0||e.some(function(ye){return ye.vertexData.hasVertexAlpha!==void 0}))&&(this.hasVertexAlpha=c.hasVertexAlpha||e.some(function(ye){return ye.vertexData.hasVertexAlpha})),i?[4]:[3,24]):[3,24];case 23:ve.sent(),ve.label=24;case 24:return c.matricesIndices?(this.matricesIndices=r._MergeElement(Y.R.MatricesIndicesKind,c.matricesIndices,t,e.map(function(ye){return[ye.vertexData.matricesIndices,ye.transform]})),i?[4]:[3,26]):[3,26];case 25:ve.sent(),ve.label=26;case 26:return c.matricesWeights?(this.matricesWeights=r._MergeElement(Y.R.MatricesWeightsKind,c.matricesWeights,t,e.map(function(ye){return[ye.vertexData.matricesWeights,ye.transform]})),i?[4]:[3,28]):[3,28];case 27:ve.sent(),ve.label=28;case 28:return c.matricesIndicesExtra?(this.matricesIndicesExtra=r._MergeElement(Y.R.MatricesIndicesExtraKind,c.matricesIndicesExtra,t,e.map(function(ye){return[ye.vertexData.matricesIndicesExtra,ye.transform]})),i?[4]:[3,30]):[3,30];case 29:ve.sent(),ve.label=30;case 30:return c.matricesWeightsExtra&&(this.matricesWeightsExtra=r._MergeElement(Y.R.MatricesWeightsExtraKind,c.matricesWeightsExtra,t,e.map(function(ye){return[ye.vertexData.matricesWeightsExtra,ye.transform]}))),[2,this]}})},r._MergeElement=function(t,e,n,i){var o=i.filter(function(g){return g[0]!==null&&g[0]!==void 0});if(!e&&o.length==0)return e;if(!e)return this._MergeElement(t,o[0][0],o[0][1],o.slice(1));var a=o.reduce(function(g,S){return g+S[0].length},e.length),s=t===Y.R.PositionKind?r._TransformVector3Coordinates:t===Y.R.NormalKind?r._TransformVector3Normals:t===Y.R.TangentKind?r._TransformVector4Normals:function(){};if(e instanceof Float32Array){var l=new Float32Array(a);l.set(e),n&&s(l,n,0,e.length);for(var c=e.length,u=0,d=o;u<d.length;u++){var h=d[u],p=h[0],m=h[1];l.set(p,c),m&&s(l,m,c,p.length),c+=p.length}return l}for(var v=new Array(a),b=0;b<e.length;b++)v[b]=e[b];n&&s(v,n,0,e.length),c=e.length;for(var E=0,C=o;E<C.length;E++){var T=C[E],f=(p=T[0],T[1]);for(b=0;b<p.length;b++)v[c+b]=p[b];f&&s(v,f,c,p.length),c+=p.length}return v},r.prototype._validate=function(){if(!this.positions)throw new Bi.bu("Positions are required",Bi.tG.MeshInvalidPositionsError);var t=function(i,o){var a=Y.R.DeduceStride(i);if(o.length%a!=0)throw new Error("The "+i+"s array count must be a multiple of "+a);return o.length/a},e=t(Y.R.PositionKind,this.positions),n=function(i,o){var a=t(i,o);if(a!==e)throw new Error("The "+i+"s element count ("+a+") does not match the positions count ("+e+")")};this.normals&&n(Y.R.NormalKind,this.normals),this.tangents&&n(Y.R.TangentKind,this.tangents),this.uvs&&n(Y.R.UVKind,this.uvs),this.uvs2&&n(Y.R.UV2Kind,this.uvs2),this.uvs3&&n(Y.R.UV3Kind,this.uvs3),this.uvs4&&n(Y.R.UV4Kind,this.uvs4),this.uvs5&&n(Y.R.UV5Kind,this.uvs5),this.uvs6&&n(Y.R.UV6Kind,this.uvs6),this.colors&&n(Y.R.ColorKind,this.colors),this.matricesIndices&&n(Y.R.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&n(Y.R.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&n(Y.R.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&n(Y.R.MatricesWeightsExtraKind,this.matricesWeightsExtra)},r.prototype.clone=function(){var t=this.serialize();return r.Parse(t)},r.prototype.serialize=function(){var t={};if(this.positions&&(t.positions=Array.from(this.positions)),this.normals&&(t.normals=Array.from(this.normals)),this.tangents&&(t.tangents=Array.from(this.tangents)),this.uvs&&(t.uvs=Array.from(this.uvs)),this.uvs2&&(t.uvs2=Array.from(this.uvs2)),this.uvs3&&(t.uvs3=Array.from(this.uvs3)),this.uvs4&&(t.uvs4=Array.from(this.uvs4)),this.uvs5&&(t.uvs5=Array.from(this.uvs5)),this.uvs6&&(t.uvs6=Array.from(this.uvs6)),this.colors&&(t.colors=Array.from(this.colors),t.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(t.matricesIndices=Array.from(this.matricesIndices),t.matricesIndices._isExpanded=!0),this.matricesWeights&&(t.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(t.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),t.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(t.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),t.indices=Array.from(this.indices),this.materialInfos){t.materialInfos=[];for(var e=0,n=this.materialInfos;e<n.length;e++){var i=n[e],o={indexStart:i.indexStart,indexCount:i.indexCount,materialIndex:i.materialIndex,verticesStart:i.verticesStart,verticesCount:i.verticesCount};t.materialInfos.push(o)}}return t},r.ExtractFromMesh=function(t,e,n){return r._ExtractFrom(t,e,n)},r.ExtractFromGeometry=function(t,e,n){return r._ExtractFrom(t,e,n)},r._ExtractFrom=function(t,e,n){var i=new r;if(t.isVerticesDataPresent(Y.R.PositionKind)&&(i.positions=t.getVerticesData(Y.R.PositionKind,e,n)),t.isVerticesDataPresent(Y.R.NormalKind)&&(i.normals=t.getVerticesData(Y.R.NormalKind,e,n)),t.isVerticesDataPresent(Y.R.TangentKind)&&(i.tangents=t.getVerticesData(Y.R.TangentKind,e,n)),t.isVerticesDataPresent(Y.R.UVKind)&&(i.uvs=t.getVerticesData(Y.R.UVKind,e,n)),t.isVerticesDataPresent(Y.R.UV2Kind)&&(i.uvs2=t.getVerticesData(Y.R.UV2Kind,e,n)),t.isVerticesDataPresent(Y.R.UV3Kind)&&(i.uvs3=t.getVerticesData(Y.R.UV3Kind,e,n)),t.isVerticesDataPresent(Y.R.UV4Kind)&&(i.uvs4=t.getVerticesData(Y.R.UV4Kind,e,n)),t.isVerticesDataPresent(Y.R.UV5Kind)&&(i.uvs5=t.getVerticesData(Y.R.UV5Kind,e,n)),t.isVerticesDataPresent(Y.R.UV6Kind)&&(i.uvs6=t.getVerticesData(Y.R.UV6Kind,e,n)),t.isVerticesDataPresent(Y.R.ColorKind)){var o=t.geometry||t,a=o.getVertexBuffer(Y.R.ColorKind),s=o.getVerticesData(Y.R.ColorKind,e,n);if(a.getSize()===3){for(var l=new Float32Array(4*s.length/3),c=0,u=0;c<s.length;c+=3,u+=4)l[u]=s[c],l[u+1]=s[c+1],l[u+2]=s[c+2],l[u+3]=1;i.colors=l}else{if(a.getSize()!==4)throw new Error("Unexpected number of color components: ".concat(a.getSize()));i.colors=s}}return t.isVerticesDataPresent(Y.R.MatricesIndicesKind)&&(i.matricesIndices=t.getVerticesData(Y.R.MatricesIndicesKind,e,n)),t.isVerticesDataPresent(Y.R.MatricesWeightsKind)&&(i.matricesWeights=t.getVerticesData(Y.R.MatricesWeightsKind,e,n)),t.isVerticesDataPresent(Y.R.MatricesIndicesExtraKind)&&(i.matricesIndicesExtra=t.getVerticesData(Y.R.MatricesIndicesExtraKind,e,n)),t.isVerticesDataPresent(Y.R.MatricesWeightsExtraKind)&&(i.matricesWeightsExtra=t.getVerticesData(Y.R.MatricesWeightsExtraKind,e,n)),i.indices=t.getIndices(e,n),i},r.CreateRibbon=function(t){throw(0,gt.n)("ribbonBuilder")},r.CreateBox=function(t){throw(0,gt.n)("boxBuilder")},r.CreateTiledBox=function(t){throw(0,gt.n)("tiledBoxBuilder")},r.CreateTiledPlane=function(t){throw(0,gt.n)("tiledPlaneBuilder")},r.CreateSphere=function(t){throw(0,gt.n)("sphereBuilder")},r.CreateCylinder=function(t){throw(0,gt.n)("cylinderBuilder")},r.CreateTorus=function(t){throw(0,gt.n)("torusBuilder")},r.CreateLineSystem=function(t){throw(0,gt.n)("linesBuilder")},r.CreateDashedLines=function(t){throw(0,gt.n)("linesBuilder")},r.CreateGround=function(t){throw(0,gt.n)("groundBuilder")},r.CreateTiledGround=function(t){throw(0,gt.n)("groundBuilder")},r.CreateGroundFromHeightMap=function(t){throw(0,gt.n)("groundBuilder")},r.CreatePlane=function(t){throw(0,gt.n)("planeBuilder")},r.CreateDisc=function(t){throw(0,gt.n)("discBuilder")},r.CreatePolygon=function(t,e,n,i,o,a,s){throw(0,gt.n)("polygonBuilder")},r.CreateIcoSphere=function(t){throw(0,gt.n)("icoSphereBuilder")},r.CreatePolyhedron=function(t){throw(0,gt.n)("polyhedronBuilder")},r.CreateCapsule=function(t){throw t===void 0&&(t={orientation:_.Pq.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}),(0,gt.n)("capsuleBuilder")},r.CreateTorusKnot=function(t){throw(0,gt.n)("torusKnotBuilder")},r.ComputeNormals=function(t,e,n,i){var o=0,a=0,s=0,l=0,c=0,u=0,d=0,h=0,p=0,m=0,v=0,b=0,E=0,C=0,T=0,f=0,g=0,S=0,y=0,x=0,R=!1,I=!1,M=!1,D=!1,B=1,F=0,X=null;i&&(R=!!i.facetNormals,I=!!i.facetPositions,M=!!i.facetPartitioning,B=i.useRightHandedSystem===!0?-1:1,F=i.ratio||0,D=!!i.depthSort,X=i.distanceTo,D&&X===void 0&&(X=_.Pq.Zero()));var $=0,Q=0,ie=0,q=0;for(M&&i&&i.bbSize&&($=i.subDiv.X*F/i.bbSize.x,Q=i.subDiv.Y*F/i.bbSize.y,ie=i.subDiv.Z*F/i.bbSize.z,q=i.subDiv.max*i.subDiv.max,i.facetPartitioning.length=0),o=0;o<t.length;o++)n[o]=0;var ee=e.length/3|0;for(o=0;o<ee;o++){if(E=1+(b=3*e[3*o]),C=b+2,f=1+(T=3*e[3*o+1]),g=T+2,y=1+(S=3*e[3*o+2]),x=S+2,a=t[b]-t[T],s=t[E]-t[f],l=t[C]-t[g],c=t[S]-t[T],u=t[y]-t[f],h=B*(s*(d=t[x]-t[g])-l*u),p=B*(l*c-a*d),m=B*(a*u-s*c),h/=v=(v=Math.sqrt(h*h+p*p+m*m))===0?1:v,p/=v,m/=v,R&&i&&(i.facetNormals[o].x=h,i.facetNormals[o].y=p,i.facetNormals[o].z=m),I&&i&&(i.facetPositions[o].x=(t[b]+t[T]+t[S])/3,i.facetPositions[o].y=(t[E]+t[f]+t[y])/3,i.facetPositions[o].z=(t[C]+t[g]+t[x])/3),M&&i){var te=Math.floor((i.facetPositions[o].x-i.bInfo.minimum.x*F)*$),ce=Math.floor((i.facetPositions[o].y-i.bInfo.minimum.y*F)*Q),fe=Math.floor((i.facetPositions[o].z-i.bInfo.minimum.z*F)*ie),de=Math.floor((t[b]-i.bInfo.minimum.x*F)*$),Te=Math.floor((t[E]-i.bInfo.minimum.y*F)*Q),ue=Math.floor((t[C]-i.bInfo.minimum.z*F)*ie),U=Math.floor((t[T]-i.bInfo.minimum.x*F)*$),N=Math.floor((t[f]-i.bInfo.minimum.y*F)*Q),w=Math.floor((t[g]-i.bInfo.minimum.z*F)*ie),k=Math.floor((t[S]-i.bInfo.minimum.x*F)*$),J=Math.floor((t[y]-i.bInfo.minimum.y*F)*Q),le=Math.floor((t[x]-i.bInfo.minimum.z*F)*ie),be=de+i.subDiv.max*Te+q*ue,ve=U+i.subDiv.max*N+q*w,ye=k+i.subDiv.max*J+q*le,Me=te+i.subDiv.max*ce+q*fe;i.facetPartitioning[Me]=i.facetPartitioning[Me]?i.facetPartitioning[Me]:new Array,i.facetPartitioning[be]=i.facetPartitioning[be]?i.facetPartitioning[be]:new Array,i.facetPartitioning[ve]=i.facetPartitioning[ve]?i.facetPartitioning[ve]:new Array,i.facetPartitioning[ye]=i.facetPartitioning[ye]?i.facetPartitioning[ye]:new Array,i.facetPartitioning[be].push(o),ve!=be&&i.facetPartitioning[ve].push(o),ye!=ve&&ye!=be&&i.facetPartitioning[ye].push(o),Me!=be&&Me!=ve&&Me!=ye&&i.facetPartitioning[Me].push(o)}if(D&&i&&i.facetPositions){var we=i.depthSortedFacets[o];we.ind=3*o,we.sqDistance=_.Pq.DistanceSquared(i.facetPositions[o],X)}n[b]+=h,n[E]+=p,n[C]+=m,n[T]+=h,n[f]+=p,n[g]+=m,n[S]+=h,n[y]+=p,n[x]+=m}for(o=0;o<n.length/3;o++)h=n[3*o],p=n[3*o+1],m=n[3*o+2],h/=v=(v=Math.sqrt(h*h+p*p+m*m))===0?1:v,p/=v,m/=v,n[3*o]=h,n[3*o+1]=p,n[3*o+2]=m},r._ComputeSides=function(t,e,n,i,o,a,s){var l,c,u=n.length,d=i.length;switch(t=t||r.DEFAULTSIDE){case r.FRONTSIDE:break;case r.BACKSIDE:for(l=0;l<u;l+=3){var h=n[l];n[l]=n[l+2],n[l+2]=h}for(c=0;c<d;c++)i[c]=-i[c];break;case r.DOUBLESIDE:for(var p=e.length,m=p/3,v=0;v<p;v++)e[p+v]=e[v];for(l=0;l<u;l+=3)n[l+u]=n[l+2]+m,n[l+1+u]=n[l+1]+m,n[l+2+u]=n[l]+m;for(c=0;c<d;c++)i[d+c]=-i[c];var b=o.length,E=0;for(E=0;E<b;E++)o[E+b]=o[E];for(a=a||new _.IU(0,0,1,1),s=s||new _.IU(0,0,1,1),E=0,l=0;l<b/2;l++)o[E]=a.x+(a.z-a.x)*o[E],o[E+1]=a.y+(a.w-a.y)*o[E+1],o[E+b]=s.x+(s.z-s.x)*o[E+b],o[E+b+1]=s.y+(s.w-s.y)*o[E+b+1],E+=2}},r.Parse=function(t){var e=new r,n=t.positions;n&&e.set(n,Y.R.PositionKind);var i=t.normals;i&&e.set(i,Y.R.NormalKind);var o=t.tangents;o&&e.set(o,Y.R.TangentKind);var a=t.uvs;a&&e.set(a,Y.R.UVKind);var s=t.uvs2;s&&e.set(s,Y.R.UV2Kind);var l=t.uvs3;l&&e.set(l,Y.R.UV3Kind);var c=t.uvs4;c&&e.set(c,Y.R.UV4Kind);var u=t.uvs5;u&&e.set(u,Y.R.UV5Kind);var d=t.uvs6;d&&e.set(d,Y.R.UV6Kind);var h=t.colors;h&&(e.set(z.ov.CheckColors4(h,n.length/3),Y.R.ColorKind),t.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=t.hasVertexAlpha));var p=t.matricesIndices;p&&e.set(p,Y.R.MatricesIndicesKind);var m=t.matricesWeights;m&&e.set(m,Y.R.MatricesWeightsKind);var v=t.indices;v&&(e.indices=v);var b=t.materialInfos;if(b){e.materialInfos=[];for(var E=0,C=b;E<C.length;E++){var T=C[E],f=new Ea;f.indexCount=T.indexCount,f.indexStart=T.indexStart,f.verticesCount=T.verticesCount,f.verticesStart=T.verticesStart,f.materialIndex=T.materialIndex,e.materialInfos.push(f)}}return e},r.ImportVertexData=function(t,e){var n=r.Parse(t);e.setAllVerticesData(n,t.updatable)},r.FRONTSIDE=0,r.BACKSIDE=1,r.DOUBLESIDE=2,r.DEFAULTSIDE=0,r._UniqueIDGenerator=0,(0,A.Cg)([V.Cx.filter(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[0];return!Array.isArray(n)})],r,"_TransformVector3Coordinates",null),(0,A.Cg)([V.Cx.filter(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[0];return!Array.isArray(n)})],r,"_TransformVector3Normals",null),(0,A.Cg)([V.Cx.filter(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[0];return!Array.isArray(n)})],r,"_TransformVector4Normals",null),(0,A.Cg)([V.Cx.filter(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=t[0];return!Array.isArray(n)})],r,"_FlipFaces",null),r}(),pr=function(){function r(){}return Object.defineProperty(r,"ForceFullSceneLoadingForIncremental",{get:function(){return r._ForceFullSceneLoadingForIncremental},set:function(t){r._ForceFullSceneLoadingForIncremental=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ShowLoadingScreen",{get:function(){return r._ShowLoadingScreen},set:function(t){r._ShowLoadingScreen=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"loggingLevel",{get:function(){return r._LoggingLevel},set:function(t){r._LoggingLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"CleanBoneMatrixWeights",{get:function(){return r._CleanBoneMatrixWeights},set:function(t){r._CleanBoneMatrixWeights=t},enumerable:!1,configurable:!0}),r._ForceFullSceneLoadingForIncremental=!1,r._ShowLoadingScreen=!0,r._CleanBoneMatrixWeights=!1,r._LoggingLevel=P.Y.SCENELOADER_NO_LOGGING,r}(),Xt=L(51956);function Z_(r,t,e,n,i,o,a,s){var l=t*Y.R.GetTypeByteLength(e),c=a*t;if(s.length!==c)throw new Error("Output length is not valid");if(e===Y.R.FLOAT&&i===l)if(r instanceof Array){var u=n/4;s.set(r,u)}else if(r instanceof ArrayBuffer){var d=new Float32Array(r,n,c);s.set(d)}else{if((u=r.byteOffset+n)%4)return O.V.Warn("CopyFloatData: copied misaligned data."),void s.set(new Float32Array(r.buffer.slice(u,u+4*c)));d=new Float32Array(r.buffer,u,c),s.set(d)}else Y.R.ForEach(r,n,i,t,e,c,o,function(h,p){return s[p]=h})}var Vi=function(){function r(t,e,n,i,o){i===void 0&&(i=!1),o===void 0&&(o=null),this.delayLoadState=P.Y.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=e||Ve.q.LastCreatedScene,this._scene&&(this.id=t,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=i,n?this.setAllVerticesData(n,i):this._totalVertices=0,this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),o&&(this.applyToMesh(o),o.computeWorldMatrix(!0)))}return Object.defineProperty(r.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(t){this._boundingBias?this._boundingBias.copyFrom(t):this._boundingBias=t.clone(),this._updateBoundingInfo(!0,null)},enumerable:!1,configurable:!0}),r.CreateGeometryForMesh=function(t){var e=new r(r.RandomId(),t.getScene());return e.applyToMesh(t),e},Object.defineProperty(r.prototype,"meshes",{get:function(){return this._meshes},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"extend",{get:function(){return this._extend},enumerable:!1,configurable:!0}),r.prototype.getScene=function(){return this._scene},r.prototype.getEngine=function(){return this._engine},r.prototype.isReady=function(){return this.delayLoadState===P.Y.DELAYLOADSTATE_LOADED||this.delayLoadState===P.Y.DELAYLOADSTATE_NONE},Object.defineProperty(r.prototype,"doNotSerialize",{get:function(){for(var t=0;t<this._meshes.length;t++)if(!this._meshes[t].doNotSerialize)return!1;return!0},enumerable:!1,configurable:!0}),r.prototype._rebuild=function(){this._vertexArrayObjects&&(this._vertexArrayObjects={}),this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer"));var t=new Set;for(var e in this._vertexBuffers)t.add(this._vertexBuffers[e].getWrapperBuffer());t.forEach(function(n){n._rebuild()})},r.prototype.setAllVerticesData=function(t,e){t.applyToGeometry(this,e),this._notifyUpdate()},r.prototype.setVerticesData=function(t,e,n,i){n===void 0&&(n=!1),n&&Array.isArray(e)&&(e=new Float32Array(e));var o=new Y.R(this._engine,e,t,{updatable:n,postponeInternalCreation:this._meshes.length===0,stride:i,label:"Geometry_"+this.id+"_"+t});this.setVerticesBuffer(o)},r.prototype.removeVerticesData=function(t){this._vertexBuffers[t]&&(this._vertexBuffers[t].dispose(),delete this._vertexBuffers[t]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()},r.prototype.setVerticesBuffer=function(t,e,n){e===void 0&&(e=null),n===void 0&&(n=!0);var i=t.getKind();this._vertexBuffers[i]&&n&&this._vertexBuffers[i].dispose(),t._buffer&&t._buffer._increaseReferences(),this._vertexBuffers[i]=t;var o=this._meshes,a=o.length;if(i===Y.R.PositionKind){this._totalVertices=e??t._maxVerticesCount,this._updateExtend(t.getFloatData(this._totalVertices)),this._resetPointsArrayCache();for(var s=this._extend&&this._extend.minimum||new _.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=this._extend&&this._extend.maximum||new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),c=0;c<a;c++){var u=o[c];u.buildBoundingInfo(s,l),u._createGlobalSubMesh(u.isUnIndexed),u.computeWorldMatrix(!0),u.synchronizeInstances()}}this._notifyUpdate(i)},r.prototype.updateVerticesDataDirectly=function(t,e,n,i){i===void 0&&(i=!1);var o=this.getVertexBuffer(t);o&&(o.updateDirectly(e,n,i),this._notifyUpdate(t))},r.prototype.updateVerticesData=function(t,e,n){n===void 0&&(n=!1);var i=this.getVertexBuffer(t);i&&(i.update(e),t===Y.R.PositionKind&&this._updateBoundingInfo(n,e),this._notifyUpdate(t))},r.prototype._updateBoundingInfo=function(t,e){if(t&&this._updateExtend(e),this._resetPointsArrayCache(),t)for(var n=0,i=this._meshes;n<i.length;n++){var o=i[n];o.hasBoundingInfo?o.getBoundingInfo().reConstruct(this._extend.minimum,this._extend.maximum):o.buildBoundingInfo(this._extend.minimum,this._extend.maximum);for(var a=0,s=o.subMeshes;a<s.length;a++)s[a].refreshBoundingInfo()}},r.prototype._bind=function(t,e,n,i){if(t){e===void 0&&(e=this._indexBuffer);var o=this.getVertexBuffers();if(o)if(e==this._indexBuffer&&(this._vertexArrayObjects||i)){var a=i||this._vertexArrayObjects,s=this._engine;a[t.key]||(a[t.key]=s.recordVertexArrayObject(o,e,t,n)),s.bindVertexArrayObject(a[t.key],e)}else this._engine.bindBuffers(o,e,t,n)}},r.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},r.prototype.getVerticesData=function(t,e,n){var i=this.getVertexBuffer(t);return i?i.getFloatData(this._totalVertices,n||e&&this._meshes.length!==1):null},r.prototype.copyVerticesData=function(t,e){var n=this.getVertexBuffer(t);if(n){e[t]||(e[t]=new Float32Array(this._totalVertices*n.getSize()));var i=n.getData();i&&Z_(i,n.getSize(),n.type,n.byteOffset,n.byteStride,n.normalized,this._totalVertices,e[t])}},r.prototype.isVertexBufferUpdatable=function(t){var e=this._vertexBuffers[t];return!!e&&e.isUpdatable()},r.prototype.getVertexBuffer=function(t){return this.isReady()?this._vertexBuffers[t]:null},r.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},r.prototype.isVerticesDataPresent=function(t){return this._vertexBuffers?this._vertexBuffers[t]!==void 0:!!this._delayInfo&&this._delayInfo.indexOf(t)!==-1},r.prototype.getVerticesDataKinds=function(){var t,e=[];if(!this._vertexBuffers&&this._delayInfo)for(t in this._delayInfo)e.push(t);else for(t in this._vertexBuffers)e.push(t);return e},r.prototype.updateIndices=function(t,e,n){if(n===void 0&&(n=!1),this._indexBuffer)if(this._indexBufferIsUpdatable){var i=t.length!==this._indices.length;if(n||(this._indices=t.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,t,e),i)for(var o=0,a=this._meshes;o<a.length;o++)a[o]._createGlobalSubMesh(!0)}else this.setIndices(t,null,!0)},r.prototype.setIndexBuffer=function(t,e,n){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=t,this._totalVertices=e,this._totalIndices=n,t.is32Bits||(t.is32Bits=this._totalIndices>65535);for(var i=0,o=this._meshes;i<o.length;i++){var a=o[i];a._createGlobalSubMesh(!0),a.synchronizeInstances()}this._notifyUpdate()},r.prototype.setIndices=function(t,e,n,i){e===void 0&&(e=null),n===void 0&&(n=!1),i===void 0&&(i=!1),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=t,this._indexBufferIsUpdatable=n,this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,n,"Geometry_"+this.id+"_IndexBuffer")),e!=null&&(this._totalVertices=e);for(var o=0,a=this._meshes;o<a.length;o++){var s=a[o];s._createGlobalSubMesh(!i),s.synchronizeInstances()}this._notifyUpdate()},r.prototype.getTotalIndices=function(){return this.isReady()?this._totalIndices!==void 0?this._totalIndices:this._indices.length:0},r.prototype.getIndices=function(t,e){if(!this.isReady())return null;var n=this._indices;return e||t&&this._meshes.length!==1?n.slice():n},r.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},r.prototype._releaseVertexArrayObject=function(t){t===void 0&&(t=null),t&&this._vertexArrayObjects&&this._vertexArrayObjects[t.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[t.key]),delete this._vertexArrayObjects[t.key])},r.prototype.releaseForMesh=function(t,e){var n=this._meshes,i=n.indexOf(t);i!==-1&&(n.splice(i,1),this._vertexArrayObjects&&t._invalidateInstanceVertexArrayObject(),t._geometry=null,n.length===0&&e&&this.dispose())},r.prototype.applyToMesh=function(t){if(t._geometry!==this){var e=t._geometry;e&&e.releaseForMesh(t),this._vertexArrayObjects&&t._invalidateInstanceVertexArrayObject();var n=this._meshes;t._geometry=this,t._internalAbstractMeshDataInfo._positions=null,this._scene.pushGeometry(this),n.push(t),this.isReady()?this._applyToMesh(t):this._boundingInfo&&t.setBoundingInfo(this._boundingInfo)}},r.prototype._updateExtend=function(t){if(t===void 0&&(t=null),this.useBoundingInfoFromGeometry&&this._boundingInfo)this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()};else{if(!t&&!(t=this.getVerticesData(Y.R.PositionKind)))return;this._extend=(0,no.b)(t,0,this._totalVertices,this.boundingBias,3)}},r.prototype._applyToMesh=function(t){var e=this._meshes.length;for(var n in this._vertexBuffers)e===1&&this._vertexBuffers[n].create(),n===Y.R.PositionKind&&(this._extend||this._updateExtend(),t.buildBoundingInfo(this._extend.minimum,this._extend.maximum),t._createGlobalSubMesh(t.isUnIndexed),t._updateBoundingInfo());e===1&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),t._syncGeometryWithMorphTargetManager(),t.synchronizeInstances()},r.prototype._notifyUpdate=function(t){this.onGeometryUpdated&&this.onGeometryUpdated(this,t),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(var e=0,n=this._meshes;e<n.length;e++)n[e]._markSubMeshesAsAttributesDirty()},r.prototype.load=function(t,e){this.delayLoadState!==P.Y.DELAYLOADSTATE_LOADING&&(this.isReady()?e&&e():(this.delayLoadState=P.Y.DELAYLOADSTATE_LOADING,this._queueLoad(t,e)))},r.prototype._queueLoad=function(t,e){var n=this;this.delayLoadingFile&&(t.addPendingData(this),t._loadFile(this.delayLoadingFile,function(i){if(n._delayLoadingFunction){n._delayLoadingFunction(JSON.parse(i),n),n.delayLoadState=P.Y.DELAYLOADSTATE_LOADED,n._delayInfo=[],t.removePendingData(n);for(var o=n._meshes,a=o.length,s=0;s<a;s++)n._applyToMesh(o[s]);e&&e()}},void 0,!0))},r.prototype.toLeftHanded=function(){var t=this.getIndices(!1);if(t!=null&&t.length>0){for(var e=0;e<t.length;e+=3){var n=t[e+0];t[e+0]=t[e+2],t[e+2]=n}this.setIndices(t)}var i=this.getVerticesData(Y.R.PositionKind,!1);if(i!=null&&i.length>0){for(e=0;e<i.length;e+=3)i[e+2]=-i[e+2];this.setVerticesData(Y.R.PositionKind,i,!1)}var o=this.getVerticesData(Y.R.NormalKind,!1);if(o!=null&&o.length>0){for(e=0;e<o.length;e+=3)o[e+2]=-o[e+2];this.setVerticesData(Y.R.NormalKind,o,!1)}},r.prototype._resetPointsArrayCache=function(){this._positions=null},r.prototype._generatePointsArray=function(){if(this._positions)return!0;var t=this.getVerticesData(Y.R.PositionKind);if(!t||t.length===0)return!1;for(var e=3*this._positionsCache.length,n=this._positionsCache.length;e<t.length;e+=3,++n)this._positionsCache[n]=_.Pq.FromArray(t,e);for(e=0,n=0;e<t.length;e+=3,++n)this._positionsCache[n].set(t[0+e],t[1+e],t[2+e]);return this._positionsCache.length=t.length/3,this._positions=this._positionsCache,!0},r.prototype.isDisposed=function(){return this._isDisposed},r.prototype._disposeVertexArrayObjects=function(){if(this._vertexArrayObjects){for(var t in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[t]);this._vertexArrayObjects={};for(var e=this._meshes,n=e.length,i=0;i<n;i++)e[i]._invalidateInstanceVertexArrayObject()}},r.prototype.dispose=function(){var t,e=this._meshes,n=e.length;for(t=0;t<n;t++)this.releaseForMesh(e[t]);for(var i in this._meshes.length=0,this._disposeVertexArrayObjects(),this._vertexBuffers)this._vertexBuffers[i].dispose();if(this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=P.Y.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._parentContainer){var o=this._parentContainer.geometries.indexOf(this);o>-1&&this._parentContainer.geometries.splice(o,1),this._parentContainer=null}this._isDisposed=!0},r.prototype.copy=function(t){var e=new rt;e.indices=[];var n=this.getIndices();if(n)for(var i=0;i<n.length;i++)e.indices.push(n[i]);var o,a=!1,s=!1;for(o in this._vertexBuffers){var l=this.getVerticesData(o);if(l&&(l instanceof Float32Array?e.set(new Float32Array(l),o):e.set(l.slice(0),o),!s)){var c=this.getVertexBuffer(o);c&&(s=!(a=c.isUpdatable()))}}var u=new r(t,this._scene,e,a);for(o in u.delayLoadState=this.delayLoadState,u.delayLoadingFile=this.delayLoadingFile,u._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)u._delayInfo=u._delayInfo||[],u._delayInfo.push(o);return u._boundingInfo=new tr(this._extend.minimum,this._extend.maximum),u},r.prototype.serialize=function(){var t={};return t.id=this.id,t.uniqueId=this.uniqueId,t.updatable=this._updatable,En.Y&&En.Y.HasTags(this)&&(t.tags=En.Y.GetTags(this)),t},r.prototype._toNumberArray=function(t){return Array.isArray(t)?t:Array.prototype.slice.call(t)},r.prototype.clearCachedData=function(){for(var t in this._indices=[],this._resetPointsArrayCache(),this._vertexBuffers)Object.prototype.hasOwnProperty.call(this._vertexBuffers,t)&&(this._vertexBuffers[t]._buffer._data=null)},r.prototype.serializeVerticeData=function(){var t=this.serialize();return this.isVerticesDataPresent(Y.R.PositionKind)&&(t.positions=this._toNumberArray(this.getVerticesData(Y.R.PositionKind)),this.isVertexBufferUpdatable(Y.R.PositionKind)&&(t.positions._updatable=!0)),this.isVerticesDataPresent(Y.R.NormalKind)&&(t.normals=this._toNumberArray(this.getVerticesData(Y.R.NormalKind)),this.isVertexBufferUpdatable(Y.R.NormalKind)&&(t.normals._updatable=!0)),this.isVerticesDataPresent(Y.R.TangentKind)&&(t.tangents=this._toNumberArray(this.getVerticesData(Y.R.TangentKind)),this.isVertexBufferUpdatable(Y.R.TangentKind)&&(t.tangents._updatable=!0)),this.isVerticesDataPresent(Y.R.UVKind)&&(t.uvs=this._toNumberArray(this.getVerticesData(Y.R.UVKind)),this.isVertexBufferUpdatable(Y.R.UVKind)&&(t.uvs._updatable=!0)),this.isVerticesDataPresent(Y.R.UV2Kind)&&(t.uvs2=this._toNumberArray(this.getVerticesData(Y.R.UV2Kind)),this.isVertexBufferUpdatable(Y.R.UV2Kind)&&(t.uvs2._updatable=!0)),this.isVerticesDataPresent(Y.R.UV3Kind)&&(t.uvs3=this._toNumberArray(this.getVerticesData(Y.R.UV3Kind)),this.isVertexBufferUpdatable(Y.R.UV3Kind)&&(t.uvs3._updatable=!0)),this.isVerticesDataPresent(Y.R.UV4Kind)&&(t.uvs4=this._toNumberArray(this.getVerticesData(Y.R.UV4Kind)),this.isVertexBufferUpdatable(Y.R.UV4Kind)&&(t.uvs4._updatable=!0)),this.isVerticesDataPresent(Y.R.UV5Kind)&&(t.uvs5=this._toNumberArray(this.getVerticesData(Y.R.UV5Kind)),this.isVertexBufferUpdatable(Y.R.UV5Kind)&&(t.uvs5._updatable=!0)),this.isVerticesDataPresent(Y.R.UV6Kind)&&(t.uvs6=this._toNumberArray(this.getVerticesData(Y.R.UV6Kind)),this.isVertexBufferUpdatable(Y.R.UV6Kind)&&(t.uvs6._updatable=!0)),this.isVerticesDataPresent(Y.R.ColorKind)&&(t.colors=this._toNumberArray(this.getVerticesData(Y.R.ColorKind)),this.isVertexBufferUpdatable(Y.R.ColorKind)&&(t.colors._updatable=!0)),this.isVerticesDataPresent(Y.R.MatricesIndicesKind)&&(t.matricesIndices=this._toNumberArray(this.getVerticesData(Y.R.MatricesIndicesKind)),t.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(Y.R.MatricesIndicesKind)&&(t.matricesIndices._updatable=!0)),this.isVerticesDataPresent(Y.R.MatricesWeightsKind)&&(t.matricesWeights=this._toNumberArray(this.getVerticesData(Y.R.MatricesWeightsKind)),this.isVertexBufferUpdatable(Y.R.MatricesWeightsKind)&&(t.matricesWeights._updatable=!0)),t.indices=this._toNumberArray(this.getIndices()),t},r.ExtractFromMesh=function(t,e){var n=t._geometry;return n?n.copy(e):null},r.RandomId=function(){return ze.S0.RandomId()},r._GetGeometryByLoadedUniqueId=function(t,e){for(var n=0;n<e.geometries.length;n++)if(e.geometries[n]._loadedUniqueId===t)return e.geometries[n];return null},r._ImportGeometry=function(t,e){var n=e.getScene(),i=t.geometryUniqueId,o=t.geometryId;if(i||o){var a=i?this._GetGeometryByLoadedUniqueId(i,n):n.getGeometryById(o);a&&a.applyToMesh(e)}else if(t instanceof ArrayBuffer){var s=e._binaryInfo;if(s.positionsAttrDesc&&s.positionsAttrDesc.count>0){var l=new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);e.setVerticesData(Y.R.PositionKind,l,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var c=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);e.setVerticesData(Y.R.NormalKind,c,!1)}if(s.tangetsAttrDesc&&s.tangetsAttrDesc.count>0){var u=new Float32Array(t,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);e.setVerticesData(Y.R.TangentKind,u,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var d=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);if(Xt.rX)for(var h=1;h<d.length;h+=2)d[h]=1-d[h];e.setVerticesData(Y.R.UVKind,d,!1)}if(s.uvs2AttrDesc&&s.uvs2AttrDesc.count>0){var p=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);if(Xt.rX)for(h=1;h<p.length;h+=2)p[h]=1-p[h];e.setVerticesData(Y.R.UV2Kind,p,!1)}if(s.uvs3AttrDesc&&s.uvs3AttrDesc.count>0){var m=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);if(Xt.rX)for(h=1;h<m.length;h+=2)m[h]=1-m[h];e.setVerticesData(Y.R.UV3Kind,m,!1)}if(s.uvs4AttrDesc&&s.uvs4AttrDesc.count>0){var v=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);if(Xt.rX)for(h=1;h<v.length;h+=2)v[h]=1-v[h];e.setVerticesData(Y.R.UV4Kind,v,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var b=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);if(Xt.rX)for(h=1;h<b.length;h+=2)b[h]=1-b[h];e.setVerticesData(Y.R.UV5Kind,b,!1)}if(s.uvs6AttrDesc&&s.uvs6AttrDesc.count>0){var E=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);if(Xt.rX)for(h=1;h<E.length;h+=2)E[h]=1-E[h];e.setVerticesData(Y.R.UV6Kind,E,!1)}if(s.colorsAttrDesc&&s.colorsAttrDesc.count>0){var C=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);e.setVerticesData(Y.R.ColorKind,C,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){for(var T=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count),f=[],g=0;g<T.length;g++)h=T[g],f.push(255&h),f.push((65280&h)>>8),f.push((16711680&h)>>16),f.push(h>>24&255);e.setVerticesData(Y.R.MatricesIndicesKind,f,!1)}if(s.matricesIndicesExtraAttrDesc&&s.matricesIndicesExtraAttrDesc.count>0){for(T=new Int32Array(t,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count),f=[],g=0;g<T.length;g++)h=T[g],f.push(255&h),f.push((65280&h)>>8),f.push((16711680&h)>>16),f.push(h>>24&255);e.setVerticesData(Y.R.MatricesIndicesExtraKind,f,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var S=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);e.setVerticesData(Y.R.MatricesWeightsKind,S,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){var y=new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);e.setIndices(y,null)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){var x=new Int32Array(t,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);for(e.subMeshes=[],g=0;g<s.subMeshesAttrDesc.count;g++){var R=x[5*g+0],I=x[5*g+1],M=x[5*g+2],D=x[5*g+3],B=x[5*g+4];yi.AddToMesh(R,I,M,D,B,e)}}}else if(t.positions&&t.normals&&t.indices){if(e.setVerticesData(Y.R.PositionKind,t.positions,t.positions._updatable),e.setVerticesData(Y.R.NormalKind,t.normals,t.normals._updatable),t.tangents&&e.setVerticesData(Y.R.TangentKind,t.tangents,t.tangents._updatable),t.uvs&&e.setVerticesData(Y.R.UVKind,t.uvs,t.uvs._updatable),t.uvs2&&e.setVerticesData(Y.R.UV2Kind,t.uvs2,t.uvs2._updatable),t.uvs3&&e.setVerticesData(Y.R.UV3Kind,t.uvs3,t.uvs3._updatable),t.uvs4&&e.setVerticesData(Y.R.UV4Kind,t.uvs4,t.uvs4._updatable),t.uvs5&&e.setVerticesData(Y.R.UV5Kind,t.uvs5,t.uvs5._updatable),t.uvs6&&e.setVerticesData(Y.R.UV6Kind,t.uvs6,t.uvs6._updatable),t.colors&&e.setVerticesData(Y.R.ColorKind,z.ov.CheckColors4(t.colors,t.positions.length/3),t.colors._updatable),t.matricesIndices)if(t.matricesIndices._isExpanded)delete t.matricesIndices._isExpanded,e.setVerticesData(Y.R.MatricesIndicesKind,t.matricesIndices,t.matricesIndices._updatable);else{for(f=[],g=0;g<t.matricesIndices.length;g++){var F=t.matricesIndices[g];f.push(255&F),f.push((65280&F)>>8),f.push((16711680&F)>>16),f.push(F>>24&255)}e.setVerticesData(Y.R.MatricesIndicesKind,f,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,e.setVerticesData(Y.R.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(f=[],g=0;g<t.matricesIndicesExtra.length;g++)F=t.matricesIndicesExtra[g],f.push(255&F),f.push((65280&F)>>8),f.push((16711680&F)>>16),f.push(F>>24&255);e.setVerticesData(Y.R.MatricesIndicesExtraKind,f,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(r._CleanMatricesWeights(t,e),e.setVerticesData(Y.R.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&e.setVerticesData(Y.R.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),e.setIndices(t.indices,null)}if(t.subMeshes){e.subMeshes=[];for(var X=0;X<t.subMeshes.length;X++){var $=t.subMeshes[X];yi.AddToMesh($.materialIndex,$.verticesStart,$.verticesCount,$.indexStart,$.indexCount,e)}}e._shouldGenerateFlatShading&&(e.convertToFlatShadedMesh(),e._shouldGenerateFlatShading=!1),e.computeWorldMatrix(!0),n.onMeshImportedObservable.notifyObservers(e)},r._CleanMatricesWeights=function(t,e){var n=.001;if(pr.CleanBoneMatrixWeights){var i=0;if(t.skeletonId>-1){var o=e.getScene().getLastSkeletonById(t.skeletonId);if(o){i=o.bones.length;for(var a=e.getVerticesData(Y.R.MatricesIndicesKind),s=e.getVerticesData(Y.R.MatricesIndicesExtraKind),l=t.matricesWeights,c=t.matricesWeightsExtra,u=t.numBoneInfluencer,d=l.length,h=0;h<d;h+=4){for(var p=0,m=-1,v=0;v<4;v++)p+=b=l[h+v],b<n&&m<0&&(m=v);if(c)for(v=0;v<4;v++){var b;p+=b=c[h+v],b<n&&m<0&&(m=v+4)}if((m<0||m>u-1)&&(m=u-1),p>n){var E=1/p;for(v=0;v<4;v++)l[h+v]*=E;if(c)for(v=0;v<4;v++)c[h+v]*=E}else m>=4?(c[h+m-4]=1-p,s[h+m-4]=i):(l[h+m]=1-p,a[h+m]=i)}e.setVerticesData(Y.R.MatricesIndicesKind,a),t.matricesWeightsExtra&&e.setVerticesData(Y.R.MatricesIndicesExtraKind,s)}}}},r.Parse=function(t,e,n){var i=new r(t.id,e,void 0,t.updatable);return i._loadedUniqueId=t.uniqueId,En.Y&&En.Y.AddTagsTo(i,t.tags),t.delayLoadingFile?(i.delayLoadState=P.Y.DELAYLOADSTATE_NOTLOADED,i.delayLoadingFile=n+t.delayLoadingFile,i._boundingInfo=new tr(_.Pq.FromArray(t.boundingBoxMinimum),_.Pq.FromArray(t.boundingBoxMaximum)),i._delayInfo=[],t.hasUVs&&i._delayInfo.push(Y.R.UVKind),t.hasUVs2&&i._delayInfo.push(Y.R.UV2Kind),t.hasUVs3&&i._delayInfo.push(Y.R.UV3Kind),t.hasUVs4&&i._delayInfo.push(Y.R.UV4Kind),t.hasUVs5&&i._delayInfo.push(Y.R.UV5Kind),t.hasUVs6&&i._delayInfo.push(Y.R.UV6Kind),t.hasColors&&i._delayInfo.push(Y.R.ColorKind),t.hasMatricesIndices&&i._delayInfo.push(Y.R.MatricesIndicesKind),t.hasMatricesWeights&&i._delayInfo.push(Y.R.MatricesWeightsKind),i._delayLoadingFunction=rt.ImportVertexData):rt.ImportVertexData(t,i),e.pushGeometry(i,!0),i},r}(),H1=_.uq.Compose(_.Pq.One(),_.PT.FromEulerAngles(0,Math.PI,0),_.Pq.Zero()),jt=function(r){function t(e,n,i){n===void 0&&(n=null),i===void 0&&(i=!0);var o=r.call(this,e,n,!1)||this;return o._forward=new _.Pq(0,0,1),o._up=new _.Pq(0,1,0),o._right=new _.Pq(1,0,0),o._position=_.Pq.Zero(),o._rotation=_.Pq.Zero(),o._rotationQuaternion=null,o._scaling=_.Pq.One(),o._transformToBoneReferal=null,o._isAbsoluteSynced=!1,o._billboardMode=t.BILLBOARDMODE_NONE,o._preserveParentRotationForBillboard=!1,o.scalingDeterminant=1,o._infiniteDistance=!1,o.ignoreNonUniformScaling=!1,o.reIntegrateRotationIntoRotationQuaternion=!1,o._poseMatrix=null,o._localMatrix=_.uq.Zero(),o._usePivotMatrix=!1,o._absolutePosition=_.Pq.Zero(),o._absoluteScaling=_.Pq.Zero(),o._absoluteRotationQuaternion=_.PT.Identity(),o._pivotMatrix=_.uq.Identity(),o._postMultiplyPivotMatrix=!1,o._isWorldMatrixFrozen=!1,o._indexInSceneTransformNodesArray=-1,o.onAfterWorldMatrixUpdateObservable=new K.cP,o._nonUniformScaling=!1,i&&o.getScene().addTransformNode(o),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=!!(this._billboardMode&t.BILLBOARDMODE_USE_POSITION),this._computeUseBillboardPath())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"preserveParentRotationForBillboard",{get:function(){return this._preserveParentRotationForBillboard},set:function(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e,this._computeUseBillboardPath())},enumerable:!1,configurable:!0}),t.prototype._computeUseBillboardPath=function(){this._cache.useBillboardPath=this._billboardMode!==t.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard},Object.defineProperty(t.prototype,"infiniteDistance",{get:function(){return this._infiniteDistance},set:function(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TransformNode"},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._isDirty=!0},enumerable:!1,configurable:!0}),t.prototype.isUsingPivotMatrix=function(){return this._usePivotMatrix},t.prototype.isUsingPostMultiplyPivotMatrix=function(){return this._postMultiplyPivotMatrix},Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._rotationQuaternion=null,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forward",{get:function(){return _.Pq.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"up",{get:function(){return _.Pq.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return _.Pq.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()},enumerable:!1,configurable:!0}),t.prototype.updatePoseMatrix=function(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)},t.prototype.getPoseMatrix=function(){return this._poseMatrix||(this._poseMatrix=_.uq.Identity()),this._poseMatrix},t.prototype._isSynchronized=function(){var e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==t.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)},t.prototype._initCache=function(){r.prototype._initCache.call(this);var e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1,e.useBillboardPath=!1},Object.defineProperty(t.prototype,"absolutePosition",{get:function(){return this.getAbsolutePosition()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"absoluteScaling",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"absoluteRotationQuaternion",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion},enumerable:!1,configurable:!0}),t.prototype.setPreTransformMatrix=function(e){return this.setPivotMatrix(e,!1)},t.prototype.setPivotMatrix=function(e,n){return n===void 0&&(n=!0),this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=n,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=_.uq.Invert(this._pivotMatrix)),this},t.prototype.getPivotMatrix=function(){return this._pivotMatrix},t.prototype.instantiateHierarchy=function(e,n,i){e===void 0&&(e=null);var o=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);o&&i&&i(this,o);for(var a=0,s=this.getChildTransformNodes(!0);a<s.length;a++)s[a].instantiateHierarchy(o,n,i);return o},t.prototype.freezeWorldMatrix=function(e,n){return e===void 0&&(e=null),n===void 0&&(n=!1),e?n?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||_.PT.Identity(),e.decompose(this._scaling,this._rotationQuaternion,this._position),this.computeWorldMatrix(!0)):(this._worldMatrix=e,this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._afterComputeWorldMatrix()):(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this},t.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(t.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!1,configurable:!0}),t.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},t.prototype.setAbsolutePosition=function(e){if(!e)return this;var n,i,o;if(e.x===void 0){if(arguments.length<3)return this;n=arguments[0],i=arguments[1],o=arguments[2]}else n=e.x,i=e.y,o=e.z;if(this.parent){var a=_.AA.Matrix[0];this.parent.getWorldMatrix().invertToRef(a),_.Pq.TransformCoordinatesFromFloatsToRef(n,i,o,a,this.position)}else this.position.x=n,this.position.y=i,this.position.z=o;return this._absolutePosition.copyFrom(e),this},t.prototype.setPositionWithLocalVector=function(e){return this.computeWorldMatrix(),this.position=_.Pq.TransformNormal(e,this._localMatrix),this},t.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var e=_.AA.Matrix[0];return this._localMatrix.invertToRef(e),_.Pq.TransformNormal(this.position,e)},t.prototype.locallyTranslate=function(e){return this.computeWorldMatrix(!0),this.position=_.Pq.TransformCoordinates(e,this._localMatrix),this},t.prototype.lookAt=function(e,n,i,o,a){n===void 0&&(n=0),i===void 0&&(i=0),o===void 0&&(o=0),a===void 0&&(a=0);var s=t._LookAtVectorCache,l=a===0?this.position:this.getAbsolutePosition();if(e.subtractToRef(l,s),this.setDirection(s,n,i,o),a===1&&this.parent)if(this.rotationQuaternion){var c=_.AA.Matrix[0];this.rotationQuaternion.toRotationMatrix(c);var u=_.AA.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.invert(),c.multiplyToRef(u,c),this.rotationQuaternion.fromRotationMatrix(c)}else{var d=_.AA.Quaternion[0];_.PT.FromEulerVectorToRef(this.rotation,d),c=_.AA.Matrix[0],d.toRotationMatrix(c),u=_.AA.Matrix[1],this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.invert(),c.multiplyToRef(u,c),d.fromRotationMatrix(c),d.toEulerAnglesToRef(this.rotation)}return this},t.prototype.getDirection=function(e){var n=_.Pq.Zero();return this.getDirectionToRef(e,n),n},t.prototype.getDirectionToRef=function(e,n){return _.Pq.TransformNormalToRef(e,this.getWorldMatrix(),n),this},t.prototype.setDirection=function(e,n,i,o){n===void 0&&(n=0),i===void 0&&(i=0),o===void 0&&(o=0);var a=-Math.atan2(e.z,e.x)+Math.PI/2,s=Math.sqrt(e.x*e.x+e.z*e.z),l=-Math.atan2(e.y,s);return this.rotationQuaternion?_.PT.RotationYawPitchRollToRef(a+n,l+i,o,this.rotationQuaternion):(this.rotation.x=l+i,this.rotation.y=a+n,this.rotation.z=o),this},t.prototype.setPivotPoint=function(e,n){n===void 0&&(n=0),this.getScene().getRenderId()==0&&this.computeWorldMatrix(!0);var i=this.getWorldMatrix();if(n==1){var o=_.AA.Matrix[0];i.invertToRef(o),e=_.Pq.TransformCoordinates(e,o)}return this.setPivotMatrix(_.uq.Translation(-e.x,-e.y,-e.z),!0)},t.prototype.getPivotPoint=function(){var e=_.Pq.Zero();return this.getPivotPointToRef(e),e},t.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},t.prototype.getAbsolutePivotPoint=function(){var e=_.Pq.Zero();return this.getAbsolutePivotPointToRef(e),e},t.prototype.getAbsolutePivotPointToRef=function(e){return this.getPivotPointToRef(e),_.Pq.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this},t.prototype.markAsDirty=function(e){if(this._isDirty)return this;if(this._children)for(var n=0,i=this._children;n<i.length;n++)i[n].markAsDirty(e);return r.prototype.markAsDirty.call(this,e)},t.prototype.setParent=function(e,n,i){if(n===void 0&&(n=!1),i===void 0&&(i=!1),!e&&!this.parent)return this;var o=_.AA.Quaternion[0],a=_.AA.Vector3[0],s=_.AA.Vector3[1],l=_.AA.Matrix[1];_.uq.IdentityToRef(l);var c=_.AA.Matrix[0];this.computeWorldMatrix(!0);var u=this.rotationQuaternion;return u||(u=t._TmpRotation,_.PT.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,u)),_.uq.ComposeToRef(this.scaling,u,this.position,c),this.parent&&c.multiplyToRef(this.parent.computeWorldMatrix(!0),c),e&&(e.computeWorldMatrix(!0).invertToRef(l),c.multiplyToRef(l,c)),c.decompose(s,o,a,n?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(o):o.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(s),this.position.copyFrom(a),this.parent=e,i&&this.setPivotMatrix(_.uq.Identity()),this},t.prototype.addChild=function(e,n){return n===void 0&&(n=!1),e.setParent(this,n),this},t.prototype.removeChild=function(e,n){return n===void 0&&(n=!1),e.setParent(null,n),this},Object.defineProperty(t.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!1,configurable:!0}),t.prototype._updateNonUniformScalingState=function(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=e,!0)},t.prototype.attachToBone=function(e,n){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=n,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},t.prototype.detachFromBone=function(e){return e===void 0&&(e=!1),this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=e?this._currentParentWhenAttachingToBone:null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)},t.prototype.rotate=function(e,n,i){var o;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),i&&i!==0){if(this.parent){var a=this.parent.getWorldMatrix(),s=_.AA.Matrix[0];a.invertToRef(s),e=_.Pq.TransformNormal(e,s),a.determinant()<0&&(n*=-1)}(o=_.PT.RotationAxisToRef(e,n,t._RotationAxisCache)).multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=_.PT.RotationAxisToRef(e,n,t._RotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion);return this},t.prototype.rotateAround=function(e,n,i){n.normalize(),this.rotationQuaternion||(this.rotationQuaternion=_.PT.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));var o=_.AA.Vector3[0],a=_.AA.Vector3[1],s=_.AA.Vector3[2],l=_.AA.Quaternion[0],c=_.AA.Matrix[0],u=_.AA.Matrix[1],d=_.AA.Matrix[2],h=_.AA.Matrix[3];return e.subtractToRef(this.position,o),_.uq.TranslationToRef(o.x,o.y,o.z,c),_.uq.TranslationToRef(-o.x,-o.y,-o.z,u),_.uq.RotationAxisToRef(n,i,d),u.multiplyToRef(d,h),h.multiplyToRef(c,h),h.decompose(a,l,s),this.position.addInPlace(s),l.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},t.prototype.translate=function(e,n,i){var o=e.scale(n);if(i&&i!==0)this.setAbsolutePosition(this.getAbsolutePosition().add(o));else{var a=this.getPositionExpressedInLocalSpace().add(o);this.setPositionWithLocalVector(a)}return this},t.prototype.addRotation=function(e,n,i){var o;this.rotationQuaternion?o=this.rotationQuaternion:(o=_.AA.Quaternion[1],_.PT.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,o));var a=_.AA.Quaternion[0];return _.PT.RotationYawPitchRollToRef(n,e,i,a),o.multiplyInPlace(a),this.rotationQuaternion||o.toEulerAnglesToRef(this.rotation),this},t.prototype._getEffectiveParent=function(){return this.parent},t.prototype.isWorldMatrixCameraDependent=function(){return this._infiniteDistance&&!this.parent||this._billboardMode!==t.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard},t.prototype.computeWorldMatrix=function(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;var i=this.getScene().getRenderId();if(!this._isDirty&&!e&&(this._currentRenderId===i||this.isSynchronized()))return this._currentRenderId=i,this._worldMatrix;n=n||this.getScene().activeCamera,this._updateCache();var o=this._cache;o.pivotMatrixUpdated=!1,o.billboardMode=this.billboardMode,o.infiniteDistance=this.infiniteDistance,o.parent=this._parentNode,this._currentRenderId=i,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;var a,s=this._getEffectiveParent(),l=t._TmpScaling,c=this._position;if(this._infiniteDistance&&!this.parent&&n){var u=n.getWorldMatrix(),d=new _.Pq(u.m[12],u.m[13],u.m[14]);(c=t._TmpTranslation).copyFromFloats(this._position.x+d.x,this._position.y+d.y,this._position.z+d.z)}if(l.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant),this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,a=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&(y=this.rotation.lengthSquared())&&(this._rotationQuaternion.multiplyInPlace(_.PT.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(a=t._TmpRotation,_.PT.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,a)),this._usePivotMatrix){var h=_.AA.Matrix[1];_.uq.ScalingToRef(l.x,l.y,l.z,h);var p=_.AA.Matrix[0];a.toRotationMatrix(p),this._pivotMatrix.multiplyToRef(h,_.AA.Matrix[4]),_.AA.Matrix[4].multiplyToRef(p,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(c.x,c.y,c.z)}else _.uq.ComposeToRef(l,a,c,this._localMatrix);if(s&&s.getWorldMatrix){if(e&&s.computeWorldMatrix(e),o.useBillboardPath){this._transformToBoneReferal?((E=this.parent).getSkeleton().prepare(),E.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),_.AA.Matrix[7])):_.AA.Matrix[7].copyFrom(s.getWorldMatrix());var m=_.AA.Vector3[5],v=_.AA.Vector3[6],b=_.AA.Quaternion[0];_.AA.Matrix[7].decompose(v,b,m),_.uq.ScalingToRef(v.x,v.y,v.z,_.AA.Matrix[7]),_.AA.Matrix[7].setTranslation(m),t.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(b,m),this._localMatrix.setTranslation(m)),this._localMatrix.multiplyToRef(_.AA.Matrix[7],this._worldMatrix)}else{var E;this._transformToBoneReferal?((E=this.parent).getSkeleton().prepare(),this._localMatrix.multiplyToRef(E.getFinalMatrix(),_.AA.Matrix[6]),_.AA.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localMatrix.multiplyToRef(s.getWorldMatrix(),this._worldMatrix)}this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(o.useBillboardPath&&n&&this.billboardMode&&!o.useBillboardPosition){var C=_.AA.Vector3[0];if(this._worldMatrix.getTranslationToRef(C),_.AA.Matrix[1].copyFrom(n.getViewMatrix()),this._scene.useRightHandedSystem&&_.AA.Matrix[1].multiplyToRef(H1,_.AA.Matrix[1]),_.AA.Matrix[1].setTranslationFromFloats(0,0,0),_.AA.Matrix[1].invertToRef(_.AA.Matrix[0]),(this.billboardMode&t.BILLBOARDMODE_ALL)!==t.BILLBOARDMODE_ALL){_.AA.Matrix[0].decompose(void 0,_.AA.Quaternion[0],void 0);var T=_.AA.Vector3[1];_.AA.Quaternion[0].toEulerAnglesToRef(T),(this.billboardMode&t.BILLBOARDMODE_X)!==t.BILLBOARDMODE_X&&(T.x=0),(this.billboardMode&t.BILLBOARDMODE_Y)!==t.BILLBOARDMODE_Y&&(T.y=0),(this.billboardMode&t.BILLBOARDMODE_Z)!==t.BILLBOARDMODE_Z&&(T.z=0),_.uq.RotationYawPitchRollToRef(T.y,T.x,T.z,_.AA.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(_.AA.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(_.AA.Vector3[0])}else if(o.useBillboardPath&&n&&o.useBillboardPosition){C=_.AA.Vector3[0],this._worldMatrix.getTranslationToRef(C);var f=n.globalPosition;this._worldMatrix.invertToRef(_.AA.Matrix[1]);var g=_.AA.Vector3[1];_.Pq.TransformCoordinatesToRef(f,_.AA.Matrix[1],g),g.normalize();var S=-Math.atan2(g.z,g.x)+Math.PI/2,y=Math.sqrt(g.x*g.x+g.z*g.z),x=-Math.atan2(g.y,y);_.PT.RotationYawPitchRollToRef(S,x,0,_.AA.Quaternion[0]),(this.billboardMode&t.BILLBOARDMODE_ALL)!==t.BILLBOARDMODE_ALL?(T=_.AA.Vector3[1],_.AA.Quaternion[0].toEulerAnglesToRef(T),(this.billboardMode&t.BILLBOARDMODE_X)!==t.BILLBOARDMODE_X&&(T.x=0),(this.billboardMode&t.BILLBOARDMODE_Y)!==t.BILLBOARDMODE_Y&&(T.y=0),(this.billboardMode&t.BILLBOARDMODE_Z)!==t.BILLBOARDMODE_Z&&(T.z=0),_.uq.RotationYawPitchRollToRef(T.y,T.x,T.z,_.AA.Matrix[0])):_.uq.FromQuaternionToRef(_.AA.Quaternion[0],_.AA.Matrix[0]),this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(_.AA.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(_.AA.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):s&&s._nonUniformScaling?this._updateNonUniformScalingState(s._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=_.uq.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix},t.prototype.resetLocalMatrix=function(e){if(e===void 0&&(e=!0),this.computeWorldMatrix(),e)for(var n=this.getChildren(),i=0;i<n.length;++i){var o=n[i];if(o){o.computeWorldMatrix();var a=_.AA.Matrix[0];o._localMatrix.multiplyToRef(this._localMatrix,a);var s=_.AA.Quaternion[0];a.decompose(o.scaling,s,o.position),o.rotationQuaternion?o.rotationQuaternion.copyFrom(s):s.toEulerAnglesToRef(o.rotation)}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=_.PT.Identity()),this._worldMatrix=_.uq.Identity()},t.prototype._afterComputeWorldMatrix=function(){},t.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},t.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},t.prototype.getPositionInCameraSpace=function(e){return e===void 0&&(e=null),e||(e=this.getScene().activeCamera),_.Pq.TransformCoordinates(this.getAbsolutePosition(),e.getViewMatrix())},t.prototype.getDistanceToCamera=function(e){return e===void 0&&(e=null),e||(e=this.getScene().activeCamera),this.getAbsolutePosition().subtract(e.globalPosition).length()},t.prototype.clone=function(e,n,i){var o=this,a=tt.p.Clone(function(){return new t(e,o.getScene())},this);if(a.name=e,a.id=e,n&&(a.parent=n),!i)for(var s=this.getDescendants(!0),l=0;l<s.length;l++){var c=s[l];c.clone&&c.clone(e+"."+c.name,a)}return a},t.prototype.serialize=function(e){var n=tt.p.Serialize(this,e);return n.type=this.getClassName(),n.uniqueId=this.uniqueId,this.parent&&this.parent._serializeAsParent(n),n.localMatrix=this.getPivotMatrix().asArray(),n.isEnabled=this.isEnabled(),tt.p.AppendSerializedAnimations(this,n),n.ranges=this.serializeAnimationRanges(),n},t.Parse=function(e,n,i){var o=tt.p.Parse(function(){return new t(e.name,n)},e,n,i);if(e.localMatrix?o.setPreTransformMatrix(_.uq.FromArray(e.localMatrix)):e.pivotMatrix&&o.setPivotMatrix(_.uq.FromArray(e.pivotMatrix)),o.setEnabled(e.isEnabled),o._waitingParsedUniqueId=e.uniqueId,e.parentId!==void 0&&(o._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(o._waitingParentInstanceIndex=e.parentInstanceIndex),e.animations){for(var a=0;a<e.animations.length;a++){var s=e.animations[a],l=(0,j.n9)("BABYLON.Animation");l&&o.animations.push(l.Parse(s))}At.ParseAnimationRanges(o,e,n)}return e.autoAnimate&&n.beginAnimation(o,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),o},t.prototype.getChildTransformNodes=function(e,n){var i=[];return this._getDescendants(i,e,function(o){return(!n||n(o))&&o instanceof t}),i},t.prototype.dispose=function(e,n){if(n===void 0&&(n=!1),this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){var i=this._parentContainer.transformNodes.indexOf(this);i>-1&&this._parentContainer.transformNodes.splice(i,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e)for(var o=0,a=this.getChildTransformNodes(!0);o<a.length;o++){var s=a[o];s.parent=null,s.computeWorldMatrix(!0)}r.prototype.dispose.call(this,e,n)},t.prototype.normalizeToUnitCube=function(e,n,i){e===void 0&&(e=!0),n===void 0&&(n=!1);var o=null,a=null;n&&(this.rotationQuaternion?(a=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(o=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));var s=this.getHierarchyBoundingVectors(e,i),l=s.max.subtract(s.min),c=Math.max(l.x,l.y,l.z);if(c===0)return this;var u=1/c;return this.scaling.scaleInPlace(u),n&&(this.rotationQuaternion&&a?this.rotationQuaternion.copyFrom(a):this.rotation&&o&&this.rotation.copyFrom(o)),this},t.prototype._syncAbsoluteScalingAndRotation=function(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)},t.BILLBOARDMODE_NONE=0,t.BILLBOARDMODE_X=1,t.BILLBOARDMODE_Y=2,t.BILLBOARDMODE_Z=4,t.BILLBOARDMODE_ALL=7,t.BILLBOARDMODE_USE_POSITION=128,t.BillboardUseParentOrientation=!1,t._TmpRotation=_.PT.Zero(),t._TmpScaling=_.Pq.Zero(),t._TmpTranslation=_.Pq.Zero(),t._LookAtVectorCache=new _.Pq(0,0,0),t._RotationAxisCache=new _.PT,(0,A.Cg)([(0,V.P_)("position")],t.prototype,"_position",void 0),(0,A.Cg)([(0,V.P_)("rotation")],t.prototype,"_rotation",void 0),(0,A.Cg)([(0,V.bR)("rotationQuaternion")],t.prototype,"_rotationQuaternion",void 0),(0,A.Cg)([(0,V.P_)("scaling")],t.prototype,"_scaling",void 0),(0,A.Cg)([(0,V.lK)("billboardMode")],t.prototype,"_billboardMode",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"scalingDeterminant",void 0),(0,A.Cg)([(0,V.lK)("infiniteDistance")],t.prototype,"_infiniteDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"ignoreNonUniformScaling",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0),t}(At),ri=L(8004),Ui=L(75482),Q_=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new _.Pq(0,0,0),this._diffPositionForCollisions=new _.Pq(0,0,0),this._collisionResponse=!0},Qn=L(13424),Be=L(82673),Y1=function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=_.Pq.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1},X1=function(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new Y1,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new Q_,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._inheritVisibility=!1},cn=function(r){function t(e,n){n===void 0&&(n=null);var i=r.call(this,e,n,!1)||this;switch(i._internalAbstractMeshDataInfo=new X1,i._waitingMaterialId=null,i.cullingStrategy=t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,i.onCollideObservable=new K.cP,i.onCollisionPositionChangeObservable=new K.cP,i.onMaterialChangedObservable=new K.cP,i.definedFacingForward=!0,i._occlusionQuery=null,i._renderingGroup=null,i.alphaIndex=Number.MAX_VALUE,i._isVisible=!0,i.isPickable=!0,i.isNearPickable=!1,i.isNearGrabbable=!1,i.showSubMeshesBoundingBox=!1,i.isBlocker=!1,i.enablePointerMoveEvents=!1,i.outlineColor=z.v9.Red(),i.outlineWidth=.02,i.overlayColor=z.v9.Red(),i.overlayAlpha=.5,i.useOctreeForRenderingSelection=!0,i.useOctreeForPicking=!0,i.useOctreeForCollisions=!0,i.alwaysSelectAsActiveMesh=!1,i.doNotSyncBoundingInfo=!1,i.actionManager=null,i.ellipsoid=new _.Pq(.5,1,.5),i.ellipsoidOffset=new _.Pq(0,0,0),i.edgesWidth=1,i.edgesColor=new z.ov(1,0,0,1),i._edgesRenderer=null,i._masterMesh=null,i._boundingInfo=null,i._boundingInfoIsDirty=!0,i._renderId=0,i._intersectionsInProgress=new Array,i._unIndexed=!1,i._lightSources=new Array,i._waitingData={lods:null,actions:null,freezeWorldMatrix:null},i._bonesTransformMatrices=null,i._transformMatrixTexture=null,i.onRebuildObservable=new K.cP,i._onCollisionPositionChange=function(o,a,s){s===void 0&&(s=null),a.subtractToRef(i._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,i._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),i._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>Be.$.CollisionsEpsilon&&i.position.addInPlace(i._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),s&&i.onCollideObservable.notifyObservers(s),i.onCollisionPositionChangeObservable.notifyObservers(i.position)},(n=i.getScene()).addMesh(i),i._resyncLightSources(),i._uniformBuffer=new Ui.D(i.getScene().getEngine(),void 0,void 0,e,!i.getScene().getEngine().isWebGPU),i._buildUniformLayout(),n.performancePriority){case 2:i.doNotSyncBoundingInfo=!0;case 1:i.alwaysSelectAsActiveMesh=!0,i.isPickable=!1}return i}return(0,A.C6)(t,r),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return jt.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return jt.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return jt.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return jt.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return jt.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return jt.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionRetryCount",{get:function(){return this._internalAbstractMeshDataInfo._collisionRetryCount},set:function(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"morphTargetManager",{get:function(){return this._internalAbstractMeshDataInfo._morphTargetManager},set:function(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bakedVertexAnimationManager",{get:function(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager},set:function(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),t.prototype._syncGeometryWithMorphTargetManager=function(){},t.prototype._updateNonUniformScalingState=function(e){return!!r.prototype._updateNonUniformScalingState.call(this,e)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,"rawBoundingInfo",{get:function(){return this._internalAbstractMeshDataInfo._rawBoundingInfo},set:function(e){this._internalAbstractMeshDataInfo._rawBoundingInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCollide",{set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){if(this._internalAbstractMeshDataInfo._visibility!==e){var n=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(n===1&&e!==1||n!==1&&e===1)&&this._markSubMeshesAsDirty(function(i){i.markAsMiscDirty(),i.markAsPrePassDirty()})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inheritVisibility",{get:function(){return this._internalAbstractMeshDataInfo._inheritVisibility},set:function(e){this._internalAbstractMeshDataInfo._inheritVisibility=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isVisible",{get:function(){if(!this._isVisible||!this.inheritVisibility||!this._parentNode)return this._isVisible;if(this._isVisible)for(var e=this._parentNode;e;){var n=e.isVisible;if(n!==void 0)return n;e=e.parent}return this._isVisible},set:function(e){this._isVisible=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerOverDisableMeshTesting",{get:function(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting},set:function(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._internalAbstractMeshDataInfo._renderingGroupId},set:function(e){this._internalAbstractMeshDataInfo._renderingGroupId=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._internalAbstractMeshDataInfo._material},set:function(e){this._setMaterial(e)},enumerable:!1,configurable:!0}),t.prototype._setMaterial=function(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(),this._unBindEffect()))},t.prototype.getMaterialForRenderPass=function(e){var n;return(n=this._internalAbstractMeshDataInfo._materialForRenderPass)===null||n===void 0?void 0:n[e]},t.prototype.setMaterialForRenderPass=function(e,n){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=n},Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasVertexAlpha",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useVertexColors",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numBoneInfluencers",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"applyFog",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableDistantPicking",{get:function(){return this._internalAbstractMeshDataInfo._enableDistantPicking},set:function(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerMask",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionResponse",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surroundingMeshes",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(e){var n=this._internalAbstractMeshDataInfo._skeleton;n&&n.needInitialSkinMatrix&&n._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!1,configurable:!0}),t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e){var n=this._uniformBuffer;n.updateMatrix("world",e),n.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),n.update()},t.prototype.getMeshUniformBuffer=function(){return this._uniformBuffer},t.prototype.getClassName=function(){return"AbstractMesh"},t.prototype.toString=function(e){var n="Name: "+this.name+", isInstance: "+(this.getClassName()!=="InstancedMesh"?"YES":"NO");n+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);var i=this._internalAbstractMeshDataInfo._skeleton;return i&&(n+=", skeleton: "+i.name),e&&(n+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],n+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),n},t.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==jt.BILLBOARDMODE_NONE?this._masterMesh:r.prototype._getEffectiveParent.call(this)},t.prototype._getActionManagerForTrigger=function(e,n){if(n===void 0&&(n=!0),this.actionManager&&(n||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},t.prototype._rebuild=function(e){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery!==null&&(this._occlusionQuery=null),this.subMeshes){for(var n=0,i=this.subMeshes;n<i.length;n++)i[n]._rebuild();this.resetDrawCache()}},t.prototype._resyncLightSources=function(){this._lightSources.length=0;for(var e=0,n=this.getScene().lights;e<n.length;e++){var i=n[e];i.isEnabled()&&i.canAffectMesh(this)&&this._lightSources.push(i)}this._markSubMeshesAsLightDirty()},t.prototype._resyncLightSource=function(e){var n=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e),o=!1;if(i===-1){if(!n)return;this._lightSources.push(e)}else{if(n)return;o=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(o)},t.prototype._unBindEffect=function(){for(var e=0,n=this.subMeshes;e<n.length;e++)n[e].setEffect(null)},t.prototype._removeLightSource=function(e,n){var i=this._lightSources.indexOf(e);i!==-1&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(n))},t.prototype._markSubMeshesAsDirty=function(e){if(this.subMeshes)for(var n=0,i=this.subMeshes;n<i.length;n++)for(var o=i[n],a=0;a<o._drawWrappers.length;++a){var s=o._drawWrappers[a];s&&s.defines&&s.defines.markAllAsDirty&&e(s.defines)}},t.prototype._markSubMeshesAsLightDirty=function(e){e===void 0&&(e=!1),this._markSubMeshesAsDirty(function(n){return n.markAsLightDirty(e)})},t.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty(function(e){return e.markAsAttributesDirty()})},t.prototype._markSubMeshesAsMiscDirty=function(){this._markSubMeshesAsDirty(function(e){return e.markAsMiscDirty()})},t.prototype.markAsDirty=function(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},t.prototype.resetDrawCache=function(e){if(this.subMeshes)for(var n=0,i=this.subMeshes;n<i.length;n++)i[n].resetDrawCache(e)},Object.defineProperty(t.prototype,"isBlocked",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.getLOD=function(e){return this},t.prototype.getTotalVertices=function(){return 0},t.prototype.getTotalIndices=function(){return 0},t.prototype.getIndices=function(){return null},t.prototype.getVerticesData=function(e){return null},t.prototype.setVerticesData=function(e,n,i,o){return this},t.prototype.updateVerticesData=function(e,n,i,o){return this},t.prototype.setIndices=function(e,n){return this},t.prototype.isVerticesDataPresent=function(e){return!1},t.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfoIsDirty&&(this._boundingInfoIsDirty=!1,this._updateBoundingInfo()),this._boundingInfo)},t.prototype.getRawBoundingInfo=function(){var e;return(e=this.rawBoundingInfo)!==null&&e!==void 0?e:this.getBoundingInfo()},t.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},Object.defineProperty(t.prototype,"hasBoundingInfo",{get:function(){return this._boundingInfo!==null},enumerable:!1,configurable:!0}),t.prototype.buildBoundingInfo=function(e,n,i){return this._boundingInfo=new tr(e,n,i),this._boundingInfo},t.prototype.normalizeToUnitCube=function(e,n,i){return e===void 0&&(e=!0),n===void 0&&(n=!1),r.prototype.normalizeToUnitCube.call(this,e,n,i)},Object.defineProperty(t.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(Y.R.MatricesIndicesKind)&&this.isVerticesDataPresent(Y.R.MatricesWeightsKind)},enumerable:!1,configurable:!0}),t.prototype._preActivate=function(){},t.prototype._preActivateForIntermediateRendering=function(e){},t.prototype._activate=function(e,n){return this._renderId=e,!0},t.prototype._postActivate=function(){},t.prototype._freeze=function(){},t.prototype._unFreeze=function(){},t.prototype.getWorldMatrix=function(){return this._masterMesh&&this.billboardMode===jt.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():r.prototype.getWorldMatrix.call(this)},t.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():r.prototype._getWorldMatrixDeterminant.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasThinInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.movePOV=function(e,n,i){return this.position.addInPlace(this.calcMovePOV(e,n,i)),this},t.prototype.calcMovePOV=function(e,n,i){var o=new _.uq;(this.rotationQuaternion?this.rotationQuaternion:_.PT.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(o);var a=_.Pq.Zero(),s=this.definedFacingForward?-1:1;return _.Pq.TransformCoordinatesFromFloatsToRef(e*s,n,i*s,o,a),a},t.prototype.rotatePOV=function(e,n,i){return this.rotation.addInPlace(this.calcRotatePOV(e,n,i)),this},t.prototype.calcRotatePOV=function(e,n,i){var o=this.definedFacingForward?1:-1;return new _.Pq(e*o,n,i*o)},t.prototype._refreshBoundingInfo=function(e,n){if(e){var i=(0,no.b)(e,0,this.getTotalVertices(),n);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new tr(i.minimum,i.maximum)}if(this.subMeshes)for(var o=0;o<this.subMeshes.length;o++)this.subMeshes[o].refreshBoundingInfo(e);this._updateBoundingInfo()},t.prototype._refreshBoundingInfoDirect=function(e){if(this._boundingInfo?this._boundingInfo.reConstruct(e.minimum,e.maximum):this._boundingInfo=new tr(e.minimum,e.maximum),this.subMeshes)for(var n=0;n<this.subMeshes.length;n++)this.subMeshes[n].refreshBoundingInfo(null);this._updateBoundingInfo()},t._ApplySkeleton=function(e,n,i,o,a,s,l){(function(c,u,d,h,p,m,v){for(var b=_.AA.Vector3[0],E=_.AA.Matrix[0],C=_.AA.Matrix[1],T=u===Y.R.NormalKind?_.Pq.TransformNormalFromFloatsToRef:_.Pq.TransformCoordinatesFromFloatsToRef,f=0,g=0;f<c.length;f+=3,g+=4){E.reset();var S=void 0,y=void 0;for(S=0;S<4;S++)(y=p[g+S])>0&&(_.uq.FromFloat32ArrayToRefScaled(d,Math.floor(16*h[g+S]),y,C),E.addToSelf(C));if(m&&v)for(S=0;S<4;S++)(y=v[g+S])>0&&(_.uq.FromFloat32ArrayToRefScaled(d,Math.floor(16*m[g+S]),y,C),E.addToSelf(C));T(c[f],c[f+1],c[f+2],E,b),b.toArray(c,f)}})(e,n,i,o,a,s,l)},t.prototype._getData=function(e,n,i){var o=this;i===void 0&&(i=Y.R.PositionKind);var a=e.cache,s=function(C){if(a){var T=a._vertexData||(a._vertexData={});return T[C]||o.copyVerticesData(C,T),T[C]}return o.getVerticesData(C)};if(n||(n=s(i)),!n)return null;if(a?(a._outputData?a._outputData.set(n):a._outputData=new Float32Array(n),n=a._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(n=n.slice()),e.applyMorph&&this.morphTargetManager&&function(C,T,f){var g=null;switch(T){case Y.R.PositionKind:g=function(D){return D.getPositions()};break;case Y.R.NormalKind:g=function(D){return D.getNormals()};break;case Y.R.TangentKind:g=function(D){return D.getTangents()};break;case Y.R.UVKind:g=function(D){return D.getUVs()};break;default:return}for(var S=0;S<C.length;S++){for(var y=C[S],x=0;x<f.numTargets;x++){var R=f.getTarget(x),I=R.influence;if(I!==0){var M=g(R);M&&(y+=(M[S]-C[S])*I)}}C[S]=y}}(n,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){var l=s(Y.R.MatricesIndicesKind),c=s(Y.R.MatricesWeightsKind);if(c&&l){var u=this.numBoneInfluencers>4,d=u?s(Y.R.MatricesIndicesExtraKind):null,h=u?s(Y.R.MatricesWeightsExtraKind):null,p=this.skeleton.getTransformMatrices(this);t._ApplySkeleton(n,i,p,l,c,d,h)}}if(e.updatePositionsArray!==!1&&i===Y.R.PositionKind){var m=this._internalAbstractMeshDataInfo._positions||[],v=m.length;if(m.length=n.length/3,v<m.length)for(var b=v;b<m.length;b++)m[b]=new _.Pq;b=0;for(var E=0;b<m.length;b++,E+=3)m[b].copyFromFloats(n[E],n[E+1],n[E+2]);this._internalAbstractMeshDataInfo._positions=m}return n},t.prototype.getNormalsData=function(e,n){return e===void 0&&(e=!1),n===void 0&&(n=!1),this._getData({applySkeleton:e,applyMorph:n,updatePositionsArray:!1},null,Y.R.NormalKind)},t.prototype.getPositionData=function(e,n,i){return e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=null),this._getData({applySkeleton:e,applyMorph:n,updatePositionsArray:!1},i,Y.R.PositionKind)},t.prototype._updateBoundingInfo=function(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new tr(_.Pq.Zero(),_.Pq.Zero(),this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this},t.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var n=this.subMeshes.length,i=0;i<n;i++){var o=this.subMeshes[i];(n>1||!o.IsGlobal)&&o.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)},t.prototype.isInFrustum=function(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return this.getBoundingInfo().isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,n,i){n===void 0&&(n=!1);var o=this.getBoundingInfo(),a=e.getBoundingInfo();if(o.intersects(a,n))return!0;if(i){for(var s=0,l=this.getChildMeshes();s<l.length;s++)if(l[s].intersectsMesh(e,n,!0))return!0}return!1},t.prototype.intersectsPoint=function(e){return this.getBoundingInfo().intersectsPoint(e)},Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collider",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider},enumerable:!1,configurable:!0}),t.prototype.moveWithCollisions=function(e){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);var n=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=n.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,n.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId),this},t.prototype._collideForSubMesh=function(e,n,i){var o;if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(n)){e._lastColliderTransformMatrix=n.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];for(var a=e.verticesStart,s=e.verticesStart+e.verticesCount,l=a;l<s;l++)e._lastColliderWorldVertices.push(_.Pq.TransformCoordinates(this._positions[l],n))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial(),this,this._shouldConvertRHS(),((o=e.getMaterial())===null||o===void 0?void 0:o.fillMode)===P.Y.MATERIAL_TriangleStripDrawMode),this},t.prototype._processCollisionsForSubMeshes=function(e,n){for(var i=this._scene.getCollidingSubMeshCandidates(this,e),o=i.length,a=0;a<o;a++){var s=i.data[a];o>1&&!s._checkCollision(e)||this._collideForSubMesh(s,n,e)}return this},t.prototype._shouldConvertRHS=function(){return!1},t.prototype._checkCollision=function(e){if(!this.getBoundingInfo()._checkCollision(e))return this;var n=_.AA.Matrix[0],i=_.AA.Matrix[1];return _.uq.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,n),this.worldMatrixFromCache.multiplyToRef(n,i),this._processCollisionsForSubMeshes(e,i),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,n,i,o,a,s){o===void 0&&(o=!1),s===void 0&&(s=!1);var l=new ri.G,c=this.getClassName(),u=c==="InstancedLinesMesh"||c==="LinesMesh"||c==="GreasedLineMesh"?this.intersectionThreshold:0,d=this.getBoundingInfo();if(!this.subMeshes||!(s||e.intersectsSphere(d.boundingSphere,u)&&e.intersectsBox(d.boundingBox,u)))return l;if(o)return l.hit=!s,l.pickedMesh=s?null:this,l.distance=s?0:_.Pq.Distance(e.origin,d.boundingSphere.center),l.subMeshId=0,l;if(!this._generatePointsArray())return l;for(var h=null,p=this._scene.getIntersectingSubMeshCandidates(this,e),m=p.length,v=!1,b=0;b<m;b++){var E=(C=p.data[b]).getMaterial();if(E&&(E.fillMode==P.Y.MATERIAL_TriangleStripDrawMode||E.fillMode==P.Y.MATERIAL_TriangleFillMode||E.fillMode==P.Y.MATERIAL_WireFrameFillMode||E.fillMode==P.Y.MATERIAL_PointFillMode||E.fillMode==P.Y.MATERIAL_LineListDrawMode)){v=!0;break}}if(!v)return l.hit=!0,l.pickedMesh=this,l.distance=_.Pq.Distance(e.origin,d.boundingSphere.center),l.subMeshId=-1,l;for(b=0;b<m;b++){var C=p.data[b];if(!(m>1)||s||C.canIntersects(e)){var T=C.intersects(e,this._positions,this.getIndices(),n,i);if(T&&(n||!h||T.distance<h.distance)&&((h=T).subMeshId=b,n))break}}if(h){var f=a??this.getWorldMatrix(),g=_.AA.Vector3[0],S=_.AA.Vector3[1];_.Pq.TransformCoordinatesToRef(e.origin,f,g),e.direction.scaleToRef(h.distance,S);var y=_.Pq.TransformNormal(S,f).addInPlace(g);return l.hit=!0,l.distance=_.Pq.Distance(g,y),l.pickedPoint=y,l.pickedMesh=this,l.bu=h.bu||0,l.bv=h.bv||0,l.subMeshFaceId=h.faceId,l.faceId=h.faceId+p.data[h.subMeshId].indexStart/(this.getClassName().indexOf("LinesMesh")!==-1?2:3),l.subMeshId=h.subMeshId,l}return l},t.prototype.clone=function(e,n,i){return null},t.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=[];return this},t.prototype.dispose=function(e,n){var i,o=this;n===void 0&&(n=!1);var a=this.getScene();for(this._scene.useMaterialMeshMap&&this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),a.freeActiveMeshes(),a.freeRenderingGroups(),a.renderingManager.maintainStateBetweenFrames&&a.renderingManager.restoreDispachedFlags(),this.actionManager!==void 0&&this.actionManager!==null&&(this.actionManager.disposeWhenUnowned&&!this._scene.meshes.some(function(d){return d!==o&&d.actionManager===o.actionManager})&&this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),i=0;i<this._intersectionsInProgress.length;i++){var s=this._intersectionsInProgress[i],l=s._intersectionsInProgress.indexOf(this);s._intersectionsInProgress.splice(l,1)}this._intersectionsInProgress.length=0,a.lights.forEach(function(d){var h=d.includedOnlyMeshes.indexOf(o);h!==-1&&d.includedOnlyMeshes.splice(h,1),(h=d.excludedMeshes.indexOf(o))!==-1&&d.excludedMeshes.splice(h,1);var p=d.getShadowGenerators();if(p)for(var m=p.values(),v=m.next();v.done!==!0;v=m.next()){var b=v.value.getShadowMap();b&&b.renderList&&(h=b.renderList.indexOf(o))!==-1&&b.renderList.splice(h,1)}}),this.getClassName()==="InstancedMesh"&&this.getClassName()==="InstancedLinesMesh"||this.releaseSubMeshes();var c=a.getEngine();if(this._occlusionQuery!==null&&(this.isOcclusionQueryInProgress=!1,c.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),c.wipeCaches(),a.removeMesh(this),this._parentContainer){var u=this._parentContainer.meshes.indexOf(this);u>-1&&this._parentContainer.meshes.splice(u,1),this._parentContainer=null}if(n&&this.material&&(this.material.getClassName()==="MultiMaterial"?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!e)for(i=0;i<a.particleSystems.length;i++)a.particleSystems[i].emitter===this&&(a.particleSystems[i].dispose(),i--);this._internalAbstractMeshDataInfo._facetData.facetDataEnabled&&this.disableFacetData(),this._uniformBuffer.dispose(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),r.prototype.dispose.call(this,e,n)},t.prototype._initFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;e.facetNormals||(e.facetNormals=[]),e.facetPositions||(e.facetPositions=[]),e.facetPartitioning||(e.facetPartitioning=new Array),e.facetNb=this.getIndices().length/3|0,e.partitioningSubdivisions=e.partitioningSubdivisions?e.partitioningSubdivisions:10,e.partitioningBBoxRatio=e.partitioningBBoxRatio?e.partitioningBBoxRatio:1.01;for(var n=0;n<e.facetNb;n++)e.facetNormals[n]=_.Pq.Zero(),e.facetPositions[n]=_.Pq.Zero();return e.facetDataEnabled=!0,this},t.prototype.updateFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;e.facetDataEnabled||this._initFacetData();var n=this.getVerticesData(Y.R.PositionKind),i=this.getIndices(),o=this.getVerticesData(Y.R.NormalKind),a=this.getBoundingInfo();if(e.facetDepthSort&&!e.facetDepthSortEnabled){if(e.facetDepthSortEnabled=!0,i instanceof Uint16Array)e.depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)e.depthSortedIndices=new Uint32Array(i);else{for(var s=!1,l=0;l<i.length;l++)if(i[l]>65535){s=!0;break}e.depthSortedIndices=s?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(v,b){return b.sqDistance-v.sqDistance},!e.facetDepthSortFrom){var c=this.getScene().activeCamera;e.facetDepthSortFrom=c?c.position:_.Pq.Zero()}e.depthSortedFacets=[];for(var u=0;u<e.facetNb;u++){var d={ind:3*u,sqDistance:0};e.depthSortedFacets.push(d)}e.invertedMatrix=_.uq.Identity(),e.facetDepthSortOrigin=_.Pq.Zero()}e.bbSize.x=a.maximum.x-a.minimum.x>pt.bH?a.maximum.x-a.minimum.x:pt.bH,e.bbSize.y=a.maximum.y-a.minimum.y>pt.bH?a.maximum.y-a.minimum.y:pt.bH,e.bbSize.z=a.maximum.z-a.minimum.z>pt.bH?a.maximum.z-a.minimum.z:pt.bH;var h=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(h=h>e.bbSize.z?h:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/h),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/h),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/h),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=a,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),_.Pq.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,o&&rt.ComputeNormals(n,i,o,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var p=e.depthSortedIndices.length/3|0;for(u=0;u<p;u++){var m=e.depthSortedFacets[u].ind;e.depthSortedIndices[3*u]=i[m],e.depthSortedIndices[3*u+1]=i[m+1],e.depthSortedIndices[3*u+2]=i[m+2]}this.updateIndices(e.depthSortedIndices,void 0,!0)}return this},t.prototype.getFacetLocalNormals=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetNormals||this.updateFacetData(),e.facetNormals},t.prototype.getFacetLocalPositions=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetPositions||this.updateFacetData(),e.facetPositions},t.prototype.getFacetLocalPartitioning=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetPartitioning||this.updateFacetData(),e.facetPartitioning},t.prototype.getFacetPosition=function(e){var n=_.Pq.Zero();return this.getFacetPositionToRef(e,n),n},t.prototype.getFacetPositionToRef=function(e,n){var i=this.getFacetLocalPositions()[e],o=this.getWorldMatrix();return _.Pq.TransformCoordinatesToRef(i,o,n),this},t.prototype.getFacetNormal=function(e){var n=_.Pq.Zero();return this.getFacetNormalToRef(e,n),n},t.prototype.getFacetNormalToRef=function(e,n){var i=this.getFacetLocalNormals()[e];return _.Pq.TransformNormalToRef(i,this.getWorldMatrix(),n),this},t.prototype.getFacetsAtLocalCoordinates=function(e,n,i){var o=this.getBoundingInfo(),a=this._internalAbstractMeshDataInfo._facetData,s=Math.floor((e-o.minimum.x*a.partitioningBBoxRatio)*a.subDiv.X*a.partitioningBBoxRatio/a.bbSize.x),l=Math.floor((n-o.minimum.y*a.partitioningBBoxRatio)*a.subDiv.Y*a.partitioningBBoxRatio/a.bbSize.y),c=Math.floor((i-o.minimum.z*a.partitioningBBoxRatio)*a.subDiv.Z*a.partitioningBBoxRatio/a.bbSize.z);return s<0||s>a.subDiv.max||l<0||l>a.subDiv.max||c<0||c>a.subDiv.max?null:a.facetPartitioning[s+a.subDiv.max*l+a.subDiv.max*a.subDiv.max*c]},t.prototype.getClosestFacetAtCoordinates=function(e,n,i,o,a,s){a===void 0&&(a=!1),s===void 0&&(s=!0);var l=this.getWorldMatrix(),c=_.AA.Matrix[5];l.invertToRef(c);var u=_.AA.Vector3[8];_.Pq.TransformCoordinatesFromFloatsToRef(e,n,i,c,u);var d=this.getClosestFacetAtLocalCoordinates(u.x,u.y,u.z,o,a,s);return o&&_.Pq.TransformCoordinatesFromFloatsToRef(o.x,o.y,o.z,l,o),d},t.prototype.getClosestFacetAtLocalCoordinates=function(e,n,i,o,a,s){a===void 0&&(a=!1),s===void 0&&(s=!0);var l=null,c=0,u=0,d=0,h=0,p=0,m=0,v=0,b=0,E=this.getFacetLocalPositions(),C=this.getFacetLocalNormals(),T=this.getFacetsAtLocalCoordinates(e,n,i);if(!T)return null;for(var f,g,S,y=Number.MAX_VALUE,x=y,R=0;R<T.length;R++)g=C[f=T[R]],h=(e-(S=E[f]).x)*g.x+(n-S.y)*g.y+(i-S.z)*g.z,(!a||a&&s&&h>=0||a&&!s&&h<=0)&&(h=g.x*S.x+g.y*S.y+g.z*S.z,p=-(g.x*e+g.y*n+g.z*i-h)/(g.x*g.x+g.y*g.y+g.z*g.z),(x=(c=(m=e+g.x*p)-e)*c+(u=(v=n+g.y*p)-n)*u+(d=(b=i+g.z*p)-i)*d)<y&&(y=x,l=f,o&&(o.x=m,o.y=v,o.z=b)));return l},t.prototype.getFacetDataParameters=function(){return this._internalAbstractMeshDataInfo._facetData.facetParameters},t.prototype.disableFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetDataEnabled&&(e.facetDataEnabled=!1,e.facetPositions=[],e.facetNormals=[],e.facetPartitioning=new Array,e.facetParameters=null,e.depthSortedIndices=new Uint32Array(0)),this},t.prototype.updateIndices=function(e,n,i){return this},t.prototype.createNormals=function(e){var n,i=this.getVerticesData(Y.R.PositionKind),o=this.getIndices();return n=this.isVerticesDataPresent(Y.R.NormalKind)?this.getVerticesData(Y.R.NormalKind):[],rt.ComputeNormals(i,o,n,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(Y.R.NormalKind,n,e),this},t.prototype.alignWithNormal=function(e,n){n||(n=Qn._0.Y);var i=_.AA.Vector3[0],o=_.AA.Vector3[1];return _.Pq.CrossToRef(n,e,o),_.Pq.CrossToRef(e,o,i),this.rotationQuaternion?_.PT.RotationQuaternionFromAxisToRef(i,e,o,this.rotationQuaternion):_.Pq.RotationFromAxisToRef(i,e,o,this.rotation),this},t.prototype._checkOcclusionQuery=function(){return!1},t.prototype.disableEdgesRendering=function(){throw(0,gt.n)("EdgesRenderer")},t.prototype.enableEdgesRendering=function(e,n,i){throw(0,gt.n)("EdgesRenderer")},t.prototype.getConnectedParticleSystems=function(){var e=this;return this._scene.particleSystems.filter(function(n){return n.emitter===e})},t.OCCLUSION_TYPE_NONE=0,t.OCCLUSION_TYPE_OPTIMISTIC=1,t.OCCLUSION_TYPE_STRICT=2,t.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,t.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,t.CULLINGSTRATEGY_STANDARD=P.Y.MESHES_CULLINGSTRATEGY_STANDARD,t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=P.Y.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=P.Y.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION,t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=P.Y.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY,(0,A.Cg)([V.Cx.filter(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=e[0],o=e[1],a=e[2],s=e[3],l=e[4];return!(Array.isArray(i)||Array.isArray(o)||Array.isArray(a)||Array.isArray(s)||Array.isArray(l))})],t,"_ApplySkeleton",null),t}(jt);(0,j.Y5)("BABYLON.AbstractMesh",cn);var Qo=L(43939),j1=function(){function r(){this.reset()}return r.prototype.reset=function(){this.enabled=!1,this.mask=255,this.func=P.Y.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=P.Y.KEEP,this.opDepthFail=P.Y.KEEP,this.opStencilDepthPass=P.Y.REPLACE},Object.defineProperty(r.prototype,"func",{get:function(){return this._func},set:function(t){this._func=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"funcRef",{get:function(){return this._funcRef},set:function(t){this._funcRef=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"funcMask",{get:function(){return this._funcMask},set:function(t){this._funcMask=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"opStencilFail",{get:function(){return this._opStencilFail},set:function(t){this._opStencilFail=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"opDepthFail",{get:function(){return this._opDepthFail},set:function(t){this._opDepthFail=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"opStencilDepthPass",{get:function(){return this._opStencilDepthPass},set:function(t){this._opStencilDepthPass=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mask",{get:function(){return this._mask},set:function(t){this._mask=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this._enabled=t},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"MaterialStencilState"},r.prototype.copyTo=function(t){tt.p.Clone(function(){return t},this)},r.prototype.serialize=function(){return tt.p.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;tt.p.Parse(function(){return i},t,e,n)},(0,A.Cg)([(0,V.lK)()],r.prototype,"func",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"funcRef",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"funcMask",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"opStencilFail",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"opDepthFail",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"opStencilDepthPass",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"mask",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"enabled",null),r}(),Re=L(85096),Lt=function(){function r(t,e,n){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new K.cP,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=P.Y.ALPHA_COMBINE,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this.zOffsetUnits=0,this.stencil=new j1,this._useUBO=!1,this._fillMode=r.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=function(){},this._callbackPluginEventIsReadyForSubMesh=function(){},this._callbackPluginEventPrepareDefines=function(){},this._callbackPluginEventPrepareDefinesBeforeAttributes=function(){},this._callbackPluginEventHardBindForSubMesh=function(){},this._callbackPluginEventBindForSubMesh=function(){},this._callbackPluginEventHasRenderTargetTextures=function(){},this._callbackPluginEventFillRenderTargetTextures=function(){},this._forceAlphaTest=!1,this._transparencyMode=null,this.name=t;var i=e||Ve.q.LastCreatedScene;i&&(this._scene=i,this._dirtyCallbacks={},this._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[P.Y.MATERIAL_LightDirtyFlag]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[P.Y.MATERIAL_FresnelDirtyFlag]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[P.Y.MATERIAL_AttributesDirtyFlag]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[P.Y.MATERIAL_MiscDirtyFlag]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[P.Y.MATERIAL_PrePassDirtyFlag]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[P.Y.MATERIAL_AllDirtyFlag]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=t||ze.S0.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new jn.E(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new Ui.D(this._scene.getEngine(),void 0,void 0,t),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,n||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),r.OnEventObservable.notifyObservers(this,1))}return Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"canRenderToMRT",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"alpha",{get:function(){return this._alpha},set:function(t){if(this._alpha!==t){var e=this._alpha;this._alpha=t,e!==1&&t!==1||this.markAsDirty(r.MiscDirtyFlag+r.PrePassDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(t){this._backFaceCulling!==t&&(this._backFaceCulling=t,this.markAsDirty(r.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cullBackFaces",{get:function(){return this._cullBackFaces},set:function(t){this._cullBackFaces!==t&&(this._cullBackFaces=t,this.markAsDirty(r.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blockDirtyMechanism",{get:function(){return this._blockDirtyMechanism},set:function(t){this._blockDirtyMechanism!==t&&(this._blockDirtyMechanism=t,t||this.markDirty())},enumerable:!1,configurable:!0}),r.prototype.atomicMaterialsUpdate=function(t){this.blockDirtyMechanism=!0;try{t(this)}finally{this.blockDirtyMechanism=!1}},Object.defineProperty(r.prototype,"hasRenderTargetTextures",{get:function(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onDispose",{set:function(t){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new K.cP),this._onBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onBind",{set:function(t){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new K.cP),this._onUnBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onEffectCreatedObservable",{get:function(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new K.cP),this._onEffectCreatedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(t){this._alphaMode!==t&&(this._alphaMode=t,this.markAsDirty(r.TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(t){this._needDepthPrePass!==t&&(this._needDepthPrePass=t,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isPrePassCapable",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAsDirty(r.MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"wireframe",{get:function(){switch(this._fillMode){case r.WireFrameFillMode:case r.LineListDrawMode:case r.LineLoopDrawMode:case r.LineStripDrawMode:return!0}return this._scene.forceWireframe},set:function(t){this.fillMode=t?r.WireFrameFillMode:r.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pointsCloud",{get:function(){switch(this._fillMode){case r.PointFillMode:case r.PointListDrawMode:return!0}return this._scene.forcePointsCloud},set:function(t){this.fillMode=t?r.PointFillMode:r.TriangleFillMode},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fillMode",{get:function(){return this._fillMode},set:function(t){this._fillMode!==t&&(this._fillMode=t,this.markAsDirty(r.MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(t){var e=this.getScene().getEngine().getCaps().fragmentDepthSupported;t&&!e&&O.V.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=t&&e,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),r.prototype._getDrawWrapper=function(){return this._drawWrapper},r.prototype._setDrawWrapper=function(t){this._drawWrapper=t},r.prototype.toString=function(t){return"Name: "+this.name},r.prototype.getClassName=function(){return"Material"},Object.defineProperty(r.prototype,"_isMaterial",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!1,configurable:!0}),r.prototype.freeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!0},r.prototype.unfreeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!1},r.prototype.isReady=function(t,e){return!0},r.prototype.isReadyForSubMesh=function(t,e,n){var i=e.materialDefines;return!!i&&(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=i,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh)},r.prototype.getEffect=function(){return this._drawWrapper.effect},r.prototype.getScene=function(){return this._scene},r.prototype._getEffectiveOrientation=function(t){return this.sideOrientation!==null?this.sideOrientation:t.sideOrientation},Object.defineProperty(r.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,this._forceAlphaTest=t===r.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_disableAlphaBlending",{get:function(){return this._transparencyMode===r.MATERIAL_OPAQUE||this._transparencyMode===r.MATERIAL_ALPHATEST},enumerable:!1,configurable:!0}),r.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&this.alpha<1},r.prototype.needAlphaBlendingForMesh=function(t){return t.visibility<1||!this._disableAlphaBlending&&(t.hasVertexAlpha||this.needAlphaBlending())},r.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest},r.prototype._shouldTurnAlphaTestOn=function(t){return!this.needAlphaBlendingForMesh(t)&&this.needAlphaTesting()},r.prototype.getAlphaTestTexture=function(){return null},r.prototype.markDirty=function(t){t===void 0&&(t=!1);for(var e=0,n=this.getScene().meshes;e<n.length;e++){var i=n[e];if(i.subMeshes)for(var o=0,a=i.subMeshes;o<a.length;o++){var s=a[o];if(s.getMaterial()===this)for(var l=0,c=s._drawWrappers;l<c.length;l++){var u=c[l];u&&this._materialContext===u.materialContext&&(u._wasPreviouslyReady=!1,u._wasPreviouslyUsingInstances=null,u._forceRebindOnNextCall=t)}}}t&&this.markAsDirty(r.AllDirtyFlag)},r.prototype._preBind=function(t,e){e===void 0&&(e=null);var n=this._scene.getEngine(),i=(e??this.sideOrientation)===r.ClockWiseSideOrientation;return n.enableEffect(t||this._getDrawWrapper()),n.setState(this.backFaceCulling,this.zOffset,!1,i,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),i},r.prototype.bind=function(t,e){},r.prototype.buildUniformLayout=function(){var t=this._uniformBuffer;this._eventInfo.ubo=t,this._callbackPluginEventGeneric(8,this._eventInfo),t.create(),this._uniformBufferLayoutBuilt=!0},r.prototype.bindForSubMesh=function(t,e,n){var i=n._drawWrapper;this._eventInfo.subMesh=n,this._callbackPluginEventBindForSubMesh(this._eventInfo),i._forceRebindOnNextCall=!1},r.prototype.bindOnlyWorldMatrix=function(t){},r.prototype.bindView=function(t){this._useUBO?this._needToBindSceneUbo=!0:t.setMatrix("view",this.getScene().getViewMatrix())},r.prototype.bindViewProjection=function(t){this._useUBO?this._needToBindSceneUbo=!0:(t.setMatrix("viewProjection",this.getScene().getTransformMatrix()),t.setMatrix("projection",this.getScene().getProjectionMatrix()))},r.prototype.bindEyePosition=function(t,e){this._useUBO?this._needToBindSceneUbo=!0:this._scene.bindEyePosition(t,e)},r.prototype._afterBind=function(t,e,n){if(e===void 0&&(e=null),this._scene._cachedMaterial=this,this._needToBindSceneUbo&&e&&(this._needToBindSceneUbo=!1,(0,Re._8)(e,this.getScene().getSceneUniformBuffer()),this._scene.finalizeSceneUbo()),this._scene._cachedVisibility=t?t.visibility:1,this._onBindObservable&&t&&this._onBindObservable.notifyObservers(t),this.disableDepthWrite){var i=this._scene.getEngine();this._cachedDepthWriteState=i.getDepthWrite(),i.setDepthWrite(!1)}this.disableColorWrite&&(i=this._scene.getEngine(),this._cachedColorWriteState=i.getColorWrite(),i.setColorWrite(!1)),this.depthFunction!==0&&(i=this._scene.getEngine(),this._cachedDepthFunctionState=i.getDepthFunction()||0,i.setDepthFunction(this.depthFunction))},r.prototype.unbind=function(){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)},r.prototype.getAnimatables=function(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables},r.prototype.getActiveTextures=function(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures},r.prototype.hasTexture=function(t){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=t,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture},r.prototype.clone=function(t){return null},r.prototype._clonePlugins=function(t,e){var n={};if(this._serializePlugins(n),r._ParsePlugins(n,t,this._scene,e),this.pluginManager)for(var i=0,o=this.pluginManager._plugins;i<o.length;i++){var a=o[i],s=t.pluginManager.getPlugin(a.name);s&&a.copyTo(s)}},r.prototype.getBindedMeshes=function(){var t=this;if(this.meshMap){var e=[];for(var n in this.meshMap){var i=this.meshMap[n];i&&e.push(i)}return e}return this._scene.meshes.filter(function(o){return o.material===t})},r.prototype.forceCompilation=function(t,e,n,i){var o=this,a=(0,A.Cl)({clipPlane:!1,useInstances:!1},n),s=this.getScene(),l=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;var c=function(){if(o._scene&&o._scene.getEngine()){var u=s.clipPlane;if(a.clipPlane&&(s.clipPlane=new Qo.Z(0,0,0,1)),o._storeEffectOnSubMeshes){var d=!0,h=null;if(t.subMeshes){var p=new yi(0,0,0,0,0,t,void 0,!1,!1);p.materialDefines&&(p.materialDefines._renderId=-1),o.isReadyForSubMesh(t,p,a.useInstances)||(p.effect&&p.effect.getCompilationError()&&p.effect.allFallbacksProcessed()?h=p.effect.getCompilationError():(d=!1,setTimeout(c,16)))}d&&(o.allowShaderHotSwapping=l,h&&i&&i(h),e&&e(o))}else o.isReady()?(o.allowShaderHotSwapping=l,e&&e(o)):setTimeout(c,16);a.clipPlane&&(s.clipPlane=u)}};c()},r.prototype.forceCompilationAsync=function(t,e){var n=this;return new Promise(function(i,o){n.forceCompilation(t,function(){i()},e,function(a){o(a)})})},r.prototype.markAsDirty=function(t){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(r._DirtyCallbackArray.length=0,t&r.TextureDirtyFlag&&r._DirtyCallbackArray.push(r._TextureDirtyCallBack),t&r.LightDirtyFlag&&r._DirtyCallbackArray.push(r._LightsDirtyCallBack),t&r.FresnelDirtyFlag&&r._DirtyCallbackArray.push(r._FresnelDirtyCallBack),t&r.AttributesDirtyFlag&&r._DirtyCallbackArray.push(r._AttributeDirtyCallBack),t&r.MiscDirtyFlag&&r._DirtyCallbackArray.push(r._MiscDirtyCallBack),t&r.PrePassDirtyFlag&&r._DirtyCallbackArray.push(r._PrePassDirtyCallBack),r._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(r._RunDirtyCallBacks),this.getScene().resetCachedMaterial())},r.prototype.resetDrawCache=function(){for(var t=0,e=this.getScene().meshes;t<e.length;t++){var n=e[t];if(n.subMeshes)for(var i=0,o=n.subMeshes;i<o.length;i++){var a=o[i];a.getMaterial()===this&&a.resetDrawCache()}}},r.prototype._markAllSubMeshesAsDirty=function(t){if(!this.getScene().blockMaterialDirtyMechanism&&!this._blockDirtyMechanism)for(var e=0,n=this.getScene().meshes;e<n.length;e++){var i=n[e];if(i.subMeshes)for(var o=0,a=i.subMeshes;o<a.length;o++){var s=a[o];if(s.getMaterial(!1)===this)for(var l=0,c=s._drawWrappers;l<c.length;l++){var u=c[l];u&&u.defines&&u.defines.markAllAsDirty&&this._materialContext===u.materialContext&&t(u.defines)}}}},r.prototype._markScenePrePassDirty=function(){if(!this.getScene().blockMaterialDirtyMechanism&&!this._blockDirtyMechanism){var t=this.getScene().enablePrePassRenderer();t&&t.markAsDirty()}},r.prototype._markAllSubMeshesAsAllDirty=function(){this._markAllSubMeshesAsDirty(r._AllDirtyCallBack)},r.prototype._markAllSubMeshesAsImageProcessingDirty=function(){this._markAllSubMeshesAsDirty(r._ImageProcessingDirtyCallBack)},r.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty(r._TextureDirtyCallBack)},r.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty(r._FresnelDirtyCallBack)},r.prototype._markAllSubMeshesAsFresnelAndMiscDirty=function(){this._markAllSubMeshesAsDirty(r._FresnelAndMiscDirtyCallBack)},r.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty(r._LightsDirtyCallBack)},r.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty(r._AttributeDirtyCallBack)},r.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty(r._MiscDirtyCallBack)},r.prototype._markAllSubMeshesAsPrePassDirty=function(){this._markAllSubMeshesAsDirty(r._MiscDirtyCallBack)},r.prototype._markAllSubMeshesAsTexturesAndMiscDirty=function(){this._markAllSubMeshesAsDirty(r._TextureAndMiscDirtyCallBack)},r.prototype._checkScenePerformancePriority=function(){var t=this;if(this._scene.performancePriority!==0){this.checkReadyOnlyOnce=!0;var e=this._scene.onScenePerformancePriorityChangedObservable.addOnce(function(){t.checkReadyOnlyOnce=!1});this.onDisposeObservable.add(function(){t._scene.onScenePerformancePriorityChangedObservable.remove(e)})}},r.prototype.setPrePassRenderer=function(t){return!1},r.prototype.dispose=function(t,e,n){var i=this.getScene();if(i.stopAnimation(this),i.freeProcessedMaterials(),i.removeMaterial(this),this._eventInfo.forceDisposeTextures=e,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){var o=this._parentContainer.materials.indexOf(this);o>-1&&this._parentContainer.materials.splice(o,1),this._parentContainer=null}if(n!==!0)if(this.meshMap)for(var a in this.meshMap)(c=this.meshMap[a])&&(c.material=null,this.releaseVertexArrayObject(c,t));else for(var s=0,l=i.meshes;s<l.length;s++){var c;(c=l[s]).material!==this||c.sourceMesh||(c.material=null,this.releaseVertexArrayObject(c,t))}this._uniformBuffer.dispose(),t&&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={})},r.prototype.releaseVertexArrayObject=function(t,e){var n=t.geometry;if(n)if(this._storeEffectOnSubMeshes){if(t.subMeshes)for(var i=0,o=t.subMeshes;i<o.length;i++){var a=o[i];n._releaseVertexArrayObject(a.effect),e&&a.effect&&a.effect.dispose()}}else n._releaseVertexArrayObject(this._drawWrapper.effect)},r.prototype.serialize=function(){var t=tt.p.Serialize(this);return t.stencil=this.stencil.serialize(),t.uniqueId=this.uniqueId,this._serializePlugins(t),t},r.prototype._serializePlugins=function(t){if(t.plugins={},this.pluginManager)for(var e=0,n=this.pluginManager._plugins;e<n.length;e++){var i=n[e];t.plugins[i.getClassName()]=i.serialize()}},r.Parse=function(t,e,n){if(t.customType){if(t.customType==="BABYLON.PBRMaterial"&&t.overloadedAlbedo&&(t.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return O.V.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null}else t.customType="BABYLON.StandardMaterial";var i=ze.S0.Instantiate(t.customType).Parse(t,e,n);return i._loadedUniqueId=t.uniqueId,i},r._ParsePlugins=function(t,e,n,i){var o;if(t.plugins)for(var a in t.plugins){var s=t.plugins[a],l=(o=e.pluginManager)===null||o===void 0?void 0:o.getPlugin(s.name);if(!l){var c=ze.S0.Instantiate("BABYLON."+a);c&&(l=new c(e))}l?.parse(s,n,i)}},r.TriangleFillMode=P.Y.MATERIAL_TriangleFillMode,r.WireFrameFillMode=P.Y.MATERIAL_WireFrameFillMode,r.PointFillMode=P.Y.MATERIAL_PointFillMode,r.PointListDrawMode=P.Y.MATERIAL_PointListDrawMode,r.LineListDrawMode=P.Y.MATERIAL_LineListDrawMode,r.LineLoopDrawMode=P.Y.MATERIAL_LineLoopDrawMode,r.LineStripDrawMode=P.Y.MATERIAL_LineStripDrawMode,r.TriangleStripDrawMode=P.Y.MATERIAL_TriangleStripDrawMode,r.TriangleFanDrawMode=P.Y.MATERIAL_TriangleFanDrawMode,r.ClockWiseSideOrientation=P.Y.MATERIAL_ClockWiseSideOrientation,r.CounterClockWiseSideOrientation=P.Y.MATERIAL_CounterClockWiseSideOrientation,r.TextureDirtyFlag=P.Y.MATERIAL_TextureDirtyFlag,r.LightDirtyFlag=P.Y.MATERIAL_LightDirtyFlag,r.FresnelDirtyFlag=P.Y.MATERIAL_FresnelDirtyFlag,r.AttributesDirtyFlag=P.Y.MATERIAL_AttributesDirtyFlag,r.MiscDirtyFlag=P.Y.MATERIAL_MiscDirtyFlag,r.PrePassDirtyFlag=P.Y.MATERIAL_PrePassDirtyFlag,r.AllDirtyFlag=P.Y.MATERIAL_AllDirtyFlag,r.MATERIAL_OPAQUE=0,r.MATERIAL_ALPHATEST=1,r.MATERIAL_ALPHABLEND=2,r.MATERIAL_ALPHATESTANDBLEND=3,r.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,r.MATERIAL_NORMALBLENDMETHOD_RNM=1,r.OnEventObservable=new K.cP,r._AllDirtyCallBack=function(t){return t.markAllAsDirty()},r._ImageProcessingDirtyCallBack=function(t){return t.markAsImageProcessingDirty()},r._TextureDirtyCallBack=function(t){return t.markAsTexturesDirty()},r._FresnelDirtyCallBack=function(t){return t.markAsFresnelDirty()},r._MiscDirtyCallBack=function(t){return t.markAsMiscDirty()},r._PrePassDirtyCallBack=function(t){return t.markAsPrePassDirty()},r._LightsDirtyCallBack=function(t){return t.markAsLightDirty()},r._AttributeDirtyCallBack=function(t){return t.markAsAttributesDirty()},r._FresnelAndMiscDirtyCallBack=function(t){r._FresnelDirtyCallBack(t),r._MiscDirtyCallBack(t)},r._TextureAndMiscDirtyCallBack=function(t){r._TextureDirtyCallBack(t),r._MiscDirtyCallBack(t)},r._DirtyCallbackArray=[],r._RunDirtyCallBacks=function(t){for(var e=0,n=r._DirtyCallbackArray;e<n.length;e++)(0,n[e])(t)},(0,A.Cg)([(0,V.lK)()],r.prototype,"id",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"uniqueId",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"name",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"metadata",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"checkReadyOnEveryCall",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"checkReadyOnlyOnce",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"state",void 0),(0,A.Cg)([(0,V.lK)("alpha")],r.prototype,"_alpha",void 0),(0,A.Cg)([(0,V.lK)("backFaceCulling")],r.prototype,"_backFaceCulling",void 0),(0,A.Cg)([(0,V.lK)("cullBackFaces")],r.prototype,"_cullBackFaces",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"sideOrientation",void 0),(0,A.Cg)([(0,V.lK)("alphaMode")],r.prototype,"_alphaMode",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"_needDepthPrePass",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"disableDepthWrite",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"disableColorWrite",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"forceDepthWrite",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"depthFunction",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"separateCullingPass",void 0),(0,A.Cg)([(0,V.lK)("fogEnabled")],r.prototype,"_fogEnabled",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"pointSize",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"zOffset",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"zOffsetUnits",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"pointsCloud",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"fillMode",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"useLogarithmicDepth",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"transparencyMode",null),r}(),Vr=function(r){function t(e,n){var i=r.call(this,e,n,!0)||this;return i._waitingSubMaterialsUniqueIds=[],i.getScene().addMultiMaterial(i),i.subMaterials=[],i._storeEffectOnSubMeshes=!0,i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!1,configurable:!0}),t.prototype.getChildren=function(){return this.subMaterials},t.prototype._hookArray=function(e){var n=this,i=e.push;e.push=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var l=i.apply(e,a);return n._markAllSubMeshesAsTexturesDirty(),l};var o=e.splice;e.splice=function(a,s){var l=o.apply(e,[a,s]);return n._markAllSubMeshesAsTexturesDirty(),l}},t.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.getActiveTextures=function(){var e;return(e=r.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map(function(n){return n?n.getActiveTextures():[]}))},t.prototype.hasTexture=function(e){var n;if(r.prototype.hasTexture.call(this,e))return!0;for(var i=0;i<this.subMaterials.length;i++)if(!((n=this.subMaterials[i])===null||n===void 0)&&n.hasTexture(e))return!0;return!1},t.prototype.getClassName=function(){return"MultiMaterial"},t.prototype.isReadyForSubMesh=function(e,n,i){for(var o=0;o<this.subMaterials.length;o++){var a=this.subMaterials[o];if(a){if(a._storeEffectOnSubMeshes){if(!a.isReadyForSubMesh(e,n,i))return!1;continue}if(!a.isReady(e))return!1}}return!0},t.prototype.clone=function(e,n){for(var i=new t(e,this.getScene()),o=0;o<this.subMaterials.length;o++){var a,s=this.subMaterials[o];a=n&&s?s.clone(e+"-"+s.name):this.subMaterials[o],i.subMaterials.push(a)}return i},t.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,En.Y&&(e.tags=En.Y.GetTags(this)),e.materialsUniqueIds=[],e.materials=[];for(var n=0;n<this.subMaterials.length;n++){var i=this.subMaterials[n];i?(e.materialsUniqueIds.push(i.uniqueId),e.materials.push(i.id)):(e.materialsUniqueIds.push(null),e.materials.push(null))}return e},t.prototype.dispose=function(e,n,i){var o=this.getScene();if(o){if(i)for(var a=0;a<this.subMaterials.length;a++){var s=this.subMaterials[a];s&&s.dispose(e,n)}var l=o.multiMaterials.indexOf(this);l>=0&&o.multiMaterials.splice(l,1),r.prototype.dispose.call(this,e,n)}},t.ParseMultiMaterial=function(e,n){var i=new t(e.name,n);return i.id=e.id,i._loadedUniqueId=e.uniqueId,En.Y&&En.Y.AddTagsTo(i,e.tags),e.materialsUniqueIds?i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach(function(o){return i.subMaterials.push(n.getLastMaterialById(o))}),i},t}(Lt);(0,j.Y5)("BABYLON.MultiMaterial",Vr);var lt=L(52366),J_=function(r,t){this.distanceOrScreenCoverage=r,this.mesh=t},Cc=function(){},q1=function(){this.visibleInstances={},this.batchCache=new Rc,this.batchCacheReplacementModeInFrozenMode=new Rc,this.instancesBufferSize=2048},Rc=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]},K1=function(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null},Z1=function(){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},xe=function(r){function t(e,n,i,o,a,s){n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=null),s===void 0&&(s=!0);var l=r.call(this,e,n)||this;return l._internalMeshDataInfo=new Z1,l.delayLoadState=P.Y.DELAYLOADSTATE_NONE,l.instances=[],l._creationDataStorage=null,l._geometry=null,l._instanceDataStorage=new q1,l._thinInstanceDataStorage=new K1,l._shouldGenerateFlatShading=!1,l._originalBuilderSideOrientation=t.DEFAULTSIDE,l.ignoreCameraMaxZ=!1,n=l.getScene(),l._scene.useRightHandedSystem?l.sideOrientation=P.Y.MATERIAL_ClockWiseSideOrientation:l.sideOrientation=P.Y.MATERIAL_CounterClockWiseSideOrientation,l._onBeforeDraw=function(c,u,d){c&&d&&(l._uniformBuffer?l.transferToEffect(u):d.bindOnlyWorldMatrix(u))},o&&l._copySource(o,a,s),i!==null&&(l.parent=i),l._instanceDataStorage.hardwareInstancedRendering=l.getEngine().getCaps().instancedArrays,l._internalMeshDataInfo._onMeshReadyObserverAdded=function(c){c.unregisterOnNextCall=!0,l.isReady(!0)?l.onMeshReadyObservable.notifyObservers(l):l._internalMeshDataInfo._checkReadinessObserver||(l._internalMeshDataInfo._checkReadinessObserver=l._scene.onBeforeRenderObservable.add(function(){l.isReady(!0)&&(l._scene.onBeforeRenderObservable.remove(l._internalMeshDataInfo._checkReadinessObserver),l._internalMeshDataInfo._checkReadinessObserver=null,l.onMeshReadyObservable.notifyObservers(l))}))},l.onMeshReadyObservable=new K.cP(l._internalMeshDataInfo._onMeshReadyObserverAdded),o&&o.onClonedObservable.notifyObservers(l),l}return(0,A.C6)(t,r),t._GetDefaultSideOrientation=function(e){return e||t.FRONTSIDE},Object.defineProperty(t.prototype,"useLODScreenCoverage",{get:function(){return this._internalMeshDataInfo._useLODScreenCoverage},set:function(e){this._internalMeshDataInfo._useLODScreenCoverage=e,this._sortLODLevels()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(Y.R.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(Y.R.NormalKind,this._internalMeshDataInfo._sourceNormals,!0),this._internalMeshDataInfo._sourcePositions=null,this._internalMeshDataInfo._sourceNormals=null),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRenderObservable",{get:function(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new K.cP),this._internalMeshDataInfo._onBeforeRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeBindObservable",{get:function(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new K.cP),this._internalMeshDataInfo._onBeforeBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRenderObservable",{get:function(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new K.cP),this._internalMeshDataInfo._onAfterRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBetweenPassObservable",{get:function(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new K.cP),this._internalMeshDataInfo._onBetweenPassObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeDrawObservable",{get:function(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new K.cP),this._internalMeshDataInfo._onBeforeDrawObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasInstances",{get:function(){return this.instances.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasThinInstances",{get:function(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forcedInstanceCount",{get:function(){return this._internalMeshDataInfo._forcedInstanceCount},set:function(e){this._internalMeshDataInfo._forcedInstanceCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sideOrientation",{get:function(){return this._internalMeshDataInfo._sideOrientation},set:function(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&e===P.Y.MATERIAL_CounterClockWiseSideOrientation||!this._scene.useRightHandedSystem&&e===P.Y.MATERIAL_ClockWiseSideOrientation},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"overrideMaterialSideOrientation",{get:function(){return this.sideOrientation},set:function(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"overrideRenderingFillMode",{get:function(){return this._internalMeshDataInfo._overrideRenderingFillMode},set:function(e){this._internalMeshDataInfo._overrideRenderingFillMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._internalAbstractMeshDataInfo._material},set:function(e){e&&(this.material&&this.material.sideOrientation===null||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cloneMeshMap",{get:function(){return this._internalMeshDataInfo.meshMap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"previousWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesPreviousData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfPreviousWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.previousManualUpdate},set:function(e){this._instanceDataStorage.previousManualUpdate=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forceWorldMatrixInstancedBufferUpdate",{get:function(){return this._instanceDataStorage.forceMatrixUpdates},set:function(e){this._instanceDataStorage.forceMatrixUpdates=e},enumerable:!1,configurable:!0}),t.prototype._copySource=function(e,n,i){i===void 0&&(i=!0);var o=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),ot.r.DeepCopy(e,this,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","worldMatrixInstancedBuffer","previousWorldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap","hasBoundingInfo","physicsBody","physicsImpostor"],["_poseMatrix"]),this._internalMeshDataInfo._source=e,o.useClonedMeshMap&&(e._internalMeshDataInfo.meshMap||(e._internalMeshDataInfo.meshMap={}),e._internalMeshDataInfo.meshMap[this.uniqueId]=this),this._originalBuilderSideOrientation=e._originalBuilderSideOrientation,this._creationDataStorage=e._creationDataStorage,e._ranges){var a=e._ranges;for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&a[s]&&this.createAnimationRange(s,a[s].from,a[s].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,En.Y&&En.Y.HasTags(e)&&En.Y.AddTagsTo(this,En.Y.GetTags(e,!0)),this.setEnabled(e.isEnabled(!1)),this.parent=e.parent,this.setPivotMatrix(e.getPivotMatrix(),this._postMultiplyPivotMatrix),this.id=this.name+"."+e.id,this.material=e.material,!n)for(var l=e.getDescendants(!0),c=0;c<l.length;c++){var u=l[c];u.clone&&u.clone(this.name+"."+u.name,this)}if(e.morphTargetManager&&(this.morphTargetManager=e.morphTargetManager),o.getPhysicsEngine){var d=o.getPhysicsEngine();if(i&&d)if(d.getPluginVersion()===1){var h=d.getImpostorForPhysicsObject(e);h&&(this.physicsImpostor=h.clone(this))}else d.getPluginVersion()===2&&e.physicsBody&&e.physicsBody.clone(this)}for(c=0;c<o.particleSystems.length;c++){var p=o.particleSystems[c];p.emitter===e&&p.clone(p.name,this)}this.skeleton=e.skeleton,this.refreshBoundingInfo(!0,!0),this.computeWorldMatrix(!0)},t.prototype.instantiateHierarchy=function(e,n,i){e===void 0&&(e=null);var o=this.getTotalVertices()===0||n&&n.doNotInstantiate&&(n.doNotInstantiate===!0||n.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));o.parent=e||this.parent,o.position=this.position.clone(),o.scaling=this.scaling.clone(),this.rotationQuaternion?o.rotationQuaternion=this.rotationQuaternion.clone():o.rotation=this.rotation.clone(),i&&i(this,o);for(var a=0,s=this.getChildTransformNodes(!0);a<s.length;a++){var l=s[a];l.getClassName()==="InstancedMesh"&&o.getClassName()==="Mesh"&&l.sourceMesh===this?l.instantiateHierarchy(o,{doNotInstantiate:n&&n.doNotInstantiate||!1,newSourcedMesh:o},i):l.instantiateHierarchy(o,n,i)}return o},t.prototype.getClassName=function(){return"Mesh"},Object.defineProperty(t.prototype,"_isMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.toString=function(e){var n=r.prototype.toString.call(this,e);if(n+=", n vertices: "+this.getTotalVertices(),n+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var i=0;i<this.animations.length;i++)n+=", animation[0]: "+this.animations[i].toString(e);if(e)if(this._geometry){var o=this.getIndices(),a=this.getVerticesData(Y.R.PositionKind);a&&o&&(n+=", flat shading: "+(a.length/3===o.length?"YES":"NO"))}else n+=", flat shading: UNKNOWN";return n},t.prototype._unBindEffect=function(){r.prototype._unBindEffect.call(this);for(var e=0,n=this.instances;e<n.length;e++)n[e]._unBindEffect()},Object.defineProperty(t.prototype,"hasLODLevels",{get:function(){return this._internalMeshDataInfo._LODLevels.length>0},enumerable:!1,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){var e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort(function(n,i){return n.distanceOrScreenCoverage<i.distanceOrScreenCoverage?e:n.distanceOrScreenCoverage>i.distanceOrScreenCoverage?-e:0})},t.prototype.addLODLevel=function(e,n){if(n&&n._masterMesh)return O.V.Warn("You cannot use a mesh as LOD level twice"),this;var i=new J_(e,n);return this._internalMeshDataInfo._LODLevels.push(i),n&&(n._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var n=this._internalMeshDataInfo,i=0;i<n._LODLevels.length;i++){var o=n._LODLevels[i];if(o.distanceOrScreenCoverage===e)return o.mesh}return null},t.prototype.removeLODLevel=function(e){for(var n=this._internalMeshDataInfo,i=0;i<n._LODLevels.length;i++)n._LODLevels[i].mesh===e&&(n._LODLevels.splice(i,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},t.prototype.getLOD=function(e,n){var i=this._internalMeshDataInfo;if(!i._LODLevels||i._LODLevels.length===0)return this;var o=n||this.getBoundingInfo().boundingSphere,a=e.mode===Pt.ORTHOGRAPHIC_CAMERA?e.minZ:o.centerWorld.subtract(e.globalPosition).length(),s=a,l=1;if(i._useLODScreenCoverage){var c=e.screenArea,u=o.radiusWorld*e.minZ/a;s=(u=u*u*Math.PI)/c,l=-1}if(l*i._LODLevels[i._LODLevels.length-1].distanceOrScreenCoverage>l*s)return this.onLODLevelSelection&&this.onLODLevelSelection(s,this,this),this;for(var d=0;d<i._LODLevels.length;d++){var h=i._LODLevels[d];if(l*h.distanceOrScreenCoverage<l*s){if(h.mesh){if(h.mesh.delayLoadState===P.Y.DELAYLOADSTATE_NOTLOADED)return h.mesh._checkDelayState(),this;if(h.mesh.delayLoadState===P.Y.DELAYLOADSTATE_LOADING)return this;h.mesh._preActivate(),h.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(s,this,h.mesh),h.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(s,this,this),this},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._geometry},enumerable:!1,configurable:!0}),t.prototype.getTotalVertices=function(){return this._geometry===null||this._geometry===void 0?0:this._geometry.getTotalVertices()},t.prototype.getVerticesData=function(e,n,i,o){var a,s;if(!this._geometry)return null;var l=o||(s=(a=this._userInstancedBuffersStorage)===null||a===void 0?void 0:a.vertexBuffers[e])===null||s===void 0?void 0:s.getFloatData(this.instances.length+1,i||n&&this._geometry.meshes.length!==1);return l||(l=this._geometry.getVerticesData(e,n,i)),l},t.prototype.copyVerticesData=function(e,n){this._geometry&&this._geometry.copyVerticesData(e,n)},t.prototype.getVertexBuffer=function(e,n){var i,o;return this._geometry?(o=n||(i=this._userInstancedBuffersStorage)===null||i===void 0?void 0:i.vertexBuffers[e])!==null&&o!==void 0?o:this._geometry.getVertexBuffer(e):null},t.prototype.isVerticesDataPresent=function(e,n){var i;return this._geometry?!n&&((i=this._userInstancedBuffersStorage)===null||i===void 0?void 0:i.vertexBuffers[e])!==void 0||this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&this._delayInfo.indexOf(e)!==-1},t.prototype.isVertexBufferUpdatable=function(e,n){var i;if(!this._geometry)return!!this._delayInfo&&this._delayInfo.indexOf(e)!==-1;if(!n){var o=(i=this._userInstancedBuffersStorage)===null||i===void 0?void 0:i.vertexBuffers[e];if(o)return o.isUpdatable()}return this._geometry.isVertexBufferUpdatable(e)},t.prototype.getVerticesDataKinds=function(e){if(!this._geometry){var n=[];return this._delayInfo&&this._delayInfo.forEach(function(a){n.push(a)}),n}var i=this._geometry.getVerticesDataKinds();if(!e&&this._userInstancedBuffersStorage)for(var o in this._userInstancedBuffersStorage.vertexBuffers)i.indexOf(o)===-1&&i.push(o);return i},t.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},t.prototype.getIndices=function(e,n){return this._geometry?this._geometry.getIndices(e,n):[]},Object.defineProperty(t.prototype,"isBlocked",{get:function(){return this._masterMesh!==null&&this._masterMesh!==void 0},enumerable:!1,configurable:!0}),t.prototype.isReady=function(e,n){var i,o,a,s,l,c,u;if(e===void 0&&(e=!1),n===void 0&&(n=!1),this.delayLoadState===P.Y.DELAYLOADSTATE_LOADING||!r.prototype.isReady.call(this,e))return!1;if(!this.subMeshes||this.subMeshes.length===0||!e)return!0;var d=this.getEngine(),h=this.getScene(),p=n||d.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();var m=this.material||h.defaultMaterial;if(m){if(m._storeEffectOnSubMeshes)for(var v=0,b=this.subMeshes;v<b.length;v++){var E=(B=b[v]).getMaterial();if(E){if(E._storeEffectOnSubMeshes){if(!E.isReadyForSubMesh(this,B,p))return!1}else if(!E.isReady(this,p))return!1}}else if(!m.isReady(this,p))return!1}for(var C=d.currentRenderPassId,T=0,f=this.lightSources;T<f.length;T++){var g=f[T].getShadowGenerators();if(g)for(var S=g.values(),y=S.next();y.done!==!0;y=S.next()){var x=y.value;if(x&&(!(!((i=x.getShadowMap())===null||i===void 0)&&i.renderList)||!((o=x.getShadowMap())===null||o===void 0)&&o.renderList&&((s=(a=x.getShadowMap())===null||a===void 0?void 0:a.renderList)===null||s===void 0?void 0:s.indexOf(this))!==-1)){for(var R=(l=x.getShadowMap().renderPassIds)!==null&&l!==void 0?l:[d.currentRenderPassId],I=0;I<R.length;++I){d.currentRenderPassId=R[I];for(var M=0,D=this.subMeshes;M<D.length;M++){var B=D[M];if(!x.isReady(B,p,(u=(c=B.getMaterial())===null||c===void 0?void 0:c.needAlphaBlendingForMesh(this))!==null&&u!==void 0&&u))return d.currentRenderPassId=C,!1}}d.currentRenderPassId=C}}}for(var F=0,X=this._internalMeshDataInfo._LODLevels;F<X.length;F++){var $=X[F];if($.mesh&&!$.mesh.isReady(p))return!1}return!0},Object.defineProperty(t.prototype,"areNormalsFrozen",{get:function(){return this._internalMeshDataInfo._areNormalsFrozen},enumerable:!1,configurable:!0}),t.prototype.freezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this},t.prototype.unfreezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this},Object.defineProperty(t.prototype,"overridenInstanceCount",{set:function(e){this._instanceDataStorage.overridenInstanceCount=e},enumerable:!1,configurable:!0}),t.prototype._preActivate=function(){var e=this._internalMeshDataInfo,n=this.getScene().getRenderId();return e._preActivateId===n||(e._preActivateId=n,this._instanceDataStorage.visibleInstances=null),this},t.prototype._preActivateForIntermediateRendering=function(e){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=e),this},t.prototype._registerInstanceForRenderId=function(e,n){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={defaultRenderId:n,selfDefaultRenderId:this._renderId}),this._instanceDataStorage.visibleInstances[n]||(this._instanceDataStorage.previousRenderId!==void 0&&this._instanceDataStorage.isFrozen&&(this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId]=null),this._instanceDataStorage.previousRenderId=n,this._instanceDataStorage.visibleInstances[n]=new Array),this._instanceDataStorage.visibleInstances[n].push(e),this},t.prototype._afterComputeWorldMatrix=function(){r.prototype._afterComputeWorldMatrix.call(this),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))},t.prototype._postActivate=function(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))},t.prototype.refreshBoundingInfo=function(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=!1),this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;var i;i=typeof e=="object"?e:{applySkeleton:e,applyMorph:n};var o=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getData(i,null,Y.R.PositionKind),o),this},t.prototype._createGlobalSubMesh=function(e){var n=this.getTotalVertices();if(!n||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){var i=this.getIndices();if(!i)return null;var o=i.length,a=!1;if(e)a=!0;else for(var s=0,l=this.subMeshes;s<l.length;s++){var c=l[s];if(c.indexStart+c.indexCount>o){a=!0;break}if(c.verticesStart+c.verticesCount>n){a=!0;break}}if(!a)return this.subMeshes[0]}return this.releaseSubMeshes(),new yi(0,0,n,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var n=this.getTotalIndices(),i=n/e|0,o=0;i%3!=0;)i++;this.releaseSubMeshes();for(var a=0;a<e&&!(o>=n);a++)yi.CreateFromIndices(0,o,a===e-1?n-o:i,this,void 0,!1),o+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,n,i,o){if(i===void 0&&(i=!1),this._geometry)this._geometry.setVerticesData(e,n,i,o);else{var a=new rt;a.set(n,e);var s=this.getScene();new Vi(Vi.RandomId(),s,a,i,this)}return this},t.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},t.prototype.markVerticesDataAsUpdatable=function(e,n){n===void 0&&(n=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==n&&this.setVerticesData(e,this.getVerticesData(e),n)},t.prototype.setVerticesBuffer=function(e,n){return n===void 0&&(n=!0),this._geometry||(this._geometry=Vi.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,n),this},t.prototype.updateVerticesData=function(e,n,i,o){return this._geometry?(o?(this.makeGeometryUnique(),this.updateVerticesData(e,n,i,!1)):this._geometry.updateVerticesData(e,n,i),this):this},t.prototype.updateMeshPositions=function(e,n){n===void 0&&(n=!0);var i=this.getVerticesData(Y.R.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(Y.R.PositionKind,i,!1,!1),n){var o=this.getIndices(),a=this.getVerticesData(Y.R.NormalKind);if(!a)return this;rt.ComputeNormals(i,o,a),this.updateVerticesData(Y.R.NormalKind,a,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(this._geometry.meshes.length===1)return this;var e=this._geometry,n=this._geometry.copy(Vi.RandomId());return e.releaseForMesh(this,!0),n.applyToMesh(this),this},t.prototype.setIndexBuffer=function(e,n,i){var o=this._geometry;o||(o=new Vi(Vi.RandomId(),this.getScene(),void 0,void 0,this)),o.setIndexBuffer(e,n,i)},t.prototype.setIndices=function(e,n,i,o){if(n===void 0&&(n=null),i===void 0&&(i=!1),o===void 0&&(o=!1),this._geometry)this._geometry.setIndices(e,n,i,o);else{var a=new rt;a.indices=e;var s=this.getScene();new Vi(Vi.RandomId(),s,a,i,this)}return this},t.prototype.updateIndices=function(e,n,i){return i===void 0&&(i=!1),this._geometry?(this._geometry.updateIndices(e,n,i),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,n,i,o){if(o===void 0&&(o=!0),!this._geometry)return this;var a,s=this.getScene().getEngine();if(this._unIndexed)a=null;else switch(this._getRenderingFillMode(i)){case Lt.PointFillMode:a=null;break;case Lt.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),s);break;default:case Lt.TriangleFillMode:a=this._geometry.getIndexBuffer()}return this._bindDirect(n,a,o)},t.prototype._bindDirect=function(e,n,i){return i===void 0&&(i=!0),this._geometry?(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),i&&this._userInstancedBuffersStorage&&!this.hasThinInstances?this._geometry._bind(e,n,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects):this._geometry._bind(e,n),this):this},t.prototype._draw=function(e,n,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var o=this.getScene().getEngine();return this._unIndexed||n==Lt.PointFillMode?o.drawArraysType(n,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):n==Lt.WireFrameFillMode?o.drawElementsType(n,0,e._linesIndexCount,this.forcedInstanceCount||i):o.drawElementsType(n,e.indexStart,e.indexCount,this.forcedInstanceCount||i),this},t.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},t.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},t.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},t.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},t.prototype._getInstancesRenderList=function(e,n){if(n===void 0&&(n=!1),this._instanceDataStorage.isFrozen){if(n)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}var i=this.getScene(),o=i._isInIntermediateRendering(),a=o?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,s=this._instanceDataStorage.batchCache;if(s.mustReturn=!1,s.renderSelf[e]=n||!a&&this.isEnabled()&&this.isVisible,s.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!n){var l=this._instanceDataStorage.visibleInstances,c=i.getRenderId(),u=o?l.intermediateDefaultRenderId:l.defaultRenderId;s.visibleInstances[e]=l[c],!s.visibleInstances[e]&&u&&(s.visibleInstances[e]=l[u])}return s.hardwareInstancedRendering[e]=!n&&this._instanceDataStorage.hardwareInstancedRendering&&s.visibleInstances[e]!==null&&s.visibleInstances[e]!==void 0,this._instanceDataStorage.previousBatch=s,s},t.prototype._renderWithInstances=function(e,n,i,o,a){for(var s,l=i.visibleInstances[e._id],c=l?l.length:0,u=this._instanceDataStorage,d=u.instancesBufferSize,h=u.instancesBuffer,p=u.instancesPreviousBuffer,m=16*(c+1)*4;u.instancesBufferSize<m;)u.instancesBufferSize*=2;u.instancesData&&d==u.instancesBufferSize||(u.instancesData=new Float32Array(u.instancesBufferSize/4)),(this._scene.needsPreviousWorldMatrices&&!u.instancesPreviousData||d!=u.instancesBufferSize)&&(u.instancesPreviousData=new Float32Array(u.instancesBufferSize/4));var v=0,b=0,E=i.renderSelf[e._id],C=!h||d!==u.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!u.instancesPreviousBuffer;if(this._instanceDataStorage.manualUpdate||u.isFrozen&&!C)b=(E?1:0)+c;else{var T=this.getWorldMatrix();if(E&&(this._scene.needsPreviousWorldMatrices&&(u.masterMeshPreviousWorldMatrix?(u.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData,v),u.masterMeshPreviousWorldMatrix.copyFrom(T)):(u.masterMeshPreviousWorldMatrix=T.clone(),u.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData,v))),T.copyToArray(u.instancesData,v),v+=16,b++),l){if(t.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&(!((s=e.getMaterial())===null||s===void 0)&&s.needAlphaBlendingForMesh(e.getRenderingMesh()))){for(var f=this._scene.activeCamera.globalPosition,g=0;g<l.length;g++){var S=l[g];S._distanceToCamera=_.Pq.Distance(S.getBoundingInfo().boundingSphere.centerWorld,f)}l.sort(function(R,I){return R._distanceToCamera>I._distanceToCamera?-1:R._distanceToCamera<I._distanceToCamera?1:0})}for(g=0;g<l.length;g++){var y=l[g],x=y.getWorldMatrix();x.copyToArray(u.instancesData,v),this._scene.needsPreviousWorldMatrices&&(y._previousWorldMatrix?(y._previousWorldMatrix.copyToArray(u.instancesPreviousData,v),y._previousWorldMatrix.copyFrom(x)):(y._previousWorldMatrix=x.clone(),y._previousWorldMatrix.copyToArray(u.instancesPreviousData,v))),v+=16,b++}}}return C?(h&&h.dispose(),p&&p.dispose(),h=new Y.h(a,u.instancesData,!0,16,!1,!0),u.instancesBuffer=h,this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0}),this._userInstancedBuffersStorage.vertexBuffers.world0=h.createVertexBuffer("world0",0,4),this._userInstancedBuffersStorage.vertexBuffers.world1=h.createVertexBuffer("world1",4,4),this._userInstancedBuffersStorage.vertexBuffers.world2=h.createVertexBuffer("world2",8,4),this._userInstancedBuffersStorage.vertexBuffers.world3=h.createVertexBuffer("world3",12,4),this._scene.needsPreviousWorldMatrices&&(p=new Y.h(a,u.instancesPreviousData,!0,16,!1,!0),u.instancesPreviousBuffer=p,this._userInstancedBuffersStorage.vertexBuffers.previousWorld0=p.createVertexBuffer("previousWorld0",0,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld1=p.createVertexBuffer("previousWorld1",4,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld2=p.createVertexBuffer("previousWorld2",8,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld3=p.createVertexBuffer("previousWorld3",12,4)),this._invalidateInstanceVertexArrayObject()):this._instanceDataStorage.isFrozen&&!this._instanceDataStorage.forceMatrixUpdates||(h.updateDirectly(u.instancesData,0,b),!this._scene.needsPreviousWorldMatrices||this._instanceDataStorage.manualUpdate&&!this._instanceDataStorage.previousManualUpdate||p.updateDirectly(u.instancesPreviousData,0,b)),this._processInstancedBuffers(l,E),this.getScene()._activeIndices.addCount(e.indexCount*b,!1),a._currentDrawContext&&(a._currentDrawContext.useInstancing=!0),this._bind(e,o,n),this._draw(e,n,b),!this._scene.needsPreviousWorldMatrices||C||!this._instanceDataStorage.manualUpdate||this._instanceDataStorage.isFrozen&&!this._instanceDataStorage.forceMatrixUpdates||this._instanceDataStorage.previousManualUpdate||p.updateDirectly(u.instancesData,0,b),a.unbindInstanceAttributes(),this},t.prototype._renderWithThinInstances=function(e,n,i,o){var a,s,l=(s=(a=this._thinInstanceDataStorage)===null||a===void 0?void 0:a.instancesCount)!==null&&s!==void 0?s:0;this.getScene()._activeIndices.addCount(e.indexCount*l,!1),o._currentDrawContext&&(o._currentDrawContext.useInstancing=!0),this._bind(e,i,n),this._draw(e,n,l),this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&this._thinInstanceDataStorage.matrixData&&(this._thinInstanceDataStorage.previousMatrixBuffer?this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,l):this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",this._thinInstanceDataStorage.matrixData,!1)),o.unbindInstanceAttributes()},t.prototype._processInstancedBuffers=function(e,n){},t.prototype._processRendering=function(e,n,i,o,a,s,l,c){var u=this.getScene(),d=u.getEngine();if(o=this._getRenderingFillMode(o),s&&n.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(n,o,i,d),this;if(s)this._renderWithInstances(n,o,a,i,d);else{d._currentDrawContext&&(d._currentDrawContext.useInstancing=!1);var h=0;a.renderSelf[n._id]&&(l&&l(!1,e.getWorldMatrix(),c),h++,this._draw(n,o,this._instanceDataStorage.overridenInstanceCount));var p=a.visibleInstances[n._id];if(p){var m=p.length;h+=m;for(var v=0;v<m;v++){var b=p[v].getWorldMatrix();l&&l(!0,b,c),this._draw(n,o)}}u._activeIndices.addCount(n.indexCount*h,!1)}return this},t.prototype._rebuild=function(e){if(e===void 0&&(e=!1),this._instanceDataStorage.instancesBuffer&&(e&&this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null),this._userInstancedBuffersStorage){for(var n in this._userInstancedBuffersStorage.vertexBuffers){var i=this._userInstancedBuffersStorage.vertexBuffers[n];i&&(e&&i.dispose(),this._userInstancedBuffersStorage.vertexBuffers[n]=null)}this._userInstancedBuffersStorage.vertexArrayObjects&&(this._userInstancedBuffersStorage.vertexArrayObjects={})}this._internalMeshDataInfo._effectiveMaterial=null,r.prototype._rebuild.call(this,e)},t.prototype._freeze=function(){if(this.subMeshes){for(var e=0;e<this.subMeshes.length;e++)this._getInstancesRenderList(e);this._internalMeshDataInfo._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}},t.prototype._unFreeze=function(){this._instanceDataStorage.isFrozen=!1,this._instanceDataStorage.previousBatch=null},t.prototype.renderWithRenderPassId=function(e,n,i,o,a){a===void 0&&(a=!0);var s=this._scene.getEngine(),l=s.currentRenderPassId;if(e!==void 0&&(s.currentRenderPassId=e),o)(!a||a&&o.isInFrustum(this._scene._frustumPlanes))&&this.render(o,!!n,i);else for(var c=0;c<this.subMeshes.length;c++){var u=this.subMeshes[c];(!a||a&&u.isInFrustum(this._scene._frustumPlanes))&&this.render(u,!!n,i)}return e!==void 0&&(s.currentRenderPassId=l),this},t.prototype.render=function(e,n,i){var o,a,s,l,c=this.getScene();this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1;var u=(a=(o=c.activeCameras)===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0;if((u>1&&c.activeCamera===c.activeCameras[0]||u<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;var d=this._getInstancesRenderList(e._id,!!i);if(d.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var h=c.getEngine(),p=0,m=null;this.ignoreCameraMaxZ&&c.activeCamera&&!c._isInIntermediateRendering()&&(p=c.activeCamera.maxZ,m=c.activeCamera,c.activeCamera.maxZ=0,c.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);var v,b=e.getRenderingMesh(),E=d.hardwareInstancedRendering[e._id]||b.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,C=this._instanceDataStorage,T=e.getMaterial();if(!T)return m&&(m.maxZ=p,c.updateTransformMatrix(!0)),this;if(C.isFrozen&&this._internalMeshDataInfo._effectiveMaterial&&this._internalMeshDataInfo._effectiveMaterial===T){if(T._storeEffectOnSubMeshes&&!(!((s=e._drawWrapper)===null||s===void 0)&&s._wasPreviouslyReady)||!T._storeEffectOnSubMeshes&&!T._getDrawWrapper()._wasPreviouslyReady)return m&&(m.maxZ=p,c.updateTransformMatrix(!0)),this}else{if(T._storeEffectOnSubMeshes){if(!T.isReadyForSubMesh(this,e,E))return m&&(m.maxZ=p,c.updateTransformMatrix(!0)),this}else if(!T.isReady(this,E))return m&&(m.maxZ=p,c.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=T}n&&h.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);for(var f=(l=(v=this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?e._drawWrapper:this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper())==null?void 0:v.effect)!==null&&l!==void 0?l:null,g=0,S=c._beforeRenderingMeshStage;g<S.length;g++)S[g].action(this,e,d,f);if(!v||!f)return m&&(m.maxZ=p,c.updateTransformMatrix(!0)),this;var y,x=i||this;if(C.isFrozen||!this._internalMeshDataInfo._effectiveMaterial.backFaceCulling&&this._internalMeshDataInfo._effectiveMaterial.sideOrientation===null&&!this._internalMeshDataInfo._effectiveMaterial.twoSidedLighting)y=C.sideOrientation;else{var R=x._getWorldMatrixDeterminant();y=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),R<0&&(y=y===Lt.ClockWiseSideOrientation?Lt.CounterClockWiseSideOrientation:Lt.ClockWiseSideOrientation),C.sideOrientation=y}var I=this._internalMeshDataInfo._effectiveMaterial._preBind(v,y);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&h.setDepthWrite(!0);var M=this._internalMeshDataInfo._effectiveMaterial,D=M.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),E||this._bind(e,f,D,!1);var B=x.getWorldMatrix();M._storeEffectOnSubMeshes?M.bindForSubMesh(B,this,e):M.bind(B,this),!M.backFaceCulling&&M.separateCullingPass&&(h.setState(!0,M.zOffset,!1,!I,M.cullBackFaces,M.stencil,M.zOffsetUnits),this._processRendering(this,e,f,D,d,E,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),h.setState(!0,M.zOffset,!1,I,M.cullBackFaces,M.stencil,M.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,f,D,d,E,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(var F=0,X=c._afterRenderingMeshStage;F<X.length;F++)X[F].action(this,e,d,f);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),m&&(m.maxZ=p,c.updateTransformMatrix(!0)),c.performancePriority!==2||C.isFrozen||this._freeze(),this},t.prototype.cleanMatrixWeights=function(){this.isVerticesDataPresent(Y.R.MatricesWeightsKind)&&(this.isVerticesDataPresent(Y.R.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())},t.prototype._normalizeSkinFourWeights=function(){for(var e=this.getVerticesData(Y.R.MatricesWeightsKind),n=e.length,i=0;i<n;i+=4){var o=e[i]+e[i+1]+e[i+2]+e[i+3];if(o===0)e[i]=1;else{var a=1/o;e[i]*=a,e[i+1]*=a,e[i+2]*=a,e[i+3]*=a}}this.setVerticesData(Y.R.MatricesWeightsKind,e)},t.prototype._normalizeSkinWeightsAndExtra=function(){for(var e=this.getVerticesData(Y.R.MatricesWeightsExtraKind),n=this.getVerticesData(Y.R.MatricesWeightsKind),i=n.length,o=0;o<i;o+=4){var a=n[o]+n[o+1]+n[o+2]+n[o+3];if((a+=e[o]+e[o+1]+e[o+2]+e[o+3])===0)n[o]=1;else{var s=1/a;n[o]*=s,n[o+1]*=s,n[o+2]*=s,n[o+3]*=s,e[o]*=s,e[o+1]*=s,e[o+2]*=s,e[o+3]*=s}}this.setVerticesData(Y.R.MatricesWeightsKind,n),this.setVerticesData(Y.R.MatricesWeightsKind,e)},t.prototype.validateSkinning=function(){var e=this.getVerticesData(Y.R.MatricesWeightsExtraKind),n=this.getVerticesData(Y.R.MatricesWeightsKind);if(n===null||this.skeleton==null)return{skinned:!1,valid:!0,report:"not skinned"};for(var i=n.length,o=0,a=0,s=0,l=0,c=e===null?4:8,u=[],d=0;d<=c;d++)u[d]=0;for(d=0;d<i;d+=4){for(var h=n[d],p=h,m=p===0?0:1,v=1;v<c;v++){var b=v<4?n[d+v]:e[d+v-4];b>h&&o++,b!==0&&m++,p+=b,h=b}if(u[m]++,m>s&&(s=m),p===0)a++;else{var E=1/p,C=0;for(v=0;v<c;v++)C+=v<4?Math.abs(n[d+v]-n[d+v]*E):Math.abs(e[d+v-4]-e[d+v-4]*E);C>.001&&l++}}var T=this.skeleton.bones.length,f=this.getVerticesData(Y.R.MatricesIndicesKind),g=this.getVerticesData(Y.R.MatricesIndicesExtraKind),S=0;for(d=0;d<i;d+=4)for(v=0;v<c;v++){var y=v<4?f[d+v]:g[d+v-4];(y>=T||y<0)&&S++}return{skinned:!0,valid:a===0&&l===0&&S===0,report:"Number of Weights = "+i/4+`
|
||
Maximum influences = `+s+`
|
||
Missing Weights = `+a+`
|
||
Not Sorted = `+o+`
|
||
Not Normalized = `+l+`
|
||
WeightCounts = [`+u+`]
|
||
Number of bones = `+T+`
|
||
Bad Bone Indices = `+S}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===P.Y.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=P.Y.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var n=this;e.addPendingData(this);var i=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return ze.S0.LoadFile(this.delayLoadingFile,function(o){o instanceof ArrayBuffer?n._delayLoadingFunction(o,n):n._delayLoadingFunction(JSON.parse(o),n),n.instances.forEach(function(a){a.refreshBoundingInfo(),a._syncSubMeshes()}),n.delayLoadState=P.Y.DELAYLOADSTATE_LOADED,e.removePendingData(n)},function(){},e.offlineProvider,i),this},t.prototype.isInFrustum=function(e){return this.delayLoadState!==P.Y.DELAYLOADSTATE_LOADING&&!!r.prototype.isInFrustum.call(this,e)&&(this._checkDelayState(),!0)},t.prototype.setMaterialById=function(e){var n,i=this.getScene().materials;for(n=i.length-1;n>-1;n--)if(i[n].id===e)return this.material=i[n],this;var o=this.getScene().multiMaterials;for(n=o.length-1;n>-1;n--)if(o[n].id===e)return this.material=o[n],this;return this},t.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(Y.R.PositionKind))return this;var n=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,o=this.getVerticesData(Y.R.PositionKind),a=_.Pq.Zero();for(i=0;i<o.length;i+=3)_.Pq.TransformCoordinatesFromFloatsToRef(o[i],o[i+1],o[i+2],e,a).toArray(o,i);if(this.setVerticesData(Y.R.PositionKind,o,this.getVertexBuffer(Y.R.PositionKind).isUpdatable()),this.isVerticesDataPresent(Y.R.NormalKind)){for(o=this.getVerticesData(Y.R.NormalKind),i=0;i<o.length;i+=3)_.Pq.TransformNormalFromFloatsToRef(o[i],o[i+1],o[i+2],e,a).normalize().toArray(o,i);this.setVerticesData(Y.R.NormalKind,o,this.getVertexBuffer(Y.R.NormalKind).isUpdatable())}if(this.isVerticesDataPresent(Y.R.TangentKind)){for(o=this.getVerticesData(Y.R.TangentKind),i=0;i<o.length;i+=4)_.Pq.TransformNormalFromFloatsToRef(o[i],o[i+1],o[i+2],e,a).normalize().toArray(o,i);this.setVerticesData(Y.R.TangentKind,o,this.getVertexBuffer(Y.R.TangentKind).isUpdatable())}return e.determinant()<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=n,this},t.prototype.bakeCurrentTransformIntoVertices=function(e){return e===void 0&&(e=!0),this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(e),this},Object.defineProperty(t.prototype,"_positions",{get:function(){return this._internalAbstractMeshDataInfo._positions||this._geometry&&this._geometry._positions||null},enumerable:!1,configurable:!0}),t.prototype._resetPointsArrayCache=function(){return this._geometry&&this._geometry._resetPointsArrayCache(),this},t.prototype._generatePointsArray=function(){return!!this._geometry&&this._geometry._generatePointsArray()},t.prototype.clone=function(e,n,i,o){return e===void 0&&(e=""),n===void 0&&(n=null),o===void 0&&(o=!0),new t(e,this.getScene(),n,this,i,o)},t.prototype.dispose=function(e,n){n===void 0&&(n=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);var 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(var o in i.meshMap)(l=i.meshMap[o])&&(l._internalMeshDataInfo._source=null,i.meshMap[o]=void 0);i._source&&i._source._internalMeshDataInfo.meshMap&&(i._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else for(var a=0,s=this.getScene().meshes;a<s.length;a++){var l;(l=s[a])._internalMeshDataInfo&&l._internalMeshDataInfo._source&&l._internalMeshDataInfo._source===this&&(l._internalMeshDataInfo._source=null)}i._source=null,this._instanceDataStorage.visibleInstances={},this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),this._internalMeshDataInfo._checkReadinessObserver&&this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),r.prototype.dispose.call(this,e,n)},t.prototype._disposeInstanceSpecificData=function(){},t.prototype._disposeThinInstanceSpecificData=function(){},t.prototype._invalidateInstanceVertexArrayObject=function(){},t.prototype.applyDisplacementMap=function(e,n,i,o,a,s,l,c){var u=this;l===void 0&&(l=!1);var d=this.getScene();return ze.S0.LoadImage(e,function(h){var p=h.width,m=h.height,v=u.getEngine().createCanvas(p,m).getContext("2d");v.drawImage(h,0,0);var b=v.getImageData(0,0,p,m).data;u.applyDisplacementMapFromBuffer(b,p,m,n,i,a,s,l),o&&o(u)},c||function(){},d.offlineProvider),this},t.prototype.applyDisplacementMapFromBuffer=function(e,n,i,o,a,s,l,c){if(c===void 0&&(c=!1),!this.isVerticesDataPresent(Y.R.PositionKind)||!this.isVerticesDataPresent(Y.R.NormalKind)||!this.isVerticesDataPresent(Y.R.UVKind))return O.V.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var u=this.getVerticesData(Y.R.PositionKind,!0,!0),d=this.getVerticesData(Y.R.NormalKind),h=this.getVerticesData(Y.R.UVKind),p=_.Pq.Zero(),m=_.Pq.Zero(),v=_.I9.Zero();s=s||_.I9.Zero(),l=l||new _.I9(1,1);for(var b=0;b<u.length;b+=3){_.Pq.FromArrayToRef(u,b,p),_.Pq.FromArrayToRef(d,b,m),_.I9.FromArrayToRef(h,b/3*2,v);var E=4*((Math.abs(v.x*l.x+s.x%1)*(n-1)%n|0)+(Math.abs(v.y*l.y+s.y%1)*(i-1)%i|0)*n),C=e[E]/255*.3+e[E+1]/255*.59+e[E+2]/255*.11;m.normalize(),m.scaleInPlace(o+(a-o)*C),(p=p.add(m)).toArray(u,b)}return rt.ComputeNormals(u,this.getIndices(),d),c?(this.setVerticesData(Y.R.PositionKind,u),this.setVerticesData(Y.R.NormalKind,d),this.setVerticesData(Y.R.UVKind,h)):(this.updateVerticesData(Y.R.PositionKind,u),this.updateVerticesData(Y.R.NormalKind,d)),this},t.prototype._getFlattenedNormals=function(e,n){for(var i=new Float32Array(3*e.length),o=0,a=this.sideOrientation===(this._scene.useRightHandedSystem?P.Y.MATERIAL_CounterClockWiseSideOrientation:P.Y.MATERIAL_ClockWiseSideOrientation),s=0;s<e.length;s+=3){var l=_.Pq.FromArray(n,3*e[s]),c=_.Pq.FromArray(n,3*e[s+1]),u=_.Pq.FromArray(n,3*e[s+2]),d=l.subtract(c),h=u.subtract(c),p=_.Pq.Normalize(_.Pq.Cross(d,h));a&&p.scaleInPlace(-1);for(var m=0;m<3;m++)i[o++]=p.x,i[o++]=p.y,i[o++]=p.z}return i},t.prototype._convertToUnIndexedMesh=function(e){var n=this;e===void 0&&(e=!1);for(var i=this.getVerticesDataKinds().filter(function(D){var B;return!(!((B=n.getVertexBuffer(D))===null||B===void 0)&&B.getIsInstanced())}),o=this.getIndices(),a={},s=function(D,B){for(var F=new Float32Array(o.length*B),X=0,$=0;$<o.length;$++)for(var Q=0;Q<B;Q++)F[X++]=D[o[$]*B+Q];return F},l=this.getBoundingInfo(),c=this.geometry?this.subMeshes.slice(0):[],u=0,d=i;u<d.length;u++)a[m=d[u]]=this.getVerticesData(m);for(var h=0,p=i;h<p.length;h++){var m=p[h],v=this.getVertexBuffer(m),b=v.getSize();if(e&&m===Y.R.NormalKind){var E=this._getFlattenedNormals(o,a[Y.R.PositionKind]);this.setVerticesData(Y.R.NormalKind,E,v.isUpdatable(),b)}else this.setVerticesData(m,s(a[m],b),v.isUpdatable(),b)}if(this.morphTargetManager){for(var C=0;C<this.morphTargetManager.numTargets;C++){var T=this.morphTargetManager.getTarget(C),f=T.getPositions();T.setPositions(s(f,3)),(E=T.getNormals())&&T.setNormals(e?this._getFlattenedNormals(o,f):s(E,3));var g=T.getTangents();g&&T.setTangents(s(g,3));var S=T.getUVs();S&&T.setUVs(s(S,2))}this.morphTargetManager.synchronize()}for(var y=0;y<o.length;y++)o[y]=y;this.setIndices(o),this._unIndexed=!0,this.releaseSubMeshes();for(var x=0,R=c;x<R.length;x++){var I=R[x],M=I.getBoundingInfo();yi.AddToMesh(I.materialIndex,I.indexStart,I.indexCount,I.indexStart,I.indexCount,this).setBoundingInfo(M)}return this.setBoundingInfo(l),this.synchronizeInstances(),this},t.prototype.convertToFlatShadedMesh=function(){return this._convertToUnIndexedMesh(!0)},t.prototype.convertToUnIndexedMesh=function(){return this._convertToUnIndexedMesh()},t.prototype.flipFaces=function(e){e===void 0&&(e=!1);var n,i=rt.ExtractFromMesh(this);if(e&&this.isVerticesDataPresent(Y.R.NormalKind)&&i.normals){for(n=0;n<i.normals.length;n++)i.normals[n]*=-1;this.setVerticesData(Y.R.NormalKind,i.normals,this.isVertexBufferUpdatable(Y.R.NormalKind))}if(i.indices){var o=void 0;for(n=0;n<i.indices.length;n+=3)o=i.indices[n+1],i.indices[n+1]=i.indices[n+2],i.indices[n+2]=o;this.setIndices(i.indices,null,this.isVertexBufferUpdatable(Y.R.PositionKind),!0)}return this},t.prototype.increaseVertices=function(e){e===void 0&&(e=1);var n=rt.ExtractFromMesh(this),i=n.indices&&!Array.isArray(n.indices)&&Array.from?Array.from(n.indices):n.indices,o=n.positions&&!Array.isArray(n.positions)&&Array.from?Array.from(n.positions):n.positions,a=n.uvs&&!Array.isArray(n.uvs)&&Array.from?Array.from(n.uvs):n.uvs,s=n.normals&&!Array.isArray(n.normals)&&Array.from?Array.from(n.normals):n.normals;if(i&&o){n.indices=i,n.positions=o,a&&(n.uvs=a),s&&(n.normals=s);for(var l=e+1,c=new Array,u=0;u<l+1;u++)c[u]=new Array;var d=void 0,h=void 0,p=new _.Pq(0,0,0),m=new _.Pq(0,0,0),v=new _.I9(0,0),b=new Array,E=new Array,C=new Array,T=void 0,f=o.length,g=void 0;a&&(g=a.length);var S=void 0;for(s&&(S=s.length),u=0;u<i.length;u+=3){E[0]=i[u],E[1]=i[u+1],E[2]=i[u+2];for(var y=0;y<3;y++)if(d=E[y],h=E[(y+1)%3],C[d]===void 0&&C[h]===void 0?(C[d]=new Array,C[h]=new Array):(C[d]===void 0&&(C[d]=new Array),C[h]===void 0&&(C[h]=new Array)),C[d][h]===void 0&&C[h][d]===void 0){C[d][h]=[],p.x=(o[3*h]-o[3*d])/l,p.y=(o[3*h+1]-o[3*d+1])/l,p.z=(o[3*h+2]-o[3*d+2])/l,s&&(m.x=(s[3*h]-s[3*d])/l,m.y=(s[3*h+1]-s[3*d+1])/l,m.z=(s[3*h+2]-s[3*d+2])/l),a&&(v.x=(a[2*h]-a[2*d])/l,v.y=(a[2*h+1]-a[2*d+1])/l),C[d][h].push(d);for(var x=1;x<l;x++)C[d][h].push(o.length/3),o[f++]=o[3*d]+x*p.x,o[f++]=o[3*d+1]+x*p.y,o[f++]=o[3*d+2]+x*p.z,s&&(s[S++]=s[3*d]+x*m.x,s[S++]=s[3*d+1]+x*m.y,s[S++]=s[3*d+2]+x*m.z),a&&(a[g++]=a[2*d]+x*v.x,a[g++]=a[2*d+1]+x*v.y);C[d][h].push(h),C[h][d]=new Array,T=C[d][h].length;for(var R=0;R<T;R++)C[h][d][R]=C[d][h][T-1-R]}for(c[0][0]=i[u],c[1][0]=C[i[u]][i[u+1]][1],c[1][1]=C[i[u]][i[u+2]][1],x=2;x<l;x++)for(c[x][0]=C[i[u]][i[u+1]][x],c[x][x]=C[i[u]][i[u+2]][x],p.x=(o[3*c[x][x]]-o[3*c[x][0]])/x,p.y=(o[3*c[x][x]+1]-o[3*c[x][0]+1])/x,p.z=(o[3*c[x][x]+2]-o[3*c[x][0]+2])/x,s&&(m.x=(s[3*c[x][x]]-s[3*c[x][0]])/x,m.y=(s[3*c[x][x]+1]-s[3*c[x][0]+1])/x,m.z=(s[3*c[x][x]+2]-s[3*c[x][0]+2])/x),a&&(v.x=(a[2*c[x][x]]-a[2*c[x][0]])/x,v.y=(a[2*c[x][x]+1]-a[2*c[x][0]+1])/x),y=1;y<x;y++)c[x][y]=o.length/3,o[f++]=o[3*c[x][0]]+y*p.x,o[f++]=o[3*c[x][0]+1]+y*p.y,o[f++]=o[3*c[x][0]+2]+y*p.z,s&&(s[S++]=s[3*c[x][0]]+y*m.x,s[S++]=s[3*c[x][0]+1]+y*m.y,s[S++]=s[3*c[x][0]+2]+y*m.z),a&&(a[g++]=a[2*c[x][0]]+y*v.x,a[g++]=a[2*c[x][0]+1]+y*v.y);for(c[l]=C[i[u+1]][i[u+2]],b.push(c[0][0],c[1][0],c[1][1]),x=1;x<l;x++){for(y=void 0,y=0;y<x;y++)b.push(c[x][y],c[x+1][y],c[x+1][y+1]),b.push(c[x][y],c[x+1][y+1],c[x][y+1]);b.push(c[x][y],c[x+1][y],c[x+1][y+1])}}n.indices=b,n.applyToMesh(this,this.isVertexBufferUpdatable(Y.R.PositionKind))}else O.V.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions")},t.prototype.forceSharedVertices=function(){var e=rt.ExtractFromMesh(this),n=e.uvs,i=e.indices,o=e.positions,a=e.colors,s=e.matricesIndices,l=e.matricesWeights,c=e.matricesIndicesExtra,u=e.matricesWeightsExtra;if(i===void 0||o===void 0||i===null||o===null)O.V.Warn("VertexData contains empty entries");else{for(var d=new Array,h=new Array,p=new Array,m=new Array,v=new Array,b=new Array,E=new Array,C=new Array,T=new Array,f=0,g={},S=void 0,y=void 0,x=0;x<i.length;x+=3){y=[i[x],i[x+1],i[x+2]],T=[];for(var R=0;R<3;R++){T[R]="";for(var I=0;I<3;I++)Math.abs(o[3*y[R]+I])<1e-8&&(o[3*y[R]+I]=0),T[R]+=o[3*y[R]+I]+"|"}if(T[0]!=T[1]&&T[0]!=T[2]&&T[1]!=T[2])for(R=0;R<3;R++){if((S=g[T[R]])===void 0){for(g[T[R]]=f,S=f++,I=0;I<3;I++)d.push(o[3*y[R]+I]);if(a!=null)for(I=0;I<4;I++)m.push(a[4*y[R]+I]);if(n!=null)for(I=0;I<2;I++)p.push(n[2*y[R]+I]);if(s!=null)for(I=0;I<4;I++)v.push(s[4*y[R]+I]);if(l!=null)for(I=0;I<4;I++)b.push(l[4*y[R]+I]);if(c!=null)for(I=0;I<4;I++)E.push(c[4*y[R]+I]);if(u!=null)for(I=0;I<4;I++)C.push(u[4*y[R]+I])}h.push(S)}}var M=new Array;rt.ComputeNormals(d,h,M),e.positions=d,e.indices=h,e.normals=M,n!=null&&(e.uvs=p),a!=null&&(e.colors=m),s!=null&&(e.matricesIndices=v),l!=null&&(e.matricesWeights=b),c!=null&&(e.matricesIndicesExtra=E),l!=null&&(e.matricesWeightsExtra=C),e.applyToMesh(this,this.isVertexBufferUpdatable(Y.R.PositionKind))}},t._instancedMeshFactory=function(e,n){throw(0,gt.n)("InstancedMesh")},t._PhysicsImpostorParser=function(e,n,i){throw(0,gt.n)("PhysicsImpostor")},t.prototype.createInstance=function(e){return t._instancedMeshFactory(e,this)},t.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++)this.instances[e]._syncSubMeshes();return this},t.prototype.optimizeIndices=function(e){var n=this,i=this.getIndices(),o=this.getVerticesData(Y.R.PositionKind);if(!o||!i)return this;for(var a=[],s=0;s<o.length;s+=3)a.push(_.Pq.FromArray(o,s));var l=[];return ze.LV.SyncAsyncForLoop(a.length,40,function(c){for(var u=a.length-1-c,d=a[u],h=0;h<u;++h){var p=a[h];if(d.equals(p)){l[u]=h;break}}},function(){for(var c=0;c<i.length;++c)i[c]=l[i[c]]||i[c];var u=n.subMeshes.slice(0);n.setIndices(i),n.subMeshes=u,e&&e(n)}),this},t.prototype.serialize=function(e){e===void 0&&(e={}),e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),En.Y&&En.Y.HasTags(this)&&(e.tags=En.Y.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.parent&&this.parent._serializeAsParent(e),e.isUnIndexed=this.isUnIndexed;var n=this._geometry;if(n&&this.subMeshes){e.geometryUniqueId=n.uniqueId,e.geometryId=n.id,e.subMeshes=[];for(var i=0;i<this.subMeshes.length;i++){var o=this.subMeshes[i];e.subMeshes.push({materialIndex:o.materialIndex,verticesStart:o.verticesStart,verticesCount:o.verticesCount,indexStart:o.indexStart,indexCount:o.indexCount})}}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.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(lt.v.NAME_PHYSICSENGINE)&&(l=this.getPhysicsImpostor())&&(e.physicsMass=l.getParam("mass"),e.physicsFriction=l.getParam("friction"),e.physicsRestitution=l.getParam("mass"),e.physicsImpostor=l.type),this.metadata&&(e.metadata=this.metadata),e.instances=[];for(var a=0;a<this.instances.length;a++){var s=this.instances[a];if(!s.doNotSerialize){var l,c={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()};s.parent&&s.parent._serializeAsParent(c),s.rotationQuaternion?c.rotationQuaternion=s.rotationQuaternion.asArray():s.rotation&&(c.rotation=s.rotation.asArray()),this.getScene()._getComponent(lt.v.NAME_PHYSICSENGINE)&&(l=s.getPhysicsImpostor())&&(c.physicsMass=l.getParam("mass"),c.physicsFriction=l.getParam("friction"),c.physicsRestitution=l.getParam("mass"),c.physicsImpostor=l.type),s.metadata&&(c.metadata=s.metadata),s.actionManager&&(c.actions=s.actionManager.serialize(s.name)),e.instances.push(c),tt.p.AppendSerializedAnimations(s,c),c.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)){var u={data:{},sizes:{},strides:{}};for(var d in this._userThinInstanceBuffersStorage.data)u.data[d]=Array.from(this._userThinInstanceBuffersStorage.data[d]),u.sizes[d]=this._userThinInstanceBuffersStorage.sizes[d],u.strides[d]=this._userThinInstanceBuffersStorage.strides[d];e.thinInstances.userThinInstance=u}return tt.p.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},t.prototype._syncGeometryWithMorphTargetManager=function(){if(this.geometry){this._markSubMeshesAsAttributesDirty();var e=this._internalAbstractMeshDataInfo._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices())return O.V.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=null);if(e.isUsingTextureForTargets)return;for(var n=0;n<e.numInfluencers;n++){var i=e.getActiveTarget(n),o=i.getPositions();if(!o)return void O.V.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(Y.R.PositionKind+n,o,!1,3);var a=i.getNormals();a&&this.geometry.setVerticesData(Y.R.NormalKind+n,a,!1,3);var s=i.getTangents();s&&this.geometry.setVerticesData(Y.R.TangentKind+n,s,!1,3);var l=i.getUVs();l&&this.geometry.setVerticesData(Y.R.UVKind+"_"+n,l,!1,2)}}else for(n=0;this.geometry.isVerticesDataPresent(Y.R.PositionKind+n);)this.geometry.removeVerticesData(Y.R.PositionKind+n),this.geometry.isVerticesDataPresent(Y.R.NormalKind+n)&&this.geometry.removeVerticesData(Y.R.NormalKind+n),this.geometry.isVerticesDataPresent(Y.R.TangentKind+n)&&this.geometry.removeVerticesData(Y.R.TangentKind+n),this.geometry.isVerticesDataPresent(Y.R.UVKind+n)&&this.geometry.removeVerticesData(Y.R.UVKind+"_"+n),n++}},t.Parse=function(e,n,i){var o;if((o=e.type&&e.type==="LinesMesh"?t._LinesMeshParser(e,n):e.type&&e.type==="GroundMesh"?t._GroundMeshParser(e,n):e.type&&e.type==="GoldbergMesh"?t._GoldbergMeshParser(e,n):e.type&&e.type==="GreasedLineMesh"?t._GreasedLineMeshParser(e,n):e.type&&e.type==="TrailMesh"?t._TrailMeshParser(e,n):new t(e.name,n)).id=e.id,o._waitingParsedUniqueId=e.uniqueId,En.Y&&En.Y.AddTagsTo(o,e.tags),o.position=_.Pq.FromArray(e.position),e.metadata!==void 0&&(o.metadata=e.metadata),e.rotationQuaternion?o.rotationQuaternion=_.PT.FromArray(e.rotationQuaternion):e.rotation&&(o.rotation=_.Pq.FromArray(e.rotation)),o.scaling=_.Pq.FromArray(e.scaling),e.localMatrix?o.setPreTransformMatrix(_.uq.FromArray(e.localMatrix)):e.pivotMatrix&&o.setPivotMatrix(_.uq.FromArray(e.pivotMatrix)),o.setEnabled(e.isEnabled),o.isVisible=e.isVisible,o.infiniteDistance=e.infiniteDistance,o.alwaysSelectAsActiveMesh=!!e.alwaysSelectAsActiveMesh,o.showBoundingBox=e.showBoundingBox,o.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,e.applyFog!==void 0&&(o.applyFog=e.applyFog),e.pickable!==void 0&&(o.isPickable=e.pickable),e.alphaIndex!==void 0&&(o.alphaIndex=e.alphaIndex),o.receiveShadows=e.receiveShadows,e.billboardMode!==void 0&&(o.billboardMode=e.billboardMode),e.visibility!==void 0&&(o.visibility=e.visibility),o.checkCollisions=e.checkCollisions,o.doNotSyncBoundingInfo=!!e.doNotSyncBoundingInfo,e.ellipsoid&&(o.ellipsoid=_.Pq.FromArray(e.ellipsoid)),e.ellipsoidOffset&&(o.ellipsoidOffset=_.Pq.FromArray(e.ellipsoidOffset)),e.overrideMaterialSideOrientation!=null&&(o.sideOrientation=e.overrideMaterialSideOrientation),e.sideOrientation!==void 0&&(o.sideOrientation=e.sideOrientation),e.isBlocker!==void 0&&(o.isBlocker=e.isBlocker),o._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(o._waitingData.freezeWorldMatrix=e.freezeWorldMatrix),e.parentId!==void 0&&(o._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(o._waitingParentInstanceIndex=e.parentInstanceIndex),e.actions!==void 0&&(o._waitingData.actions=e.actions),e.overlayAlpha!==void 0&&(o.overlayAlpha=e.overlayAlpha),e.overlayColor!==void 0&&(o.overlayColor=z.v9.FromArray(e.overlayColor)),e.renderOverlay!==void 0&&(o.renderOverlay=e.renderOverlay),o.isUnIndexed=!!e.isUnIndexed,o.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(o.delayLoadState=P.Y.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=i+e.delayLoadingFile,o.buildBoundingInfo(_.Pq.FromArray(e.boundingBoxMinimum),_.Pq.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(o._binaryInfo=e._binaryInfo),o._delayInfo=[],e.hasUVs&&o._delayInfo.push(Y.R.UVKind),e.hasUVs2&&o._delayInfo.push(Y.R.UV2Kind),e.hasUVs3&&o._delayInfo.push(Y.R.UV3Kind),e.hasUVs4&&o._delayInfo.push(Y.R.UV4Kind),e.hasUVs5&&o._delayInfo.push(Y.R.UV5Kind),e.hasUVs6&&o._delayInfo.push(Y.R.UV6Kind),e.hasColors&&o._delayInfo.push(Y.R.ColorKind),e.hasMatricesIndices&&o._delayInfo.push(Y.R.MatricesIndicesKind),e.hasMatricesWeights&&o._delayInfo.push(Y.R.MatricesWeightsKind),o._delayLoadingFunction=Vi._ImportGeometry,pr.ForceFullSceneLoadingForIncremental&&o._checkDelayState()):Vi._ImportGeometry(e,o),e.materialUniqueId?o._waitingMaterialId=e.materialUniqueId:e.materialId&&(o._waitingMaterialId=e.materialId),e.morphTargetManagerId>-1&&(o.morphTargetManager=n.getMorphTargetManagerById(e.morphTargetManagerId)),e.skeletonId!==void 0&&e.skeletonId!==null&&(o.skeleton=n.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(o.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var a=0;a<e.animations.length;a++){var s=e.animations[a];(d=(0,j.n9)("BABYLON.Animation"))&&o.animations.push(d.Parse(s))}At.ParseAnimationRanges(o,e,n)}if(e.autoAnimate&&n.beginAnimation(o,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?o.layerMask=Math.abs(parseInt(e.layerMask)):o.layerMask=268435455,e.physicsImpostor&&(o.physicsImpostor=t._PhysicsImpostorParser(n,o,e)),e.lodMeshIds&&(o._waitingData.lods={ids:e.lodMeshIds,distances:e.lodDistances?e.lodDistances:null,coverages:e.lodCoverages?e.lodCoverages:null}),e.instances)for(var l=0;l<e.instances.length;l++){var c=e.instances[l],u=o.createInstance(c.name);if(c.id&&(u.id=c.id),En.Y&&(c.tags?En.Y.AddTagsTo(u,c.tags):En.Y.AddTagsTo(u,e.tags)),u.position=_.Pq.FromArray(c.position),c.metadata!==void 0&&(u.metadata=c.metadata),c.parentId!==void 0&&(u._waitingParentId=c.parentId),c.parentInstanceIndex!==void 0&&(u._waitingParentInstanceIndex=c.parentInstanceIndex),c.isEnabled!==void 0&&c.isEnabled!==null&&u.setEnabled(c.isEnabled),c.isVisible!==void 0&&c.isVisible!==null&&(u.isVisible=c.isVisible),c.isPickable!==void 0&&c.isPickable!==null&&(u.isPickable=c.isPickable),c.rotationQuaternion?u.rotationQuaternion=_.PT.FromArray(c.rotationQuaternion):c.rotation&&(u.rotation=_.Pq.FromArray(c.rotation)),u.scaling=_.Pq.FromArray(c.scaling),c.checkCollisions!=null&&c.checkCollisions!=null&&(u.checkCollisions=c.checkCollisions),c.pickable!=null&&c.pickable!=null&&(u.isPickable=c.pickable),c.showBoundingBox!=null&&c.showBoundingBox!=null&&(u.showBoundingBox=c.showBoundingBox),c.showSubMeshesBoundingBox!=null&&c.showSubMeshesBoundingBox!=null&&(u.showSubMeshesBoundingBox=c.showSubMeshesBoundingBox),c.alphaIndex!=null&&c.showSubMeshesBoundingBox!=null&&(u.alphaIndex=c.alphaIndex),c.physicsImpostor&&(u.physicsImpostor=t._PhysicsImpostorParser(n,u,c)),c.actions!==void 0&&(u._waitingData.actions=c.actions),c.animations){for(a=0;a<c.animations.length;a++){var d;s=c.animations[a],(d=(0,j.n9)("BABYLON.Animation"))&&u.animations.push(d.Parse(s))}At.ParseAnimationRanges(u,c,n),c.autoAnimate&&n.beginAnimation(u,c.autoAnimateFrom,c.autoAnimateTo,c.autoAnimateLoop,c.autoAnimateSpeed||1)}}if(e.thinInstances){var h=e.thinInstances;if(o.thinInstanceEnablePicking=!!h.enablePicking,h.matrixData?(o.thinInstanceSetBuffer("matrix",new Float32Array(h.matrixData),16,!1),o._thinInstanceDataStorage.matrixBufferSize=h.matrixBufferSize,o._thinInstanceDataStorage.instancesCount=h.instancesCount):o._thinInstanceDataStorage.matrixBufferSize=h.matrixBufferSize,e.thinInstances.userThinInstance){var p=e.thinInstances.userThinInstance;for(var m in p.data)o.thinInstanceSetBuffer(m,new Float32Array(p.data[m]),p.strides[m],!1),o._userThinInstanceBuffersStorage.sizes[m]=p.sizes[m]}}return o},t.prototype.setPositionsForCPUSkinning=function(){var e=this._internalMeshDataInfo;if(!e._sourcePositions){var n=this.getVerticesData(Y.R.PositionKind);if(!n)return e._sourcePositions;e._sourcePositions=new Float32Array(n),this.isVertexBufferUpdatable(Y.R.PositionKind)||this.setVerticesData(Y.R.PositionKind,n,!0)}return e._sourcePositions},t.prototype.setNormalsForCPUSkinning=function(){var e=this._internalMeshDataInfo;if(!e._sourceNormals){var n=this.getVerticesData(Y.R.NormalKind);if(!n)return e._sourceNormals;e._sourceNormals=new Float32Array(n),this.isVertexBufferUpdatable(Y.R.NormalKind)||this.setVerticesData(Y.R.NormalKind,n,!0)}return e._sourceNormals},t.prototype.applySkeleton=function(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(Y.R.PositionKind))return this;if(!this.isVerticesDataPresent(Y.R.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(Y.R.MatricesWeightsKind))return this;var n=this.isVerticesDataPresent(Y.R.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){var o=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=o}n&&!i._sourceNormals&&this.setNormalsForCPUSkinning();var a=this.getVerticesData(Y.R.PositionKind);if(!a)return this;a instanceof Float32Array||(a=new Float32Array(a));var s=this.getVerticesData(Y.R.NormalKind);if(n){if(!s)return this;s instanceof Float32Array||(s=new Float32Array(s))}var l=this.getVerticesData(Y.R.MatricesIndicesKind),c=this.getVerticesData(Y.R.MatricesWeightsKind);if(!c||!l)return this;for(var u,d=this.numBoneInfluencers>4,h=d?this.getVerticesData(Y.R.MatricesIndicesExtraKind):null,p=d?this.getVerticesData(Y.R.MatricesWeightsExtraKind):null,m=e.getTransformMatrices(this),v=_.Pq.Zero(),b=new _.uq,E=new _.uq,C=0,T=0;T<a.length;T+=3,C+=4){var f=void 0;for(u=0;u<4;u++)(f=c[C+u])>0&&(_.uq.FromFloat32ArrayToRefScaled(m,Math.floor(16*l[C+u]),f,E),b.addToSelf(E));if(d)for(u=0;u<4;u++)(f=p[C+u])>0&&(_.uq.FromFloat32ArrayToRefScaled(m,Math.floor(16*h[C+u]),f,E),b.addToSelf(E));_.Pq.TransformCoordinatesFromFloatsToRef(i._sourcePositions[T],i._sourcePositions[T+1],i._sourcePositions[T+2],b,v),v.toArray(a,T),n&&(_.Pq.TransformNormalFromFloatsToRef(i._sourceNormals[T],i._sourceNormals[T+1],i._sourceNormals[T+2],b,v),v.toArray(s,T)),b.reset()}return this.updateVerticesData(Y.R.PositionKind,a),n&&this.updateVerticesData(Y.R.NormalKind,s),this},t.MinMax=function(e){var n=null,i=null;return e.forEach(function(o){var a=o.getBoundingInfo().boundingBox;n&&i?(n.minimizeInPlace(a.minimumWorld),i.maximizeInPlace(a.maximumWorld)):(n=a.minimumWorld,i=a.maximumWorld)}),n&&i?{min:n,max:i}:{min:_.Pq.Zero(),max:_.Pq.Zero()}},t.Center=function(e){var n=e instanceof Array?t.MinMax(e):e;return _.Pq.Center(n.min,n.max)},t.MergeMeshes=function(e,n,i,o,a,s){return n===void 0&&(n=!0),As(t._MergeMeshesCoroutine(e,n,i,o,a,s,!1))},t.MergeMeshesAsync=function(e,n,i,o,a,s){return n===void 0&&(n=!0),Cs(t._MergeMeshesCoroutine(e,n,i,o,a,s,!0),Y_())},t._MergeMeshesCoroutine=function(e,n,i,o,a,s,l){var c,u,d,h,p,m,v,b,E,C,T,f,g,S,y,x,R,I,M,D,B,F,X,$,Q,ie;return n===void 0&&(n=!0),(0,A.YH)(this,function(q){switch(q.label){case 0:if((e=e.filter(Boolean)).length===0)return[2,null];if(!i){for(u=0,c=0;c<e.length;c++)if((u+=e[c].getTotalVertices())>=65536)return O.V.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),[2,null]}for(s&&(a=!1),d=new Array,h=new Array,p=new Array,m=e[0].sideOrientation,c=0;c<e.length;c++){if((v=e[c]).isAnInstance)return O.V.Warn("Cannot merge instance meshes."),[2,null];if(m!==v.sideOrientation)return O.V.Warn("Cannot merge meshes with different sideOrientation values."),[2,null];if(a&&p.push(v.getTotalIndices()),s)if(v.material)if((b=v.material)instanceof Vr){for(E=0;E<b.subMaterials.length;E++)d.indexOf(b.subMaterials[E])<0&&d.push(b.subMaterials[E]);for(Q=0;Q<v.subMeshes.length;Q++)h.push(d.indexOf(b.subMaterials[v.subMeshes[Q].materialIndex])),p.push(v.subMeshes[Q].indexCount)}else for(d.indexOf(b)<0&&d.push(b),Q=0;Q<v.subMeshes.length;Q++)h.push(d.indexOf(b)),p.push(v.subMeshes[Q].indexCount);else for(Q=0;Q<v.subMeshes.length;Q++)h.push(0),p.push(v.subMeshes[Q].indexCount)}return C=e[0],T=function(ee){var te=ee.computeWorldMatrix(!0);return{vertexData:rt.ExtractFromMesh(ee,!1,!1),transform:te}},ie=T(C),f=ie.vertexData,g=ie.transform,l?[4]:[3,2];case 1:q.sent(),q.label=2;case 2:S=new Array(e.length-1),y=1,q.label=3;case 3:return y<e.length?(S[y-1]=T(e[y]),l?[4]:[3,5]):[3,6];case 4:q.sent(),q.label=5;case 5:return y++,[3,3];case 6:x=f._mergeCoroutine(g,S,i,l,!n),R=x.next(),q.label=7;case 7:return R.done?[3,10]:l?[4]:[3,9];case 8:q.sent(),q.label=9;case 9:return R=x.next(),[3,7];case 10:I=R.value,o||(o=new t(C.name+"_merged",C.getScene())),M=I._applyToCoroutine(o,void 0,l),D=M.next(),q.label=11;case 11:return D.done?[3,14]:l?[4]:[3,13];case 12:q.sent(),q.label=13;case 13:return D=M.next(),[3,11];case 14:if(o.checkCollisions=C.checkCollisions,o.sideOrientation=C.sideOrientation,n)for(c=0;c<e.length;c++)e[c].dispose();if(a||s){for(o.releaseSubMeshes(),c=0,B=0;c<p.length;)yi.CreateFromIndices(0,B,p[c],o,void 0,!1),B+=p[c],c++;for(F=0,X=o.subMeshes;F<X.length;F++)X[F].refreshBoundingInfo();o.computeWorldMatrix(!0)}if(s){for(($=new Vr(C.name+"_merged",C.getScene())).subMaterials=d,Q=0;Q<o.subMeshes.length;Q++)o.subMeshes[Q].materialIndex=h[Q];o.material=$}else o.material=C.material;return[2,o]}})},t.prototype.addInstance=function(e){e._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(e)},t.prototype.removeInstance=function(e){var n=e._indexInSourceMeshInstanceArray;if(n!=-1){if(n!==this.instances.length-1){var i=this.instances[this.instances.length-1];this.instances[n]=i,i._indexInSourceMeshInstanceArray=n}e._indexInSourceMeshInstanceArray=-1,this.instances.pop()}},t.prototype._shouldConvertRHS=function(){return this._scene.useRightHandedSystem&&this.sideOrientation===Lt.CounterClockWiseSideOrientation},t.prototype._getRenderingFillMode=function(e){var n,i=this.getScene();return i.forcePointsCloud?Lt.PointFillMode:i.forceWireframe?Lt.WireFrameFillMode:(n=this.overrideRenderingFillMode)!==null&&n!==void 0?n:e},t.prototype.setMaterialByID=function(e){return this.setMaterialById(e)},t.CreateRibbon=function(e,n,i,o,a,s,l,c,u){throw new Error("Import MeshBuilder to populate this function")},t.CreateDisc=function(e,n,i,o,a,s){throw new Error("Import MeshBuilder to populate this function")},t.CreateBox=function(e,n,i,o,a){throw new Error("Import MeshBuilder to populate this function")},t.CreateSphere=function(e,n,i,o,a,s){throw new Error("Import MeshBuilder to populate this function")},t.CreateHemisphere=function(e,n,i,o){throw new Error("Import MeshBuilder to populate this function")},t.CreateCylinder=function(e,n,i,o,a,s,l,c,u){throw new Error("Import MeshBuilder to populate this function")},t.CreateTorus=function(e,n,i,o,a,s,l){throw new Error("Import MeshBuilder to populate this function")},t.CreateTorusKnot=function(e,n,i,o,a,s,l,c,u,d){throw new Error("Import MeshBuilder to populate this function")},t.CreateLines=function(e,n,i,o,a){throw new Error("Import MeshBuilder to populate this function")},t.CreateDashedLines=function(e,n,i,o,a,s,l,c){throw new Error("Import MeshBuilder to populate this function")},t.CreatePolygon=function(e,n,i,o,a,s,l){throw new Error("Import MeshBuilder to populate this function")},t.ExtrudePolygon=function(e,n,i,o,a,s,l,c){throw new Error("Import MeshBuilder to populate this function")},t.ExtrudeShape=function(e,n,i,o,a,s,l,c,u,d){throw new Error("Import MeshBuilder to populate this function")},t.ExtrudeShapeCustom=function(e,n,i,o,a,s,l,c,u,d,h,p){throw new Error("Import MeshBuilder to populate this function")},t.CreateLathe=function(e,n,i,o,a,s,l){throw new Error("Import MeshBuilder to populate this function")},t.CreatePlane=function(e,n,i,o,a){throw new Error("Import MeshBuilder to populate this function")},t.CreateGround=function(e,n,i,o,a,s){throw new Error("Import MeshBuilder to populate this function")},t.CreateTiledGround=function(e,n,i,o,a,s,l,c,u){throw new Error("Import MeshBuilder to populate this function")},t.CreateGroundFromHeightMap=function(e,n,i,o,a,s,l,c,u,d,h){throw new Error("Import MeshBuilder to populate this function")},t.CreateTube=function(e,n,i,o,a,s,l,c,u,d){throw new Error("Import MeshBuilder to populate this function")},t.CreatePolyhedron=function(e,n,i){throw new Error("Import MeshBuilder to populate this function")},t.CreateIcoSphere=function(e,n,i){throw new Error("Import MeshBuilder to populate this function")},t.CreateDecal=function(e,n,i,o,a,s){throw new Error("Import MeshBuilder to populate this function")},t.CreateCapsule=function(e,n,i){throw new Error("Import MeshBuilder to populate this function")},t.ExtendToGoldberg=function(e){throw new Error("Import MeshBuilder to populate this function")},t.FRONTSIDE=rt.FRONTSIDE,t.BACKSIDE=rt.BACKSIDE,t.DOUBLESIDE=rt.DOUBLESIDE,t.DEFAULTSIDE=rt.DEFAULTSIDE,t.NO_CAP=0,t.CAP_START=1,t.CAP_END=2,t.CAP_ALL=3,t.NO_FLIP=0,t.FLIP_TILE=1,t.ROTATE_TILE=2,t.FLIP_ROW=3,t.ROTATE_ROW=4,t.FLIP_N_ROTATE_TILE=5,t.FLIP_N_ROTATE_ROW=6,t.CENTER=0,t.LEFT=1,t.RIGHT=2,t.TOP=3,t.BOTTOM=4,t.INSTANCEDMESH_SORT_TRANSPARENT=!1,t._GroundMeshParser=function(e,n){throw(0,gt.n)("GroundMesh")},t._GoldbergMeshParser=function(e,n){throw(0,gt.n)("GoldbergMesh")},t._LinesMeshParser=function(e,n){throw(0,gt.n)("LinesMesh")},t._GreasedLineMeshParser=function(e,n){throw(0,gt.n)("GreasedLineMesh")},t._GreasedLineRibbonMeshParser=function(e,n){throw(0,gt.n)("GreasedLineRibbonMesh")},t._TrailMeshParser=function(e,n){throw(0,gt.n)("TrailMesh")},t}(cn);(0,j.Y5)("BABYLON.Mesh",xe),xe._instancedMeshFactory=function(r,t){var e=new Co(r,t);if(t.instancedBuffers)for(var n in e.instancedBuffers={},t.instancedBuffers)e.instancedBuffers[n]=t.instancedBuffers[n];return e};var Co=function(r){function t(e,n){var i=r.call(this,e,n.getScene())||this;i._indexInSourceMeshInstanceArray=-1,i._distanceToCamera=0,n.addInstance(i),i._sourceMesh=n,i._unIndexed=n._unIndexed,i.position.copyFrom(n.position),i.rotation.copyFrom(n.rotation),i.scaling.copyFrom(n.scaling),n.rotationQuaternion&&(i.rotationQuaternion=n.rotationQuaternion.clone()),i.animations=n.animations.slice();for(var o=0,a=n.getAnimationRanges();o<a.length;o++){var s=a[o];s!=null&&i.createAnimationRange(s.name,s.from,s.to)}return i.infiniteDistance=n.infiniteDistance,i.setPivotMatrix(n.getPivotMatrix()),i.refreshBoundingInfo(!0,!0),i._syncSubMeshes(),i}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._sourceMesh._lightSources},enumerable:!1,configurable:!0}),t.prototype._resyncLightSources=function(){},t.prototype._resyncLightSource=function(){},t.prototype._removeLightSource=function(){},Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},set:function(e){var n;((n=this._sourceMesh)===null||n===void 0?void 0:n.receiveShadows)!==e&&ze.S0.Warn("Setting receiveShadows on an instanced mesh has no effect")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._sourceMesh.material},set:function(e){var n;((n=this._sourceMesh)===null||n===void 0?void 0:n.material)!==e&&ze.S0.Warn("Setting material on an instanced mesh has no effect")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},set:function(e){var n;((n=this._sourceMesh)===null||n===void 0?void 0:n.visibility)!==e&&ze.S0.Warn("Setting visibility on an instanced mesh has no effect")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},set:function(e){var n;((n=this._sourceMesh)===null||n===void 0?void 0:n.skeleton)!==e&&ze.S0.Warn("Setting skeleton on an instanced mesh has no effect")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},set:function(e){this._sourceMesh&&e!==this._sourceMesh.renderingGroupId&&O.V.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")},enumerable:!1,configurable:!0}),t.prototype.getTotalVertices=function(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0},t.prototype.getTotalIndices=function(){return this._sourceMesh.getTotalIndices()},Object.defineProperty(t.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!1,configurable:!0}),t.prototype.createInstance=function(e){return this._sourceMesh.createInstance(e)},t.prototype.isReady=function(e){return e===void 0&&(e=!1),this._sourceMesh.isReady(e,!0)},t.prototype.getVerticesData=function(e,n,i){return this._sourceMesh.getVerticesData(e,n,i)},t.prototype.copyVerticesData=function(e,n){this._sourceMesh.copyVerticesData(e,n)},t.prototype.setVerticesData=function(e,n,i,o){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,n,i,o),this.sourceMesh},t.prototype.updateVerticesData=function(e,n,i,o){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,n,i,o),this.sourceMesh},t.prototype.setIndices=function(e,n){return n===void 0&&(n=null),this.sourceMesh&&this.sourceMesh.setIndices(e,n),this.sourceMesh},t.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},t.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(t.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!1,configurable:!0}),t.prototype.refreshBoundingInfo=function(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=!1),this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;var i;i=typeof e=="object"?e:{applySkeleton:e,applyMorph:n};var o=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(i,null,Y.R.PositionKind),o),this},t.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},t.prototype._activate=function(e,n){if(r.prototype._activate.call(this,e,n),this._sourceMesh.subMeshes||O.V.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>=0!=this._getWorldMatrixDeterminant()>=0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),n){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},t.prototype._postActivate=function(){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)},t.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==jt.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new _.uq);var e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,_.AA.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(_.AA.Vector3[7]),this._currentLOD._masterMesh=e,this._billboardWorldMatrix}return r.prototype.getWorldMatrix.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.getLOD=function(e){if(!e)return this;var n=this.sourceMesh.getLODLevels();if(n&&n.length!==0){var i=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,i.boundingSphere)}else this._currentLOD=this.sourceMesh;return this._currentLOD},t.prototype._preActivateForIntermediateRendering=function(e){return this.sourceMesh._preActivateForIntermediateRendering(e)},t.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this},t.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},t.prototype._updateBoundingInfo=function(){return this.hasBoundingInfo?this.getBoundingInfo().update(this.worldMatrixFromCache):this.buildBoundingInfo(this.absolutePosition,this.absolutePosition,this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this},t.prototype.clone=function(e,n,i,o){n===void 0&&(n=null);var a=(o||this._sourceMesh).createInstance(e);if(ot.r.DeepCopy(this,a,["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"],[]),this.refreshBoundingInfo(),n&&(a.parent=n),!i)for(var s=0;s<this.getScene().meshes.length;s++){var l=this.getScene().meshes[s];l.parent===this&&l.clone(l.name,a)}return a.computeWorldMatrix(!0),this.onClonedObservable.notifyObservers(a),a},t.prototype.dispose=function(e,n){n===void 0&&(n=!1),this._sourceMesh.removeInstance(this),r.prototype.dispose.call(this,e,n)},t.prototype._serializeAsParent=function(e){r.prototype._serializeAsParent.call(this,e),e.parentId=this._sourceMesh.uniqueId,e.parentInstanceIndex=this._indexInSourceMeshInstanceArray},t.prototype.instantiateHierarchy=function(e,n,i){e===void 0&&(e=null);var o=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0,n&&n.newSourcedMesh);o&&i&&i(this,o);for(var a=0,s=this.getChildTransformNodes(!0);a<s.length;a++)s[a].instantiateHierarchy(o,n,i);return o},t}(cn);xe.prototype.registerInstancedBuffer=function(r,t){var e,n;if((n=(e=this._userInstancedBuffersStorage)===null||e===void 0?void 0:e.vertexBuffers[r])===null||n===void 0||n.dispose(),!this.instancedBuffers){this.instancedBuffers={};for(var i=0,o=this.instances;i<o.length;i++)o[i].instancedBuffers={}}this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0}),this.instancedBuffers[r]=null,this._userInstancedBuffersStorage.strides[r]=t,this._userInstancedBuffersStorage.sizes[r]=32*t,this._userInstancedBuffersStorage.data[r]=new Float32Array(this._userInstancedBuffersStorage.sizes[r]),this._userInstancedBuffersStorage.vertexBuffers[r]=new Y.R(this.getEngine(),this._userInstancedBuffersStorage.data[r],r,!0,!1,t,!0);for(var a=0,s=this.instances;a<s.length;a++)s[a].instancedBuffers[r]=null;this._invalidateInstanceVertexArrayObject(),this._markSubMeshesAsAttributesDirty()},xe.prototype._processInstancedBuffers=function(r,t){var e=r?r.length:0;for(var n in this.instancedBuffers){for(var i=this._userInstancedBuffersStorage.sizes[n],o=this._userInstancedBuffersStorage.strides[n],a=(e+1)*o;i<a;)i*=2;this._userInstancedBuffersStorage.data[n].length!=i&&(this._userInstancedBuffersStorage.data[n]=new Float32Array(i),this._userInstancedBuffersStorage.sizes[n]=i,this._userInstancedBuffersStorage.vertexBuffers[n]&&(this._userInstancedBuffersStorage.vertexBuffers[n].dispose(),this._userInstancedBuffersStorage.vertexBuffers[n]=null));var s=this._userInstancedBuffersStorage.data[n],l=0;t&&((u=this.instancedBuffers[n]).toArray?u.toArray(s,l):u.copyToArray?u.copyToArray(s,l):s[l]=u,l+=o);for(var c=0;c<e;c++){var u;(u=r[c].instancedBuffers[n]).toArray?u.toArray(s,l):u.copyToArray?u.copyToArray(s,l):s[l]=u,l+=o}this._userInstancedBuffersStorage.vertexBuffers[n]?this._userInstancedBuffersStorage.vertexBuffers[n].updateDirectly(s,0):(this._userInstancedBuffersStorage.vertexBuffers[n]=new Y.R(this.getEngine(),this._userInstancedBuffersStorage.data[n],n,!0,!1,o,!0),this._invalidateInstanceVertexArrayObject())}},xe.prototype._invalidateInstanceVertexArrayObject=function(){if(this._userInstancedBuffersStorage&&this._userInstancedBuffersStorage.vertexArrayObjects!==void 0){for(var r in this._userInstancedBuffersStorage.vertexArrayObjects)this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[r]);this._userInstancedBuffersStorage.vertexArrayObjects={}}},xe.prototype._disposeInstanceSpecificData=function(){for(this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(var r in this.instancedBuffers)this._userInstancedBuffersStorage.vertexBuffers[r]&&this._userInstancedBuffersStorage.vertexBuffers[r].dispose();this._invalidateInstanceVertexArrayObject(),this.instancedBuffers={}},(0,j.Y5)("BABYLON.InstancedMesh",Co);var Ri=L(91946),hi=function(r){function t(e,n){var i=r.call(this,e,n,!1)||this;return i.diffuse=new z.v9(1,1,1),i.specular=new z.v9(1,1,1),i.falloffType=t.FALLOFF_DEFAULT,i.intensity=1,i._range=Number.MAX_VALUE,i._inverseSquaredRange=0,i._photometricScale=1,i._intensityMode=t.INTENSITYMODE_AUTOMATIC,i._radius=1e-5,i.renderPriority=0,i._shadowEnabled=!0,i._excludeWithLayerMask=0,i._includeOnlyWithLayerMask=0,i._lightmapMode=0,i._shadowGenerators=null,i._excludedMeshesIds=new Array,i._includedOnlyMeshesIds=new Array,i._isLight=!0,i.getScene().addLight(i),i._uniformBuffer=new Ui.D(i.getScene().getEngine(),void 0,void 0,e),i._buildUniformLayout(),i.includedOnlyMeshes=[],i.excludedMeshes=[],i._resyncMeshes(),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"range",{get:function(){return this._range},set:function(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowEnabled",{get:function(){return this._shadowEnabled},set:function(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),t.prototype.getViewMatrix=function(e){return null},t.prototype.getProjectionMatrix=function(e,n){return null},t.prototype.transferTexturesToEffect=function(e,n){return this},t.prototype._bindLight=function(e,n,i,o,a){var s;a===void 0&&(a=!0);var l=e.toString(),c=!1;if(this._uniformBuffer.bindToEffect(i,"Light"+l),this._renderId!==n.getRenderId()||this._lastUseSpecular!==o||!this._uniformBuffer.useUbo){this._renderId=n.getRenderId(),this._lastUseSpecular=o;var u=this.getScaledIntensity();this.transferToEffect(i,l),this.diffuse.scaleToRef(u,z.IG.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",z.IG.Color3[0],this.range,l),o&&(this.specular.scaleToRef(u,z.IG.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",z.IG.Color3[1],this.radius,l)),c=!0}if(this.transferTexturesToEffect(i,l),n.shadowsEnabled&&this.shadowEnabled&&a){var d=(s=this.getShadowGenerator(n.activeCamera))!==null&&s!==void 0?s:this.getShadowGenerator();d&&(d.bindShadowLight(l,i),c=!0)}c?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()},t.prototype.getClassName=function(){return"Light"},t.prototype.toString=function(e){var n="Name: "+this.name;if(n+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var i=0;i<this.animations.length;i++)n+=", animation[0]: "+this.animations[i].toString(e);return n},t.prototype._syncParentEnabledState=function(){r.prototype._syncParentEnabledState.call(this),this.isDisposed()||this._resyncMeshes()},t.prototype.setEnabled=function(e){r.prototype.setEnabled.call(this,e),this._resyncMeshes()},t.prototype.getShadowGenerator=function(e){var n;return e===void 0&&(e=null),this._shadowGenerators===null?null:(n=this._shadowGenerators.get(e))!==null&&n!==void 0?n:null},t.prototype.getShadowGenerators=function(){return this._shadowGenerators},t.prototype.getAbsolutePosition=function(){return _.Pq.Zero()},t.prototype.canAffectMesh=function(e){return!(e&&(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&this.includedOnlyMeshes.indexOf(e)===-1||this.excludedMeshes&&this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1||!(this.includeOnlyWithLayerMask===0||this.includeOnlyWithLayerMask&e.layerMask)||this.excludeWithLayerMask!==0&&this.excludeWithLayerMask&e.layerMask))},t.prototype.dispose=function(e,n){if(n===void 0&&(n=!1),this._shadowGenerators){for(var i=this._shadowGenerators.values(),o=i.next();o.done!==!0;o=i.next())o.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){var a=this._parentContainer.lights.indexOf(this);a>-1&&this._parentContainer.lights.splice(a,1),this._parentContainer=null}for(var s=0,l=this.getScene().meshes;s<l.length;s++)l[s]._removeLightSource(this,!0);this._uniformBuffer.dispose(),this.getScene().removeLight(this),r.prototype.dispose.call(this,e,n)},t.prototype.getTypeID=function(){return 0},t.prototype.getScaledIntensity=function(){return this._photometricScale*this.intensity},t.prototype.clone=function(e,n){n===void 0&&(n=null);var i=t.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;var o=tt.p.Clone(i,this);return e&&(o.name=e),n&&(o.parent=n),o.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(o),o},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach(function(n){e.excludedMeshesIds.push(n.id)})),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach(function(n){e.includedOnlyMeshesIds.push(n.id)})),tt.p.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e},t.GetConstructorFromName=function(e,n,i){return At.Construct("Light_Type_"+e,n,i)||null},t.Parse=function(e,n){var i=t.GetConstructorFromName(e.type,e.name,n);if(!i)return null;var o=tt.p.Parse(i,e,n);if(e.excludedMeshesIds&&(o._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId!==void 0&&(o._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(o._waitingParentInstanceIndex=e.parentInstanceIndex),e.falloffType!==void 0&&(o.falloffType=e.falloffType),e.lightmapMode!==void 0&&(o.lightmapMode=e.lightmapMode),e.animations){for(var a=0;a<e.animations.length;a++){var s=e.animations[a],l=(0,j.n9)("BABYLON.Animation");l&&o.animations.push(l.Parse(s))}At.ParseAnimationRanges(o,e,n)}return e.autoAnimate&&n.beginAnimation(o,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.isEnabled!==void 0&&o.setEnabled(e.isEnabled),o},t.prototype._hookArrayForExcluded=function(e){var n=this,i=e.push;e.push=function(){for(var l=[],c=0;c<arguments.length;c++)l[c]=arguments[c];for(var u=i.apply(e,l),d=0,h=l;d<h.length;d++)h[d]._resyncLightSource(n);return u};var o=e.splice;e.splice=function(l,c){for(var u=o.apply(e,[l,c]),d=0,h=u;d<h.length;d++)h[d]._resyncLightSource(n);return u};for(var a=0,s=e;a<s.length;a++)s[a]._resyncLightSource(this)},t.prototype._hookArrayForIncludedOnly=function(e){var n=this,i=e.push;e.push=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var l=i.apply(e,a);return n._resyncMeshes(),l};var o=e.splice;e.splice=function(a,s){var l=o.apply(e,[a,s]);return n._resyncMeshes(),l},this._resyncMeshes()},t.prototype._resyncMeshes=function(){for(var e=0,n=this.getScene().meshes;e<n.length;e++)n[e]._resyncLightSource(this)},t.prototype._markMeshesAsLightDirty=function(){for(var e=0,n=this.getScene().meshes;e<n.length;e++){var i=n[e];i.lightSources.indexOf(this)!==-1&&i._markSubMeshesAsLightDirty()}},t.prototype._computePhotometricScale=function(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()},t.prototype._getPhotometricScale=function(){var e=0,n=this.getTypeID(),i=this.intensityMode;switch(i===t.INTENSITYMODE_AUTOMATIC&&(i=n===t.LIGHTTYPEID_DIRECTIONALLIGHT?t.INTENSITYMODE_ILLUMINANCE:t.INTENSITYMODE_LUMINOUSINTENSITY),n){case t.LIGHTTYPEID_POINTLIGHT:case t.LIGHTTYPEID_SPOTLIGHT:switch(i){case t.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case t.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case t.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case t.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case t.INTENSITYMODE_ILLUMINANCE:e=1;break;case t.INTENSITYMODE_LUMINANCE:var o=this.radius;o=Math.max(o,.001),e=2*Math.PI*(1-Math.cos(o))}break;case t.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e},t.prototype._reorderLightsInScene=function(){var e=this.getScene();this._renderPriority!=0&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()},t.FALLOFF_DEFAULT=Ri.c.FALLOFF_DEFAULT,t.FALLOFF_PHYSICAL=Ri.c.FALLOFF_PHYSICAL,t.FALLOFF_GLTF=Ri.c.FALLOFF_GLTF,t.FALLOFF_STANDARD=Ri.c.FALLOFF_STANDARD,t.LIGHTMAP_DEFAULT=Ri.c.LIGHTMAP_DEFAULT,t.LIGHTMAP_SPECULAR=Ri.c.LIGHTMAP_SPECULAR,t.LIGHTMAP_SHADOWSONLY=Ri.c.LIGHTMAP_SHADOWSONLY,t.INTENSITYMODE_AUTOMATIC=Ri.c.INTENSITYMODE_AUTOMATIC,t.INTENSITYMODE_LUMINOUSPOWER=Ri.c.INTENSITYMODE_LUMINOUSPOWER,t.INTENSITYMODE_LUMINOUSINTENSITY=Ri.c.INTENSITYMODE_LUMINOUSINTENSITY,t.INTENSITYMODE_ILLUMINANCE=Ri.c.INTENSITYMODE_ILLUMINANCE,t.INTENSITYMODE_LUMINANCE=Ri.c.INTENSITYMODE_LUMINANCE,t.LIGHTTYPEID_POINTLIGHT=Ri.c.LIGHTTYPEID_POINTLIGHT,t.LIGHTTYPEID_DIRECTIONALLIGHT=Ri.c.LIGHTTYPEID_DIRECTIONALLIGHT,t.LIGHTTYPEID_SPOTLIGHT=Ri.c.LIGHTTYPEID_SPOTLIGHT,t.LIGHTTYPEID_HEMISPHERICLIGHT=Ri.c.LIGHTTYPEID_HEMISPHERICLIGHT,(0,A.Cg)([(0,V.jT)()],t.prototype,"diffuse",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"specular",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"falloffType",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"intensity",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"range",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"intensityMode",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"radius",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"_renderPriority",void 0),(0,A.Cg)([(0,V.$z)("_reorderLightsInScene")],t.prototype,"renderPriority",void 0),(0,A.Cg)([(0,V.lK)("shadowEnabled")],t.prototype,"_shadowEnabled",void 0),(0,A.Cg)([(0,V.lK)("excludeWithLayerMask")],t.prototype,"_excludeWithLayerMask",void 0),(0,A.Cg)([(0,V.lK)("includeOnlyWithLayerMask")],t.prototype,"_includeOnlyWithLayerMask",void 0),(0,A.Cg)([(0,V.lK)("lightmapMode")],t.prototype,"_lightmapMode",void 0),t}(At),$_=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t}(nt.d),em=function(){function r(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]}return r.prototype.dispose=function(){this.rootNodes.slice(0).forEach(function(t){t.dispose()}),this.rootNodes.length=0,this.skeletons.slice(0).forEach(function(t){t.dispose()}),this.skeletons.length=0,this.animationGroups.slice(0).forEach(function(t){t.dispose()}),this.animationGroups.length=0},r}(),tm=function(r){function t(e){var n=r.call(this)||this;return n._wasAddedToScene=!1,(e=e||Ve.q.LastCreatedScene)&&(n.scene=e,n.sounds=[],n.effectLayers=[],n.layers=[],n.lensFlareSystems=[],n.proceduralTextures=[],n.reflectionProbes=[],e.onDisposeObservable.add(function(){n._wasAddedToScene||n.dispose()}),n._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add(function(){for(var i=0,o=n.geometries;i<o.length;i++)o[i]._rebuild();for(var a=0,s=n.meshes;a<s.length;a++)s[a]._rebuild();for(var l=0,c=n.particleSystems;l<c.length;l++)c[l].rebuild();for(var u=0,d=n.textures;u<d.length;u++)d[u]._rebuild()})),n}return(0,A.C6)(t,r),t.prototype._topologicalSort=function(e){for(var n=new Map,i=0,o=e;i<o.length;i++){var a=o[i];n.set(a.uniqueId,a)}for(var s={dependsOn:new Map,dependedBy:new Map},l=0,c=e;l<c.length;l++){var u=(a=c[l]).uniqueId;s.dependsOn.set(u,new Set),s.dependedBy.set(u,new Set)}for(var d=0,h=e;d<h.length;d++){u=(a=h[d]).uniqueId;var p=s.dependsOn.get(u);if(a instanceof Co){var m=a.sourceMesh;n.has(m.uniqueId)&&(p.add(m.uniqueId),s.dependedBy.get(m.uniqueId).add(u))}for(var v=s.dependedBy.get(u),b=0,E=a.getDescendants();b<E.length;b++){var C=E[b].uniqueId;n.has(C)&&(v.add(C),s.dependsOn.get(C).add(u))}}for(var T=[],f=[],g=0,S=e;g<S.length;g++)u=(a=S[g]).uniqueId,s.dependsOn.get(u).size===0&&(f.push(a),n.delete(u));for(var y=f;y.length>0;){var x=y.shift();T.push(x);for(var R=s.dependedBy.get(x.uniqueId),I=0,M=Array.from(R.values());I<M.length;I++){var D=M[I],B=s.dependsOn.get(D);B.delete(x.uniqueId),B.size===0&&n.get(D)&&(y.push(n.get(D)),n.delete(D))}}return n.size>0&&(O.V.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),n.forEach(function(F){return O.V.Error(F.name)})),T},t.prototype._addNodeAndDescendantsToList=function(e,n,i,o){if(i&&(!o||o(i))&&!n.has(i.uniqueId)){e.push(i),n.add(i.uniqueId);for(var a=0,s=i.getDescendants(!0);a<s.length;a++){var l=s[a];this._addNodeAndDescendantsToList(e,n,l,o)}}},t.prototype._isNodeInContainer=function(e){return e instanceof cn&&this.meshes.indexOf(e)!==-1||e instanceof jt&&this.transformNodes.indexOf(e)!==-1||e instanceof hi&&this.lights.indexOf(e)!==-1||e instanceof Pt&&this.cameras.indexOf(e)!==-1},t.prototype._isValidHierarchy=function(){for(var e=0,n=this.meshes;e<n.length;e++)if((u=n[e]).parent&&!this._isNodeInContainer(u.parent))return O.V.Warn("Node ".concat(u.name," has a parent that is not in the container.")),!1;for(var i=0,o=this.transformNodes;i<o.length;i++)if((u=o[i]).parent&&!this._isNodeInContainer(u.parent))return O.V.Warn("Node ".concat(u.name," has a parent that is not in the container.")),!1;for(var a=0,s=this.lights;a<s.length;a++)if((u=s[a]).parent&&!this._isNodeInContainer(u.parent))return O.V.Warn("Node ".concat(u.name," has a parent that is not in the container.")),!1;for(var l=0,c=this.cameras;l<c.length;l++){var u;if((u=c[l]).parent&&!this._isNodeInContainer(u.parent))return O.V.Warn("Node ".concat(u.name," has a parent that is not in the container.")),!1}return!0},t.prototype.instantiateModelsToScene=function(e,n,i){var o=this;n===void 0&&(n=!1),this._isValidHierarchy()||ze.S0.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");for(var a={},s={},l=new em,c=[],u=[],d=(0,A.Cl)({doNotInstantiate:!0},i),h=[],p=new Set,m=0,v=this.transformNodes;m<v.length;m++){var b=v[m];b.parent===null&&this._addNodeAndDescendantsToList(h,p,b,d.predicate)}for(var E=0,C=this.meshes;E<C.length;E++){var T=C[E];T.parent===null&&this._addNodeAndDescendantsToList(h,p,T,d.predicate)}var f=this._topologicalSort(h),g=function(S,y){if(function(Q,ie){if(a[Q.uniqueId]=ie.uniqueId,s[ie.uniqueId]=ie,e&&(ie.name=e(Q.name)),ie instanceof xe){var q=ie;if(q.morphTargetManager){var ee=Q.morphTargetManager;q.morphTargetManager=ee.clone();for(var te=0;te<ee.numTargets;te++){var ce=ee.getTarget(te),fe=q.morphTargetManager.getTarget(te);a[ce.uniqueId]=fe.uniqueId,s[fe.uniqueId]=fe}}}}(S,y),S.parent){var x=a[S.parent.uniqueId],R=s[x];y.parent=R||S.parent}if(y.position&&S.position&&y.position.copyFrom(S.position),y.rotationQuaternion&&S.rotationQuaternion&&y.rotationQuaternion.copyFrom(S.rotationQuaternion),y.rotation&&S.rotation&&y.rotation.copyFrom(S.rotation),y.scaling&&S.scaling&&y.scaling.copyFrom(S.scaling),y.material){var I=y;if(I.material)if(n){var M=S.material;if(u.indexOf(M)===-1){var D=M.clone(e?e(M.name):"Clone of "+M.name);if(u.push(M),a[M.uniqueId]=D.uniqueId,s[D.uniqueId]=D,M.getClassName()==="MultiMaterial"){for(var B=M,F=0,X=B.subMaterials;F<X.length;F++){var $=X[F];$&&(D=$.clone(e?e($.name):"Clone of "+$.name),u.push($),a[$.uniqueId]=D.uniqueId,s[D.uniqueId]=D)}B.subMaterials=B.subMaterials.map(function(Q){return Q&&s[a[Q.uniqueId]]})}}I.getClassName()!=="InstancedMesh"&&(I.material=s[a[M.uniqueId]])}else I.material.getClassName()==="MultiMaterial"?o.scene.multiMaterials.indexOf(I.material)===-1&&o.scene.addMultiMaterial(I.material):o.scene.materials.indexOf(I.material)===-1&&o.scene.addMaterial(I.material)}y.parent===null&&l.rootNodes.push(y)};return f.forEach(function(S){if(S.getClassName()==="InstancedMesh"){var y=S,x=y.sourceMesh,R=a[x.uniqueId],I=(typeof R=="number"?s[R]:x).createInstance(y.name);g(y,I)}else{var M=!0;S.getClassName()==="TransformNode"||S.getClassName()==="Node"||S.skeleton||!S.getTotalVertices||S.getTotalVertices()===0?M=!1:d.doNotInstantiate&&(M=typeof d.doNotInstantiate=="function"?!d.doNotInstantiate(S):!d.doNotInstantiate);var D=M?S.createInstance("instance of ".concat(S.name)):S.clone("Clone of ".concat(S.name),null,!0);if(!D)throw new Error("Could not clone or instantiate node on Asset Container ".concat(S.name));g(S,D)}}),this.skeletons.forEach(function(S){if(!d.predicate||d.predicate(S)){for(var y=S.clone(e?e(S.name):"Clone of "+S.name),x=0,R=o.meshes;x<R.length;x++){var I=R[x];if(I.skeleton===S&&!I.isAnInstance){var M=s[a[I.uniqueId]];if(!M||M.isAnInstance||(M.skeleton=y,c.indexOf(y)!==-1))continue;c.push(y);for(var D=0,B=y.bones;D<B.length;D++){var F=B[D];F._linkedTransformNode&&(F._linkedTransformNode=s[a[F._linkedTransformNode.uniqueId]])}}}l.skeletons.push(y)}}),this.animationGroups.forEach(function(S){if(!d.predicate||d.predicate(S)){var y=S.clone(e?e(S.name):"Clone of "+S.name,function(x){return s[a[x.uniqueId]]||x});l.animationGroups.push(y)}}),l},t.prototype.addAllToScene=function(){if(!this._wasAddedToScene){this._isValidHierarchy()||ze.S0.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!0,this.addToScene(null),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(var e=0,n=this.scene._serializableComponents;e<n.length;e++)n[e].addFromContainer(this);this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null}},t.prototype.addToScene=function(e){var n=this;e===void 0&&(e=null);var i=[];this.cameras.forEach(function(l){e&&!e(l)||(n.scene.addCamera(l),i.push(l))}),this.lights.forEach(function(l){e&&!e(l)||(n.scene.addLight(l),i.push(l))}),this.meshes.forEach(function(l){e&&!e(l)||(n.scene.addMesh(l),i.push(l))}),this.skeletons.forEach(function(l){e&&!e(l)||n.scene.addSkeleton(l)}),this.animations.forEach(function(l){e&&!e(l)||n.scene.addAnimation(l)}),this.animationGroups.forEach(function(l){e&&!e(l)||n.scene.addAnimationGroup(l)}),this.multiMaterials.forEach(function(l){e&&!e(l)||n.scene.addMultiMaterial(l)}),this.materials.forEach(function(l){e&&!e(l)||n.scene.addMaterial(l)}),this.morphTargetManagers.forEach(function(l){e&&!e(l)||n.scene.addMorphTargetManager(l)}),this.geometries.forEach(function(l){e&&!e(l)||n.scene.addGeometry(l)}),this.transformNodes.forEach(function(l){e&&!e(l)||(n.scene.addTransformNode(l),i.push(l))}),this.actionManagers.forEach(function(l){e&&!e(l)||n.scene.addActionManager(l)}),this.textures.forEach(function(l){e&&!e(l)||n.scene.addTexture(l)}),this.reflectionProbes.forEach(function(l){e&&!e(l)||n.scene.addReflectionProbe(l)});for(var o=0,a=i;o<a.length;o++){var s=a[o];s.parent&&this.scene.getNodes().indexOf(s.parent)===-1&&(s.setParent?s.setParent(null):s.parent=null)}},t.prototype.removeAllFromScene=function(){this._isValidHierarchy()||ze.S0.Warn("SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!1,this.removeFromScene(null),this.environmentTexture===this.scene.environmentTexture&&(this.scene.environmentTexture=null);for(var e=0,n=this.scene._serializableComponents;e<n.length;e++)n[e].removeFromContainer(this)},t.prototype.removeFromScene=function(e){var n=this;e===void 0&&(e=null),this.cameras.forEach(function(i){e&&!e(i)||n.scene.removeCamera(i)}),this.lights.forEach(function(i){e&&!e(i)||n.scene.removeLight(i)}),this.meshes.forEach(function(i){e&&!e(i)||n.scene.removeMesh(i,!0)}),this.skeletons.forEach(function(i){e&&!e(i)||n.scene.removeSkeleton(i)}),this.animations.forEach(function(i){e&&!e(i)||n.scene.removeAnimation(i)}),this.animationGroups.forEach(function(i){e&&!e(i)||n.scene.removeAnimationGroup(i)}),this.multiMaterials.forEach(function(i){e&&!e(i)||n.scene.removeMultiMaterial(i)}),this.materials.forEach(function(i){e&&!e(i)||n.scene.removeMaterial(i)}),this.morphTargetManagers.forEach(function(i){e&&!e(i)||n.scene.removeMorphTargetManager(i)}),this.geometries.forEach(function(i){e&&!e(i)||n.scene.removeGeometry(i)}),this.transformNodes.forEach(function(i){e&&!e(i)||n.scene.removeTransformNode(i)}),this.actionManagers.forEach(function(i){e&&!e(i)||n.scene.removeActionManager(i)}),this.textures.forEach(function(i){e&&!e(i)||n.scene.removeTexture(i)}),this.reflectionProbes.forEach(function(i){e&&!e(i)||n.scene.removeReflectionProbe(i)})},t.prototype.dispose=function(){this.cameras.slice(0).forEach(function(i){i.dispose()}),this.cameras.length=0,this.lights.slice(0).forEach(function(i){i.dispose()}),this.lights.length=0,this.meshes.slice(0).forEach(function(i){i.dispose()}),this.meshes.length=0,this.skeletons.slice(0).forEach(function(i){i.dispose()}),this.skeletons.length=0,this.animationGroups.slice(0).forEach(function(i){i.dispose()}),this.animationGroups.length=0,this.multiMaterials.slice(0).forEach(function(i){i.dispose()}),this.multiMaterials.length=0,this.materials.slice(0).forEach(function(i){i.dispose()}),this.materials.length=0,this.geometries.slice(0).forEach(function(i){i.dispose()}),this.geometries.length=0,this.transformNodes.slice(0).forEach(function(i){i.dispose()}),this.transformNodes.length=0,this.actionManagers.slice(0).forEach(function(i){i.dispose()}),this.actionManagers.length=0,this.textures.slice(0).forEach(function(i){i.dispose()}),this.textures.length=0,this.reflectionProbes.slice(0).forEach(function(i){i.dispose()}),this.reflectionProbes.length=0,this.morphTargetManagers.slice(0).forEach(function(i){i.dispose()}),this.morphTargetManagers.length=0,this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(var e=0,n=this.scene._serializableComponents;e<n.length;e++)n[e].removeFromContainer(this,!0);this._onContextRestoredObserver&&(this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)},t.prototype._moveAssets=function(e,n,i){if(e&&n)for(var o=0,a=e;o<a.length;o++){var s=a[o],l=!0;if(i){for(var c=0,u=i;c<u.length;c++)if(s===u[c]){l=!1;break}}l&&(n.push(s),s._parentContainer=this)}},t.prototype.moveAllFromScene=function(e){for(var n in this._wasAddedToScene=!1,e===void 0&&(e=new $_),this)Object.prototype.hasOwnProperty.call(this,n)&&(this[n]=this[n]||(n==="_environmentTexture"?null:[]),this._moveAssets(this.scene[n],this[n],e[n]));this.environmentTexture=this.scene.environmentTexture,this.removeAllFromScene()},t.prototype.createRootMesh=function(){var e=new xe("assetContainerRootMesh",this.scene);return this.meshes.forEach(function(n){n.parent||e.addChild(n)}),this.meshes.unshift(e),e},t.prototype.mergeAnimationsTo=function(e,n,i){if(e===void 0&&(e=Ve.q.LastCreatedScene),i===void 0&&(i=null),!e)return O.V.Error("No scene available to merge animations to"),[];var o=i||function(s){var l=null,c=s.animations.length?s.animations[0].targetProperty:"",u=s.name.split(".").join("").split("_primitive")[0];switch(c){case"position":case"rotationQuaternion":l=e.getTransformNodeByName(s.name)||e.getTransformNodeByName(u);break;case"influence":l=e.getMorphTargetByName(s.name)||e.getMorphTargetByName(u);break;default:l=e.getNodeByName(s.name)||e.getNodeByName(u)}return l};this.getNodes().forEach(function(s){var l=o(s);if(l!==null){for(var c=function(h){for(var p=0,m=l.animations.filter(function(E){return E.targetProperty===h.targetProperty});p<m.length;p++){var v=m[p],b=l.animations.indexOf(v,0);b>-1&&l.animations.splice(b,1)}},u=0,d=s.animations;u<d.length;u++)c(d[u]);l.animations=l.animations.concat(s.animations)}});var a=[];return this.animationGroups.slice().forEach(function(s){a.push(s.clone(s.name,o)),s.animatables.forEach(function(l){l.stop()})}),n.forEach(function(s){var l=o(s.target);l&&(e.beginAnimation(l,s.fromFrame,s.toFrame,s.loopAnimation,s.speedRatio,s.onAnimationEnd?s.onAnimationEnd:void 0,void 0,!0,void 0,s.onAnimationLoop?s.onAnimationLoop:void 0),e.stopAnimation(s.target))}),a},t.prototype.populateRootNodes=function(){var e=this;this.rootNodes.length=0,this.meshes.forEach(function(n){n.parent||e.rootNodes.indexOf(n)!==-1||e.rootNodes.push(n)}),this.transformNodes.forEach(function(n){n.parent||e.rootNodes.indexOf(n)!==-1||e.rootNodes.push(n)}),this.lights.forEach(function(n){n.parent||e.rootNodes.indexOf(n)!==-1||e.rootNodes.push(n)}),this.cameras.forEach(function(n){n.parent||e.rootNodes.indexOf(n)!==-1||e.rootNodes.push(n)})},t.prototype.addAllAssetsToContainer=function(e){if(e){var n=[],i=new Set;for(n.push(e);n.length>0;){var o=n.pop();if(o instanceof xe?(o.geometry&&this.geometries.indexOf(o.geometry)===-1&&this.geometries.push(o.geometry),this.meshes.push(o)):o instanceof jt?this.transformNodes.push(o):o instanceof hi?this.lights.push(o):o instanceof Pt&&this.cameras.push(o),o instanceof cn){if(o.material&&this.materials.indexOf(o.material)===-1){this.materials.push(o.material);for(var a=0,s=o.material.getActiveTextures();a<s.length;a++){var l=s[a];this.textures.indexOf(l)===-1&&this.textures.push(l)}}o.skeleton&&this.skeletons.indexOf(o.skeleton)===-1&&this.skeletons.push(o.skeleton),o.morphTargetManager&&this.morphTargetManagers.indexOf(o.morphTargetManager)===-1&&this.morphTargetManagers.push(o.morphTargetManager)}for(var c=0,u=o.getChildren();c<u.length;c++){var d=u[c];i.has(d)||n.push(d)}i.add(o)}this.populateRootNodes()}},t}(nt.d),BS=function(){function r(t){this.SMOOTHING=.75,this.FFT_SIZE=512,this.BARGRAPHAMPLITUDE=256,this.DEBUGCANVASPOS={x:20,y:20},this.DEBUGCANVASSIZE={width:320,height:200},(t=t||Ve.q.LastCreatedScene)&&(this._scene=t,Be.$.audioEngine?(this._audioEngine=Be.$.audioEngine,this._audioEngine.canUseWebAudio&&this._audioEngine.audioContext&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))):ze.S0.Warn("No audio engine initialized, failed to create an audio analyser"))}return r.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},r.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},r.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},r.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},r.prototype.drawDebugCanvas=function(){var t=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){t.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc&&this._debugCanvasContext)){var e=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var n=0;n<this.getFrequencyBinCount();n++){var i=e[n]/this.BARGRAPHAMPLITUDE,o=this.DEBUGCANVASSIZE.height*i,a=this.DEBUGCANVASSIZE.height-o-1,s=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),l=n/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+l+", 100%, 50%)",this._debugCanvasContext.fillRect(n*s,a,s,o)}}},r.prototype.stopDebugCanvas=function(){this._debugCanvas&&(this._registerFunc&&(this._scene.unregisterBeforeRender(this._registerFunc),this._registerFunc=null),document.body.removeChild(this._debugCanvas),this._debugCanvas=null,this._debugCanvasContext=null)},r.prototype.connectAudioNodes=function(t,e){this._audioEngine.canUseWebAudio&&(t.connect(this._webAudioAnalyser),this._webAudioAnalyser.connect(e))},r.prototype.dispose=function(){this._audioEngine.canUseWebAudio&&this._webAudioAnalyser.disconnect()},r}(),bi=L(5153);Be.$.AudioEngineFactory=function(r,t,e){return new nm(r,t,e)};var nm=function(){function r(t,e,n){t===void 0&&(t=null),e===void 0&&(e=null),n===void 0&&(n=null);var i=this;if(this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this._audioDestination=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!1,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new K.cP,this.onAudioLockedObservable=new K.cP,this._tryToRun=!1,this._onResize=function(){i._moveButtonToTopLeft()},(0,bi.BA)()){window.AudioContext!==void 0&&(this.canUseWebAudio=!0);var o=document.createElement("audio");this._hostElement=t,this._audioContext=e,this._audioDestination=n;try{o&&o.canPlayType&&(o.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")||o.canPlayType("audio/mp3").replace(/^no$/,""))&&(this.isMP3supported=!0)}catch{}try{o&&o.canPlayType&&o.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch{}}}return Object.defineProperty(r.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!1,configurable:!0}),r.prototype.lock=function(){this._triggerSuspendedState()},r.prototype.unlock=function(){var t,e,n=this;if(((t=this._audioContext)===null||t===void 0?void 0:t.state)==="running")return this._hideMuteButton(),void(this.unlocked||(this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this)));this._tryToRun?(e=this._audioContext)===null||e===void 0||e.suspend().then(function(){n._tryToRun=!1,n._triggerRunningState()}):this._triggerRunningState()},r.prototype._resumeAudioContextOnStateChange=function(){var t,e=this;(t=this._audioContext)===null||t===void 0||t.addEventListener("statechange",function(){var n;e.unlocked&&((n=e._audioContext)===null||n===void 0?void 0:n.state)!=="running"&&e._resumeAudioContext()},{once:!0,passive:!0,signal:AbortSignal.timeout(3e3)})},r.prototype._resumeAudioContext=function(){var t;return!((t=this._audioContext)===null||t===void 0)&&t.resume?this._audioContext.resume():Promise.resolve()},r.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext||(this._audioContext=new AudioContext),this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this._audioDestination||(this._audioDestination=this._audioContext.destination),this.masterGain.connect(this._audioDestination),this._audioContextInitialized=!0,this._audioContext.state==="running"&&this._triggerRunningState())}catch(t){this.canUseWebAudio=!1,O.V.Error("Web Audio: "+t.message)}},r.prototype._triggerRunningState=function(){var t=this;this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then(function(){t._tryToRun=!1,t._muteButton&&t._hideMuteButton(),t.unlocked=!0,t.onAudioUnlockedObservable.notifyObservers(t)}).catch(function(){t._tryToRun=!1,t.unlocked=!1}))},r.prototype._triggerSuspendedState=function(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()},r.prototype._displayMuteButton=function(){var t=this;if(!this.useCustomUnlockedButton&&!this._muteButton){this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";var e=".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E":"https://cdn.babylonjs.com/Assets/audio.png")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }",n=document.createElement("style");n.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(n),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",function(){t._triggerRunningState()},!0),this._muteButton.addEventListener("click",function(){t.unlock()},!0),window.addEventListener("resize",this._onResize)}},r.prototype._moveButtonToTopLeft=function(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")},r.prototype._hideMuteButton=function(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)},r.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()},r.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},r.prototype.setGlobalVolume=function(t){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=t)},r.prototype.connectToAnalyser=function(t){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=t,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},r}(),Jo=function(){function r(t,e,n,i,o){i===void 0&&(i=null);var a,s,l,c,u,d=this;if(this.autoplay=!1,this._loop=!1,this.useCustomAttenuation=!1,this.isPlaying=!1,this.isPaused=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this.metadata=null,this.onEndedObservable=new K.cP,this._spatialSound=!1,this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._currentTime=0,this._position=_.Pq.Zero(),this._localDirection=new _.Pq(1,0,0),this._volume=1,this._isReadyToPlay=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,n=n||Ve.q.LastCreatedScene)if(this._scene=n,r._SceneComponentInitialization(n),this._readyToPlayCallback=i,this._customAttenuationFunction=function(C,T,f,g,S){return T<f?C*(1-T/f):0},o&&(this.autoplay=o.autoplay||!1,this._loop=o.loop||!1,o.volume!==void 0&&(this._volume=o.volume),this._spatialSound=(a=o.spatialSound)!==null&&a!==void 0&&a,this.maxDistance=(s=o.maxDistance)!==null&&s!==void 0?s:100,this.useCustomAttenuation=(l=o.useCustomAttenuation)!==null&&l!==void 0&&l,this.rolloffFactor=o.rolloffFactor||1,this.refDistance=o.refDistance||1,this.distanceModel=o.distanceModel||"linear",this._playbackRate=o.playbackRate||1,this._streaming=(c=o.streaming)!==null&&c!==void 0&&c,this._length=o.length,this._offset=o.offset),((u=Be.$.audioEngine)===null||u===void 0?void 0:u.canUseWebAudio)&&Be.$.audioEngine.audioContext){this._soundGain=Be.$.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._outputAudioNode=this._soundGain,this._spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.addSound(this);var h=!0;if(e)try{typeof e=="string"?(this._urlType="String",this._url=e):e instanceof ArrayBuffer?this._urlType="ArrayBuffer":e instanceof HTMLMediaElement?this._urlType="MediaElement":e instanceof MediaStream?this._urlType="MediaStream":e instanceof AudioBuffer?this._urlType="AudioBuffer":Array.isArray(e)&&(this._urlType="Array");var p=[],m=!1;switch(this._urlType){case"MediaElement":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=Be.$.audioEngine.audioContext.createMediaElementSource(e),this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"MediaStream":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=Be.$.audioEngine.audioContext.createMediaStreamSource(e),this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"ArrayBuffer":e.byteLength>0&&(m=!0,this._soundLoaded(e));break;case"AudioBuffer":this._audioBufferLoaded(e);break;case"String":p.push(e);case"Array":p.length===0&&(p=e);for(var v=function(C){var T=p[C];if(m=o&&o.skipCodecCheck||T.indexOf(".mp3",T.length-4)!==-1&&Be.$.audioEngine.isMP3supported||T.indexOf(".ogg",T.length-4)!==-1&&Be.$.audioEngine.isOGGsupported||T.indexOf(".wav",T.length-4)!==-1||T.indexOf(".m4a",T.length-4)!==-1||T.indexOf(".mp4",T.length-4)!==-1||T.indexOf("blob:")!==-1)return b._streaming?(b._htmlAudioElement=new Audio(T),b._htmlAudioElement.controls=!1,b._htmlAudioElement.loop=b.loop,ze.S0.SetCorsBehavior(T,b._htmlAudioElement),b._htmlAudioElement.preload="auto",b._htmlAudioElement.addEventListener("canplaythrough",function(){d._isReadyToPlay=!0,d.autoplay&&d.play(0,d._offset,d._length),d._readyToPlayCallback&&d._readyToPlayCallback()},{once:!0}),document.body.appendChild(b._htmlAudioElement),b._htmlAudioElement.load()):b._scene._loadFile(T,function(f){d._soundLoaded(f)},void 0,!0,!0,function(f){f&&O.V.Error("XHR "+f.status+" error on: "+T+"."),O.V.Error("Sound creation aborted."),d._scene.mainSoundTrack.removeSound(d)}),"break"},b=this,E=0;E<p.length&&v(E)!=="break";E++);break;default:h=!1}h?m||(this._isReadyToPlay=!0,this._readyToPlayCallback&&setTimeout(function(){d._readyToPlayCallback&&d._readyToPlayCallback()},1e3)):O.V.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")}catch{O.V.Error("Unexpected error. Sound creation aborted."),this._scene.mainSoundTrack.removeSound(this)}}else this._scene.mainSoundTrack.addSound(this),Be.$.audioEngine&&!Be.$.audioEngine.WarnedWebAudioUnsupported&&(O.V.Error("Web Audio is not supported by your browser."),Be.$.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&setTimeout(function(){d._readyToPlayCallback&&d._readyToPlayCallback()},1e3)}return Object.defineProperty(r.prototype,"loop",{get:function(){return this._loop},set:function(t){t!==this._loop&&(this._loop=t,this.updateOptions({loop:t}))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentTime",{get:function(){var t;if(this._htmlAudioElement)return this._htmlAudioElement.currentTime;if(!((t=Be.$.audioEngine)===null||t===void 0)&&t.audioContext&&(this.isPlaying||this.isPaused)){var e=this.isPaused?0:Be.$.audioEngine.audioContext.currentTime-this._startTime;return this._currentTime+e}return 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"spatialSound",{get:function(){return this._spatialSound},set:function(t){if(t!=this._spatialSound){var e=this.isPlaying;this.pause(),t?(this._spatialSound=t,this._updateSpatialParameters()):this._disableSpatialSound(),e&&this.play()}},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){var t;!((t=Be.$.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,this.soundTrackId===-1?this._scene.mainSoundTrack.removeSound(this):this._scene.soundTracks&&this._scene.soundTracks[this.soundTrackId].removeSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement),this._htmlAudioElement=null),this._streamingSource&&(this._streamingSource.disconnect(),this._streamingSource=null),this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedTransformNode=null),this._clearTimeoutsAndObservers())},r.prototype.isReady=function(){return this._isReadyToPlay},r.prototype.getClassName=function(){return"Sound"},r.prototype._audioBufferLoaded=function(t){var e;!((e=Be.$.audioEngine)===null||e===void 0)&&e.audioContext&&(this._audioBuffer=t,this._isReadyToPlay=!0,this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback())},r.prototype._soundLoaded=function(t){var e,n=this;!((e=Be.$.audioEngine)===null||e===void 0)&&e.audioContext&&Be.$.audioEngine.audioContext.decodeAudioData(t,function(i){n._audioBufferLoaded(i)},function(i){O.V.Error("Error while decoding audio data for: "+n.name+" / Error: "+i)})},r.prototype.setAudioBuffer=function(t){var e;!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&(this._audioBuffer=t,this._isReadyToPlay=!0)},r.prototype.updateOptions=function(t){var e,n,i,o,a,s,l,c,u,d,h;t&&(this.loop=(e=t.loop)!==null&&e!==void 0?e:this.loop,this.maxDistance=(n=t.maxDistance)!==null&&n!==void 0?n:this.maxDistance,this.useCustomAttenuation=(i=t.useCustomAttenuation)!==null&&i!==void 0?i:this.useCustomAttenuation,this.rolloffFactor=(o=t.rolloffFactor)!==null&&o!==void 0?o:this.rolloffFactor,this.refDistance=(a=t.refDistance)!==null&&a!==void 0?a:this.refDistance,this.distanceModel=(s=t.distanceModel)!==null&&s!==void 0?s:this.distanceModel,this._playbackRate=(l=t.playbackRate)!==null&&l!==void 0?l:this._playbackRate,this._length=(c=t.length)!==null&&c!==void 0?c:void 0,this.spatialSound=(u=t.spatialSound)!==null&&u!==void 0?u:this._spatialSound,this._setOffset((d=t.offset)!==null&&d!==void 0?d:void 0),this.setVolume((h=t.volume)!==null&&h!==void 0?h:this._volume),this._updateSpatialParameters(),this.isPlaying&&(this._streaming&&this._htmlAudioElement?(this._htmlAudioElement.playbackRate=this._playbackRate,this._htmlAudioElement.loop!==this.loop&&(this._htmlAudioElement.loop=this.loop)):this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.loop!==this.loop&&(this._soundSource.loop=this.loop),this._offset!==void 0&&this._soundSource.loopStart!==this._offset&&(this._soundSource.loopStart=this._offset),this._length!==void 0&&this._length!==this._soundSource.loopEnd&&(this._soundSource.loopEnd=(0|this._offset)+this._length))))},r.prototype._createSpatialParameters=function(){var t,e;!((t=Be.$.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&Be.$.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=(e=this._soundPanner)!==null&&e!==void 0?e:Be.$.audioEngine.audioContext.createPanner(),this._soundPanner&&this._outputAudioNode&&(this._updateSpatialParameters(),this._soundPanner.connect(this._outputAudioNode),this._inputAudioNode=this._soundPanner))},r.prototype._disableSpatialSound=function(){var t;this._spatialSound&&(this._inputAudioNode=this._soundGain,(t=this._soundPanner)===null||t===void 0||t.disconnect(),this._soundPanner=null,this._spatialSound=!1)},r.prototype._updateSpatialParameters=function(){this._spatialSound&&(this._soundPanner?this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel):this._createSpatialParameters())},r.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},r.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},r.prototype._switchPanningModel=function(){var t;!((t=Be.$.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)},r.prototype.connectToSoundTrackAudioNode=function(t){var e;!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._outputAudioNode&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(t),this._isOutputConnected=!0)},r.prototype.setDirectionalCone=function(t,e,n){e<t?O.V.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=t,this._coneOuterAngle=e,this._coneOuterGain=n,this._isDirectional=!0,this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length)))},Object.defineProperty(r.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(t){var e;if(t!=this._coneInnerAngle){if(this._coneOuterAngle<t)return void O.V.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=t,!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._spatialSound&&this._soundPanner&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(t){var e;if(t!=this._coneOuterAngle){if(t<this._coneInnerAngle)return void O.V.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=t,!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._spatialSound&&this._soundPanner&&(this._soundPanner.coneOuterAngle=this._coneOuterAngle)}},enumerable:!1,configurable:!0}),r.prototype.setPosition=function(t){var e;t.equals(this._position)||(this._position.copyFrom(t),!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._spatialSound&&this._soundPanner&&!isNaN(this._position.x)&&!isNaN(this._position.y)&&!isNaN(this._position.z)&&(this._soundPanner.positionX.value=this._position.x,this._soundPanner.positionY.value=this._position.y,this._soundPanner.positionZ.value=this._position.z))},r.prototype.setLocalDirectionToMesh=function(t){var e;this._localDirection=t,!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._connectedTransformNode&&this.isPlaying&&this._updateDirection()},r.prototype._updateDirection=function(){if(this._connectedTransformNode&&this._soundPanner){var t=this._connectedTransformNode.getWorldMatrix(),e=_.Pq.TransformNormal(this._localDirection,t);e.normalize(),this._soundPanner.orientationX.value=e.x,this._soundPanner.orientationY.value=e.y,this._soundPanner.orientationZ.value=e.z}},r.prototype.updateDistanceFromListener=function(){var t;if(!((t=Be.$.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&this._connectedTransformNode&&this.useCustomAttenuation&&this._soundGain&&this._scene.activeCamera){var e=this._scene.audioListenerPositionProvider?this._connectedTransformNode.position.subtract(this._scene.audioListenerPositionProvider()).length():this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,e,this.maxDistance,this.refDistance,this.rolloffFactor)}},r.prototype.setAttenuationFunction=function(t){this._customAttenuationFunction=t},r.prototype.play=function(t,e,n){var i,o,a,s,l=this;if(this._isReadyToPlay&&this._scene.audioEnabled&&(!((i=Be.$.audioEngine)===null||i===void 0)&&i.audioContext))try{this._clearTimeoutsAndObservers();var c=t?((o=Be.$.audioEngine)===null||o===void 0?void 0:o.audioContext.currentTime)+t:(a=Be.$.audioEngine)===null||a===void 0?void 0:a.audioContext.currentTime;if(this._soundSource&&this._streamingSource||this._spatialSound&&this._soundPanner&&(isNaN(this._position.x)||isNaN(this._position.y)||isNaN(this._position.z)||(this._soundPanner.positionX.value=this._position.x,this._soundPanner.positionY.value=this._position.y,this._soundPanner.positionZ.value=this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedTransformNode?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming){if(!this._streamingSource&&this._htmlAudioElement&&(this._streamingSource=Be.$.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){l._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource&&(this._streamingSource.disconnect(),this._inputAudioNode&&this._streamingSource.connect(this._inputAudioNode)),this._htmlAudioElement){var u=function(){var h,p;if(!((h=Be.$.audioEngine)===null||h===void 0)&&h.unlocked){if(!l._htmlAudioElement)return;l._htmlAudioElement.currentTime=e??0;var m=l._htmlAudioElement.play();m!==void 0&&m.catch(function(){var v,b;(v=Be.$.audioEngine)===null||v===void 0||v.lock(),(l.loop||l.autoplay)&&(l._audioUnlockedObserver=(b=Be.$.audioEngine)===null||b===void 0?void 0:b.onAudioUnlockedObservable.addOnce(function(){u()}))})}else(l.loop||l.autoplay)&&(l._audioUnlockedObserver=(p=Be.$.audioEngine)===null||p===void 0?void 0:p.onAudioUnlockedObservable.addOnce(function(){u()}))};u()}}else{var d=function(){var h,p,m,v;if(!((h=Be.$.audioEngine)===null||h===void 0)&&h.audioContext){if(n=n||l._length,e!==void 0&&l._setOffset(e),l._soundSource){var b=l._soundSource;b.onended=function(){b.disconnect()}}if(l._soundSource=(p=Be.$.audioEngine)===null||p===void 0?void 0:p.audioContext.createBufferSource(),l._soundSource&&l._inputAudioNode){l._soundSource.buffer=l._audioBuffer,l._soundSource.connect(l._inputAudioNode),l._soundSource.loop=l.loop,e!==void 0&&(l._soundSource.loopStart=e),n!==void 0&&(l._soundSource.loopEnd=(0|e)+n),l._soundSource.playbackRate.value=l._playbackRate,l._soundSource.onended=function(){l._onended()},c=t?((m=Be.$.audioEngine)===null||m===void 0?void 0:m.audioContext.currentTime)+t:Be.$.audioEngine.audioContext.currentTime;var E=((l.isPaused?l.currentTime:0)+((v=l._offset)!==null&&v!==void 0?v:0))%l._soundSource.buffer.duration;l._soundSource.start(c,E,l.loop?void 0:n)}}};((s=Be.$.audioEngine)===null||s===void 0?void 0:s.audioContext.state)==="suspended"?this._tryToPlayTimeout=setTimeout(function(){var h;((h=Be.$.audioEngine)===null||h===void 0?void 0:h.audioContext.state)==="suspended"?(Be.$.audioEngine.lock(),(l.loop||l.autoplay)&&(l._audioUnlockedObserver=Be.$.audioEngine.onAudioUnlockedObservable.addOnce(function(){d()}))):d()},500):d()}this._startTime=c,this.isPlaying=!0,this.isPaused=!1}catch(h){O.V.Error("Error while trying to play audio: "+this.name+", "+h.message)}},r.prototype._onended=function(){this.isPlaying=!1,this._startTime=0,this._currentTime=0,this.onended&&this.onended(),this.onEndedObservable.notifyObservers(this)},r.prototype.stop=function(t){var e,n,i=this;if(this.isPlaying)if(this._clearTimeoutsAndObservers(),this._streaming)this._htmlAudioElement?(this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0)):(e=this._streamingSource)===null||e===void 0||e.disconnect(),this.isPlaying=!1;else if(!((n=Be.$.audioEngine)===null||n===void 0)&&n.audioContext&&this._soundSource){var o=t?Be.$.audioEngine.audioContext.currentTime+t:void 0;this._soundSource.onended=function(){i.isPlaying=!1,i.isPaused=!1,i._startTime=0,i._currentTime=0,i._soundSource&&(i._soundSource.onended=function(){}),i._onended()},this._soundSource.stop(o)}else this.isPlaying=!1;else this.isPaused&&(this.isPaused=!1,this._startTime=0,this._currentTime=0)},r.prototype.pause=function(){var t,e;this.isPlaying&&(this._clearTimeoutsAndObservers(),this._streaming?(this._htmlAudioElement?this._htmlAudioElement.pause():(t=this._streamingSource)===null||t===void 0||t.disconnect(),this.isPlaying=!1,this.isPaused=!0):!((e=Be.$.audioEngine)===null||e===void 0)&&e.audioContext&&this._soundSource&&(this._soundSource.onended=function(){},this._soundSource.stop(),this.isPlaying=!1,this.isPaused=!0,this._currentTime+=Be.$.audioEngine.audioContext.currentTime-this._startTime))},r.prototype.setVolume=function(t,e){var n;!((n=Be.$.audioEngine)===null||n===void 0)&&n.canUseWebAudio&&this._soundGain&&(e&&Be.$.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(Be.$.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,Be.$.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,Be.$.audioEngine.audioContext.currentTime+e)):this._soundGain.gain.value=t),this._volume=t},r.prototype.setPlaybackRate=function(t){this._playbackRate=t,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},r.prototype.getPlaybackRate=function(){return this._playbackRate},r.prototype.getVolume=function(){return this._volume},r.prototype.attachToMesh=function(t){var e=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=t,this._spatialSound||(this._spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length))),this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),this._registerFunc=function(n){return e._onRegisterAfterWorldMatrixUpdate(n)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},r.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},r.prototype._onRegisterAfterWorldMatrixUpdate=function(t){var e;if(t.getBoundingInfo){var n=t.getBoundingInfo();this.setPosition(n.boundingSphere.centerWorld)}else this.setPosition(t.absolutePosition);!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},r.prototype.clone=function(){var t=this;if(this._streaming)return null;var e=function(){t._isReadyToPlay?(i._audioBuffer=t.getAudioBuffer(),i._isReadyToPlay=!0,i.autoplay&&i.play(0,t._offset,t._length)):setTimeout(e,300)},n={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this._spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},i=new r(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,n);return this.useCustomAttenuation&&i.setAttenuationFunction(this._customAttenuationFunction),i.setPosition(this._position),i.setPlaybackRate(this._playbackRate),e(),i},r.prototype.getAudioBuffer=function(){return this._audioBuffer},r.prototype.getSoundSource=function(){return this._soundSource},r.prototype.getSoundGain=function(){return this._soundGain},r.prototype.serialize=function(){var t={name:this.name,url:this._url,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this._spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId,metadata:this.metadata};return this._spatialSound&&(this._connectedTransformNode&&(t.connectedMeshId=this._connectedTransformNode.id),t.position=this._position.asArray(),t.refDistance=this.refDistance,t.distanceModel=this.distanceModel,t.isDirectional=this._isDirectional,t.localDirectionToMesh=this._localDirection.asArray(),t.coneInnerAngle=this._coneInnerAngle,t.coneOuterAngle=this._coneOuterAngle,t.coneOuterGain=this._coneOuterGain),t},r.Parse=function(t,e,n,i){var o,a=t.name;o=t.url?n+t.url:n+a;var s,l={autoplay:t.autoplay,loop:t.loop,volume:t.volume,spatialSound:t.spatialSound,maxDistance:t.maxDistance,rolloffFactor:t.rolloffFactor,refDistance:t.refDistance,distanceModel:t.distanceModel,playbackRate:t.playbackRate};if(i){var c=function(){i._isReadyToPlay?(s._audioBuffer=i.getAudioBuffer(),s._isReadyToPlay=!0,s.autoplay&&s.play(0,s._offset,s._length)):setTimeout(c,300)};s=new r(a,new ArrayBuffer(0),e,null,l),c()}else s=new r(a,o,e,function(){e.removePendingData(s)},l),e.addPendingData(s);if(t.position){var u=_.Pq.FromArray(t.position);s.setPosition(u)}if(t.isDirectional&&(s.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=_.Pq.FromArray(t.localDirectionToMesh);s.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var h=e.getMeshById(t.connectedMeshId);h&&s.attachToMesh(h)}return t.metadata&&(s.metadata=t.metadata),s},r.prototype._setOffset=function(t){this._offset!==t&&(this.isPaused&&(this.stop(),this.isPaused=!1),this._offset=t)},r.prototype._clearTimeoutsAndObservers=function(){var t;this._tryToPlayTimeout&&(clearTimeout(this._tryToPlayTimeout),this._tryToPlayTimeout=null),this._audioUnlockedObserver&&((t=Be.$.audioEngine)===null||t===void 0||t.onAudioUnlockedObservable.remove(this._audioUnlockedObserver),this._audioUnlockedObserver=null)},r._SceneComponentInitialization=function(t){throw(0,gt.n)("AudioSceneComponent")},r}();(0,j.Y5)("BABYLON.Sound",Jo);var im=function(){function r(t,e){e===void 0&&(e={}),this.id=-1,this._isInitialized=!1,(t=t||Ve.q.LastCreatedScene)&&(this._scene=t,this.soundCollection=[],this._options=e,!this._options.mainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1))}return r.prototype._initializeSoundTrackAudioGraph=function(){var t;!((t=Be.$.audioEngine)===null||t===void 0)&&t.canUseWebAudio&&Be.$.audioEngine.audioContext&&(this._outputAudioNode=Be.$.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Be.$.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},r.prototype.dispose=function(){if(Be.$.audioEngine&&Be.$.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},r.prototype.addSound=function(t){var e;this._isInitialized||this._initializeSoundTrackAudioGraph(),!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._outputAudioNode&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId!==void 0&&(t.soundTrackId===-1?this._scene.mainSoundTrack.removeSound(t):this._scene.soundTracks&&this._scene.soundTracks[t.soundTrackId].removeSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},r.prototype.removeSound=function(t){var e=this.soundCollection.indexOf(t);e!==-1&&this.soundCollection.splice(e,1)},r.prototype.setVolume=function(t){var e;!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=t)},r.prototype.switchPanningModelToHRTF=function(){var t;if(!((t=Be.$.audioEngine)===null||t===void 0)&&t.canUseWebAudio)for(var e=0;e<this.soundCollection.length;e++)this.soundCollection[e].switchPanningModelToHRTF()},r.prototype.switchPanningModelToEqualPower=function(){var t;if(!((t=Be.$.audioEngine)===null||t===void 0)&&t.canUseWebAudio)for(var e=0;e<this.soundCollection.length;e++)this.soundCollection[e].switchPanningModelToEqualPower()},r.prototype.connectToAnalyser=function(t){var e;this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser=t,!((e=Be.$.audioEngine)===null||e===void 0)&&e.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,Be.$.audioEngine.masterGain))},r}();nt.d.AddParser(lt.v.NAME_AUDIO,function(r,t,e,n){var i,o,a=[];if(e.sounds=e.sounds||[],r.sounds!==void 0&&r.sounds!==null)for(var s=0,l=r.sounds.length;s<l;s++){var c=r.sounds[s];!((i=Be.$.audioEngine)===null||i===void 0)&&i.canUseWebAudio?(c.url||(c.url=c.name),a[c.url]?e.sounds.push(Jo.Parse(c,t,n,a[c.url])):(o=Jo.Parse(c,t,n),a[c.url]=o,e.sounds.push(o))):e.sounds.push(new Jo(c.name,null,t))}a=[]}),Object.defineProperty(ke.Z.prototype,"mainSoundTrack",{get:function(){var r=this._getComponent(lt.v.NAME_AUDIO);return r||(r=new nr(this),this._addComponent(r)),this._mainSoundTrack||(this._mainSoundTrack=new im(this,{mainTrack:!0})),this._mainSoundTrack},enumerable:!0,configurable:!0}),ke.Z.prototype.getSoundByName=function(r){var t;for(t=0;t<this.mainSoundTrack.soundCollection.length;t++)if(this.mainSoundTrack.soundCollection[t].name===r)return this.mainSoundTrack.soundCollection[t];if(this.soundTracks){for(var e=0;e<this.soundTracks.length;e++)for(t=0;t<this.soundTracks[e].soundCollection.length;t++)if(this.soundTracks[e].soundCollection[t].name===r)return this.soundTracks[e].soundCollection[t]}return null},Object.defineProperty(ke.Z.prototype,"audioEnabled",{get:function(){var r=this._getComponent(lt.v.NAME_AUDIO);return r||(r=new nr(this),this._addComponent(r)),r.audioEnabled},set:function(r){var t=this._getComponent(lt.v.NAME_AUDIO);t||(t=new nr(this),this._addComponent(t)),r?t.enableAudio():t.disableAudio()},enumerable:!0,configurable:!0}),Object.defineProperty(ke.Z.prototype,"headphone",{get:function(){var r=this._getComponent(lt.v.NAME_AUDIO);return r||(r=new nr(this),this._addComponent(r)),r.headphone},set:function(r){var t=this._getComponent(lt.v.NAME_AUDIO);t||(t=new nr(this),this._addComponent(t)),r?t.switchAudioModeForHeadphones():t.switchAudioModeForNormalSpeakers()},enumerable:!0,configurable:!0}),Object.defineProperty(ke.Z.prototype,"audioListenerPositionProvider",{get:function(){var r=this._getComponent(lt.v.NAME_AUDIO);return r||(r=new nr(this),this._addComponent(r)),r.audioListenerPositionProvider},set:function(r){var t=this._getComponent(lt.v.NAME_AUDIO);if(t||(t=new nr(this),this._addComponent(t)),r&&typeof r!="function")throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");t.audioListenerPositionProvider=r},enumerable:!0,configurable:!0}),Object.defineProperty(ke.Z.prototype,"audioListenerRotationProvider",{get:function(){var r=this._getComponent(lt.v.NAME_AUDIO);return r||(r=new nr(this),this._addComponent(r)),r.audioListenerRotationProvider},set:function(r){var t=this._getComponent(lt.v.NAME_AUDIO);if(t||(t=new nr(this),this._addComponent(t)),r&&typeof r!="function")throw new Error("The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3");t.audioListenerRotationProvider=r},enumerable:!0,configurable:!0}),Object.defineProperty(ke.Z.prototype,"audioPositioningRefreshRate",{get:function(){var r=this._getComponent(lt.v.NAME_AUDIO);return r||(r=new nr(this),this._addComponent(r)),r.audioPositioningRefreshRate},set:function(r){var t=this._getComponent(lt.v.NAME_AUDIO);t||(t=new nr(this),this._addComponent(t)),t.audioPositioningRefreshRate=r},enumerable:!0,configurable:!0});var nr=function(){function r(t){this.name=lt.v.NAME_AUDIO,this._audioEnabled=!0,this._headphone=!1,this.audioPositioningRefreshRate=500,this.audioListenerPositionProvider=null,this.audioListenerRotationProvider=null,this._cachedCameraDirection=new _.Pq,this._cachedCameraPosition=new _.Pq,this._lastCheck=0,this._invertMatrixTemp=new _.uq,this._cameraDirectionTemp=new _.Pq,(t=t||Ve.q.LastCreatedScene)&&(this.scene=t,t.soundTracks=[],t.sounds=[])}return Object.defineProperty(r.prototype,"audioEnabled",{get:function(){return this._audioEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"headphone",{get:function(){return this._headphone},enumerable:!1,configurable:!0}),r.prototype.register=function(){this.scene._afterRenderStage.registerStep(lt.v.STEP_AFTERRENDER_AUDIO,this,this._afterRender)},r.prototype.rebuild=function(){},r.prototype.serialize=function(t){if(t.sounds=[],this.scene.soundTracks)for(var e=0;e<this.scene.soundTracks.length;e++)for(var n=this.scene.soundTracks[e],i=0;i<n.soundCollection.length;i++)t.sounds.push(n.soundCollection[i].serialize())},r.prototype.addFromContainer=function(t){var e=this;t.sounds&&t.sounds.forEach(function(n){n.play(),n.autoplay=!0,e.scene.mainSoundTrack.addSound(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;e===void 0&&(e=!1),t.sounds&&t.sounds.forEach(function(i){i.stop(),i.autoplay=!1,n.scene.mainSoundTrack.removeSound(i),e&&i.dispose()})},r.prototype.dispose=function(){var t=this.scene;if(t._mainSoundTrack&&t.mainSoundTrack.dispose(),t.soundTracks)for(var e=0;e<t.soundTracks.length;e++)t.soundTracks[e].dispose()},r.prototype.disableAudio=function(){var t,e=this.scene;for(this._audioEnabled=!1,Be.$.audioEngine&&Be.$.audioEngine.audioContext&&Be.$.audioEngine.audioContext.suspend(),t=0;t<e.mainSoundTrack.soundCollection.length;t++)e.mainSoundTrack.soundCollection[t].pause();if(e.soundTracks)for(t=0;t<e.soundTracks.length;t++)for(var n=0;n<e.soundTracks[t].soundCollection.length;n++)e.soundTracks[t].soundCollection[n].pause()},r.prototype.enableAudio=function(){var t,e=this.scene;for(this._audioEnabled=!0,Be.$.audioEngine&&Be.$.audioEngine.audioContext&&Be.$.audioEngine.audioContext.resume(),t=0;t<e.mainSoundTrack.soundCollection.length;t++)e.mainSoundTrack.soundCollection[t].isPaused&&e.mainSoundTrack.soundCollection[t].play();if(e.soundTracks)for(t=0;t<e.soundTracks.length;t++)for(var n=0;n<e.soundTracks[t].soundCollection.length;n++)e.soundTracks[t].soundCollection[n].isPaused&&e.soundTracks[t].soundCollection[n].play()},r.prototype.switchAudioModeForHeadphones=function(){var t=this.scene;if(this._headphone=!0,t.mainSoundTrack.switchPanningModelToHRTF(),t.soundTracks)for(var e=0;e<t.soundTracks.length;e++)t.soundTracks[e].switchPanningModelToHRTF()},r.prototype.switchAudioModeForNormalSpeakers=function(){var t=this.scene;if(this._headphone=!1,t.mainSoundTrack.switchPanningModelToEqualPower(),t.soundTracks)for(var e=0;e<t.soundTracks.length;e++)t.soundTracks[e].switchPanningModelToEqualPower()},r.prototype._afterRender=function(){var t=et.j.Now;if(!(this._lastCheck&&t-this._lastCheck<this.audioPositioningRefreshRate)){this._lastCheck=t;var e=this.scene;if(this._audioEnabled&&e._mainSoundTrack&&e.soundTracks&&(e._mainSoundTrack.soundCollection.length!==0||e.soundTracks.length!==1)){var n=Be.$.audioEngine;if(n&&n.audioContext){var i=e.activeCamera;if(e.activeCameras&&e.activeCameras.length>0&&(i=e.activeCameras[0]),this.audioListenerPositionProvider){var o=this.audioListenerPositionProvider();n.audioContext.listener.setPosition(o.x||0,o.y||0,o.z||0)}else i?this._cachedCameraPosition.equals(i.globalPosition)||(this._cachedCameraPosition.copyFrom(i.globalPosition),n.audioContext.listener.setPosition(i.globalPosition.x,i.globalPosition.y,i.globalPosition.z)):n.audioContext.listener.setPosition(0,0,0);if(this.audioListenerRotationProvider){var a=this.audioListenerRotationProvider();n.audioContext.listener.setOrientation(a.x||0,a.y||0,a.z||0,0,1,0)}else i?(i.rigCameras&&i.rigCameras.length>0&&(i=i.rigCameras[0]),i.getViewMatrix().invertToRef(this._invertMatrixTemp),_.Pq.TransformNormalToRef(r._CameraDirection,this._invertMatrixTemp,this._cameraDirectionTemp),this._cameraDirectionTemp.normalize(),isNaN(this._cameraDirectionTemp.x)||isNaN(this._cameraDirectionTemp.y)||isNaN(this._cameraDirectionTemp.z)||this._cachedCameraDirection.equals(this._cameraDirectionTemp)||(this._cachedCameraDirection.copyFrom(this._cameraDirectionTemp),n.audioContext.listener.setOrientation(this._cameraDirectionTemp.x,this._cameraDirectionTemp.y,this._cameraDirectionTemp.z,0,1,0))):n.audioContext.listener.setOrientation(0,0,0,0,1,0);var s=void 0;for(s=0;s<e.mainSoundTrack.soundCollection.length;s++)(c=e.mainSoundTrack.soundCollection[s]).useCustomAttenuation&&c.updateDistanceFromListener();if(e.soundTracks)for(s=0;s<e.soundTracks.length;s++)for(var l=0;l<e.soundTracks[s].soundCollection.length;l++){var c;(c=e.soundTracks[s].soundCollection[l]).useCustomAttenuation&&c.updateDistanceFromListener()}}}}},r._CameraDirection=new _.Pq(0,0,-1),r}();Jo._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_AUDIO);t||(t=new nr(r),r._addComponent(t))};var VS=function(){function r(t,e,n){var i=this;if(this.loop=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._volume=1,this.isPlaying=!1,this.isPaused=!1,this._sounds=[],this._weights=[],e.length!==n.length)throw new Error("Sounds length does not equal weights length");this.loop=t,this._weights=n;for(var o=0,a=0,s=n;a<s.length;a++)o+=s[a];for(var l=o>0?1/o:0,c=0;c<this._weights.length;c++)this._weights[c]*=l;this._sounds=e;for(var u=0,d=this._sounds;u<d.length;u++)d[u].onEndedObservable.add(function(){i._onended()})}return Object.defineProperty(r.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(t){if(t!==this._coneInnerAngle){if(this._coneOuterAngle<t)return void O.V.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=t;for(var e=0,n=this._sounds;e<n.length;e++)n[e].directionalConeInnerAngle=t}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(t){if(t!==this._coneOuterAngle){if(t<this._coneInnerAngle)return void O.V.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=t;for(var e=0,n=this._sounds;e<n.length;e++)n[e].directionalConeOuterAngle=t}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"volume",{get:function(){return this._volume},set:function(t){if(t!==this._volume)for(var e=0,n=this._sounds;e<n.length;e++)n[e].setVolume(t)},enumerable:!1,configurable:!0}),r.prototype._onended=function(){this._currentIndex!==void 0&&(this._sounds[this._currentIndex].autoplay=!1),this.loop&&this.isPlaying?this.play():this.isPlaying=!1},r.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._currentIndex!==void 0&&this._sounds[this._currentIndex].pause())},r.prototype.stop=function(){this.isPlaying=!1,this._currentIndex!==void 0&&this._sounds[this._currentIndex].stop()},r.prototype.play=function(t){var e;if(!this.isPaused){this.stop();for(var n=Math.random(),i=0,o=0;o<this._weights.length;o++)if(n<=(i+=this._weights[o])){this._currentIndex=o;break}}var a=this._sounds[(e=this._currentIndex)!==null&&e!==void 0?e:0];a.isReady()?a.play(0,this.isPaused?void 0:t):a.autoplay=!0,this.isPlaying=!0,this.isPaused=!1},r}(),US=function(){function r(t){this._texture=null,this._isEnabled=!0,this.isEnabled=!0,this.time=0,(t=t||Ve.q.LastCreatedScene)&&(this._scene=t,this.animationParameters=new _.IU(0,0,0,30))}return r.prototype._markSubMeshesAsAttributesDirty=function(){for(var t=0,e=this._scene.meshes;t<e.length;t++){var n=e[t];n.bakedVertexAnimationManager===this&&n._markSubMeshesAsAttributesDirty()}},r.prototype.bind=function(t,e){if(e===void 0&&(e=!1),this._texture&&this._isEnabled){var n=this._texture.getSize();t.setFloat2("bakedVertexAnimationTextureSizeInverted",1/n.width,1/n.height),t.setFloat("bakedVertexAnimationTime",this.time),e||t.setVector4("bakedVertexAnimationSettings",this.animationParameters),t.setTexture("bakedVertexAnimationTexture",this._texture)}},r.prototype.clone=function(){var t=new r(this._scene);return this.copyTo(t),t},r.prototype.setAnimationParameters=function(t,e,n,i){n===void 0&&(n=0),i===void 0&&(i=30),this.animationParameters=new _.IU(t,e,n,i)},r.prototype.dispose=function(t){var e;t&&((e=this._texture)===null||e===void 0||e.dispose())},r.prototype.getClassName=function(){return"BakedVertexAnimationManager"},r.prototype.copyTo=function(t){tt.p.Clone(function(){return t},this)},r.prototype.serialize=function(){return tt.p.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;tt.p.Parse(function(){return i},t,e,n)},(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markSubMeshesAsAttributesDirty")],r.prototype,"texture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markSubMeshesAsAttributesDirty")],r.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"animationParameters",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"time",void 0),r}(),Ie=L(50582),rn=L(19133),an=L(96352),ir=L(87074);function GS(r,t,e,n){var i,o=1;n===P.Y.TEXTURETYPE_FLOAT?i=new Float32Array(t*e*4):n===P.Y.TEXTURETYPE_HALF_FLOAT?(i=new Uint16Array(t*e*4),o=15360):i=n===P.Y.TEXTURETYPE_UNSIGNED_INTEGER?new Uint32Array(t*e*4):new Uint8Array(t*e*4);for(var a=0;a<t;a++)for(var s=0;s<e;s++){var l=3*(s*t+a),c=4*(s*t+a);i[c+0]=r[l+0],i[c+1]=r[l+1],i[c+2]=r[l+2],i[c+3]=o}return i}function kS(r){return function(t,e,n,i,o,a,s,l,c,u){c===void 0&&(c=null),u===void 0&&(u=P.Y.TEXTURETYPE_UNSIGNED_INT);var d=r?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,h=r?10:11,p=new rn.h(this,h);p.baseWidth=e,p.baseHeight=n,p.baseDepth=i,p.width=e,p.height=n,p.depth=i,p.format=o,p.type=u,p.generateMipMaps=a,p.samplingMode=l,r?p.is3D=!0:p.is2DArray=!0,this._doNotHandleContextLost||(p._bufferView=t),r?this.updateRawTexture3D(p,t,o,s,c,u):this.updateRawTexture2DArray(p,t,o,s,c,u),this._bindTextureDirectly(d,p,!0);var m=this._getSamplingParameters(l,a);return this._gl.texParameteri(d,this._gl.TEXTURE_MAG_FILTER,m.mag),this._gl.texParameteri(d,this._gl.TEXTURE_MIN_FILTER,m.min),a&&this._gl.generateMipmap(d),this._bindTextureDirectly(d,null),this._internalTexturesCache.push(p),p}}function zS(r){return function(t,e,n,i,o,a){o===void 0&&(o=null),a===void 0&&(a=P.Y.TEXTURETYPE_UNSIGNED_INT);var s=r?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,l=this._getWebGLTextureType(a),c=this._getInternalFormat(n),u=this._getRGBABufferInternalSizedFormat(a,n);this._bindTextureDirectly(s,t,!0),this._unpackFlipY(i===void 0||!!i),this._doNotHandleContextLost||(t._bufferView=e,t.format=n,t.invertY=i,t._compression=o),t.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&e?this._gl.compressedTexImage3D(s,0,this.getCaps().s3tc[o],t.width,t.height,t.depth,0,e):this._gl.texImage3D(s,0,u,t.width,t.height,t.depth,0,c,l,e),t.generateMipMaps&&this._gl.generateMipmap(s),this._bindTextureDirectly(s,null),t.isReady=!0}}an.w.prototype.updateRawTexture=function(r,t,e,n,i,o,a){if(i===void 0&&(i=null),o===void 0&&(o=P.Y.TEXTURETYPE_UNSIGNED_INT),a===void 0&&(a=!1),r){var s=this._getRGBABufferInternalSizedFormat(o,e,a),l=this._getInternalFormat(e),c=this._getWebGLTextureType(o);this._bindTextureDirectly(this._gl.TEXTURE_2D,r,!0),this._unpackFlipY(n===void 0||!!n),this._doNotHandleContextLost||(r._bufferView=t,r.format=e,r.type=o,r.invertY=n,r._compression=i),r.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),i&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[i],r.width,r.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,s,r.width,r.height,0,l,c,t),r.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r.isReady=!0}},an.w.prototype.createRawTexture=function(r,t,e,n,i,o,a,s,l,c,u){s===void 0&&(s=null),l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=!1);var d=new rn.h(this,3);d.baseWidth=t,d.baseHeight=e,d.width=t,d.height=e,d.format=n,d.generateMipMaps=i,d.samplingMode=a,d.invertY=o,d._compression=s,d.type=l,d._useSRGBBuffer=this._getUseSRGBBuffer(u,!i),this._doNotHandleContextLost||(d._bufferView=r),this.updateRawTexture(d,r,n,o,s,l,d._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,d,!0);var h=this._getSamplingParameters(a,i);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,h.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,h.min),i&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(d),d},an.w.prototype.createRawCubeTexture=function(r,t,e,n,i,o,a,s){s===void 0&&(s=null);var l=this._gl,c=new rn.h(this,8);c.isCube=!0,c.format=e,c.type=n,this._doNotHandleContextLost||(c._bufferViewArray=r);var u=this._getWebGLTextureType(n),d=this._getInternalFormat(e);d===l.RGB&&(d=l.RGBA),u!==l.FLOAT||this._caps.textureFloatLinearFiltering?u!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?u!==l.FLOAT||this._caps.textureFloatRender?u!==l.HALF_FLOAT||this._caps.colorBufferFloat||(i=!1,O.V.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(i=!1,O.V.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(i=!1,a=P.Y.TEXTURE_NEAREST_SAMPLINGMODE,O.V.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(i=!1,a=P.Y.TEXTURE_NEAREST_SAMPLINGMODE,O.V.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var h=t,p=h;if(c.width=h,c.height=p,c.invertY=o,c._compression=s,!this.needPOTTextures||(0,ir.L8)(c.width)&&(0,ir.L8)(c.height)||(i=!1),r)this.updateRawCubeTexture(c,r,e,n,o,s);else{var m=this._getRGBABufferInternalSizedFormat(n);this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c,!0);for(var v=0;v<6;v++)s?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,this.getCaps().s3tc[s],c.width,c.height,0,void 0):l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,m,c.width,c.height,0,d,u,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,c,!0),r&&i&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var b=this._getSamplingParameters(a,i);return l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,b.mag),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,b.min),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),c.generateMipMaps=i,c.samplingMode=a,c.isReady=!0,c},an.w.prototype.updateRawCubeTexture=function(r,t,e,n,i,o,a){o===void 0&&(o=null),a===void 0&&(a=0),r._bufferViewArray=t,r.format=e,r.type=n,r.invertY=i,r._compression=o;var s=this._gl,l=this._getWebGLTextureType(n),c=this._getInternalFormat(e),u=this._getRGBABufferInternalSizedFormat(n),d=!1;c===s.RGB&&(c=s.RGBA,d=!0),this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,r,!0),this._unpackFlipY(i===void 0||!!i),r.width%4!=0&&s.pixelStorei(s.UNPACK_ALIGNMENT,1);for(var h=0;h<6;h++){var p=t[h];o?s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+h,a,this.getCaps().s3tc[o],r.width,r.height,0,p):(d&&(p=GS(p,r.width,r.height,n)),s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+h,a,u,r.width,r.height,0,c,l,p))}(!this.needPOTTextures||(0,ir.L8)(r.width)&&(0,ir.L8)(r.height))&&r.generateMipMaps&&a===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),r.isReady=!0},an.w.prototype.createRawCubeTextureFromUrl=function(r,t,e,n,i,o,a,s,l,c,u,d){var h=this;l===void 0&&(l=null),c===void 0&&(c=null),u===void 0&&(u=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),d===void 0&&(d=!1);var p=this._gl,m=this.createRawCubeTexture(null,e,n,i,!o,d,u,null);return t?.addPendingData(m),m.url=r,m.isReady=!1,this._internalTexturesCache.push(m),this._loadFile(r,function(v){(function(b){var E=m.width,C=a(b);if(C){if(s){var T=h._getWebGLTextureType(i),f=h._getInternalFormat(n),g=h._getRGBABufferInternalSizedFormat(i),S=!1;f===p.RGB&&(f=p.RGBA,S=!0),h._bindTextureDirectly(p.TEXTURE_CUBE_MAP,m,!0),h._unpackFlipY(!1);for(var y=s(C),x=0;x<y.length;x++)for(var R=E>>x,I=0;I<6;I++){var M=y[x][I];S&&(M=GS(M,R,R,i)),p.texImage2D(I,x,g,R,R,0,f,T,M)}h._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else h.updateRawCubeTexture(m,C,n,i,d);m.isReady=!0,t?.removePendingData(m),m.onLoadedObservable.notifyObservers(m),m.onLoadedObservable.clear(),l&&l()}})(v)},void 0,t?.offlineProvider,!0,function(v,b){t?.removePendingData(m),c&&v&&c(v.status+" "+v.statusText,b)}),m},an.w.prototype.createRawTexture2DArray=kS(!1),an.w.prototype.createRawTexture3D=kS(!0),an.w.prototype.updateRawTexture2DArray=zS(!1),an.w.prototype.updateRawTexture3D=zS(!0);var Ln=function(r){function t(e,n,i,o,a,s,l,c,u,d,h){s===void 0&&(s=!0),l===void 0&&(l=!1),c===void 0&&(c=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),u===void 0&&(u=P.Y.TEXTURETYPE_UNSIGNED_INT);var p=r.call(this,null,a,!s,l,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,d)||this;return p.format=o,p._engine&&(p._engine._caps.textureFloatLinearFiltering||u!==P.Y.TEXTURETYPE_FLOAT||(c=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),p._engine._caps.textureHalfFloatLinearFiltering||u!==P.Y.TEXTURETYPE_HALF_FLOAT||(c=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),p._texture=p._engine.createRawTexture(e,n,i,o,s,l,c,null,u,d??0,h!=null&&h),p.wrapU=Ie.g.CLAMP_ADDRESSMODE,p.wrapV=Ie.g.CLAMP_ADDRESSMODE),p}return(0,A.C6)(t,r),t.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,this._texture._useSRGBBuffer)},t.prototype.clone=function(){if(!this._texture)return r.prototype.clone.call(this);var e=new t(null,this.getSize().width,this.getSize().height,this.format,this.getScene(),this._texture.generateMipMaps,this._invertY,this.samplingMode,this._texture.type,this._texture._creationFlags,this._useSRGBBuffer);return e._texture=this._texture,this._texture.incrementReferences(),e},t.CreateLuminanceTexture=function(e,n,i,o,a,s,l){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,n,i,P.Y.TEXTUREFORMAT_LUMINANCE,o,a,s,l)},t.CreateLuminanceAlphaTexture=function(e,n,i,o,a,s,l){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,n,i,P.Y.TEXTUREFORMAT_LUMINANCE_ALPHA,o,a,s,l)},t.CreateAlphaTexture=function(e,n,i,o,a,s,l){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,n,i,P.Y.TEXTUREFORMAT_ALPHA,o,a,s,l)},t.CreateRGBTexture=function(e,n,i,o,a,s,l,c,u,d){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=0),d===void 0&&(d=!1),new t(e,n,i,P.Y.TEXTUREFORMAT_RGB,o,a,s,l,c,u,d)},t.CreateRGBATexture=function(e,n,i,o,a,s,l,c,u,d){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=0),d===void 0&&(d=!1),new t(e,n,i,P.Y.TEXTUREFORMAT_RGBA,o,a,s,l,c,u,d)},t.CreateRGBAStorageTexture=function(e,n,i,o,a,s,l,c,u){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=!1),new t(e,n,i,P.Y.TEXTUREFORMAT_RGBA,o,a,s,l,c,P.Y.TEXTURE_CREATIONFLAG_STORAGE,u)},t.CreateRTexture=function(e,n,i,o,a,s,l,c){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=Ie.g.TRILINEAR_SAMPLINGMODE),c===void 0&&(c=P.Y.TEXTURETYPE_FLOAT),new t(e,n,i,P.Y.TEXTUREFORMAT_R,o,a,s,l,c)},t.CreateRStorageTexture=function(e,n,i,o,a,s,l,c){return a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=Ie.g.TRILINEAR_SAMPLINGMODE),c===void 0&&(c=P.Y.TEXTURETYPE_FLOAT),new t(e,n,i,P.Y.TEXTUREFORMAT_R,o,a,s,l,c,P.Y.TEXTURE_CREATIONFLAG_STORAGE)},t}(Ie.g),fi=L(37530),xa=function(){function r(t,e,n){this.name=t,this.id=e,this.bones=[],this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=_.uq.Identity(),this._currentRenderId=-1,this._ranges={},this._absoluteTransformIsDirty=!0,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._parentContainer=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new K.cP,this.bones=[],this._scene=n||Ve.q.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var i=this._scene.getEngine().getCaps();this._canUseTextureForBones=i.textureFloat&&i.maxVertexTextureImageUnits>0}return Object.defineProperty(r.prototype,"useTextureToStoreBoneMatrices",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(t){this._useTextureToStoreBoneMatrices=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(t){this._animationPropertiesOverride=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"Skeleton"},r.prototype.getChildren=function(){return this.bones.filter(function(t){return!t.getParent()})},r.prototype.getTransformMatrices=function(t){if(this.needInitialSkinMatrix){if(!t)throw new Error("getTransformMatrices: When using the needInitialSkinMatrix flag, a mesh must be provided");return t._bonesTransformMatrices||this.prepare(!0),t._bonesTransformMatrices}return this._transformMatrices&&!this._isDirty||this.prepare(!this._transformMatrices),this._transformMatrices},r.prototype.getTransformMatrixTexture=function(t){return this.needInitialSkinMatrix&&t._transformMatrixTexture?t._transformMatrixTexture:this._transformMatrixTexture},r.prototype.getScene=function(){return this._scene},r.prototype.toString=function(t){var e="Name: ".concat(this.name,", nBones: ").concat(this.bones.length);if(e+=", nAnimationRanges: ".concat(this._ranges?Object.keys(this._ranges).length:"none"),t){e+=", Ranges: {";var n=!0;for(var i in this._ranges)n&&(e+=", ",n=!1),e+=i;e+="}"}return e},r.prototype.getBoneIndexByName=function(t){for(var e=0,n=this.bones.length;e<n;e++)if(this.bones[e].name===t)return e;return-1},r.prototype.createAnimationRange=function(t,e,n){if(!this._ranges[t]){this._ranges[t]=new kt(t,e,n);for(var i=0,o=this.bones.length;i<o;i++)this.bones[i].animations[0]&&this.bones[i].animations[0].createRange(t,e,n)}},r.prototype.deleteAnimationRange=function(t,e){e===void 0&&(e=!0);for(var n=0,i=this.bones.length;n<i;n++)this.bones[n].animations[0]&&this.bones[n].animations[0].deleteRange(t,e);this._ranges[t]=null},r.prototype.getAnimationRange=function(t){return this._ranges[t]||null},r.prototype.getAnimationRanges=function(){var t,e=[];for(t in this._ranges)e.push(this._ranges[t]);return e},r.prototype.copyAnimationRange=function(t,e,n){if(n===void 0&&(n=!1),this._ranges[e]||!t.getAnimationRange(e))return!1;var i,o,a=!0,s=this._getHighestAnimationFrame()+1,l={},c=t.bones;for(o=0,i=c.length;o<i;o++)l[c[o].name]=c[o];this.bones.length!==c.length&&(O.V.Warn("copyAnimationRange: this rig has ".concat(this.bones.length," bones, while source as ").concat(c.length)),a=!1);var u=n&&this.dimensionsAtRest&&t.dimensionsAtRest?this.dimensionsAtRest.divide(t.dimensionsAtRest):null;for(o=0,i=this.bones.length;o<i;o++){var d=this.bones[o].name,h=l[d];h?a=a&&this.bones[o].copyAnimationRange(h,e,s,n,u):(O.V.Warn("copyAnimationRange: not same rig, missing source bone "+d),a=!1)}var p=t.getAnimationRange(e);return p&&(this._ranges[e]=new kt(e,p.from+s,p.to+s)),a},r.prototype.returnToRest=function(){for(var t=0,e=this.bones;t<e.length;t++){var n=e[t];n._index!==-1&&n.returnToRest()}},r.prototype._getHighestAnimationFrame=function(){for(var t=0,e=0,n=this.bones.length;e<n;e++)if(this.bones[e].animations[0]){var i=this.bones[e].animations[0].getHighestFrame();t<i&&(t=i)}return t},r.prototype.beginAnimation=function(t,e,n,i){var o=this.getAnimationRange(t);return o?this._scene.beginAnimation(this,o.from,o.to,e,n,i):null},r.MakeAnimationAdditive=function(t,e,n){e===void 0&&(e=0);var i=t.getAnimationRange(n);if(!i)return null;for(var o=t._scene.getAllAnimatablesByTarget(t),a=null,s=0;s<o.length;s++){var l=o[s];if(l.fromFrame===i?.from&&l.toFrame===i?.to){a=l;break}}var c=t.getAnimatables();for(s=0;s<c.length;s++){var u=c[s].animations;if(u)for(var d=0;d<u.length;d++)Le.MakeAnimationAdditive(u[d],e,n)}return a&&(a.isAdditive=!0),t},r.prototype._markAsDirty=function(){this._isDirty=!0,this._absoluteTransformIsDirty=!0},r.prototype._registerMeshWithPoseMatrix=function(t){this._meshesWithPoseMatrix.push(t)},r.prototype._unregisterMeshWithPoseMatrix=function(t){var e=this._meshesWithPoseMatrix.indexOf(t);e>-1&&this._meshesWithPoseMatrix.splice(e,1)},r.prototype._computeTransformMatrices=function(t,e){this.onBeforeComputeObservable.notifyObservers(this);for(var n=0;n<this.bones.length;n++){var i=this.bones[n];i._childUpdateId++;var o=i.getParent();if(o?i.getLocalMatrix().multiplyToRef(o.getFinalMatrix(),i.getFinalMatrix()):e?i.getLocalMatrix().multiplyToRef(e,i.getFinalMatrix()):i.getFinalMatrix().copyFrom(i.getLocalMatrix()),i._index!==-1){var a=i._index===null?n:i._index;i.getAbsoluteInverseBindMatrix().multiplyToArray(i.getFinalMatrix(),t,16*a)}}this._identity.copyToArray(t,16*this.bones.length)},r.prototype.prepare=function(t){if(t===void 0&&(t=!1),!t){var e=this.getScene().getRenderId();if(this._currentRenderId===e)return;this._currentRenderId=e}if(this._numBonesWithLinkedTransformNode>0){for(var n=0,i=this.bones;n<i.length;n++)if((p=i[n])._linkedTransformNode){var o=p._linkedTransformNode;p.position=o.position,o.rotationQuaternion?p.rotationQuaternion=o.rotationQuaternion:p.rotation=o.rotation,p.scaling=o.scaling}}if(this.needInitialSkinMatrix)for(var a=0,s=this._meshesWithPoseMatrix;a<s.length;a++){var l=s[a],c=l.getPoseMatrix(),u=this._isDirty;if(l._bonesTransformMatrices&&l._bonesTransformMatrices.length===16*(this.bones.length+1)||(l._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1)),u=!0),u){if(this._synchronizedWithMesh!==l){this._synchronizedWithMesh=l;for(var d=0,h=this.bones;d<h.length;d++){var p;(p=h[d]).getParent()||(p.getBindMatrix().multiplyToRef(c,_.AA.Matrix[1]),p._updateAbsoluteBindMatrices(_.AA.Matrix[1]))}if(this.isUsingTextureForMatrices){var m=4*(this.bones.length+1);l._transformMatrixTexture&&l._transformMatrixTexture.getSize().width===m||(l._transformMatrixTexture&&l._transformMatrixTexture.dispose(),l._transformMatrixTexture=Ln.CreateRGBATexture(l._bonesTransformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT))}}this._computeTransformMatrices(l._bonesTransformMatrices,c),this.isUsingTextureForMatrices&&l._transformMatrixTexture&&l._transformMatrixTexture.update(l._bonesTransformMatrices)}}else{if(!this._isDirty)return;this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1)),this.isUsingTextureForMatrices&&(this._transformMatrixTexture&&this._transformMatrixTexture.dispose(),this._transformMatrixTexture=Ln.CreateRGBATexture(this._transformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT))),this._computeTransformMatrices(this._transformMatrices,null),this.isUsingTextureForMatrices&&this._transformMatrixTexture&&this._transformMatrixTexture.update(this._transformMatrices)}this._isDirty=!1},r.prototype.getAnimatables=function(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(var t=0;t<this.bones.length;t++)this._animatables.push(this.bones[t])}return this._animatables},r.prototype.clone=function(t,e){var n=new r(t,e||t,this._scene);n.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var i=0;i<this.bones.length;i++){var o=this.bones[i],a=null,s=o.getParent();if(s){var l=this.bones.indexOf(s);a=n.bones[l]}var c=new Ct(o.name,n,a,o.getBindMatrix().clone(),o.getRestMatrix().clone());c._index=o._index,o._linkedTransformNode&&c.linkTransformNode(o._linkedTransformNode),ot.r.DeepCopy(o.animations,c.animations)}if(this._ranges)for(var u in n._ranges={},this._ranges){var d=this._ranges[u];d&&(n._ranges[u]=d.clone())}return this._isDirty=!0,n.prepare(!0),n},r.prototype.enableBlending=function(t){t===void 0&&(t=.01),this.bones.forEach(function(e){e.animations.forEach(function(n){n.enableBlending=!0,n.blendingSpeed=t})})},r.prototype.dispose=function(){if(this._meshesWithPoseMatrix.length=0,this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this),this._parentContainer){var t=this._parentContainer.skeletons.indexOf(this);t>-1&&this._parentContainer.skeletons.splice(t,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)},r.prototype.serialize=function(){var t,e={};e.name=this.name,e.id=this.id,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var n=0;n<this.bones.length;n++){var i=this.bones[n],o=i.getParent(),a={parentBoneIndex:o?this.bones.indexOf(o):-1,index:i.getIndex(),name:i.name,id:i.id,matrix:i.getBindMatrix().asArray(),rest:i.getRestMatrix().asArray(),linkedTransformNodeId:(t=i.getTransformNode())===null||t===void 0?void 0:t.id};for(var s in e.bones.push(a),i.length&&(a.length=i.length),i.metadata&&(a.metadata=i.metadata),i.animations&&i.animations.length>0&&(a.animation=i.animations[0].serialize()),e.ranges=[],this._ranges){var l=this._ranges[s];if(l){var c={};c.name=s,c.from=l.from,c.to=l.to,e.ranges.push(c)}}}return e},r.Parse=function(t,e){var n,i=new r(t.name,t.id,e);for(t.dimensionsAtRest&&(i.dimensionsAtRest=_.Pq.FromArray(t.dimensionsAtRest)),i.needInitialSkinMatrix=t.needInitialSkinMatrix,n=0;n<t.bones.length;n++){var o=t.bones[n],a=t.bones[n].index,s=null;o.parentBoneIndex>-1&&(s=i.bones[o.parentBoneIndex]);var l=o.rest?_.uq.FromArray(o.rest):null,c=new Ct(o.name,i,s,_.uq.FromArray(o.matrix),l,null,a);o.id!==void 0&&o.id!==null&&(c.id=o.id),o.length&&(c.length=o.length),o.metadata&&(c.metadata=o.metadata),o.animation&&c.animations.push(Le.Parse(o.animation)),o.linkedTransformNodeId!==void 0&&o.linkedTransformNodeId!==null&&(i._hasWaitingData=!0,c._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(n=0;n<t.ranges.length;n++){var u=t.ranges[n];i.createAnimationRange(u.name,u.from,u.to)}return i},r.prototype.computeAbsoluteMatrices=function(t){t===void 0&&(t=!1),(this._absoluteTransformIsDirty||t)&&(this.bones[0].computeAbsoluteMatrices(),this._absoluteTransformIsDirty=!1)},r.prototype.computeAbsoluteTransforms=function(t){t===void 0&&(t=!1),this.computeAbsoluteMatrices(t)},r.prototype.getPoseMatrix=function(){var t=null;return this._meshesWithPoseMatrix.length>0&&(t=this._meshesWithPoseMatrix[0].getPoseMatrix()),t},r.prototype.sortBones=function(){for(var t=[],e=new Array(this.bones.length),n=0;n<this.bones.length;n++)this._sortBones(n,t,e);this.bones=t},r.prototype._sortBones=function(t,e,n){if(!n[t]){n[t]=!0;var i=this.bones[t];if(i){i._index===void 0&&(i._index=t);var o=i.getParent();o&&this._sortBones(this.bones.indexOf(o),e,n),e.push(i)}}},r.prototype.setCurrentPoseAsRest=function(){this.bones.forEach(function(t){t.setCurrentPoseAsRest()})},r}(),WS=function(){function r(t,e){this._scene=t,e instanceof xa?(this._skeleton=e,this._mesh=null):(this._mesh=e,this._skeleton=e.skeleton)}return r.prototype.bakeVertexData=function(t){return(0,A.sH)(this,void 0,void 0,function(){var e,n,i,o,a,s,l,c;return(0,A.YH)(this,function(u){switch(u.label){case 0:if(!this._skeleton)throw new Error("No skeleton provided.");if(e=this._skeleton.bones.length,n=t.reduce(function(d,h){return d+h.to-h.from+1},0),isNaN(n))throw new Error("Invalid animation ranges.");i=0,o=new Float32Array(4*(e+1)*4*n),this._scene.stopAnimation(this._skeleton),this._skeleton.returnToRest(),a=0,s=t,u.label=1;case 1:if(!(a<s.length))return[3,6];l=s[a],c=l.from,u.label=2;case 2:return c<=l.to?[4,this._executeAnimationFrame(o,c,i++)]:[3,5];case 3:u.sent(),u.label=4;case 4:return c++,[3,2];case 5:return a++,[3,1];case 6:return[2,o]}})})},r.prototype._executeAnimationFrame=function(t,e,n){return(0,A.sH)(this,void 0,void 0,function(){var i=this;return(0,A.YH)(this,function(o){return[2,new Promise(function(a,s){i._scene.beginAnimation(i._skeleton,e,e,!1,1,function(){var l=i._skeleton.getTransformMatrices(i._mesh);t.set(l,n*l.length),a()})})]})})},r.prototype.textureFromBakedVertexData=function(t){if(!this._skeleton)throw new Error("No skeleton provided.");var e=this._skeleton.bones.length,n=Ln.CreateRGBATexture(t,4*(e+1),t.length/(4*(e+1)*4),this._scene,!1,!1,Ie.g.NEAREST_NEAREST,P.Y.TEXTURETYPE_FLOAT);return n.name="VAT"+this._skeleton.name,n},r.prototype.serializeBakedVertexDataToObject=function(t){if(!this._skeleton)throw new Error("No skeleton provided.");var e=this._skeleton.bones.length,n=4*(e+1),i=t.length/(4*(e+1)*4);return{vertexData:(0,fi.EL)(t),width:n,height:i}},r.prototype.loadBakedVertexDataFromObject=function(t){return new Float32Array((0,fi.yS)(t.vertexData))},r.prototype.serializeBakedVertexDataToJSON=function(t){return JSON.stringify(this.serializeBakedVertexDataToObject(t))},r.prototype.loadBakedVertexDataFromJSON=function(t){return this.loadBakedVertexDataFromObject(JSON.parse(t))},r}(),vt=L(64391),rm=function(){function r(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}return Object.defineProperty(r.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(t){this._zoomStopsAnimation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(t){this._idleRotationSpeed=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(t){this._idleRotationWaitTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(t){this._idleRotationSpinupTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rotationInProgress",{get:function(){return Math.abs(this._cameraRotationSpeed)>0},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t){var e=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();this._onPrePointerObservableObserver=n.onPrePointerObservable.add(function(i){i.type!==vt.Zp.POINTERDOWN?i.type===vt.Zp.POINTERUP&&(e._isPointerDown=!1):e._isPointerDown=!0}),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){if(!e._reachTargetAlpha()){var i=et.j.Now,o=0;e._lastFrameTime!=null&&(o=i-e._lastFrameTime),e._lastFrameTime=i,e._applyUserInteraction();var a=i-e._lastInteractionTime-e._idleRotationWaitTime,s=Math.max(Math.min(a/e._idleRotationSpinupTime,1),0);e._cameraRotationSpeed=e._idleRotationSpeed*s,e._attachedCamera&&(e._attachedCamera.alpha-=e._cameraRotationSpeed*(o/1e3))}})},r.prototype.detach=function(){if(this._attachedCamera){var t=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&t.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},r.prototype.resetLastInteractionTime=function(t){this._lastInteractionTime=t??et.j.Now},r.prototype._reachTargetAlpha=function(){return!(!this._attachedCamera||!this.targetAlpha)&&Math.abs(this._attachedCamera.alpha-this.targetAlpha)<pt.bH},r.prototype._userIsZooming=function(){return!!this._attachedCamera&&this._attachedCamera.inertialRadiusOffset!==0},r.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var t=!1;return this._lastFrameRadius===this._attachedCamera.radius&&this._attachedCamera.inertialRadiusOffset!==0&&(t=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?t:this._userIsZooming()},r.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=et.j.Now)},r.prototype._userIsMoving=function(){return!!this._attachedCamera&&(this._attachedCamera.inertialAlphaOffset!==0||this._attachedCamera.inertialBetaOffset!==0||this._attachedCamera.inertialRadiusOffset!==0||this._attachedCamera.inertialPanningX!==0||this._attachedCamera.inertialPanningY!==0||this._isPointerDown)},r}(),om=function(){function r(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(r.prototype,"name",{get:function(){return"Bouncing"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(t){var e=this;if(this._autoTransitionRange!==t){this._autoTransitionRange=t;var n=this._attachedCamera;n&&(t?this._onMeshTargetChangedObserver=n.onMeshTargetChangedObservable.add(function(i){if(i&&(i.computeWorldMatrix(!0),i.getBoundingInfo)){var o=i.getBoundingInfo().diagonalLength;e.lowerRadiusTransitionRange=.05*o,e.upperRadiusTransitionRange=.05*o}}):this._onMeshTargetChangedObserver&&n.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t){var e=this;this._attachedCamera=t,this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){e._attachedCamera&&(e._isRadiusAtLimit(e._attachedCamera.lowerRadiusLimit)&&e._applyBoundRadiusAnimation(e.lowerRadiusTransitionRange),e._isRadiusAtLimit(e._attachedCamera.upperRadiusLimit)&&e._applyBoundRadiusAnimation(e.upperRadiusTransitionRange))})},r.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},r.prototype._isRadiusAtLimit=function(t){return!!this._attachedCamera&&this._attachedCamera.radius===t&&!this._radiusIsAnimating},r.prototype._applyBoundRadiusAnimation=function(t){var e=this;if(this._attachedCamera){this._radiusBounceTransition||(r.EasingFunction.setEasingMode(r.EasingMode),this._radiusBounceTransition=Le.CreateAnimation("radius",Le.ANIMATIONTYPE_FLOAT,60,r.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var n=Le.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,function(){return e._clearAnimationLocks()});n&&this._animatables.push(n)}},r.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},r.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},r.EasingFunction=new Yn(.3),r.EasingMode=Wt.EASINGMODE_EASEOUT,r}(),am=function(){function r(){this.onTargetFramingAnimationEndObservable=new K.cP,this._mode=r.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(r.prototype,"name",{get:function(){return"Framing"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mode",{get:function(){return this._mode},set:function(t){this._mode=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(t){this._radiusScale=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"positionScale",{get:function(){return this._positionScale},set:function(t){this._positionScale=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(t){this._defaultElevation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(t){this._elevationReturnTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(t){this._elevationReturnWaitTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(t){this._zoomStopsAnimation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"framingTime",{get:function(){return this._framingTime},set:function(t){this._framingTime=t},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t){var e=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();r.EasingFunction.setEasingMode(r.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add(function(i){i.type!==vt.Zp.POINTERDOWN?i.type===vt.Zp.POINTERUP&&(e._isPointerDown=!1):e._isPointerDown=!0}),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add(function(i){i&&i.getBoundingInfo&&e.zoomOnMesh(i,void 0,function(){e.onTargetFramingAnimationEndObservable.notifyObservers()})}),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){e._applyUserInteraction(),e._maintainCameraAboveGround()})},r.prototype.detach=function(){if(this._attachedCamera){var t=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&t.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},r.prototype.zoomOnMesh=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=null),t.computeWorldMatrix(!0);var i=t.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(i.minimumWorld,i.maximumWorld,e,n)},r.prototype.zoomOnMeshHierarchy=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=null),t.computeWorldMatrix(!0);var i=t.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(i.min,i.max,e,n)},r.prototype.zoomOnMeshesHierarchy=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=null);for(var i=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),o=new _.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),a=0;a<t.length;a++){var s=t[a].getHierarchyBoundingVectors(!0);_.Pq.CheckExtends(s.min,i,o),_.Pq.CheckExtends(s.max,i,o)}this.zoomOnBoundingInfo(i,o,e,n)},r.prototype.zoomOnBoundingInfo=function(t,e,n,i){var o,a=this;if(n===void 0&&(n=!1),i===void 0&&(i=null),!this._attachedCamera)return!1;var s=t.y,l=s+(e.y-s)*this._positionScale,c=e.subtract(t).scale(.5);if(n)o=new _.Pq(0,l,0);else{var u=t.add(c);o=new _.Pq(u.x,l,u.z)}this._vectorTransition||(this._vectorTransition=Le.CreateAnimation("target",Le.ANIMATIONTYPE_VECTOR3,60,r.EasingFunction)),this._betaIsAnimating=!0;var d=Le.TransitionTo("target",o,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);d&&this._animatables.push(d);var h=0;if(this._mode===r.FitFrustumSidesMode){var p=this._calculateLowerRadiusFromModelBoundingSphere(t,e);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=c.length()+this._attachedCamera.minZ),h=p}else this._mode===r.IgnoreBoundsSizeMode&&(h=this._calculateLowerRadiusFromModelBoundingSphere(t,e),this.autoCorrectCameraLimitsAndSensibility&&this._attachedCamera.lowerRadiusLimit===null&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){var m=e.subtract(t).length();this._attachedCamera.panningSensibility=5e3/m,this._attachedCamera.wheelPrecision=100/h}return this._radiusTransition||(this._radiusTransition=Le.CreateAnimation("radius",Le.ANIMATIONTYPE_FLOAT,60,r.EasingFunction)),(d=Le.TransitionTo("radius",h,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,function(){a.stopAllAnimations(),i&&i(),a._attachedCamera&&a._attachedCamera.useInputToRestoreState&&a._attachedCamera.storeState()}))&&this._animatables.push(d),!0},r.prototype._calculateLowerRadiusFromModelBoundingSphere=function(t,e){var n=this._attachedCamera;if(!n)return 0;var i=n._calculateLowerRadiusFromModelBoundingSphere(t,e,this._radiusScale);return n.lowerRadiusLimit&&this._mode===r.IgnoreBoundsSizeMode&&(i=i<n.lowerRadiusLimit?n.lowerRadiusLimit:i),n.upperRadiusLimit&&(i=i>n.upperRadiusLimit?n.upperRadiusLimit:i),i},r.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var e=et.j.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,i=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>i&&e>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=Le.CreateAnimation("beta",Le.ANIMATIONTYPE_FLOAT,60,r.EasingFunction));var o=Le.TransitionTo("beta",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,function(){t._clearAnimationLocks(),t.stopAllAnimations()});o&&this._animatables.push(o)}}},r.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},r.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=et.j.Now,this.stopAllAnimations(),this._clearAnimationLocks())},r.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(r.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(this._attachedCamera.inertialAlphaOffset!==0||this._attachedCamera.inertialBetaOffset!==0||this._attachedCamera.inertialRadiusOffset!==0||this._attachedCamera.inertialPanningX!==0||this._attachedCamera.inertialPanningY!==0||this._isPointerDown)},enumerable:!1,configurable:!0}),r.EasingFunction=new Xn,r.EasingMode=Wt.EASINGMODE_EASEINOUT,r.IgnoreBoundsSizeMode=0,r.FitFrustumSidesMode=1,r}(),Pa=function(r,t,e,n){t===void 0&&(t=new _.Pq),e===void 0&&(e=0),n===void 0&&(n=!1),this.direction=r,this.rotatedDirection=t,this.diff=e,this.ignore=n},HS=function(){function r(t){this._ui=t,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Pa(_.Pq.Up()),new Pa(_.Pq.Down()),new Pa(_.Pq.Left()),new Pa(_.Pq.Right()),new Pa(_.Pq.Forward()),new Pa(_.Pq.Forward().scaleInPlace(-1))],this._tmpMatrix=new _.uq,this._tmpVector=new _.Pq,this._zeroVector=_.Pq.Zero(),this._lookAtTmpMatrix=new _.uq}return r.prototype.init=function(){},r.prototype._closestFace=function(t){var e=this;return this._faceVectors.forEach(function(n){e._target.rotationQuaternion||(e._target.rotationQuaternion=_.PT.RotationYawPitchRoll(e._target.rotation.y,e._target.rotation.x,e._target.rotation.z)),e._target.rotationQuaternion.toRotationMatrix(e._tmpMatrix),_.Pq.TransformCoordinatesToRef(n.direction,e._tmpMatrix,n.rotatedDirection),n.diff=_.Pq.GetAngleBetweenVectors(n.rotatedDirection,t,_.Pq.Cross(n.rotatedDirection,t))}),this._faceVectors.reduce(function(n,i){return n.ignore?i:i.ignore||n.diff<i.diff?n:i},this._faceVectors[0])},r.prototype._lookAtToRef=function(t,e,n){e===void 0&&(e=new _.Pq(0,1,0)),_.uq.LookAtLHToRef(this._zeroVector,t,e,this._lookAtTmpMatrix),this._lookAtTmpMatrix.invert(),_.PT.FromRotationMatrixToRef(this._lookAtTmpMatrix,n)},r.prototype.attach=function(t){var e=this;this._target=t,this._scene=this._target.getScene(),this._onRenderObserver=this._scene.onBeforeRenderObservable.add(function(){if(e._scene.activeCamera){var n=e._scene.activeCamera.position;e._scene.activeCamera.devicePosition&&(n=e._scene.activeCamera.devicePosition);var i=e._closestFace(n.subtract(t.position));e._scene.activeCamera.leftCamera?e._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix):e._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix),_.Pq.TransformCoordinatesToRef(_.Pq.Up(),e._tmpMatrix,e._tmpVector),e._faceVectors.forEach(function(a){i.direction.x&&a.direction.x&&(a.ignore=!0),i.direction.y&&a.direction.y&&(a.ignore=!0),i.direction.z&&a.direction.z&&(a.ignore=!0)});var o=e._closestFace(e._tmpVector);e._faceVectors.forEach(function(a){a.ignore=!1}),e._ui.position.copyFrom(t.position),i.direction.x&&(i.rotatedDirection.scaleToRef(t.scaling.x/2+e.distanceAwayFromFace,e._tmpVector),e._ui.position.addInPlace(e._tmpVector)),i.direction.y&&(i.rotatedDirection.scaleToRef(t.scaling.y/2+e.distanceAwayFromFace,e._tmpVector),e._ui.position.addInPlace(e._tmpVector)),i.direction.z&&(i.rotatedDirection.scaleToRef(t.scaling.z/2+e.distanceAwayFromFace,e._tmpVector),e._ui.position.addInPlace(e._tmpVector)),e._ui.rotationQuaternion||(e._ui.rotationQuaternion=_.PT.RotationYawPitchRoll(e._ui.rotation.y,e._ui.rotation.x,e._ui.rotation.z)),i.rotatedDirection.scaleToRef(-1,e._tmpVector),e._lookAtToRef(e._tmpVector,o.rotatedDirection,e._ui.rotationQuaternion),o.direction.x&&e._ui.up.scaleToRef(e.distanceAwayFromBottomOfFace-t.scaling.x/2,e._tmpVector),o.direction.y&&e._ui.up.scaleToRef(e.distanceAwayFromBottomOfFace-t.scaling.y/2,e._tmpVector),o.direction.z&&e._ui.up.scaleToRef(e.distanceAwayFromBottomOfFace-t.scaling.z/2,e._tmpVector),e._ui.position.addInPlace(e._tmpVector)}})},r.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._onRenderObserver)},r}(),YS=function(){function r(){var t=this;this.fadeInDelay=0,this.fadeOutDelay=0,this.fadeInTime=300,this.fadeOutTime=300,this._millisecondsPerFrame=1e3/60,this._hovered=!1,this._hoverValue=0,this._ownerNode=null,this._delay=0,this._time=300,this._update=function(){if(t._ownerNode){if(t._hoverValue+=t._hovered?t._millisecondsPerFrame:-t._millisecondsPerFrame,t._setAllVisibility(t._ownerNode,(t._hoverValue-t._delay)/t._time),t._ownerNode.visibility>1){if(t._setAllVisibility(t._ownerNode,1),t._hoverValue>t._time)return t._hoverValue=t._time,void t._detachObserver()}else if(t._ownerNode.visibility<0&&(t._setAllVisibility(t._ownerNode,0),t._hoverValue<0))return t._hoverValue=0,void t._detachObserver();t._attachObserver()}}}return Object.defineProperty(r.prototype,"delay",{get:function(){return this.fadeInDelay},set:function(t){this.fadeInDelay=t,this.fadeOutDelay=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t){this._ownerNode=t,this._setAllVisibility(this._ownerNode,0)},r.prototype.detach=function(){this._ownerNode=null},r.prototype.fadeIn=function(t){t===void 0&&(t=!0),this._delay=t?this.fadeInDelay:this.fadeOutDelay,this._time=t?this.fadeInTime:this.fadeOutTime,this._detachObserver(),this._ownerNode&&(t&&this._ownerNode.visibility>=1||!t&&this._ownerNode.visibility<=0)||(this._hovered=t,this._hovered||(this._delay*=-1),this._ownerNode.visibility>=1?this._hoverValue=this._time:this._ownerNode.visibility<=0&&(this._hoverValue=0),this._update())},r.prototype.fadeOut=function(){this.fadeIn(!1)},r.prototype._setAllVisibility=function(t,e){var n=this;t.visibility=e,t.getChildMeshes().forEach(function(i){n._setAllVisibility(i,e)})},r.prototype._attachObserver=function(){var t;this._onBeforeRenderObserver||(this._onBeforeRenderObserver=(t=this._ownerNode)===null||t===void 0?void 0:t.getScene().onBeforeRenderObservable.add(this._update))},r.prototype._detachObserver=function(){var t;this._onBeforeRenderObserver&&((t=this._ownerNode)===null||t===void 0||t.getScene().onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=null)},r}(),fn=function(){function r(t,e,n,i){n===void 0&&(n=Number.MAX_VALUE),i===void 0&&(i=pt.bH),this.origin=t,this.direction=e,this.length=n,this.epsilon=i}return r.prototype.clone=function(){return new r(this.origin.clone(),this.direction.clone(),this.length)},r.prototype.intersectsBoxMinMax=function(t,e,n){n===void 0&&(n=0);var i,o,a,s,l=r._TmpVector3[0].copyFromFloats(t.x-n,t.y-n,t.z-n),c=r._TmpVector3[1].copyFromFloats(e.x+n,e.y+n,e.z+n),u=0,d=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<l.x||this.origin.x>c.x)return!1}else if(i=1/this.direction.x,o=(l.x-this.origin.x)*i,(a=(c.x-this.origin.x)*i)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<l.y||this.origin.y>c.y)return!1}else if(i=1/this.direction.y,o=(l.y-this.origin.y)*i,(a=(c.y-this.origin.y)*i)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<l.z||this.origin.z>c.z)return!1}else if(i=1/this.direction.z,o=(l.z-this.origin.z)*i,(a=(c.z-this.origin.z)*i)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(d=Math.min(a,d)))return!1;return!0},r.prototype.intersectsBox=function(t,e){return e===void 0&&(e=0),this.intersectsBoxMinMax(t.minimum,t.maximum,e)},r.prototype.intersectsSphere=function(t,e){e===void 0&&(e=0);var n=t.center.x-this.origin.x,i=t.center.y-this.origin.y,o=t.center.z-this.origin.z,a=n*n+i*i+o*o,s=t.radius+e,l=s*s;if(a<=l)return!0;var c=n*this.direction.x+i*this.direction.y+o*this.direction.z;return!(c<0)&&a-c*c<=l},r.prototype.intersectsTriangle=function(t,e,n){var i=r._TmpVector3[0],o=r._TmpVector3[1],a=r._TmpVector3[2],s=r._TmpVector3[3],l=r._TmpVector3[4];e.subtractToRef(t,i),n.subtractToRef(t,o),_.Pq.CrossToRef(this.direction,o,a);var c=_.Pq.Dot(i,a);if(c===0)return null;var u=1/c;this.origin.subtractToRef(t,s);var d=_.Pq.Dot(s,a)*u;if(d<-this.epsilon||d>1+this.epsilon)return null;_.Pq.CrossToRef(s,i,l);var h=_.Pq.Dot(this.direction,l)*u;if(h<-this.epsilon||d+h>1+this.epsilon)return null;var p=_.Pq.Dot(o,l)*u;return p>this.length?null:new Rs(1-d-h,d,p)},r.prototype.intersectsPlane=function(t){var e,n=_.Pq.Dot(t.normal,this.direction);if(Math.abs(n)<999999997475243e-21)return null;var i=_.Pq.Dot(t.normal,this.origin);return(e=(-t.d-i)/n)<0?e<-999999997475243e-21?null:0:e},r.prototype.intersectsAxis=function(t,e){switch(e===void 0&&(e=0),t){case"y":return(n=(this.origin.y-e)/this.direction.y)>0?null:new _.Pq(this.origin.x+this.direction.x*-n,e,this.origin.z+this.direction.z*-n);case"x":return(n=(this.origin.x-e)/this.direction.x)>0?null:new _.Pq(e,this.origin.y+this.direction.y*-n,this.origin.z+this.direction.z*-n);case"z":var n;return(n=(this.origin.z-e)/this.direction.z)>0?null:new _.Pq(this.origin.x+this.direction.x*-n,this.origin.y+this.direction.y*-n,e);default:return null}},r.prototype.intersectsMesh=function(t,e,n,i,o,a){i===void 0&&(i=!1),a===void 0&&(a=!1);var s=_.AA.Matrix[0];return t.getWorldMatrix().invertToRef(s),this._tmpRay?r.TransformToRef(this,s,this._tmpRay):this._tmpRay=r.Transform(this,s),t.intersects(this._tmpRay,e,n,i,o,a)},r.prototype.intersectsMeshes=function(t,e,n){n?n.length=0:n=[];for(var i=0;i<t.length;i++){var o=this.intersectsMesh(t[i],e);o.hit&&n.push(o)}return n.sort(this._comparePickingInfo),n},r.prototype._comparePickingInfo=function(t,e){return t.distance<e.distance?-1:t.distance>e.distance?1:0},r.prototype.intersectionSegment=function(t,e,n){var i=this.origin,o=_.AA.Vector3[0],a=_.AA.Vector3[1],s=_.AA.Vector3[2],l=_.AA.Vector3[3];e.subtractToRef(t,o),this.direction.scaleToRef(r._Rayl,s),i.addToRef(s,a),t.subtractToRef(i,l);var c,u,d=_.Pq.Dot(o,o),h=_.Pq.Dot(o,s),p=_.Pq.Dot(s,s),m=_.Pq.Dot(o,l),v=_.Pq.Dot(s,l),b=d*p-h*h,E=b,C=b;b<r._Smallnum?(c=0,E=1,u=v,C=p):(u=d*v-h*m,(c=h*v-p*m)<0?(c=0,u=v,C=p):c>E&&(c=E,u=v+h,C=p)),u<0?(u=0,-m<0?c=0:-m>d?c=E:(c=-m,E=d)):u>C&&(u=C,-m+h<0?c=0:-m+h>d?c=E:(c=-m+h,E=d));var T=Math.abs(c)<r._Smallnum?0:c/E,f=Math.abs(u)<r._Smallnum?0:u/C,g=_.AA.Vector3[4];s.scaleToRef(f,g);var S=_.AA.Vector3[5];o.scaleToRef(T,S),S.addInPlace(l);var y=_.AA.Vector3[6];return S.subtractToRef(g,y),f>0&&f<=this.length&&y.lengthSquared()<n*n?S.length():-1},r.prototype.update=function(t,e,n,i,o,a,s,l){if(l===void 0&&(l=!1),l){r._RayDistant||(r._RayDistant=r.Zero()),r._RayDistant.unprojectRayToRef(t,e,n,i,_.uq.IdentityReadOnly,a,s);var c=_.AA.Matrix[0];o.invertToRef(c),r.TransformToRef(r._RayDistant,c,this)}else this.unprojectRayToRef(t,e,n,i,o,a,s);return this},r.Zero=function(){return new r(_.Pq.Zero(),_.Pq.Zero())},r.CreateNew=function(t,e,n,i,o,a,s){return r.Zero().update(t,e,n,i,o,a,s)},r.CreateNewFromTo=function(t,e,n){n===void 0&&(n=_.uq.IdentityReadOnly);var i=new r(new _.Pq(0,0,0),new _.Pq(0,0,0));return r.CreateFromToToRef(t,e,i,n)},r.CreateFromToToRef=function(t,e,n,i){i===void 0&&(i=_.uq.IdentityReadOnly),n.origin.copyFrom(t);var o=e.subtractToRef(t,n.direction),a=Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z);return n.length=a,n.direction.normalize(),r.TransformToRef(n,i,n)},r.Transform=function(t,e){var n=new r(new _.Pq(0,0,0),new _.Pq(0,0,0));return r.TransformToRef(t,e,n),n},r.TransformToRef=function(t,e,n){_.Pq.TransformCoordinatesToRef(t.origin,e,n.origin),_.Pq.TransformNormalToRef(t.direction,e,n.direction),n.length=t.length,n.epsilon=t.epsilon;var i=n.direction,o=i.length();if(o!==0&&o!==1){var a=1/o;i.x*=a,i.y*=a,i.z*=a,n.length*=o}return n},r.prototype.unprojectRayToRef=function(t,e,n,i,o,a,s){var l=_.AA.Matrix[0];o.multiplyToRef(a,l),l.multiplyToRef(s,l),l.invert();var c=Ve.q.LastCreatedEngine,u=_.AA.Vector3[0];u.x=t/n*2-1,u.y=-(e/i*2-1),u.z=c?.useReverseDepthBuffer?1:c?.isNDCHalfZRange?0:-1;var d=_.AA.Vector3[1].copyFromFloats(u.x,u.y,1-1e-8),h=_.AA.Vector3[2],p=_.AA.Vector3[3];_.Pq._UnprojectFromInvertedMatrixToRef(u,l,h),_.Pq._UnprojectFromInvertedMatrixToRef(d,l,p),this.origin.copyFrom(h),p.subtractToRef(h,this.direction),this.direction.normalize()},r._TmpVector3=(0,st.mI)(6,_.Pq.Zero),r._RayDistant=r.Zero(),r._Smallnum=1e-8,r._Rayl=1e9,r}();ke.Z.prototype.createPickingRay=function(r,t,e,n,i){i===void 0&&(i=!1);var o=fn.Zero();return this.createPickingRayToRef(r,t,e,o,n,i),o},ke.Z.prototype.createPickingRayToRef=function(r,t,e,n,i,o,a){o===void 0&&(o=!1),a===void 0&&(a=!1);var s=this.getEngine();if(!i&&!(i=this.activeCamera))return this;var l=i.viewport,c=s.getRenderHeight(),u=l.toGlobal(s.getRenderWidth(),c),d=u.x,h=u.y,p=u.width,m=u.height,v=1/s.getHardwareScalingLevel();return r=r*v-d,t=t*v-(c-h-m),n.update(r,t,p,m,e||_.uq.IdentityReadOnly,o?_.uq.IdentityReadOnly:i.getViewMatrix(),i.getProjectionMatrix(),a),this},ke.Z.prototype.createPickingRayInCameraSpace=function(r,t,e){var n=fn.Zero();return this.createPickingRayInCameraSpaceToRef(r,t,n,e),n},ke.Z.prototype.createPickingRayInCameraSpaceToRef=function(r,t,e,n){if(!ri.G)return this;var i=this.getEngine();if(!n&&!(n=this.activeCamera))throw new Error("Active camera not set");var o=n.viewport,a=i.getRenderHeight(),s=o.toGlobal(i.getRenderWidth(),a),l=s.x,c=s.y,u=s.width,d=s.height,h=_.uq.Identity(),p=1/i.getHardwareScalingLevel();return r=r*p-l,t=t*p-(a-c-d),e.update(r,t,u,d,h,h,n.getProjectionMatrix()),this},ke.Z.prototype._internalPickForMesh=function(r,t,e,n,i,o,a,s){var l=t(n,e.enableDistantPicking),c=e.intersects(l,i,a,o,n,s);return c&&c.hit?!i&&r!=null&&c.distance>=r.distance?null:c:null},ke.Z.prototype._internalPick=function(r,t,e,n,i){for(var o=null,a=!!(this.activeCameras&&this.activeCameras.length>1&&this.cameraToUseForPointers!==this.activeCamera),s=this.cameraToUseForPointers||this.activeCamera,l=0;l<this.meshes.length;l++){var c=this.meshes[l];if(t){if(!t(c,-1))continue}else if(!c.isEnabled()||!c.isVisible||!c.isPickable)continue;var u,d=a&&c.isWorldMatrixCameraDependent(),h=c.computeWorldMatrix(d,s);if(c.hasThinInstances&&c.thinInstanceEnablePicking){if(u=this._internalPickForMesh(o,r,c,h,!0,!0,i)){if(n)return u;for(var p=_.AA.Matrix[1],m=c.thinInstanceGetWorldMatrices(),v=0;v<m.length;v++)if(!t||t(c,v)){m[v].multiplyToRef(h,p);var b=this._internalPickForMesh(o,r,c,p,e,n,i,!0);if(b&&((o=b).thinInstanceIndex=v,e))return o}}}else if((u=this._internalPickForMesh(o,r,c,h,e,n,i))&&(o=u,e))return o}return o||new ri.G},ke.Z.prototype._internalMultiPick=function(r,t,e){if(!ri.G)return null;for(var n=[],i=!!(this.activeCameras&&this.activeCameras.length>1&&this.cameraToUseForPointers!==this.activeCamera),o=this.cameraToUseForPointers||this.activeCamera,a=0;a<this.meshes.length;a++){var s=this.meshes[a];if(t){if(!t(s,-1))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var l,c=i&&s.isWorldMatrixCameraDependent(),u=s.computeWorldMatrix(c,o);if(s.hasThinInstances&&s.thinInstanceEnablePicking){if(l=this._internalPickForMesh(null,r,s,u,!0,!0,e)){for(var d=_.AA.Matrix[1],h=s.thinInstanceGetWorldMatrices(),p=0;p<h.length;p++)if(!t||t(s,p)){h[p].multiplyToRef(u,d);var m=this._internalPickForMesh(null,r,s,d,!1,!1,e,!0);m&&(m.thinInstanceIndex=p,n.push(m))}}}else(l=this._internalPickForMesh(null,r,s,u,!1,!1,e))&&n.push(l)}return n},ke.Z.prototype.pickWithBoundingInfo=function(r,t,e,n,i){var o=this;if(!ri.G)return null;var a=this._internalPick(function(s){return o._tempPickingRay||(o._tempPickingRay=fn.Zero()),o.createPickingRayToRef(r,t,s,o._tempPickingRay,i||null),o._tempPickingRay},e,n,!0);return a&&(a.ray=this.createPickingRay(r,t,_.uq.Identity(),i||null)),a},Object.defineProperty(ke.Z.prototype,"_pickingAvailable",{get:function(){return!0},enumerable:!1,configurable:!1}),ke.Z.prototype.pick=function(r,t,e,n,i,o,a){var s=this,l=this._internalPick(function(c,u){return s._tempPickingRay||(s._tempPickingRay=fn.Zero()),s.createPickingRayToRef(r,t,c,s._tempPickingRay,i||null,!1,u),s._tempPickingRay},e,n,!1,o);return l&&(l.ray=this.createPickingRay(r,t,_.uq.Identity(),i||null)),l},ke.Z.prototype.pickWithRay=function(r,t,e,n){var i=this,o=this._internalPick(function(a){return i._pickWithRayInverseMatrix||(i._pickWithRayInverseMatrix=_.uq.Identity()),a.invertToRef(i._pickWithRayInverseMatrix),i._cachedRayForTransform||(i._cachedRayForTransform=fn.Zero()),fn.TransformToRef(r,i._pickWithRayInverseMatrix,i._cachedRayForTransform),i._cachedRayForTransform},t,e,!1,n);return o&&(o.ray=r),o},ke.Z.prototype.multiPick=function(r,t,e,n,i){var o=this;return this._internalMultiPick(function(a){return o.createPickingRay(r,t,a,n||null)},e,i)},ke.Z.prototype.multiPickWithRay=function(r,t,e){var n=this;return this._internalMultiPick(function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=_.uq.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=fn.Zero()),fn.TransformToRef(r,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform},t,e)},Pt.prototype.getForwardRay=function(r,t,e){return r===void 0&&(r=100),this.getForwardRayToRef(new fn(_.Pq.Zero(),_.Pq.Zero(),r),r,t,e)},Pt.prototype.getForwardRayToRef=function(r,t,e,n){t===void 0&&(t=100),e||(e=this.getWorldMatrix()),r.length=t,n?r.origin.copyFrom(n):r.origin.copyFrom(this.position);var i=_.AA.Vector3[2];i.set(0,0,this._scene.useRightHandedSystem?-1:1);var o=_.AA.Vector3[3];return _.Pq.TransformNormalToRef(i,e,o),_.Pq.NormalizeToRef(o,r.direction),r};var Gi=function(){function r(){}return r._RemoveAndStorePivotPoint=function(t){t&&r._PivotCached===0&&(t.getPivotPointToRef(r._OldPivotPoint),r._PivotPostMultiplyPivotMatrix=t._postMultiplyPivotMatrix,r._OldPivotPoint.equalsToFloats(0,0,0)||(t.setPivotMatrix(_.uq.IdentityReadOnly),r._OldPivotPoint.subtractToRef(t.getPivotPoint(),r._PivotTranslation),r._PivotTmpVector.copyFromFloats(1,1,1),r._PivotTmpVector.subtractInPlace(t.scaling),r._PivotTmpVector.multiplyInPlace(r._PivotTranslation),t.position.addInPlace(r._PivotTmpVector))),r._PivotCached++},r._RestorePivotPoint=function(t){t&&!r._OldPivotPoint.equalsToFloats(0,0,0)&&r._PivotCached===1&&(t.setPivotPoint(r._OldPivotPoint),t._postMultiplyPivotMatrix=r._PivotPostMultiplyPivotMatrix,r._PivotTmpVector.copyFromFloats(1,1,1),r._PivotTmpVector.subtractInPlace(t.scaling),r._PivotTmpVector.multiplyInPlace(r._PivotTranslation),t.position.subtractInPlace(r._PivotTmpVector)),this._PivotCached--},r._PivotCached=0,r._OldPivotPoint=new _.Pq,r._PivotTranslation=new _.Pq,r._PivotTmpVector=new _.Pq,r._PivotPostMultiplyPivotMatrix=!1,r}();function Is(r){var t=[],e=[],n=[],i=[],o=r.width||r.size||1,a=r.height||r.size||1,s=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,l=o/2,c=a/2;e.push(-l,-c,0),n.push(0,0,-1),i.push(0,Xt.rX?1:0),e.push(l,-c,0),n.push(0,0,-1),i.push(1,Xt.rX?1:0),e.push(l,c,0),n.push(0,0,-1),i.push(1,Xt.rX?0:1),e.push(-l,c,0),n.push(0,0,-1),i.push(0,Xt.rX?0:1),t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),rt._ComputeSides(s,e,t,n,i,r.frontUVs,r.backUVs);var u=new rt;return u.indices=t,u.positions=e,u.normals=n,u.uvs=i,u}function Ur(r,t,e){t===void 0&&(t={}),e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Is(t).applyToMesh(n,t.updatable),t.sourcePlane&&(n.translate(t.sourcePlane.normal,-t.sourcePlane.d),n.setDirection(t.sourcePlane.normal.scale(-1))),n}var XS={CreatePlane:Ur};rt.CreatePlane=Is,xe.CreatePlane=function(r,t,e,n,i){return Ur(r,{size:t,width:t,height:t,sideOrientation:i,updatable:n},e)};var sm,Ic,Mc,Oc,Gr=function(){function r(t){this._useAlternatePickedPointAboveMaxDragAngleDragSpeed=-1.1,this._activeDragButton=-1,this.maxDragAngle=0,this.dragButtons=[0,1,2],this._useAlternatePickedPointAboveMaxDragAngle=!1,this.currentDraggingPointerId=-1,this.dragging=!1,this.dragDeltaRatio=.2,this.updateDragPlane=!0,this._debugMode=!1,this._moving=!1,this.onDragObservable=new K.cP,this.onDragStartObservable=new K.cP,this.onDragEndObservable=new K.cP,this.onEnabledObservable=new K.cP,this.moveAttached=!0,this._enabled=!0,this.startAndReleaseDragOnPointerEvents=!0,this.detachCameraControls=!0,this.useObjectOrientationForDragging=!0,this.validateDrag=function(n){return!0},this._tmpVector=new _.Pq(0,0,0),this._alternatePickedPoint=new _.Pq(0,0,0),this._worldDragAxis=new _.Pq(0,0,0),this._targetPosition=new _.Pq(0,0,0),this._attachedToElement=!1,this._startDragRay=new fn(new _.Pq,new _.Pq),this._lastPointerRay={},this._dragDelta=new _.Pq,this._pointA=new _.Pq(0,0,0),this._pointC=new _.Pq(0,0,0),this._localAxis=new _.Pq(0,0,0),this._lookAt=new _.Pq(0,0,0),this._options=t||{};var e=0;if(this._options.dragAxis&&e++,this._options.dragPlaneNormal&&e++,e>1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(r.prototype,"currentDraggingPointerID",{get:function(){return this.currentDraggingPointerId},set:function(t){this.currentDraggingPointerId=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enabled",{get:function(){return this._enabled},set:function(t){t!=this._enabled&&this.onEnabledObservable.notifyObservers(t),this._enabled=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"options",{get:function(){return this._options},set:function(t){this._options=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t,e){var n=this;this._scene=t.getScene(),t.isNearGrabbable=!0,this.attachedNode=t,r._PlaneScene||(this._debugMode?r._PlaneScene=this._scene:(r._PlaneScene=new ke.Z(this._scene.getEngine(),{virtual:!0}),r._PlaneScene.detachControl(),this._scene.onDisposeObservable.addOnce(function(){r._PlaneScene.dispose(),r._PlaneScene=null}))),this._dragPlane=Ur("pointerDragPlane",{size:this._debugMode?1:1e4,updatable:!1,sideOrientation:xe.DOUBLESIDE},r._PlaneScene),this.lastDragPosition=new _.Pq(0,0,0);var i=e||function(o){return n.attachedNode==o||o.isDescendantOf(n.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add(function(o){if(n.enabled){if(o.type==vt.Zp.POINTERDOWN)n.startAndReleaseDragOnPointerEvents&&!n.dragging&&o.pickInfo&&o.pickInfo.hit&&o.pickInfo.pickedMesh&&o.pickInfo.pickedPoint&&o.pickInfo.ray&&i(o.pickInfo.pickedMesh)&&n._activeDragButton===-1&&n.dragButtons.indexOf(o.event.button)!==-1&&(n._activeDragButton=o.event.button,n._activePointerInfo=o,n._startDrag(o.event.pointerId,o.pickInfo.ray,o.pickInfo.pickedPoint));else if(o.type==vt.Zp.POINTERUP)!n.startAndReleaseDragOnPointerEvents||n.currentDraggingPointerId!=o.event.pointerId||n._activeDragButton!==o.event.button&&n._activeDragButton!==-1||n.releaseDrag();else if(o.type==vt.Zp.POINTERMOVE){var a=o.event.pointerId;if(n.currentDraggingPointerId===r._AnyMouseId&&a!==r._AnyMouseId){var s=o.event;(s.pointerType==="mouse"||!n._scene.getEngine().hostInformation.isMobile&&s instanceof MouseEvent)&&(n._lastPointerRay[n.currentDraggingPointerId]&&(n._lastPointerRay[a]=n._lastPointerRay[n.currentDraggingPointerId],delete n._lastPointerRay[n.currentDraggingPointerId]),n.currentDraggingPointerId=a)}n._lastPointerRay[a]||(n._lastPointerRay[a]=new fn(new _.Pq,new _.Pq)),o.pickInfo&&o.pickInfo.ray&&(n._lastPointerRay[a].origin.copyFrom(o.pickInfo.ray.origin),n._lastPointerRay[a].direction.copyFrom(o.pickInfo.ray.direction),n.currentDraggingPointerId==a&&n.dragging&&n._moveDrag(o.pickInfo.ray))}}else n._attachedToElement&&n.releaseDrag()}),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add(function(){if(n._moving&&n.moveAttached){var o=!1;Gi._RemoveAndStorePivotPoint(n.attachedNode),n._targetPosition.subtractToRef(n.attachedNode.absolutePosition,n._tmpVector),n._tmpVector.scaleInPlace(n.dragDeltaRatio),n.attachedNode.getAbsolutePosition().addToRef(n._tmpVector,n._tmpVector),n.validateDrag(n._tmpVector)&&(n.attachedNode.setAbsolutePosition(n._tmpVector),o=!0),Gi._RestorePivotPoint(n.attachedNode),o&&n.attachedNode.computeWorldMatrix()}})},r.prototype.releaseDrag=function(){if(this.dragging&&(this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerId,pointerInfo:this._activePointerInfo})),this.currentDraggingPointerId=-1,this._activeDragButton=-1,this._activePointerInfo=null,this._moving=!1,this.detachCameraControls&&this._attachedToElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera){if(this._scene.activeCamera.getClassName()==="ArcRotateCamera"){var t=this._scene.activeCamera;t.attachControl(!t.inputs||t.inputs.noPreventDefault,t._useCtrlForPanning,t._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},r.prototype.startDrag=function(t,e,n){t===void 0&&(t=r._AnyMouseId),this._startDrag(t,e,n);var i=this._lastPointerRay[t];t===r._AnyMouseId&&(i=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),i&&this._moveDrag(i)},r.prototype._startDrag=function(t,e,n){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){Gi._RemoveAndStorePivotPoint(this.attachedNode),e?(this._startDragRay.direction.copyFrom(e.direction),this._startDragRay.origin.copyFrom(e.origin)):(this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),this._tmpVector.subtractToRef(this._scene.activeCamera.position,this._startDragRay.direction)),this._updateDragPlanePosition(this._startDragRay,n||this._tmpVector);var i=this._pickWithRayOnDragPlane(this._startDragRay);i?(this.dragging=!0,this.currentDraggingPointerId=t,this.lastDragPosition.copyFrom(i),this.onDragStartObservable.notifyObservers({dragPlanePoint:i,pointerId:this.currentDraggingPointerId,pointerInfo:this._activePointerInfo}),this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()),this.detachCameraControls&&this._scene.activeCamera&&this._scene.activeCamera.inputs&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedToElement?(this._scene.activeCamera.detachControl(),this._attachedToElement=!0):this._attachedToElement=!1)):this.releaseDrag(),Gi._RestorePivotPoint(this.attachedNode)}},r.prototype._moveDrag=function(t){this._moving=!0;var e=this._pickWithRayOnDragPlane(t);if(e){Gi._RemoveAndStorePivotPoint(this.attachedNode),this.updateDragPlane&&this._updateDragPlanePosition(t,e);var n=0;this._options.dragAxis?(this.useObjectOrientationForDragging?_.Pq.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),e.subtractToRef(this.lastDragPosition,this._tmpVector),n=_.Pq.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(n,this._dragDelta)):(n=this._dragDelta.length(),e.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:n,delta:this._dragDelta,dragPlanePoint:e,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerId,pointerInfo:this._activePointerInfo}),this.lastDragPosition.copyFrom(e),Gi._RestorePivotPoint(this.attachedNode)}},r.prototype._pickWithRayOnDragPlane=function(t){if(!t)return null;var e=Math.acos(_.Pq.Dot(this._dragPlane.forward,t.direction));if(e>Math.PI/2&&(e=Math.PI-e),this.maxDragAngle>0&&e>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(t.direction),this.attachedNode.absolutePosition.subtractToRef(t.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*_.Pq.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var n=_.Pq.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-n,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var i=this._dragPlane.forward,o=this._dragPlane.position,a=t.direction.dot(i);if(Math.abs(a)<pt.bH)return null;o.subtractToRef(t.origin,_.AA.Vector3[0]);var s=_.AA.Vector3[0].dot(i)/a;return s<0?null:(t.direction.scaleToRef(s,_.AA.Vector3[0]),t.origin.add(_.AA.Vector3[0]))},r.prototype._updateDragPlanePosition=function(t,e){this._pointA.copyFrom(e),this._options.dragAxis?(this.useObjectOrientationForDragging?_.Pq.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),t.origin.subtractToRef(this._pointA,this._pointC),this._pointC.normalize(),Math.abs(_.Pq.Dot(this._localAxis,this._pointC))>.999?Math.abs(_.Pq.Dot(_.Pq.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(_.Pq.Right()):this._lookAt.copyFrom(_.Pq.UpReadOnly):(_.Pq.CrossToRef(this._localAxis,this._pointC,this._lookAt),_.Pq.CrossToRef(this._localAxis,this._lookAt,this._lookAt),this._lookAt.normalize()),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrientationForDragging?_.Pq.TransformCoordinatesToRef(this._options.dragPlaneNormal,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(t.origin)),this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition()),this._dragPlane.computeWorldMatrix(!0)},r.prototype.detach=function(){this._lastPointerRay={},this.attachedNode&&(this.attachedNode.isNearGrabbable=!1),this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this._dragPlane&&this._dragPlane.dispose(),this.releaseDrag()},r._AnyMouseId=-2,r}(),jS=function(){function r(){this._startDistance=0,this._initialScale=new _.Pq(0,0,0),this._targetScale=new _.Pq(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new Gr({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new Gr({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(r.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},r.prototype.attach=function(t){var e=this;this._ownerNode=t,this._dragBehaviorA.onDragStartObservable.add(function(){e._dragBehaviorA.dragging&&e._dragBehaviorB.dragging&&(e._dragBehaviorA.currentDraggingPointerId==e._dragBehaviorB.currentDraggingPointerId?e._dragBehaviorA.releaseDrag():(e._initialScale.copyFrom(t.scaling),e._startDistance=e._getCurrentDistance()))}),this._dragBehaviorB.onDragStartObservable.add(function(){e._dragBehaviorA.dragging&&e._dragBehaviorB.dragging&&(e._dragBehaviorA.currentDraggingPointerId==e._dragBehaviorB.currentDraggingPointerId?e._dragBehaviorB.releaseDrag():(e._initialScale.copyFrom(t.scaling),e._startDistance=e._getCurrentDistance()))}),[this._dragBehaviorA,this._dragBehaviorB].forEach(function(n){n.onDragObservable.add(function(){if(e._dragBehaviorA.dragging&&e._dragBehaviorB.dragging){var i=e._getCurrentDistance()/e._startDistance;e._initialScale.scaleToRef(i,e._targetScale)}})}),t.addBehavior(this._dragBehaviorA),t.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add(function(){if(e._dragBehaviorA.dragging&&e._dragBehaviorB.dragging){var n=e._targetScale.subtract(t.scaling).scaleInPlace(.1);n.length()>.01&&t.scaling.addInPlace(n)}})},r.prototype.detach=function(){var t=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach(function(e){e.onDragStartObservable.clear(),e.onDragObservable.clear(),t._ownerNode.removeBehavior(e)})},r}(),Dc=function(){function r(){this._attachedToElement=!1,this._virtualMeshesInfo={},this._tmpVector=new _.Pq,this._tmpQuaternion=new _.PT,this._dragType={NONE:0,DRAG:1,DRAG_WITH_CONTROLLER:2,NEAR_DRAG:3},this._moving=!1,this._dragging=this._dragType.NONE,this.draggableMeshes=null,this.zDragFactor=3,this.currentDraggingPointerIds=[],this.detachCameraControls=!0,this.onDragStartObservable=new K.cP,this.onDragObservable=new K.cP,this.onDragEndObservable=new K.cP,this.allowMultiPointer=!0}return Object.defineProperty(r.prototype,"currentDraggingPointerId",{get:function(){return this.currentDraggingPointerIds[0]!==void 0?this.currentDraggingPointerIds[0]:-1},set:function(t){this.currentDraggingPointerIds[0]=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentDraggingPointerID",{get:function(){return this.currentDraggingPointerId},set:function(t){this.currentDraggingPointerId=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return"BaseSixDofDrag"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isMoving",{get:function(){return this._moving},enumerable:!1,configurable:!0}),r.prototype.init=function(){},Object.defineProperty(r.prototype,"_pointerCamera",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!1,configurable:!0}),r.prototype._createVirtualMeshInfo=function(){var t=new jt("",r._virtualScene);t.rotationQuaternion=new _.PT;var e=new jt("",r._virtualScene);e.rotationQuaternion=new _.PT;var n=new jt("",r._virtualScene);return n.rotationQuaternion=new _.PT,{dragging:!1,moving:!1,dragMesh:t,originMesh:e,pivotMesh:n,startingPivotPosition:new _.Pq,startingPivotOrientation:new _.PT,startingPosition:new _.Pq,startingOrientation:new _.PT,lastOriginPosition:new _.Pq,lastDragPosition:new _.Pq}},r.prototype._resetVirtualMeshesPosition=function(){for(var t=0;t<this.currentDraggingPointerIds.length;t++)this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint()),this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingPivotPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.position),this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingPivotOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].pivotMesh.rotationQuaternion),this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].dragMesh.position),this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].startingOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[t]].dragMesh.rotationQuaternion)},r.prototype._pointerUpdate2D=function(t,e,n){!this._pointerCamera||this._pointerCamera.cameraRigMode!=Pt.RIG_MODE_NONE||this._pointerCamera._isLeftCamera||this._pointerCamera._isRightCamera||(t.origin.copyFrom(this._pointerCamera.globalPosition),n=0);var i=this._virtualMeshesInfo[e],o=_.AA.Vector3[0];t.origin.subtractToRef(i.lastOriginPosition,o),i.lastOriginPosition.copyFrom(t.origin);var a=-_.Pq.Dot(o,t.direction);i.originMesh.addChild(i.dragMesh),i.originMesh.addChild(i.pivotMesh),this._applyZOffset(i.dragMesh,a,n),this._applyZOffset(i.pivotMesh,a,n),i.originMesh.position.copyFrom(t.origin);var s=_.AA.Vector3[0];t.origin.addToRef(t.direction,s),i.originMesh.lookAt(s),i.originMesh.removeChild(i.dragMesh),i.originMesh.removeChild(i.pivotMesh)},r.prototype._pointerUpdateXR=function(t,e,n,i){var o=this._virtualMeshesInfo[n];if(o.originMesh.position.copyFrom(t.position),this._dragging===this._dragType.NEAR_DRAG&&e?o.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion):o.originMesh.rotationQuaternion.copyFrom(t.rotationQuaternion),o.pivotMesh.computeWorldMatrix(!0),o.dragMesh.computeWorldMatrix(!0),i!==0){var a=_.AA.Vector3[0],s=_.AA.Vector3[1];a.copyFrom(this._pointerCamera.getForwardRay().direction),o.originMesh.position.subtractToRef(o.lastOriginPosition,s),o.lastOriginPosition.copyFrom(o.originMesh.position);var l=s.length();s.normalize();var c=_.AA.Vector3[2],u=_.AA.Vector3[3];o.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition,c),o.dragMesh.absolutePosition.subtractToRef(o.originMesh.position,u);var d=u.length();c.normalize(),u.normalize();var h=Math.abs(_.Pq.Dot(s,u))*_.Pq.Dot(s,a)*i*l*d;h<0&&.01-d>h&&(h=Math.min(.01-d,0)),u.scaleInPlace(h),u.addToRef(o.pivotMesh.absolutePosition,this._tmpVector),o.pivotMesh.setAbsolutePosition(this._tmpVector),u.addToRef(o.dragMesh.absolutePosition,this._tmpVector),o.dragMesh.setAbsolutePosition(this._tmpVector)}},r.prototype.attach=function(t){var e=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),r._virtualScene||(r._virtualScene=new ke.Z(this._scene.getEngine(),{virtual:!0}),r._virtualScene.detachControl()),this._pointerObserver=this._scene.onPointerObservable.add(function(n){var i=n.event.pointerId;e._virtualMeshesInfo[i]||(e._virtualMeshesInfo[i]=e._createVirtualMeshInfo());var o,a=e._virtualMeshesInfo[i],s=n.event.pointerType==="xr-near"||n.event.pointerType==="xr";if(n.type==vt.Zp.POINTERDOWN){if(!a.dragging&&n.pickInfo&&n.pickInfo.hit&&n.pickInfo.pickedMesh&&n.pickInfo.pickedPoint&&n.pickInfo.ray&&(!s||n.pickInfo.aimTransform)&&(o=n.pickInfo.pickedMesh,e._ownerNode===o||o.isDescendantOf(e._ownerNode)&&(!e.draggableMeshes||e.draggableMeshes.indexOf(o)!==-1))){if((!e.allowMultiPointer||s)&&e.currentDraggingPointerIds.length>0)return;!e._pointerCamera||e._pointerCamera.cameraRigMode!==Pt.RIG_MODE_NONE||e._pointerCamera._isLeftCamera||e._pointerCamera._isRightCamera||n.pickInfo.ray.origin.copyFrom(e._pointerCamera.globalPosition),e._ownerNode.computeWorldMatrix(!0);var l=e._virtualMeshesInfo[i];s?(e._dragging=n.pickInfo.originMesh?e._dragType.NEAR_DRAG:e._dragType.DRAG_WITH_CONTROLLER,l.originMesh.position.copyFrom(n.pickInfo.aimTransform.position),e._dragging===e._dragType.NEAR_DRAG&&n.pickInfo.gripTransform?l.originMesh.rotationQuaternion.copyFrom(n.pickInfo.gripTransform.rotationQuaternion):l.originMesh.rotationQuaternion.copyFrom(n.pickInfo.aimTransform.rotationQuaternion)):(e._dragging=e._dragType.DRAG,l.originMesh.position.copyFrom(n.pickInfo.ray.origin)),l.lastOriginPosition.copyFrom(l.originMesh.position),l.dragMesh.position.copyFrom(n.pickInfo.pickedPoint),l.lastDragPosition.copyFrom(n.pickInfo.pickedPoint),l.pivotMesh.position.copyFrom(e._ownerNode.getAbsolutePivotPoint()),l.pivotMesh.rotationQuaternion.copyFrom(e._ownerNode.absoluteRotationQuaternion),l.startingPosition.copyFrom(l.dragMesh.position),l.startingPivotPosition.copyFrom(l.pivotMesh.position),l.startingOrientation.copyFrom(l.dragMesh.rotationQuaternion),l.startingPivotOrientation.copyFrom(l.pivotMesh.rotationQuaternion),s?(l.originMesh.addChild(l.dragMesh),l.originMesh.addChild(l.pivotMesh)):l.originMesh.lookAt(l.dragMesh.position),l.dragging=!0,e.currentDraggingPointerIds.indexOf(i)===-1&&e.currentDraggingPointerIds.push(i),e.detachCameraControls&&e._pointerCamera&&!e._pointerCamera.leftCamera&&(e._pointerCamera.inputs&&e._pointerCamera.inputs.attachedToElement?(e._pointerCamera.detachControl(),e._attachedToElement=!0):e.allowMultiPointer&&e.currentDraggingPointerIds.length!==0||(e._attachedToElement=!1)),e._targetDragStart(l.pivotMesh.position,l.pivotMesh.rotationQuaternion,i),e.onDragStartObservable.notifyObservers({position:l.pivotMesh.position})}}else if(n.type==vt.Zp.POINTERUP||n.type==vt.Zp.POINTERDOUBLETAP){var c=e.currentDraggingPointerIds.indexOf(i);a.dragging=!1,c!==-1&&(e.currentDraggingPointerIds.splice(c,1),e.currentDraggingPointerIds.length===0&&(e._moving=!1,e._dragging=e._dragType.NONE,e.detachCameraControls&&e._attachedToElement&&e._pointerCamera&&!e._pointerCamera.leftCamera&&(e._reattachCameraControls(),e._attachedToElement=!1)),a.originMesh.removeChild(a.dragMesh),a.originMesh.removeChild(a.pivotMesh),e._targetDragEnd(i),e.onDragEndObservable.notifyObservers({}))}else if(n.type==vt.Zp.POINTERMOVE&&(c=e.currentDraggingPointerIds.indexOf(i))!==-1&&a.dragging&&n.pickInfo&&(n.pickInfo.ray||n.pickInfo.aimTransform)){var u=e.zDragFactor;(e.currentDraggingPointerIds.length>1||n.pickInfo.originMesh)&&(u=0),e._ownerNode.computeWorldMatrix(!0),s?e._pointerUpdateXR(n.pickInfo.aimTransform,n.pickInfo.gripTransform,i,u):e._pointerUpdate2D(n.pickInfo.ray,i,u),e._tmpQuaternion.copyFrom(a.startingPivotOrientation),e._tmpQuaternion.x=-e._tmpQuaternion.x,e._tmpQuaternion.y=-e._tmpQuaternion.y,e._tmpQuaternion.z=-e._tmpQuaternion.z,a.pivotMesh.absoluteRotationQuaternion.multiplyToRef(e._tmpQuaternion,e._tmpQuaternion),a.pivotMesh.absolutePosition.subtractToRef(a.startingPivotPosition,e._tmpVector),e.onDragObservable.notifyObservers({delta:e._tmpVector,position:a.pivotMesh.position,pickInfo:n.pickInfo}),e._targetDrag(e._tmpVector,e._tmpQuaternion,i),a.lastDragPosition.copyFrom(a.dragMesh.absolutePosition),e._moving=!0}})},r.prototype._applyZOffset=function(t,e,n){t.position.z-=t.position.z<1?e*n:e*n*t.position.z,t.position.z<0&&(t.position.z=0)},r.prototype._targetDragStart=function(t,e,n){},r.prototype._targetDrag=function(t,e,n){},r.prototype._targetDragEnd=function(t){},r.prototype._reattachCameraControls=function(){if(this._pointerCamera)if(this._pointerCamera.getClassName()==="ArcRotateCamera"){var t=this._pointerCamera;t.attachControl(!t.inputs||t.inputs.noPreventDefault,t._useCtrlForPanning,t._panningMouseButton)}else this._pointerCamera.attachControl(!this._pointerCamera.inputs||this._pointerCamera.inputs.noPreventDefault)},r.prototype.detach=function(){for(var t in this._scene&&(this.detachCameraControls&&this._attachedToElement&&this._pointerCamera&&!this._pointerCamera.leftCamera&&(this._reattachCameraControls(),this._attachedToElement=!1),this._scene.onPointerObservable.remove(this._pointerObserver)),this._virtualMeshesInfo)this._virtualMeshesInfo[t].originMesh.dispose(),this._virtualMeshesInfo[t].dragMesh.dispose();this.onDragEndObservable.clear(),this.onDragObservable.clear(),this.onDragStartObservable.clear()},r}(),lm=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._sceneRenderObserver=null,e._targetPosition=new _.Pq(0,0,0),e._targetOrientation=new _.PT,e._targetScaling=new _.Pq(1,1,1),e._startingPosition=new _.Pq(0,0,0),e._startingOrientation=new _.PT,e._startingScaling=new _.Pq(1,1,1),e.onPositionChangedObservable=new K.cP,e.dragDeltaRatio=.2,e.rotateDraggedObject=!0,e.rotateAroundYOnly=!1,e.rotateWithMotionController=!0,e.disableMovement=!1,e.faceCameraOnDragStart=!1,e}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!1,configurable:!0}),t.prototype.attach=function(e){var n=this;r.prototype.attach.call(this,e),e.isNearGrabbable=!0,e.getChildMeshes().forEach(function(i){i.isNearGrabbable=!0}),this._virtualTransformNode=new jt("virtual_sixDof",Dc._virtualScene),this._virtualTransformNode.rotationQuaternion=_.PT.Identity(),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add(function(){if(n.currentDraggingPointerIds.length===1&&n._moving&&!n.disableMovement){var i=_.AA.Vector3[0];i.copyFrom(n._targetPosition).subtractInPlace(e.absolutePosition).scaleInPlace(n.dragDeltaRatio);var o=_.AA.Vector3[1];if(o.copyFrom(i),e.parent){var a=_.AA.Matrix[0];e.parent.absoluteRotationQuaternion.toRotationMatrix(a),a.invert(),_.Pq.TransformNormalToRef(i,a,o)}if(e.position.addInPlace(o),n.onPositionChangedObservable.notifyObservers({position:e.absolutePosition}),!e.parent||e.parent.scaling&&!e.parent.scaling.isNonUniformWithinEpsilon(.001)){var s=_.AA.Quaternion[0];if(s.copyFrom(n._targetOrientation),e.parent){var l=_.AA.Quaternion[0];l.copyFrom(e.parent.absoluteRotationQuaternion),l.invertInPlace(),l.multiplyToRef(n._targetOrientation,s)}_.PT.SlerpToRef(e.rotationQuaternion,s,n.dragDeltaRatio,e.rotationQuaternion)}}})},t.prototype._getPositionOffsetAround=function(e,n,i){var o=_.AA.Matrix[0],a=_.AA.Matrix[1],s=_.AA.Matrix[2],l=_.AA.Matrix[3],c=_.AA.Matrix[4];return _.uq.TranslationToRef(e.x,e.y,e.z,o),_.uq.TranslationToRef(-e.x,-e.y,-e.z,a),_.uq.FromQuaternionToRef(i,s),_.uq.ScalingToRef(n,n,n,l),a.multiplyToRef(s,c),c.multiplyToRef(l,c),c.multiplyToRef(o,c),c.getTranslation()},t.prototype._onePointerPositionUpdated=function(e,n){_.AA.Vector3[0].setAll(0),this._dragging===this._dragType.DRAG?this.rotateDraggedObject&&(this.rotateAroundYOnly?_.PT.RotationYawPitchRollToRef(n.toEulerAngles().y,0,0,_.AA.Quaternion[0]):_.AA.Quaternion[0].copyFrom(n),_.AA.Quaternion[0].multiplyToRef(this._startingOrientation,this._targetOrientation)):(this._dragging===this._dragType.NEAR_DRAG||this._dragging===this._dragType.DRAG_WITH_CONTROLLER&&this.rotateWithMotionController)&&n.multiplyToRef(this._startingOrientation,this._targetOrientation),this._targetPosition.copyFrom(this._startingPosition).addInPlace(e)},t.prototype._twoPointersPositionUpdated=function(){var e=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition,n=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition,i=_.AA.Vector3[0];e.addToRef(n,i),i.scaleInPlace(.5);var o=_.AA.Vector3[1];n.subtractToRef(e,o);var a=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition,s=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition,l=_.AA.Vector3[2];a.addToRef(s,l),l.scaleInPlace(.5);var c=_.AA.Vector3[3];s.subtractToRef(a,c);var u=c.length()/o.length(),d=l.subtract(i),h=_.PT.FromEulerAngles(0,_.Pq.GetAngleBetweenVectorsOnPlane(o.normalize(),c.normalize(),_.Pq.UpReadOnly),0),p=this._ownerNode.parent;this._ownerNode.setParent(null);var m=this._getPositionOffsetAround(i.subtract(this._virtualTransformNode.getAbsolutePivotPoint()),u,h);this._virtualTransformNode.rotationQuaternion.multiplyToRef(h,this._ownerNode.rotationQuaternion),this._virtualTransformNode.scaling.scaleToRef(u,this._ownerNode.scaling),this._virtualTransformNode.position.addToRef(d.addInPlace(m),this._ownerNode.position),this.onPositionChangedObservable.notifyObservers({position:this._ownerNode.position}),this._ownerNode.setParent(p)},t.prototype._targetDragStart=function(){var e=this.currentDraggingPointerIds.length;this._ownerNode.rotationQuaternion||(this._ownerNode.rotationQuaternion=_.PT.RotationYawPitchRoll(this._ownerNode.rotation.y,this._ownerNode.rotation.x,this._ownerNode.rotation.z));var n=this._ownerNode.getAbsolutePivotPoint();if(e===1){if(this._targetPosition.copyFrom(this._ownerNode.absolutePosition),this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion),this._targetScaling.copyFrom(this._ownerNode.absoluteScaling),this.faceCameraOnDragStart&&this._scene.activeCamera){var i=_.AA.Vector3[0];this._scene.activeCamera.position.subtractToRef(n,i),i.normalize();var o=_.AA.Quaternion[0];this._scene.useRightHandedSystem?_.PT.FromLookDirectionRHToRef(i,new _.Pq(0,1,0),o):_.PT.FromLookDirectionLHToRef(i,new _.Pq(0,1,0),o),o.normalize(),_.PT.RotationYawPitchRollToRef(o.toEulerAngles().y,0,0,_.AA.Quaternion[0]),this._targetOrientation.copyFrom(_.AA.Quaternion[0])}this._startingPosition.copyFrom(this._targetPosition),this._startingOrientation.copyFrom(this._targetOrientation),this._startingScaling.copyFrom(this._targetScaling)}else e===2&&(this._virtualTransformNode.setPivotPoint(new _.Pq(0,0,0),0),this._virtualTransformNode.position.copyFrom(this._ownerNode.absolutePosition),this._virtualTransformNode.scaling.copyFrom(this._ownerNode.absoluteScaling),this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.absoluteRotationQuaternion),this._virtualTransformNode.setPivotPoint(n,1),this._resetVirtualMeshesPosition())},t.prototype._targetDrag=function(e,n){this.currentDraggingPointerIds.length===1?this._onePointerPositionUpdated(e,n):this.currentDraggingPointerIds.length===2&&this._twoPointersPositionUpdated()},t.prototype._targetDragEnd=function(){if(this.currentDraggingPointerIds.length===1){this._resetVirtualMeshesPosition();var e=this.faceCameraOnDragStart;this.faceCameraOnDragStart=!1,this._targetDragStart(),this.faceCameraOnDragStart=e}},t.prototype.detach=function(){r.prototype.detach.call(this),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualTransformNode&&this._virtualTransformNode.dispose()},t}(Dc),qS=function(){function r(){this._attachPointLocalOffset=new _.Pq,this._workingPosition=new _.Pq,this._workingQuaternion=new _.PT,this._lastTick=-1,this._hit=!1,this.hitNormalOffset=.05,this.meshes=[],this.interpolatePose=!0,this.lerpTime=250,this.keepOrientationVertical=!0,this.enabled=!0,this.maxStickingDistance=.8}return Object.defineProperty(r.prototype,"name",{get:function(){return"SurfaceMagnetism"},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t,e){this._attachedMesh=t,this._scene=e||t.getScene(),this._attachedMesh.rotationQuaternion||(this._attachedMesh.rotationQuaternion=_.PT.RotationYawPitchRoll(this._attachedMesh.rotation.y,this._attachedMesh.rotation.x,this._attachedMesh.rotation.z)),this.updateAttachPoint(),this._workingPosition.copyFrom(this._attachedMesh.position),this._workingQuaternion.copyFrom(this._attachedMesh.rotationQuaternion),this._addObservables()},r.prototype.detach=function(){this._attachedMesh=null,this._removeObservables()},r.prototype._getTargetPose=function(t){if(!this._attachedMesh)return null;if(t&&t.hit){var e=t.getNormal(!0,!0),n=t.pickedPoint;if(!e||!n)return null;e.normalize();var i=_.AA.Vector3[0];return i.copyFrom(e),i.scaleInPlace(this.hitNormalOffset),i.addInPlace(n),this._attachedMesh.parent&&(_.AA.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),_.Pq.TransformNormalToRef(i,_.AA.Matrix[0],i)),{position:i,quaternion:_.PT.RotationYawPitchRoll(-Math.atan2(e.x,-e.z),this.keepOrientationVertical?0:Math.atan2(e.y,Math.sqrt(e.z*e.z+e.x*e.x)),0)}}return null},r.prototype.updateAttachPoint=function(){this._getAttachPointOffsetToRef(this._attachPointLocalOffset)},r.prototype.findAndUpdateTarget=function(t){if(this._hit=!1,!t.ray)return!1;var e=t.ray.intersectsMeshes(this.meshes)[0];if(this._attachedMesh&&e&&e.hit&&e.pickedMesh){var n=this._getTargetPose(e);n&&_.Pq.Distance(this._attachedMesh.position,n.position)<this.maxStickingDistance&&(this._workingPosition.copyFrom(n.position),this._workingQuaternion.copyFrom(n.quaternion),this._hit=!0)}return this._hit},r.prototype._getAttachPointOffsetToRef=function(t){if(this._attachedMesh){var e=_.AA.Quaternion[0];e.copyFrom(this._attachedMesh.rotationQuaternion),this._attachedMesh.rotationQuaternion.copyFromFloats(0,0,0,1),this._attachedMesh.computeWorldMatrix();var n=this._attachedMesh.getHierarchyBoundingVectors(),i=_.AA.Vector3[0];n.max.addToRef(n.min,i),i.scaleInPlace(.5),i.z=n.max.z;var o=_.AA.Matrix[0];this._attachedMesh.getWorldMatrix().invertToRef(o),_.Pq.TransformCoordinatesToRef(i,o,t),this._attachedMesh.rotationQuaternion.copyFrom(e)}else t.setAll(0)},r.prototype._updateTransformToGoal=function(t){if(this._attachedMesh&&this._hit){var e=this._attachedMesh.parent;this._attachedMesh.setParent(null);var n=_.AA.Vector3[0];if(_.Pq.TransformNormalToRef(this._attachPointLocalOffset,this._attachedMesh.getWorldMatrix(),n),!this.interpolatePose)return this._attachedMesh.position.copyFrom(this._workingPosition).subtractInPlace(n),void this._attachedMesh.rotationQuaternion.copyFrom(this._workingQuaternion);var i=new _.Pq;_.Pq.SmoothToRef(this._attachedMesh.position,this._workingPosition,t,this.lerpTime,i),this._attachedMesh.position.copyFrom(i);var o=new _.PT;o.copyFrom(this._attachedMesh.rotationQuaternion),_.PT.SmoothToRef(o,this._workingQuaternion,t,this.lerpTime,this._attachedMesh.rotationQuaternion),this._attachedMesh.setParent(e)}},r.prototype._addObservables=function(){var t=this;this._pointerObserver=this._scene.onPointerObservable.add(function(e){t.enabled&&e.type==vt.Zp.POINTERMOVE&&e.pickInfo&&t.findAndUpdateTarget(e.pickInfo)}),this._lastTick=Date.now(),this._onBeforeRender=this._scene.onBeforeRenderObservable.add(function(){var e=Date.now();t._updateTransformToGoal(e-t._lastTick),t._lastTick=e})},r.prototype._removeObservables=function(){this._scene.onPointerObservable.remove(this._pointerObserver),this._scene.onBeforeRenderObservable.remove(this._onBeforeRender),this._pointerObserver=null,this._onBeforeRender=null},r}(),KS=function(){function r(){this._tmpQuaternion=new _.PT,this._tmpVectors=[new _.Pq,new _.Pq,new _.Pq,new _.Pq,new _.Pq,new _.Pq,new _.Pq],this._tmpMatrix=new _.uq,this._tmpInvertView=new _.uq,this._tmpForward=new _.Pq,this._tmpNodeForward=new _.Pq,this._tmpPosition=new _.Pq,this._workingPosition=new _.Pq,this._workingQuaternion=new _.PT,this._lastTick=-1,this._recenterNextUpdate=!0,this.interpolatePose=!0,this.lerpTime=500,this.ignoreCameraPitchAndRoll=!1,this.pitchOffset=15,this.maxViewVerticalDegrees=30,this.maxViewHorizontalDegrees=30,this.orientToCameraDeadzoneDegrees=60,this.ignoreDistanceClamp=!1,this.ignoreAngleClamp=!1,this.verticalMaxDistance=0,this.defaultDistance=.8,this.maximumDistance=2,this.minimumDistance=.3,this.useFixedVerticalOffset=!1,this.fixedVerticalOffset=0,this._enabled=!0}return Object.defineProperty(r.prototype,"followedCamera",{get:function(){return this._followedCamera||this._scene.activeCamera},set:function(t){this._followedCamera=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return"Follow"},enumerable:!1,configurable:!0}),r.prototype.init=function(){},r.prototype.attach=function(t,e){this._scene=t.getScene(),this.attachedNode=t,e&&(this.followedCamera=e),this._addObservables()},r.prototype.detach=function(){this.attachedNode=null,this._removeObservables()},r.prototype.recenter=function(){this._recenterNextUpdate=!0},r.prototype._angleBetweenVectorAndPlane=function(t,e){return this._tmpVectors[0].copyFrom(t),t=this._tmpVectors[0],this._tmpVectors[1].copyFrom(e),e=this._tmpVectors[1],t.normalize(),e.normalize(),Math.PI/2-Math.acos(_.Pq.Dot(t,e))},r.prototype._length2D=function(t){return Math.sqrt(t.x*t.x+t.z*t.z)},r.prototype._distanceClamp=function(t,e){e===void 0&&(e=!1);var n=this.minimumDistance,i=this.maximumDistance,o=this.defaultDistance,a=this._tmpVectors[0];a.copyFrom(t);var s=a.length();if(a.normalizeFromLength(s),this.ignoreCameraPitchAndRoll){n=this._length2D(a)*n,i=this._length2D(a)*i;var l=this._length2D(t);a.scaleInPlace(s/l),s=l}var c;return c=e?o:(0,qe.Clamp)(s,n,i),t.copyFrom(a).scaleInPlace(c),s!==c},r.prototype._applyVerticalClamp=function(t){this.verticalMaxDistance!==0&&(t.y=(0,qe.Clamp)(t.y,-this.verticalMaxDistance,this.verticalMaxDistance))},r.prototype._toOrientationQuatToRef=function(t,e){_.PT.RotationYawPitchRollToRef(Math.atan2(t.x,t.z),Math.atan2(t.y,Math.sqrt(t.z*t.z+t.x*t.x)),0,e)},r.prototype._applyPitchOffset=function(t){var e=this._tmpVectors[0],n=this._tmpVectors[1];e.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),n.copyFromFloats(1,0,0),_.Pq.TransformNormalToRef(e,t,e),e.y=0,e.normalize(),_.Pq.TransformNormalToRef(n,t,n),_.PT.RotationAxisToRef(n,this.pitchOffset*Math.PI/180,this._tmpQuaternion),e.rotateByQuaternionToRef(this._tmpQuaternion,e),this._toOrientationQuatToRef(e,this._tmpQuaternion),this._tmpQuaternion.toRotationMatrix(this._tmpMatrix),t.copyFrom(this._tmpMatrix)},r.prototype._angularClamp=function(t,e){var n=this._tmpVectors[5];n.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1);var i=this._tmpVectors[6];i.copyFromFloats(1,0,0),_.Pq.TransformNormalToRef(n,t,n),_.Pq.TransformNormalToRef(i,t,i);var o=_.Pq.UpReadOnly;if(e.length()<pt.bH)return!1;var a=!1,s=this._tmpQuaternion;if(this.ignoreCameraPitchAndRoll){var l=_.Pq.GetAngleBetweenVectorsOnPlane(e,n,i);_.PT.RotationAxisToRef(i,l,s),e.rotateByQuaternionToRef(s,e)}else{var c=-_.Pq.GetAngleBetweenVectorsOnPlane(e,n,i),u=this.maxViewVerticalDegrees*Math.PI/180*.5;c<-u?(_.PT.RotationAxisToRef(i,-c-u,s),e.rotateByQuaternionToRef(s,e),a=!0):c>u&&(_.PT.RotationAxisToRef(i,-c+u,s),e.rotateByQuaternionToRef(s,e),a=!0)}var d=this._angleBetweenVectorAndPlane(e,i)*(this._scene.useRightHandedSystem?-1:1),h=this.maxViewHorizontalDegrees*Math.PI/180*.5;return d<-h?(_.PT.RotationAxisToRef(o,-d-h,s),e.rotateByQuaternionToRef(s,e),a=!0):d>h&&(_.PT.RotationAxisToRef(o,-d+h,s),e.rotateByQuaternionToRef(s,e),a=!0),a},r.prototype._orientationClamp=function(t,e){var n,i=this._tmpVectors[0];i.copyFrom(t).scaleInPlace(-1).normalize();var o=this._tmpVectors[1],a=this._tmpVectors[2];o.copyFromFloats(0,1,0),_.Pq.CrossToRef(i,o,a);var s=a.length();s<pt.bH||(a.normalizeFromLength(s),_.Pq.CrossToRef(a,i,o),!((n=this.attachedNode)===null||n===void 0)&&n.getScene().useRightHandedSystem?_.PT.FromLookDirectionRHToRef(i,o,e):_.PT.FromLookDirectionLHToRef(i,o,e))},r.prototype._passedOrientationDeadzone=function(t,e){var n=this._tmpVectors[5];return n.copyFrom(t),n.normalize(),180*Math.abs(_.Pq.GetAngleBetweenVectorsOnPlane(e,n,_.Pq.UpReadOnly))/Math.PI>this.orientToCameraDeadzoneDegrees},r.prototype._updateLeashing=function(t){if(this.attachedNode&&this._enabled){var e=this.attachedNode.parent;this.attachedNode.setParent(null);var n=this.attachedNode.getWorldMatrix(),i=this._workingPosition,o=this._workingQuaternion,a=this.attachedNode.getPivotPoint(),s=this._tmpInvertView;s.copyFrom(t.getViewMatrix()),s.invert(),_.Pq.TransformCoordinatesToRef(a,n,i);var l=this._tmpPosition;l.copyFromFloats(0,0,0),_.Pq.TransformCoordinatesToRef(l,n,l),l.scaleInPlace(-1).subtractInPlace(a),i.subtractInPlace(t.globalPosition),this.ignoreCameraPitchAndRoll&&this._applyPitchOffset(s);var c=!1,u=this._tmpForward;u.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),_.Pq.TransformNormalToRef(u,s,u);var d=this._tmpNodeForward;if(d.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),_.Pq.TransformNormalToRef(d,n,d),this._recenterNextUpdate)i.copyFrom(u).scaleInPlace(this.defaultDistance);else if(this.ignoreAngleClamp){var h=i.length();i.copyFrom(u).scaleInPlace(h)}else c=this._angularClamp(s,i);var p=!1;this.ignoreDistanceClamp||(p=this._distanceClamp(i,c),this._applyVerticalClamp(i)),this.useFixedVerticalOffset&&(i.y=l.y-t.globalPosition.y+this.fixedVerticalOffset),(c||p||this._passedOrientationDeadzone(i,d)||this._recenterNextUpdate)&&this._orientationClamp(i,o),this._workingPosition.subtractInPlace(a),this._recenterNextUpdate=!1,this.attachedNode.setParent(e)}},r.prototype._updateTransformToGoal=function(t){if(this.attachedNode&&this.followedCamera&&this._enabled){this.attachedNode.rotationQuaternion||(this.attachedNode.rotationQuaternion=_.PT.Identity());var e=this.attachedNode.parent;if(this.attachedNode.setParent(null),!this.interpolatePose)return this.attachedNode.position.copyFrom(this.followedCamera.globalPosition).addInPlace(this._workingPosition),void this.attachedNode.rotationQuaternion.copyFrom(this._workingQuaternion);var n=new _.Pq;n.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),_.Pq.SmoothToRef(n,this._workingPosition,t,this.lerpTime,n),n.addInPlace(this.followedCamera.globalPosition),this.attachedNode.position.copyFrom(n);var i=new _.PT;i.copyFrom(this.attachedNode.rotationQuaternion),_.PT.SmoothToRef(i,this._workingQuaternion,t,this.lerpTime,this.attachedNode.rotationQuaternion),this.attachedNode.setParent(e)}},r.prototype._addObservables=function(){var t=this;this._lastTick=Date.now(),this._onBeforeRender=this._scene.onBeforeRenderObservable.add(function(){if(t.followedCamera){var e=Date.now();t._updateLeashing(t.followedCamera),t._updateTransformToGoal(e-t._lastTick),t._lastTick=e}})},r.prototype._removeObservables=function(){this._onBeforeRender&&this._scene.onBeforeRenderObservable.remove(this._onBeforeRender)},r}(),vn=function(){function r(){}return r.ANCHOR_SYSTEM="xr-anchor-system",r.BACKGROUND_REMOVER="xr-background-remover",r.HIT_TEST="xr-hit-test",r.MESH_DETECTION="xr-mesh-detection",r.PHYSICS_CONTROLLERS="xr-physics-controller",r.PLANE_DETECTION="xr-plane-detection",r.POINTER_SELECTION="xr-controller-pointer-selection",r.TELEPORTATION="xr-controller-teleportation",r.FEATURE_POINTS="xr-feature-points",r.HAND_TRACKING="xr-hand-tracking",r.IMAGE_TRACKING="xr-image-tracking",r.NEAR_INTERACTION="xr-near-interaction",r.DOM_OVERLAY="xr-dom-overlay",r.MOVEMENT="xr-controller-movement",r.LIGHT_ESTIMATION="xr-light-estimation",r.EYE_TRACKING="xr-eye-tracking",r.WALKING_LOCOMOTION="xr-walking-locomotion",r.LAYERS="xr-layers",r.DEPTH_SENSING="xr-depth-sensing",r.SPACE_WARP="xr-space-warp",r.RAW_CAMERA_ACCESS="xr-raw-camera-access",r}(),kn=function(){function r(t){var e=this;this._xrSessionManager=t,this._features={},this._xrSessionManager.onXRSessionInit.add(function(){e.getEnabledFeatures().forEach(function(n){var i=e._features[n];!i.enabled||i.featureImplementation.attached||i.featureImplementation.disableAutoAttach||e.attachFeature(n)})}),this._xrSessionManager.onXRSessionEnded.add(function(){e.getEnabledFeatures().forEach(function(n){var i=e._features[n];i.enabled&&i.featureImplementation.attached&&e.detachFeature(n)})})}return r.AddWebXRFeature=function(t,e,n,i){n===void 0&&(n=1),i===void 0&&(i=!1),this._AvailableFeatures[t]=this._AvailableFeatures[t]||{latest:n},n>this._AvailableFeatures[t].latest&&(this._AvailableFeatures[t].latest=n),i&&(this._AvailableFeatures[t].stable=n),this._AvailableFeatures[t][n]=e},r.ConstructFeature=function(t,e,n,i){e===void 0&&(e=1);var o=this._AvailableFeatures[t][e];if(!o)throw new Error("feature not found");return o(n,i)},r.GetAvailableFeatures=function(){return Object.keys(this._AvailableFeatures)},r.GetAvailableVersions=function(t){return Object.keys(this._AvailableFeatures[t])},r.GetLatestVersionOfFeature=function(t){return this._AvailableFeatures[t]&&this._AvailableFeatures[t].latest||-1},r.GetStableVersionOfFeature=function(t){return this._AvailableFeatures[t]&&this._AvailableFeatures[t].stable||-1},r.prototype.attachFeature=function(t){var e=this._features[t];e&&e.enabled&&!e.featureImplementation.attached&&(e.featureImplementation.attach()||ze.S0.Warn("Feature ".concat(t," failed to attach")))},r.prototype.detachFeature=function(t){var e=this._features[t];e&&e.featureImplementation.attached&&(e.featureImplementation.detach()||ze.S0.Warn("Feature ".concat(t," failed to detach")))},r.prototype.disableFeature=function(t){var e=typeof t=="string"?t:t.Name,n=this._features[e];return!(!n||!n.enabled||(n.enabled=!1,this.detachFeature(e),n.featureImplementation.dispose(),delete this._features[e],0))},r.prototype.dispose=function(){var t=this;this.getEnabledFeatures().forEach(function(e){t.disableFeature(e)})},r.prototype.enableFeature=function(t,e,n,i,o){var a=this;e===void 0&&(e="latest"),n===void 0&&(n={}),i===void 0&&(i=!0),o===void 0&&(o=!0);var s=typeof t=="string"?t:t.Name,l=0;if(typeof e=="string"){if(!e)throw new Error("Error in provided version - ".concat(s," (").concat(e,")"));if((l=e==="stable"?r.GetStableVersionOfFeature(s):e==="latest"?r.GetLatestVersionOfFeature(s):+e)===-1||isNaN(l))throw new Error("feature not found - ".concat(s," (").concat(e,")"))}else l=e;var c=r._ConflictingFeatures[s];if(c!==void 0&&this.getEnabledFeatures().indexOf(c)!==-1)throw new Error("Feature ".concat(s," cannot be enabled while ").concat(c," is enabled."));var u=this._features[s],d=r.ConstructFeature(s,l,this._xrSessionManager,n);if(!d)throw new Error("feature not found - ".concat(s));u&&this.disableFeature(s);var h=d();if(h.dependsOn){var p=h.dependsOn.every(function(m){return!!a._features[m]});if(!p)throw new Error("Dependant features missing. Make sure the following features are enabled - ".concat(h.dependsOn.join(", ")))}if(h.isCompatible())return this._features[s]={featureImplementation:h,enabled:!0,version:l,required:o},i?this._xrSessionManager.session&&!this._features[s].featureImplementation.attached&&this.attachFeature(s):this._features[s].featureImplementation.disableAutoAttach=!0,this._features[s].featureImplementation;if(o)throw new Error("required feature not compatible");return ze.S0.Warn("Feature ".concat(s," not compatible with the current environment/browser and was not enabled.")),h},r.prototype.getEnabledFeature=function(t){return this._features[t]&&this._features[t].featureImplementation},r.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},r.prototype._extendXRSessionInitObject=function(t){return(0,A.sH)(this,void 0,void 0,function(){var e,n,i,o,a,s,l;return(0,A.YH)(this,function(c){switch(c.label){case 0:e=this.getEnabledFeatures(),n=0,i=e,c.label=1;case 1:return n<i.length?(o=i[n],a=this._features[o],(s=a.featureImplementation.xrNativeFeatureName)&&(a.required?(t.requiredFeatures=t.requiredFeatures||[],t.requiredFeatures.indexOf(s)===-1&&t.requiredFeatures.push(s)):(t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.indexOf(s)===-1&&t.optionalFeatures.push(s))),a.featureImplementation.getXRSessionInitExtension?[4,a.featureImplementation.getXRSessionInitExtension()]:[3,3]):[3,4];case 2:l=c.sent(),t=(0,A.Cl)((0,A.Cl)({},t),l),c.label=3;case 3:return n++,[3,1];case 4:return[2,t]}})})},r._AvailableFeatures={},r._ConflictingFeatures=((sm={})[vn.TELEPORTATION]=vn.MOVEMENT,sm[vn.MOVEMENT]=vn.TELEPORTATION,sm),r}();(function(r){r[r.ABOVE_FINGER_TIPS=0]="ABOVE_FINGER_TIPS",r[r.RADIAL_SIDE=1]="RADIAL_SIDE",r[r.ULNAR_SIDE=2]="ULNAR_SIDE",r[r.BELOW_WRIST=3]="BELOW_WRIST"})(Ic||(Ic={})),function(r){r[r.LOOK_AT_CAMERA=0]="LOOK_AT_CAMERA",r[r.HAND_ROTATION=1]="HAND_ROTATION"}(Mc||(Mc={})),function(r){r[r.ALWAYS_VISIBLE=0]="ALWAYS_VISIBLE",r[r.PALM_UP=1]="PALM_UP",r[r.GAZE_FOCUS=2]="GAZE_FOCUS",r[r.PALM_AND_GAZE=3]="PALM_AND_GAZE"}(Oc||(Oc={}));var cm,ZS=function(){function r(){this._sceneRenderObserver=null,this._zoneAxis={},this.handConstraintVisibility=3,this.palmUpStrictness=.95,this.gazeProximityRadius=.15,this.targetOffset=.1,this.targetZone=2,this.zoneOrientationMode=1,this.nodeOrientationMode=1,this.handedness="none",this.lerpTime=100,this._zoneAxis[0]=new _.Pq(0,1,0),this._zoneAxis[1]=new _.Pq(-1,0,0),this._zoneAxis[2]=new _.Pq(1,0,0),this._zoneAxis[3]=new _.Pq(0,-1,0)}return Object.defineProperty(r.prototype,"name",{get:function(){return"HandConstraint"},enumerable:!1,configurable:!0}),r.prototype.enable=function(){this._node.setEnabled(!0)},r.prototype.disable=function(){this._node.setEnabled(!1)},r.prototype._getHandPose=function(){if(!this._handTracking)return null;var t;if(t=this.handedness==="none"?this._handTracking.getHandByHandedness("left")||this._handTracking.getHandByHandedness("right"):this._handTracking.getHandByHandedness(this.handedness)){var e=t.getJointMesh("pinky-finger-metacarpal"),n=t.getJointMesh("middle-finger-metacarpal"),i=t.getJointMesh("wrist");if(i&&n&&e){var o={position:n.absolutePosition,quaternion:new _.PT,id:t.xrController.uniqueId},a=_.AA.Vector3[0],s=_.AA.Vector3[1],l=_.AA.Vector3[2];return a.copyFrom(n.absolutePosition).subtractInPlace(i.absolutePosition).normalize(),s.copyFrom(e.absolutePosition).subtractInPlace(n.absolutePosition).normalize(),_.Pq.CrossToRef(a,s,s),_.Pq.CrossToRef(s,a,l),_.PT.FromLookDirectionLHToRef(s,a,o.quaternion),o}}return null},r.prototype.init=function(){},r.prototype.attach=function(t){var e=this;this._node=t,this._scene=t.getScene(),this._node.rotationQuaternion||(this._node.rotationQuaternion=_.PT.RotationYawPitchRoll(this._node.rotation.y,this._node.rotation.x,this._node.rotation.z));var n=Date.now();this._sceneRenderObserver=this._scene.onBeforeRenderObservable.add(function(){var i=e._getHandPose();if(e._node.reservedDataStore=e._node.reservedDataStore||{},e._node.reservedDataStore.nearInteraction=e._node.reservedDataStore.nearInteraction||{},e._node.reservedDataStore.nearInteraction.excludedControllerId=null,i){var o=_.AA.Vector3[0],a=e._scene.activeCamera;o.copyFrom(e._zoneAxis[e.targetZone]);var s=_.AA.Quaternion[0];if(a&&(e.zoneOrientationMode===0||e.nodeOrientationMode===0)){var l=_.AA.Vector3[1];l.copyFrom(a.position).subtractInPlace(i.position).normalize(),e._scene.useRightHandedSystem?_.PT.FromLookDirectionRHToRef(l,_.Pq.UpReadOnly,s):_.PT.FromLookDirectionLHToRef(l,_.Pq.UpReadOnly,s)}e.zoneOrientationMode===1?i.quaternion.toRotationMatrix(_.AA.Matrix[0]):s.toRotationMatrix(_.AA.Matrix[0]),_.Pq.TransformNormalToRef(o,_.AA.Matrix[0],o),o.scaleInPlace(e.targetOffset);var c=_.AA.Vector3[2],u=_.AA.Quaternion[1];c.copyFrom(i.position).addInPlace(o),e.nodeOrientationMode===1?u.copyFrom(i.quaternion):u.copyFrom(s);var d=Date.now()-n;_.Pq.SmoothToRef(e._node.position,c,d,e.lerpTime,e._node.position),_.PT.SmoothToRef(e._node.rotationQuaternion,u,d,e.lerpTime,e._node.rotationQuaternion),e._node.reservedDataStore.nearInteraction.excludedControllerId=i.id}e._setVisibility(i),n=Date.now()})},r.prototype._setVisibility=function(t){var e=!0,n=!0,i=this._scene.activeCamera;if(i){var o=i.getForwardRay();if(this.handConstraintVisibility===2||this.handConstraintVisibility===3){n=!1;var a=void 0;this._eyeTracking&&(a=this._eyeTracking.getEyeGaze()),a=a||o;var s=_.AA.Vector3[0];t?t.position.subtractToRef(a.origin,s):this._node.getAbsolutePosition().subtractToRef(a.origin,s);var l=_.Pq.Dot(s,a.direction),c=l*l;l>0&&s.lengthSquared()-c<this.gazeProximityRadius*this.gazeProximityRadius&&(n=!0)}if((this.handConstraintVisibility===1||this.handConstraintVisibility===3)&&(e=!1,t)){var u=_.AA.Vector3[0];_.Pq.LeftHandedForwardReadOnly.rotateByQuaternionToRef(t.quaternion,u),_.Pq.Dot(u,o.direction)>2*this.palmUpStrictness-1&&(e=!0)}}this._node.setEnabled(e&&n)},r.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver)},r.prototype.linkToXRExperience=function(t){var e=t.featuresManager?t.featuresManager:t;if(e){try{this._eyeTracking=e.getEnabledFeature(vn.EYE_TRACKING)}catch{}try{this._handTracking=e.getEnabledFeature(vn.HAND_TRACKING)}catch{ze.S0.Error("Hand tracking must be enabled for the Hand Menu to work")}}else ze.S0.Error("XR features manager must be available or provided directly for the Hand Menu to work")},r}(),QS=function(){function r(t,e,n){this.targetPosition=_.Pq.Zero(),this.poleTargetPosition=_.Pq.Zero(),this.poleTargetLocalOffset=_.Pq.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=_.PT.Identity(),this._bone1Mat=_.uq.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=_.Pq.Right(),this._slerping=!1,this._adjustRoll=0,this._notEnoughInformation=!1,this._bone2=e;var i=e.getParent();if(!i)return this._notEnoughInformation=!0,void O.V.Error("BoneIKController: bone must have a parent for IK to work.");if(this._bone1=i,this._bone2.children.length===0&&!this._bone2.length)return this._notEnoughInformation=!0,void O.V.Error("BoneIKController: bone must not be a leaf or it should have a length for IK to work.");this.mesh=t,e.getSkeleton().computeAbsoluteMatrices();var o=e.getPosition();if(e.getAbsoluteMatrix().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,o.x>o.y&&o.x>o.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length&&this._bone2.length){var a=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*a.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone2.children[0]){t.computeWorldMatrix(!0);var l=this._bone2.children[0].getAbsolutePosition(t),c=this._bone2.getAbsolutePosition(t),u=this._bone1.getAbsolutePosition(t);this._bone2Length=_.Pq.Distance(l,c),this._bone1Length=_.Pq.Distance(c,u)}else t.computeWorldMatrix(!0),s=this._bone2.getScale(),this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y,c=this._bone2.getAbsolutePosition(t),u=this._bone1.getAbsolutePosition(t),this._bone1Length=_.Pq.Distance(c,u);this._bone1.getRotationMatrixToRef(1,t,this._bone1Mat),this.maxAngle=Math.PI,n&&(n.targetMesh&&(this.targetMesh=n.targetMesh,this.targetMesh.computeWorldMatrix(!0)),n.poleTargetMesh?(this.poleTargetMesh=n.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):n.poleTargetBone?this.poleTargetBone=n.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),n.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(n.poleTargetLocalOffset),n.poleAngle&&(this.poleAngle=n.poleAngle),n.bendAxis&&this._bendAxis.copyFrom(n.bendAxis),n.maxAngle&&(this.maxAngle=n.maxAngle),n.slerpAmount&&(this.slerpAmount=n.slerpAmount))}return Object.defineProperty(r.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(t){this._setMaxAngle(t)},enumerable:!1,configurable:!0}),r.prototype._setMaxAngle=function(t){t<0&&(t=0),(t>Math.PI||t==null)&&(t=Math.PI),this._maxAngle=t;var e=this._bone1Length,n=this._bone2Length;this._maxReach=Math.sqrt(e*e+n*n-2*e*n*Math.cos(t))},r.prototype.update=function(){if(!this._notEnoughInformation){var t=this.targetPosition,e=this.poleTargetPosition,n=r._TmpMats[0],i=r._TmpMats[1];this.targetMesh&&t.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,e):this.poleTargetMesh&&_.Pq.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),e);var o=r._TmpVecs[0],a=r._TmpVecs[1],s=r._TmpVecs[2],l=r._TmpVecs[3],c=r._TmpVecs[4],u=r._TmpQuat;this._bone1.getAbsolutePositionToRef(this.mesh,o),e.subtractToRef(o,c),c.x==0&&c.y==0&&c.z==0?c.y=1:c.normalize(),t.subtractToRef(o,l),l.normalize(),_.Pq.CrossToRef(l,c,a),a.normalize(),_.Pq.CrossToRef(l,a,s),s.normalize(),_.uq.FromXYZAxesToRef(s,l,a,n);var d=this._bone1Length,h=this._bone2Length,p=_.Pq.Distance(o,t);this._maxReach>0&&(p=Math.min(this._maxReach,p));var m=(h*h+p*p-d*d)/(2*h*p),v=(p*p+d*d-h*h)/(2*p*d);m>1&&(m=1),v>1&&(v=1),m<-1&&(m=-1),v<-1&&(v=-1);var b=Math.acos(m),E=Math.acos(v),C=-b-E;if(this._rightHandedSystem)_.uq.RotationYawPitchRollToRef(0,0,this._adjustRoll,i),i.multiplyToRef(n,n),_.uq.RotationAxisToRef(this._bendAxis,E,i),i.multiplyToRef(n,n);else{var T=r._TmpVecs[5];T.copyFrom(this._bendAxis),T.x*=-1,_.uq.RotationAxisToRef(T,-E,i),i.multiplyToRef(n,n)}this.poleAngle&&(_.uq.RotationAxisToRef(l,this.poleAngle,i),n.multiplyToRef(i,n)),this._bone1&&(this.slerpAmount<1?(this._slerping||_.PT.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),_.PT.FromRotationMatrixToRef(n,u),_.PT.SlerpToRef(this._bone1Quat,u,this.slerpAmount,this._bone1Quat),C=this._bone2Ang*(1-this.slerpAmount)+C*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,1,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,1,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1),this._updateLinkedTransformRotation(this._bone1)),this._bone2.setAxisAngle(this._bendAxis,C,0),this._updateLinkedTransformRotation(this._bone2),this._bone2Ang=C}},r.prototype._updateLinkedTransformRotation=function(t){t._linkedTransformNode&&(t._linkedTransformNode.rotationQuaternion||(t._linkedTransformNode.rotationQuaternion=new _.PT),t.getRotationQuaternionToRef(0,null,t._linkedTransformNode.rotationQuaternion))},r._TmpVecs=[_.Pq.Zero(),_.Pq.Zero(),_.Pq.Zero(),_.Pq.Zero(),_.Pq.Zero(),_.Pq.Zero()],r._TmpQuat=_.PT.Identity(),r._TmpMats=[_.uq.Identity(),_.uq.Identity()],r}(),JS=function(){function r(t,e,n,i){if(this.upAxis=_.Pq.Up(),this.upAxisSpace=0,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=_.PT.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=_.Pq.Forward(),this.useAbsoluteValueForYaw=!1,this.mesh=t,this.bone=e,this.target=n,i){if(i.adjustYaw&&(this.adjustYaw=i.adjustYaw),i.adjustPitch&&(this.adjustPitch=i.adjustPitch),i.adjustRoll&&(this.adjustRoll=i.adjustRoll),i.maxYaw!=null?this.maxYaw=i.maxYaw:this.maxYaw=Math.PI,i.minYaw!=null?this.minYaw=i.minYaw:this.minYaw=-Math.PI,i.maxPitch!=null?this.maxPitch=i.maxPitch:this.maxPitch=Math.PI,i.minPitch!=null?this.minPitch=i.minPitch:this.minPitch=-Math.PI,i.slerpAmount!=null&&(this.slerpAmount=i.slerpAmount),i.upAxis!=null&&(this.upAxis=i.upAxis),i.upAxisSpace!=null&&(this.upAxisSpace=i.upAxisSpace),i.yawAxis!=null||i.pitchAxis!=null){var o=Qn._0.Y,a=Qn._0.X;i.yawAxis!=null&&(o=i.yawAxis.clone()).normalize(),i.pitchAxis!=null&&(a=i.pitchAxis.clone()).normalize();var s=_.Pq.Cross(a,o);this._transformYawPitch=_.uq.Identity(),_.uq.FromXYZAxesToRef(a,o,s,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}i.useAbsoluteValueForYaw!==void 0&&(this.useAbsoluteValueForYaw=i.useAbsoluteValueForYaw)}e.getParent()||this.upAxisSpace!=2||(this.upAxisSpace=0)}return Object.defineProperty(r.prototype,"minYaw",{get:function(){return this._minYaw},set:function(t){this._minYaw=t,this._minYawSin=Math.sin(t),this._minYawCos=Math.cos(t),this._maxYaw!=null&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(t){this._maxYaw=t,this._maxYawSin=Math.sin(t),this._maxYawCos=Math.cos(t),this._minYaw!=null&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"minPitch",{get:function(){return this._minPitch},set:function(t){this._minPitch=t,this._minPitchTan=Math.tan(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(t){this._maxPitch=t,this._maxPitchTan=Math.tan(t)},enumerable:!1,configurable:!0}),r.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,e=r._TmpVecs[0];t.getAbsolutePositionToRef(this.mesh,e);var n=this.target,i=r._TmpMats[0],o=r._TmpMats[1],a=this.mesh,s=t.getParent(),l=r._TmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==2&&s?(this._transformYawPitch&&_.Pq.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),s.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==0&&(a.getDirectionToRef(l,l),a.scaling.x==1&&a.scaling.y==1&&a.scaling.z==1||l.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var d=r._TmpMats[2],h=r._TmpMats[3];if(this.upAxisSpace==2&&l.y==1&&s)s.getRotationMatrixToRef(1,this.mesh,d);else if(this.upAxisSpace!=0||l.y!=1||s){var p=r._TmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&_.Pq.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),s?s.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var m=_.Pq.Cross(l,p);m.normalize(),p=_.Pq.Cross(m,l),_.uq.FromXYZAxesToRef(m,l,p,d)}else d.copyFrom(a.getWorldMatrix());d.invertToRef(h);var v=null;if(u){var b=r._TmpVecs[3];n.subtractToRef(e,b),_.Pq.TransformCoordinatesToRef(b,h,b),v=Math.sqrt(b.x*b.x+b.z*b.z);var E=Math.atan2(b.y,v),C=E;E>this._maxPitch?(b.y=this._maxPitchTan*v,C=this._maxPitch):E<this._minPitch&&(b.y=this._minPitchTan*v,C=this._minPitch),E!=C&&(_.Pq.TransformCoordinatesToRef(b,d,b),b.addInPlace(e),n=b)}if(c){b=r._TmpVecs[4],n.subtractToRef(e,b),_.Pq.TransformCoordinatesToRef(b,h,b);var T=Math.atan2(b.x,b.z),f=this.useAbsoluteValueForYaw?Math.abs(T):T,g=T;if((f>this._maxYaw||f<this._minYaw)&&(v==null&&(v=Math.sqrt(b.x*b.x+b.z*b.z)),this._yawRange>Math.PI?this._isAngleBetween(T,this._maxYaw,this._midYawConstraint)?(b.z=this._maxYawCos*v,b.x=this._maxYawSin*v,g=this._maxYaw):this._isAngleBetween(T,this._midYawConstraint,this._minYaw)&&(b.z=this._minYawCos*v,b.x=this._minYawSin*v,g=this._minYaw):f>this._maxYaw?(b.z=this._maxYawCos*v,b.x=this._maxYawSin*v,T<0&&this.useAbsoluteValueForYaw&&(b.x*=-1),g=this._maxYaw):f<this._minYaw&&(b.z=this._minYawCos*v,b.x=this._minYawSin*v,T<0&&this.useAbsoluteValueForYaw&&(b.x*=-1),g=this._minYaw)),this._slerping&&this._yawRange>Math.PI){var S=r._TmpVecs[8];S.copyFrom(Qn._0.Z),this._transformYawPitch&&_.Pq.TransformCoordinatesToRef(S,this._transformYawPitchInv,S);var y=r._TmpMats[4];this._boneQuat.toRotationMatrix(y),this.mesh.getWorldMatrix().multiplyToRef(y,y),_.Pq.TransformCoordinatesToRef(S,y,S),_.Pq.TransformCoordinatesToRef(S,h,S);var x=Math.atan2(S.x,S.z);if(this._getAngleBetween(x,T)>this._getAngleBetween(x,this._midYawConstraint)){v==null&&(v=Math.sqrt(b.x*b.x+b.z*b.z));var R=this._getAngleBetween(x,this._maxYaw);this._getAngleBetween(x,this._minYaw)<R?(g=x+.75*Math.PI,b.z=Math.cos(g)*v,b.x=Math.sin(g)*v):(g=x-.75*Math.PI,b.z=Math.cos(g)*v,b.x=Math.sin(g)*v)}}T!=g&&(_.Pq.TransformCoordinatesToRef(b,d,b),b.addInPlace(e),n=b)}}var I=r._TmpVecs[5],M=r._TmpVecs[6],D=r._TmpVecs[7],B=r._TmpQuat,F=r._TmpVecs[9];n.subtractToRef(e,I),I.normalize(),_.Pq.CrossToRef(l,I,M),M.normalize(),_.Pq.CrossToRef(I,M,D),D.normalize(),_.uq.FromXYZAxesToRef(M,D,I,i),M.x===0&&M.y===0&&M.z===0||D.x===0&&D.y===0&&D.z===0||I.x===0&&I.y===0&&I.z===0||((this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(_.uq.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,o),o.multiplyToRef(i,i)),F.copyFrom(this.bone.getScale()),this.slerpAmount<1?(this._slerping||this.bone.getRotationQuaternionToRef(1,this.mesh,this._boneQuat),this._transformYawPitch&&this._transformYawPitch.multiplyToRef(i,i),_.PT.FromRotationMatrixToRef(i,B),_.PT.SlerpToRef(this._boneQuat,B,this.slerpAmount,this._boneQuat),this.bone.setRotationQuaternion(this._boneQuat,1,this.mesh),this._slerping=!0):(this._transformYawPitch&&this._transformYawPitch.multiplyToRef(i,i),this.bone.setRotationMatrix(i,1,this.mesh),this._slerping=!1),this.bone.setScale(F),this._updateLinkedTransformRotation())}},r.prototype._getAngleDiff=function(t,e){var n=e-t;return(n%=2*Math.PI)>Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI),n},r.prototype._getAngleBetween=function(t,e){var n=0;return(n=(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)?e-t:t-e)>Math.PI&&(n=2*Math.PI-n),n},r.prototype._isAngleBetween=function(t,e,n){if(t=(t%=2*Math.PI)<0?t+2*Math.PI:t,(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(n=(n%=2*Math.PI)<0?n+2*Math.PI:n)){if(t>e&&t<n)return!0}else if(t>n&&t<e)return!0;return!1},r.prototype._updateLinkedTransformRotation=function(){var t=this.bone;t._linkedTransformNode&&(t._linkedTransformNode.rotationQuaternion||(t._linkedTransformNode.rotationQuaternion=new _.PT),t.getRotationQuaternionToRef(0,null,t._linkedTransformNode.rotationQuaternion))},r._TmpVecs=(0,st.mI)(10,_.Pq.Zero),r._TmpQuat=_.PT.Identity(),r._TmpMats=(0,st.mI)(5,_.uq.Identity),r}(),$o=L(37943),um=L(1554),Ms=(cm=new Uint8Array(4),!!((new Uint32Array(cm.buffer)[0]=1)&cm[0]));Object.defineProperty(Y.R.prototype,"effectiveByteStride",{get:function(){return this._alignedBuffer&&this._alignedBuffer.byteStride||this.byteStride},enumerable:!0,configurable:!0}),Object.defineProperty(Y.R.prototype,"effectiveByteOffset",{get:function(){return this._alignedBuffer?0:this.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(Y.R.prototype,"effectiveBuffer",{get:function(){return this._alignedBuffer&&this._alignedBuffer.getBuffer()||this._buffer.getBuffer()},enumerable:!0,configurable:!0}),Y.R.prototype._rebuild=function(){var r,t;(r=this._buffer)===null||r===void 0||r._rebuild(),(t=this._alignedBuffer)===null||t===void 0||t._rebuild()},Y.R.prototype.dispose=function(){var r;this._ownsBuffer&&this._buffer.dispose(),(r=this._alignedBuffer)===null||r===void 0||r.dispose(),this._alignedBuffer=void 0,this._isDisposed=!0},Y.R.prototype.getWrapperBuffer=function(){return this._alignedBuffer||this._buffer},Y.R.prototype._alignBuffer=function(){var r,t,e=this._buffer.getData();if(this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes&&(this.byteStride%4!=0||this.byteOffset%4!=0)&&e){var n,i,o=Y.R.GetTypeByteLength(this.type),a=this.byteStride+3&-4,s=a/o,l=this._maxVerticesCount,c=l*a/o;if(Array.isArray(e)){var u=new Float32Array(e);n=new DataView(u.buffer,u.byteOffset,u.byteLength)}else n=e instanceof ArrayBuffer?new DataView(e,0,e.byteLength):new DataView(e.buffer,e.byteOffset,e.byteLength);i=this.type===Y.R.BYTE?new Int8Array(c):this.type===Y.R.UNSIGNED_BYTE?new Uint8Array(c):this.type===Y.R.SHORT?new Int16Array(c):this.type===Y.R.UNSIGNED_SHORT?new Uint16Array(c):this.type===Y.R.INT?new Int32Array(c):this.type===Y.R.UNSIGNED_INT?new Uint32Array(c):new Float32Array(c);for(var d=this.getSize(),h=this.byteOffset,p=0;p<l;++p){for(var m=0;m<d;++m)switch(this.type){case Y.R.BYTE:i[p*s+m]=n.getInt8(h+m);break;case Y.R.UNSIGNED_BYTE:i[p*s+m]=n.getUint8(h+m);break;case Y.R.SHORT:i[p*s+m]=n.getInt16(h+2*m,Ms);break;case Y.R.UNSIGNED_SHORT:i[p*s+m]=n.getUint16(h+2*m,Ms);break;case Y.R.INT:i[p*s+m]=n.getInt32(h+4*m,Ms);break;case Y.R.UNSIGNED_INT:i[p*s+m]=n.getUint32(h+4*m,Ms);break;case Y.R.FLOAT:i[p*s+m]=n.getFloat32(h+4*m,Ms)}h+=this.byteStride}(r=this._alignedBuffer)===null||r===void 0||r.dispose(),this._alignedBuffer=new Y.h(this.engine,i,!1,a,!1,this.getIsInstanced(),!0,this.instanceDivisor,((t=this._label)!==null&&t!==void 0?t:"VertexBuffer")+"_aligned")}};var Aa=L(50712),dm=function(){function r(){this.wheelPrecisionX=3,this.wheelPrecisionY=3,this.wheelPrecisionZ=3,this.onChangedObservable=new K.cP,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n){if(n.type===vt.Zp.POINTERWHEEL){var i=n.event,o=i.deltaMode===Aa.s.DOM_DELTA_LINE?e._ffMultiplier:1;e._wheelDeltaX+=e.wheelPrecisionX*o*i.deltaX/e._normalize,e._wheelDeltaY-=e.wheelPrecisionY*o*i.deltaY/e._normalize,e._wheelDeltaZ+=e.wheelPrecisionZ*o*i.deltaZ/e._normalize,i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,vt.Zp.POINTERWHEEL)},r.prototype.detachControl=function(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null),this.onChangedObservable&&this.onChangedObservable.clear()},r.prototype.checkInputs=function(){this.onChangedObservable.notifyObservers({wheelDeltaX:this._wheelDeltaX,wheelDeltaY:this._wheelDeltaY,wheelDeltaZ:this._wheelDeltaZ}),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0},r.prototype.getClassName=function(){return"BaseCameraMouseWheelInput"},r.prototype.getSimpleName=function(){return"mousewheel"},(0,A.Cg)([(0,V.lK)()],r.prototype,"wheelPrecisionX",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"wheelPrecisionY",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"wheelPrecisionZ",void 0),r}(),Nc=function(){function r(){this._currentActiveButton=-1,this.buttons=[0,1,2]}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments);var n=this.camera.getEngine(),i=n.getInputElement(),o=0,a=null;this._pointA=null,this._pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=function(l){var c,u,d=l.event,h=d.pointerType==="touch";if(l.type===vt.Zp.POINTERMOVE||e.buttons.indexOf(d.button)!==-1){var p=d.target;if(e._altKey=d.altKey,e._ctrlKey=d.ctrlKey,e._metaKey=d.metaKey,e._shiftKey=d.shiftKey,e._buttonsPressed=d.buttons,n.isPointerLock){var m=d.movementX,v=d.movementY;e.onTouch(null,m,v),e._pointA=null,e._pointB=null}else{if(l.type!==vt.Zp.POINTERDOWN&&l.type!==vt.Zp.POINTERDOUBLETAP&&h&&((c=e._pointA)===null||c===void 0?void 0:c.pointerId)!==d.pointerId&&((u=e._pointB)===null||u===void 0?void 0:u.pointerId)!==d.pointerId)return;if(l.type!==vt.Zp.POINTERDOWN||e._currentActiveButton!==-1&&!h)if(l.type===vt.Zp.POINTERDOUBLETAP)e.onDoubleTap(d.pointerType);else if(l.type!==vt.Zp.POINTERUP||e._currentActiveButton!==d.button&&!h){if(l.type===vt.Zp.POINTERMOVE){if(t||d.preventDefault(),e._pointA&&e._pointB===null)m=d.clientX-e._pointA.x,v=d.clientY-e._pointA.y,e._pointA.x=d.clientX,e._pointA.y=d.clientY,e.onTouch(e._pointA,m,v);else if(e._pointA&&e._pointB){var b=e._pointA.pointerId===d.pointerId?e._pointA:e._pointB;b.x=d.clientX,b.y=d.clientY;var E=e._pointA.x-e._pointB.x,C=e._pointA.y-e._pointB.y,T=E*E+C*C,f={x:(e._pointA.x+e._pointB.x)/2,y:(e._pointA.y+e._pointB.y)/2,pointerId:d.pointerId,type:l.type};e.onMultiTouch(e._pointA,e._pointB,o,T,a,f),a=f,o=T}}}else{try{p?.releasePointerCapture(d.pointerId)}catch{}h||(e._pointB=null),n._badOS?e._pointA=e._pointB=null:e._pointB&&e._pointA&&e._pointA.pointerId==d.pointerId?(e._pointA=e._pointB,e._pointB=null):e._pointA&&e._pointB&&e._pointB.pointerId==d.pointerId?e._pointB=null:e._pointA=e._pointB=null,(o!==0||a)&&(e.onMultiTouch(e._pointA,e._pointB,o,0,a,null),o=0,a=null),e._currentActiveButton=-1,e.onButtonUp(d),t||d.preventDefault()}else{try{p?.setPointerCapture(d.pointerId)}catch{}if(e._pointA===null)e._pointA={x:d.clientX,y:d.clientY,pointerId:d.pointerId,type:d.pointerType};else{if(e._pointB!==null)return;e._pointB={x:d.clientX,y:d.clientY,pointerId:d.pointerId,type:d.pointerType}}e._currentActiveButton!==-1||h||(e._currentActiveButton=d.button),e.onButtonDown(d),t||(d.preventDefault(),i&&i.focus())}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,vt.Zp.POINTERDOWN|vt.Zp.POINTERUP|vt.Zp.POINTERMOVE|vt.Zp.POINTERDOUBLETAP),this._onLostFocus=function(){e._pointA=e._pointB=null,o=0,a=null,e.onLostFocus()},this._contextMenuBind=function(l){return e.onContextMenu(l)},i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);var s=this.camera.getScene().getEngine().getHostWindow();s&&ze.S0.RegisterTopRootEvents(s,[{name:"blur",handler:this._onLostFocus}])},r.prototype.detachControl=function(){if(this._onLostFocus){var t=this.camera.getScene().getEngine().getHostWindow();t&&ze.S0.UnregisterTopRootEvents(t,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){var e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentActiveButton=-1},r.prototype.getClassName=function(){return"BaseCameraPointersInput"},r.prototype.getSimpleName=function(){return"pointers"},r.prototype.onDoubleTap=function(t){},r.prototype.onTouch=function(t,e,n){},r.prototype.onMultiTouch=function(t,e,n,i,o,a){},r.prototype.onContextMenu=function(t){t.preventDefault()},r.prototype.onButtonDown=function(t){},r.prototype.onButtonUp=function(t){},r.prototype.onLostFocus=function(){},(0,A.Cg)([(0,V.lK)()],r.prototype,"buttons",void 0),r}(),oi={},Ca=function(){function r(t){this.attachedToElement=!1,this.attached={},this.camera=t,this.checkInputs=function(){}}return r.prototype.add=function(t){var e=t.getSimpleName();this.attached[e]?O.V.Warn("camera input of type "+e+" already exists on camera"):(this.attached[e]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedToElement&&t.attachControl(this.noPreventDefault))},r.prototype.remove=function(t){for(var e in this.attached){var n=this.attached[e];if(n===t)return n.detachControl(),n.camera=null,delete this.attached[e],void this.rebuildInputCheck()}},r.prototype.removeByType=function(t){for(var e in this.attached){var n=this.attached[e];n.getClassName()===t&&(n.detachControl(),n.camera=null,delete this.attached[e],this.rebuildInputCheck())}},r.prototype._addCheckInputs=function(t){var e=this.checkInputs;return function(){e(),t()}},r.prototype.attachInput=function(t){this.attachedToElement&&t.attachControl(this.noPreventDefault)},r.prototype.attachElement=function(t){if(t===void 0&&(t=!1),!this.attachedToElement)for(var e in t=!Pt.ForceAttachControlToAlwaysPreventDefault&&t,this.attachedToElement=!0,this.noPreventDefault=t,this.attached)this.attached[e].attachControl(t)},r.prototype.detachElement=function(t){for(var e in t===void 0&&(t=!1),this.attached)this.attached[e].detachControl(),t&&(this.attached[e].camera=null);this.attachedToElement=!1},r.prototype.rebuildInputCheck=function(){for(var t in this.checkInputs=function(){},this.attached){var e=this.attached[t];e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e)))}},r.prototype.clear=function(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=function(){}},r.prototype.serialize=function(t){var e={};for(var n in this.attached){var i=this.attached[n],o=tt.p.Serialize(i);e[i.getClassName()]=o}t.inputsmgr=e},r.prototype.parse=function(t){var e=t.inputsmgr;if(e){this.clear();var n=function(l){var c=oi[l];if(c){var u=e[l],d=tt.p.Parse(function(){return new c},u,null);i.add(d)}},i=this;for(var o in e)n(o)}else{var a=function(l){var c=oi[s.attached[l].getClassName()];if(c){var u=tt.p.Parse(function(){return new c},t,null);s.remove(s.attached[l]),s.add(u)}},s=this;for(var o in this.attached)a(o)}},r}(),$S=function(r,t){this.x=r,this.y=t},Ii=function(){function r(t,e,n,i,o,a,s){i===void 0&&(i=0),o===void 0&&(o=1),a===void 0&&(a=2),s===void 0&&(s=3),this.id=t,this.index=e,this.browserGamepad=n,this._leftStick={x:0,y:0},this._rightStick={x:0,y:0},this._isConnected=!0,this._invertLeftStickY=!1,this.type=r.GAMEPAD,this._leftStickAxisX=i,this._leftStickAxisY=o,this._rightStickAxisX=a,this._rightStickAxisY=s,this.browserGamepad.axes.length>=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(r.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!1,configurable:!0}),r.prototype.onleftstickchanged=function(t){this._onleftstickchanged=t},r.prototype.onrightstickchanged=function(t){this._onrightstickchanged=t},Object.defineProperty(r.prototype,"leftStick",{get:function(){return this._leftStick},set:function(t){!this._onleftstickchanged||this._leftStick.x===t.x&&this._leftStick.y===t.y||this._onleftstickchanged(t),this._leftStick=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightStick",{get:function(){return this._rightStick},set:function(t){!this._onrightstickchanged||this._rightStick.x===t.x&&this._rightStick.y===t.y||this._onrightstickchanged(t),this._rightStick=t},enumerable:!1,configurable:!0}),r.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},r.prototype.dispose=function(){},r.GAMEPAD=0,r.GENERIC=1,r.XBOX=2,r.POSE_ENABLED=3,r.DUALSHOCK=4,r}(),hm=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.onButtonDownObservable=new K.cP,o.onButtonUpObservable=new K.cP,o.type=Ii.GENERIC,o._buttons=new Array(i.buttons.length),o}return(0,A.C6)(t,r),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,n,i){return e!==n&&(e===1&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),e===0&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype.update=function(){r.prototype.update.call(this);for(var e=0;e<this._buttons.length;e++)this._buttons[e]=this._setButtonValue(this.browserGamepad.buttons[e].value,this._buttons[e],e)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear()},t}(Ii),Lc=function(){function r(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40,this._yAxisScale=1}return Object.defineProperty(r.prototype,"invertYAxis",{get:function(){return this._yAxisScale!==1},set:function(t){this._yAxisScale=t?-1:1},enumerable:!1,configurable:!0}),r.prototype.attachControl=function(){var t=this,e=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=e.onGamepadConnectedObservable.add(function(n){n.type!==Ii.POSE_ENABLED&&(t.gamepad&&n.type!==Ii.XBOX||(t.gamepad=n))}),this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add(function(n){t.gamepad===n&&(t.gamepad=null)}),this.gamepad=e.getGamepadByType(Ii.XBOX),!this.gamepad&&e.gamepads.length&&(this.gamepad=e.gamepads[0])},r.prototype.detachControl=function(){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},r.prototype.checkInputs=function(){if(this.gamepad){var t=this.camera,e=this.gamepad.rightStick;if(e){if(e.x!=0){var n=e.x/this.gamepadRotationSensibility;n!=0&&Math.abs(n)>.005&&(t.inertialAlphaOffset+=n)}if(e.y!=0){var i=e.y/this.gamepadRotationSensibility*this._yAxisScale;i!=0&&Math.abs(i)>.005&&(t.inertialBetaOffset+=i)}}var o=this.gamepad.leftStick;if(o&&o.y!=0){var a=o.y/this.gamepadMoveSensibility;a!=0&&Math.abs(a)>.005&&(this.camera.inertialRadiusOffset-=a)}}},r.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},r.prototype.getSimpleName=function(){return"gamepad"},(0,A.Cg)([(0,V.lK)()],r.prototype,"gamepadRotationSensibility",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"gamepadMoveSensibility",void 0),r}();oi.ArcRotateCameraGamepadInput=Lc;var io=L(6451),Fc=function(){function r(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;o.metaKey||(n.type===io.TB.KEYDOWN?(e._ctrlPressed=o.ctrlKey,e._altPressed=o.altKey,(e.keysUp.indexOf(o.keyCode)!==-1||e.keysDown.indexOf(o.keyCode)!==-1||e.keysLeft.indexOf(o.keyCode)!==-1||e.keysRight.indexOf(o.keyCode)!==-1||e.keysReset.indexOf(o.keyCode)!==-1)&&((i=e._keys.indexOf(o.keyCode))===-1&&e._keys.push(o.keyCode),o.preventDefault&&(t||o.preventDefault()))):e.keysUp.indexOf(o.keyCode)===-1&&e.keysDown.indexOf(o.keyCode)===-1&&e.keysLeft.indexOf(o.keyCode)===-1&&e.keysRight.indexOf(o.keyCode)===-1&&e.keysReset.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))>=0&&e._keys.splice(i,1),o.preventDefault&&(t||o.preventDefault())))}))},r.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},r.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,e=0;e<this._keys.length;e++){var n=this._keys[e];this.keysLeft.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningX-=1/this.panningSensibility:t.inertialAlphaOffset-=this.angularSpeed:this.keysUp.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?t.inertialRadiusOffset+=1/this.zoomingSensibility:t.inertialBetaOffset-=this.angularSpeed:this.keysRight.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningX+=1/this.panningSensibility:t.inertialAlphaOffset+=this.angularSpeed:this.keysDown.indexOf(n)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?t.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?t.inertialRadiusOffset-=1/this.zoomingSensibility:t.inertialBetaOffset+=this.angularSpeed:this.keysReset.indexOf(n)!==-1&&t.useInputToRestoreState&&t.restoreState()}},r.prototype.getClassName=function(){return"ArcRotateCameraKeyboardMoveInput"},r.prototype.getSimpleName=function(){return"keyboard"},(0,A.Cg)([(0,V.lK)()],r.prototype,"keysUp",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysDown",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysLeft",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRight",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysReset",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"panningSensibility",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"zoomingSensibility",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"useAltToZoom",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"angularSpeed",void 0),r}();oi.ArcRotateCameraKeyboardMoveInput=Fc;var wc=function(){function r(){this.wheelPrecision=3,this.zoomToMouseLocation=!1,this.wheelDeltaPercentage=0,this.customComputeDeltaFromMouseWheel=null,this._viewOffset=new _.Pq(0,0,0),this._globalOffset=new _.Pq(0,0,0),this._inertialPanning=_.Pq.Zero()}return r.prototype._computeDeltaFromMouseWheelLegacyEvent=function(t,e){var n=.01*t*this.wheelDeltaPercentage*e;return t>0?n/(1+this.wheelDeltaPercentage):n*(1+this.wheelDeltaPercentage)},r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n){if(n.type===vt.Zp.POINTERWHEEL){var i=n.event,o=0,a=i.deltaMode===Aa.s.DOM_DELTA_LINE?40:1,s=-i.deltaY*a;if(e.customComputeDeltaFromMouseWheel)o=e.customComputeDeltaFromMouseWheel(s,e,i);else if(e.wheelDeltaPercentage){if((o=e._computeDeltaFromMouseWheelLegacyEvent(s,e.camera.radius))>0){for(var l=e.camera.radius,c=e.camera.inertialRadiusOffset+o,u=0;u<20&&Math.abs(c)>.001;u++)l-=c,c*=e.camera.inertia;l=(0,qe.Clamp)(l,0,Number.MAX_VALUE),o=e._computeDeltaFromMouseWheelLegacyEvent(s,l)}}else o=s/(40*e.wheelPrecision);o&&(e.zoomToMouseLocation?(e._hitPlane||e._updateHitPlane(),e._zoomToMouse(o)):e.camera.inertialRadiusOffset+=o),i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,vt.Zp.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)},r.prototype.detachControl=function(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)},r.prototype.checkInputs=function(){if(this.zoomToMouseLocation){var t=this.camera;0+t.inertialAlphaOffset+t.inertialBetaOffset+t.inertialRadiusOffset&&(this._updateHitPlane(),t.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(t.inertia),this._zeroIfClose(this._inertialPanning))}},r.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},r.prototype.getSimpleName=function(){return"mousewheel"},r.prototype._updateHitPlane=function(){var t=this.camera,e=t.target.subtract(t.position);this._hitPlane=Qo.Z.FromPositionAndNormal(t.target,e)},r.prototype._getPosition=function(){var t,e=this.camera,n=e.getScene(),i=n.createPickingRay(n.pointerX,n.pointerY,_.uq.Identity(),e,!1);e.targetScreenOffset.x===0&&e.targetScreenOffset.y===0||(this._viewOffset.set(e.targetScreenOffset.x,e.targetScreenOffset.y,0),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),this._globalOffset=_.Pq.TransformNormal(this._viewOffset,e._cameraTransformMatrix),i.origin.addInPlace(this._globalOffset));var o=0;return this._hitPlane&&(o=(t=i.intersectsPlane(this._hitPlane))!==null&&t!==void 0?t:0),i.origin.addInPlace(i.direction.scaleInPlace(o))},r.prototype._zoomToMouse=function(t){var e,n,i=this.camera,o=1-i.inertia;if(i.lowerRadiusLimit){var a=(e=i.lowerRadiusLimit)!==null&&e!==void 0?e:0;i.radius-(i.inertialRadiusOffset+t)/o<a&&(t=(i.radius-a)*o-i.inertialRadiusOffset)}if(i.upperRadiusLimit){var s=(n=i.upperRadiusLimit)!==null&&n!==void 0?n:0;i.radius-(i.inertialRadiusOffset+t)/o>s&&(t=(i.radius-s)*o-i.inertialRadiusOffset)}var l=t/o/i.radius,c=this._getPosition(),u=_.AA.Vector3[6];c.subtractToRef(i.target,u),u.scaleInPlace(l),u.scaleInPlace(o),this._inertialPanning.addInPlace(u),i.inertialRadiusOffset+=t},r.prototype._zeroIfClose=function(t){Math.abs(t.x)<pt.bH&&(t.x=0),Math.abs(t.y)<pt.bH&&(t.y=0),Math.abs(t.z)<pt.bH&&(t.z=0)},(0,A.Cg)([(0,V.lK)()],r.prototype,"wheelPrecision",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"zoomToMouseLocation",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"wheelDeltaPercentage",void 0),r}();oi.ArcRotateCameraMouseWheelInput=wc;var Bc=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.buttons=[0,1,2],e.angularSensibilityX=1e3,e.angularSensibilityY=1e3,e.pinchPrecision=12,e.pinchDeltaPercentage=0,e.useNaturalPinchZoom=!1,e.pinchZoom=!0,e.panningSensibility=1e3,e.multiTouchPanning=!0,e.multiTouchPanAndZoom=!0,e.pinchInwards=!0,e._isPanClick=!1,e._twoFingerActivityCount=0,e._isPinching=!1,e}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype._computeMultiTouchPanning=function(e,n){if(this.panningSensibility!==0&&e&&n){var i=n.x-e.x,o=n.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=o/this.panningSensibility}},t.prototype._computePinchZoom=function(e,n){var i=this.camera.radius||t.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=i*Math.sqrt(e)/Math.sqrt(n):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(n-e)*i*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(n-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)},t.prototype.onTouch=function(e,n,i){this.panningSensibility!==0&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-n/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=n/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},t.prototype.onDoubleTap=function(){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,n,i,o,a,s){i===0&&a===null||o===0&&s===null||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,o),this._computeMultiTouchPanning(a,s)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(o)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance?(this._computePinchZoom(i,o),this._isPinching=!0):this._computeMultiTouchPanning(a,s)):this.multiTouchPanning?this._computeMultiTouchPanning(a,s):this.pinchZoom&&this._computePinchZoom(i,o))},t.prototype.onButtonDown=function(e){this._isPanClick=e.button===this.camera._panningMouseButton},t.prototype.onButtonUp=function(e){this._twoFingerActivityCount=0,this._isPinching=!1},t.prototype.onLostFocus=function(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1},t.MinimumRadiusForPinch=.001,(0,A.Cg)([(0,V.lK)()],t.prototype,"buttons",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"angularSensibilityX",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"angularSensibilityY",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"pinchPrecision",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"pinchDeltaPercentage",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"useNaturalPinchZoom",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"pinchZoom",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"panningSensibility",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"multiTouchPanning",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"multiTouchPanAndZoom",void 0),t}(Nc);oi.ArcRotateCameraPointersInput=Bc;var Os=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t.prototype.addMouseWheel=function(){return this.add(new wc),this},t.prototype.addPointers=function(){return this.add(new Bc),this},t.prototype.addKeyboard=function(){return this.add(new Fc),this},t}(Ca);Os.prototype.addVRDeviceOrientation=function(){return this.add(new Vc),this};var Vc=function(){function r(){var t=this;this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=function(e){return t._onOrientationEvent(e)}}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this.camera.attachControl(t);var n=this.camera.getScene().getEngine().getHostWindow();n&&(typeof DeviceOrientationEvent<"u"&&typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(function(i){i==="granted"?n.addEventListener("deviceorientation",e._deviceOrientationHandler):ze.S0.Warn("Permission not granted.")}).catch(function(i){ze.S0.Error(i)}):n.addEventListener("deviceorientation",this._deviceOrientationHandler))},r.prototype._onOrientationEvent=function(t){t.alpha!==null&&(this._alpha=(0|+t.alpha)*this.alphaCorrection),t.gamma!==null&&(this._gamma=(0|+t.gamma)*this.gammaCorrection),this._dirty=!0},r.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},r.prototype.detachControl=function(){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},r.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},r.prototype.getSimpleName=function(){return"VRDeviceOrientation"},r}();oi.ArcRotateCameraVRDeviceOrientationInput=Vc;var Uc=function(){function r(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;n.type===io.TB.KEYDOWN?e.keysForward.indexOf(o.keyCode)===-1&&e.keysBackward.indexOf(o.keyCode)===-1&&e.keysUp.indexOf(o.keyCode)===-1&&e.keysDown.indexOf(o.keyCode)===-1&&e.keysLeft.indexOf(o.keyCode)===-1&&e.keysRight.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))===-1&&e._keys.push(o.keyCode),t||o.preventDefault()):e.keysForward.indexOf(o.keyCode)===-1&&e.keysBackward.indexOf(o.keyCode)===-1&&e.keysUp.indexOf(o.keyCode)===-1&&e.keysDown.indexOf(o.keyCode)===-1&&e.keysLeft.indexOf(o.keyCode)===-1&&e.keysRight.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))>=0&&e._keys.splice(i,1),t||o.preventDefault())}))},r.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},r.prototype.getClassName=function(){return"FlyCameraKeyboardInput"},r.prototype._onLostFocus=function(){this._keys.length=0},r.prototype.getSimpleName=function(){return"keyboard"},r.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,e=0;e<this._keys.length;e++){var n=this._keys[e],i=t._computeLocalCameraSpeed();this.keysForward.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,i):this.keysBackward.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,-i):this.keysUp.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,i,0):this.keysDown.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,-i,0):this.keysRight.indexOf(n)!==-1?t._localDirection.copyFromFloats(i,0,0):this.keysLeft.indexOf(n)!==-1&&t._localDirection.copyFromFloats(-i,0,0),t.getScene().useRightHandedSystem&&(t._localDirection.z*=-1),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),_.Pq.TransformNormalToRef(t._localDirection,t._cameraTransformMatrix,t._transformedDirection),t.cameraDirection.addInPlace(t._transformedDirection)}},(0,A.Cg)([(0,V.lK)()],r.prototype,"keysForward",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysBackward",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysUp",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysDown",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRight",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysLeft",void 0),r}();oi.FlyCameraKeyboardInput=Uc;var Gc=function(){function r(){this.buttons=[0,1,2],this.buttonsYaw=[-1,0,1],this.buttonsPitch=[-1,0,1],this.buttonsRoll=[2],this.activeButton=-1,this.angularSensibility=1e3,this._previousPosition=null}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._noPreventDefault=t,this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(function(n){e._pointerInput(n)},vt.Zp.POINTERDOWN|vt.Zp.POINTERUP|vt.Zp.POINTERMOVE),this._rollObserver=this.camera.getScene().onBeforeRenderObservable.add(function(){e.camera.rollCorrect&&e.camera.restoreRoll(e.camera.rollCorrect)})},r.prototype.detachControl=function(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver),this._observer=null,this._rollObserver=null,this._previousPosition=null,this._noPreventDefault=void 0)},r.prototype.getClassName=function(){return"FlyCameraMouseInput"},r.prototype.getSimpleName=function(){return"mouse"},r.prototype._pointerInput=function(t){var e=t.event,n=this.camera.getEngine();if((this.touchEnabled||e.pointerType!=="touch")&&(t.type===vt.Zp.POINTERMOVE||this.buttons.indexOf(e.button)!==-1)){var i=e.target;if(t.type===vt.Zp.POINTERDOWN){try{i?.setPointerCapture(e.pointerId)}catch{}this._previousPosition={x:e.clientX,y:e.clientY},this.activeButton=e.button,this._noPreventDefault||e.preventDefault(),n.isPointerLock&&this._onMouseMove(t.event)}else if(t.type===vt.Zp.POINTERUP){try{i?.releasePointerCapture(e.pointerId)}catch{}this.activeButton=-1,this._previousPosition=null,this._noPreventDefault||e.preventDefault()}else if(t.type===vt.Zp.POINTERMOVE){if(!this._previousPosition)return void(n.isPointerLock&&this._onMouseMove(t.event));var o=e.clientX-this._previousPosition.x,a=e.clientY-this._previousPosition.y;this._rotateCamera(o,a),this._previousPosition={x:e.clientX,y:e.clientY},this._noPreventDefault||e.preventDefault()}}},r.prototype._onMouseMove=function(t){if(this.camera.getEngine().isPointerLock){var e=t.movementX,n=t.movementY;this._rotateCamera(e,n),this._previousPosition=null,this._noPreventDefault||t.preventDefault()}},r.prototype._rotateCamera=function(t,e){var n,i=this,o=this.camera,a=(t*=o._calculateHandednessMultiplier())/this.angularSensibility,s=e/this.angularSensibility,l=_.PT.RotationYawPitchRoll(o.rotation.y,o.rotation.x,o.rotation.z);if(this.buttonsPitch.some(function(d){return d===i.activeButton})&&(n=_.PT.RotationAxis(Qn._0.X,s),l.multiplyInPlace(n)),this.buttonsYaw.some(function(d){return d===i.activeButton})){n=_.PT.RotationAxis(Qn._0.Y,a),l.multiplyInPlace(n);var c=o.bankedTurnLimit+o._trackRoll;if(o.bankedTurn&&-c<o.rotation.z&&o.rotation.z<c){var u=o.bankedTurnMultiplier*-a;n=_.PT.RotationAxis(Qn._0.Z,u),l.multiplyInPlace(n)}}this.buttonsRoll.some(function(d){return d===i.activeButton})&&(n=_.PT.RotationAxis(Qn._0.Z,-a),o._trackRoll-=a,l.multiplyInPlace(n)),l.toEulerAnglesToRef(o.rotation)},(0,A.Cg)([(0,V.lK)()],r.prototype,"buttons",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"angularSensibility",void 0),r}();oi.FlyCameraMouseInput=Gc;var kc=function(){function r(){this.keysHeightOffsetIncr=[38],this.keysHeightOffsetDecr=[40],this.keysHeightOffsetModifierAlt=!1,this.keysHeightOffsetModifierCtrl=!1,this.keysHeightOffsetModifierShift=!1,this.keysRotationOffsetIncr=[37],this.keysRotationOffsetDecr=[39],this.keysRotationOffsetModifierAlt=!1,this.keysRotationOffsetModifierCtrl=!1,this.keysRotationOffsetModifierShift=!1,this.keysRadiusIncr=[40],this.keysRadiusDecr=[38],this.keysRadiusModifierAlt=!0,this.keysRadiusModifierCtrl=!1,this.keysRadiusModifierShift=!1,this.heightSensibility=1,this.rotationSensibility=1,this.radiusSensibility=1,this._keys=new Array}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;o.metaKey||(n.type===io.TB.KEYDOWN?(e._ctrlPressed=o.ctrlKey,e._altPressed=o.altKey,e._shiftPressed=o.shiftKey,(e.keysHeightOffsetIncr.indexOf(o.keyCode)!==-1||e.keysHeightOffsetDecr.indexOf(o.keyCode)!==-1||e.keysRotationOffsetIncr.indexOf(o.keyCode)!==-1||e.keysRotationOffsetDecr.indexOf(o.keyCode)!==-1||e.keysRadiusIncr.indexOf(o.keyCode)!==-1||e.keysRadiusDecr.indexOf(o.keyCode)!==-1)&&((i=e._keys.indexOf(o.keyCode))===-1&&e._keys.push(o.keyCode),o.preventDefault&&(t||o.preventDefault()))):e.keysHeightOffsetIncr.indexOf(o.keyCode)===-1&&e.keysHeightOffsetDecr.indexOf(o.keyCode)===-1&&e.keysRotationOffsetIncr.indexOf(o.keyCode)===-1&&e.keysRotationOffsetDecr.indexOf(o.keyCode)===-1&&e.keysRadiusIncr.indexOf(o.keyCode)===-1&&e.keysRadiusDecr.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))>=0&&e._keys.splice(i,1),o.preventDefault&&(t||o.preventDefault())))}))},r.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},r.prototype.checkInputs=function(){var t=this;this._onKeyboardObserver&&this._keys.forEach(function(e){t.keysHeightOffsetIncr.indexOf(e)!==-1&&t._modifierHeightOffset()?t.camera.heightOffset+=t.heightSensibility:t.keysHeightOffsetDecr.indexOf(e)!==-1&&t._modifierHeightOffset()?t.camera.heightOffset-=t.heightSensibility:t.keysRotationOffsetIncr.indexOf(e)!==-1&&t._modifierRotationOffset()?(t.camera.rotationOffset+=t.rotationSensibility,t.camera.rotationOffset%=360):t.keysRotationOffsetDecr.indexOf(e)!==-1&&t._modifierRotationOffset()?(t.camera.rotationOffset-=t.rotationSensibility,t.camera.rotationOffset%=360):t.keysRadiusIncr.indexOf(e)!==-1&&t._modifierRadius()?t.camera.radius+=t.radiusSensibility:t.keysRadiusDecr.indexOf(e)!==-1&&t._modifierRadius()&&(t.camera.radius-=t.radiusSensibility)})},r.prototype.getClassName=function(){return"FollowCameraKeyboardMoveInput"},r.prototype.getSimpleName=function(){return"keyboard"},r.prototype._modifierHeightOffset=function(){return this.keysHeightOffsetModifierAlt===this._altPressed&&this.keysHeightOffsetModifierCtrl===this._ctrlPressed&&this.keysHeightOffsetModifierShift===this._shiftPressed},r.prototype._modifierRotationOffset=function(){return this.keysRotationOffsetModifierAlt===this._altPressed&&this.keysRotationOffsetModifierCtrl===this._ctrlPressed&&this.keysRotationOffsetModifierShift===this._shiftPressed},r.prototype._modifierRadius=function(){return this.keysRadiusModifierAlt===this._altPressed&&this.keysRadiusModifierCtrl===this._ctrlPressed&&this.keysRadiusModifierShift===this._shiftPressed},(0,A.Cg)([(0,V.lK)()],r.prototype,"keysHeightOffsetIncr",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysHeightOffsetDecr",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysHeightOffsetModifierAlt",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysHeightOffsetModifierCtrl",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysHeightOffsetModifierShift",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotationOffsetIncr",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotationOffsetDecr",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotationOffsetModifierAlt",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotationOffsetModifierCtrl",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotationOffsetModifierShift",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRadiusIncr",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRadiusDecr",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRadiusModifierAlt",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRadiusModifierCtrl",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRadiusModifierShift",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"heightSensibility",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"rotationSensibility",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"radiusSensibility",void 0),r}();oi.FollowCameraKeyboardMoveInput=kc;var zc=function(){function r(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n){if(n.type===vt.Zp.POINTERWHEEL){var i=n.event,o=0,a=Math.max(-1,Math.min(1,i.deltaY));e.wheelDeltaPercentage?(+e.axisControlRadius+ +e.axisControlHeight+ +e.axisControlRotation&&O.V.Warn("wheelDeltaPercentage only usable when mouse wheel controls ONE axis. Currently enabled: axisControlRadius: "+e.axisControlRadius+", axisControlHeightOffset: "+e.axisControlHeight+", axisControlRotationOffset: "+e.axisControlRotation),e.axisControlRadius?o=.01*a*e.wheelDeltaPercentage*e.camera.radius:e.axisControlHeight?o=.01*a*e.wheelDeltaPercentage*e.camera.heightOffset:e.axisControlRotation&&(o=.01*a*e.wheelDeltaPercentage*e.camera.rotationOffset)):o=a*e.wheelPrecision,o&&(e.axisControlRadius?e.camera.radius+=o:e.axisControlHeight?e.camera.heightOffset-=o:e.axisControlRotation&&(e.camera.rotationOffset-=o)),i.preventDefault&&(t||i.preventDefault())}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,vt.Zp.POINTERWHEEL)},r.prototype.detachControl=function(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)},r.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},r.prototype.getSimpleName=function(){return"mousewheel"},(0,A.Cg)([(0,V.lK)()],r.prototype,"axisControlRadius",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"axisControlHeight",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"axisControlRotation",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"wheelPrecision",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"wheelDeltaPercentage",void 0),r}();oi.FollowCameraMouseWheelInput=zc;var Wc=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.angularSensibilityX=1,e.angularSensibilityY=1,e.pinchPrecision=1e4,e.pinchDeltaPercentage=0,e.axisXControlRadius=!1,e.axisXControlHeight=!1,e.axisXControlRotation=!0,e.axisYControlRadius=!1,e.axisYControlHeight=!0,e.axisYControlRotation=!1,e.axisPinchControlRadius=!0,e.axisPinchControlHeight=!1,e.axisPinchControlRotation=!1,e.warningEnable=!0,e._warningCounter=0,e}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FollowCameraPointersInput"},t.prototype.onTouch=function(e,n,i){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=n/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=i/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=n/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=i/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=n/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=i/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,n,i,o,a,s){if(!(i===0&&a===null||o===0&&s===null)){var l=(o-i)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(l*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=l*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=l*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=l*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=l),this.axisPinchControlHeight&&(this.camera.heightOffset+=l),this.axisPinchControlRadius&&(this.camera.radius-=l))}},t.prototype._warning=function(){if(this.warningEnable&&this._warningCounter++%100==0){var e="It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: ";+this.axisXControlRotation+ +this.axisXControlHeight+ +this.axisXControlRadius<=1&&O.V.Warn(e+"axisXControlRotation: "+this.axisXControlRotation+", axisXControlHeight: "+this.axisXControlHeight+", axisXControlRadius: "+this.axisXControlRadius),+this.axisYControlRotation+ +this.axisYControlHeight+ +this.axisYControlRadius<=1&&O.V.Warn(e+"axisYControlRotation: "+this.axisYControlRotation+", axisYControlHeight: "+this.axisYControlHeight+", axisYControlRadius: "+this.axisYControlRadius),+this.axisPinchControlRotation+ +this.axisPinchControlHeight+ +this.axisPinchControlRadius<=1&&O.V.Warn(e+"axisPinchControlRotation: "+this.axisPinchControlRotation+", axisPinchControlHeight: "+this.axisPinchControlHeight+", axisPinchControlRadius: "+this.axisPinchControlRadius)}},(0,A.Cg)([(0,V.lK)()],t.prototype,"angularSensibilityX",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"angularSensibilityY",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"pinchPrecision",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"pinchDeltaPercentage",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisXControlRadius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisXControlHeight",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisXControlRotation",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisYControlRadius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisYControlHeight",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisYControlRotation",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisPinchControlRadius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisPinchControlHeight",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"axisPinchControlRotation",void 0),t}(Nc);oi.FollowCameraPointersInput=Wc;var Hc=function(){function r(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this.rotationSpeed=.5,this.keysRotateLeft=[],this.keysRotateRight=[],this.keysRotateUp=[],this.keysRotateDown=[],this._keys=new Array}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){e._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(n){var i,o=n.event;o.metaKey||(n.type===io.TB.KEYDOWN?e.keysUp.indexOf(o.keyCode)===-1&&e.keysDown.indexOf(o.keyCode)===-1&&e.keysLeft.indexOf(o.keyCode)===-1&&e.keysRight.indexOf(o.keyCode)===-1&&e.keysUpward.indexOf(o.keyCode)===-1&&e.keysDownward.indexOf(o.keyCode)===-1&&e.keysRotateLeft.indexOf(o.keyCode)===-1&&e.keysRotateRight.indexOf(o.keyCode)===-1&&e.keysRotateUp.indexOf(o.keyCode)===-1&&e.keysRotateDown.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))===-1&&e._keys.push(o.keyCode),t||o.preventDefault()):e.keysUp.indexOf(o.keyCode)===-1&&e.keysDown.indexOf(o.keyCode)===-1&&e.keysLeft.indexOf(o.keyCode)===-1&&e.keysRight.indexOf(o.keyCode)===-1&&e.keysUpward.indexOf(o.keyCode)===-1&&e.keysDownward.indexOf(o.keyCode)===-1&&e.keysRotateLeft.indexOf(o.keyCode)===-1&&e.keysRotateRight.indexOf(o.keyCode)===-1&&e.keysRotateUp.indexOf(o.keyCode)===-1&&e.keysRotateDown.indexOf(o.keyCode)===-1||((i=e._keys.indexOf(o.keyCode))>=0&&e._keys.splice(i,1),t||o.preventDefault()))}))},r.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},r.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,e=0;e<this._keys.length;e++){var n=this._keys[e],i=t._computeLocalCameraSpeed();this.keysLeft.indexOf(n)!==-1?t._localDirection.copyFromFloats(-i,0,0):this.keysUp.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,i):this.keysRight.indexOf(n)!==-1?t._localDirection.copyFromFloats(i,0,0):this.keysDown.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,0,-i):this.keysUpward.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,i,0):this.keysDownward.indexOf(n)!==-1?t._localDirection.copyFromFloats(0,-i,0):this.keysRotateLeft.indexOf(n)!==-1?(t._localDirection.copyFromFloats(0,0,0),t.cameraRotation.y-=this._getLocalRotation()):this.keysRotateRight.indexOf(n)!==-1?(t._localDirection.copyFromFloats(0,0,0),t.cameraRotation.y+=this._getLocalRotation()):this.keysRotateUp.indexOf(n)!==-1?(t._localDirection.copyFromFloats(0,0,0),t.cameraRotation.x-=this._getLocalRotation()):this.keysRotateDown.indexOf(n)!==-1&&(t._localDirection.copyFromFloats(0,0,0),t.cameraRotation.x+=this._getLocalRotation()),t.getScene().useRightHandedSystem&&(t._localDirection.z*=-1),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),_.Pq.TransformNormalToRef(t._localDirection,t._cameraTransformMatrix,t._transformedDirection),t.cameraDirection.addInPlace(t._transformedDirection)}},r.prototype.getClassName=function(){return"FreeCameraKeyboardMoveInput"},r.prototype._onLostFocus=function(){this._keys.length=0},r.prototype.getSimpleName=function(){return"keyboard"},r.prototype._getLocalRotation=function(){var t=this.camera._calculateHandednessMultiplier();return this.rotationSpeed*this._engine.getDeltaTime()/1e3*t},(0,A.Cg)([(0,V.lK)()],r.prototype,"keysUp",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysUpward",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysDown",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysDownward",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysLeft",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRight",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"rotationSpeed",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotateLeft",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotateRight",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotateUp",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"keysRotateDown",void 0),r}();oi.FreeCameraKeyboardMoveInput=Hc;var pn,Yc=function(){function r(t){t===void 0&&(t=!0),this.touchEnabled=t,this.buttons=[0,1,2],this.angularSensibility=2e3,this._previousPosition=null,this.onPointerMovedObservable=new K.cP,this._allowCameraRotation=!0,this._currentActiveButton=-1,this._activePointerId=-1}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments);var n=this.camera.getEngine(),i=n.getInputElement();this._pointerInput||(this._pointerInput=function(o){var a=o.event,s=a.pointerType==="touch";if((e.touchEnabled||!s)&&(o.type===vt.Zp.POINTERMOVE||e.buttons.indexOf(a.button)!==-1)){var l=a.target;if(o.type===vt.Zp.POINTERDOWN){if(s&&e._activePointerId!==-1||!s&&e._currentActiveButton!==-1)return;e._activePointerId=a.pointerId;try{l?.setPointerCapture(a.pointerId)}catch{}e._currentActiveButton===-1&&(e._currentActiveButton=a.button),e._previousPosition={x:a.clientX,y:a.clientY},t||(a.preventDefault(),i&&i.focus()),n.isPointerLock&&e._onMouseMove&&e._onMouseMove(o.event)}else if(o.type===vt.Zp.POINTERUP){if(s&&e._activePointerId!==a.pointerId||!s&&e._currentActiveButton!==a.button)return;try{l?.releasePointerCapture(a.pointerId)}catch{}e._currentActiveButton=-1,e._previousPosition=null,t||a.preventDefault(),e._activePointerId=-1}else if(o.type===vt.Zp.POINTERMOVE&&(e._activePointerId===a.pointerId||!s)){if(n.isPointerLock&&e._onMouseMove)e._onMouseMove(o.event);else if(e._previousPosition){var c=e.camera._calculateHandednessMultiplier(),u=(a.clientX-e._previousPosition.x)*c,d=a.clientY-e._previousPosition.y;e._allowCameraRotation&&(e.camera.cameraRotation.y+=u/e.angularSensibility,e.camera.cameraRotation.x+=d/e.angularSensibility),e.onPointerMovedObservable.notifyObservers({offsetX:u,offsetY:d}),e._previousPosition={x:a.clientX,y:a.clientY},t||a.preventDefault()}}}}),this._onMouseMove=function(o){if(n.isPointerLock){var a=e.camera._calculateHandednessMultiplier(),s=o.movementX*a;e.camera.cameraRotation.y+=s/e.angularSensibility;var l=o.movementY;e.camera.cameraRotation.x+=l/e.angularSensibility,e._previousPosition=null,t||o.preventDefault()}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,vt.Zp.POINTERDOWN|vt.Zp.POINTERUP|vt.Zp.POINTERMOVE),i&&(this._contextMenuBind=function(o){return e.onContextMenu(o)},i.addEventListener("contextmenu",this._contextMenuBind,!1))},r.prototype.onContextMenu=function(t){t.preventDefault()},r.prototype.detachControl=function(){if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._contextMenuBind){var t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("contextmenu",this._contextMenuBind)}this.onPointerMovedObservable&&this.onPointerMovedObservable.clear(),this._observer=null,this._onMouseMove=null,this._previousPosition=null}this._activePointerId=-1,this._currentActiveButton=-1},r.prototype.getClassName=function(){return"FreeCameraMouseInput"},r.prototype.getSimpleName=function(){return"mouse"},(0,A.Cg)([(0,V.lK)()],r.prototype,"buttons",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"angularSensibility",void 0),r}();oi.FreeCameraMouseInput=Yc,function(r){r[r.MoveRelative=0]="MoveRelative",r[r.RotateRelative=1]="RotateRelative",r[r.MoveScene=2]="MoveScene"}(pn||(pn={}));var Xc=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._moveRelative=_.Pq.Zero(),e._rotateRelative=_.Pq.Zero(),e._moveScene=_.Pq.Zero(),e._wheelXAction=pn.MoveRelative,e._wheelXActionCoordinate=0,e._wheelYAction=pn.MoveRelative,e._wheelYActionCoordinate=2,e._wheelZAction=null,e._wheelZActionCoordinate=null,e}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FreeCameraMouseWheelInput"},Object.defineProperty(t.prototype,"wheelXMoveRelative",{get:function(){return this._wheelXAction!==pn.MoveRelative?null:this._wheelXActionCoordinate},set:function(e){e===null&&this._wheelXAction!==pn.MoveRelative||(this._wheelXAction=pn.MoveRelative,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYMoveRelative",{get:function(){return this._wheelYAction!==pn.MoveRelative?null:this._wheelYActionCoordinate},set:function(e){e===null&&this._wheelYAction!==pn.MoveRelative||(this._wheelYAction=pn.MoveRelative,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZMoveRelative",{get:function(){return this._wheelZAction!==pn.MoveRelative?null:this._wheelZActionCoordinate},set:function(e){e===null&&this._wheelZAction!==pn.MoveRelative||(this._wheelZAction=pn.MoveRelative,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelXRotateRelative",{get:function(){return this._wheelXAction!==pn.RotateRelative?null:this._wheelXActionCoordinate},set:function(e){e===null&&this._wheelXAction!==pn.RotateRelative||(this._wheelXAction=pn.RotateRelative,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYRotateRelative",{get:function(){return this._wheelYAction!==pn.RotateRelative?null:this._wheelYActionCoordinate},set:function(e){e===null&&this._wheelYAction!==pn.RotateRelative||(this._wheelYAction=pn.RotateRelative,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZRotateRelative",{get:function(){return this._wheelZAction!==pn.RotateRelative?null:this._wheelZActionCoordinate},set:function(e){e===null&&this._wheelZAction!==pn.RotateRelative||(this._wheelZAction=pn.RotateRelative,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelXMoveScene",{get:function(){return this._wheelXAction!==pn.MoveScene?null:this._wheelXActionCoordinate},set:function(e){e===null&&this._wheelXAction!==pn.MoveScene||(this._wheelXAction=pn.MoveScene,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYMoveScene",{get:function(){return this._wheelYAction!==pn.MoveScene?null:this._wheelYActionCoordinate},set:function(e){e===null&&this._wheelYAction!==pn.MoveScene||(this._wheelYAction=pn.MoveScene,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZMoveScene",{get:function(){return this._wheelZAction!==pn.MoveScene?null:this._wheelZActionCoordinate},set:function(e){e===null&&this._wheelZAction!==pn.MoveScene||(this._wheelZAction=pn.MoveScene,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),t.prototype.checkInputs=function(){if(this._wheelDeltaX!==0||this._wheelDeltaY!==0||this._wheelDeltaZ!=0){this._moveRelative.setAll(0),this._rotateRelative.setAll(0),this._moveScene.setAll(0),this._updateCamera(),this.camera.getScene().useRightHandedSystem&&(this._moveRelative.z*=-1);var e=_.uq.Zero();this.camera.getViewMatrix().invertToRef(e);var n=_.Pq.Zero();_.Pq.TransformNormalToRef(this._moveRelative,e,n),this.camera.cameraRotation.x+=this._rotateRelative.x/200,this.camera.cameraRotation.y+=this._rotateRelative.y/200,this.camera.cameraDirection.addInPlace(n),this.camera.cameraDirection.addInPlace(this._moveScene),r.prototype.checkInputs.call(this)}},t.prototype._updateCamera=function(){this._updateCameraProperty(this._wheelDeltaX,this._wheelXAction,this._wheelXActionCoordinate),this._updateCameraProperty(this._wheelDeltaY,this._wheelYAction,this._wheelYActionCoordinate),this._updateCameraProperty(this._wheelDeltaZ,this._wheelZAction,this._wheelZActionCoordinate)},t.prototype._updateCameraProperty=function(e,n,i){if(e!==0&&n!==null&&i!==null){var o=null;switch(n){case pn.MoveRelative:o=this._moveRelative;break;case pn.RotateRelative:o=this._rotateRelative;break;case pn.MoveScene:o=this._moveScene}switch(i){case 0:o.set(e,0,0);break;case 1:o.set(0,e,0);break;case 2:o.set(0,0,e)}}},(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelXMoveRelative",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelYMoveRelative",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelZMoveRelative",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelXRotateRelative",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelYRotateRelative",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelZRotateRelative",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelXMoveScene",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelYMoveScene",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"wheelZMoveScene",null),t}(dm);oi.FreeCameraMouseWheelInput=Xc;var jc=function(){function r(t){t===void 0&&(t=!1),this.allowMouse=t,this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this.singleFingerRotate=!1,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array,this._isSafari=ze.S0.IsSafari()}return r.prototype.attachControl=function(t){var e=this;t=ze.S0.BackCompatCameraNoPreventDefault(arguments);var n=null;if(this._pointerInput===void 0&&(this._onLostFocus=function(){e._offsetX=null,e._offsetY=null},this._pointerInput=function(o){var a=o.event,s=a.pointerType==="mouse"||e._isSafari&&a.pointerType===void 0;if(e.allowMouse||!s){if(o.type===vt.Zp.POINTERDOWN){if(t||a.preventDefault(),e._pointerPressed.push(a.pointerId),e._pointerPressed.length!==1)return;n={x:a.clientX,y:a.clientY}}else if(o.type===vt.Zp.POINTERUP){if(t||a.preventDefault(),(l=e._pointerPressed.indexOf(a.pointerId))===-1||(e._pointerPressed.splice(l,1),l!=0))return;n=null,e._offsetX=null,e._offsetY=null}else if(o.type===vt.Zp.POINTERMOVE){if(t||a.preventDefault(),!n)return;var l;if((l=e._pointerPressed.indexOf(a.pointerId))!=0)return;e._offsetX=a.clientX-n.x,e._offsetY=-(a.clientY-n.y)}}}),this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,vt.Zp.POINTERDOWN|vt.Zp.POINTERUP|vt.Zp.POINTERMOVE),this._onLostFocus){var i=this.camera.getEngine().getInputElement();i&&i.addEventListener("blur",this._onLostFocus)}},r.prototype.detachControl=function(){if(this._pointerInput){if(this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null),this._onLostFocus){var t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null}this._pointerPressed.length=0,this._offsetX=null,this._offsetY=null}},r.prototype.checkInputs=function(){if(this._offsetX!==null&&this._offsetY!==null&&(this._offsetX!==0||this._offsetY!==0)){var t=this.camera,e=t._calculateHandednessMultiplier();if(t.cameraRotation.y=e*this._offsetX/this.touchAngularSensibility,this.singleFingerRotate&&this._pointerPressed.length===1||!this.singleFingerRotate&&this._pointerPressed.length>1)t.cameraRotation.x=-this._offsetY/this.touchAngularSensibility;else{var n=t._computeLocalCameraSpeed(),i=new _.Pq(0,0,this.touchMoveSensibility!==0?n*this._offsetY/this.touchMoveSensibility:0);_.uq.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(_.Pq.TransformCoordinates(i,t._cameraRotationMatrix))}}},r.prototype.getClassName=function(){return"FreeCameraTouchInput"},r.prototype.getSimpleName=function(){return"touch"},(0,A.Cg)([(0,V.lK)()],r.prototype,"touchAngularSensibility",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"touchMoveSensibility",void 0),r}();oi.FreeCameraTouchInput=jc;var Ra=function(r){function t(e){var n=r.call(this,e)||this;return n._mouseInput=null,n._mouseWheelInput=null,n}return(0,A.C6)(t,r),t.prototype.addKeyboard=function(){return this.add(new Hc),this},t.prototype.addMouse=function(e){return e===void 0&&(e=!0),this._mouseInput||(this._mouseInput=new Yc(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addMouseWheel=function(){return this._mouseWheelInput||(this._mouseWheelInput=new Xc,this.add(this._mouseWheelInput)),this},t.prototype.removeMouseWheel=function(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this},t.prototype.addTouch=function(){return this.add(new jc),this},t.prototype.clear=function(){r.prototype.clear.call(this),this._mouseInput=null},t}(Ca);Ra.prototype.addDeviceOrientation=function(r){return this._deviceOrientationInput||(this._deviceOrientationInput=new qc,r&&(this._deviceOrientationInput.smoothFactor=r),this.add(this._deviceOrientationInput)),this};var qc=function(){function r(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new _.PT,this._alpha=0,this._beta=0,this._gamma=0,this.smoothFactor=0,this._onDeviceOrientationChangedObservable=new K.cP,this._orientationChanged=function(){t._screenOrientationAngle=window.orientation!==void 0?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-ze.S0.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t.smoothFactor?(t._alpha=e.alpha!==null?ze.S0.SmoothAngleChange(t._alpha,e.alpha,t.smoothFactor):0,t._beta=e.beta!==null?ze.S0.SmoothAngleChange(t._beta,e.beta,t.smoothFactor):0,t._gamma=e.gamma!==null?ze.S0.SmoothAngleChange(t._gamma,e.gamma,t.smoothFactor):0):(t._alpha=e.alpha!==null?e.alpha:0,t._beta=e.beta!==null?e.beta:0,t._gamma=e.gamma!==null?e.gamma:0),e.alpha!==null&&t._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTransform=new _.PT(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return r.WaitForOrientationChangeAsync=function(t){return new Promise(function(e,n){var i=!1,o=function(){window.removeEventListener("deviceorientation",o),i=!0,e()};t&&setTimeout(function(){i||(window.removeEventListener("deviceorientation",o),n("WaitForOrientationChangeAsync timed out"))},t),typeof DeviceOrientationEvent<"u"&&typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(function(a){a=="granted"?window.addEventListener("deviceorientation",o):ze.S0.Warn("Permission not granted.")}).catch(function(a){ze.S0.Error(a)}):window.addEventListener("deviceorientation",o)})},Object.defineProperty(r.prototype,"camera",{get:function(){return this._camera},set:function(t){var e=this;this._camera=t,this._camera==null||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new _.PT),this._camera&&this._camera.onDisposeObservable.add(function(){e._onDeviceOrientationChangedObservable.clear()})},enumerable:!1,configurable:!0}),r.prototype.attachControl=function(){var t=this,e=this.camera.getScene().getEngine().getHostWindow();if(e){var n=function(){e.addEventListener("orientationchange",t._orientationChanged),e.addEventListener("deviceorientation",t._deviceOrientation),t._orientationChanged()};typeof DeviceOrientationEvent<"u"&&typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(function(i){i==="granted"?n():ze.S0.Warn("Permission not granted.")}).catch(function(i){ze.S0.Error(i)}):n()}},r.prototype.detachControl=function(){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation),this._alpha=0},r.prototype.checkInputs=function(){this._alpha&&(_.PT.RotationYawPitchRollToRef(ze.S0.ToRadians(this._alpha),ze.S0.ToRadians(this._beta),-ze.S0.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTransform),this._camera.getScene().useRightHandedSystem?this._camera.rotationQuaternion.y*=-1:this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},r.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},r.prototype.getSimpleName=function(){return"deviceOrientation"},r}();oi.FreeCameraDeviceOrientationInput=qc;var Kc=function(){function r(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this.deadzoneDelta=.1,this._yAxisScale=1,this._cameraTransform=_.uq.Identity(),this._deltaTransform=_.Pq.Zero(),this._vector3=_.Pq.Zero(),this._vector2=_.I9.Zero()}return Object.defineProperty(r.prototype,"invertYAxis",{get:function(){return this._yAxisScale!==1},set:function(t){this._yAxisScale=t?-1:1},enumerable:!1,configurable:!0}),r.prototype.attachControl=function(){var t=this,e=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=e.onGamepadConnectedObservable.add(function(n){n.type!==Ii.POSE_ENABLED&&(t.gamepad&&n.type!==Ii.XBOX||(t.gamepad=n))}),this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add(function(n){t.gamepad===n&&(t.gamepad=null)}),this.gamepad=e.getGamepadByType(Ii.XBOX),!this.gamepad&&e.gamepads.length&&(this.gamepad=e.gamepads[0])},r.prototype.detachControl=function(){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},r.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var t=this.camera,e=this.gamepad.leftStick;this.gamepadMoveSensibility!==0&&(e.x=Math.abs(e.x)>this.deadzoneDelta?e.x/this.gamepadMoveSensibility:0,e.y=Math.abs(e.y)>this.deadzoneDelta?e.y/this.gamepadMoveSensibility:0);var n=this.gamepad.rightStick;n&&this.gamepadAngularSensibility!==0?(n.x=Math.abs(n.x)>this.deadzoneDelta?n.x/this.gamepadAngularSensibility:0,n.y=(Math.abs(n.y)>this.deadzoneDelta?n.y/this.gamepadAngularSensibility:0)*this._yAxisScale):n={x:0,y:0},t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):_.uq.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var i=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(e.x*i,0,-e.y*i),_.Pq.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(n.y,n.x),t.cameraRotation.addInPlace(this._vector2)}},r.prototype.getClassName=function(){return"FreeCameraGamepadInput"},r.prototype.getSimpleName=function(){return"gamepad"},(0,A.Cg)([(0,V.lK)()],r.prototype,"gamepadAngularSensibility",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"gamepadMoveSensibility",void 0),r}();oi.FreeCameraGamepadInput=Kc;var Zc,fm=L(59437);(function(r){r[r.X=0]="X",r[r.Y=1]="Y",r[r.Z=2]="Z"})(Zc||(Zc={}));var Qc=function(){function r(t,e){var n=this;this._released=!1;var i=(0,A.Cl)((0,A.Cl)({},r._GetDefaultOptions()),e);if(this._leftJoystick=!!t,r._GlobalJoystickIndex++,this._axisTargetedByLeftAndRight=0,this._axisTargetedByUpAndDown=1,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new fm.w,this.deltaPosition=_.Pq.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(){r._VJCanvasWidth=window.innerWidth,r._VJCanvasHeight=window.innerHeight,r.Canvas&&(r.Canvas.width=r._VJCanvasWidth,r.Canvas.height=r._VJCanvasHeight),r._HalfWidth=r._VJCanvasWidth/2},!r.Canvas){window.addEventListener("resize",this._onResize,!1),r.Canvas=document.createElement("canvas"),r._VJCanvasWidth=window.innerWidth,r._VJCanvasHeight=window.innerHeight,r.Canvas.width=window.innerWidth,r.Canvas.height=window.innerHeight,r.Canvas.style.width="100%",r.Canvas.style.height="100%",r.Canvas.style.position="absolute",r.Canvas.style.backgroundColor="transparent",r.Canvas.style.top="0px",r.Canvas.style.left="0px",r.Canvas.style.zIndex="5",r.Canvas.style.touchAction="none",r.Canvas.setAttribute("touch-action","none");var o=r.Canvas.getContext("2d");if(!o)throw new Error("Unable to create canvas for virtual joystick");r._VJCanvasContext=o,r._VJCanvasContext.strokeStyle="#ffffff",r._VJCanvasContext.lineWidth=2,document.body.appendChild(r.Canvas)}r._HalfWidth=r.Canvas.width/2,this.pressed=!1,this.limitToContainer=i.limitToContainer,this._joystickColor=i.color,this.containerSize=i.containerSize,this.puckSize=i.puckSize,i.position&&this.setPosition(i.position.x,i.position.y),i.puckImage&&this.setPuckImage(i.puckImage),i.containerImage&&this.setContainerImage(i.containerImage),i.alwaysVisible&&r._AlwaysVisibleSticks++,this.alwaysVisible=i.alwaysVisible,this._joystickPointerId=-1,this._joystickPointerPos=new _.I9(0,0),this._joystickPreviousPointerPos=new _.I9(0,0),this._joystickPointerStartPos=new _.I9(0,0),this._deltaJoystickVector=new _.I9(0,0),this._onPointerDownHandlerRef=function(a){n._onPointerDown(a)},this._onPointerMoveHandlerRef=function(a){n._onPointerMove(a)},this._onPointerUpHandlerRef=function(a){n._onPointerUp(a)},r.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),r.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),r.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),r.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),r.Canvas.addEventListener("contextmenu",function(a){a.preventDefault()},!1),requestAnimationFrame(function(){n._drawVirtualJoystick()})}return r._GetDefaultOptions=function(){return{puckSize:40,containerSize:60,color:"cyan",puckImage:void 0,containerImage:void 0,position:void 0,alwaysVisible:!1,limitToContainer:!1}},r.prototype.setJoystickSensibility=function(t){this._joystickSensibility=t,this._inversedSensibility=1/(this._joystickSensibility/1e3)},r.prototype._onPointerDown=function(t){t.preventDefault(),(this._leftJoystick===!0?t.clientX<r._HalfWidth:t.clientX>r._HalfWidth)&&this._joystickPointerId<0?(this._joystickPointerId=t.pointerId,this._joystickPosition?(this._joystickPointerStartPos=this._joystickPosition.clone(),this._joystickPointerPos=this._joystickPosition.clone(),this._joystickPreviousPointerPos=this._joystickPosition.clone(),this._onPointerMove(t)):(this._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone()),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):r._GlobalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},r.prototype._onPointerMove=function(t){if(this._joystickPointerId==t.pointerId){if(this.limitToContainer){var e=new _.I9(t.clientX-this._joystickPointerStartPos.x,t.clientY-this._joystickPointerStartPos.y),n=e.length();n>this.containerSize&&e.scaleInPlace(this.containerSize/n),this._joystickPointerPos.x=this._joystickPointerStartPos.x+e.x,this._joystickPointerPos.y=this._joystickPointerStartPos.y+e.y}else this._joystickPointerPos.x=t.clientX,this._joystickPointerPos.y=t.clientY;this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos),0<r._AlwaysVisibleSticks&&(this._leftJoystick?this._joystickPointerPos.x=Math.min(r._HalfWidth,this._joystickPointerPos.x):this._joystickPointerPos.x=Math.max(r._HalfWidth,this._joystickPointerPos.x));var i=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case 0:this.deltaPosition.x=Math.min(1,Math.max(-1,i));break;case 1:this.deltaPosition.y=Math.min(1,Math.max(-1,i));break;case 2:this.deltaPosition.z=Math.min(1,Math.max(-1,i))}var o=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case 0:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case 1:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case 2:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var a=this._touches.get(t.pointerId.toString());a&&(a.x=t.clientX,a.y=t.clientY)}},r.prototype._onPointerUp=function(t){if(this._joystickPointerId==t.pointerId)this._clearPreviousDraw(),this._joystickPointerId=-1,this.pressed=!1;else{var e=this._touches.get(t.pointerId.toString());e&&r._VJCanvasContext.clearRect(e.prevX-44,e.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(t.pointerId.toString())},r.prototype.setJoystickColor=function(t){this._joystickColor=t},Object.defineProperty(r.prototype,"containerSize",{get:function(){return this._joystickContainerSize},set:function(t){this._joystickContainerSize=t,this._clearContainerSize=~~(2.1*this._joystickContainerSize),this._clearContainerSizeOffset=~~(this._clearContainerSize/2)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"puckSize",{get:function(){return this._joystickPuckSize},set:function(t){this._joystickPuckSize=t,this._clearPuckSize=~~(2.1*this._joystickPuckSize),this._clearPuckSizeOffset=~~(this._clearPuckSize/2)},enumerable:!1,configurable:!0}),r.prototype.clearPosition=function(){this.alwaysVisible=!1,this._joystickPosition=null},Object.defineProperty(r.prototype,"alwaysVisible",{get:function(){return this._alwaysVisible},set:function(t){this._alwaysVisible!==t&&(t&&this._joystickPosition?(r._AlwaysVisibleSticks++,this._alwaysVisible=!0):(r._AlwaysVisibleSticks--,this._alwaysVisible=!1))},enumerable:!1,configurable:!0}),r.prototype.setPosition=function(t,e){this._joystickPointerStartPos&&this._clearPreviousDraw(),this._joystickPosition=new _.I9(t,e)},r.prototype.setActionOnTouch=function(t){this._action=t},r.prototype.setAxisForLeftRight=function(t){switch(t){case 0:case 1:case 2:this._axisTargetedByLeftAndRight=t;break;default:this._axisTargetedByLeftAndRight=0}},r.prototype.setAxisForUpDown=function(t){switch(t){case 0:case 1:case 2:this._axisTargetedByUpAndDown=t;break;default:this._axisTargetedByUpAndDown=1}},r.prototype._clearPreviousDraw=function(){var t=this._joystickPosition||this._joystickPointerStartPos;r._VJCanvasContext.clearRect(t.x-this._clearContainerSizeOffset,t.y-this._clearContainerSizeOffset,this._clearContainerSize,this._clearContainerSize),r._VJCanvasContext.clearRect(this._joystickPreviousPointerPos.x-this._clearPuckSizeOffset-1,this._joystickPreviousPointerPos.y-this._clearPuckSizeOffset-1,this._clearPuckSize+2,this._clearPuckSize+2)},r.prototype.setContainerImage=function(t){var e=this,n=new Image;n.src=t,n.onload=function(){return e._containerImage=n}},r.prototype.setPuckImage=function(t){var e=this,n=new Image;n.src=t,n.onload=function(){return e._puckImage=n}},r.prototype._drawContainer=function(){var t=this._joystickPosition||this._joystickPointerStartPos;this._clearPreviousDraw(),this._containerImage?r._VJCanvasContext.drawImage(this._containerImage,t.x-this.containerSize,t.y-this.containerSize,2*this.containerSize,2*this.containerSize):(r._VJCanvasContext.beginPath(),r._VJCanvasContext.strokeStyle=this._joystickColor,r._VJCanvasContext.lineWidth=2,r._VJCanvasContext.arc(t.x,t.y,this.containerSize,0,2*Math.PI,!0),r._VJCanvasContext.stroke(),r._VJCanvasContext.closePath(),r._VJCanvasContext.beginPath(),r._VJCanvasContext.lineWidth=6,r._VJCanvasContext.strokeStyle=this._joystickColor,r._VJCanvasContext.arc(t.x,t.y,this.puckSize,0,2*Math.PI,!0),r._VJCanvasContext.stroke(),r._VJCanvasContext.closePath())},r.prototype._drawPuck=function(){this._puckImage?r._VJCanvasContext.drawImage(this._puckImage,this._joystickPointerPos.x-this.puckSize,this._joystickPointerPos.y-this.puckSize,2*this.puckSize,2*this.puckSize):(r._VJCanvasContext.beginPath(),r._VJCanvasContext.strokeStyle=this._joystickColor,r._VJCanvasContext.lineWidth=2,r._VJCanvasContext.arc(this._joystickPointerPos.x,this._joystickPointerPos.y,this.puckSize,0,2*Math.PI,!0),r._VJCanvasContext.stroke(),r._VJCanvasContext.closePath())},r.prototype._drawVirtualJoystick=function(){var t=this;this._released||(this.alwaysVisible&&this._drawContainer(),this.pressed&&this._touches.forEach(function(e,n){n.pointerId===t._joystickPointerId?(t.alwaysVisible||t._drawContainer(),t._drawPuck(),t._joystickPreviousPointerPos=t._joystickPointerPos.clone()):(r._VJCanvasContext.clearRect(n.prevX-44,n.prevY-44,88,88),r._VJCanvasContext.beginPath(),r._VJCanvasContext.fillStyle="white",r._VJCanvasContext.beginPath(),r._VJCanvasContext.strokeStyle="red",r._VJCanvasContext.lineWidth=6,r._VJCanvasContext.arc(n.x,n.y,40,0,2*Math.PI,!0),r._VJCanvasContext.stroke(),r._VJCanvasContext.closePath(),n.prevX=n.x,n.prevY=n.y)}),requestAnimationFrame(function(){t._drawVirtualJoystick()}))},r.prototype.releaseCanvas=function(){r.Canvas&&(r.Canvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),r.Canvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),r.Canvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),r.Canvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(r.Canvas),r.Canvas=null),this._released=!0},r._GlobalJoystickIndex=0,r._AlwaysVisibleSticks=0,r}();Ra.prototype.addVirtualJoystick=function(){return this.add(new Jc),this};var Jc=function(){function r(){}return r.prototype.getLeftJoystick=function(){return this._leftjoystick},r.prototype.getRightJoystick=function(){return this._rightjoystick},r.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,e=50*t._computeLocalCameraSpeed(),n=_.uq.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),i=_.Pq.TransformCoordinates(new _.Pq(this._leftjoystick.deltaPosition.x*e,this._leftjoystick.deltaPosition.y*e,this._leftjoystick.deltaPosition.z*e),n);t.cameraDirection=t.cameraDirection.add(i),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},r.prototype.attachControl=function(){this._leftjoystick=new Qc(!0),this._leftjoystick.setAxisForUpDown(2),this._leftjoystick.setAxisForLeftRight(0),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new Qc(!1),this._rightjoystick.setAxisForUpDown(0),this._rightjoystick.setAxisForLeftRight(1),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},r.prototype.detachControl=function(){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},r.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},r.prototype.getSimpleName=function(){return"virtualJoystick"},r}();oi.FreeCameraVirtualJoystickInput=Jc,At.AddNodeConstructor("TargetCamera",function(r,t){return function(){return new kr(r,_.Pq.Zero(),t)}});var kr=function(r){function t(e,n,i,o){o===void 0&&(o=!0);var a=r.call(this,e,n,i,o)||this;return a._tmpUpVector=_.Pq.Zero(),a._tmpTargetVector=_.Pq.Zero(),a.cameraDirection=new _.Pq(0,0,0),a.cameraRotation=new _.I9(0,0),a.ignoreParentScaling=!1,a.updateUpVectorFromRotation=!1,a._tmpQuaternion=new _.PT,a.rotation=new _.Pq(0,0,0),a.speed=2,a.noRotationConstraint=!1,a.invertRotation=!1,a.inverseRotationSpeed=.2,a.lockedTarget=null,a._currentTarget=_.Pq.Zero(),a._initialFocalDistance=1,a._viewMatrix=_.uq.Zero(),a._camMatrix=_.uq.Zero(),a._cameraTransformMatrix=_.uq.Zero(),a._cameraRotationMatrix=_.uq.Zero(),a._referencePoint=new _.Pq(0,0,1),a._transformedReferencePoint=_.Pq.Zero(),a._deferredPositionUpdate=new _.Pq,a._deferredRotationQuaternionUpdate=new _.PT,a._deferredRotationUpdate=new _.Pq,a._deferredUpdated=!1,a._deferOnly=!1,a._defaultUp=_.Pq.Up(),a._cachedRotationZ=0,a._cachedQuaternionRotationZ=0,a}return(0,A.C6)(t,r),t.prototype.getFrontPosition=function(e){this.getWorldMatrix();var n=this.getTarget().subtract(this.position);return n.normalize(),n.scaleInPlace(e),this.globalPosition.add(n)},t.prototype._getLockedTargetPosition=function(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){var e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget},t.prototype.storeState=function(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),r.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!r.prototype._restoreStateValues.call(this)&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)},t.prototype._initCache=function(){r.prototype._initCache.call(this),this._cache.lockedTarget=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new _.PT(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},t.prototype._updateCache=function(e){e||r.prototype._updateCache.call(this);var n=this._getLockedTargetPosition();n?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(n):this._cache.lockedTarget=n.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},t.prototype._isSynchronizedViewMatrix=function(){if(!r.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},t.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},t.prototype.setTarget=function(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=pt.bH),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),_.uq.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var n=e.subtract(this.position);n.x>=0?this.rotation.y=-Math.atan(n.z/n.x)+Math.PI/2:this.rotation.y=-Math.atan(n.z/n.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&_.PT.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},Object.defineProperty(t.prototype,"target",{get:function(){return this.getTarget()},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),t.prototype.getTarget=function(){return this._currentTarget},t.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(_.AA.Matrix[0]),_.Pq.TransformNormalToRef(this.cameraDirection,_.AA.Matrix[0],_.AA.Vector3[0]),this._deferredPositionUpdate.addInPlace(_.AA.Vector3[0]),void(this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate));this._deferredPositionUpdate.addInPlace(this.cameraDirection),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate)},t.prototype._checkInputs=function(){var e=this.invertRotation?-this.inverseRotationSpeed:1,n=this._decideIfNeedsToMove(),i=this.cameraRotation.x||this.cameraRotation.y;if(this._deferredUpdated=!1,this._deferredRotationUpdate.copyFrom(this.rotation),this._deferredPositionUpdate.copyFrom(this.position),this.rotationQuaternion&&this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion),n&&this._updatePosition(),i){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate),this._deferredRotationUpdate.x+=this.cameraRotation.x*e,this._deferredRotationUpdate.y+=this.cameraRotation.y*e,!this.noRotationConstraint){var o=1.570796;this._deferredRotationUpdate.x>o&&(this._deferredRotationUpdate.x=o),this._deferredRotationUpdate.x<-o&&(this._deferredRotationUpdate.x=-o)}this._deferOnly?this._deferredUpdated=!0:this.rotation.copyFrom(this._deferredRotationUpdate),this.rotationQuaternion&&this._deferredRotationUpdate.lengthSquared()&&(_.PT.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate))}n&&(Math.abs(this.cameraDirection.x)<this.speed*pt.bH&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*pt.bH&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*pt.bH&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<this.speed*pt.bH&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*pt.bH&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),r.prototype._checkInputs.call(this)},t.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):_.uq.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},t.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return _.Pq.TransformNormalToRef(this._defaultUp,this._cameraRotationMatrix,this.upVector),this},t.prototype._getViewMatrix=function(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!==this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),_.Pq.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?Qn._0.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(_.PT.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),Qn._0.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},t.prototype._computeViewMatrix=function(e,n,i){if(this.ignoreParentScaling){if(this.parent){var o=this.parent.getWorldMatrix();_.Pq.TransformCoordinatesToRef(e,o,this._globalPosition),_.Pq.TransformCoordinatesToRef(n,o,this._tmpTargetVector),_.Pq.TransformNormalToRef(i,o,this._tmpUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._tmpTargetVector.copyFrom(n),this._tmpUpVector.copyFrom(i);this.getScene().useRightHandedSystem?_.uq.LookAtRHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix):_.uq.LookAtLHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix)}else this.getScene().useRightHandedSystem?_.uq.LookAtRHToRef(e,n,i,this._viewMatrix):_.uq.LookAtLHToRef(e,n,i,this._viewMatrix),this.parent?(o=this.parent.getWorldMatrix(),this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(o,this._viewMatrix),this._viewMatrix.getTranslationToRef(this._globalPosition),this._viewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(e)},t.prototype.createRigCamera=function(e,n){if(this.cameraRigMode!==Pt.RIG_MODE_NONE){var i=new t(e,this.position.clone(),this.getScene());return i.isRigCamera=!0,i.rigParent=this,this.cameraRigMode===Pt.RIG_MODE_VR&&(this.rotationQuaternion||(this.rotationQuaternion=new _.PT),i._cameraRigParams={},i.rotationQuaternion=new _.PT),i.mode=this.mode,i.orthoLeft=this.orthoLeft,i.orthoRight=this.orthoRight,i.orthoTop=this.orthoTop,i.orthoBottom=this.orthoBottom,i}return null},t.prototype._updateRigCameras=function(){var e=this._rigCameras[0],n=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case Pt.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case Pt.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Pt.RIG_MODE_STEREOSCOPIC_INTERLACED:var i=this.cameraRigMode===Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,o=this.cameraRigMode===Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,e),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*o,n);break;case Pt.RIG_MODE_VR:e.rotationQuaternion?(e.rotationQuaternion.copyFrom(this.rotationQuaternion),n.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.rotation.copyFrom(this.rotation),n.rotation.copyFrom(this.rotation)),e.position.copyFrom(this.position),n.position.copyFrom(this.position)}r.prototype._updateRigCameras.call(this)},t.prototype._getRigCamPositionAndTarget=function(e,n){this.getTarget().subtractToRef(this.position,t._TargetFocalPoint),t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);var i=t._TargetFocalPoint.addInPlace(this.position);_.uq.TranslationToRef(-i.x,-i.y,-i.z,t._TargetTransformMatrix),t._TargetTransformMatrix.multiplyToRef(_.uq.RotationAxis(n.upVector,e),t._RigCamTransformMatrix),_.uq.TranslationToRef(i.x,i.y,i.z,t._TargetTransformMatrix),t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix,t._RigCamTransformMatrix),_.Pq.TransformCoordinatesToRef(this.position,t._RigCamTransformMatrix,n.position),n.setTarget(i)},t.prototype.getClassName=function(){return"TargetCamera"},t._RigCamTransformMatrix=new _.uq,t._TargetTransformMatrix=new _.uq,t._TargetFocalPoint=new _.Pq,(0,A.Cg)([(0,V.P_)()],t.prototype,"rotation",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"speed",void 0),(0,A.Cg)([(0,V.xG)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Pt),_r=function(r){function t(e,n,i,o){o===void 0&&(o=!0);var a=r.call(this,e,n,i,o)||this;return a.ellipsoid=new _.Pq(.5,1,.5),a.ellipsoidOffset=new _.Pq(0,0,0),a.checkCollisions=!1,a.applyGravity=!1,a._needMoveForGravity=!1,a._oldPosition=_.Pq.Zero(),a._diffPosition=_.Pq.Zero(),a._newPosition=_.Pq.Zero(),a._collisionMask=-1,a._onCollisionPositionChange=function(s,l,c){c===void 0&&(c=null),a._newPosition.copyFrom(l),a._newPosition.subtractToRef(a._oldPosition,a._diffPosition),a._diffPosition.length()>Be.$.CollisionsEpsilon&&(a.position.addToRef(a._diffPosition,a._deferredPositionUpdate),a._deferOnly?a._deferredUpdated=!0:a.position.copyFrom(a._deferredPositionUpdate),a.onCollide&&c&&a.onCollide(c))},a.inputs=new Ra(a),a.inputs.addKeyboard().addMouse(),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var n=this.inputs.attached.mouse;n&&(n.angularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUpward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUpward:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysUpward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDownward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDownward:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysDownward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateLeft:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysRotateLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateRight:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysRotateRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateUp:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysRotateUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateDown:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysRotateDown=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,n){n=ze.S0.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(n)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new _.Pq(0,0,0),this.cameraRotation=new _.I9(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?_.Pq.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var n=this.getScene().collisionCoordinator;this._collider||(this._collider=n.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),n.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=_.Pq.Zero(),this._transformedDirection=_.Pq.Zero()),this.inputs.checkInputs(),r.prototype._checkInputs.call(this)},Object.defineProperty(t.prototype,"needMoveForGravity",{get:function(){return this._needMoveForGravity},set:function(e){this._needMoveForGravity=e},enumerable:!1,configurable:!0}),t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):r.prototype._updatePosition.call(this)},t.prototype.dispose=function(){this.inputs.clear(),r.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FreeCamera"},(0,A.Cg)([(0,V.P_)()],t.prototype,"ellipsoid",void 0),(0,A.Cg)([(0,V.P_)()],t.prototype,"ellipsoidOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"checkCollisions",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"applyGravity",void 0),t}(kr);(0,j.Y5)("BABYLON.FreeCamera",_r),At.AddNodeConstructor("TouchCamera",function(r,t){return function(){return new $c(r,_.Pq.Zero(),t)}});var $c=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.inputs.addTouch(),o._setupInputs(),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var n=this.inputs.attached.touch;n&&(n.touchAngularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var n=this.inputs.attached.touch;n&&(n.touchMoveSensibility=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.touch,n=this.inputs.attached.mouse;n?n.touchEnabled=!e:e.allowMouse=!n},t}(_r);At.AddNodeConstructor("ArcRotateCamera",function(r,t){return function(){return new zr(r,0,0,1,_.Pq.Zero(),t)}});var zr=function(r){function t(e,n,i,o,a,s,l){l===void 0&&(l=!0);var c=r.call(this,e,_.Pq.Zero(),s,l)||this;return c.inertialAlphaOffset=0,c.inertialBetaOffset=0,c.inertialRadiusOffset=0,c.lowerAlphaLimit=null,c.upperAlphaLimit=null,c.lowerBetaLimit=.01,c.upperBetaLimit=Math.PI-.01,c.lowerRadiusLimit=null,c.upperRadiusLimit=null,c.inertialPanningX=0,c.inertialPanningY=0,c.pinchToPanMaxDistance=20,c.panningDistanceLimit=null,c.panningOriginTarget=_.Pq.Zero(),c.panningInertia=.9,c.zoomOnFactor=1,c.targetScreenOffset=_.I9.Zero(),c.allowUpsideDown=!0,c.useInputToRestoreState=!0,c.restoreStateInterpolationFactor=0,c._viewMatrix=new _.uq,c.panningAxis=new _.Pq(1,1,0),c._transformedDirection=new _.Pq,c.mapPanning=!1,c._progressiveRestore=!1,c.onMeshTargetChangedObservable=new K.cP,c.checkCollisions=!1,c.collisionRadius=new _.Pq(.5,.5,.5),c._previousPosition=_.Pq.Zero(),c._collisionVelocity=_.Pq.Zero(),c._newPosition=_.Pq.Zero(),c._computationVector=_.Pq.Zero(),c._onCollisionPositionChange=function(u,d,h){h===void 0&&(h=null),h?(c.setPosition(d),c.onCollide&&c.onCollide(h)):c._previousPosition.copyFrom(c._position);var p=Math.cos(c.alpha),m=Math.sin(c.alpha),v=Math.cos(c.beta),b=Math.sin(c.beta);b===0&&(b=1e-4);var E=c._getTargetPosition();c._computationVector.copyFromFloats(c.radius*p*b,c.radius*v,c.radius*m*b),E.addToRef(c._computationVector,c._newPosition),c._position.copyFrom(c._newPosition);var C=c.upVector;c.allowUpsideDown&&c.beta<0&&(C=(C=C.clone()).negate()),c._computeViewMatrix(c._position,E,C),c._viewMatrix.addAtIndex(12,c.targetScreenOffset.x),c._viewMatrix.addAtIndex(13,c.targetScreenOffset.y),c._collisionTriggered=!1},c._target=_.Pq.Zero(),a&&c.setTarget(a),c.alpha=n,c.beta=i,c.radius=o,c.getViewMatrix(),c.inputs=new Os(c),c.inputs.addKeyboard().addMouseWheel().addPointers(),c}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetHost",{get:function(){return this._targetHost},set:function(e){e&&this.setTarget(e)},enumerable:!1,configurable:!0}),t.prototype.getTarget=function(){return this.target},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._yToUpMatrix=new _.uq,this._upToYMatrix=new _.uq,this._upVector=_.Pq.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),t.prototype.setMatUp=function(){_.uq.RotationAlignToRef(_.Pq.UpReadOnly,this._upVector,this._yToUpMatrix),_.uq.RotationAlignToRef(this._upVector,_.Pq.UpReadOnly,this._upToYMatrix)},Object.defineProperty(t.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0},set:function(e){var n=this.inputs.attached.pointers;n&&(n.angularSensibilityX=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var n=this.inputs.attached.pointers;n&&(n.angularSensibilityY=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var n=this.inputs.attached.pointers;n&&(n.pinchPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var n=this.inputs.attached.pointers;n&&(n.pinchDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useNaturalPinchZoom",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var n=this.inputs.attached.pointers;n&&(n.useNaturalPinchZoom=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var n=this.inputs.attached.pointers;n&&(n.panningSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysRight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var n=this.inputs.attached.mousewheel;n&&(n.wheelPrecision=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoomToMouseLocation",{get:function(){var e=this.inputs.attached.mousewheel;return!!e&&e.zoomToMouseLocation},set:function(e){var n=this.inputs.attached.mousewheel;n&&(n.zoomToMouseLocation=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var n=this.inputs.attached.mousewheel;n&&(n.wheelDeltaPercentage=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return this._bouncingBehavior!=null},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new om,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return this._framingBehavior!=null},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new am,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return this._autoRotationBehavior!=null},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new rm,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!1,configurable:!0}),t.prototype._initCache=function(){r.prototype._initCache.call(this),this._cache._target=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=_.I9.Zero()},t.prototype._updateCache=function(e){e||r.prototype._updateCache.call(this),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},t.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}return this._getLockedTargetPosition()||this._target},t.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),r.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>pt.bH&&this.restoreStateInterpolationFactor<1?(this._progressiveRestore=!0,this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0):!!r.prototype._restoreStateValues.call(this)&&(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)},t.prototype._isSynchronizedViewMatrix=function(){return!!r.prototype._isSynchronizedViewMatrix.call(this)&&this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset)},t.prototype.attachControl=function(e,n,i,o){var a=this;i===void 0&&(i=!0),o===void 0&&(o=2);var s=arguments;n=ze.S0.BackCompatCameraNoPreventDefault(s),this._useCtrlForPanning=i,this._panningMouseButton=o,typeof s[0]=="boolean"&&(s.length>1&&(this._useCtrlForPanning=s[1]),s.length>2&&(this._panningMouseButton=s[2])),this.inputs.attachElement(n),this._reset=function(){a.inertialAlphaOffset=0,a.inertialBetaOffset=0,a.inertialRadiusOffset=0,a.inertialPanningX=0,a.inertialPanningY=0}},t.prototype.detachControl=function(){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),this._progressiveRestore){var e=this._scene.getEngine().getDeltaTime()/1e3,n=1-Math.pow(2,-e/this.restoreStateInterpolationFactor);this.setTarget(_.Pq.Lerp(this.getTarget(),this._storedTarget,n)),_.PT.RotationAlphaBetaGammaToRef(this._storedAlpha,this._storedBeta,0,_.AA.Quaternion[0]),_.PT.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,_.AA.Quaternion[1]),_.PT.SlerpToRef(_.AA.Quaternion[1],_.AA.Quaternion[0],n,_.AA.Quaternion[2]),_.AA.Quaternion[2].normalize(),_.AA.Quaternion[2].toAlphaBetaGammaToRef(_.AA.Vector3[0]),this.alpha=_.AA.Vector3[0].x,this.beta=_.AA.Vector3[0].y,this.radius+=(this._storedRadius-this.radius)*n,_.I9.LerpToRef(this.targetScreenOffset,this._storedTargetScreenOffset,n,this.targetScreenOffset),(_.Pq.DistanceSquared(this.getTarget(),this._storedTarget)<pt.bH&&_.AA.Quaternion[2].equalsWithEpsilon(_.AA.Quaternion[0])&&Math.pow(this._storedRadius-this.radius,2)<pt.bH&&_.I9.Distance(this.targetScreenOffset,this._storedTargetScreenOffset)<pt.bH||this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0||this.inertialPanningX!==0||this.inertialPanningY!==0)&&(this._progressiveRestore=!1)}if(this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0){var i=this.invertRotation?-1:1,o=this._calculateHandednessMultiplier(),a=this.inertialAlphaOffset*o;this.beta<0&&(a*=-1),this.alpha+=a*i,this.beta+=this.inertialBetaOffset*i,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<pt.bH&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<pt.bH&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*pt.bH&&(this.inertialRadiusOffset=0)}if(this.inertialPanningX!==0||this.inertialPanningY!==0){var s=new _.Pq(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);if(this._viewMatrix.invertToRef(this._cameraTransformMatrix),s.multiplyInPlace(this.panningAxis),_.Pq.TransformNormalToRef(s,this._cameraTransformMatrix,this._transformedDirection),this.mapPanning){var l=this.upVector,c=_.Pq.CrossToRef(this._transformedDirection,l,this._transformedDirection);_.Pq.CrossToRef(l,c,this._transformedDirection)}else this.panningAxis.y||(this._transformedDirection.y=0);if(!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),_.Pq.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else{if(this.parent){var u=_.AA.Matrix[0];this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.transposeToRef(u),_.Pq.TransformCoordinatesToRef(this._transformedDirection,u,this._transformedDirection)}this._target.addInPlace(this._transformedDirection)}this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*pt.bH&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*pt.bH&&(this.inertialPanningY=0)}this._checkLimits(),r.prototype._checkInputs.call(this)}},t.prototype._checkLimits=function(){this.lowerBetaLimit===null||this.lowerBetaLimit===void 0?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),this.upperBetaLimit===null||this.upperBetaLimit===void 0?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit!==null&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit,this.inertialRadiusOffset=0),this.upperRadiusLimit!==null&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),this._upVector.x===0&&this._upVector.y===1&&this._upVector.z===0||_.Pq.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),this.radius===0&&(this.radius=1e-4);var e=this.alpha;this._computationVector.x===0&&this._computationVector.z===0?this.alpha=Math.PI/2:this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha);var n=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*n*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()},t.prototype.setPosition=function(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())},t.prototype.setTarget=function(e,n,i,o){var a;if(n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=!1),o=(a=this.overrideCloneAlphaBetaRadius)!==null&&a!==void 0?a:o,e.computeWorldMatrix)n&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.centerWorld.clone():this._targetBoundingCenter=null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var s=e,l=this._getTargetPosition();if(l&&!i&&l.equals(s))return;this._targetHost=null,this._target=s,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}o||this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),n=Math.sin(this.alpha),i=Math.cos(this.beta),o=Math.sin(this.beta);o===0&&(o=1e-4),this.radius===0&&(this.radius=1e-4);var a=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*o,this.radius*i,this.radius*n*o),this._upVector.x===0&&this._upVector.y===1&&this._upVector.z===0||_.Pq.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),a.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var s=this.getScene().collisionCoordinator;this._collider||(this._collider=s.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,s.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var l=this.upVector;this.allowUpsideDown&&o<0&&(l=l.negate()),this._computeViewMatrix(this._position,a,l),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=a,this._viewMatrix},t.prototype.zoomOn=function(e,n){n===void 0&&(n=!1),e=e||this.getScene().meshes;var i=xe.MinMax(e),o=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);o=Math.max(Math.min(o,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=o*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:o},n)},t.prototype.focusOn=function(e,n){var i,o;if(n===void 0&&(n=!1),e.min===void 0){var a=e||this.getScene().meshes;i=xe.MinMax(a),o=_.Pq.Distance(i.min,i.max)}else i=e,o=e.distance;this._target=xe.Center(i),n||(this.maxZ=2*o)},t.prototype.createRigCamera=function(e,n){var i=0;switch(this.cameraRigMode){case Pt.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Pt.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Pt.RIG_MODE_STEREOSCOPIC_INTERLACED:case Pt.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(n===0?1:-1);break;case Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(n===0?-1:1)}var o=new t(e,this.alpha+i,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o.isRigCamera=!0,o.rigParent=this,o.upVector=this.upVector,o.mode=this.mode,o.orthoLeft=this.orthoLeft,o.orthoRight=this.orthoRight,o.orthoBottom=this.orthoBottom,o.orthoTop=this.orthoTop,o},t.prototype._updateRigCameras=function(){var e=this._rigCameras[0],n=this._rigCameras[1];switch(e.beta=n.beta=this.beta,this.cameraRigMode){case Pt.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Pt.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Pt.RIG_MODE_STEREOSCOPIC_INTERLACED:case Pt.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:e.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}r.prototype._updateRigCameras.call(this)},t.prototype._calculateLowerRadiusFromModelBoundingSphere=function(e,n,i){i===void 0&&(i=1);var o=_.Pq.Distance(e,n),a=this.getScene().getEngine().getAspectRatio(this),s=Math.tan(this.fov/2),l=s*a,c=.5*o*i,u=c*Math.sqrt(1+1/(l*l)),d=c*Math.sqrt(1+1/(s*s));return Math.max(u,d)},t.prototype.dispose=function(){this.inputs.clear(),r.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"ArcRotateCamera"},(0,A.Cg)([(0,V.lK)()],t.prototype,"alpha",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"beta",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"radius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"overrideCloneAlphaBetaRadius",void 0),(0,A.Cg)([(0,V.P_)("target")],t.prototype,"_target",void 0),(0,A.Cg)([(0,V.xG)("targetHost")],t.prototype,"_targetHost",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"inertialAlphaOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"inertialBetaOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"inertialRadiusOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lowerAlphaLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"upperAlphaLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lowerBetaLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"upperBetaLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lowerRadiusLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"upperRadiusLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"inertialPanningX",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"inertialPanningY",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"pinchToPanMaxDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"panningDistanceLimit",void 0),(0,A.Cg)([(0,V.P_)()],t.prototype,"panningOriginTarget",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"panningInertia",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"zoomToMouseLocation",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"zoomOnFactor",void 0),(0,A.Cg)([(0,V.WM)()],t.prototype,"targetScreenOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"allowUpsideDown",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"useInputToRestoreState",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"restoreStateInterpolationFactor",void 0),t}(kr);(0,j.Y5)("BABYLON.ArcRotateCamera",zr),At.AddNodeConstructor("DeviceOrientationCamera",function(r,t){return function(){return new Ds(r,_.Pq.Zero(),t)}});var Ds=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o._tmpDragQuaternion=new _.PT,o._disablePointerInputWhenUsingDeviceOrientation=!0,o._dragFactor=0,o._quaternionCache=new _.PT,o.inputs.addDeviceOrientation(),o.inputs._deviceOrientationInput&&o.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function(){o._disablePointerInputWhenUsingDeviceOrientation&&o.inputs._mouseInput&&(o.inputs._mouseInput._allowCameraRotation=!1,o.inputs._mouseInput.onPointerMovedObservable.add(function(a){o._dragFactor!=0&&(o._initialQuaternion||(o._initialQuaternion=new _.PT),_.PT.FromEulerAnglesToRef(0,a.offsetX*o._dragFactor,0,o._tmpDragQuaternion),o._initialQuaternion.multiplyToRef(o._tmpDragQuaternion,o._initialQuaternion))}))}),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"disablePointerInputWhenUsingDeviceOrientation",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e},enumerable:!1,configurable:!0}),t.prototype.enableHorizontalDragging=function(e){e===void 0&&(e=1/300),this._dragFactor=e},t.prototype.getClassName=function(){return"DeviceOrientationCamera"},t.prototype._checkInputs=function(){r.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},t.prototype.resetToCurrentRotation=function(e){var n=this;e===void 0&&(e=Qn._0.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new _.PT),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach(function(i){e[i]?n._initialQuaternion[i]*=-1:n._initialQuaternion[i]=0}),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(_r),pm=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t.prototype.addKeyboard=function(){return this.add(new Uc),this},t.prototype.addMouse=function(){return this.add(new Gc),this},t}(Ca),_m=function(r){function t(e,n,i,o){o===void 0&&(o=!0);var a=r.call(this,e,n,i,o)||this;return a.ellipsoid=new _.Pq(1,1,1),a.ellipsoidOffset=new _.Pq(0,0,0),a.checkCollisions=!1,a.applyGravity=!1,a.cameraDirection=_.Pq.Zero(),a._trackRoll=0,a.rollCorrect=100,a.bankedTurn=!1,a.bankedTurnLimit=Math.PI/2,a.bankedTurnMultiplier=1,a._needMoveForGravity=!1,a._oldPosition=_.Pq.Zero(),a._diffPosition=_.Pq.Zero(),a._newPosition=_.Pq.Zero(),a._collisionMask=-1,a._onCollisionPositionChange=function(s,l,c){var u;c===void 0&&(c=null),u=l,a._newPosition.copyFrom(u),a._newPosition.subtractToRef(a._oldPosition,a._diffPosition),a._diffPosition.length()>Be.$.CollisionsEpsilon&&(a.position.addInPlace(a._diffPosition),a.onCollide&&c&&a.onCollide(c))},a.inputs=new pm(a),a.inputs.addKeyboard().addMouse(),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var n=this.inputs.attached.mouse;n&&(n.angularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysForward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysForward:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysForward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysBackward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysBackward:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysBackward=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysUp=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysDown=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var n=this.inputs.attached.keyboard;n&&(n.keysRight=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,n){n=ze.S0.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(n)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new _.Pq(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?_.Pq.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var n=this.getScene().collisionCoordinator;this._collider||(this._collider=n.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),n.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=_.Pq.Zero(),this._transformedDirection=_.Pq.Zero()),this.inputs.checkInputs(),r.prototype._checkInputs.call(this)},Object.defineProperty(t.prototype,"needMoveForGravity",{get:function(){return this._needMoveForGravity},set:function(e){this._needMoveForGravity=e},enumerable:!1,configurable:!0}),t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):r.prototype._updatePosition.call(this)},t.prototype.restoreRoll=function(e){var n=this._trackRoll,i=n-this.rotation.z;Math.abs(i)>=.001&&(this.rotation.z+=i/e,Math.abs(n-this.rotation.z)<=.001&&(this.rotation.z=n))},t.prototype.dispose=function(){this.inputs.clear(),r.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FlyCamera"},(0,A.Cg)([(0,V.P_)()],t.prototype,"ellipsoid",void 0),(0,A.Cg)([(0,V.P_)()],t.prototype,"ellipsoidOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"checkCollisions",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"applyGravity",void 0),t}(kr);(0,j.Y5)("BABYLON.FlyCamera",_m);var mm=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t.prototype.addKeyboard=function(){return this.add(new kc),this},t.prototype.addMouseWheel=function(){return this.add(new zc),this},t.prototype.addPointers=function(){return this.add(new Wc),this},t.prototype.addVRDeviceOrientation=function(){return O.V.Warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(Ca);At.AddNodeConstructor("FollowCamera",function(r,t){return function(){return new nu(r,_.Pq.Zero(),t)}}),At.AddNodeConstructor("ArcFollowCamera",function(r,t){return function(){return new iu(r,0,0,1,null,t)}});var eu,tu,nu=function(r){function t(e,n,i,o){o===void 0&&(o=null);var a=r.call(this,e,n,i)||this;return a.radius=12,a.lowerRadiusLimit=null,a.upperRadiusLimit=null,a.rotationOffset=0,a.lowerRotationOffsetLimit=null,a.upperRotationOffsetLimit=null,a.heightOffset=4,a.lowerHeightOffsetLimit=null,a.upperHeightOffsetLimit=null,a.cameraAcceleration=.05,a.maxCameraSpeed=20,a.lockedTarget=o,a.inputs=new mm(a),a.inputs.addKeyboard().addMouseWheel().addPointers(),a}return(0,A.C6)(t,r),t.prototype._follow=function(e){if(e){var n=_.AA.Matrix[0];e.absoluteRotationQuaternion.toRotationMatrix(n);var i=Math.atan2(n.m[8],n.m[10]),o=ze.S0.ToRadians(this.rotationOffset)+i,a=e.getAbsolutePosition(),s=a.x+Math.sin(o)*this.radius,l=a.z+Math.cos(o)*this.radius,c=s-this.position.x,u=a.y+this.heightOffset-this.position.y,d=l-this.position.z,h=c*this.cameraAcceleration*2,p=u*this.cameraAcceleration,m=d*this.cameraAcceleration*2;(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(p>this.maxCameraSpeed||p<-this.maxCameraSpeed)&&(p=p<1?-this.maxCameraSpeed:this.maxCameraSpeed),(m>this.maxCameraSpeed||m<-this.maxCameraSpeed)&&(m=m<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new _.Pq(this.position.x+h,this.position.y+p,this.position.z+m),this.setTarget(a)}},t.prototype.attachControl=function(e,n){n=ze.S0.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(n),this._reset=function(){}},t.prototype.detachControl=function(){this.inputs.detachElement(),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),r.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){this.lowerRadiusLimit!==null&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit!==null&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),this.lowerHeightOffsetLimit!==null&&this.heightOffset<this.lowerHeightOffsetLimit&&(this.heightOffset=this.lowerHeightOffsetLimit),this.upperHeightOffsetLimit!==null&&this.heightOffset>this.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),this.lowerRotationOffsetLimit!==null&&this.rotationOffset<this.lowerRotationOffsetLimit&&(this.rotationOffset=this.lowerRotationOffsetLimit),this.upperRotationOffsetLimit!==null&&this.rotationOffset>this.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},(0,A.Cg)([(0,V.lK)()],t.prototype,"radius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lowerRadiusLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"upperRadiusLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"rotationOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lowerRotationOffsetLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"upperRotationOffsetLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"heightOffset",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lowerHeightOffsetLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"upperHeightOffsetLimit",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"cameraAcceleration",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"maxCameraSpeed",void 0),(0,A.Cg)([(0,V.xG)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(kr),iu=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e,_.Pq.Zero(),s)||this;return l.alpha=n,l.beta=i,l.radius=o,l._cartesianCoordinates=_.Pq.Zero(),l.setMeshTarget(a),l}return(0,A.C6)(t,r),t.prototype.setMeshTarget=function(e){this._meshTarget=e,this._follow()},t.prototype._follow=function(){if(this._meshTarget){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this._meshTarget.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){r.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return"ArcFollowCamera"},t}(kr);(0,j.Y5)("BABYLON.FollowCamera",nu),(0,j.Y5)("BABYLON.ArcFollowCamera",iu),function(r){r[r.A=0]="A",r[r.B=1]="B",r[r.X=2]="X",r[r.Y=3]="Y",r[r.LB=4]="LB",r[r.RB=5]="RB",r[r.Back=8]="Back",r[r.Start=9]="Start",r[r.LeftStick=10]="LeftStick",r[r.RightStick=11]="RightStick"}(eu||(eu={})),function(r){r[r.Up=12]="Up",r[r.Down=13]="Down",r[r.Left=14]="Left",r[r.Right=15]="Right"}(tu||(tu={}));var ru,ou,gm=function(r){function t(e,n,i,o){o===void 0&&(o=!1);var a=r.call(this,e,n,i,0,1,2,3)||this;return a._leftTrigger=0,a._rightTrigger=0,a.onButtonDownObservable=new K.cP,a.onButtonUpObservable=new K.cP,a.onPadDownObservable=new K.cP,a.onPadUpObservable=new K.cP,a._buttonA=0,a._buttonB=0,a._buttonX=0,a._buttonY=0,a._buttonBack=0,a._buttonStart=0,a._buttonLB=0,a._buttonRB=0,a._buttonLeftStick=0,a._buttonRightStick=0,a._dPadUp=0,a._dPadDown=0,a._dPadLeft=0,a._dPadRight=0,a._isXboxOnePad=!1,a.type=Ii.XBOX,a._isXboxOnePad=o,a}return(0,A.C6)(t,r),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,n,i){return e!==n&&(e===1&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),e===0&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,n,i){return e!==n&&(e===1&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),e===0&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,2)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,3)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,9)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,8)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,4)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,5)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,10)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,11)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,12)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,13)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,14)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,15)},enumerable:!1,configurable:!0}),t.prototype.update=function(){r.prototype.update.call(this),this._isXboxOnePad,this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(Ii);(function(r){r[r.Cross=0]="Cross",r[r.Circle=1]="Circle",r[r.Square=2]="Square",r[r.Triangle=3]="Triangle",r[r.L1=4]="L1",r[r.R1=5]="R1",r[r.Share=8]="Share",r[r.Options=9]="Options",r[r.LeftStick=10]="LeftStick",r[r.RightStick=11]="RightStick"})(ru||(ru={})),function(r){r[r.Up=12]="Up",r[r.Down=13]="Down",r[r.Left=14]="Left",r[r.Right=15]="Right"}(ou||(ou={}));var vm=function(r){function t(e,n,i){var o=r.call(this,e.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),n,i,0,1,2,3)||this;return o._leftTrigger=0,o._rightTrigger=0,o.onButtonDownObservable=new K.cP,o.onButtonUpObservable=new K.cP,o.onPadDownObservable=new K.cP,o.onPadUpObservable=new K.cP,o._buttonCross=0,o._buttonCircle=0,o._buttonSquare=0,o._buttonTriangle=0,o._buttonShare=0,o._buttonOptions=0,o._buttonL1=0,o._buttonR1=0,o._buttonLeftStick=0,o._buttonRightStick=0,o._dPadUp=0,o._dPadDown=0,o._dPadLeft=0,o._dPadRight=0,o.type=Ii.DUALSHOCK,o}return(0,A.C6)(t,r),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!1,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,n,i){return e!==n&&(e===1&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),e===0&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,n,i){return e!==n&&(e===1&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),e===0&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,"buttonCross",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonCircle",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonSquare",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,2)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonTriangle",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,3)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonOptions",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,9)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonShare",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,8)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonL1",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,4)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonR1",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,5)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,10)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,11)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,12)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,13)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,14)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,15)},enumerable:!1,configurable:!0}),t.prototype.update=function(){r.prototype.update.call(this),this.buttonCross=this.browserGamepad.buttons[0].value,this.buttonCircle=this.browserGamepad.buttons[1].value,this.buttonSquare=this.browserGamepad.buttons[2].value,this.buttonTriangle=this.browserGamepad.buttons[3].value,this.buttonL1=this.browserGamepad.buttons[4].value,this.buttonR1=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonShare=this.browserGamepad.buttons[8].value,this.buttonOptions=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(Ii),ym=function(){function r(t){var e=this;if(this._scene=t,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new K.cP,(0,bi.BA)()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator&&navigator.getGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new K.cP(function(i){for(var o in e._babylonGamepads){var a=e._babylonGamepads[o];a&&a._isConnected&&e.onGamepadConnectedObservable.notifyObserver(i,a)}}),this._onGamepadConnectedEvent=function(i){var o,a=i.gamepad;a.index in e._babylonGamepads&&e._babylonGamepads[a.index].isConnected||(e._babylonGamepads[a.index]?((o=e._babylonGamepads[a.index]).browserGamepad=a,o._isConnected=!0):o=e._addNewGamepad(a),e.onGamepadConnectedObservable.notifyObservers(o),e._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(i){var o=i.gamepad;for(var a in e._babylonGamepads)if(e._babylonGamepads[a].index===o.index){var s=e._babylonGamepads[a];s._isConnected=!1,e.onGamepadDisconnectedObservable.notifyObservers(s),s.dispose&&s.dispose();break}},this._gamepadSupport)if(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported){var n=this._scene?this._scene.getEngine().getHostWindow():window;n&&(n.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),n.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1))}else this._startMonitoringGamepads()}return Object.defineProperty(r.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!1,configurable:!0}),r.prototype.getGamepadByType=function(t){t===void 0&&(t=Ii.XBOX);for(var e=0,n=this._babylonGamepads;e<n.length;e++){var i=n[e];if(i&&i.type===t)return i}return null},r.prototype.dispose=function(){this._gamepadEventSupported&&(this._onGamepadConnectedEvent&&window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent),this._onGamepadDisconnectedEvent&&window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent),this._onGamepadConnectedEvent=null,this._onGamepadDisconnectedEvent=null),this._babylonGamepads.forEach(function(t){t.dispose()}),this.onGamepadConnectedObservable.clear(),this.onGamepadDisconnectedObservable.clear(),this._oneGamepadConnected=!1,this._stopMonitoringGamepads(),this._babylonGamepads=[]},r.prototype._addNewGamepad=function(t){var e;this._oneGamepadConnected||(this._oneGamepadConnected=!0);var n=t.id.search("054c")!==-1&&t.id.search("0ce6")===-1,i=t.id.search("Xbox One")!==-1;return e=i||t.id.search("Xbox 360")!==-1||t.id.search("xinput")!==-1||t.id.search("045e")!==-1&&t.id.search("Surface Dock")===-1?new gm(t.id,t.index,t,i):n?new vm(t.id,t.index,t):new hm(t.id,t.index,t),this._babylonGamepads[e.index]=e,e},r.prototype._startMonitoringGamepads=function(){this._isMonitoring||(this._isMonitoring=!0,this._checkGamepadsStatus())},r.prototype._stopMonitoringGamepads=function(){this._isMonitoring=!1},r.prototype._checkGamepadsStatus=function(){var t=this;for(var e in this._updateGamepadObjects(),this._babylonGamepads){var n=this._babylonGamepads[e];if(n&&n.isConnected)try{n.update()}catch{this._loggedErrors.indexOf(n.index)===-1&&(ze.S0.Warn("Error updating gamepad ".concat(n.id)),this._loggedErrors.push(n.index))}}this._isMonitoring&&Be.$.QueueNewFrame(function(){t._checkGamepadsStatus()})},r.prototype._updateGamepadObjects=function(){for(var t=navigator.getGamepads?navigator.getGamepads():[],e=0;e<t.length;e++){var n=t[e];if(n)if(this._babylonGamepads[n.index])this._babylonGamepads[e].browserGamepad=n,this._babylonGamepads[e].isConnected||(this._babylonGamepads[e]._isConnected=!0,this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[e]));else{var i=this._addNewGamepad(n);this.onGamepadConnectedObservable.notifyObservers(i)}}},r}();Object.defineProperty(ke.Z.prototype,"gamepadManager",{get:function(){if(!this._gamepadManager){this._gamepadManager=new ym(this);var r=this._getComponent(lt.v.NAME_GAMEPAD);r||(r=new bm(this),this._addComponent(r))}return this._gamepadManager},enumerable:!0,configurable:!0}),Ra.prototype.addGamepad=function(){return this.add(new Kc),this},Os.prototype.addGamepad=function(){return this.add(new Lc),this};var bm=function(){function r(t){this.name=lt.v.NAME_GAMEPAD,this.scene=t}return r.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(lt.v.STEP_BEFORECAMERAUPDATE_GAMEPAD,this,this._beforeCameraUpdate)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){var t=this.scene._gamepadManager;t&&(t.dispose(),this.scene._gamepadManager=null)},r.prototype._beforeCameraUpdate=function(){var t=this.scene._gamepadManager;t&&t._isMonitoring&&t._checkGamepadsStatus()},r}();At.AddNodeConstructor("FreeCamera",function(r,t){return function(){return new So(r,_.Pq.Zero(),t)}});var So=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.inputs.addGamepad(),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0},set:function(e){var n=this.inputs.attached.gamepad;n&&(n.gamepadAngularSensibility=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0},set:function(e){var n=this.inputs.attached.gamepad;n&&(n.gamepadMoveSensibility=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t}($c);Pt._CreateDefaultParsedCamera=function(r,t){return new So(r,_.Pq.Zero(),t)},At.AddNodeConstructor("GamepadCamera",function(r,t){return function(){return new Ns(r,_.Pq.Zero(),t)}});var Ns=function(r){function t(e,n,i){return r.call(this,e,n,i)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GamepadCamera"},t}(So),ro=L(73441),_t=L(30622),au=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e,"anaglyph",null,["leftSampler"],n,i[1],o,a,s)||this;return l._passedProcess=i[0]._rigPostProcess,l.onApplyObservable.add(function(c){c.setTextureFromPostProcess("leftSampler",l._passedProcess)}),l}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"AnaglyphPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,89111)))):n.push(Promise.resolve().then(L.bind(L,10534))),r.prototype._gatherImports.call(this,e,n)},t}(_t.w);function Ia(r){r._rigCameras[0]._rigPostProcess=new ro.v(r.name+"_passthru",1,r._rigCameras[0]),r._rigCameras[1]._rigPostProcess=new au(r.name+"_anaglyph",1,r._rigCameras)}(0,j.Y5)("BABYLON.AnaglyphPostProcess",au),At.AddNodeConstructor("AnaglyphArcRotateCamera",function(r,t,e){return function(){return new Tm(r,0,0,1,_.Pq.Zero(),e.interaxial_distance,t)}});var Tm=function(r){function t(e,n,i,o,a,s,l){var c=r.call(this,e,n,i,o,a,l)||this;return c._setRigMode=function(){return Ia(c)},c.interaxialDistance=s,c.setCameraRigMode(Pt.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:s}),c}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(zr);At.AddNodeConstructor("AnaglyphFreeCamera",function(r,t,e){return function(){return new Sm(r,_.Pq.Zero(),e.interaxial_distance,t)}});var Sm=function(r){function t(e,n,i,o){var a=r.call(this,e,n,o)||this;return a._setRigMode=function(){return Ia(a)},a.interaxialDistance=i,a.setCameraRigMode(Pt.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),a}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(_r);At.AddNodeConstructor("AnaglyphGamepadCamera",function(r,t,e){return function(){return new Em(r,_.Pq.Zero(),e.interaxial_distance,t)}});var Em=function(r){function t(e,n,i,o){var a=r.call(this,e,n,o)||this;return a._setRigMode=function(){return Ia(a)},a.interaxialDistance=i,a.setCameraRigMode(Pt.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),a}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(Ns);At.AddNodeConstructor("AnaglyphUniversalCamera",function(r,t,e){return function(){return new xm(r,_.Pq.Zero(),e.interaxial_distance,t)}});var xm=function(r){function t(e,n,i,o){var a=r.call(this,e,n,o)||this;return a._setRigMode=function(){return Ia(a)},a.interaxialDistance=i,a.setCameraRigMode(Pt.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),a}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(So),Gt=L(98519);Gt.l.ShadersStore.stereoscopicInterlacePixelShader=`const vec3 TWO=vec3(2.0,2.0,2.0);varying vec2 vUV;uniform sampler2D camASampler;uniform sampler2D textureSampler;uniform vec2 stepSize;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{bool useCamA;bool useCamB;vec2 texCoord1;vec2 texCoord2;vec3 frag1;vec3 frag2;
|
||
#ifdef IS_STEREOSCOPIC_HORIZ
|
||
useCamB=vUV.x>0.5;useCamA=!useCamB;texCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);texCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);
|
||
#else
|
||
#ifdef IS_STEREOSCOPIC_INTERLACED
|
||
float rowNum=floor(vUV.y/stepSize.y);useCamA=mod(rowNum,2.0)==1.0;useCamB=mod(rowNum,2.0)==0.0;texCoord1=vec2(vUV.x,vUV.y);texCoord2=vec2(vUV.x,vUV.y);
|
||
#else
|
||
useCamB=vUV.y>0.5;useCamA=!useCamB;texCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);texCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);
|
||
#endif
|
||
#endif
|
||
if (useCamB){frag1=texture2D(textureSampler,texCoord1).rgb;frag2=texture2D(textureSampler,texCoord2).rgb;}else if (useCamA){frag1=texture2D(camASampler ,texCoord1).rgb;frag2=texture2D(camASampler ,texCoord2).rgb;}else {discard;}
|
||
gl_FragColor=vec4((frag1+frag2)/TWO,1.0);}
|
||
`;var Pm=function(r){function t(e,n,i,o,a,s,l){var c=r.call(this,e,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],a,s,l,o?"#define IS_STEREOSCOPIC_INTERLACED 1":i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return c._passedProcess=n[0]._rigPostProcess,c._stepSize=new _.I9(1/c.width,1/c.height),c.onSizeChangedObservable.add(function(){c._stepSize=new _.I9(1/c.width,1/c.height)}),c.onApplyObservable.add(function(u){u.setTextureFromPostProcess("camASampler",c._passedProcess),u.setFloat2("stepSize",c._stepSize.x,c._stepSize.y)}),c}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcessI"},t}(_t.w),eE=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],o,a,s,i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=n[0]._rigPostProcess,l._stepSize=new _.I9(1/l.width,1/l.height),l.onSizeChangedObservable.add(function(){l._stepSize=new _.I9(1/l.width,1/l.height)}),l.onApplyObservable.add(function(c){c.setTextureFromPostProcess("camASampler",l._passedProcess),c.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)}),l}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcess"},t}(_t.w);function Ma(r){var t=r.cameraRigMode===Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||r.cameraRigMode===Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,e=r.cameraRigMode===Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;r.cameraRigMode===Pt.RIG_MODE_STEREOSCOPIC_INTERLACED?(r._rigCameras[0]._rigPostProcess=new ro.v(r.name+"_passthru",1,r._rigCameras[0]),r._rigCameras[1]._rigPostProcess=new Pm(r.name+"_stereoInterlace",r._rigCameras,!1,!0)):(r._rigCameras[e?1:0].viewport=new Br.L(0,0,t?.5:1,t?1:.5),r._rigCameras[e?0:1].viewport=new Br.L(t?.5:0,t?0:.5,t?.5:1,t?1:.5))}At.AddNodeConstructor("StereoscopicArcRotateCamera",function(r,t,e){return function(){return new Am(r,0,0,1,_.Pq.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Am=function(r){function t(e,n,i,o,a,s,l,c){var u=r.call(this,e,n,i,o,a,c)||this;return u._setRigMode=function(){return Ma(u)},u.interaxialDistance=s,u.isStereoscopicSideBySide=l,u.setCameraRigMode(l?Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Pt.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:s}),u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(zr);At.AddNodeConstructor("StereoscopicFreeCamera",function(r,t,e){return function(){return new Cm(r,_.Pq.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Cm=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,a)||this;return s._setRigMode=function(){return Ma(s)},s.interaxialDistance=i,s.isStereoscopicSideBySide=o,s.setCameraRigMode(o?Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Pt.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),s}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(_r);At.AddNodeConstructor("StereoscopicGamepadCamera",function(r,t,e){return function(){return new Rm(r,_.Pq.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Rm=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,a)||this;return s._setRigMode=function(){return Ma(s)},s.interaxialDistance=i,s.isStereoscopicSideBySide=o,s.setCameraRigMode(o?Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Pt.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),s}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(Ns);At.AddNodeConstructor("StereoscopicFreeCamera",function(r,t,e){return function(){return new Im(r,_.Pq.Zero(),e.interaxial_distance,e.isStereoscopicSideBySide,t)}});var Im=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,a)||this;return s._setRigMode=function(){return Ma(s)},s.interaxialDistance=i,s.isStereoscopicSideBySide=o,s.setCameraRigMode(o?Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Pt.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),s}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(So),tE=function(r){function t(e,n,i,o,a){o===void 0&&(o=1),a===void 0&&(a=.065);var s=r.call(this,e,n,i)||this;return s._distanceBetweenEyes=a,s._distanceToProjectionPlane=o,s.setCameraRigMode(Pt.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,{stereoHalfAngle:0}),s._cameraRigParams.stereoHalfAngle=0,s._cameraRigParams.interaxialDistance=a,s}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"distanceBetweenEyes",{get:function(){return this._distanceBetweenEyes},set:function(e){this._distanceBetweenEyes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"distanceToProjectionPlane",{get:function(){return this._distanceToProjectionPlane},set:function(e){this._distanceToProjectionPlane=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t.prototype.createRigCamera=function(e){var n=new kr(e,_.Pq.Zero(),this.getScene()),i=new jt("tm_"+e,this.getScene());return n.parent=i,i.setPivotMatrix(_.uq.Identity(),!1),n.isRigCamera=!0,n.rigParent=this,n},t.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++){var n=this._rigCameras[e];n.minZ=this.minZ,n.maxZ=this.maxZ,n.fov=this.fov,n.upVector.copyFrom(this.upVector),n.rotationQuaternion?n.rotationQuaternion.copyFrom(this.rotationQuaternion):n.rotation.copyFrom(this.rotation),this._updateCamera(this._rigCameras[e],e)}},t.prototype._updateCamera=function(e,n){var i=this.distanceBetweenEyes/2,o=i/this.distanceToProjectionPlane;e.position.copyFrom(this.position),e.position.addInPlaceFromFloats(n===0?-i:i,0,-this._distanceToProjectionPlane);var a=e.parent,s=a.getPivotMatrix();s.setTranslationFromFloats(n===0?i:-i,0,0),s.setRowFromFloats(2,n===0?o:-o,0,1,0),a.setPivotMatrix(s,!1)},t.prototype._setRigMode=function(){this._rigCameras[0].viewport=new Br.L(0,0,.5,1),this._rigCameras[1].viewport=new Br.L(.5,0,.5,1);for(var e=0;e<this._rigCameras.length;e++)this._updateCamera(this._rigCameras[e],e)},t}(So);At.AddNodeConstructor("VirtualJoysticksCamera",function(r,t){return function(){return new Mm(r,_.Pq.Zero(),t)}});var Mm=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.inputs.addVirtualJoystick(),o}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(_r),Oa=function(){function r(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(r.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"leftHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return _.uq.Translation(t,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return _.uq.Translation(-t,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"leftPreViewMatrix",{get:function(){return _.uq.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rightPreViewMatrix",{get:function(){return _.uq.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),r.GetDefault=function(){var t=new r;return t.hResolution=1280,t.vResolution=800,t.hScreenSize=.149759993,t.vScreenSize=.0935999975,t.vScreenCenter=.0467999987,t.eyeToScreenDistance=.0410000011,t.lensSeparationDistance=.063500002,t.interpupillaryDistance=.064000003,t.distortionK=[1,.219999999,.239999995,0],t.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],t.postProcessScaleFactor=1.714605507808412,t.lensCenterOffset=.151976421,t},r}(),su=function(r){function t(e,n,i,o){var a=r.call(this,e,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,n,Ie.g.BILINEAR_SAMPLINGMODE)||this;return a._isRightEye=i,a._distortionFactors=o.distortionK,a._postProcessScaleFactor=o.postProcessScaleFactor,a._lensCenterOffset=o.lensCenterOffset,a.adaptScaleToCurrentViewport=!0,a.onSizeChangedObservable.add(function(){a._scaleIn=new _.I9(2,2/a.aspectRatio),a._scaleFactor=new _.I9(1/a._postProcessScaleFactor*.5,1/a._postProcessScaleFactor*.5*a.aspectRatio),a._lensCenter=new _.I9(a._isRightEye?.5-.5*a._lensCenterOffset:.5+.5*a._lensCenterOffset,.5)}),a.onApplyObservable.add(function(s){s.setFloat2("LensCenter",a._lensCenter.x,a._lensCenter.y),s.setFloat2("Scale",a._scaleFactor.x,a._scaleFactor.y),s.setFloat2("ScaleIn",a._scaleIn.x,a._scaleIn.y),s.setFloat4("HmdWarpParam",a._distortionFactors[0],a._distortionFactors[1],a._distortionFactors[2],a._distortionFactors[3])}),a}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VRDistortionCorrectionPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,15390)))):n.push(Promise.resolve().then(L.bind(L,67291))),r.prototype._gatherImports.call(this,e,n)},t}(_t.w);Gt.l.ShadersStore.vrMultiviewToSingleviewPixelShader=`precision mediump sampler2DArray;varying vec2 vUV;uniform sampler2DArray multiviewSampler;uniform int imageIndex;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{gl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));}`;var lu=function(){function r(t){t===void 0&&(t=30),this._enabled=!0,this._rollingFrameTime=new Om(t)}return r.prototype.sampleFrame=function(t){if(t===void 0&&(t=et.j.Now),this._enabled){if(this._lastFrameTimeMs!=null){var e=t-this._lastFrameTimeMs;this._rollingFrameTime.add(e)}this._lastFrameTimeMs=t}},Object.defineProperty(r.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"instantaneousFPS",{get:function(){var t=this._rollingFrameTime.history(0);return t===0?0:1e3/t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!1,configurable:!0}),r.prototype.enable=function(){this._enabled=!0},r.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null},Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),r.prototype.reset=function(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()},r}(),Om=function(){function r(t){this._samples=new Array(t),this.reset()}return r.prototype.add=function(t){var e;if(this.isSaturated()){var n=this._samples[this._pos];e=n-this.average,this.average-=e/(this._sampleCount-1),this._m2-=e*(n-this.average)}else this._sampleCount++;e=t-this.average,this.average+=e/this._sampleCount,this._m2+=e*(t-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=t,this._pos++,this._pos%=this._samples.length},r.prototype.history=function(t){if(t>=this._sampleCount||t>=this._samples.length)return 0;var e=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(e-t)]},r.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},r.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},r.prototype._wrapPosition=function(t){var e=this._samples.length;return(t%e+e)%e},r}(),Dm=L(26218),ea=L(90519);an.w.prototype.setAlphaMode=function(r,t){if(t===void 0&&(t=!1),this._alphaMode!==r){switch(r){case P.Y.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case P.Y.ALPHA_PREMULTIPLIED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_COMBINE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_SUBTRACT:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_INTERPOLATE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_SCREENMODE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ONEONE_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ALPHATOCOLOR:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_REVERSEONEMINUS:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE_MINUS_DST_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_SRC_DSTONEMINUSSRCALPHA:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ONEONE_ONEZERO:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_EXCLUSION:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_LAYER_ACCUMULATE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}t||(this.depthCullingState.depthMask=r===P.Y.ALPHA_DISABLE),this._alphaMode=r}else if(!t){var e=r===P.Y.ALPHA_DISABLE;this.depthCullingState.depthMask!==e&&(this.depthCullingState.depthMask=e)}};var cu=L(82345);function uu(r,t,e){r._onCanvasFocus=function(){r.onCanvasFocusObservable.notifyObservers(r)},r._onCanvasBlur=function(){r.onCanvasBlurObservable.notifyObservers(r)},r._onCanvasContextMenu=function(i){r.disableContextMenu&&i.preventDefault()},t.addEventListener("focus",r._onCanvasFocus),t.addEventListener("blur",r._onCanvasBlur),t.addEventListener("contextmenu",r._onCanvasContextMenu),r._onBlur=function(){r.disablePerformanceMonitorInBackground&&r.performanceMonitor.disable(),r._windowIsBackground=!0},r._onFocus=function(){r.disablePerformanceMonitorInBackground&&r.performanceMonitor.enable(),r._windowIsBackground=!1},r._onCanvasPointerOut=function(i){document.elementFromPoint(i.clientX,i.clientY)!==t&&r.onCanvasPointerOutObservable.notifyObservers(i)};var n=r.getHostWindow();n&&typeof n.addEventListener=="function"&&(n.addEventListener("blur",r._onBlur),n.addEventListener("focus",r._onFocus)),t.addEventListener("pointerout",r._onCanvasPointerOut),e.doNotHandleTouchAction||function(i){i&&i.setAttribute&&(i.setAttribute("touch-action","none"),i.style.touchAction="none",i.style.webkitTapHighlightColor="transparent")}(t),!Be.$.audioEngine&&e.audioEngine&&Be.$.AudioEngineFactory&&(Be.$.audioEngine=Be.$.AudioEngineFactory(r.getRenderingCanvas(),r.getAudioContext(),r.getAudioDestination())),(0,bi.Nf)()&&(r._onFullscreenChange=function(){r.isFullscreen=!!document.fullscreenElement,r.isFullscreen&&r._pointerLockRequested&&t&&Ls(t)},document.addEventListener("fullscreenchange",r._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",r._onFullscreenChange,!1),r._onPointerLockChange=function(){r.isPointerLock=document.pointerLockElement===t},document.addEventListener("pointerlockchange",r._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",r._onPointerLockChange,!1)),r.enableOfflineSupport=Be.$.OfflineProviderFactory!==void 0,r._deterministicLockstep=!!e.deterministicLockstep,r._lockstepMaxSteps=e.lockstepMaxSteps||0,r._timeStep=e.timeStep||1/60}function du(r,t){Ve.q.Instances.length===1&&Be.$.audioEngine&&(Be.$.audioEngine.dispose(),Be.$.audioEngine=null);var e=r.getHostWindow();e&&typeof e.removeEventListener=="function"&&(e.removeEventListener("blur",r._onBlur),e.removeEventListener("focus",r._onFocus)),t&&(t.removeEventListener("focus",r._onCanvasFocus),t.removeEventListener("blur",r._onCanvasBlur),t.removeEventListener("pointerout",r._onCanvasPointerOut),t.removeEventListener("contextmenu",r._onCanvasContextMenu)),(0,bi.Nf)()&&(document.removeEventListener("fullscreenchange",r._onFullscreenChange),document.removeEventListener("mozfullscreenchange",r._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",r._onFullscreenChange),document.removeEventListener("msfullscreenchange",r._onFullscreenChange),document.removeEventListener("pointerlockchange",r._onPointerLockChange),document.removeEventListener("mspointerlockchange",r._onPointerLockChange),document.removeEventListener("mozpointerlockchange",r._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",r._onPointerLockChange))}function hu(r){var t=document.createElement("span");t.textContent="Hg",t.style.font=r;var e=document.createElement("div");e.style.display="inline-block",e.style.width="1px",e.style.height="0px",e.style.verticalAlign="bottom";var n=document.createElement("div");n.style.whiteSpace="nowrap",n.appendChild(t),n.appendChild(e),document.body.appendChild(n);var i=0,o=0;try{o=e.getBoundingClientRect().top-t.getBoundingClientRect().top,e.style.verticalAlign="baseline",i=e.getBoundingClientRect().top-t.getBoundingClientRect().top}finally{document.body.removeChild(n)}return{ascent:i,height:o,descent:o-i}}function fu(r,t,e){return new Promise(function(n,i){var o=new Image;o.onload=function(){o.decode().then(function(){r.createImageBitmap(o,e).then(function(a){n(a)})})},o.onerror=function(){i("Error loading image ".concat(o.src))},o.src=t})}function pu(r,t,e,n){var i=r.createCanvas(e,n).getContext("2d");if(!i)throw new Error("Unable to get 2d context for resizeImageBitmap");return i.drawImage(t,0,0),i.getImageData(0,0,e,n).data}function _u(r){var t=r.requestFullscreen||r.webkitRequestFullscreen;t&&t.call(r)}function mu(){var r=document;document.exitFullscreen?document.exitFullscreen():r.webkitCancelFullScreen&&r.webkitCancelFullScreen()}function Ls(r){if(r.requestPointerLock){var t=r.requestPointerLock();t instanceof Promise?t.then(function(){r.focus()}).catch(function(){}):r.focus()}}function gu(){document.exitPointerLock&&document.exitPointerLock()}an.w.prototype.updateDynamicIndexBuffer=function(r,t,e){var n;this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(r),n=r.is32Bits?t instanceof Uint32Array?t:new Uint32Array(t):t instanceof Uint16Array?t:new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,n,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},an.w.prototype.updateDynamicVertexBuffer=function(r,t,e,n){this.bindArrayBuffer(r),e===void 0&&(e=0);var i=t.byteLength||t.length;n===void 0||n>=i&&e===0?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,e,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,e,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(e,e+n)):(t=t instanceof ArrayBuffer?new Uint8Array(t,e,n):new Uint8Array(t.buffer,t.byteOffset+e,n),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()},Be.$.prototype.displayLoadingUI=function(){if((0,bi.BA)()){var r=this.loadingScreen;r&&r.displayLoadingUI()}},Be.$.prototype.hideLoadingUI=function(){if((0,bi.BA)()){var r=this._loadingScreen;r&&r.hideLoadingUI()}},Object.defineProperty(Be.$.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=Be.$.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(r){this._loadingScreen=r},enumerable:!0,configurable:!0}),Object.defineProperty(Be.$.prototype,"loadingUIText",{set:function(r){this.loadingScreen.loadingUIText=r},enumerable:!0,configurable:!0}),Object.defineProperty(Be.$.prototype,"loadingUIBackgroundColor",{set:function(r){this.loadingScreen.loadingUIBackgroundColor=r},enumerable:!0,configurable:!0}),Be.$.prototype.getInputElement=function(){return this._renderingCanvas},Be.$.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},Be.$.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},Be.$.prototype.getAspectRatio=function(r,t){t===void 0&&(t=!1);var e=r.viewport;return this.getRenderWidth(t)*e.width/(this.getRenderHeight(t)*e.height)},Be.$.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},Be.$.prototype._verifyPointerLock=function(){var r;(r=this._onPointerLockChange)===null||r===void 0||r.call(this)},Be.$.prototype.setAlphaEquation=function(r){if(this._alphaEquation!==r){switch(r){case P.Y.ALPHA_EQUATION_ADD:this._alphaState.setAlphaEquationParameters(P.Y.GL_ALPHA_EQUATION_ADD,P.Y.GL_ALPHA_EQUATION_ADD);break;case P.Y.ALPHA_EQUATION_SUBSTRACT:this._alphaState.setAlphaEquationParameters(P.Y.GL_ALPHA_EQUATION_SUBTRACT,P.Y.GL_ALPHA_EQUATION_SUBTRACT);break;case P.Y.ALPHA_EQUATION_REVERSE_SUBTRACT:this._alphaState.setAlphaEquationParameters(P.Y.GL_ALPHA_EQUATION_REVERSE_SUBTRACT,P.Y.GL_ALPHA_EQUATION_REVERSE_SUBTRACT);break;case P.Y.ALPHA_EQUATION_MAX:this._alphaState.setAlphaEquationParameters(P.Y.GL_ALPHA_EQUATION_MAX,P.Y.GL_ALPHA_EQUATION_MAX);break;case P.Y.ALPHA_EQUATION_MIN:this._alphaState.setAlphaEquationParameters(P.Y.GL_ALPHA_EQUATION_MIN,P.Y.GL_ALPHA_EQUATION_MIN);break;case P.Y.ALPHA_EQUATION_DARKEN:this._alphaState.setAlphaEquationParameters(P.Y.GL_ALPHA_EQUATION_MIN,P.Y.GL_ALPHA_EQUATION_ADD)}this._alphaEquation=r}},Be.$.prototype.getInputElement=function(){return this._renderingCanvas},Be.$.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},Be.$.prototype.setDepthFunction=function(r){this._depthCullingState.depthFunc=r},Be.$.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(P.Y.GREATER)},Be.$.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(P.Y.GEQUAL)},Be.$.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(P.Y.LESS)},Be.$.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(P.Y.LEQUAL)},Be.$.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},Be.$.prototype.setDepthWrite=function(r){this._depthCullingState.depthMask=r},Be.$.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},Be.$.prototype.setStencilBuffer=function(r){this._stencilState.stencilTest=r},Be.$.prototype.getStencilMask=function(){return this._stencilState.stencilMask},Be.$.prototype.setStencilMask=function(r){this._stencilState.stencilMask=r},Be.$.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},Be.$.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},Be.$.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},Be.$.prototype.setStencilFunction=function(r){this._stencilState.stencilFunc=r},Be.$.prototype.setStencilFunctionReference=function(r){this._stencilState.stencilFuncRef=r},Be.$.prototype.setStencilFunctionMask=function(r){this._stencilState.stencilFuncMask=r},Be.$.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},Be.$.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},Be.$.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},Be.$.prototype.setStencilOperationFail=function(r){this._stencilState.stencilOpStencilFail=r},Be.$.prototype.setStencilOperationDepthFail=function(r){this._stencilState.stencilOpDepthFail=r},Be.$.prototype.setStencilOperationPass=function(r){this._stencilState.stencilOpStencilDepthPass=r},Be.$.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()},Be.$.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)},Be.$.prototype.setAlphaConstants=function(r,t,e,n){this._alphaState.setAlphaBlendConstants(r,t,e,n)},Be.$.prototype.getAlphaMode=function(){return this._alphaMode},Be.$.prototype.getAlphaEquation=function(){return this._alphaEquation},Be.$.prototype.getRenderPassNames=function(){return this._renderPassNames},Be.$.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]},Be.$.prototype.createRenderPassId=function(r){var t=++Be.$._RenderPassIdCounter;return this._renderPassNames[t]=r??"NONAME",t},Be.$.prototype.releaseRenderPassId=function(r){this._renderPassNames[r]=void 0;for(var t=0;t<this.scenes.length;++t)for(var e=this.scenes[t],n=0;n<e.meshes.length;++n){var i=e.meshes[n];if(i.subMeshes)for(var o=0;o<i.subMeshes.length;++o)i.subMeshes[o]._removeDrawWrapper(r)}},L(20833);var Mi=L(70511),Zt=function(r){function t(e,n,i,o){o===void 0&&(o=!1);var a=r.call(this,e,n,i,o)||this;if(a.customAnimationFrameRequester=null,a._performanceMonitor=new lu,a._drawCalls=new Mi.A,!e)return a;if(a._features.supportRenderPasses=!0,i=a._creationOptions,e.getContext){var s=e;a._sharedInit(s)}return a}return(0,A.C6)(t,r),Object.defineProperty(t,"NpmPackage",{get:function(){return Be.$.NpmPackage},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Version",{get:function(){return Be.$.Version},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Instances",{get:function(){return Ve.q.Instances},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedEngine",{get:function(){return Ve.q.LastCreatedEngine},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedScene",{get:function(){return Ve.q.LastCreatedScene},enumerable:!1,configurable:!0}),t.DefaultLoadingScreenFactory=function(e){return Be.$.DefaultLoadingScreenFactory(e)},Object.defineProperty(t.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!!t._RescalePostProcessFactory},enumerable:!1,configurable:!0}),t.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},Object.defineProperty(t.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!1,configurable:!0}),t.prototype._initGLContext=function(){r.prototype._initGLContext.call(this),this._rescalePostProcess=null},t.prototype._sharedInit=function(e){r.prototype._sharedInit.call(this,e),uu(this,e,this._creationOptions)},t.prototype.resizeImageBitmap=function(e,n,i){return pu(this,e,n,i)},t.prototype._createImageBitmapFromSource=function(e,n){return fu(this,e,n)},t.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},t.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&_u(this._renderingCanvas))},t.prototype.exitFullscreen=function(){this.isFullscreen&&mu()},t.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},t.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},t.prototype.setDirectViewport=function(e,n,i,o){var a=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,n,i,o),a},t.prototype.scissorClear=function(e,n,i,o,a){this.enableScissor(e,n,i,o),this.clear(a,!0,!0,!0),this.disableScissor()},t.prototype.enableScissor=function(e,n,i,o){var a=this._gl;a.enable(a.SCISSOR_TEST),a.scissor(e,n,i,o)},t.prototype.disableScissor=function(){var e=this._gl;e.disable(e.SCISSOR_TEST)},t.prototype._loadFileAsync=function(e,n,i){var o=this;return new Promise(function(a,s){o._loadFile(e,function(l){a(l)},void 0,n,i,function(l,c){s(c)})})},t.prototype.getVertexShaderSource=function(e){var n=this._gl.getAttachedShaders(e);return n?this._gl.getShaderSource(n[0]):null},t.prototype.getFragmentShaderSource=function(e){var n=this._gl.getAttachedShaders(e);return n?this._gl.getShaderSource(n[1]):null},Object.defineProperty(t.prototype,"framebufferDimensionsObject",{set:function(e){this._framebufferDimensionsObject=e,this._framebufferDimensionsObject&&this.onResizeObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),t.prototype._rebuildBuffers=function(){for(var e=0,n=this.scenes;e<n.length;e++)(a=n[e]).resetCachedMaterial(),a._rebuildGeometries();for(var i=0,o=this._virtualScenes;i<o.length;i++){var a;(a=o[i]).resetCachedMaterial(),a._rebuildGeometries()}r.prototype._rebuildBuffers.call(this)},t.prototype.getFontOffset=function(e){return hu(e)},t.prototype._cancelFrame=function(){if(this.customAnimationFrameRequester){if(this._frameHandler!==0){this._frameHandler=0;var e=this.customAnimationFrameRequester.cancelAnimationFrame;e&&e(this.customAnimationFrameRequester.requestID)}}else r.prototype._cancelFrame.call(this)},t.prototype._renderLoop=function(){if(this._frameHandler=0,!this._contextWasLost){var e=!0;(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0&&this._frameHandler===0&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))},t.prototype.enterPointerlock=function(){this._renderingCanvas&&Ls(this._renderingCanvas)},t.prototype.exitPointerlock=function(){gu()},t.prototype.beginFrame=function(){this._measureFps(),r.prototype.beginFrame.call(this)},t.prototype._deletePipelineContext=function(e){var n=e;n&&n.program&&n.transformFeedback&&(this.deleteTransformFeedback(n.transformFeedback),n.transformFeedback=null),r.prototype._deletePipelineContext.call(this,e)},t.prototype.createShaderProgram=function(e,n,i,o,a,s){s===void 0&&(s=null),a=a||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var l=r.prototype.createShaderProgram.call(this,e,n,i,o,a,s);return this.onAfterShaderCompilationObservable.notifyObservers(this),l},t.prototype._createShaderProgram=function(e,n,i,o,a){a===void 0&&(a=null);var s=o.createProgram();if(e.program=s,!s)throw new Error("Unable to create program");if(o.attachShader(s,n),o.attachShader(s,i),this.webGLVersion>1&&a){var l=this.createTransformFeedback();this.bindTransformFeedback(l),this.setTranformFeedbackVaryings(s,a),e.transformFeedback=l}return o.linkProgram(s),this.webGLVersion>1&&a&&this.bindTransformFeedback(null),e.context=o,e.vertexShader=n,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),s},t.prototype._releaseTexture=function(e){r.prototype._releaseTexture.call(this,e)},t.prototype._releaseRenderTargetWrapper=function(e){r.prototype._releaseRenderTargetWrapper.call(this,e),this.scenes.forEach(function(n){n.postProcesses.forEach(function(i){i._outputTexture===e&&(i._outputTexture=null)}),n.cameras.forEach(function(i){i._postProcesses.forEach(function(o){o&&o._outputTexture===e&&(o._outputTexture=null)})})})},t.prototype._rescaleTexture=function(e,n,i,o,a){var s=this;this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);var l=this.createRenderTargetTexture({width:n.width,height:n.height},{generateMipMaps:!1,type:P.Y.TEXTURETYPE_UNSIGNED_INT,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&t._RescalePostProcessFactory&&(this._rescalePostProcess=t._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;var c=function(){s._rescalePostProcess.onApply=function(h){h._bindTexture("textureSampler",e)};var d=i;d||(d=s.scenes[s.scenes.length-1]),d.postProcessManager.directRender([s._rescalePostProcess],l,!0),s._bindTextureDirectly(s._gl.TEXTURE_2D,n,!0),s._gl.copyTexImage2D(s._gl.TEXTURE_2D,0,o,0,0,n.width,n.height,0),s.unBindFramebuffer(l),l.dispose(),a&&a()},u=this._rescalePostProcess.getEffect();u?u.executeWhenCompiled(c):this._rescalePostProcess.onEffectCreatedObservable.addOnce(function(d){d.executeWhenCompiled(c)})}},t.prototype.wrapWebGLTexture=function(e,n,i,o,a){n===void 0&&(n=!1),i===void 0&&(i=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),o===void 0&&(o=0),a===void 0&&(a=0);var s=new ea.d(e,this._gl),l=new rn.h(this,0,!0);return l._hardwareTexture=s,l.baseWidth=o,l.baseHeight=a,l.width=o,l.height=a,l.isReady=!0,l.useMipMaps=n,this.updateTextureSamplingMode(i,l),l},t.prototype._uploadImageToTexture=function(e,n,i,o){i===void 0&&(i=0),o===void 0&&(o=0);var a=this._gl,s=this._getWebGLTextureType(e.type),l=this._getInternalFormat(e.format),c=this._getRGBABufferInternalSizedFormat(e.type,l),u=e.isCube?a.TEXTURE_CUBE_MAP:a.TEXTURE_2D;this._bindTextureDirectly(u,e,!0),this._unpackFlipY(e.invertY);var d=a.TEXTURE_2D;e.isCube&&(d=a.TEXTURE_CUBE_MAP_POSITIVE_X+i),a.texImage2D(d,o,c,l,s,n),this._bindTextureDirectly(u,null,!0)},t.prototype.updateTextureComparisonFunction=function(e,n){if(this.webGLVersion!==1){var i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),n===0?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,P.Y.LEQUAL),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,n),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),n===0?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,P.Y.LEQUAL),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,n),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=n}else O.V.Error("WebGL 1 does not support texture comparison.")},t.prototype.createInstancesBuffer=function(e){var n=this._gl.createBuffer();if(!n)throw new Error("Unable to create instance buffer");var i=new Dm.A(n);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i.references=1,i},t.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},t.prototype._clientWaitAsync=function(e,n,i){n===void 0&&(n=0),i===void 0&&(i=10);var o=this._gl;return new Promise(function(a,s){var l=function(){var c=o.clientWaitSync(e,n,0);c!=o.WAIT_FAILED?c!=o.TIMEOUT_EXPIRED?a():setTimeout(l,i):s()};l()})},t.prototype._readPixelsAsync=function(e,n,i,o,a,s,l){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");var c=this._gl,u=c.createBuffer();c.bindBuffer(c.PIXEL_PACK_BUFFER,u),c.bufferData(c.PIXEL_PACK_BUFFER,l.byteLength,c.STREAM_READ),c.readPixels(e,n,i,o,a,s,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);var d=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);return d?(c.flush(),this._clientWaitAsync(d,0,10).then(function(){return c.deleteSync(d),c.bindBuffer(c.PIXEL_PACK_BUFFER,u),c.getBufferSubData(c.PIXEL_PACK_BUFFER,0,l),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),c.deleteBuffer(u),l})):null},t.prototype.dispose=function(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),du(this,this._renderingCanvas),r.prototype.dispose.call(this)},t.ALPHA_DISABLE=P.Y.ALPHA_DISABLE,t.ALPHA_ADD=P.Y.ALPHA_ADD,t.ALPHA_COMBINE=P.Y.ALPHA_COMBINE,t.ALPHA_SUBTRACT=P.Y.ALPHA_SUBTRACT,t.ALPHA_MULTIPLY=P.Y.ALPHA_MULTIPLY,t.ALPHA_MAXIMIZED=P.Y.ALPHA_MAXIMIZED,t.ALPHA_ONEONE=P.Y.ALPHA_ONEONE,t.ALPHA_PREMULTIPLIED=P.Y.ALPHA_PREMULTIPLIED,t.ALPHA_PREMULTIPLIED_PORTERDUFF=P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHA_INTERPOLATE=P.Y.ALPHA_INTERPOLATE,t.ALPHA_SCREENMODE=P.Y.ALPHA_SCREENMODE,t.DELAYLOADSTATE_NONE=P.Y.DELAYLOADSTATE_NONE,t.DELAYLOADSTATE_LOADED=P.Y.DELAYLOADSTATE_LOADED,t.DELAYLOADSTATE_LOADING=P.Y.DELAYLOADSTATE_LOADING,t.DELAYLOADSTATE_NOTLOADED=P.Y.DELAYLOADSTATE_NOTLOADED,t.NEVER=P.Y.NEVER,t.ALWAYS=P.Y.ALWAYS,t.LESS=P.Y.LESS,t.EQUAL=P.Y.EQUAL,t.LEQUAL=P.Y.LEQUAL,t.GREATER=P.Y.GREATER,t.GEQUAL=P.Y.GEQUAL,t.NOTEQUAL=P.Y.NOTEQUAL,t.KEEP=P.Y.KEEP,t.REPLACE=P.Y.REPLACE,t.INCR=P.Y.INCR,t.DECR=P.Y.DECR,t.INVERT=P.Y.INVERT,t.INCR_WRAP=P.Y.INCR_WRAP,t.DECR_WRAP=P.Y.DECR_WRAP,t.TEXTURE_CLAMP_ADDRESSMODE=P.Y.TEXTURE_CLAMP_ADDRESSMODE,t.TEXTURE_WRAP_ADDRESSMODE=P.Y.TEXTURE_WRAP_ADDRESSMODE,t.TEXTURE_MIRROR_ADDRESSMODE=P.Y.TEXTURE_MIRROR_ADDRESSMODE,t.TEXTUREFORMAT_ALPHA=P.Y.TEXTUREFORMAT_ALPHA,t.TEXTUREFORMAT_LUMINANCE=P.Y.TEXTUREFORMAT_LUMINANCE,t.TEXTUREFORMAT_LUMINANCE_ALPHA=P.Y.TEXTUREFORMAT_LUMINANCE_ALPHA,t.TEXTUREFORMAT_RGB=P.Y.TEXTUREFORMAT_RGB,t.TEXTUREFORMAT_RGBA=P.Y.TEXTUREFORMAT_RGBA,t.TEXTUREFORMAT_RED=P.Y.TEXTUREFORMAT_RED,t.TEXTUREFORMAT_R=P.Y.TEXTUREFORMAT_R,t.TEXTUREFORMAT_RG=P.Y.TEXTUREFORMAT_RG,t.TEXTUREFORMAT_RED_INTEGER=P.Y.TEXTUREFORMAT_RED_INTEGER,t.TEXTUREFORMAT_R_INTEGER=P.Y.TEXTUREFORMAT_R_INTEGER,t.TEXTUREFORMAT_RG_INTEGER=P.Y.TEXTUREFORMAT_RG_INTEGER,t.TEXTUREFORMAT_RGB_INTEGER=P.Y.TEXTUREFORMAT_RGB_INTEGER,t.TEXTUREFORMAT_RGBA_INTEGER=P.Y.TEXTUREFORMAT_RGBA_INTEGER,t.TEXTURETYPE_UNSIGNED_BYTE=P.Y.TEXTURETYPE_UNSIGNED_BYTE,t.TEXTURETYPE_UNSIGNED_INT=P.Y.TEXTURETYPE_UNSIGNED_INT,t.TEXTURETYPE_FLOAT=P.Y.TEXTURETYPE_FLOAT,t.TEXTURETYPE_HALF_FLOAT=P.Y.TEXTURETYPE_HALF_FLOAT,t.TEXTURETYPE_BYTE=P.Y.TEXTURETYPE_BYTE,t.TEXTURETYPE_SHORT=P.Y.TEXTURETYPE_SHORT,t.TEXTURETYPE_UNSIGNED_SHORT=P.Y.TEXTURETYPE_UNSIGNED_SHORT,t.TEXTURETYPE_INT=P.Y.TEXTURETYPE_INT,t.TEXTURETYPE_UNSIGNED_INTEGER=P.Y.TEXTURETYPE_UNSIGNED_INTEGER,t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=P.Y.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=P.Y.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=P.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=P.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,t.TEXTURETYPE_UNSIGNED_INT_24_8=P.Y.TEXTURETYPE_UNSIGNED_INT_24_8,t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=P.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=P.Y.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=P.Y.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,t.TEXTURE_NEAREST_SAMPLINGMODE=P.Y.TEXTURE_NEAREST_SAMPLINGMODE,t.TEXTURE_BILINEAR_SAMPLINGMODE=P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,t.TEXTURE_TRILINEAR_SAMPLINGMODE=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,t.TEXTURE_NEAREST_NEAREST_MIPLINEAR=P.Y.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR_MIPNEAREST=P.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TEXTURE_LINEAR_LINEAR_MIPLINEAR=P.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_NEAREST_MIPNEAREST=P.Y.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPNEAREST=P.Y.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPLINEAR=P.Y.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_LINEAR=P.Y.TEXTURE_NEAREST_LINEAR,t.TEXTURE_NEAREST_NEAREST=P.Y.TEXTURE_NEAREST_NEAREST,t.TEXTURE_LINEAR_NEAREST_MIPNEAREST=P.Y.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.TEXTURE_LINEAR_NEAREST_MIPLINEAR=P.Y.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR=P.Y.TEXTURE_LINEAR_LINEAR,t.TEXTURE_LINEAR_NEAREST=P.Y.TEXTURE_LINEAR_NEAREST,t.TEXTURE_EXPLICIT_MODE=P.Y.TEXTURE_EXPLICIT_MODE,t.TEXTURE_SPHERICAL_MODE=P.Y.TEXTURE_SPHERICAL_MODE,t.TEXTURE_PLANAR_MODE=P.Y.TEXTURE_PLANAR_MODE,t.TEXTURE_CUBIC_MODE=P.Y.TEXTURE_CUBIC_MODE,t.TEXTURE_PROJECTION_MODE=P.Y.TEXTURE_PROJECTION_MODE,t.TEXTURE_SKYBOX_MODE=P.Y.TEXTURE_SKYBOX_MODE,t.TEXTURE_INVCUBIC_MODE=P.Y.TEXTURE_INVCUBIC_MODE,t.TEXTURE_EQUIRECTANGULAR_MODE=P.Y.TEXTURE_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=P.Y.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=P.Y.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.SCALEMODE_FLOOR=P.Y.SCALEMODE_FLOOR,t.SCALEMODE_NEAREST=P.Y.SCALEMODE_NEAREST,t.SCALEMODE_CEILING=P.Y.SCALEMODE_CEILING,t}(an.w),un=L(41085),Nm=function(r){function t(e,n){n===void 0&&(n=512);var i=r.call(this,"multiview rtt",n,e,!1,!0,P.Y.TEXTURETYPE_UNSIGNED_INT,!1,void 0,!1,!1,!0,void 0,!0)||this;return i._renderTarget=i.getScene().getEngine().createMultiviewRenderTargetTexture(i.getRenderWidth(),i.getRenderHeight()),i._texture=i._renderTarget.texture,i._texture.isMultiview=!0,i._texture.format=P.Y.TEXTUREFORMAT_RGBA,i.samples=i._getEngine().getCaps().maxSamples||i.samples,i._texture.samples=i._samples,i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples=e},enumerable:!1,configurable:!0}),t.prototype._bindFrameBuffer=function(){this._renderTarget&&this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)},t.prototype.getViewCount=function(){return 2},t}(un.$);function nE(r,t){var e=new Ui.D(r,void 0,!0,t);return e.addUniform("viewProjection",16),e.addUniform("viewProjectionR",16),e.addUniform("view",16),e.addUniform("projection",16),e.addUniform("vEyePosition",4),e}Zt.prototype.createMultiviewRenderTargetTexture=function(r,t,e,n){var i=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var o=this._createHardwareRenderTargetWrapper(!1,!1,{width:r,height:t});o._framebuffer=i.createFramebuffer();var a=new rn.h(this,0,!0);return a.width=r,a.height=t,a.isMultiview=!0,e||(e=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,e),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.RGBA8,r,t,2)),o._colorTextureArray=e,n||(n=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,n),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH24_STENCIL8,r,t,2)),o._depthStencilTextureArray=n,a.isReady=!0,o.setTextures(a),o._depthStencilTexture=a,o},Zt.prototype.bindMultiviewFramebuffer=function(r){var t=r,e=this._gl,n=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(t,void 0,void 0,void 0,!0),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,t._framebuffer),!t._colorTextureArray||!t._depthStencilTextureArray)throw"Invalid multiview frame buffer";this.getCaps().oculusMultiview?(n.framebufferTextureMultisampleMultiviewOVR(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,t._colorTextureArray,0,t.samples,0,2),n.framebufferTextureMultisampleMultiviewOVR(e.DRAW_FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,t._depthStencilTextureArray,0,t.samples,0,2)):(n.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,t._colorTextureArray,0,0,2),n.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,t._depthStencilTextureArray,0,0,2))},Zt.prototype.bindSpaceWarpFramebuffer=function(r){var t=r,e=this._gl,n=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(t,void 0,void 0,void 0,!0),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,t._framebuffer),!t._colorTextureArray||!t._depthStencilTextureArray)throw new Error("Invalid Space Warp framebuffer");n.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,t._colorTextureArray,0,0,2),n.framebufferTextureMultiviewOVR(e.DRAW_FRAMEBUFFER,e.DEPTH_ATTACHMENT,t._depthStencilTextureArray,0,0,2)},Pt.prototype._useMultiviewToSingleView=!1,Pt.prototype._multiviewTexture=null,Pt.prototype._resizeOrCreateMultiviewTexture=function(r,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==r&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new Nm(this.getScene(),{width:r,height:t})):this._multiviewTexture=new Nm(this.getScene(),{width:r,height:t})};var Q1=ke.Z.prototype.createSceneUniformBuffer;ke.Z.prototype._transformMatrixR=_.uq.Zero(),ke.Z.prototype._multiviewSceneUbo=null,ke.Z.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=nE(this.getEngine(),"scene_multiview")},ke.Z.prototype.createSceneUniformBuffer=function(r){return this._multiviewSceneUbo?nE(this.getEngine(),r):Q1.bind(this)(r)},ke.Z.prototype._updateMultiviewUbo=function(r,t){r&&t&&r.multiplyToRef(t,this._transformMatrixR),r&&t&&(r.multiplyToRef(t,_.AA.Matrix[0]),j_.P.GetRightPlaneToRef(_.AA.Matrix[0],this._frustumPlanes[3])),this._multiviewSceneUbo&&(this._multiviewSceneUbo.updateMatrix("viewProjection",this.getTransformMatrix()),this._multiviewSceneUbo.updateMatrix("viewProjectionR",this._transformMatrixR),this._multiviewSceneUbo.updateMatrix("view",this._viewMatrix),this._multiviewSceneUbo.updateMatrix("projection",this._projectionMatrix))},ke.Z.prototype._renderMultiviewToSingleView=function(r){r._resizeOrCreateMultiviewTexture(r._rigPostProcess&&r._rigPostProcess&&r._rigPostProcess.width>0?r._rigPostProcess.width:this.getEngine().getRenderWidth(!0),r._rigPostProcess&&r._rigPostProcess&&r._rigPostProcess.height>0?r._rigPostProcess.height:this.getEngine().getRenderHeight(!0)),this._multiviewSceneUbo||this._createMultiviewUbo(),r.outputRenderTarget=r._multiviewTexture,this._renderForCamera(r),r.outputRenderTarget=null;for(var t=0;t<r._rigCameras.length;t++){var e=this.getEngine();this._activeCamera=r._rigCameras[t],e.setViewport(this._activeCamera.viewport),this.postProcessManager&&(this.postProcessManager._prepareFrame(),this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate))}};var Lm=function(r){function t(e,n,i){var o=r.call(this,e,"vrMultiviewToSingleview",["imageIndex"],["multiviewSampler"],i,n,Ie.g.BILINEAR_SAMPLINGMODE)||this,a=n??o.getCamera();return o.onSizeChangedObservable.add(function(){}),o.onApplyObservable.add(function(s){a._scene.activeCamera&&a._scene.activeCamera.isLeftCamera?s.setInt("imageIndex",0):s.setInt("imageIndex",1),s.setTexture("multiviewSampler",a._multiviewTexture)}),o}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VRMultiviewToSingleviewPostProcess"},t}(_t.w);function Fs(r,t){var e=t.vrCameraMetrics||Oa.GetDefault();r._rigCameras[0]._cameraRigParams.vrMetrics=e,r._rigCameras[0].viewport=new Br.L(0,0,.5,1),r._rigCameras[0]._cameraRigParams.vrWorkMatrix=new _.uq,r._rigCameras[0]._cameraRigParams.vrHMatrix=e.leftHMatrix,r._rigCameras[0]._cameraRigParams.vrPreViewMatrix=e.leftPreViewMatrix,r._rigCameras[0].getProjectionMatrix=r._rigCameras[0]._getVRProjectionMatrix,r._rigCameras[1]._cameraRigParams.vrMetrics=e,r._rigCameras[1].viewport=new Br.L(.5,0,.5,1),r._rigCameras[1]._cameraRigParams.vrWorkMatrix=new _.uq,r._rigCameras[1]._cameraRigParams.vrHMatrix=e.rightHMatrix,r._rigCameras[1]._cameraRigParams.vrPreViewMatrix=e.rightPreViewMatrix,r._rigCameras[1].getProjectionMatrix=r._rigCameras[1]._getVRProjectionMatrix,e.multiviewEnabled&&(r.getScene().getEngine().getCaps().multiview?(r._useMultiviewToSingleView=!0,r._rigPostProcess=new Lm("VRMultiviewToSingleview",r,e.postProcessScaleFactor)):(O.V.Warn("Multiview is not supported, falling back to standard rendering"),e.multiviewEnabled=!1)),e.compensateDistortion&&(r._rigCameras[0]._rigPostProcess=new su("VR_Distort_Compensation_Left",r._rigCameras[0],!1,e),r._rigCameras[1]._rigPostProcess=new su("VR_Distort_Compensation_Right",r._rigCameras[1],!0,e))}At.AddNodeConstructor("VRDeviceOrientationArcRotateCamera",function(r,t){return function(){return new Fm(r,0,0,1,_.Pq.Zero(),t)}});var Fm=function(r){function t(e,n,i,o,a,s,l,c){l===void 0&&(l=!0),c===void 0&&(c=Oa.GetDefault());var u=r.call(this,e,n,i,o,a,s)||this;return u._setRigMode=function(d){return Fs(u,d)},c.compensateDistortion=l,u.setCameraRigMode(Pt.RIG_MODE_VR,{vrCameraMetrics:c}),u.inputs.addVRDeviceOrientation(),u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VRDeviceOrientationArcRotateCamera"},t}(zr);At.AddNodeConstructor("VRDeviceOrientationFreeCamera",function(r,t){return function(){return new ws(r,_.Pq.Zero(),t)}});var ws=function(r){function t(e,n,i,o,a){o===void 0&&(o=!0),a===void 0&&(a=Oa.GetDefault());var s=r.call(this,e,n,i)||this;return s._setRigMode=function(l){return Fs(s,l)},a.compensateDistortion=o,s.setCameraRigMode(Pt.RIG_MODE_VR,{vrCameraMetrics:a}),s}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VRDeviceOrientationFreeCamera"},t}(Ds);At.AddNodeConstructor("VRDeviceOrientationGamepadCamera",function(r,t){return function(){return new wm(r,_.Pq.Zero(),t)}});var wm=function(r){function t(e,n,i,o,a){o===void 0&&(o=!0),a===void 0&&(a=Oa.GetDefault());var s=r.call(this,e,n,i,o,a)||this;return s._setRigMode=function(l){return Fs(s,l)},s.inputs.addGamepad(),s}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VRDeviceOrientationGamepadCamera"},t}(ws),Ti=L(81914),Da=function(){function r(){this.previousWorldMatrices={},this.previousBones={}}return r.AddUniforms=function(t){t.push("previousWorld","previousViewProjection","mPreviousBones")},r.AddSamplers=function(t){},r.prototype.bindForSubMesh=function(t,e,n,i,o){if(e.prePassRenderer&&e.prePassRenderer.enabled&&e.prePassRenderer.currentRTisSceneRT&&(e.prePassRenderer.getIndex(P.Y.PREPASS_VELOCITY_TEXTURE_TYPE)!==-1||e.prePassRenderer.getIndex(P.Y.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE)!==-1)){this.previousWorldMatrices[n.uniqueId]||(this.previousWorldMatrices[n.uniqueId]=i.clone()),this.previousViewProjection||(this.previousViewProjection=e.getTransformMatrix().clone(),this.currentViewProjection=e.getTransformMatrix().clone());var a=e.getEngine();this.currentViewProjection.updateFlag!==e.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(e.getTransformMatrix())):this._lastUpdateFrameId!==a.frameId&&(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),t.setMatrix("previousWorld",this.previousWorldMatrices[n.uniqueId]),t.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[n.uniqueId]=i.clone()}},r}(),si=function(){function r(t){if(this._keys=[],this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1,this._externalProperties=t,t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this._setDefaultValue(e)}return Object.defineProperty(r.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),r.prototype.markAsProcessed=function(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1},r.prototype.markAsUnprocessed=function(){this._isDirty=!0},r.prototype.markAllAsDirty=function(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!1,this._areImageProcessingDirty=!0,this._isDirty=!0},r.prototype.markAsImageProcessingDirty=function(){this._areImageProcessingDirty=!0,this._isDirty=!0},r.prototype.markAsLightDirty=function(t){t===void 0&&(t=!1),this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||t,this._isDirty=!0},r.prototype.markAsAttributesDirty=function(){this._areAttributesDirty=!0,this._isDirty=!0},r.prototype.markAsTexturesDirty=function(){this._areTexturesDirty=!0,this._isDirty=!0},r.prototype.markAsFresnelDirty=function(){this._areFresnelDirty=!0,this._isDirty=!0},r.prototype.markAsMiscDirty=function(){this._areMiscDirty=!0,this._isDirty=!0},r.prototype.markAsPrePassDirty=function(){this._arePrePassDirty=!0,this._isDirty=!0},r.prototype.rebuild=function(){this._keys.length=0;for(var t=0,e=Object.keys(this);t<e.length;t++){var n=e[t];n[0]!=="_"&&this._keys.push(n)}if(this._externalProperties)for(var i in this._externalProperties)this._keys.indexOf(i)===-1&&this._keys.push(i)},r.prototype.isEqual=function(t){if(this._keys.length!==t._keys.length)return!1;for(var e=0;e<this._keys.length;e++){var n=this._keys[e];if(this[n]!==t[n])return!1}return!0},r.prototype.cloneTo=function(t){this._keys.length!==t._keys.length&&(t._keys=this._keys.slice(0));for(var e=0;e<this._keys.length;e++){var n=this._keys[e];t[n]=this[n]}},r.prototype.reset=function(){var t=this;this._keys.forEach(function(e){return t._setDefaultValue(e)})},r.prototype._setDefaultValue=function(t){var e,n,i,o,a,s=(i=(n=(e=this._externalProperties)===null||e===void 0?void 0:e[t])===null||n===void 0?void 0:n.type)!==null&&i!==void 0?i:typeof this[t],l=(a=(o=this._externalProperties)===null||o===void 0?void 0:o[t])===null||a===void 0?void 0:a.default;switch(s){case"number":this[t]=l??0;break;case"string":this[t]=l??"";break;default:this[t]=l!=null&&l}},r.prototype.toString=function(){for(var t="",e=0;e<this._keys.length;e++){var n=this._keys[e],i=this[n];switch(typeof i){case"number":case"string":t+="#define "+n+" "+i+`
|
||
`;break;default:i&&(t+="#define "+n+`
|
||
`)}}return t},r}(),Ro=function(r){function t(e,n,i){i===void 0&&(i=!0);var o=r.call(this,e,n)||this;return o._normalMatrix=new _.uq,o._storeEffectOnSubMeshes=i,o}return(0,A.C6)(t,r),t.prototype.getEffect=function(){return this._storeEffectOnSubMeshes?this._activeEffect:r.prototype.getEffect.call(this)},t.prototype.isReady=function(e,n){return!!e&&(!this._storeEffectOnSubMeshes||!e.subMeshes||e.subMeshes.length===0||this.isReadyForSubMesh(e,e.subMeshes[0],n))},t.prototype._isReadyForSubMesh=function(e){var n=e.materialDefines;return!(this.checkReadyOnEveryCall||!e.effect||!n||n._renderId!==this.getScene().getRenderId())},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindOnlyNormalMatrix=function(e){this._activeEffect.setMatrix("normalMatrix",e)},t.prototype.bind=function(e,n){n&&this.bindForSubMesh(e,n,n.subMeshes[0])},t.prototype._afterBind=function(e,n,i){n===void 0&&(n=null),r.prototype._afterBind.call(this,e,n,i),this.getScene()._cachedEffect=n,i?i._drawWrapper._forceRebindOnNextCall=!1:this._drawWrapper._forceRebindOnNextCall=!1},t.prototype._mustRebind=function(e,n,i,o){return o===void 0&&(o=1),i._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,n,o)},t.prototype.dispose=function(e,n,i){this._activeEffect=void 0,r.prototype.dispose.call(this,e,n,i)},t}(Lt),$e=function(){function r(){}return Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(t){this._DiffuseTextureEnabled!==t&&(this._DiffuseTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"DetailTextureEnabled",{get:function(){return this._DetailTextureEnabled},set:function(t){this._DetailTextureEnabled!==t&&(this._DetailTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"DecalMapEnabled",{get:function(){return this._DecalMapEnabled},set:function(t){this._DecalMapEnabled!==t&&(this._DecalMapEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(t){this._AmbientTextureEnabled!==t&&(this._AmbientTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(t){this._OpacityTextureEnabled!==t&&(this._OpacityTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(t){this._ReflectionTextureEnabled!==t&&(this._ReflectionTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(t){this._EmissiveTextureEnabled!==t&&(this._EmissiveTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(t){this._SpecularTextureEnabled!==t&&(this._SpecularTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(t){this._BumpTextureEnabled!==t&&(this._BumpTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(t){this._LightmapTextureEnabled!==t&&(this._LightmapTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(t){this._RefractionTextureEnabled!==t&&(this._RefractionTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(t){this._ColorGradingTextureEnabled!==t&&(this._ColorGradingTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(t){this._FresnelEnabled!==t&&(this._FresnelEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_FresnelDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ClearCoatTextureEnabled",{get:function(){return this._ClearCoatTextureEnabled},set:function(t){this._ClearCoatTextureEnabled!==t&&(this._ClearCoatTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ClearCoatBumpTextureEnabled",{get:function(){return this._ClearCoatBumpTextureEnabled},set:function(t){this._ClearCoatBumpTextureEnabled!==t&&(this._ClearCoatBumpTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ClearCoatTintTextureEnabled",{get:function(){return this._ClearCoatTintTextureEnabled},set:function(t){this._ClearCoatTintTextureEnabled!==t&&(this._ClearCoatTintTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"SheenTextureEnabled",{get:function(){return this._SheenTextureEnabled},set:function(t){this._SheenTextureEnabled!==t&&(this._SheenTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"AnisotropicTextureEnabled",{get:function(){return this._AnisotropicTextureEnabled},set:function(t){this._AnisotropicTextureEnabled!==t&&(this._AnisotropicTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ThicknessTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(t){this._ThicknessTextureEnabled!==t&&(this._ThicknessTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"RefractionIntensityTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(t){this._RefractionIntensityTextureEnabled!==t&&(this._RefractionIntensityTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"TranslucencyIntensityTextureEnabled",{get:function(){return this._TranslucencyIntensityTextureEnabled},set:function(t){this._TranslucencyIntensityTextureEnabled!==t&&(this._TranslucencyIntensityTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"TranslucencyColorTextureEnabled",{get:function(){return this._TranslucencyColorTextureEnabled},set:function(t){this._TranslucencyColorTextureEnabled!==t&&(this._TranslucencyColorTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(r,"IridescenceTextureEnabled",{get:function(){return this._IridescenceTextureEnabled},set:function(t){this._IridescenceTextureEnabled!==t&&(this._IridescenceTextureEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),r._DiffuseTextureEnabled=!0,r._DetailTextureEnabled=!0,r._DecalMapEnabled=!0,r._AmbientTextureEnabled=!0,r._OpacityTextureEnabled=!0,r._ReflectionTextureEnabled=!0,r._EmissiveTextureEnabled=!0,r._SpecularTextureEnabled=!0,r._BumpTextureEnabled=!0,r._LightmapTextureEnabled=!0,r._RefractionTextureEnabled=!0,r._ColorGradingTextureEnabled=!0,r._FresnelEnabled=!0,r._ClearCoatTextureEnabled=!0,r._ClearCoatBumpTextureEnabled=!0,r._ClearCoatTintTextureEnabled=!0,r._SheenTextureEnabled=!0,r._AnisotropicTextureEnabled=!0,r._ThicknessTextureEnabled=!0,r._RefractionIntensityTextureEnabled=!0,r._TranslucencyIntensityTextureEnabled=!0,r._TranslucencyColorTextureEnabled=!0,r._IridescenceTextureEnabled=!0,r}(),Tr=function(){function r(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}return r.prototype.unBindMesh=function(){this._mesh=null},r.prototype.addFallback=function(t,e){this._defines[t]||(t<this._currentRank&&(this._currentRank=t),t>this._maxRank&&(this._maxRank=t),this._defines[t]=new Array),this._defines[t].push(e)},r.prototype.addCPUSkinningFallback=function(t,e){this._mesh=e,t<this._currentRank&&(this._currentRank=t),t>this._maxRank&&(this._maxRank=t)},Object.defineProperty(r.prototype,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),r.prototype.reduce=function(t,e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,t=t.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),e._bonesComputationForcedToCPU=!0;for(var n=this._mesh.getScene(),i=0;i<n.meshes.length;i++){var o=n.meshes[i];if(o.material){if(o.computeBonesUsingShaders&&o.numBoneInfluencers!==0){if(o.material.getEffect()===e)o.computeBonesUsingShaders=!1;else if(o.subMeshes){for(var a=0,s=o.subMeshes;a<s.length;a++)if(s[a].effect===e){o.computeBonesUsingShaders=!1;break}}}}else!this._mesh.material&&o.computeBonesUsingShaders&&o.numBoneInfluencers>0&&(o.computeBonesUsingShaders=!1)}}else{var l=this._defines[this._currentRank];if(l)for(i=0;i<l.length;i++)t=t.replace("#define "+l[i],"");this._currentRank++}return t},r}(),Io=L(35930),J1=new RegExp("^([gimus]+)!"),Bm=function(){function r(t){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=t,this._scene=t.getScene(),this._engine=this._scene.getEngine()}return r.prototype._addPlugin=function(t){for(var e=this,n=0;n<this._plugins.length;++n)if(this._plugins[n].name===t.name)return!1;if(this._material._uniformBufferLayoutBuilt)throw'The plugin "'.concat(t.name,`" can't be added to the material "`).concat(this._material.name,'" because this material has already been used for rendering! Please add plugins to materials before any rendering with this material occurs.');if(!t.isCompatible(this._material.shaderLanguage))throw'The plugin "'.concat(t.name,`" can't be added to the material "`).concat(this._material.name,'" because the plugin is not compatible with the shader language of the material.');var i=t.getClassName();r._MaterialPluginClassToMainDefine[i]||(r._MaterialPluginClassToMainDefine[i]="MATERIALPLUGIN_"+ ++r._MaterialPluginCounter),this._material._callbackPluginEventGeneric=function(c,u){return e._handlePluginEvent(c,u)},this._plugins.push(t),this._plugins.sort(function(c,u){return c.priority-u.priority}),this._codeInjectionPoints={};var o={};o[r._MaterialPluginClassToMainDefine[i]]={type:"boolean",default:!0};for(var a=0,s=this._plugins;a<s.length;a++){var l=s[a];l.collectDefines(o),this._collectPointNames("vertex",l.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",l.getCustomCode("fragment",this._material.shaderLanguage))}return this._defineNamesFromPlugins=o,!0},r.prototype._activatePlugin=function(t){this._activePlugins.indexOf(t)===-1&&(this._activePlugins.push(t),this._activePlugins.sort(function(e,n){return e.priority-n.priority}),this._material._callbackPluginEventIsReadyForSubMesh=this._handlePluginEventIsReadyForSubMesh.bind(this),this._material._callbackPluginEventPrepareDefinesBeforeAttributes=this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this),this._material._callbackPluginEventPrepareDefines=this._handlePluginEventPrepareDefines.bind(this),this._material._callbackPluginEventBindForSubMesh=this._handlePluginEventBindForSubMesh.bind(this),t.registerForExtraEvents&&(this._activePluginsForExtraEvents.push(t),this._activePluginsForExtraEvents.sort(function(e,n){return e.priority-n.priority}),this._material._callbackPluginEventHasRenderTargetTextures=this._handlePluginEventHasRenderTargetTextures.bind(this),this._material._callbackPluginEventFillRenderTargetTextures=this._handlePluginEventFillRenderTargetTextures.bind(this),this._material._callbackPluginEventHardBindForSubMesh=this._handlePluginEventHardBindForSubMesh.bind(this)))},r.prototype.getPlugin=function(t){for(var e=0;e<this._plugins.length;++e)if(this._plugins[e].name===t)return this._plugins[e];return null},r.prototype._handlePluginEventIsReadyForSubMesh=function(t){for(var e=!0,n=0,i=this._activePlugins;n<i.length;n++){var o=i[n];e=e&&o.isReadyForSubMesh(t.defines,this._scene,this._engine,t.subMesh)}t.isReadyForSubMesh=e},r.prototype._handlePluginEventPrepareDefinesBeforeAttributes=function(t){for(var e=0,n=this._activePlugins;e<n.length;e++)n[e].prepareDefinesBeforeAttributes(t.defines,this._scene,t.mesh)},r.prototype._handlePluginEventPrepareDefines=function(t){for(var e=0,n=this._activePlugins;e<n.length;e++)n[e].prepareDefines(t.defines,this._scene,t.mesh)},r.prototype._handlePluginEventHardBindForSubMesh=function(t){for(var e=0,n=this._activePluginsForExtraEvents;e<n.length;e++)n[e].hardBindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,t.subMesh)},r.prototype._handlePluginEventBindForSubMesh=function(t){for(var e=0,n=this._activePlugins;e<n.length;e++)n[e].bindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,t.subMesh)},r.prototype._handlePluginEventHasRenderTargetTextures=function(t){for(var e=!1,n=0,i=this._activePluginsForExtraEvents;n<i.length&&!(e=i[n].hasRenderTargetTextures());n++);t.hasRenderTargetTextures=e},r.prototype._handlePluginEventFillRenderTargetTextures=function(t){for(var e=0,n=this._activePluginsForExtraEvents;e<n.length;e++)n[e].fillRenderTargetTextures(t.renderTargets)},r.prototype._handlePluginEvent=function(t,e){var n,i,o,a;switch(t){case 512:for(var s=e,l=0,c=this._activePlugins;l<c.length;l++)(T=c[l]).getActiveTextures(s.activeTextures);break;case 256:s=e;for(var u=0,d=this._activePlugins;u<d.length;u++)(T=d[u]).getAnimatables(s.animatables);break;case 1024:s=e;for(var h=!1,p=0,m=this._activePlugins;p<m.length&&!(h=(T=m[p]).hasTexture(s.texture));p++);s.hasTexture=h;break;case 2:s=e;for(var v=0,b=this._plugins;v<b.length;v++)(T=b[v]).dispose(s.forceDisposeTextures);break;case 4:(s=e).defineNames=this._defineNamesFromPlugins;break;case 128:s=e;for(var E=0,C=this._activePlugins;E<C.length;E++){var T=C[E];s.fallbackRank=T.addFallbacks(s.defines,s.fallbacks,s.fallbackRank),T.getAttributes(s.attributes,this._scene,s.mesh)}this._uniformList.length>0&&(n=s.uniforms).push.apply(n,this._uniformList),this._samplerList.length>0&&(i=s.samplers).push.apply(i,this._samplerList),this._uboList.length>0&&(o=s.uniformBuffersNames).push.apply(o,this._uboList),s.customCode=this._injectCustomCode(s,s.customCode);break;case 8:s=e,this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];for(var f=this._material.shaderLanguage===1,g=0,S=this._plugins;g<S.length;g++){var y=(T=S[g]).getUniforms(this._material.shaderLanguage);if(y){if(y.ubo)for(var x=0,R=y.ubo;x<R.length;x++){var I=R[x];if(I.size&&I.type){var M=(a=I.arraySize)!==null&&a!==void 0?a:0;if(s.ubo.addUniform(I.name,I.size,M),f){var D=void 0;switch(I.type){case"mat4":D="mat4x4f";break;case"float":D="f32";break;default:D="".concat(I.type,"f")}this._uboDeclaration+="uniform ".concat(I.name,": ").concat(D).concat(M>0?"[".concat(M,"]"):"",`;
|
||
`)}else this._uboDeclaration+="".concat(I.type," ").concat(I.name).concat(M>0?"[".concat(M,"]"):"",`;
|
||
`)}this._uniformList.push(I.name)}y.vertex&&(this._vertexDeclaration+=y.vertex+`
|
||
`),y.fragment&&(this._fragmentDeclaration+=y.fragment+`
|
||
`)}T.getSamplers(this._samplerList),T.getUniformBuffersNames(this._uboList)}}},r.prototype._collectPointNames=function(t,e){if(e)for(var n in e)this._codeInjectionPoints[t]||(this._codeInjectionPoints[t]={}),this._codeInjectionPoints[t][n]=!0},r.prototype._injectCustomCode=function(t,e){var n=this;return function(i,o){var a,s;e&&(o=e(i,o)),n._uboDeclaration&&(o=o.replace("#define ADDITIONAL_UBO_DECLARATION",n._uboDeclaration)),n._vertexDeclaration&&(o=o.replace("#define ADDITIONAL_VERTEX_DECLARATION",n._vertexDeclaration)),n._fragmentDeclaration&&(o=o.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",n._fragmentDeclaration));var l=(a=n._codeInjectionPoints)===null||a===void 0?void 0:a[i];if(!l)return o;var c=null;for(var u in l){for(var d="",h=function(y){var x=(s=y.getCustomCode(i,n._material.shaderLanguage))===null||s===void 0?void 0:s[u];if(!x)return"continue";y.resolveIncludes&&(c===null&&(c={defines:[],indexParameters:t.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:n._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:n._engine.supportsUniformBuffers,shadersRepository:Gt.l.GetShadersRepository(0),includesShadersStore:Gt.l.GetIncludesShadersStore(0),version:void 0,platformName:n._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:n._engine.isNDCHalfZRange,useReverseDepthBuffer:n._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}),c.isFragment=i==="fragment",(0,Io.Iq)(x,c,function(R){return x=R})),d+=x+`
|
||
`},p=0,m=n._activePlugins;p<m.length;p++)h(m[p]);if(d.length>0)if(u.charAt(0)==="!"){var v="g";if((u=u.substring(1)).charAt(0)==="!")v="",u=u.substring(1);else{var b=J1.exec(u);b&&b.length>=2&&(v=b[1],u=u.substring(v.length+1))}v.indexOf("g")<0&&(v+="g");for(var E=o,C=new RegExp(u,v),T=C.exec(E);T!==null;){for(var f=d,g=0;g<T.length;++g)f=f.replace("$"+g,T[g]);o=o.replace(T[0],f),T=C.exec(E)}}else{var S="#define "+u;o=o.replace(S,`
|
||
`+d+`
|
||
`+S)}}return o}},r._MaterialPluginClassToMainDefine={},r._MaterialPluginCounter=0,Ve.q.OnEnginesDisposedObservable.add(function(){vu()}),r}(),Mo=[],Vm=!1,Um=null;function iE(r,t){Vm||(Um=Lt.OnEventObservable.add(function(n){for(var i=0,o=Mo;i<o.length;i++)(0,o[i][1])(n)},1),Vm=!0);var e=Mo.filter(function(n){var i=n[0];return n[1],i===r});e.length>0?e[0][1]=t:Mo.push([r,t])}function rE(r){for(var t=0;t<Mo.length;++t)if(Mo[t][0]===r)return Mo.splice(t,1),Mo.length===0&&vu(),!0;return!1}function vu(){Mo.length=0,Vm=!1,Lt.OnEventObservable.remove(Um),Um=null}var qi=function(){function r(t,e,n,i,o,a,s){o===void 0&&(o=!0),a===void 0&&(a=!1),s===void 0&&(s=!1),this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this._material=t,this.name=e,this.priority=n,this.resolveIncludes=s,t.pluginManager||(t.pluginManager=new Bm(t),t.onDisposeObservable.add(function(){t.pluginManager=void 0})),this._pluginDefineNames=i,this._pluginManager=t.pluginManager,o&&this._pluginManager._addPlugin(this),a&&this._enable(!0),this.markAllDefinesAsDirty=t._dirtyCallbacks[P.Y.MATERIAL_AllDirtyFlag]}return r.prototype.isCompatible=function(t){return t===0},r.prototype._enable=function(t){t&&this._pluginManager._activatePlugin(this)},r.prototype.getClassName=function(){return"MaterialPluginBase"},r.prototype.isReadyForSubMesh=function(t,e,n,i){return!0},r.prototype.hardBindForSubMesh=function(t,e,n,i){},r.prototype.bindForSubMesh=function(t,e,n,i){},r.prototype.dispose=function(t){},r.prototype.getCustomCode=function(t,e){return null},r.prototype.collectDefines=function(t){if(this._pluginDefineNames)for(var e=0,n=Object.keys(this._pluginDefineNames);e<n.length;e++){var i=n[e];if(i[0]!=="_"){var o=typeof this._pluginDefineNames[i];t[i]={type:o==="number"?"number":o==="string"?"string":o==="boolean"?"boolean":"object",default:this._pluginDefineNames[i]}}}},r.prototype.prepareDefinesBeforeAttributes=function(t,e,n){},r.prototype.prepareDefines=function(t,e,n){},r.prototype.hasTexture=function(t){return!1},r.prototype.hasRenderTargetTextures=function(){return!1},r.prototype.fillRenderTargetTextures=function(t){},r.prototype.getActiveTextures=function(t){},r.prototype.getAnimatables=function(t){},r.prototype.addFallbacks=function(t,e,n){return n},r.prototype.getSamplers=function(t){},r.prototype.getAttributes=function(t,e,n){},r.prototype.getUniformBuffersNames=function(t){},r.prototype.getUniforms=function(t){return{}},r.prototype.copyTo=function(t){tt.p.Clone(function(){return t},this)},r.prototype.serialize=function(){return tt.p.Serialize(this)},r.prototype.parse=function(t,e,n){var i=this;tt.p.Parse(function(){return i},t,e,n)},(0,A.Cg)([(0,V.lK)()],r.prototype,"name",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"priority",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"resolveIncludes",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"registerForExtraEvents",void 0),r}();(0,j.Y5)("BABYLON.MaterialPluginBase",qi);var Gm=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.DETAIL=!1,e.DETAILDIRECTUV=0,e.DETAIL_NORMALBLENDMETHOD=0,e}return(0,A.C6)(t,r),t}(si),Bs=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"DetailMap",140,new Gm,n)||this;return i._texture=null,i.diffuseBlendLevel=1,i.roughnessBlendLevel=1,i.bumpLevel=1,i._normalBlendMethod=Lt.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,i._isEnabled=!1,i.isEnabled=!1,i._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],i}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n,i){return!this._isEnabled||!(e._areTexturesDirty&&n.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&$e.DetailTextureEnabled&&!this._texture.isReady())},t.prototype.prepareDefines=function(e,n){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;var i=n.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&$e.DetailTextureEnabled&&this._isEnabled?((0,Re.YT)(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1},t.prototype.bindForSubMesh=function(e,n){if(this._isEnabled){var i=this._material.isFrozen;e.useUbo&&i&&e.isSync||this._texture&&$e.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),(0,Re.mA)(this._texture,e,"detail")),n.texturesEnabled&&this._texture&&$e.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture)}},t.prototype.hasTexture=function(e){return this._texture===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},t.prototype.dispose=function(e){var n;e&&((n=this._texture)===null||n===void 0||n.dispose())},t.prototype.getClassName=function(){return"DetailMapConfiguration"},t.prototype.getSamplers=function(e){e.push("detailSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}},(0,A.Cg)([(0,V.uM)("detailTexture"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"diffuseBlendLevel",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"roughnessBlendLevel",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"bumpLevel",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"normalBlendMethod",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),t}(qi),tn=L(34561),km={effect:null,subMesh:null},zm=function(r){function t(e){var n=r.call(this,e)||this;return n.MAINUV1=!1,n.MAINUV2=!1,n.MAINUV3=!1,n.MAINUV4=!1,n.MAINUV5=!1,n.MAINUV6=!1,n.DIFFUSE=!1,n.DIFFUSEDIRECTUV=0,n.BAKED_VERTEX_ANIMATION_TEXTURE=!1,n.AMBIENT=!1,n.AMBIENTDIRECTUV=0,n.OPACITY=!1,n.OPACITYDIRECTUV=0,n.OPACITYRGB=!1,n.REFLECTION=!1,n.EMISSIVE=!1,n.EMISSIVEDIRECTUV=0,n.SPECULAR=!1,n.SPECULARDIRECTUV=0,n.BUMP=!1,n.BUMPDIRECTUV=0,n.PARALLAX=!1,n.PARALLAX_RHS=!1,n.PARALLAXOCCLUSION=!1,n.SPECULAROVERALPHA=!1,n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.ALPHATEST=!1,n.DEPTHPREPASS=!1,n.ALPHAFROMDIFFUSE=!1,n.POINTSIZE=!1,n.FOG=!1,n.SPECULARTERM=!1,n.DIFFUSEFRESNEL=!1,n.OPACITYFRESNEL=!1,n.REFLECTIONFRESNEL=!1,n.REFRACTIONFRESNEL=!1,n.EMISSIVEFRESNEL=!1,n.FRESNEL=!1,n.NORMAL=!1,n.TANGENT=!1,n.UV1=!1,n.UV2=!1,n.UV3=!1,n.UV4=!1,n.UV5=!1,n.UV6=!1,n.VERTEXCOLOR=!1,n.VERTEXALPHA=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.BONETEXTURE=!1,n.BONES_VELOCITY_ENABLED=!1,n.INSTANCES=!1,n.THIN_INSTANCES=!1,n.INSTANCESCOLOR=!1,n.GLOSSINESS=!1,n.ROUGHNESS=!1,n.EMISSIVEASILLUMINATION=!1,n.LINKEMISSIVEWITHDIFFUSE=!1,n.REFLECTIONFRESNELFROMSPECULAR=!1,n.LIGHTMAP=!1,n.LIGHTMAPDIRECTUV=0,n.OBJECTSPACE_NORMALMAP=!1,n.USELIGHTMAPASSHADOWMAP=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFRACTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.INVERTCUBICMAP=!1,n.LOGARITHMICDEPTH=!1,n.REFRACTION=!1,n.REFRACTIONMAP_3D=!1,n.REFLECTIONOVERALPHA=!1,n.TWOSIDEDLIGHTING=!1,n.SHADOWFLOAT=!1,n.MORPHTARGETS=!1,n.MORPHTARGETS_NORMAL=!1,n.MORPHTARGETS_TANGENT=!1,n.MORPHTARGETS_UV=!1,n.NUM_MORPH_INFLUENCERS=0,n.MORPHTARGETS_TEXTURE=!1,n.NONUNIFORMSCALING=!1,n.PREMULTIPLYALPHA=!1,n.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,n.ALPHABLEND=!0,n.PREPASS=!1,n.PREPASS_IRRADIANCE=!1,n.PREPASS_IRRADIANCE_INDEX=-1,n.PREPASS_ALBEDO_SQRT=!1,n.PREPASS_ALBEDO_SQRT_INDEX=-1,n.PREPASS_DEPTH=!1,n.PREPASS_DEPTH_INDEX=-1,n.PREPASS_SCREENSPACE_DEPTH=!1,n.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,n.PREPASS_NORMAL=!1,n.PREPASS_NORMAL_INDEX=-1,n.PREPASS_NORMAL_WORLDSPACE=!1,n.PREPASS_WORLD_NORMAL=!1,n.PREPASS_WORLD_NORMAL_INDEX=-1,n.PREPASS_POSITION=!1,n.PREPASS_POSITION_INDEX=-1,n.PREPASS_LOCAL_POSITION=!1,n.PREPASS_LOCAL_POSITION_INDEX=-1,n.PREPASS_VELOCITY=!1,n.PREPASS_VELOCITY_INDEX=-1,n.PREPASS_VELOCITY_LINEAR=!1,n.PREPASS_VELOCITY_LINEAR_INDEX=-1,n.PREPASS_REFLECTIVITY=!1,n.PREPASS_REFLECTIVITY_INDEX=-1,n.SCENE_MRT_COUNT=0,n.RGBDLIGHTMAP=!1,n.RGBDREFLECTION=!1,n.RGBDREFRACTION=!1,n.IMAGEPROCESSING=!1,n.VIGNETTE=!1,n.VIGNETTEBLENDMODEMULTIPLY=!1,n.VIGNETTEBLENDMODEOPAQUE=!1,n.TONEMAPPING=0,n.CONTRAST=!1,n.COLORCURVES=!1,n.COLORGRADING=!1,n.COLORGRADING3D=!1,n.SAMPLER3DGREENDEPTH=!1,n.SAMPLER3DBGRMAP=!1,n.DITHER=!1,n.IMAGEPROCESSINGPOSTPROCESS=!1,n.SKIPFINALCOLORCLAMP=!1,n.MULTIVIEW=!1,n.ORDER_INDEPENDENT_TRANSPARENCY=!1,n.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,n.CAMERA_ORTHOGRAPHIC=!1,n.CAMERA_PERSPECTIVE=!1,n.IS_REFLECTION_LINEAR=!1,n.IS_REFRACTION_LINEAR=!1,n.EXPOSURE=!1,n.DECAL_AFTER_DETAIL=!1,n.rebuild(),n}return(0,A.C6)(t,r),t.prototype.setReflectionMode=function(e){for(var n=0,i=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];n<i.length;n++){var o=i[n];this[o]=o===e}},t}(si),qt=function(r){function t(e,n,i){i===void 0&&(i=!1);var o=r.call(this,e,n)||this;o._diffuseTexture=null,o._ambientTexture=null,o._opacityTexture=null,o._reflectionTexture=null,o._emissiveTexture=null,o._specularTexture=null,o._bumpTexture=null,o._lightmapTexture=null,o._refractionTexture=null,o.ambientColor=new z.v9(0,0,0),o.diffuseColor=new z.v9(1,1,1),o.specularColor=new z.v9(1,1,1),o.emissiveColor=new z.v9(0,0,0),o.specularPower=64,o._useAlphaFromDiffuseTexture=!1,o._useEmissiveAsIllumination=!1,o._linkEmissiveWithDiffuse=!1,o._useSpecularOverAlpha=!1,o._useReflectionOverAlpha=!1,o._disableLighting=!1,o._useObjectSpaceNormalMap=!1,o._useParallax=!1,o._useParallaxOcclusion=!1,o.parallaxScaleBias=.05,o._roughness=0,o.indexOfRefraction=.98,o.invertRefractionY=!0,o.alphaCutOff=.4,o._useLightmapAsShadowmap=!1,o._useReflectionFresnelFromSpecular=!1,o._useGlossinessFromSpecularMapAlpha=!1,o._maxSimultaneousLights=4,o._invertNormalMapX=!1,o._invertNormalMapY=!1,o._twoSidedLighting=!1,o._applyDecalMapAfterDetailMap=!1,o._shadersLoaded=!1,o._renderTargets=new er.L(16),o._worldViewProjectionMatrix=_.uq.Zero(),o._globalAmbientColor=new z.v9(0,0,0),o._cacheHasRenderTargetTextures=!1;var a=o.getScene().getEngine();return!a.isWebGPU||i||t.ForceGLSL||(o._uniformBuffer&&o._uniformBuffer.dispose(),o._uniformBuffer=new Ui.D(a,void 0,void 0,o.name,!0),o._shaderLanguage=1),o.detailMap=new Bs(o),o._attachImageProcessingConfiguration(null),o.prePassConfiguration=new Da,o.getRenderTargetTextures=function(){return o._renderTargets.reset(),t.ReflectionTextureEnabled&&o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),t.RefractionTextureEnabled&&o._refractionTexture&&o._refractionTexture.isRenderTarget&&o._renderTargets.push(o._refractionTexture),o._eventInfo.renderTargets=o._renderTargets,o._callbackPluginEventFillRenderTargetTextures(o._eventInfo),o._renderTargets},o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var n=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"isPrePassCapable",{get:function(){return!this.disableDepthWrite},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canRenderToMRT",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!!(t.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(t.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)||this._cacheHasRenderTargetTextures},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"StandardMaterial"},t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled)},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===Lt.MATERIAL_ALPHATEST)},t.prototype._shouldUseAlphaFromDiffuseTexture=function(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==Lt.MATERIAL_OPAQUE},t.prototype._hasAlphaChannel=function(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._opacityTexture!=null},t.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},t.prototype.isReadyForSubMesh=function(e,n,i){var o=this;i===void 0&&(i=!1),this._uniformBufferLayoutBuilt||this.buildUniformLayout();var a=n._drawWrapper;if(a.effect&&this.isFrozen&&a._wasPreviouslyReady&&a._wasPreviouslyUsingInstances===i)return!0;n.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),n.materialDefines=new zm(this._eventInfo.defineNames));var s=this.getScene(),l=n.materialDefines;if(this._isReadyForSubMesh(n))return!0;var c=s.getEngine();l._needNormals=(0,Re.az)(s,e,l,!0,this._maxSimultaneousLights,this._disableLighting),(0,Re.VO)(s,l);var u=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if((0,Re.N4)(s,l,this.canRenderToMRT&&!u),(0,Re.Nc)(s,l,u),l._areTexturesDirty){this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,l._needUVs=!1;for(var d=1;d<=P.Y.MAX_SUPPORTED_UV_SETS;++d)l["MAINUV"+d]=!1;if(s.texturesEnabled){if(l.DIFFUSEDIRECTUV=0,l.BUMPDIRECTUV=0,l.AMBIENTDIRECTUV=0,l.OPACITYDIRECTUV=0,l.EMISSIVEDIRECTUV=0,l.SPECULARDIRECTUV=0,l.LIGHTMAPDIRECTUV=0,this._diffuseTexture&&t.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;(0,Re.YT)(this._diffuseTexture,l,"DIFFUSE")}else l.DIFFUSE=!1;if(this._ambientTexture&&t.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;(0,Re.YT)(this._ambientTexture,l,"AMBIENT")}else l.AMBIENT=!1;if(this._opacityTexture&&t.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;(0,Re.YT)(this._opacityTexture,l,"OPACITY"),l.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else l.OPACITY=!1;if(this._reflectionTexture&&t.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(l._needNormals=!0,l.REFLECTION=!0,l.ROUGHNESS=this._roughness>0,l.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,l.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===Ie.g.INVCUBIC_MODE,l.REFLECTIONMAP_3D=this._reflectionTexture.isCube,l.REFLECTIONMAP_OPPOSITEZ=l.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!this._reflectionTexture.invertZ:this._reflectionTexture.invertZ,l.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case Ie.g.EXPLICIT_MODE:l.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case Ie.g.PLANAR_MODE:l.setReflectionMode("REFLECTIONMAP_PLANAR");break;case Ie.g.PROJECTION_MODE:l.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case Ie.g.SKYBOX_MODE:l.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case Ie.g.SPHERICAL_MODE:l.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case Ie.g.EQUIRECTANGULAR_MODE:l.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case Ie.g.FIXED_EQUIRECTANGULAR_MODE:l.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case Ie.g.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:l.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case Ie.g.CUBIC_MODE:case Ie.g.INVCUBIC_MODE:default:l.setReflectionMode("REFLECTIONMAP_CUBIC")}l.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else l.REFLECTION=!1,l.REFLECTIONMAP_OPPOSITEZ=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;(0,Re.YT)(this._emissiveTexture,l,"EMISSIVE")}else l.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;(0,Re.YT)(this._lightmapTexture,l,"LIGHTMAP"),l.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,l.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else l.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;(0,Re.YT)(this._specularTexture,l,"SPECULAR"),l.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else l.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;(0,Re.YT)(this._bumpTexture,l,"BUMP"),l.PARALLAX=this._useParallax,l.PARALLAX_RHS=s.useRightHandedSystem,l.PARALLAXOCCLUSION=this._useParallaxOcclusion,l.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else l.BUMP=!1,l.PARALLAX=!1,l.PARALLAX_RHS=!1,l.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;l._needUVs=!0,l.REFRACTION=!0,l.REFRACTIONMAP_3D=this._refractionTexture.isCube,l.RGBDREFRACTION=this._refractionTexture.isRGBD,l.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize}else l.REFRACTION=!1;l.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else l.DIFFUSE=!1,l.AMBIENT=!1,l.OPACITY=!1,l.REFLECTION=!1,l.EMISSIVE=!1,l.LIGHTMAP=!1,l.BUMP=!1,l.REFRACTION=!1;l.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),l.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,l.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,l.SPECULAROVERALPHA=this._useSpecularOverAlpha,l.PREMULTIPLYALPHA=this.alphaMode===P.Y.ALPHA_PREMULTIPLIED||this.alphaMode===P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF,l.ALPHATEST_AFTERALLALPHACOMPUTATIONS=this.transparencyMode!==null,l.ALPHABLEND=this.transparencyMode===null||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=l,this._eventInfo.subMesh=n,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(l._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(l),l.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,l.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}l._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(l.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,l.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,l.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,l.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,l.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,l.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,l._needNormals=!0,l.FRESNEL=!0):l.FRESNEL=!1),(0,Re.fm)(e,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,l,this._applyDecalMapAfterDetailMap),(0,Re.OR)(s,c,this,l,i,null,n.getRenderingMesh().hasThinInstances),this._eventInfo.defines=l,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),(0,Re.qB)(e,l,!0,!0,!0),this._callbackPluginEventPrepareDefines(this._eventInfo);var h=!1;if(l.isDirty){var p=l._areLightsDisposed;l.markAsProcessed();var m=new Tr;l.REFLECTION&&m.addFallback(0,"REFLECTION"),l.SPECULAR&&m.addFallback(0,"SPECULAR"),l.BUMP&&m.addFallback(0,"BUMP"),l.PARALLAX&&m.addFallback(1,"PARALLAX"),l.PARALLAX_RHS&&m.addFallback(1,"PARALLAX_RHS"),l.PARALLAXOCCLUSION&&m.addFallback(0,"PARALLAXOCCLUSION"),l.SPECULAROVERALPHA&&m.addFallback(0,"SPECULAROVERALPHA"),l.FOG&&m.addFallback(1,"FOG"),l.POINTSIZE&&m.addFallback(0,"POINTSIZE"),l.LOGARITHMICDEPTH&&m.addFallback(0,"LOGARITHMICDEPTH"),(0,Re.c4)(l,m,this._maxSimultaneousLights),l.SPECULARTERM&&m.addFallback(0,"SPECULARTERM"),l.DIFFUSEFRESNEL&&m.addFallback(1,"DIFFUSEFRESNEL"),l.OPACITYFRESNEL&&m.addFallback(2,"OPACITYFRESNEL"),l.REFLECTIONFRESNEL&&m.addFallback(3,"REFLECTIONFRESNEL"),l.EMISSIVEFRESNEL&&m.addFallback(4,"EMISSIVEFRESNEL"),l.FRESNEL&&m.addFallback(4,"FRESNEL"),l.MULTIVIEW&&m.addFallback(0,"MULTIVIEW");var v=[Y.R.PositionKind];for(l.NORMAL&&v.push(Y.R.NormalKind),l.TANGENT&&v.push(Y.R.TangentKind),d=1;d<=P.Y.MAX_SUPPORTED_UV_SETS;++d)l["UV"+d]&&v.push("uv".concat(d===1?"":d));l.VERTEXCOLOR&&v.push(Y.R.ColorKind),(0,Re.ni)(v,e,l,m),(0,Re.ER)(v,l),(0,Re.IF)(v,e,l),(0,Re.J2)(v,e,l);var b="default",E=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","vRefractionPosition","vRefractionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth","morphTargetTextureInfo","morphTargetTextureIndices"],C=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],T=["Material","Scene","Mesh"],f={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:l.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=m,this._eventInfo.fallbackRank=0,this._eventInfo.defines=l,this._eventInfo.uniforms=E,this._eventInfo.attributes=v,this._eventInfo.samplers=C,this._eventInfo.uniformBuffersNames=T,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=f,this._callbackPluginEventGeneric(128,this._eventInfo),Da.AddUniforms(E),Da.AddSamplers(C),Ti.p&&(Ti.p.PrepareUniforms(E,l),Ti.p.PrepareSamplers(C,l)),(0,Re.Bb)({uniformsNames:E,uniformBuffersNames:T,samplers:C,defines:l,maxSimultaneousLights:this._maxSimultaneousLights}),(0,tn.TV)(E);var g={};this.customShaderNameResolve&&(b=this.customShaderNameResolve(b,E,T,C,l,v,g));var S=l.toString(),y=n.effect,x=s.getEngine().createEffect(b,{attributes:v,uniformsNames:E,uniformBuffersNames:T,samplers:C,defines:S,fallbacks:m,onCompiled:this.onCompiled,onError:this.onError,indexParameters:f,processFinalCode:g.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:l.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:function(){return(0,A.sH)(o,void 0,void 0,function(){return(0,A.YH)(this,function(R){switch(R.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,66904)),Promise.resolve().then(L.bind(L,85588))])];case 1:return R.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,84765)),Promise.resolve().then(L.bind(L,23667))])];case 3:R.sent(),R.label=4;case 4:return this._shadersLoaded=!0,[2]}})})}},c);if(this._eventInfo.customCode=void 0,x)if(this._onEffectCreatedObservable&&(km.effect=x,km.subMesh=n,this._onEffectCreatedObservable.notifyObservers(km)),this.allowShaderHotSwapping&&y&&!x.isReady()){if(x=y,l.markAsUnprocessed(),h=this.isFrozen,p)return l._areLightsDisposed=!0,!1}else s.resetCachedMaterial(),n.setEffect(x,l,this._materialContext)}return!(!n.effect||!n.effect.isReady()||(l._renderId=s.getRenderId(),a._wasPreviouslyReady=!h,a._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),0))},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("alphaCutOff",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vRefractionPosition",3),e.addUniform("vRefractionSize",3),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vDiffuseColor",4),e.addUniform("vAmbientColor",3),r.prototype.buildUniformLayout.call(this)},t.prototype.bindForSubMesh=function(e,n,i){var o,a=this.getScene(),s=i.materialDefines;if(s){var l=i.effect;if(l){this._activeEffect=l,n.getMeshUniformBuffer().bindToEffect(l,"Mesh"),n.transferToEffect(e),this._uniformBuffer.bindToEffect(l,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,a,n,e,this.isFrozen),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var c=this._mustRebind(a,l,i,n.visibility);(0,Re.f$)(n,l);var u=this._uniformBuffer;if(c){if(this.bindViewProjection(l),!u.useUbo||!this.isFrozen||!u.isSync||i._drawWrapper._forceRebindOnNextCall){if(t.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(u.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),u.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&u.updateColor4("opacityParts",new z.v9(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(u.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),u.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(u.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),u.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(u.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),u.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),a.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(u.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),(0,Re.mA)(this._diffuseTexture,u,"diffuse")),this._ambientTexture&&t.AmbientTextureEnabled&&(u.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),(0,Re.mA)(this._ambientTexture,u,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(u.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),(0,Re.mA)(this._opacityTexture,u,"opacity")),this._hasAlphaChannel()&&u.updateFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&t.ReflectionTextureEnabled&&(u.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),u.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var d=this._reflectionTexture;u.updateVector3("vReflectionPosition",d.boundingBoxPosition),u.updateVector3("vReflectionSize",d.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(u.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),(0,Re.mA)(this._emissiveTexture,u,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(u.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),(0,Re.mA)(this._lightmapTexture,u,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(u.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),(0,Re.mA)(this._specularTexture,u,"specular")),this._bumpTexture&&a.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(u.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),(0,Re.mA)(this._bumpTexture,u,"bump"),a._mirroredCameraPosition?u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var h=1;this._refractionTexture.isCube||(u.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(h=this._refractionTexture.depth)),u.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,h,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize&&(d=this._refractionTexture,u.updateVector3("vRefractionPosition",d.boundingBoxPosition),u.updateVector3("vRefractionSize",d.boundingBoxSize))}}this.pointsCloud&&u.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&u.updateColor4("vSpecularColor",this.specularColor,this.specularPower),u.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:z.v9.BlackReadOnly),u.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),a.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),u.updateColor3("vAmbientColor",this._globalAmbientColor)}a.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&l.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&l.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&l.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?l.setTexture("reflectionCubeSampler",this._reflectionTexture):l.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&l.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&l.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&l.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&a.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&l.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled&&(this._refractionTexture.isCube?l.setTexture("refractionCubeSampler",this._refractionTexture):l.setTexture("refraction2DSampler",this._refractionTexture))),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(n)&&this.getScene().depthPeelingRenderer.bind(l),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),(0,tn.gS)(l,this,a),this.bindEyePosition(l)}else a.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!c&&this.isFrozen||(a.lightsEnabled&&!this._disableLighting&&(0,Re.RL)(a,n,l,s,this._maxSimultaneousLights),(a.fogEnabled&&n.applyFog&&a.fogMode!==ke.Z.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||n.receiveShadows||s.PREPASS)&&this.bindView(l),(0,Re.Yy)(a,n,l),s.NUM_MORPH_INFLUENCERS&&(0,Re.nR)(n,l),s.BAKED_VERTEX_ANIMATION_TEXTURE&&((o=n.bakedVertexAnimationManager)===null||o===void 0||o.bind(l,s.INSTANCES)),this.useLogarithmicDepth&&(0,Re.DL)(s,l,a),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(n,this._activeEffect,i),u.update()}}},t.prototype.getAnimatables=function(){var e=r.prototype.getAnimatables.call(this);return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},t.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},t.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||this._diffuseTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._specularTexture===e||this._bumpTexture===e||this._lightmapTexture===e||this._refractionTexture===e},t.prototype.dispose=function(e,n){var i,o,a,s,l,c,u,d,h;n&&((i=this._diffuseTexture)===null||i===void 0||i.dispose(),(o=this._ambientTexture)===null||o===void 0||o.dispose(),(a=this._opacityTexture)===null||a===void 0||a.dispose(),(s=this._reflectionTexture)===null||s===void 0||s.dispose(),(l=this._emissiveTexture)===null||l===void 0||l.dispose(),(c=this._specularTexture)===null||c===void 0||c.dispose(),(u=this._bumpTexture)===null||u===void 0||u.dispose(),(d=this._lightmapTexture)===null||d===void 0||d.dispose(),(h=this._refractionTexture)===null||h===void 0||h.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,n)},t.prototype.clone=function(e,n,i){var o=this;n===void 0&&(n=!0),i===void 0&&(i="");var a=tt.p.Clone(function(){return new t(e,o.getScene())},this,{cloneTexturesOnlyOnce:n});return a.name=e,a.id=e,this.stencil.copyTo(a.stencil),this._clonePlugins(a,i),a},t.Parse=function(e,n,i){var o=tt.p.Parse(function(){return new t(e.name,n)},e,n,i);return e.stencil&&o.stencil.parse(e.stencil,n,i),Lt._ParsePlugins(e,o,n,i),o},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return $e.DiffuseTextureEnabled},set:function(e){$e.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DetailTextureEnabled",{get:function(){return $e.DetailTextureEnabled},set:function(e){$e.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return $e.AmbientTextureEnabled},set:function(e){$e.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return $e.OpacityTextureEnabled},set:function(e){$e.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return $e.ReflectionTextureEnabled},set:function(e){$e.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return $e.EmissiveTextureEnabled},set:function(e){$e.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return $e.SpecularTextureEnabled},set:function(e){$e.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return $e.BumpTextureEnabled},set:function(e){$e.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return $e.LightmapTextureEnabled},set:function(e){$e.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return $e.RefractionTextureEnabled},set:function(e){$e.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return $e.ColorGradingTextureEnabled},set:function(e){$e.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return $e.FresnelEnabled},set:function(e){$e.FresnelEnabled=e},enumerable:!1,configurable:!0}),t.ForceGLSL=!1,(0,A.Cg)([(0,V.uM)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),(0,A.Cg)([(0,V.uM)("ambientTexture")],t.prototype,"_ambientTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),(0,A.Cg)([(0,V.uM)("opacityTexture")],t.prototype,"_opacityTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),(0,A.Cg)([(0,V.uM)("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),(0,A.Cg)([(0,V.uM)("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),(0,A.Cg)([(0,V.uM)("specularTexture")],t.prototype,"_specularTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),(0,A.Cg)([(0,V.uM)("bumpTexture")],t.prototype,"_bumpTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),(0,A.Cg)([(0,V.uM)("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),(0,A.Cg)([(0,V.uM)("refractionTexture")],t.prototype,"_refractionTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),(0,A.Cg)([(0,V.jT)("ambient")],t.prototype,"ambientColor",void 0),(0,A.Cg)([(0,V.jT)("diffuse")],t.prototype,"diffuseColor",void 0),(0,A.Cg)([(0,V.jT)("specular")],t.prototype,"specularColor",void 0),(0,A.Cg)([(0,V.jT)("emissive")],t.prototype,"emissiveColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"specularPower",void 0),(0,A.Cg)([(0,V.lK)("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),(0,A.Cg)([(0,V.lK)("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),(0,A.Cg)([(0,V.lK)("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),(0,A.Cg)([(0,V.lK)("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),(0,A.Cg)([(0,V.lK)("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),(0,A.Cg)([(0,V.lK)("disableLighting")],t.prototype,"_disableLighting",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),(0,A.Cg)([(0,V.lK)("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),(0,A.Cg)([(0,V.lK)("useParallax")],t.prototype,"_useParallax",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),(0,A.Cg)([(0,V.lK)("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"parallaxScaleBias",void 0),(0,A.Cg)([(0,V.lK)("roughness")],t.prototype,"_roughness",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"indexOfRefraction",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"invertRefractionY",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"alphaCutOff",void 0),(0,A.Cg)([(0,V.lK)("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),(0,A.Cg)([(0,V.Y9)("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),(0,A.Cg)([(0,V.Y9)("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),(0,A.Cg)([(0,V.Y9)("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),(0,A.Cg)([(0,V.Y9)("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),(0,A.Cg)([(0,V.Y9)("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),(0,A.Cg)([(0,V.lK)("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),(0,A.Cg)([(0,V.lK)("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),(0,A.Cg)([(0,V.lK)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),(0,A.Cg)([(0,V.lK)("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),(0,A.Cg)([(0,V.lK)("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),(0,A.Cg)([(0,V.lK)("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),(0,A.Cg)([(0,V.lK)("applyDecalMapAfterDetailMap")],t.prototype,"_applyDecalMapAfterDetailMap",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"applyDecalMapAfterDetailMap",void 0),t}(Ro);(0,j.Y5)("BABYLON.StandardMaterial",qt),ke.Z.DefaultMaterialFactory=function(r){return new qt("default material",r)},an.w.prototype.createDynamicTexture=function(r,t,e,n){var i=new rn.h(this,4);return i.baseWidth=r,i.baseHeight=t,e&&(r=this.needPOTTextures?(0,ir.R)(r,this._caps.maxTextureSize):r,t=this.needPOTTextures?(0,ir.R)(t,this._caps.maxTextureSize):t),i.width=r,i.height=t,i.isReady=!1,i.generateMipMaps=e,i.samplingMode=n,this.updateTextureSamplingMode(n,i),this._internalTexturesCache.push(i),i},an.w.prototype.updateDynamicTexture=function(r,t,e,n,i,o,a){if(n===void 0&&(n=!1),o===void 0&&(o=!1),r){var s=this._gl,l=s.TEXTURE_2D,c=this._bindTextureDirectly(l,r,!0,o);this._unpackFlipY(e===void 0?r.invertY:e),n&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var u=this._getWebGLTextureType(r.type),d=this._getInternalFormat(i||r.format),h=this._getRGBABufferInternalSizedFormat(r.type,d);s.texImage2D(l,0,h,d,u,t),r.generateMipMaps&&s.generateMipmap(l),c||this._bindTextureDirectly(l,null),n&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),i&&(r.format=i),r._dynamicTextureSource=t,r._premulAlpha=n,r.invertY=e||!1,r.isReady=!0}};var Oo=function(r){function t(e,n,i,o,a,s,l){i===void 0&&(i=null),o===void 0&&(o=!1),a===void 0&&(a=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),s===void 0&&(s=P.Y.TEXTUREFORMAT_RGBA);var c=r.call(this,null,i,!o,l,a,void 0,void 0,void 0,void 0,s)||this;c.name=e,c.wrapU=Ie.g.CLAMP_ADDRESSMODE,c.wrapV=Ie.g.CLAMP_ADDRESSMODE,c._generateMipMaps=o;var u=c._getEngine();if(!u)return c;n.getContext?(c._canvas=n,c._ownCanvas=!1,c._texture=u.createDynamicTexture(n.width,n.height,o,a)):(c._canvas=u.createCanvas(1,1),c._ownCanvas=!0,n.width||n.width===0?c._texture=u.createDynamicTexture(n.width,n.height,o,a):c._texture=u.createDynamicTexture(n,n,o,a));var d=c.getSize();return c._canvas.width!==d.width&&(c._canvas.width=d.width),c._canvas.height!==d.height&&(c._canvas.height=d.height),c._context=c._canvas.getContext("2d"),c}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)},t.prototype.scale=function(e){var n=this.getSize();n.width*=e,n.height*=e,this._recreate(n)},t.prototype.scaleTo=function(e,n){var i=this.getSize();i.width=e,i.height=n,this._recreate(i)},t.prototype.getContext=function(){return this._context},t.prototype.clear=function(e){var n=this.getSize();e&&(this._context.fillStyle=e),this._context.clearRect(0,0,n.width,n.height)},t.prototype.update=function(e,n,i){n===void 0&&(n=!1),i===void 0&&(i=!1),this._getEngine().updateDynamicTexture(this._texture,this._canvas,e===void 0||e,n,this._format||void 0,void 0,i)},t.prototype.drawText=function(e,n,i,o,a,s,l,c){c===void 0&&(c=!0);var u=this.getSize();if(s&&(this._context.fillStyle=s,this._context.fillRect(0,0,u.width,u.height)),this._context.font=o,n==null){var d=this._context.measureText(e);n=(u.width-d.width)/2}if(i==null){var h=parseInt(o.replace(/\D/g,""));i=u.height/2+h/3.65}this._context.fillStyle=a||"",this._context.fillText(e,n,i),c&&this.update(l)},t.prototype.dispose=function(){var e,n;r.prototype.dispose.call(this),this._ownCanvas&&((n=(e=this._canvas)===null||e===void 0?void 0:e.remove)===null||n===void 0||n.call(e)),this._canvas=null,this._context=null},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=this.getSize(),i=new t(this.name,n,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.wrapU=this.wrapU,i.wrapV=this.wrapV,i},t.prototype.serialize=function(){var e=this.getScene();e&&!e.isReady()&&O.V.Warn("The scene must be ready before serializing the dynamic texture");var n=r.prototype.serialize.call(this);return t._IsCanvasElement(this._canvas)&&(n.base64String=this._canvas.toDataURL()),n.invertY=this._invertY,n.samplingMode=this.samplingMode,n},t._IsCanvasElement=function(e){return e.toDataURL!==void 0},t.prototype._rebuild=function(){this.update()},t}(Ie.g),Wm=function(){function r(t,e,n,i,o){this.getWidth=t,this.getHeight=e,this.layer=n,this.layerType=i,this._createRenderTargetTextureProvider=o,this._rttWrapper=null}return Object.defineProperty(r.prototype,"isFixedFoveationSupported",{get:function(){return this.layerType=="XRWebGLLayer"&&typeof this.layer.fixedFoveation=="number"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fixedFoveation",{get:function(){return this.isFixedFoveationSupported?this.layer.fixedFoveation:null},set:function(t){if(this.isFixedFoveationSupported){var e=Math.max(0,Math.min(1,t||0));this.layer.fixedFoveation=e}},enumerable:!1,configurable:!0}),r.prototype.createRenderTargetTextureProvider=function(t){return this._rttWrapper=this._createRenderTargetTextureProvider(t),this._rttWrapper},r.prototype.dispose=function(){this._rttWrapper&&(this._rttWrapper.dispose(),this._rttWrapper=null)},r}(),Vs=function(){function r(t,e){this._scene=t,this.layerWrapper=e,this._renderTargetTextures=new Array,this._engine=t.getEngine()}return r.prototype._createInternalTexture=function(t,e){var n=new rn.h(this._engine,0,!0);return n.width=t.width,n.height=t.height,n._hardwareTexture=new ea.d(e,this._engine._gl),n.isReady=!0,n},r.prototype._createRenderTargetTexture=function(t,e,n,i,o,a){if(!this._engine)throw new Error("Engine is disposed");var s={width:t,height:e},l=a?new Nm(this._scene,s):new un.$("XR renderTargetTexture",s,this._scene),c=l.renderTarget;if(c._samples=l.samples,!n&&i||(c._framebuffer=n),i)if(a)c._colorTextureArray=i;else{var u=this._createInternalTexture(s,i);c.setTexture(u,0),l._texture=u}return o&&(a?c._depthStencilTextureArray=o:c._depthStencilTexture=this._createInternalTexture(s,o)),l.disableRescaling(),this._renderTargetTextures.push(l),l},r.prototype._destroyRenderTargetTexture=function(t){this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(t),1),t.dispose()},r.prototype.getFramebufferDimensions=function(){return this._framebufferDimensions},r.prototype.dispose=function(){this._renderTargetTextures.forEach(function(t){return t.dispose()}),this._renderTargetTextures.length=0},r}(),Hm=function(r){function t(e){var n=r.call(this,function(){return e.framebufferWidth},function(){return e.framebufferHeight},e,"XRWebGLLayer",function(i){return new $1(i.scene,n)})||this;return n.layer=e,n}return(0,A.C6)(t,r),t}(Wm),$1=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.layerWrapper=n,i._layer=n.layer,i._framebufferDimensions={framebufferWidth:i._layer.framebufferWidth,framebufferHeight:i._layer.framebufferHeight},i}return(0,A.C6)(t,r),t.prototype.trySetViewportForView=function(e,n){var i=this._layer.getViewport(n);if(!i)return!1;var o=this._framebufferDimensions.framebufferWidth,a=this._framebufferDimensions.framebufferHeight;return e.x=i.x/o,e.y=i.y/a,e.width=i.width/o,e.height=i.height/a,!0},t.prototype.getRenderTargetTextureForEye=function(e){var n=this._layer.framebufferWidth,i=this._layer.framebufferHeight,o=this._layer.framebuffer;return this._rtt&&n===this._framebufferDimensions.framebufferWidth&&i===this._framebufferDimensions.framebufferHeight&&o===this._framebuffer||(this._rtt=this._createRenderTargetTexture(n,i,o),this._framebufferDimensions.framebufferWidth=n,this._framebufferDimensions.framebufferHeight=i,this._framebuffer=o),this._rtt},t.prototype.getRenderTargetTextureForView=function(e){return this.getRenderTargetTextureForEye(e.eye)},t}(Vs),yu=function(){function r(){}return r.GetDefaults=function(t){var e=new r;return e.canvasOptions={antialias:!0,depth:!0,stencil:!t||t.isStencilEnable,alpha:!0,framebufferScaleFactor:1},e.newCanvasCssStyle="position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",e},r}(),Ym=function(){function r(t,e){e===void 0&&(e=yu.GetDefaults());var n=this;if(this._options=e,this._canvas=null,this._engine=null,this.xrLayer=null,this._xrLayerWrapper=null,this.onXRLayerInitObservable=new K.cP,this._engine=t.scene.getEngine(),this._engine.onDisposeObservable.addOnce(function(){n._engine=null}),e.canvasElement)this._setManagedOutputCanvas(e.canvasElement);else{var i=document.createElement("canvas");i.style.cssText=this._options.newCanvasCssStyle||"position:absolute; bottom:0px;right:0px;",this._setManagedOutputCanvas(i)}t.onXRSessionInit.add(function(){n._addCanvas()}),t.onXRSessionEnded.add(function(){n._removeCanvas()}),this._makeCanvasCompatibleAsync()}return r.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},r.prototype._makeCanvasCompatibleAsync=function(){var t=this;this._canvasCompatiblePromise=new Promise(function(e,n){try{t.canvasContext&&t.canvasContext.makeXRCompatible?t.canvasContext.makeXRCompatible().then(function(){e()},function(){ze.S0.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly."),e()}):e()}catch(i){n(i)}})},r.prototype.initializeXRLayerAsync=function(t){return(0,A.sH)(this,void 0,void 0,function(){var e,n=this;return(0,A.YH)(this,function(i){return e=function(){return n.xrLayer=new XRWebGLLayer(t,n.canvasContext,n._options.canvasOptions),n._xrLayerWrapper=new Hm(n.xrLayer),n.onXRLayerInitObservable.notifyObservers(n.xrLayer),n.xrLayer},[2,this._canvasCompatiblePromise.then(function(){},function(){}).then(function(){return e()})]})})},r.prototype._addCanvas=function(){var t=this;this._canvas&&this._engine&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.appendChild(this._canvas),this.xrLayer?this._setCanvasSize(!0):this.onXRLayerInitObservable.addOnce(function(){t._setCanvasSize(!0)})},r.prototype._removeCanvas=function(){this._canvas&&this._engine&&document.body.contains(this._canvas)&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.removeChild(this._canvas),this._setCanvasSize(!1)},r.prototype._setCanvasSize=function(t,e){t===void 0&&(t=!0),e===void 0&&(e=this._xrLayerWrapper),this._canvas&&this._engine&&(t?e&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=e.getWidth()+"px",this._canvas.style.height=e.getHeight()+"px"):this._engine.setSize(e.getWidth(),e.getHeight())):this._originalCanvasSize&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=this._originalCanvasSize.width+"px",this._canvas.style.height=this._originalCanvasSize.height+"px"):this._engine.setSize(this._originalCanvasSize.width,this._originalCanvasSize.height)))},r.prototype._setManagedOutputCanvas=function(t){this._removeCanvas(),t?(this._originalCanvasSize={width:t.offsetWidth,height:t.offsetHeight},this._canvas=t,this.canvasContext=this._canvas.getContext("webgl2"),this.canvasContext||(this.canvasContext=this._canvas.getContext("webgl"))):(this._canvas=null,this.canvasContext=null)},r}(),Xm=function(r){function t(e){var n=r.call(this,function(){return e.framebufferWidth},function(){return e.framebufferHeight},e,"XRWebGLLayer",function(i){return new jm(i,n)})||this;return n.layer=e,n}return(0,A.C6)(t,r),t}(Wm),jm=function(r){function t(e,n){var i=r.call(this,e.scene,n)||this;return i.layerWrapper=n,i._nativeRTTProvider=navigator.xr.getNativeRenderTargetProvider(e.session,i._createRenderTargetTexture.bind(i),i._destroyRenderTargetTexture.bind(i)),i._nativeLayer=n.layer,i}return(0,A.C6)(t,r),t.prototype.trySetViewportForView=function(e){return e.x=0,e.y=0,e.width=1,e.height=1,!0},t.prototype.getRenderTargetTextureForEye=function(e){return this._nativeRTTProvider.getRenderTargetForEye(e)},t.prototype.getRenderTargetTextureForView=function(e){return this._nativeRTTProvider.getRenderTargetForEye(e.eye)},t.prototype.getFramebufferDimensions=function(){return{framebufferWidth:this._nativeLayer.framebufferWidth,framebufferHeight:this._nativeLayer.framebufferHeight}},t}(Vs),qm=function(){function r(t){this._nativeRenderTarget=navigator.xr.getWebXRRenderTarget(t.scene.getEngine())}return r.prototype.initializeXRLayerAsync=function(t){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return[4,this._nativeRenderTarget.initializeXRLayerAsync(t)];case 1:return e.sent(),this.xrLayer=this._nativeRenderTarget.xrLayer,[2,this.xrLayer]}})})},r.prototype.dispose=function(){},r}(),bu=function(){function r(t){var e=this;this.scene=t,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new K.cP,this.onXRReferenceSpaceChanged=new K.cP,this.onXRSessionEnded=new K.cP,this.onXRSessionInit=new K.cP,this.onXRReferenceSpaceInitialized=new K.cP,this.onXRReady=new K.cP,this.inXRFrameLoop=!1,this.inXRSession=!1,this._worldScalingFactor=1,this.onWorldScaleFactorChangedObservable=new K.cP(void 0,!0),this._engine=t.getEngine(),this._onEngineDisposedObserver=this._engine.onDisposeObservable.addOnce(function(){e._engine=null}),t.onDisposeObservable.addOnce(function(){e.dispose()})}return Object.defineProperty(r.prototype,"worldScalingFactor",{get:function(){return this._worldScalingFactor},set:function(t){var e=this._worldScalingFactor;this._worldScalingFactor=t,this.onWorldScaleFactorChangedObservable.notifyObservers({previousScaleFactor:e,newScaleFactor:t})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"referenceSpace",{get:function(){return this._referenceSpace},set:function(t){this._referenceSpace=t,this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sessionMode",{get:function(){return this._sessionMode},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){var t;this.inXRSession&&this.exitXRAsync(),this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear(),this.onXRReferenceSpaceChanged.clear(),this.onXRSessionInit.clear(),this.onWorldScaleFactorChangedObservable.clear(),(t=this._engine)===null||t===void 0||t.onDisposeObservable.remove(this._onEngineDisposedObserver),this._engine=null},r.prototype.exitXRAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:if(!this.session||!this.inXRSession)return[3,4];this.inXRSession=!1,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.session.end()];case 2:return[2,t.sent()];case 3:return t.sent(),O.V.Warn("Could not end XR session."),[3,4];case 4:return[2,Promise.resolve()]}})})},r.prototype.trySetViewportForView=function(t,e){var n;return((n=this._baseLayerRTTProvider)===null||n===void 0?void 0:n.trySetViewportForView(t,e))||!1},r.prototype.getRenderTargetTextureForEye=function(t){var e;return((e=this._baseLayerRTTProvider)===null||e===void 0?void 0:e.getRenderTargetTextureForEye(t))||null},r.prototype.getRenderTargetTextureForView=function(t){var e;return((e=this._baseLayerRTTProvider)===null||e===void 0?void 0:e.getRenderTargetTextureForView(t))||null},r.prototype.getWebXRRenderTarget=function(t){var e=this.scene.getEngine();return this._xrNavigator.xr.native?new qm(this):((t=t||yu.GetDefaults(e)).canvasElement=t.canvasElement||e.getRenderingCanvas()||void 0,new Ym(this,t))},r.prototype.initializeAsync=function(){return this._xrNavigator=navigator,this._xrNavigator.xr?Promise.resolve():Promise.reject("WebXR not available")},r.prototype.initializeSessionAsync=function(t,e){var n=this;return t===void 0&&(t="immersive-vr"),e===void 0&&(e={}),this._xrNavigator.xr.requestSession(t,e).then(function(i){return n.session=i,n._sessionMode=t,n.inXRSession=!0,n.onXRSessionInit.notifyObservers(i),n.session.addEventListener("end",function(){var o;n.inXRSession=!1,n.onXRSessionEnded.notifyObservers(null),n._engine&&(n._engine.framebufferDimensionsObject=null,n._engine.restoreDefaultFramebuffer(),n._engine.customAnimationFrameRequester=null,n._engine._renderLoop()),n.isNative&&((o=n._baseLayerRTTProvider)===null||o===void 0||o.dispose()),n._baseLayerRTTProvider=null,n._baseLayerWrapper=null},{once:!0}),n.session})},r.prototype.isSessionSupportedAsync=function(t){return r.IsSessionSupportedAsync(t)},r.prototype.resetReferenceSpace=function(){this.referenceSpace=this.baseReferenceSpace},r.prototype.runXRRenderLoop=function(){var t,e=this;this.inXRSession&&this._engine&&(this._engine.customAnimationFrameRequester={requestAnimationFrame:function(n){return e.session.requestAnimationFrame(n)},renderFunction:function(n,i){var o;if(e.inXRSession&&e._engine&&(e.currentFrame=i,e.currentTimestamp=n,i)){e.inXRFrameLoop=!0;var a=((o=e._baseLayerRTTProvider)===null||o===void 0?void 0:o.getFramebufferDimensions())||null;e._engine.framebufferDimensionsObject!==a&&(e._engine.framebufferDimensionsObject=a),e.onXRFrameObservable.notifyObservers(i),e._engine._renderLoop(),e._engine.framebufferDimensionsObject=null,e.inXRFrameLoop=!1}}},this._engine.framebufferDimensionsObject=((t=this._baseLayerRTTProvider)===null||t===void 0?void 0:t.getFramebufferDimensions())||null,this.onXRFrameObservable.addOnce(function(){e.onXRReady.notifyObservers(e)}),typeof window<"u"&&window.cancelAnimationFrame&&window.cancelAnimationFrame(this._engine._frameHandler),this._engine._renderLoop())},r.prototype.setReferenceSpaceTypeAsync=function(t){var e=this;return t===void 0&&(t="local-floor"),this.session.requestReferenceSpace(t).then(function(n){return n},function(n){return O.V.Error("XR.requestReferenceSpace failed for the following reason: "),O.V.Error(n),O.V.Log('Defaulting to universally-supported "viewer" reference space type.'),e.session.requestReferenceSpace("viewer").then(function(i){var o=new XRRigidTransform({x:0,y:-e.defaultHeightCompensation,z:0});return i.getOffsetReferenceSpace(o)},function(i){throw O.V.Error(i),'XR initialization failed: required "viewer" reference space type not supported.'})}).then(function(n){return e.session.requestReferenceSpace("viewer").then(function(i){return e.viewerReferenceSpace=i,n})}).then(function(n){return e.referenceSpace=e.baseReferenceSpace=n,e.onXRReferenceSpaceInitialized.notifyObservers(n),e.referenceSpace})},r.prototype.updateRenderStateAsync=function(t){return Promise.resolve(this.session.updateRenderState(t))},r.prototype._setBaseLayerWrapper=function(t){var e,n;this.isNative&&((e=this._baseLayerRTTProvider)===null||e===void 0||e.dispose()),this._baseLayerWrapper=t,this._baseLayerRTTProvider=((n=this._baseLayerWrapper)===null||n===void 0?void 0:n.createRenderTargetTextureProvider(this))||null},r.prototype._getBaseLayerWrapper=function(){return this._baseLayerWrapper},r.prototype.updateRenderState=function(t){t.baseLayer&&this._setBaseLayerWrapper(this.isNative?new Xm(t.baseLayer):new Hm(t.baseLayer)),this.session.updateRenderState(t)},r.IsSessionSupportedAsync=function(t){if(!navigator.xr)return Promise.resolve(!1);var e=navigator.xr.isSessionSupported||navigator.xr.supportsSession;return e?e.call(navigator.xr,t).then(function(n){var i=n===void 0||n;return Promise.resolve(i)}).catch(function(n){return O.V.Warn(n),Promise.resolve(!1)}):Promise.resolve(!1)},Object.defineProperty(r.prototype,"isNative",{get:function(){var t;return(t=this._xrNavigator.xr.native)!==null&&t!==void 0&&t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentFrameRate",{get:function(){var t;return(t=this.session)===null||t===void 0?void 0:t.frameRate},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"supportedFrameRates",{get:function(){var t;return(t=this.session)===null||t===void 0?void 0:t.supportedFrameRates},enumerable:!1,configurable:!0}),r.prototype.updateTargetFrameRate=function(t){return this.session.updateTargetFrameRate(t)},r.prototype.runInXRFrame=function(t,e){e===void 0&&(e=!0),this.inXRFrameLoop?t():!this.inXRSession&&e||this.onXRFrameObservable.addOnce(t)},Object.defineProperty(r.prototype,"isFixedFoveationSupported",{get:function(){var t;return((t=this._baseLayerWrapper)===null||t===void 0?void 0:t.isFixedFoveationSupported)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fixedFoveation",{get:function(){var t;return((t=this._baseLayerWrapper)===null||t===void 0?void 0:t.fixedFoveation)||null},set:function(t){var e=Math.max(0,Math.min(1,t||0));this._baseLayerWrapper&&(this._baseLayerWrapper.fixedFoveation=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enabledFeatures",{get:function(){var t,e;return(e=(t=this.session)===null||t===void 0?void 0:t.enabledFeatures)!==null&&e!==void 0?e:null},enumerable:!1,configurable:!0}),r}();xe._GroundMeshParser=function(r,t){return Us.Parse(r,t)};var Us=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.generateOctree=!1,i}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!1,configurable:!0}),t.prototype.optimize=function(e,n){n===void 0&&(n=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e),this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(n)},t.prototype.getHeightAtCoordinates=function(e,n){var i=this.getWorldMatrix(),o=_.AA.Matrix[5];i.invertToRef(o);var a=_.AA.Vector3[8];if(_.Pq.TransformCoordinatesFromFloatsToRef(e,0,n,o,a),e=a.x,n=a.z,e<this._minX||e>=this._maxX||n<=this._minZ||n>this._maxZ)return this.position.y;this._heightQuads&&this._heightQuads.length!=0||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,n),l=-(s.x*e+s.z*n+s.w)/s.y;return _.Pq.TransformCoordinatesFromFloatsToRef(0,l,0,i,a),a.y},t.prototype.getNormalAtCoordinates=function(e,n){var i=new _.Pq(0,1,0);return this.getNormalAtCoordinatesToRef(e,n,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,n,i){var o=this.getWorldMatrix(),a=_.AA.Matrix[5];o.invertToRef(a);var s=_.AA.Vector3[8];if(_.Pq.TransformCoordinatesFromFloatsToRef(e,0,n,a,s),e=s.x,n=s.z,e<this._minX||e>this._maxX||n<this._minZ||n>this._maxZ)return this;this._heightQuads&&this._heightQuads.length!=0||(this._initHeightQuads(),this._computeHeightQuads());var l=this._getFacetAt(e,n);return _.Pq.TransformNormalFromFloatsToRef(l.x,l.y,l.z,o,i),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&this._heightQuads.length!=0||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,n){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),o=Math.floor(-(n+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),a=this._heightQuads[o*this._subdivisionsX+i];return n<a.slope.x*e+a.slope.y?a.facet1:a.facet2},t.prototype._initHeightQuads=function(){var e=this._subdivisionsX,n=this._subdivisionsY;this._heightQuads=new Array;for(var i=0;i<n;i++)for(var o=0;o<e;o++){var a={slope:_.I9.Zero(),facet1:new _.IU(0,0,0,0),facet2:new _.IU(0,0,0,0)};this._heightQuads[i*e+o]=a}return this},t.prototype._computeHeightQuads=function(){var e=this.getVerticesData(Y.R.PositionKind);if(!e)return this;for(var n=_.AA.Vector3[3],i=_.AA.Vector3[2],o=_.AA.Vector3[1],a=_.AA.Vector3[0],s=_.AA.Vector3[4],l=_.AA.Vector3[5],c=_.AA.Vector3[6],u=_.AA.Vector3[7],d=_.AA.Vector3[8],h=0,p=0,m=0,v=0,b=0,E=0,C=0,T=this._subdivisionsX,f=this._subdivisionsY,g=0;g<f;g++)for(var S=0;S<T;S++){h=3*S,p=g*(T+1)*3,m=(g+1)*(T+1)*3,n.x=e[p+h],n.y=e[p+h+1],n.z=e[p+h+2],i.x=e[p+h+3],i.y=e[p+h+4],i.z=e[p+h+5],o.x=e[m+h],o.y=e[m+h+1],o.z=e[m+h+2],a.x=e[m+h+3],a.y=e[m+h+4],a.z=e[m+h+5],v=(a.z-n.z)/(a.x-n.x),b=n.z-v*n.x,i.subtractToRef(n,s),o.subtractToRef(n,l),a.subtractToRef(n,c),_.Pq.CrossToRef(c,l,u),_.Pq.CrossToRef(s,c,d),u.normalize(),d.normalize(),E=-(u.x*n.x+u.y*n.y+u.z*n.z),C=-(d.x*i.x+d.y*i.y+d.z*i.z);var y=this._heightQuads[g*T+S];y.slope.copyFromFloats(v,b),y.facet1.copyFromFloats(u.x,u.y,u.z,E),y.facet2.copyFromFloats(d.x,d.y,d.z,C)}return this},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height},t.Parse=function(e,n){var i=new t(e.name,n);return i._subdivisionsX=e.subdivisionsX||1,i._subdivisionsY=e.subdivisionsY||1,i._minX=e.minX,i._maxX=e.maxX,i._minZ=e.minZ,i._maxZ=e.maxZ,i._width=e.width,i._height=e.height,i},t}(xe);function Wr(r){var t,e,n=[],i=[],o=[],a=[],s=r.width||1,l=r.height||1,c=0|(r.subdivisionsX||r.subdivisions||1),u=0|(r.subdivisionsY||r.subdivisions||1);for(t=0;t<=u;t++)for(e=0;e<=c;e++){var d=new _.Pq(e*s/c-s/2,0,(u-t)*l/u-l/2),h=new _.Pq(0,1,0);i.push(d.x,d.y,d.z),o.push(h.x,h.y,h.z),a.push(e/c,Xt.rX?t/u:1-t/u)}for(t=0;t<u;t++)for(e=0;e<c;e++)n.push(e+1+(t+1)*(c+1)),n.push(e+1+t*(c+1)),n.push(e+t*(c+1)),n.push(e+(t+1)*(c+1)),n.push(e+1+(t+1)*(c+1)),n.push(e+t*(c+1));var p=new rt;return p.indices=n,p.positions=i,p.normals=o,p.uvs=a,p}function Tu(r){var t,e,n,i,o=r.xmin!==void 0&&r.xmin!==null?r.xmin:-1,a=r.zmin!==void 0&&r.zmin!==null?r.zmin:-1,s=r.xmax!==void 0&&r.xmax!==null?r.xmax:1,l=r.zmax!==void 0&&r.zmax!==null?r.zmax:1,c=r.subdivisions||{w:1,h:1},u=r.precision||{w:1,h:1},d=[],h=[],p=[],m=[];c.h=c.h<1?1:c.h,c.w=c.w<1?1:c.w,u.w=u.w<1?1:u.w,u.h=u.h<1?1:u.h;var v=(s-o)/c.w,b=(l-a)/c.h;function E(T,f,g,S){var y=h.length/3,x=u.w+1;for(t=0;t<u.h;t++)for(e=0;e<u.w;e++){var R=[y+e+t*x,y+(e+1)+t*x,y+(e+1)+(t+1)*x,y+e+(t+1)*x];d.push(R[1]),d.push(R[2]),d.push(R[3]),d.push(R[0]),d.push(R[1]),d.push(R[3])}var I=_.Pq.Zero(),M=new _.Pq(0,1,0);for(t=0;t<=u.h;t++)for(I.z=t*(S-f)/u.h+f,e=0;e<=u.w;e++)I.x=e*(g-T)/u.w+T,I.y=0,h.push(I.x,I.y,I.z),p.push(M.x,M.y,M.z),m.push(e/u.w,t/u.h)}for(n=0;n<c.h;n++)for(i=0;i<c.w;i++)E(o+i*v,a+n*b,o+(i+1)*v,a+(n+1)*b);var C=new rt;return C.indices=d,C.positions=h,C.normals=p,C.uvs=m,C}function Su(r){var t,e,n=[],i=[],o=[],a=[],s=r.colorFilter||new z.v9(.3,.59,.11),l=r.alphaFilter||0,c=!1;if(r.minHeight>r.maxHeight){c=!0;var u=r.maxHeight;r.maxHeight=r.minHeight,r.minHeight=u}for(t=0;t<=r.subdivisions;t++)for(e=0;e<=r.subdivisions;e++){var d=new _.Pq(e*r.width/r.subdivisions-r.width/2,0,(r.subdivisions-t)*r.height/r.subdivisions-r.height/2),h=4*(((d.x+r.width/2)/r.width*(r.bufferWidth-1)|0)+((1-(d.z+r.height/2)/r.height)*(r.bufferHeight-1)|0)*r.bufferWidth),p=r.buffer[h]/255,m=r.buffer[h+1]/255,v=r.buffer[h+2]/255,b=r.buffer[h+3]/255;c&&(p=1-p,m=1-m,v=1-v);var E=p*s.r+m*s.g+v*s.b;d.y=b>=l?r.minHeight+(r.maxHeight-r.minHeight)*E:r.minHeight-pt.bH,r.heightBuffer&&(r.heightBuffer[t*(r.subdivisions+1)+e]=d.y),i.push(d.x,d.y,d.z),o.push(0,0,0),a.push(e/r.subdivisions,1-t/r.subdivisions)}for(t=0;t<r.subdivisions;t++)for(e=0;e<r.subdivisions;e++){var C=e+1+(t+1)*(r.subdivisions+1),T=e+1+t*(r.subdivisions+1),f=e+t*(r.subdivisions+1),g=e+(t+1)*(r.subdivisions+1),S=i[3*C+1]>=r.minHeight,y=i[3*T+1]>=r.minHeight,x=i[3*f+1]>=r.minHeight;S&&y&&x&&(n.push(C),n.push(T),n.push(f)),i[3*g+1]>=r.minHeight&&S&&x&&(n.push(g),n.push(C),n.push(f))}rt.ComputeNormals(i,n,o);var R=new rt;return R.indices=n,R.positions=i,R.normals=o,R.uvs=a,R}function ta(r,t,e){t===void 0&&(t={});var n=new Us(r,e);return n._setReady(!1),n._subdivisionsX=t.subdivisionsX||t.subdivisions||1,n._subdivisionsY=t.subdivisionsY||t.subdivisions||1,n._width=t.width||1,n._height=t.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,Wr(t).applyToMesh(n,t.updatable),n._setReady(!0),n}function Gs(r,t,e){e===void 0&&(e=null);var n=new xe(r,e);return Tu(t).applyToMesh(n,t.updatable),n}function ks(r,t,e,n){e===void 0&&(e={}),n===void 0&&(n=null);var i=e.width||10,o=e.height||10,a=e.subdivisions||1,s=e.minHeight||0,l=e.maxHeight||1,c=e.colorFilter||new z.v9(.3,.59,.11),u=e.alphaFilter||0,d=e.updatable,h=e.onReady;n=n||Ve.q.LastCreatedScene;var p,m=new Us(r,n);m._subdivisionsX=a,m._subdivisionsY=a,m._width=i,m._height=o,m._maxX=m._width/2,m._maxZ=m._height/2,m._minX=-m._maxX,m._minZ=-m._maxZ,m._setReady(!1),e.passHeightBufferInCallback&&(p=new Float32Array((a+1)*(a+1)));var v=function(b,E,C){Su({width:i,height:o,subdivisions:a,minHeight:s,maxHeight:l,colorFilter:c,buffer:b,bufferWidth:E,bufferHeight:C,alphaFilter:u,heightBuffer:p}).applyToMesh(m,d),h&&h(m,p),m._setReady(!0)};return typeof t=="string"?ze.S0.LoadImage(t,function(b){var E=b.width,C=b.height;if(!n.isDisposed){var T=n?.getEngine().resizeImageBitmap(b,E,C);v(T,E,C)}},e.onError?e.onError:function(){},n.offlineProvider):v(t.data,t.width,t.height),m}var oE={CreateGround:ta,CreateGroundFromHeightMap:ks,CreateTiledGround:Gs};function zs(r){for(var t=[],e=[],n=[],i=[],o=r.diameter||1,a=r.thickness||.5,s=0|(r.tessellation||16),l=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,c=s+1,u=0;u<=s;u++)for(var d=u/s,h=u*Math.PI*2/s-Math.PI/2,p=_.uq.Translation(o/2,0,0).multiply(_.uq.RotationY(h)),m=0;m<=s;m++){var v=1-m/s,b=m*Math.PI*2/s+Math.PI,E=Math.cos(b),C=Math.sin(b),T=new _.Pq(E,C,0),f=T.scale(a/2),g=new _.I9(d,v);f=_.Pq.TransformCoordinates(f,p),T=_.Pq.TransformNormal(T,p),e.push(f.x,f.y,f.z),n.push(T.x,T.y,T.z),i.push(g.x,Xt.rX?1-g.y:g.y);var S=(u+1)%c,y=(m+1)%c;t.push(u*c+m),t.push(u*c+y),t.push(S*c+m),t.push(u*c+y),t.push(S*c+y),t.push(S*c+m)}rt._ComputeSides(l,e,t,n,i,r.frontUVs,r.backUVs);var x=new rt;return x.indices=t,x.positions=e,x.normals=n,x.uvs=i,x}function Sr(r,t,e){t===void 0&&(t={});var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,zs(t).applyToMesh(n,t.updatable),n}rt.CreateGround=Wr,rt.CreateTiledGround=Tu,rt.CreateGroundFromHeightMap=Su,xe.CreateGround=function(r,t,e,n,i,o){return ta(r,{width:t,height:e,subdivisions:n,updatable:o},i)},xe.CreateTiledGround=function(r,t,e,n,i,o,a,s,l){return Gs(r,{xmin:t,zmin:e,xmax:n,zmax:i,subdivisions:o,precision:a,updatable:l},s)},xe.CreateGroundFromHeightMap=function(r,t,e,n,i,o,a,s,l,c,u){return ks(r,t,{width:e,height:n,subdivisions:i,minHeight:o,maxHeight:a,updatable:l,onReady:c,alphaFilter:u},s)};var aE={CreateTorus:Sr};rt.CreateTorus=zs,xe.CreateTorus=function(r,t,e,n,i,o,a){return Sr(r,{diameter:t,thickness:e,tessellation:n,sideOrientation:a,updatable:o},i)};var Hr,sE=function(r){function t(e,n){var i=r.call(this,n)||this;return i._getCamera=e,i}return(0,A.C6)(t,r),t.prototype._getForwardRay=function(e){var n=this._getCamera();return n?n.getForwardRay(e):new fn(_.Pq.Zero(),_.Pq.Forward())},t}(function(){function r(t,e){if(e===void 0&&(e=null),this.scene=t,this._pointerDownOnMeshAsked=!1,this._isActionableMesh=!1,this._teleportationRequestInitiated=!1,this._teleportationBackRequestInitiated=!1,this._rotationRightAsked=!1,this._rotationLeftAsked=!1,this._dpadPressed=!0,this._activePointer=!1,this._id=r._IdCounter++,e)this._gazeTracker=e.clone("gazeTracker");else{this._gazeTracker=Sr("gazeTracker",{diameter:.0035,thickness:.0025,tessellation:20,updatable:!1},t),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var n=new qt("targetMat",t);n.specularColor=z.v9.Black(),n.emissiveColor=new z.v9(.7,.7,.7),n.backFaceCulling=!1,this._gazeTracker.material=n}}return r.prototype._getForwardRay=function(t){return new fn(_.Pq.Zero(),new _.Pq(0,0,t))},r.prototype._selectionPointerDown=function(){this._pointerDownOnMeshAsked=!0,this._currentHit&&this.scene.simulatePointerDown(this._currentHit,{pointerId:this._id})},r.prototype._selectionPointerUp=function(){this._currentHit&&this.scene.simulatePointerUp(this._currentHit,{pointerId:this._id}),this._pointerDownOnMeshAsked=!1},r.prototype._activatePointer=function(){this._activePointer=!0},r.prototype._deactivatePointer=function(){this._activePointer=!1},r.prototype._updatePointerDistance=function(t){},r.prototype.dispose=function(){this._interactionsEnabled=!1,this._teleportationEnabled=!1,this._gazeTracker&&this._gazeTracker.dispose()},r._IdCounter=0,r}()),lE=function(){},Km=function(){function r(t,e){e===void 0&&(e={});var n=this;if(this.webVROptions=e,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new K.cP,this.onAfterEnteringVRObservable=new K.cP,this.onExitingVRObservable=new K.cP,this._useCustomVRButton=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._teleportationMode=r.TELEPORTATIONMODE_CONSTANTTIME,this._teleportationTime=122,this._teleportationSpeed=20,this._rotationAllowed=!0,this._teleportBackwardsVector=new _.Pq(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new _.Pq(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._pickedLaserColor=new z.v9(.2,.2,1),this._pickedGazeColor=new z.v9(0,0,1),this.onNewMeshSelected=new K.cP,this.onNewMeshPicked=new K.cP,this.onBeforeCameraTeleport=new K.cP,this.onAfterCameraTeleport=new K.cP,this.onSelectedMeshUnselected=new K.cP,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._displayGaze=!0,this._displayLaserPointer=!0,this.updateGazeTrackerScale=!0,this.updateGazeTrackerColor=!0,this.updateControllerLaserColor=!0,this.requestPointerLockOnFullScreen=!0,this.xrTestDone=!1,this._onResize=function(){n._moveButtonToBottomRight()},this._onFullscreenChange=function(){n._fullscreenVRpresenting=!!document.fullscreenElement,!n._fullscreenVRpresenting&&n._inputElement&&(n.exitVR(),!n._useCustomVRButton&&n._btnVR&&(n._btnVR.style.top=n._inputElement.offsetTop+n._inputElement.offsetHeight-70+"px",n._btnVR.style.left=n._inputElement.offsetLeft+n._inputElement.offsetWidth-100+"px",n._updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this._beforeRender=function(){n._scene.getEngine().isPointerLock||n.enableGazeEvenWhenNoPointerLock||(n._cameraGazer._gazeTracker.isVisible=!1)},this._onNewGamepadConnected=function(o){o.type!==Ii.POSE_ENABLED&&(o.leftStick&&o.onleftstickchanged(function(a){n._teleportationInitialized&&n.teleportationEnabled&&(n._checkTeleportWithRay(a,n._cameraGazer),n._checkTeleportBackwards(a,n._cameraGazer))}),o.rightStick&&o.onrightstickchanged(function(a){n._teleportationInitialized&&n._checkRotate(a,n._cameraGazer)}),o.type===Ii.XBOX&&(o.onbuttondown(function(a){n._interactionsEnabled&&a===0&&n._cameraGazer._selectionPointerDown()}),o.onbuttonup(function(a){n._interactionsEnabled&&a===0&&n._cameraGazer._selectionPointerUp()})))},this._workingVector=_.Pq.Zero(),this._workingQuaternion=_.PT.Identity(),this._workingMatrix=_.uq.Identity(),O.V.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||e.useXR!==void 0||(e.useXR=!0),e.createFallbackVRDeviceOrientationFreeCamera===void 0&&(e.createFallbackVRDeviceOrientationFreeCamera=!0),e.createDeviceOrientationCamera===void 0&&(e.createDeviceOrientationCamera=!0),e.laserToggle===void 0&&(e.laserToggle=!0),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new _.Pq(0,this._defaultHeight,0),e.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new Ds("deviceOrientationVRHelper",this._position.clone(),t),this._scene.activeCamera&&(this._deviceOrientationCamera.minZ=this._scene.activeCamera.minZ,this._deviceOrientationCamera.maxZ=this._scene.activeCamera.maxZ,this._scene.activeCamera instanceof kr&&this._scene.activeCamera.rotation)){var i=this._scene.activeCamera;i.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(i.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(_.PT.RotationYawPitchRoll(i.rotation.y,i.rotation.x,i.rotation.z)),this._deviceOrientationCamera.rotation=i.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._inputElement&&this._scene.activeCamera.attachControl()}else this._existingCamera=this._scene.activeCamera;this.webVROptions.useXR&&navigator.xr?bu.IsSessionSupportedAsync("immersive-vr").then(function(o){o?(O.V.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),t.createDefaultXRExperienceAsync({floorMeshes:e.floorMeshes||[]}).then(function(a){n.xr=a,n.xrTestDone=!0,n._cameraGazer=new sE(function(){return n.xr.baseExperience.camera},t),n.xr.baseExperience.onStateChangedObservable.add(function(s){switch(s){case 0:n.onEnteringVRObservable.notifyObservers(n),n._interactionsEnabled||n.xr.pointerSelection.detach(),n.xr.pointerSelection.displayLaserPointer=n._displayLaserPointer;break;case 1:n.onExitingVRObservable.notifyObservers(n),n._scene.getEngine().resize();break;case 2:n._hasEnteredVR=!0;break;case 3:n._hasEnteredVR=!1}})})):n._completeVRInit(t,e)}):this._completeVRInit(t,e)}return Object.defineProperty(r.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"teleportationTarget",{get:function(){return this._teleportationTarget},set:function(t){t&&(t.name="teleportationTarget",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"gazeTrackerMesh",{get:function(){return this._cameraGazer._gazeTracker},set:function(t){t&&(this._cameraGazer._gazeTracker&&this._cameraGazer._gazeTracker.dispose(),this._cameraGazer._gazeTracker=t,this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),this._cameraGazer._gazeTracker.isPickable=!1,this._cameraGazer._gazeTracker.isVisible=!1,this._cameraGazer._gazeTracker.name="gazeTracker")},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"displayGaze",{get:function(){return this._displayGaze},set:function(t){this._displayGaze=t,t||(this._cameraGazer._gazeTracker.isVisible=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(t){this._displayLaserPointer=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentVRCamera",{get:function(){return this._scene.activeCamera},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"vrButton",{get:function(){return this._btnVR},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_teleportationRequestInitiated",{get:function(){return this._cameraGazer._teleportationRequestInitiated},enumerable:!1,configurable:!0}),r.prototype._completeVRInit=function(t,e){var n=this;if(this.xrTestDone=!0,e.createFallbackVRDeviceOrientationFreeCamera&&(this._vrDeviceOrientationCamera=new ws("VRDeviceOrientationVRHelper",this._position,this._scene,!0,e.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._cameraGazer=new sE(function(){return n.currentVRCamera},t),!this._useCustomVRButton){this._btnVR=document.createElement("BUTTON"),this._btnVR.className="babylonVRicon",this._btnVR.id="babylonVRiconbtn",this._btnVR.title="Click to switch to VR";var i=".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A":"https://cdn.babylonjs.com/Assets/vrButton.png")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";i+=".babylonVRicon.vrdisplaypresenting { display: none; }";var o=document.createElement("style");o.appendChild(document.createTextNode(i)),document.getElementsByTagName("head")[0].appendChild(o),this._moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",function(){n.isInVRMode||n.enterVR()});var a=this._scene.getEngine().getHostWindow();a&&(a.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),e.createFallbackVRDeviceOrientationFreeCamera&&this._displayVRButton(),this._onKeyDown=function(s){s.keyCode===27&&n.isInVRMode&&n.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add(function(){n._hasEnteredVR&&n.exitVROnDoubleTap&&(n.exitVR(),n._fullscreenVRpresenting&&n._scene.getEngine().exitFullscreen())},vt.Zp.POINTERDOUBLETAP,!1),t.onDisposeObservable.add(function(){n.dispose()}),this._updateButtonVisibility(),this._circleEase=new xn,this._circleEase.setEasingMode(Wt.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,t.onPointerObservable.add(function(s){n._interactionsEnabled&&t.activeCamera===n.vrDeviceOrientationCamera&&s.event.pointerType==="mouse"&&(s.type===vt.Zp.POINTERDOWN?n._cameraGazer._selectionPointerDown():s.type===vt.Zp.POINTERUP&&n._cameraGazer._selectionPointerUp())}),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes}))},Object.defineProperty(r.prototype,"isInVRMode",{get:function(){return this.xr&&this.webVROptions.useXR&&this.xr.baseExperience.state===2||this._fullscreenVRpresenting},enumerable:!1,configurable:!0}),r.prototype._moveButtonToBottomRight=function(){if(this._inputElement&&!this._useCustomVRButton&&this._btnVR){var t=this._inputElement.getBoundingClientRect();this._btnVR.style.top=t.top+t.height-70+"px",this._btnVR.style.left=t.left+t.width-100+"px"}},r.prototype._displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||!this._btnVR||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},r.prototype._updateButtonVisibility=function(){this._btnVR&&!this._useCustomVRButton&&(this._btnVR.className="babylonVRicon",this.isInVRMode&&(this._btnVR.className+=" vrdisplaypresenting"))},r.prototype.enterVR=function(){var t=this;if(this.xr)this.xr.baseExperience.enterXRAsync("immersive-vr","local-floor",this.xr.renderTarget);else{if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(e){O.V.Warn("Error in your custom logic onEnteringVR: "+e)}this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=_.PT.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this._existingCamera=this._scene.activeCamera,this._existingCamera.angularSensibilityX&&(this._cachedAngularSensibility.angularSensibilityX=this._existingCamera.angularSensibilityX,this._existingCamera.angularSensibilityX=Number.MAX_VALUE),this._existingCamera.angularSensibilityY&&(this._cachedAngularSensibility.angularSensibilityY=this._existingCamera.angularSensibilityY,this._existingCamera.angularSensibilityY=Number.MAX_VALUE),this._existingCamera.angularSensibility&&(this._cachedAngularSensibility.angularSensibility=this._existingCamera.angularSensibility,this._existingCamera.angularSensibility=Number.MAX_VALUE)),this._vrDeviceOrientationCamera&&(this._vrDeviceOrientationCamera.position=this._position,this._scene.activeCamera&&(this._vrDeviceOrientationCamera.minZ=this._scene.activeCamera.minZ),this._scene.activeCamera=this._vrDeviceOrientationCamera,this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen),this._updateButtonVisibility(),this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function(){t.onAfterEnteringVRObservable.notifyObservers({success:!0})})),this._scene.activeCamera&&this._inputElement&&this._scene.activeCamera.attachControl(),this._interactionsEnabled&&this._scene.registerBeforeRender(this._beforeRender),this._hasEnteredVR=!0}},r.prototype.exitVR=function(){if(this.xr)this.xr.baseExperience.exitXRAsync();else if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(t){O.V.Warn("Error in your custom logic onExitingVR: "+t)}this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone()),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._cachedAngularSensibility.angularSensibilityX&&(this._deviceOrientationCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._deviceOrientationCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._deviceOrientationCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera,this._inputElement&&this._scene.activeCamera.attachControl(),this._cachedAngularSensibility.angularSensibilityX&&(this._existingCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._existingCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._existingCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)),this._updateButtonVisibility(),this._interactionsEnabled&&(this._scene.unregisterBeforeRender(this._beforeRender),this._cameraGazer._gazeTracker.isVisible=!1),this._scene.getEngine().resize(),this._hasEnteredVR=!1}},Object.defineProperty(r.prototype,"position",{get:function(){return this._position},set:function(t){this._position=t,this._scene.activeCamera&&(this._scene.activeCamera.position=t)},enumerable:!1,configurable:!0}),r.prototype.enableInteractions=function(){var t=this;if(!this._interactionsEnabled){if(this.xr)return void(this.xr.baseExperience.state===2&&this.xr.pointerSelection.attach());this.raySelectionPredicate=function(e){return e.isVisible&&(e.isPickable||e.name===t._floorMeshName)},this.meshSelectionPredicate=function(){return!0},this._raySelectionPredicate=function(e){return!!(t._isTeleportationFloor(e)||e.name.indexOf("gazeTracker")===-1&&e.name.indexOf("teleportationTarget")===-1&&e.name.indexOf("torusTeleportation")===-1)&&t.raySelectionPredicate(e)},this._interactionsEnabled=!0}},r.prototype._isTeleportationFloor=function(t){for(var e=0;e<this._floorMeshesCollection.length;e++)if(this._floorMeshesCollection[e].id===t.id)return!0;return!(!this._floorMeshName||t.name!==this._floorMeshName)},r.prototype.addFloorMesh=function(t){this._floorMeshesCollection&&(this._floorMeshesCollection.indexOf(t)>-1||this._floorMeshesCollection.push(t))},r.prototype.removeFloorMesh=function(t){if(this._floorMeshesCollection){var e=this._floorMeshesCollection.indexOf(t);e!==-1&&this._floorMeshesCollection.splice(e,1)}},r.prototype.enableTeleportation=function(t){var e=this;if(t===void 0&&(t={}),!this._teleportationInitialized){if(this.enableInteractions(),this.webVROptions.useXR&&(t.floorMeshes||t.floorMeshName)){var n=t.floorMeshes||[];if(!n.length){var i=this._scene.getMeshByName(t.floorMeshName);i&&n.push(i)}if(this.xr)return n.forEach(function(s){e.xr.teleportation.addFloorMesh(s)}),void(this.xr.teleportation.attached||this.xr.teleportation.attach());if(!this.xrTestDone){var o=function(){e.xrTestDone&&(e._scene.unregisterBeforeRender(o),e.xr?e.xr.teleportation.attached||e.xr.teleportation.attach():e.enableTeleportation(t))};return void this._scene.registerBeforeRender(o)}}t.floorMeshName&&(this._floorMeshName=t.floorMeshName),t.floorMeshes&&(this._floorMeshesCollection=t.floorMeshes),t.teleportationMode&&(this._teleportationMode=t.teleportationMode),t.teleportationTime&&t.teleportationTime>0&&(this._teleportationTime=t.teleportationTime),t.teleportationSpeed&&t.teleportationSpeed>0&&(this._teleportationSpeed=t.teleportationSpeed),t.easingFunction!==void 0&&(this._teleportationEasing=t.easingFunction);var a=new Ti.p;a.vignetteColor=new z.ov(0,0,0,0),a.vignetteEnabled=!0,this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&this._createTeleportationCircles()}},r.prototype._checkTeleportWithRay=function(t,e){this._teleportationRequestInitiated&&!e._teleportationRequestInitiated||(e._teleportationRequestInitiated?Math.sqrt(t.y*t.y+t.x*t.x)<this._padSensibilityDown&&(this._teleportActive&&this.teleportCamera(this._haloCenter),e._teleportationRequestInitiated=!1):t.y<-this._padSensibilityUp&&e._dpadPressed&&(e._activatePointer(),e._teleportationRequestInitiated=!0))},r.prototype._checkRotate=function(t,e){e._teleportationRequestInitiated||(e._rotationLeftAsked?t.x>-this._padSensibilityDown&&(e._rotationLeftAsked=!1):t.x<-this._padSensibilityUp&&e._dpadPressed&&(e._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),e._rotationRightAsked?t.x<this._padSensibilityDown&&(e._rotationRightAsked=!1):t.x>this._padSensibilityUp&&e._dpadPressed&&(e._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},r.prototype._checkTeleportBackwards=function(t,e){if(!e._teleportationRequestInitiated)if(t.y>this._padSensibilityUp&&e._dpadPressed){if(!e._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var n=_.PT.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),i=this.currentVRCamera.position;n.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,_.PT.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),_.Pq.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var o=new fn(i,this._workingVector),a=this._scene.pickWithRay(o,this._raySelectionPredicate);a&&a.pickedPoint&&a.pickedMesh&&this._isTeleportationFloor(a.pickedMesh)&&a.distance<5&&this.teleportCamera(a.pickedPoint),e._teleportationBackRequestInitiated=!0}}else e._teleportationBackRequestInitiated=!1},r.prototype._createTeleportationCircles=function(){this._teleportationTarget=ta("teleportationTarget",{width:2,height:2,subdivisions:2},this._scene),this._teleportationTarget.isPickable=!1;var t=new Oo("DynamicTexture",512,this._scene,!0);t.hasAlpha=!0;var e=t.getContext();e.beginPath(),e.arc(256,256,200,0,2*Math.PI,!1),e.fillStyle=this._teleportationFillColor,e.fill(),e.lineWidth=10,e.strokeStyle=this._teleportationBorderColor,e.stroke(),e.closePath(),t.update();var n=new qt("TextPlaneMaterial",this._scene);n.diffuseTexture=t,this._teleportationTarget.material=n;var i=Sr("torusTeleportation",{diameter:.75,thickness:.1,tessellation:25,updatable:!1},this._scene);i.isPickable=!1,i.parent=this._teleportationTarget;var o=new Le("animationInnerCircle","position.y",30,Le.ANIMATIONTYPE_FLOAT,Le.ANIMATIONLOOPMODE_CYCLE),a=[];a.push({frame:0,value:0}),a.push({frame:30,value:.4}),a.push({frame:60,value:0}),o.setKeys(a);var s=new Ci;s.setEasingMode(Wt.EASINGMODE_EASEINOUT),o.setEasingFunction(s),i.animations=[],i.animations.push(o),this._scene.beginAnimation(i,0,60,!0),this._hideTeleportationTarget()},r.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},r.prototype._rotateCamera=function(t){if(this.currentVRCamera instanceof _r){t?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var e=_.PT.FromRotationMatrix(_.uq.RotationY(Math.PI/4*this._rotationAngle)),n=new Le("animationRotation","rotationQuaternion",90,Le.ANIMATIONTYPE_QUATERNION,Le.ANIMATIONLOOPMODE_CONSTANT),i=[];i.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),i.push({frame:6,value:e}),n.setKeys(i),n.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(n),this._postProcessMove.animations=[];var o=new Le("animationPP","vignetteWeight",90,Le.ANIMATIONTYPE_FLOAT,Le.ANIMATIONLOOPMODE_CONSTANT),a=[];a.push({frame:0,value:0}),a.push({frame:3,value:4}),a.push({frame:6,value:0}),o.setKeys(a),o.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(o);var s=new Le("animationPP2","vignetteStretch",90,Le.ANIMATIONTYPE_FLOAT,Le.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),s.setKeys(l),s.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(s),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},r.prototype.teleportCamera=function(t){var e=this;if(this.currentVRCamera instanceof _r){var n,i;if(this._workingVector.copyFrom(t),this.isInVRMode||(this._workingVector.y+=this._defaultHeight),this.onBeforeCameraTeleport.notifyObservers(this._workingVector),this._teleportationMode==r.TELEPORTATIONMODE_CONSTANTSPEED){i=90;var o=_.Pq.Distance(this.currentVRCamera.position,this._workingVector);n=this._teleportationSpeed/o}else i=Math.round(90*this._teleportationTime/1e3),n=1;this.currentVRCamera.animations=[];var a=new Le("animationCameraTeleportation","position",90,Le.ANIMATIONTYPE_VECTOR3,Le.ANIMATIONLOOPMODE_CONSTANT),s=[{frame:0,value:this.currentVRCamera.position},{frame:i,value:this._workingVector}];a.setKeys(s),a.setEasingFunction(this._teleportationEasing),this.currentVRCamera.animations.push(a),this._postProcessMove.animations=[];var l=Math.round(i/2),c=new Le("animationPP","vignetteWeight",90,Le.ANIMATIONTYPE_FLOAT,Le.ANIMATIONLOOPMODE_CONSTANT),u=[];u.push({frame:0,value:0}),u.push({frame:l,value:8}),u.push({frame:i,value:0}),c.setKeys(u),this._postProcessMove.animations.push(c);var d=new Le("animationPP2","vignetteStretch",90,Le.ANIMATIONTYPE_FLOAT,Le.ANIMATIONLOOPMODE_CONSTANT),h=[];h.push({frame:0,value:0}),h.push({frame:l,value:10}),h.push({frame:i,value:0}),d.setKeys(h),this._postProcessMove.animations.push(d),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._scene.beginAnimation(this.currentVRCamera,0,i,!1,n,function(){e.onAfterCameraTeleport.notifyObservers(e._workingVector)}),this._hideTeleportationTarget()}},r.prototype.setLaserColor=function(t,e){e===void 0&&(e=this._pickedLaserColor),this._pickedLaserColor=e},r.prototype.setLaserLightingState=function(t){},r.prototype.setGazeColor=function(t,e){e===void 0&&(e=this._pickedGazeColor),this._pickedGazeColor=e},r.prototype.changeLaserColor=function(t){this.updateControllerLaserColor},r.prototype.changeGazeColor=function(t){this.updateGazeTrackerColor&&this._cameraGazer._gazeTracker.material&&(this._cameraGazer._gazeTracker.material.emissiveColor=t)},r.prototype.dispose=function(){this.isInVRMode&&this.exitVR(),this._postProcessMove&&this._postProcessMove.dispose(),this._vrDeviceOrientationCamera&&this._vrDeviceOrientationCamera.dispose(),!this._useCustomVRButton&&this._btnVR&&this._btnVR.parentNode&&document.body.removeChild(this._btnVR),this._deviceOrientationCamera&&this._scene.activeCamera!=this._deviceOrientationCamera&&this._deviceOrientationCamera.dispose(),this._cameraGazer&&this._cameraGazer.dispose(),this._teleportationTarget&&this._teleportationTarget.dispose(),this.xr&&this.xr.dispose(),this._floorMeshesCollection.length=0,document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChangeBind),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFullscreenChange),this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),this._scene.unregisterBeforeRender(this._beforeRender)},r.prototype.getClassName=function(){return"VRExperienceHelper"},r.TELEPORTATIONMODE_CONSTANTTIME=0,r.TELEPORTATIONMODE_CONSTANTSPEED=1,r}(),Na=(Hr={root:0,found:!1},function(r,t,e,n){Hr.root=0,Hr.found=!1;var i=t*t-4*r*e;if(i<0)return Hr;var o=Math.sqrt(i),a=(-t-o)/(2*r),s=(-t+o)/(2*r);if(a>s){var l=s;s=a,a=l}return a>0&&a<n?(Hr.root=a,Hr.found=!0,Hr):(s>0&&s<n&&(Hr.root=s,Hr.found=!0),Hr)}),Zm=function(){function r(){this._collisionPoint=_.Pq.Zero(),this._planeIntersectionPoint=_.Pq.Zero(),this._tempVector=_.Pq.Zero(),this._tempVector2=_.Pq.Zero(),this._tempVector3=_.Pq.Zero(),this._tempVector4=_.Pq.Zero(),this._edge=_.Pq.Zero(),this._baseToVertex=_.Pq.Zero(),this._destinationPoint=_.Pq.Zero(),this._slidePlaneNormal=_.Pq.Zero(),this._displacementVector=_.Pq.Zero(),this._radius=_.Pq.One(),this._retry=0,this._basePointWorld=_.Pq.Zero(),this._velocityWorld=_.Pq.Zero(),this._normalizedVelocity=_.Pq.Zero(),this._collisionMask=-1}return Object.defineProperty(r.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(t){this._collisionMask=isNaN(t)?-1:t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!1,configurable:!0}),r.prototype._initialize=function(t,e,n){this._velocity=e,this._velocitySquaredLength=this._velocity.lengthSquared();var i=Math.sqrt(this._velocitySquaredLength);i===0||i===1?this._normalizedVelocity.copyFromFloats(e._x,e._y,e._z):e.scaleToRef(1/i,this._normalizedVelocity),this._basePoint=t,t.multiplyToRef(this._radius,this._basePointWorld),e.multiplyToRef(this._radius,this._velocityWorld),this._velocityWorldLength=this._velocityWorld.length(),this._epsilon=n,this.collisionFound=!1},r.prototype._checkPointInTriangle=function(t,e,n,i,o){e.subtractToRef(t,this._tempVector),n.subtractToRef(t,this._tempVector2),_.Pq.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var a=_.Pq.Dot(this._tempVector4,o);return!(a<0)&&(i.subtractToRef(t,this._tempVector3),_.Pq.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((a=_.Pq.Dot(this._tempVector4,o))<0)&&(_.Pq.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),(a=_.Pq.Dot(this._tempVector4,o))>=0))},r.prototype._canDoCollision=function(t,e,n,i){var o=_.Pq.Distance(this._basePointWorld,t),a=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(o>this._velocityWorldLength+a+e||!function(s,l,c,u){return!(s.x>c.x+u||c.x-u>l.x||s.y>c.y+u||c.y-u>l.y||s.z>c.z+u||c.z-u>l.z)}(n,i,this._basePointWorld,this._velocityWorldLength+a))},r.prototype._testTriangle=function(t,e,n,i,o,a,s){var l,c=!1;e||(e=[]),e[t]||(e[t]=new Qo.Z(0,0,0,0),e[t].copyFromPoints(n,i,o));var u=e[t];if(a||u.isFrontFacingTo(this._normalizedVelocity,0)){var d=u.signedDistanceTo(this._basePoint),h=_.Pq.Dot(u.normal,this._velocity);if(!(r.DoubleSidedCheck&&h>1e-4)){if(h==0){if(Math.abs(d)>=1)return;c=!0,l=0}else{var p=(1-d)/h;if((l=(-1-d)/h)>p){var m=p;p=l,l=m}if(l>1||p<0)return;l<0&&(l=0),l>1&&(l=1)}this._collisionPoint.copyFromFloats(0,0,0);var v=!1,b=1;if(c||(this._basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(l,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,i,o,u.normal)&&(v=!0,b=l,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!v){var E=this._velocitySquaredLength;this._basePoint.subtractToRef(n,this._tempVector);var C=2*_.Pq.Dot(this._velocity,this._tempVector),T=this._tempVector.lengthSquared()-1,f=Na(E,C,T,b);f.found&&(b=f.root,v=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(i,this._tempVector),C=2*_.Pq.Dot(this._velocity,this._tempVector),T=this._tempVector.lengthSquared()-1,(f=Na(E,C,T,b)).found&&(b=f.root,v=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(o,this._tempVector),C=2*_.Pq.Dot(this._velocity,this._tempVector),T=this._tempVector.lengthSquared()-1,(f=Na(E,C,T,b)).found&&(b=f.root,v=!0,this._collisionPoint.copyFrom(o)),i.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex);var g,S=this._edge.lengthSquared(),y=_.Pq.Dot(this._edge,this._velocity),x=_.Pq.Dot(this._edge,this._baseToVertex);E=S*-this._velocitySquaredLength+y*y,C=2*(S*_.Pq.Dot(this._velocity,this._baseToVertex)-y*x),T=S*(1-this._baseToVertex.lengthSquared())+x*x,(f=Na(E,C,T,b)).found&&(g=(y*f.root-x)/S)>=0&&g<=1&&(b=f.root,v=!0,this._edge.scaleInPlace(g),n.addToRef(this._edge,this._collisionPoint)),o.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex),S=this._edge.lengthSquared(),y=_.Pq.Dot(this._edge,this._velocity),x=_.Pq.Dot(this._edge,this._baseToVertex),E=S*-this._velocitySquaredLength+y*y,C=2*(S*_.Pq.Dot(this._velocity,this._baseToVertex)-y*x),T=S*(1-this._baseToVertex.lengthSquared())+x*x,(f=Na(E,C,T,b)).found&&(g=(y*f.root-x)/S)>=0&&g<=1&&(b=f.root,v=!0,this._edge.scaleInPlace(g),i.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(o,this._edge),o.subtractToRef(this._basePoint,this._baseToVertex),S=this._edge.lengthSquared(),y=_.Pq.Dot(this._edge,this._velocity),x=_.Pq.Dot(this._edge,this._baseToVertex),E=S*-this._velocitySquaredLength+y*y,C=2*(S*_.Pq.Dot(this._velocity,this._baseToVertex)-y*x),T=S*(1-this._baseToVertex.lengthSquared())+x*x,(f=Na(E,C,T,b)).found&&(g=(y*f.root-x)/S)>=0&&g<=1&&(b=f.root,v=!0,this._edge.scaleInPlace(g),o.addToRef(this._edge,this._collisionPoint))}if(v){var R=b*b*this._velocitySquaredLength;(!this.collisionFound||R<this._nearestDistanceSquared)&&(s.collisionResponse&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this._nearestDistanceSquared=R,this._nearestDistance=Math.sqrt(R),this.collisionFound=!0),this.collidedMesh=s)}}}},r.prototype._collide=function(t,e,n,i,o,a,s,l,c,u){if(u===void 0&&(u=!1),u)if(n&&n.length!==0)for(m=i;m<o-2;m+=1){var d=n[m],h=n[m+1],p=n[m+2];p!==4294967295?(v=e[d],b=e[h],E=e[p],v&&b&&E&&((c?1:0)^m%2?this._testTriangle(m,t,v,b,E,s,l):this._testTriangle(m,t,b,v,E,s,l))):m+=2}else for(var m=0;m<e.length-2;m+=1){var v=e[m],b=e[m+1],E=e[m+2];v&&b&&E&&((c?1:0)^m%2?this._testTriangle(m,t,v,b,E,s,l):this._testTriangle(m,t,b,v,E,s,l))}else if(n&&n.length!==0)for(m=i;m<o;m+=3)v=e[n[m]-a],b=e[n[m+1]-a],E=e[n[m+2]-a],c?this._testTriangle(m,t,v,b,E,s,l):this._testTriangle(m,t,E,b,v,s,l);else for(m=0;m<e.length;m+=3)v=e[m],b=e[m+1],E=e[m+2],c?this._testTriangle(m,t,v,b,E,s,l):this._testTriangle(m,t,E,b,v,s,l)},r.prototype._getResponse=function(t,e){t.addToRef(e,this._destinationPoint),e.scaleInPlace(this._nearestDistance/e.length()),this._basePoint.addToRef(e,t),t.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this._epsilon,this._displacementVector),t.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(Qo.Z.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,e)},r.DoubleSidedCheck=!1,r}(),Qm=function(){function r(){this._scaledPosition=_.Pq.Zero(),this._scaledVelocity=_.Pq.Zero(),this._finalPosition=_.Pq.Zero()}return r.prototype.getNewPosition=function(t,e,n,i,o,a,s){t.divideToRef(n._radius,this._scaledPosition),e.divideToRef(n._radius,this._scaledVelocity),n.collidedMesh=null,n._retry=0,n._initialVelocity=this._scaledVelocity,n._initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,n,i,this._finalPosition,o),this._finalPosition.multiplyInPlace(n._radius),a(s,this._finalPosition,n.collidedMesh)},r.prototype.createCollider=function(){return new Zm},r.prototype.init=function(t){this._scene=t},r.prototype._collideWithWorld=function(t,e,n,i,o,a){a===void 0&&(a=null);var s=10*Be.$.CollisionsEpsilon;if(n._retry>=i)o.copyFrom(t);else{var l=a?a.collisionMask:n.collisionMask;n._initialize(t,e,s);for(var c=a&&a.surroundingMeshes||this._scene.meshes,u=0;u<c.length;u++){var d=c[u];d.isEnabled()&&d.checkCollisions&&d.subMeshes&&d!==a&&l&d.collisionGroup&&d._checkCollision(n)}n.collisionFound?(e.x===0&&e.y===0&&e.z===0||n._getResponse(t,e),e.length()<=s?o.copyFrom(t):(n._retry++,this._collideWithWorld(t,e,n,i,o,a))):t.addToRef(e,o)}},r}();ke.Z.CollisionCoordinatorFactory=function(){return new Qm};var Jm={effect:null,subMesh:null},pi=function(r){function t(e,n,i,o,a){o===void 0&&(o={}),a===void 0&&(a=!0);var s=r.call(this,e,n,a)||this;return s._textures={},s._textureArrays={},s._externalTextures={},s._floats={},s._ints={},s._uints={},s._floatsArrays={},s._colors3={},s._colors3Arrays={},s._colors4={},s._colors4Arrays={},s._vectors2={},s._vectors3={},s._vectors4={},s._quaternions={},s._quaternionsArrays={},s._matrices={},s._matrixArrays={},s._matrices3x3={},s._matrices2x2={},s._vectors2Arrays={},s._vectors3Arrays={},s._vectors4Arrays={},s._uniformBuffers={},s._textureSamplers={},s._storageBuffers={},s._cachedWorldViewMatrix=new _.uq,s._cachedWorldViewProjectionMatrix=new _.uq,s._multiview=!1,s._materialHelperNeedsPreviousMatrices=!1,s._shaderPath=i,s._options=(0,A.Cl)({needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],externalTextures:[],samplerObjects:[],storageBuffers:[],defines:[],useClipPlane:!1},o),s}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"shaderPath",{get:function(){return this._shaderPath},set:function(e){this._shaderPath=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isMultiview",{get:function(){return this._multiview},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"ShaderMaterial"},t.prototype.needAlphaBlending=function(){return this.alpha<1||this._options.needAlphaBlending},t.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},t.prototype._checkUniform=function(e){this._options.uniforms.indexOf(e)===-1&&this._options.uniforms.push(e)},t.prototype.setTexture=function(e,n){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._textures[e]=n,this},t.prototype.setTextureArray=function(e,n){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=n,this},t.prototype.setExternalTexture=function(e,n){return this._options.externalTextures.indexOf(e)===-1&&this._options.externalTextures.push(e),this._externalTextures[e]=n,this},t.prototype.setFloat=function(e,n){return this._checkUniform(e),this._floats[e]=n,this},t.prototype.setInt=function(e,n){return this._checkUniform(e),this._ints[e]=n,this},t.prototype.setUInt=function(e,n){return this._checkUniform(e),this._uints[e]=n,this},t.prototype.setFloats=function(e,n){return this._checkUniform(e),this._floatsArrays[e]=n,this},t.prototype.setColor3=function(e,n){return this._checkUniform(e),this._colors3[e]=n,this},t.prototype.setColor3Array=function(e,n){return this._checkUniform(e),this._colors3Arrays[e]=n.reduce(function(i,o){return o.toArray(i,i.length),i},[]),this},t.prototype.setColor4=function(e,n){return this._checkUniform(e),this._colors4[e]=n,this},t.prototype.setColor4Array=function(e,n){return this._checkUniform(e),this._colors4Arrays[e]=n.reduce(function(i,o){return o.toArray(i,i.length),i},[]),this},t.prototype.setVector2=function(e,n){return this._checkUniform(e),this._vectors2[e]=n,this},t.prototype.setVector3=function(e,n){return this._checkUniform(e),this._vectors3[e]=n,this},t.prototype.setVector4=function(e,n){return this._checkUniform(e),this._vectors4[e]=n,this},t.prototype.setQuaternion=function(e,n){return this._checkUniform(e),this._quaternions[e]=n,this},t.prototype.setQuaternionArray=function(e,n){return this._checkUniform(e),this._quaternionsArrays[e]=n.reduce(function(i,o){return o.toArray(i,i.length),i},[]),this},t.prototype.setMatrix=function(e,n){return this._checkUniform(e),this._matrices[e]=n,this},t.prototype.setMatrices=function(e,n){this._checkUniform(e);for(var i=new Float32Array(16*n.length),o=0;o<n.length;o++)n[o].copyToArray(i,16*o);return this._matrixArrays[e]=i,this},t.prototype.setMatrix3x3=function(e,n){return this._checkUniform(e),this._matrices3x3[e]=n,this},t.prototype.setMatrix2x2=function(e,n){return this._checkUniform(e),this._matrices2x2[e]=n,this},t.prototype.setArray2=function(e,n){return this._checkUniform(e),this._vectors2Arrays[e]=n,this},t.prototype.setArray3=function(e,n){return this._checkUniform(e),this._vectors3Arrays[e]=n,this},t.prototype.setArray4=function(e,n){return this._checkUniform(e),this._vectors4Arrays[e]=n,this},t.prototype.setUniformBuffer=function(e,n){return this._options.uniformBuffers.indexOf(e)===-1&&this._options.uniformBuffers.push(e),this._uniformBuffers[e]=n,this},t.prototype.setTextureSampler=function(e,n){return this._options.samplerObjects.indexOf(e)===-1&&this._options.samplerObjects.push(e),this._textureSamplers[e]=n,this},t.prototype.setStorageBuffer=function(e,n){return this._options.storageBuffers.indexOf(e)===-1&&this._options.storageBuffers.push(e),this._storageBuffers[e]=n,this},t.prototype.setDefine=function(e,n){var i=e.trimEnd()+" ",o=this.options.defines.findIndex(function(a){return a===e||a.startsWith(i)});return o>=0&&this.options.defines.splice(o,1),(typeof n!="boolean"||n)&&this.options.defines.push(i+n),this},t.prototype.isReadyForSubMesh=function(e,n,i){return this.isReady(e,i,n)},t.prototype.isReady=function(e,n,i){var o,a,s,l,c=i&&this._storeEffectOnSubMeshes;if(this.isFrozen){var u=c?i._drawWrapper:this._drawWrapper;if(u.effect&&u._wasPreviouslyReady&&u._wasPreviouslyUsingInstances===n)return!0}var d=this.getScene(),h=d.getEngine(),p=[],m=[],v=new Tr,b=this._shaderPath,E=this._options.uniforms,C=this._options.uniformBuffers,T=this._options.samplers;h.getCaps().multiview&&d.activeCamera&&d.activeCamera.outputRenderTarget&&d.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,p.push("#define MULTIVIEW"),E.indexOf("viewProjection")!==-1&&E.indexOf("viewProjectionR")===-1&&E.push("viewProjectionR"));for(var f=0;f<this._options.defines.length;f++){var g=this._options.defines[f].indexOf("#define")===0?this._options.defines[f]:"#define ".concat(this._options.defines[f]);p.push(g)}for(f=0;f<this._options.attributes.length;f++)m.push(this._options.attributes[f]);if(e&&e.isVerticesDataPresent(Y.R.ColorKind)&&(m.indexOf(Y.R.ColorKind)===-1&&m.push(Y.R.ColorKind),p.push("#define VERTEXCOLOR")),n&&(p.push("#define INSTANCES"),(0,Re.te)(m,this._materialHelperNeedsPreviousMatrices),e?.hasThinInstances&&(p.push("#define THIN_INSTANCES"),e&&e.isVerticesDataPresent(Y.R.ColorInstanceKind)&&(m.push(Y.R.ColorInstanceKind),p.push("#define INSTANCESCOLOR")))),e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton){m.push(Y.R.MatricesIndicesKind),m.push(Y.R.MatricesWeightsKind),e.numBoneInfluencers>4&&(m.push(Y.R.MatricesIndicesExtraKind),m.push(Y.R.MatricesWeightsExtraKind));var S=e.skeleton;p.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),v.addCPUSkinningFallback(0,e),S.isUsingTextureForMatrices?(p.push("#define BONETEXTURE"),E.indexOf("boneTextureWidth")===-1&&E.push("boneTextureWidth"),this._options.samplers.indexOf("boneSampler")===-1&&this._options.samplers.push("boneSampler")):(p.push("#define BonesPerMesh "+(S.bones.length+1)),E.indexOf("mBones")===-1&&E.push("mBones"))}else p.push("#define NUM_BONE_INFLUENCERS 0");var y=0,x=e?e.morphTargetManager:null;if(x){var R=x.supportsUVs&&p.indexOf("#define UV1")!==-1,I=x.supportsTangents&&p.indexOf("#define TANGENT")!==-1,M=x.supportsNormals&&p.indexOf("#define NORMAL")!==-1;for(y=x.numMaxInfluencers||x.numInfluencers,R&&p.push("#define MORPHTARGETS_UV"),I&&p.push("#define MORPHTARGETS_TANGENT"),M&&p.push("#define MORPHTARGETS_NORMAL"),y>0&&p.push("#define MORPHTARGETS"),x.isUsingTextureForTargets&&(p.push("#define MORPHTARGETS_TEXTURE"),E.indexOf("morphTargetTextureIndices")===-1&&E.push("morphTargetTextureIndices"),this._options.samplers.indexOf("morphTargets")===-1&&this._options.samplers.push("morphTargets")),p.push("#define NUM_MORPH_INFLUENCERS "+y),f=0;f<y;f++)m.push(Y.R.PositionKind+f),M&&m.push(Y.R.NormalKind+f),I&&m.push(Y.R.TangentKind+f),R&&m.push(Y.R.UVKind+"_"+f);y>0&&((E=E.slice()).push("morphTargetInfluences"),E.push("morphTargetCount"),E.push("morphTargetTextureInfo"),E.push("morphTargetTextureIndices"))}else p.push("#define NUM_MORPH_INFLUENCERS 0");if(e){var D=e.bakedVertexAnimationManager;D&&D.isEnabled&&(p.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),E.indexOf("bakedVertexAnimationSettings")===-1&&E.push("bakedVertexAnimationSettings"),E.indexOf("bakedVertexAnimationTextureSizeInverted")===-1&&E.push("bakedVertexAnimationTextureSizeInverted"),E.indexOf("bakedVertexAnimationTime")===-1&&E.push("bakedVertexAnimationTime"),this._options.samplers.indexOf("bakedVertexAnimationTexture")===-1&&this._options.samplers.push("bakedVertexAnimationTexture")),(0,Re.J2)(m,e,p)}for(var B in this._textures)if(!this._textures[B].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&p.push("#define ALPHATEST"),this._options.useClipPlane!==!1&&((0,tn.TV)(E),(0,tn.tv)(this,d,p)),d.fogEnabled&&e?.applyFog&&d.fogMode!==ke.Z.FOGMODE_NONE&&(p.push("#define FOG"),E.indexOf("view")===-1&&E.push("view"),E.indexOf("vFogInfos")===-1&&E.push("vFogInfos"),E.indexOf("vFogColor")===-1&&E.push("vFogColor")),this._useLogarithmicDepth&&(p.push("#define LOGARITHMICDEPTH"),E.indexOf("logarithmicDepthConstant")===-1&&E.push("logarithmicDepthConstant")),this.customShaderNameResolve&&(E=E.slice(),C=C.slice(),T=T.slice(),b=this.customShaderNameResolve(this.name,E,C,T,p,m));var F=c?i._getDrawWrapper(void 0,!0):this._drawWrapper,X=(o=F?.effect)!==null&&o!==void 0?o:null,$=(a=F?.defines)!==null&&a!==void 0?a:null,Q=p.join(`
|
||
`),ie=X;return $!==Q&&(ie=h.createEffect(b,{attributes:m,uniformsNames:E,uniformBuffersNames:C,samplers:T,defines:Q,fallbacks:v,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:y},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},h),c?i.setEffect(ie,Q,this._materialContext):F&&F.setEffect(ie,Q),this._onEffectCreatedObservable&&(Jm.effect=ie,Jm.subMesh=(s=i??e?.subMeshes[0])!==null&&s!==void 0?s:null,this._onEffectCreatedObservable.notifyObservers(Jm))),F._wasPreviouslyUsingInstances=!!n,(l=!ie?.isReady())!==null&&l!==void 0&&!l&&(X!==ie&&d.resetCachedMaterial(),F._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e,n){var i=this.getScene(),o=n??this.getEffect();o&&(this._options.uniforms.indexOf("world")!==-1&&o.setMatrix("world",e),this._options.uniforms.indexOf("worldView")!==-1&&(e.multiplyToRef(i.getViewMatrix(),this._cachedWorldViewMatrix),o.setMatrix("worldView",this._cachedWorldViewMatrix)),this._options.uniforms.indexOf("worldViewProjection")!==-1&&(e.multiplyToRef(i.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),o.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),this._options.uniforms.indexOf("view")!==-1&&o.setMatrix("view",i.getViewMatrix()))},t.prototype.bindForSubMesh=function(e,n,i){var o;this.bind(e,n,(o=i._drawWrapperOverride)===null||o===void 0?void 0:o.effect,i)},t.prototype.bind=function(e,n,i,o){var a,s=o&&this._storeEffectOnSubMeshes,l=i??(s?o.effect:this.getEffect());if(l){var c=this.getScene();this._activeEffect=l,this.bindOnlyWorldMatrix(e,i);var u=this._options.uniformBuffers,d=!1;if(l&&u&&u.length>0&&c.getEngine().supportsUniformBuffers)for(var h=0;h<u.length;++h)switch(u[h]){case"Mesh":n&&(n.getMeshUniformBuffer().bindToEffect(l,"Mesh"),n.transferToEffect(e));break;case"Scene":(0,Re._8)(l,c.getSceneUniformBuffer()),c.finalizeSceneUbo(),d=!0}var p=n&&s?this._mustRebind(c,l,o,n.visibility):c.getCachedMaterial()!==this;if(l&&p){var m;for(m in d||this._options.uniforms.indexOf("view")===-1||l.setMatrix("view",c.getViewMatrix()),d||this._options.uniforms.indexOf("projection")===-1||l.setMatrix("projection",c.getProjectionMatrix()),d||this._options.uniforms.indexOf("viewProjection")===-1||(l.setMatrix("viewProjection",c.getTransformMatrix()),this._multiview&&l.setMatrix("viewProjectionR",c._transformMatrixR)),c.activeCamera&&this._options.uniforms.indexOf("cameraPosition")!==-1&&l.setVector3("cameraPosition",c.activeCamera.globalPosition),(0,Re.f$)(n,l),(0,tn.gS)(l,this,c),this._useLogarithmicDepth&&(0,Re.DL)(s?o.materialDefines:l.defines,l,c),n&&(0,Re.Yy)(c,n,l),this._textures)l.setTexture(m,this._textures[m]);for(m in this._textureArrays)l.setTextureArray(m,this._textureArrays[m]);for(m in this._ints)l.setInt(m,this._ints[m]);for(m in this._uints)l.setUInt(m,this._uints[m]);for(m in this._floats)l.setFloat(m,this._floats[m]);for(m in this._floatsArrays)l.setArray(m,this._floatsArrays[m]);for(m in this._colors3)l.setColor3(m,this._colors3[m]);for(m in this._colors3Arrays)l.setArray3(m,this._colors3Arrays[m]);for(m in this._colors4){var v=this._colors4[m];l.setFloat4(m,v.r,v.g,v.b,v.a)}for(m in this._colors4Arrays)l.setArray4(m,this._colors4Arrays[m]);for(m in this._vectors2)l.setVector2(m,this._vectors2[m]);for(m in this._vectors3)l.setVector3(m,this._vectors3[m]);for(m in this._vectors4)l.setVector4(m,this._vectors4[m]);for(m in this._quaternions)l.setQuaternion(m,this._quaternions[m]);for(m in this._matrices)l.setMatrix(m,this._matrices[m]);for(m in this._matrixArrays)l.setMatrices(m,this._matrixArrays[m]);for(m in this._matrices3x3)l.setMatrix3x3(m,this._matrices3x3[m]);for(m in this._matrices2x2)l.setMatrix2x2(m,this._matrices2x2[m]);for(m in this._vectors2Arrays)l.setArray2(m,this._vectors2Arrays[m]);for(m in this._vectors3Arrays)l.setArray3(m,this._vectors3Arrays[m]);for(m in this._vectors4Arrays)l.setArray4(m,this._vectors4Arrays[m]);for(m in this._quaternionsArrays)l.setArray4(m,this._quaternionsArrays[m]);for(m in this._uniformBuffers){var b=this._uniformBuffers[m].getBuffer();b&&l.bindUniformBuffer(b,m)}var E=c.getEngine(),C=E.setExternalTexture;if(C)for(m in this._externalTextures)C.call(E,m,this._externalTextures[m]);var T=E.setTextureSampler;if(T)for(m in this._textureSamplers)T.call(E,m,this._textureSamplers[m]);var f=E.setStorageBuffer;if(f)for(m in this._storageBuffers)f.call(E,m,this._storageBuffers[m])}if(l&&n&&(p||!this.isFrozen)){var g=n.morphTargetManager;g&&g.numInfluencers>0&&(0,Re.nR)(n,l);var S=n.bakedVertexAnimationManager;if(S&&S.isEnabled){var y=s?o._drawWrapper:this._drawWrapper;(a=n.bakedVertexAnimationManager)===null||a===void 0||a.bind(l,!!y._wasPreviouslyUsingInstances)}}this._afterBind(n,l,o)}},t.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);for(var n in this._textures)e.push(this._textures[n]);for(var i in this._textureArrays)for(var o=this._textureArrays[i],a=0;a<o.length;a++)e.push(o[a]);return e},t.prototype.hasTexture=function(e){if(r.prototype.hasTexture.call(this,e))return!0;for(var n in this._textures)if(this._textures[n]===e)return!0;for(var i in this._textureArrays)for(var o=this._textureArrays[i],a=0;a<o.length;a++)if(o[a]===e)return!0;return!1},t.prototype.clone=function(e){var n=this,i=tt.p.Clone(function(){return new t(e,n.getScene(),n._shaderPath,n._options,n._storeEffectOnSubMeshes)},this);for(var o in i.name=e,i.id=e,typeof i._shaderPath=="object"&&(i._shaderPath=(0,A.Cl)({},i._shaderPath)),this._options=(0,A.Cl)({},this._options),Object.keys(this._options).forEach(function(a){var s=n._options[a];Array.isArray(s)&&(n._options[a]=s.slice(0))}),this.stencil.copyTo(i.stencil),this._textures)i.setTexture(o,this._textures[o]);for(var o in this._textureArrays)i.setTextureArray(o,this._textureArrays[o]);for(var o in this._externalTextures)i.setExternalTexture(o,this._externalTextures[o]);for(var o in this._ints)i.setInt(o,this._ints[o]);for(var o in this._uints)i.setUInt(o,this._uints[o]);for(var o in this._floats)i.setFloat(o,this._floats[o]);for(var o in this._floatsArrays)i.setFloats(o,this._floatsArrays[o]);for(var o in this._colors3)i.setColor3(o,this._colors3[o]);for(var o in this._colors3Arrays)i._colors3Arrays[o]=this._colors3Arrays[o];for(var o in this._colors4)i.setColor4(o,this._colors4[o]);for(var o in this._colors4Arrays)i._colors4Arrays[o]=this._colors4Arrays[o];for(var o in this._vectors2)i.setVector2(o,this._vectors2[o]);for(var o in this._vectors3)i.setVector3(o,this._vectors3[o]);for(var o in this._vectors4)i.setVector4(o,this._vectors4[o]);for(var o in this._quaternions)i.setQuaternion(o,this._quaternions[o]);for(var o in this._quaternionsArrays)i._quaternionsArrays[o]=this._quaternionsArrays[o];for(var o in this._matrices)i.setMatrix(o,this._matrices[o]);for(var o in this._matrixArrays)i._matrixArrays[o]=this._matrixArrays[o].slice();for(var o in this._matrices3x3)i.setMatrix3x3(o,this._matrices3x3[o]);for(var o in this._matrices2x2)i.setMatrix2x2(o,this._matrices2x2[o]);for(var o in this._vectors2Arrays)i.setArray2(o,this._vectors2Arrays[o]);for(var o in this._vectors3Arrays)i.setArray3(o,this._vectors3Arrays[o]);for(var o in this._vectors4Arrays)i.setArray4(o,this._vectors4Arrays[o]);for(var o in this._uniformBuffers)i.setUniformBuffer(o,this._uniformBuffers[o]);for(var o in this._textureSamplers)i.setTextureSampler(o,this._textureSamplers[o]);for(var o in this._storageBuffers)i.setStorageBuffer(o,this._storageBuffers[o]);return i},t.prototype.dispose=function(e,n,i){if(n){var o;for(o in this._textures)this._textures[o].dispose();for(o in this._textureArrays)for(var a=this._textureArrays[o],s=0;s<a.length;s++)a[s].dispose()}this._textures={},r.prototype.dispose.call(this,e,n,i)},t.prototype.serialize=function(){var e,n=tt.p.Serialize(this);for(e in n.customType="BABYLON.ShaderMaterial",n.uniqueId=this.uniqueId,n.options=this._options,n.shaderPath=this._shaderPath,n.storeEffectOnSubMeshes=this._storeEffectOnSubMeshes,n.stencil=this.stencil.serialize(),n.textures={},this._textures)n.textures[e]=this._textures[e].serialize();for(e in n.textureArrays={},this._textureArrays){n.textureArrays[e]=[];for(var i=this._textureArrays[e],o=0;o<i.length;o++)n.textureArrays[e].push(i[o].serialize())}for(e in n.ints={},this._ints)n.ints[e]=this._ints[e];for(e in n.uints={},this._uints)n.uints[e]=this._uints[e];for(e in n.floats={},this._floats)n.floats[e]=this._floats[e];for(e in n.floatsArrays={},this._floatsArrays)n.floatsArrays[e]=this._floatsArrays[e];for(e in n.colors3={},this._colors3)n.colors3[e]=this._colors3[e].asArray();for(e in n.colors3Arrays={},this._colors3Arrays)n.colors3Arrays[e]=this._colors3Arrays[e];for(e in n.colors4={},this._colors4)n.colors4[e]=this._colors4[e].asArray();for(e in n.colors4Arrays={},this._colors4Arrays)n.colors4Arrays[e]=this._colors4Arrays[e];for(e in n.vectors2={},this._vectors2)n.vectors2[e]=this._vectors2[e].asArray();for(e in n.vectors3={},this._vectors3)n.vectors3[e]=this._vectors3[e].asArray();for(e in n.vectors4={},this._vectors4)n.vectors4[e]=this._vectors4[e].asArray();for(e in n.quaternions={},this._quaternions)n.quaternions[e]=this._quaternions[e].asArray();for(e in n.matrices={},this._matrices)n.matrices[e]=this._matrices[e].asArray();for(e in n.matrixArray={},this._matrixArrays)n.matrixArray[e]=this._matrixArrays[e];for(e in n.matrices3x3={},this._matrices3x3)n.matrices3x3[e]=this._matrices3x3[e];for(e in n.matrices2x2={},this._matrices2x2)n.matrices2x2[e]=this._matrices2x2[e];for(e in n.vectors2Arrays={},this._vectors2Arrays)n.vectors2Arrays[e]=this._vectors2Arrays[e];for(e in n.vectors3Arrays={},this._vectors3Arrays)n.vectors3Arrays[e]=this._vectors3Arrays[e];for(e in n.vectors4Arrays={},this._vectors4Arrays)n.vectors4Arrays[e]=this._vectors4Arrays[e];for(e in n.quaternionsArrays={},this._quaternionsArrays)n.quaternionsArrays[e]=this._quaternionsArrays[e];return n},t.Parse=function(e,n,i){var o,a=tt.p.Parse(function(){return new t(e.name,n,e.shaderPath,e.options,e.storeEffectOnSubMeshes)},e,n,i);for(o in e.stencil&&a.stencil.parse(e.stencil,n,i),e.textures)a.setTexture(o,Ie.g.Parse(e.textures[o],n,i));for(o in e.textureArrays){for(var s=e.textureArrays[o],l=[],c=0;c<s.length;c++)l.push(Ie.g.Parse(s[c],n,i));a.setTextureArray(o,l)}for(o in e.ints)a.setInt(o,e.ints[o]);for(o in e.uints)a.setUInt(o,e.uints[o]);for(o in e.floats)a.setFloat(o,e.floats[o]);for(o in e.floatsArrays)a.setFloats(o,e.floatsArrays[o]);for(o in e.colors3)a.setColor3(o,z.v9.FromArray(e.colors3[o]));for(o in e.colors3Arrays){var u=e.colors3Arrays[o].reduce(function(d,h,p){return p%3==0?d.push([h]):d[d.length-1].push(h),d},[]).map(function(d){return z.v9.FromArray(d)});a.setColor3Array(o,u)}for(o in e.colors4)a.setColor4(o,z.ov.FromArray(e.colors4[o]));for(o in e.colors4Arrays)u=e.colors4Arrays[o].reduce(function(d,h,p){return p%4==0?d.push([h]):d[d.length-1].push(h),d},[]).map(function(d){return z.ov.FromArray(d)}),a.setColor4Array(o,u);for(o in e.vectors2)a.setVector2(o,_.I9.FromArray(e.vectors2[o]));for(o in e.vectors3)a.setVector3(o,_.Pq.FromArray(e.vectors3[o]));for(o in e.vectors4)a.setVector4(o,_.IU.FromArray(e.vectors4[o]));for(o in e.quaternions)a.setQuaternion(o,_.PT.FromArray(e.quaternions[o]));for(o in e.matrices)a.setMatrix(o,_.uq.FromArray(e.matrices[o]));for(o in e.matrixArray)a._matrixArrays[o]=new Float32Array(e.matrixArray[o]);for(o in e.matrices3x3)a.setMatrix3x3(o,e.matrices3x3[o]);for(o in e.matrices2x2)a.setMatrix2x2(o,e.matrices2x2[o]);for(o in e.vectors2Arrays)a.setArray2(o,e.vectors2Arrays[o]);for(o in e.vectors3Arrays)a.setArray3(o,e.vectors3Arrays[o]);for(o in e.vectors4Arrays)a.setArray4(o,e.vectors4Arrays[o]);for(o in e.quaternionsArrays)a.setArray4(o,e.quaternionsArrays[o]);return a},t.ParseFromFileAsync=function(e,n,i,o){var a=this;return o===void 0&&(o=""),new Promise(function(s,l){var c=new We.u;c.addEventListener("readystatechange",function(){if(c.readyState==4)if(c.status==200){var u=JSON.parse(c.responseText),d=a.Parse(u,i||Ve.q.LastCreatedScene,o);e&&(d.name=e),s(d)}else l("Unable to load the ShaderMaterial")}),c.open("GET",n),c.send()})},t.ParseFromSnippetAsync=function(e,n,i){var o=this;return i===void 0&&(i=""),new Promise(function(a,s){var l=new We.u;l.addEventListener("readystatechange",function(){if(l.readyState==4)if(l.status==200){var c=JSON.parse(JSON.parse(l.responseText).jsonPayload),u=JSON.parse(c.shaderMaterial),d=o.Parse(u,n||Ve.q.LastCreatedScene,i);d.snippetId=e,a(d)}else s("Unable to load the snippet "+e)}),l.open("GET",o.SnippetUrl+"/"+e.replace(/#/g,"/")),l.send()})},t.SnippetUrl=P.Y.SnippetUrl,t.CreateFromSnippetAsync=t.ParseFromSnippetAsync,t}(Ro);(0,j.Y5)("BABYLON.ShaderMaterial",pi);var cE=function(){function r(){this._pickingTexture=null,this._idMap=[],this._thinIdMap=[],this._idColors=[],this._meshMaterialMap=new Map,this._meshRenderingCount=0,this._attributeName="instanceMeshID",this._shaderLanguage=0,this._pickingInProgress=!1}return Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pickingInProgress",{get:function(){return this._pickingInProgress},enumerable:!1,configurable:!0}),r._IdToRgb=function(t){r._TempColor.r=(16711680&t)>>16,r._TempColor.g=(65280&t)>>8,r._TempColor.b=255&t},r.prototype._getColorIdFromReadBuffer=function(t){return(this._readbuffer[t]<<16)+(this._readbuffer[t+1]<<8)+this._readbuffer[t+2]},r._SetColorData=function(t,e,n,i,o){t[e]=n/255,t[e+1]=i/255,t[e+2]=o/255,t[e+3]=1},r.prototype._createRenderTarget=function(t,e,n){this._pickingTexture&&this._pickingTexture.dispose(),this._pickingTexture=new un.$("pickingTexure",{width:e,height:n},t,!1,void 0,P.Y.TEXTURETYPE_UNSIGNED_INT,!1,P.Y.TEXTURE_NEAREST_NEAREST)},r.prototype._createColorMaterialAsync=function(t){return(0,A.sH)(this,void 0,void 0,function(){var e,n,i=this;return(0,A.YH)(this,function(o){return this._defaultRenderMaterial&&this._defaultRenderMaterial.dispose(),this._defaultRenderMaterial=null,t.getEngine().isWebGPU&&(this._shaderLanguage=1),e=[],n={attributes:[Y.R.PositionKind,this._attributeName,"bakedVertexAnimationSettingsInstanced"],uniforms:["world","viewProjection","meshID"],needAlphaBlending:!1,defines:e,useClipPlane:null,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(i,void 0,void 0,function(){return(0,A.YH)(this,function(a){switch(a.label){case 0:return this.shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,72014)),Promise.resolve().then(L.bind(L,96672))])];case 1:return a.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,98197)),Promise.resolve().then(L.bind(L,30683))])];case 3:a.sent(),a.label=4;case 4:return[2]}})})}},this._defaultRenderMaterial=new pi("pickingShader",t,"picking",n,!1),this._defaultRenderMaterial.onBindObservable.add(this._materialBindCallback,void 0,void 0,this),[2]})})},r.prototype._materialBindCallback=function(t){if(t){var e=this._meshMaterialMap.get(t).getEffect();t.hasInstances||t.isAnInstance||t.hasThinInstances||e.setColor4("meshID",this._idColors[t.uniqueId],1),this._meshRenderingCount++}},r.prototype._generateColorData=function(t,e,n,i,o,a,s){var l=new Float32Array(4*(t+1));r._SetColorData(l,0,i,o,a);for(var c=0;c<t;c++)r._IdToRgb(e),s(c,e),r._SetColorData(l,4*(c+1),r._TempColor.r,r._TempColor.g,r._TempColor.b),e++;return l},r.prototype._generateThinInstanceColorData=function(t,e,n){for(var i=new Float32Array(4*t),o=0;o<t;o++)r._IdToRgb(e),n(o,e),r._SetColorData(i,4*o,r._TempColor.r,r._TempColor.g,r._TempColor.b),e++;return i},r.prototype.setPickingList=function(t){var e=this;if(this._pickableMeshes){for(var n=0;n<this._pickableMeshes.length;n++){var i=this._pickableMeshes[n];i.hasInstances&&i.removeVerticesData(this._attributeName),i.hasThinInstances&&i.thinInstanceSetBuffer(this._attributeName,null),this._pickingTexture&&this._pickingTexture.setMaterialForRendering(i,void 0);var o=this._meshMaterialMap.get(i);o!==this._defaultRenderMaterial&&o.onBindObservable.removeCallback(this._materialBindCallback)}this._pickableMeshes.length=0,this._meshMaterialMap.clear(),this._idMap.length=0,this._thinIdMap.length=0,this._idColors.length=0,this._pickingTexture&&(this._pickingTexture.renderList=[])}if(t&&t.length!==0){this._pickableMeshes=t;var a=("mesh"in t[0]?t[0].mesh:t[0]).getScene(),s=a.getEngine(),l=s.getRenderWidth(),c=s.getRenderHeight();if(this._pickingTexture){var u=this._pickingTexture.getSize();u.width===l&&u.height===c&&this._cachedScene===a||this._createRenderTarget(a,l,c)}else this._createRenderTarget(a,l,c);this._cachedScene&&this._cachedScene===a||this._createColorMaterialAsync(a),this._cachedScene=a,this._engine=a.getEngine();for(var d=0;d<t.length;d++){var h=t[d];"mesh"in h?(this._meshMaterialMap.set(h.mesh,h.material),t[d]=h.mesh):this._meshMaterialMap.set(h,this._defaultRenderMaterial)}this._pickingTexture.renderList=[];var p=1,m=function(b){var E=v._pickableMeshes[b],C=v._meshMaterialMap.get(E);if(C!==v._defaultRenderMaterial&&C.onBindObservable.add(v._materialBindCallback,void 0,void 0,v),v._pickingTexture.setMaterialForRendering(E,C),v._pickingTexture.renderList.push(E),E.isAnInstance)return"continue";if(r._IdToRgb(p),E.hasThinInstances){var T=v._generateThinInstanceColorData(E.thinInstanceCount,p,function(y,x){e._thinIdMap[x]={meshId:b,thinId:y}});p+=E.thinInstanceCount,E.thinInstanceSetBuffer(v._attributeName,T,4)}else if(v._idMap[p]=b,p++,E.hasInstances){var f=E.instances;T=v._generateColorData(f.length,p,b,r._TempColor.r,r._TempColor.g,r._TempColor.b,function(y,x){var R=f[y];e._idMap[x]=e._pickableMeshes.indexOf(R)}),p+=f.length;var g=E.getEngine(),S=new Y.R(g,T,v._attributeName,!1,!1,4,!0);E.setVerticesBuffer(S,!0)}else v._idColors[E.uniqueId]=z.v9.FromInts(r._TempColor.r,r._TempColor.g,r._TempColor.b)},v=this;for(n=0;n<this._pickableMeshes.length;n++)m(n)}},r.prototype.pickAsync=function(t,e,n){return n===void 0&&(n=!1),(0,A.sH)(this,void 0,void 0,function(){var i,o,a,s,l,c;return(0,A.YH)(this,function(u){return this._pickingInProgress?[2,null]:this._pickableMeshes&&this._pickableMeshes.length!==0?(c=this._prepareForPicking(t,e),i=c.x,o=c.y,a=c.rttSizeW,s=c.rttSizeH,i<0||o<0||i>=a||o>=s?[2,null]:(this._pickingInProgress=!0,l=s-o-1,this._preparePickingBuffer(this._engine,a,s,i,l),[2,this._executePicking(i,l,n)])):[2,null]})})},r.prototype.multiPickAsync=function(t,e){var n;return e===void 0&&(e=!1),(0,A.sH)(this,void 0,void 0,function(){var i,o,a,s,l,c,u,d,h,p,m,v,b,E,C;return(0,A.YH)(this,function(T){switch(T.label){case 0:return this._pickingInProgress?[2,null]:this._pickableMeshes&&this._pickableMeshes.length!==0&&t.length!==0?t.length!==1?[3,2]:[4,this.pickAsync(t[0].x,t[0].y,e)]:[2,null];case 1:return i=T.sent(),[2,{meshes:[(n=i?.mesh)!==null&&n!==void 0?n:null],thinInstanceIndexes:i?.thinInstanceIndex?[i.thinInstanceIndex]:void 0}];case 2:for(this._pickingInProgress=!0,o=t[0].x,a=t[0].x,s=t[0].y,l=t[0].y,c=1;c<t.length;c++)E=t[c],u=E.x,d=E.y,o=Math.min(o,u),a=Math.max(a,u),s=Math.min(s,d),l=Math.max(l,d);return C=this._prepareForPicking(o,s),h=C.rttSizeW,p=C.rttSizeH,m=Math.max(a-o,1),v=Math.max(l-s,1),b=p-l-1,this._preparePickingBuffer(this._engine,h,p,o,b,m,v),[2,this._executeMultiPicking(t,o,l,p,m,v,e)]}})})},r.prototype._prepareForPicking=function(t,e){var n=this._cachedScene.getEngine(),i=n.getRenderWidth(),o=n.getRenderHeight(),a=1/n._hardwareScalingLevel;return{x:a*t|0,y:a*e|0,rttSizeW:i,rttSizeH:o}},r.prototype._preparePickingBuffer=function(t,e,n,i,o,a,s){var l=this;a===void 0&&(a=1),s===void 0&&(s=1),this._meshRenderingCount=0;var c=t.isWebGPU?4*a*s+255&-256:4*a*s;(!this._readbuffer||this._readbuffer.length<c)&&(this._readbuffer=new Uint8Array(c));var u=this._pickingTexture.getSize();u.width===e&&u.height===n||(this._createRenderTarget(this._cachedScene,e,n),this._updateRenderList()),this._pickingTexture.clearColor=new z.ov(0,0,0,0),this._pickingTexture.onBeforeRender=function(){l._enableScissor(i,o,a,s)},this._cachedScene.customRenderTargets.push(this._pickingTexture)},r.prototype._executePicking=function(t,e,n){var i=this;return new Promise(function(o,a){if(!i._pickingTexture)return i._pickingInProgress=!1,void a();i._pickingTexture.onAfterRender=function(){return(0,A.sH)(i,void 0,void 0,function(){var s,l,c,u;return(0,A.YH)(this,function(d){switch(d.label){case 0:return this._disableScissor(),this._checkRenderStatus()?(this._pickingTexture.onAfterRender=null,s=null,l=void 0,(c=this._cachedScene.customRenderTargets.indexOf(this._pickingTexture))>-1&&this._cachedScene.customRenderTargets.splice(c,1),[4,this._readTexturePixelsAsync(t,e)]):[3,2];case 1:d.sent()&&(u=this._getColorIdFromReadBuffer(0),this._thinIdMap[u]?(s=this._pickableMeshes[this._thinIdMap[u].meshId],l=this._thinIdMap[u].thinId):s=this._pickableMeshes[this._idMap[u]]),n&&this.dispose(),this._pickingInProgress=!1,o(s?{mesh:s,thinInstanceIndex:l}:null),d.label=2;case 2:return[2]}})})}})},r.prototype._executeMultiPicking=function(t,e,n,i,o,a,s){var l=this;return new Promise(function(c,u){if(!l._pickingTexture)return l._pickingInProgress=!1,void u();l._pickingTexture.onAfterRender=function(){return(0,A.sH)(l,void 0,void 0,function(){var d,h,p,m,v,b;return(0,A.YH)(this,function(E){switch(E.label){case 0:return this._disableScissor(),this._checkRenderStatus()?(this._pickingTexture.onAfterRender=null,d=[],h=[],[4,this._readTexturePixelsAsync(e,i-n-1,o,a)]):[3,2];case 1:if(E.sent())for(p=0;p<t.length;p++)b=this._getMeshFromMultiplePoints(t[p].x,t[p].y,e,n,o),m=b.pickedMesh,v=b.thinInstanceIndex,d.push(m),h.push(v??0);s&&this.dispose(),this._pickingInProgress=!1,c({meshes:d,thinInstanceIndexes:h}),E.label=2;case 2:return[2]}})})}})},r.prototype._enableScissor=function(t,e,n,i){n===void 0&&(n=1),i===void 0&&(i=1),this._engine.enableScissor&&this._engine.enableScissor(t,e,n,i)},r.prototype._disableScissor=function(){this._engine.disableScissor&&this._engine.disableScissor()},r.prototype._checkRenderStatus=function(){if(this._meshRenderingCount>0){var t=this._cachedScene.customRenderTargets.indexOf(this._pickingTexture);return t>-1&&this._cachedScene.customRenderTargets.splice(t,1),!0}return this._meshRenderingCount=0,!1},r.prototype._getMeshFromMultiplePoints=function(t,e,n,i,o){var a=4*(t-n-1),s=(i-e-1)*o*4;a=Math.max(a,0),s=Math.max(s,0);var l,c=this._getColorIdFromReadBuffer(a+s),u=null;return c>0&&(this._thinIdMap[c]?(u=this._pickableMeshes[this._thinIdMap[c].meshId],l=this._thinIdMap[c].thinId):u=this._pickableMeshes[this._idMap[c]]),{pickedMesh:u,thinInstanceIndex:l}},r.prototype._updateRenderList=function(){this._pickingTexture.renderList=[];for(var t=0,e=this._pickableMeshes;t<e.length;t++){var n=e[t];this._pickingTexture.setMaterialForRendering(n,this._meshMaterialMap.get(n)),this._pickingTexture.renderList.push(n)}},r.prototype._readTexturePixelsAsync=function(t,e,n,i){var o;return n===void 0&&(n=1),i===void 0&&(i=1),(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(a){switch(a.label){case 0:return this._cachedScene&&(!((o=this._pickingTexture)===null||o===void 0)&&o._texture)?[4,this._cachedScene.getEngine()._readTexturePixels(this._pickingTexture._texture,n,i,-1,0,this._readbuffer,!0,!0,t,e)]:[2,!1];case 1:return a.sent(),[2,!0]}})})},r.prototype.dispose=function(){var t,e;this.setPickingList(null),this._cachedScene=null,(t=this._pickingTexture)===null||t===void 0||t.dispose(),this._pickingTexture=null,(e=this._defaultRenderMaterial)===null||e===void 0||e.dispose(),this._defaultRenderMaterial=null},r._TempColor={r:0,g:0,b:0},r}(),uE=L(98197),dE=L(30683),hE=L(72014),fE=L(96672),$m=function(){function r(t,e,n,i){i===void 0&&(i="");var o,a,s,l=this;this.defines="",this.onCompiled=null,this.onError=null,this.uniqueId=0,this.onCompileObservable=new K.cP,this.onErrorObservable=new K.cP,this.onBindObservable=new K.cP,this._wasPreviouslyReady=!1,this._isReady=!1,this._compilationError="",this._key="",this._computeSourceCodeOverride="",this._pipelineContext=null,this._computeSourceCode="",this._rawComputeSourceCode="",this._shaderLanguage=1,this.name=t,this._key=i,this._engine=n,this.uniqueId=r._UniqueIdSeed++,this.defines=(o=e.defines)!==null&&o!==void 0?o:"",this.onError=e.onError,this.onCompiled=e.onCompiled,this._entryPoint=(a=e.entryPoint)!==null&&a!==void 0?a:"main",this._shaderStore=Gt.l.GetShadersStore(this._shaderLanguage),this._shaderRepository=Gt.l.GetShadersRepository(this._shaderLanguage),this._includeShaderStore=Gt.l.GetIncludesShadersStore(this._shaderLanguage);var c=(0,bi.BA)()?this._engine.getHostDocument():null;s=typeof t=="string"?t:t.computeSource?"source:"+t.computeSource:t.computeElement?c?.getElementById(t.computeElement)||t.computeElement:t.compute||t;var u={defines:this.defines.split(`
|
||
`),indexParameters:void 0,isFragment:!1,shouldUseHighPrecisionShader:!1,processor:null,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:this._shaderRepository,includesShadersStore:this._includeShaderStore,version:(100*this._engine.version).toString(),platformName:this._engine.shaderPlatformName,processingContext:null,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:function(d,h,p){if(!p)return h;for(var m=0,v=p;m<v.length;m++){var b=v[m].replace("#define","").replace(";","").trim().split(" ");if(b.length===2){var E=b[0],C=b[1];isNaN(parseInt(C))&&isNaN(parseFloat(C))||(h="const ".concat(E," = ").concat(C,`;
|
||
`)+h)}}return h}};this._loadShader(s,"Compute","",function(d){(0,Io.pB)(u),(0,Io.jC)(d,u,function(h){l._rawComputeSourceCode=d,e.processFinalCode&&(h=e.processFinalCode(h));var p=(0,Io.nO)(h,"",u);l._useFinalCode(p.vertexCode,t)},l._engine)})}return r.prototype._useFinalCode=function(t,e){if(e){var n=e.computeElement||e.compute||e.spectorName||e;this._computeSourceCode="//#define SHADER_NAME compute:"+n+`
|
||
`+t}else this._computeSourceCode=t;this._prepareEffect()},Object.defineProperty(r.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),r.prototype.isReady=function(){try{return this._isReadyInternal()}catch{return!1}},r.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},r.prototype.getEngine=function(){return this._engine},r.prototype.getPipelineContext=function(){return this._pipelineContext},r.prototype.getCompilationError=function(){return this._compilationError},r.prototype.executeWhenCompiled=function(t){var e=this;this.isReady()?t(this):(this.onCompileObservable.add(function(n){t(n)}),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout(function(){e._checkIsReady(null)},16))},r.prototype._checkIsReady=function(t){var e=this;try{if(this._isReadyInternal())return}catch(n){return void this._processCompilationErrors(n,t)}setTimeout(function(){e._checkIsReady(t)},16)},r.prototype._loadShader=function(t,e,n,i){var o;typeof HTMLElement<"u"&&t instanceof HTMLElement?i((0,bi.Zl)(t)):t.substring(0,7)!=="source:"?t.substring(0,7)!=="base64:"?this._shaderStore[t+e+"Shader"]?i(this._shaderStore[t+e+"Shader"]):n&&this._shaderStore[t+n+"Shader"]?i(this._shaderStore[t+n+"Shader"]):(o=t[0]==="."||t[0]==="/"||t.indexOf("http")>-1?t:this._shaderRepository+t,this._engine._loadFile(o+"."+e.toLowerCase()+".fx",i)):i(window.atob(t.substring(7))):i(t.substring(7))},Object.defineProperty(r.prototype,"computeSourceCode",{get:function(){var t,e;return this._computeSourceCodeOverride?this._computeSourceCodeOverride:(e=(t=this._pipelineContext)===null||t===void 0?void 0:t._getComputeShaderCode())!==null&&e!==void 0?e:this._computeSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rawComputeSourceCode",{get:function(){return this._rawComputeSourceCode},enumerable:!1,configurable:!0}),r.prototype._prepareEffect=function(){var t=this,e=this.defines,n=this._pipelineContext;this._isReady=!1;try{var i=this._engine;this._pipelineContext=i.createComputePipelineContext(),this._pipelineContext._name=this._key,i._prepareComputePipelineContext(this._pipelineContext,this._computeSourceCodeOverride?this._computeSourceCodeOverride:this._computeSourceCode,this._rawComputeSourceCode,this._computeSourceCodeOverride?null:e,this._entryPoint),i._executeWhenComputeStateIsCompiled(this._pipelineContext,function(o){o&&o.numErrors>0?t._processCompilationErrors(o,n):(t._compilationError="",t._isReady=!0,t.onCompiled&&t.onCompiled(t),t.onCompileObservable.notifyObservers(t),t.onCompileObservable.clear(),n&&t.getEngine()._deleteComputePipelineContext(n))}),this._pipelineContext.isAsync&&this._checkIsReady(n)}catch(o){this._processCompilationErrors(o,n)}},r.prototype._processCompilationErrors=function(t,e){var n;if(e===void 0&&(e=null),this._compilationError="",O.V.Error("Unable to compile compute effect:"),this.defines&&O.V.Error(`Defines:
|
||
`+this.defines),r.LogShaderCodeOnCompilationError){var i=(n=this._pipelineContext)===null||n===void 0?void 0:n._getComputeShaderCode();i&&(O.V.Error("Compute code:"),O.V.Error(i))}if(typeof t=="string")this._compilationError=t,O.V.Error("Error: "+this._compilationError);else for(var o=0,a=t.messages;o<a.length;o++){var s=a[o],l="";s.line!==void 0&&(l+="Line "+s.line+", "),s.offset!==void 0&&(l+="Offset "+s.offset+", "),s.length!==void 0&&(l+="Length "+s.length+", "),l+=s.type+": "+s.text,this._compilationError&&(this._compilationError+=`
|
||
`),this._compilationError+=l,O.V.Error(l)}e&&(this._pipelineContext=e,this._isReady=!0),this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)},r.prototype.dispose=function(){this._pipelineContext&&this._pipelineContext.dispose(),this._engine._releaseComputeEffect(this)},r.RegisterShader=function(t,e){Gt.l.GetShadersStore(1)["".concat(t,"ComputeShader")]=e},r._UniqueIdSeed=0,r.LogShaderCodeOnCompilationError=!0,r}(),eg=L(75227),pE=function(){function r(t){this._engine=t}return r.prototype._initializePlatform=function(){return(0,A.sH)(this,void 0,void 0,function(){var t,e;return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._platform?[3,5]:this._engine.getCaps().supportComputeShaders?[4,Promise.resolve().then(L.bind(L,18149))]:[3,2];case 1:return t=n.sent(),this._platform=new t.ComputeShaderBoundingHelper(this._engine),[3,5];case 2:return this._engine.getCaps().supportTransformFeedbacks?[4,Promise.resolve().then(L.bind(L,37904))]:[3,4];case 3:return e=n.sent(),this._platform=new e.TransformFeedbackBoundingHelper(this._engine),[3,5];case 4:throw new Error("Your engine does not support Compute Shaders or Transform Feedbacks");case 5:return[2]}})})},r.prototype.computeAsync=function(t){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return[4,this._initializePlatform()];case 1:return e.sent(),[2,this._platform.processAsync(t)]}})})},r.prototype.batchInitializeAsync=function(t){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return[4,this._initializePlatform()];case 1:return e.sent(),[2,this._platform.registerMeshListAsync(t)]}})})},r.prototype.batchProcess=function(){this._platform.processMeshList()},r.prototype.batchFetchResultsAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){return[2,this._platform.fetchResultsForMeshListAsync()]})})},r.prototype.dispose=function(){this._platform.dispose()},r}(),_E=L(37904),mE=L(18149),tg=function(){function r(t,e,n,i,o,a){this.entries=[],this._boundingVectors=new Array,this._capacity=n,this._depth=i,this._maxDepth=o,this._creationFunc=a,this._minPoint=t,this._maxPoint=e,this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors[2].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[3].y=e.y,this._boundingVectors.push(t.clone()),this._boundingVectors[4].z=e.z,this._boundingVectors.push(e.clone()),this._boundingVectors[5].z=t.z,this._boundingVectors.push(e.clone()),this._boundingVectors[6].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[7].y=t.y}return Object.defineProperty(r.prototype,"capacity",{get:function(){return this._capacity},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!1,configurable:!0}),r.prototype.addEntry=function(t){if(this.blocks)for(var e=0;e<this.blocks.length;e++)this.blocks[e].addEntry(t);else this._creationFunc(t,this),this.entries.length>this.capacity&&this._depth<this._maxDepth&&this.createInnerBlocks()},r.prototype.removeEntry=function(t){if(this.blocks)for(var e=0;e<this.blocks.length;e++)this.blocks[e].removeEntry(t);else{var n=this.entries.indexOf(t);n>-1&&this.entries.splice(n,1)}},r.prototype.addEntries=function(t){for(var e=0;e<t.length;e++){var n=t[e];this.addEntry(n)}},r.prototype.select=function(t,e,n){if(To.IsInFrustum(this._boundingVectors,t)){if(this.blocks){for(var i=0;i<this.blocks.length;i++)this.blocks[i].select(t,e,n);return}n?e.concat(this.entries):e.concatWithNoDuplicate(this.entries)}},r.prototype.intersects=function(t,e,n,i){if(To.IntersectsSphere(this._minPoint,this._maxPoint,t,e)){if(this.blocks){for(var o=0;o<this.blocks.length;o++)this.blocks[o].intersects(t,e,n,i);return}i?n.concat(this.entries):n.concatWithNoDuplicate(this.entries)}},r.prototype.intersectsRay=function(t,e){if(t.intersectsBoxMinMax(this._minPoint,this._maxPoint)){if(this.blocks){for(var n=0;n<this.blocks.length;n++)this.blocks[n].intersectsRay(t,e);return}e.concatWithNoDuplicate(this.entries)}},r.prototype.createInnerBlocks=function(){r._CreateBlocks(this._minPoint,this._maxPoint,this.entries,this._capacity,this._depth,this._maxDepth,this,this._creationFunc),this.entries.splice(0)},r._CreateBlocks=function(t,e,n,i,o,a,s,l){s.blocks=new Array;for(var c=new _.Pq((e.x-t.x)/2,(e.y-t.y)/2,(e.z-t.z)/2),u=0;u<2;u++)for(var d=0;d<2;d++)for(var h=0;h<2;h++){var p=new r(t.add(c.multiplyByFloats(u,d,h)),t.add(c.multiplyByFloats(u+1,d+1,h+1)),i,o+1,a,l);p.addEntries(n),s.blocks.push(p)}},r}(),La=function(){function r(t,e,n){n===void 0&&(n=2),this.maxDepth=n,this.dynamicContent=[],this._maxBlockCapacity=e||64,this._selectionContent=new er.b(1024),this._creationFunc=t}return r.prototype.update=function(t,e,n){tg._CreateBlocks(t,e,n,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},r.prototype.addMesh=function(t){for(var e=0;e<this.blocks.length;e++)this.blocks[e].addEntry(t)},r.prototype.removeMesh=function(t){for(var e=0;e<this.blocks.length;e++)this.blocks[e].removeEntry(t)},r.prototype.select=function(t,e){this._selectionContent.reset();for(var n=0;n<this.blocks.length;n++)this.blocks[n].select(t,this._selectionContent,e);return e?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.prototype.intersects=function(t,e,n){this._selectionContent.reset();for(var i=0;i<this.blocks.length;i++)this.blocks[i].intersects(t,e,this._selectionContent,n);return n?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.prototype.intersectsRay=function(t){this._selectionContent.reset();for(var e=0;e<this.blocks.length;e++)this.blocks[e].intersectsRay(t,this._selectionContent);return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.CreationFuncForMeshes=function(t,e){var n=t.getBoundingInfo();!t.isBlocked&&n.boundingBox.intersectsMinMax(e.minPoint,e.maxPoint)&&e.entries.push(t)},r.CreationFuncForSubMeshes=function(t,e){t.getBoundingInfo().boundingBox.intersectsMinMax(e.minPoint,e.maxPoint)&&e.entries.push(t)},r}();ke.Z.prototype.createOrUpdateSelectionOctree=function(r,t){r===void 0&&(r=64),t===void 0&&(t=2);var e=this._getComponent(lt.v.NAME_OCTREE);e||(e=new Eu(this),this._addComponent(e)),this._selectionOctree||(this._selectionOctree=new La(La.CreationFuncForMeshes,r,t));var n=this.getWorldExtends();return this._selectionOctree.update(n.min,n.max,this.meshes),this._selectionOctree},Object.defineProperty(ke.Z.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),cn.prototype.createOrUpdateSubmeshesOctree=function(r,t){r===void 0&&(r=64),t===void 0&&(t=2);var e=this.getScene(),n=e._getComponent(lt.v.NAME_OCTREE);n||(n=new Eu(e),e._addComponent(n)),this._submeshesOctree||(this._submeshesOctree=new La(La.CreationFuncForSubMeshes,r,t)),this.computeWorldMatrix(!0);var i=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(i.minimumWorld,i.maximumWorld,this.subMeshes),this._submeshesOctree};var Eu=function(){function r(t){var e=this;this.name=lt.v.NAME_OCTREE,this.checksIsEnabled=!0,this._tempRay=new fn(_.Pq.Zero(),new _.Pq(1,1,1)),(t=t||Ve.q.LastCreatedScene)&&(this.scene=t,this.scene.getActiveMeshCandidates=function(){return e.getActiveMeshCandidates()},this.scene.getActiveSubMeshCandidates=function(n){return e.getActiveSubMeshCandidates(n)},this.scene.getCollidingSubMeshCandidates=function(n,i){return e.getCollidingSubMeshCandidates(n,i)},this.scene.getIntersectingSubMeshCandidates=function(n,i){return e.getIntersectingSubMeshCandidates(n,i)})}return r.prototype.register=function(){var t=this;this.scene.onMeshRemovedObservable.add(function(e){var n=t.scene.selectionOctree;if(n!=null){var i=n.dynamicContent.indexOf(e);i!==-1&&n.dynamicContent.splice(i,1)}}),this.scene.onMeshImportedObservable.add(function(e){var n=t.scene.selectionOctree;n?.addMesh(e)})},r.prototype.getActiveMeshCandidates=function(){var t;return((t=this.scene._selectionOctree)===null||t===void 0?void 0:t.select(this.scene.frustumPlanes))||this.scene._getDefaultMeshCandidates()},r.prototype.getActiveSubMeshCandidates=function(t){return t._submeshesOctree&&t.useOctreeForRenderingSelection?t._submeshesOctree.select(this.scene.frustumPlanes):this.scene._getDefaultSubMeshCandidates(t)},r.prototype.getIntersectingSubMeshCandidates=function(t,e){return t._submeshesOctree&&t.useOctreeForPicking?(fn.TransformToRef(e,t.getWorldMatrix(),this._tempRay),t._submeshesOctree.intersectsRay(this._tempRay)):this.scene._getDefaultSubMeshCandidates(t)},r.prototype.getCollidingSubMeshCandidates=function(t,e){if(t._submeshesOctree&&t.useOctreeForCollisions){var n=e._velocityWorldLength+Math.max(e._radius.x,e._radius.y,e._radius.z);return t._submeshesOctree.intersects(e._basePointWorld,n)}return this.scene._getDefaultSubMeshCandidates(t)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r}();function Ws(r){var t=r.height||2,e=r.diameterTop===0?0:r.diameterTop||r.diameter||1,n=r.diameterBottom===0?0:r.diameterBottom||r.diameter||1;e=e||1e-5,n=n||1e-5;var i,o=0|(r.tessellation||24),a=0|(r.subdivisions||1),s=!!r.hasRings,l=!!r.enclose,c=r.cap===0?0:r.cap||xe.CAP_ALL,u=r.arc&&(r.arc<=0||r.arc>1)?1:r.arc||1,d=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,h=r.faceUV||new Array(3),p=r.faceColors,m=2+(1+(u!==1&&l?2:0))*(s?a:1);for(i=0;i<m;i++)p&&p[i]===void 0&&(p[i]=new z.ov(1,1,1,1));for(i=0;i<m;i++)h&&h[i]===void 0&&(h[i]=new _.IU(0,0,1,1));var v,b,E,C,T,f,g=[],S=[],y=[],x=[],R=[],I=2*Math.PI*u/o,M=(n-e)/2/t,D=_.Pq.Zero(),B=_.Pq.Zero(),F=_.Pq.Zero(),X=_.Pq.Zero(),$=_.Pq.Zero(),Q=Qn._0.Y,ie=1,q=1,ee=0,te=0;for(C=0;C<=a;C++)for(E=((b=C/a)*(e-n)+n)/2,ie=s&&C!==0&&C!==a?2:1,f=0;f<ie;f++){for(s&&(q+=f),l&&(q+=2*f),T=0;T<=o;T++)v=T*I,D.x=Math.cos(-v)*E,D.y=-t/2+b*t,D.z=Math.sin(-v)*E,e===0&&C===a?(B.x=y[y.length-3*(o+1)],B.y=y[y.length-3*(o+1)+1],B.z=y[y.length-3*(o+1)+2]):(B.x=D.x,B.z=D.z,B.y=Math.sqrt(B.x*B.x+B.z*B.z)*M,B.normalize()),T===0&&(F.copyFrom(D),X.copyFrom(B)),S.push(D.x,D.y,D.z),y.push(B.x,B.y,B.z),te=s?ee!==q?h[q].y:h[q].w:h[q].y+(h[q].w-h[q].y)*b,x.push(h[q].x+(h[q].z-h[q].x)*T/o,Xt.rX?1-te:te),p&&R.push(p[q].r,p[q].g,p[q].b,p[q].a);u!==1&&l&&(S.push(D.x,D.y,D.z),S.push(0,D.y,0),S.push(0,D.y,0),S.push(F.x,F.y,F.z),_.Pq.CrossToRef(Q,B,$),$.normalize(),y.push($.x,$.y,$.z,$.x,$.y,$.z),_.Pq.CrossToRef(X,Q,$),$.normalize(),y.push($.x,$.y,$.z,$.x,$.y,$.z),te=s?ee!==q?h[q+1].y:h[q+1].w:h[q+1].y+(h[q+1].w-h[q+1].y)*b,x.push(h[q+1].x,Xt.rX?1-te:te),x.push(h[q+1].z,Xt.rX?1-te:te),te=s?ee!==q?h[q+2].y:h[q+2].w:h[q+2].y+(h[q+2].w-h[q+2].y)*b,x.push(h[q+2].x,Xt.rX?1-te:te),x.push(h[q+2].z,Xt.rX?1-te:te),p&&(R.push(p[q+1].r,p[q+1].g,p[q+1].b,p[q+1].a),R.push(p[q+1].r,p[q+1].g,p[q+1].b,p[q+1].a),R.push(p[q+2].r,p[q+2].g,p[q+2].b,p[q+2].a),R.push(p[q+2].r,p[q+2].g,p[q+2].b,p[q+2].a))),ee!==q&&(ee=q)}var ce=u!==1&&l?o+4:o;for(C=0,q=0;q<a;q++){var fe=0,de=0,Te=0,ue=0;for(T=0;T<o;T++)fe=C*(ce+1)+T,de=(C+1)*(ce+1)+T,Te=C*(ce+1)+(T+1),ue=(C+1)*(ce+1)+(T+1),g.push(fe,de,Te),g.push(ue,Te,de);u!==1&&l&&(g.push(fe+2,de+2,Te+2),g.push(ue+2,Te+2,de+2),g.push(fe+4,de+4,Te+4),g.push(ue+4,Te+4,de+4)),C=s?C+2:C+1}var U=function(w){var k=w?e/2:n/2;if(k!==0){var J,le,be,ve=w?h[m-1]:h[0],ye=null;p&&(ye=w?p[m-1]:p[0]);var Me=S.length/3,we=w?t/2:-t/2,He=new _.Pq(0,we,0);S.push(He.x,He.y,He.z),y.push(0,w?1:-1,0);var Ke=ve.y+.5*(ve.w-ve.y);x.push(ve.x+.5*(ve.z-ve.x),Xt.rX?1-Ke:Ke),ye&&R.push(ye.r,ye.g,ye.b,ye.a);var Qe=new _.I9(.5,.5);for(be=0;be<=o;be++){J=2*Math.PI*be*u/o;var Je=Math.cos(-J),ht=Math.sin(-J);le=new _.Pq(Je*k,we,ht*k);var mt=new _.I9(Je*Qe.x+.5,ht*Qe.y+.5);S.push(le.x,le.y,le.z),y.push(0,w?1:-1,0);var yt=ve.y+(ve.w-ve.y)*mt.y;x.push(ve.x+(ve.z-ve.x)*mt.x,Xt.rX?1-yt:yt),ye&&R.push(ye.r,ye.g,ye.b,ye.a)}for(be=0;be<o;be++)w?(g.push(Me),g.push(Me+(be+2)),g.push(Me+(be+1))):(g.push(Me),g.push(Me+(be+1)),g.push(Me+(be+2)))}};c!==xe.CAP_START&&c!==xe.CAP_ALL||U(!1),c!==xe.CAP_END&&c!==xe.CAP_ALL||U(!0),rt._ComputeSides(d,S,g,y,x,r.frontUVs,r.backUVs);var N=new rt;return N.indices=g,N.positions=S,N.normals=y,N.uvs=x,p&&(N.colors=R),N}function _i(r,t,e){t===void 0&&(t={});var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ws(t).applyToMesh(n,t.updatable),n}var gE={CreateCylinder:_i};rt.CreateCylinder=Ws,xe.CreateCylinder=function(r,t,e,n,i,o,a,s,l){return a!==void 0&&a instanceof ke.Z||(a!==void 0&&(l=s||xe.DEFAULTSIDE,s=a),a=o,o=1),_i(r,{height:t,diameterTop:e,diameterBottom:n,tessellation:i,subdivisions:o,sideOrientation:l,updatable:s},a)},At.AddNodeConstructor("Light_Type_3",function(r,t){return function(){return new na(r,_.Pq.Zero(),t)}});var na=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o.groundColor=new z.v9(0,0,0),o.direction=n||_.Pq.Up(),o}return(0,A.C6)(t,r),t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.getClassName=function(){return"HemisphericLight"},t.prototype.setDirectionToTarget=function(e){return this.direction=_.Pq.Normalize(e.subtract(_.Pq.Zero())),this.direction},t.prototype.getShadowGenerator=function(){return null},t.prototype.transferToEffect=function(e,n){var i=_.Pq.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",i.x,i.y,i.z,0,n),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),n),this},t.prototype.transferToNodeMaterialEffect=function(e,n){var i=_.Pq.Normalize(this.direction);return e.setFloat3(n,i.x,i.y,i.z),this},t.prototype.computeWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=_.uq.Identity()),this._worldMatrix},t.prototype.getTypeID=function(){return hi.LIGHTTYPEID_HEMISPHERICLIGHT},t.prototype.prepareLightSpecificDefines=function(e,n){e["HEMILIGHT"+n]=!0},(0,A.Cg)([(0,V.jT)()],t.prototype,"groundColor",void 0),(0,A.Cg)([(0,V.P_)()],t.prototype,"direction",void 0),t}(hi);(0,j.Y5)("BABYLON.HemisphericLight",na);var xu,Pu,Fn=function(){function r(t,e){e===void 0&&(e=!0);var n=this;this.originalScene=t,this._pointerCaptures={},this._lastPointerEvents={},this._sharedGizmoLight=null,this._renderCamera=null,this.pickUtilitySceneFirst=!0,this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.pickingEnabled=!0,this.onPointerOutObservable=new K.cP,this.utilityLayerScene=new ke.Z(t.getEngine(),{virtual:!0}),this.utilityLayerScene.useRightHandedSystem=t.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,this.utilityLayerScene.postProcessesEnabled=!1,this.utilityLayerScene.detachControl(),e&&(this._originalPointerObserver=t.onPrePointerObservable.add(function(i){if(n.utilityLayerScene.activeCamera&&n.pickingEnabled&&(n.processAllEvents||i.type===vt.Zp.POINTERMOVE||i.type===vt.Zp.POINTERUP||i.type===vt.Zp.POINTERDOWN||i.type===vt.Zp.POINTERDOUBLETAP)){n.utilityLayerScene.pointerX=t.pointerX,n.utilityLayerScene.pointerY=t.pointerY;var o=i.event;if(t.isPointerCaptured(o.pointerId))n._pointerCaptures[o.pointerId]=!1;else{var a=function(u){var d=null;if(i.nearInteractionPickingInfo)d=i.nearInteractionPickingInfo.pickedMesh.getScene()==u?i.nearInteractionPickingInfo:new ri.G;else if(u!==n.utilityLayerScene&&i.originalPickingInfo)d=i.originalPickingInfo;else{var h=null;n._renderCamera&&(h=u._activeCamera,u._activeCamera=n._renderCamera,i.ray=null),d=i.ray?u.pickWithRay(i.ray):u.pick(t.pointerX,t.pointerY),h&&(u._activeCamera=h)}return d},s=a(n.utilityLayerScene);if(!i.ray&&s&&(i.ray=s.ray),n.utilityLayerScene.onPrePointerObservable.notifyObservers(i),n.onlyCheckPointerDownEvents&&i.type!=vt.Zp.POINTERDOWN)return i.skipOnPointerObservable||n.utilityLayerScene.onPointerObservable.notifyObservers(new vt.mx(i.type,i.event,s),i.type),void(i.type===vt.Zp.POINTERUP&&n._pointerCaptures[o.pointerId]&&(n._pointerCaptures[o.pointerId]=!1));if(n.utilityLayerScene.autoClearDepthAndStencil||n.pickUtilitySceneFirst)s&&s.hit&&(i.skipOnPointerObservable||n.utilityLayerScene.onPointerObservable.notifyObservers(new vt.mx(i.type,i.event,s),i.type),i.skipOnPointerObservable=!0);else{var l=a(t),c=i.event;l&&s&&(s.distance===0&&l.pickedMesh?n.mainSceneTrackerPredicate&&n.mainSceneTrackerPredicate(l.pickedMesh)?(n._notifyObservers(i,l,c),i.skipOnPointerObservable=!0):i.type===vt.Zp.POINTERDOWN?n._pointerCaptures[c.pointerId]=!0:i.type!==vt.Zp.POINTERMOVE&&i.type!==vt.Zp.POINTERUP||(n._lastPointerEvents[c.pointerId]&&(n.onPointerOutObservable.notifyObservers(c.pointerId),delete n._lastPointerEvents[c.pointerId]),n._notifyObservers(i,l,c)):!n._pointerCaptures[c.pointerId]&&(s.distance<l.distance||l.distance===0)?(n._notifyObservers(i,s,c),i.skipOnPointerObservable||(i.skipOnPointerObservable=s.distance>0)):!n._pointerCaptures[c.pointerId]&&s.distance>=l.distance&&(n.mainSceneTrackerPredicate&&n.mainSceneTrackerPredicate(l.pickedMesh)?(n._notifyObservers(i,l,c),i.skipOnPointerObservable=!0):(i.type!==vt.Zp.POINTERMOVE&&i.type!==vt.Zp.POINTERUP||n._lastPointerEvents[c.pointerId]&&(n.onPointerOutObservable.notifyObservers(c.pointerId),delete n._lastPointerEvents[c.pointerId]),n._notifyObservers(i,s,c))),i.type===vt.Zp.POINTERUP&&n._pointerCaptures[c.pointerId]&&(n._pointerCaptures[c.pointerId]=!1))}}}}),this._originalPointerObserver&&t.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterRenderCameraObservable.add(function(i){n.shouldRender&&i==n.getRenderCamera()&&n.render()}),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add(function(){n.dispose()}),this._updateCamera()}return r.prototype.getRenderCamera=function(t){if(this._renderCamera)return this._renderCamera;var e;return e=this.originalScene.activeCameras&&this.originalScene.activeCameras.length>1?this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.originalScene.activeCamera,t&&e&&e.isRigCamera?e.rigParent:e},r.prototype.setRenderCamera=function(t){this._renderCamera=t},r.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new na("shared gizmo light",new _.Pq(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=z.v9.Gray()),this._sharedGizmoLight},Object.defineProperty(r,"DefaultUtilityLayer",{get:function(){return r._DefaultUtilityLayer==null?r._CreateDefaultUtilityLayerFromScene(Ve.q.LastCreatedScene):r._DefaultUtilityLayer},enumerable:!1,configurable:!0}),r._CreateDefaultUtilityLayerFromScene=function(t){return r._DefaultUtilityLayer=new r(t),r._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){r._DefaultUtilityLayer=null}),r._DefaultUtilityLayer},Object.defineProperty(r,"DefaultKeepDepthUtilityLayer",{get:function(){return r._DefaultKeepDepthUtilityLayer==null&&(r._DefaultKeepDepthUtilityLayer=new r(Ve.q.LastCreatedScene),r._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,r._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){r._DefaultKeepDepthUtilityLayer=null})),r._DefaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),r.prototype._notifyObservers=function(t,e,n){t.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new vt.mx(t.type,t.event,e),t.type),this._lastPointerEvents[n.pointerId]=!0)},r.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var t=this.utilityLayerScene.activeCamera.getScene(),e=this.utilityLayerScene.activeCamera;e._scene=this.utilityLayerScene,e.leftCamera&&(e.leftCamera._scene=this.utilityLayerScene),e.rightCamera&&(e.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),e._scene=t,e.leftCamera&&(e.leftCamera._scene=t),e.rightCamera&&(e.rightCamera._scene=t)}},r.prototype.dispose=function(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()},r.prototype._updateCamera=function(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()},r._DefaultUtilityLayer=null,r._DefaultKeepDepthUtilityLayer=null,r}();(function(r){r[r.Origin=0]="Origin",r[r.Pivot=1]="Pivot"})(xu||(xu={})),function(r){r[r.World=0]="World",r[r.Local=1]="Local"}(Pu||(Pu={}));var Hs,Jn=function(){function r(t){t===void 0&&(t=Fn.DefaultUtilityLayer);var e=this;this.gizmoLayer=t,this._attachedMesh=null,this._attachedNode=null,this._customRotationQuaternion=null,this._scaleRatio=1,this._isHovered=!1,this._customMeshSet=!1,this._updateGizmoRotationToMatchAttachedMesh=!0,this._updateGizmoPositionToMatchAttachedMesh=!0,this._anchorPoint=0,this._updateScale=!0,this._coordinatesMode=1,this._interactionsEnabled=!0,this._rightHandtoLeftHandMatrix=_.uq.RotationY(Math.PI),this._rootMesh=new xe("gizmoRootNode",t.utilityLayerScene),this._rootMesh.rotationQuaternion=_.PT.Identity(),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function(){e._update()})}return Object.defineProperty(r.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(t){this._scaleRatio=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isHovered",{get:function(){return this._isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(t){this._attachedMesh=t,t&&(this._attachedNode=t),this._rootMesh.setEnabled(!!t),this._attachedNodeChanged(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"attachedNode",{get:function(){return this._attachedNode},set:function(t){this._attachedNode=t,this._attachedMesh=null,this._rootMesh.setEnabled(!!t),this._attachedNodeChanged(t)},enumerable:!1,configurable:!0}),r.prototype.setCustomMesh=function(t){if(t.getScene()!=this.gizmoLayer.utilityLayerScene)throw"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";this._rootMesh.getChildMeshes().forEach(function(e){e.dispose()}),t.parent=this._rootMesh,this._customMeshSet=!0},Object.defineProperty(r.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(t){this._additionalTransformNode=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(t){this._updateGizmoRotationToMatchAttachedMesh=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"updateGizmoPositionToMatchAttachedMesh",{get:function(){return this._updateGizmoPositionToMatchAttachedMesh},set:function(t){this._updateGizmoPositionToMatchAttachedMesh=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(t){this._anchorPoint=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(t){this._coordinatesMode=t;var e=t==1;this.updateGizmoRotationToMatchAttachedMesh=e,this.updateGizmoPositionToMatchAttachedMesh=!0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"updateScale",{get:function(){return this._updateScale},set:function(t){this._updateScale=t},enumerable:!1,configurable:!0}),r.prototype._attachedNodeChanged=function(t){},Object.defineProperty(r.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(t){this._customRotationQuaternion=t},enumerable:!1,configurable:!0}),r.prototype._update=function(){if(this.attachedNode){var t=this.attachedNode;if(this.attachedMesh&&(t=this.attachedMesh||this.attachedNode),this.updateGizmoPositionToMatchAttachedMesh)if(this.anchorPoint==1&&t.getAbsolutePivotPoint){var e=t.getAbsolutePivotPoint();this._rootMesh.position.copyFrom(e)}else{var n=t.getWorldMatrix().getRow(3);e=n?n.toVector3():new _.Pq(0,0,0),this._rootMesh.position.copyFrom(e)}if(this.updateGizmoRotationToMatchAttachedMesh){var i=t._isMesh||t.getClassName()==="AbstractMesh"||t.getClassName()==="TransformNode"||t.getClassName()==="InstancedMesh"?t:void 0;t.getWorldMatrix().decompose(void 0,this._rootMesh.rotationQuaternion,void 0,r.PreserveScaling?i:void 0),this._rootMesh.rotationQuaternion.normalize()}else this._customRotationQuaternion?this._rootMesh.rotationQuaternion.copyFrom(this._customRotationQuaternion):this._rootMesh.rotationQuaternion.set(0,0,0,1);if(this.updateScale){var o=this.gizmoLayer.utilityLayerScene.activeCamera,a=o.globalPosition;this._rootMesh.position.subtractToRef(a,_.AA.Vector3[0]);var s=this.scaleRatio;if(o.mode==Pt.ORTHOGRAPHIC_CAMERA)o.orthoTop&&o.orthoBottom&&(s*=o.orthoTop-o.orthoBottom);else{var l=o.getScene().useRightHandedSystem?_.Pq.RightHandedForwardReadOnly:_.Pq.LeftHandedForwardReadOnly,c=o.getDirection(l);s*=_.Pq.Dot(_.AA.Vector3[0],c)}this._rootMesh.scaling.setAll(s),t._getWorldMatrixDeterminant()<0&&!r.PreserveScaling&&(this._rootMesh.scaling.y*=-1)}else this._rootMesh.scaling.setAll(this.scaleRatio)}this.additionalTransformNode&&(this._rootMesh.computeWorldMatrix(!0),this._rootMesh.getWorldMatrix().multiplyToRef(this.additionalTransformNode.getWorldMatrix(),_.AA.Matrix[0]),_.AA.Matrix[0].decompose(this._rootMesh.scaling,this._rootMesh.rotationQuaternion,this._rootMesh.position))},r.prototype._handlePivotMatrixInverse=function(t,e,n){if(t.isUsingPivotMatrix()&&!t.isUsingPostMultiplyPivotMatrix())return t.getPivotMatrix().invertToRef(_.AA.Matrix[5]),void _.AA.Matrix[5].multiplyToRef(e,n);n.copyFrom(e)},r.prototype._matrixChanged=function(){if(this._attachedNode)if(this._attachedNode._isCamera){var t=this._attachedNode,e=void 0,n=void 0;if(t.parent){var i=_.AA.Matrix[1];t.parent._worldMatrix.invertToRef(i),this._attachedNode._worldMatrix.multiplyToRef(i,_.AA.Matrix[0]),e=_.AA.Matrix[0]}else e=this._attachedNode._worldMatrix;if(t.getScene().useRightHandedSystem?(this._rightHandtoLeftHandMatrix.multiplyToRef(e,_.AA.Matrix[1]),n=_.AA.Matrix[1]):n=e,n.decompose(_.AA.Vector3[1],_.AA.Quaternion[0],_.AA.Vector3[0]),this._attachedNode.getClassName()==="FreeCamera"||this._attachedNode.getClassName()==="FlyCamera"||this._attachedNode.getClassName()==="ArcFollowCamera"||this._attachedNode.getClassName()==="TargetCamera"||this._attachedNode.getClassName()==="TouchCamera"||this._attachedNode.getClassName()==="UniversalCamera"){var o=this._attachedNode;o.rotation=_.AA.Quaternion[0].toEulerAngles(),o.rotationQuaternion&&(o.rotationQuaternion.copyFrom(_.AA.Quaternion[0]),o.rotationQuaternion.normalize())}t.position.copyFrom(_.AA.Vector3[0])}else if(this._attachedNode._isMesh||this._attachedNode.getClassName()==="AbstractMesh"||this._attachedNode.getClassName()==="TransformNode"||this._attachedNode.getClassName()==="InstancedMesh"){var a=this._attachedNode;if(a.parent){i=_.AA.Matrix[0];var s=_.AA.Matrix[1];a.parent.getWorldMatrix().invertToRef(i),this._attachedNode.getWorldMatrix().multiplyToRef(i,s);var l=_.AA.Matrix[4];if(this._handlePivotMatrixInverse(a,s,l),l.decompose(_.AA.Vector3[0],_.AA.Quaternion[0],a.position,r.PreserveScaling?a:void 0,r.UseAbsoluteScaling),_.AA.Quaternion[0].normalize(),a.isUsingPivotMatrix()){var c=_.AA.Quaternion[1];_.PT.RotationYawPitchRollToRef(a.rotation.y,a.rotation.x,a.rotation.z,c);var u=_.AA.Matrix[2];_.uq.ScalingToRef(a.scaling.x,a.scaling.y,a.scaling.z,u);var d=_.AA.Matrix[2];c.toRotationMatrix(d);var h=a.getPivotMatrix(),p=_.AA.Matrix[3];h.invertToRef(p),h.multiplyToRef(u,_.AA.Matrix[4]),_.AA.Matrix[4].multiplyToRef(d,_.AA.Matrix[5]),_.AA.Matrix[5].multiplyToRef(p,_.AA.Matrix[6]),_.AA.Matrix[6].getTranslationToRef(_.AA.Vector3[1]),a.position.subtractInPlace(_.AA.Vector3[1])}}else l=_.AA.Matrix[4],this._handlePivotMatrixInverse(a,this._attachedNode._worldMatrix,l),l.decompose(_.AA.Vector3[0],_.AA.Quaternion[0],a.position,r.PreserveScaling?a:void 0,r.UseAbsoluteScaling);_.AA.Vector3[0].scaleInPlace(1/a.scalingDeterminant),a.scaling.copyFrom(_.AA.Vector3[0]),a.billboardMode||(a.rotationQuaternion?(a.rotationQuaternion.copyFrom(_.AA.Quaternion[0]),a.rotationQuaternion.normalize()):a.rotation=_.AA.Quaternion[0].toEulerAngles())}else if(this._attachedNode.getClassName()==="Bone"){var m=this._attachedNode,v=m.getParent();if(v){var b=_.AA.Matrix[0],E=_.AA.Matrix[1];v.getFinalMatrix().invertToRef(b),m.getFinalMatrix().multiplyToRef(b,E),m.getLocalMatrix().copyFrom(E)}else m.getLocalMatrix().copyFrom(m.getFinalMatrix());m.markAsDirty()}else{var C=this._attachedNode;if(C.getTypeID){var T=C.getTypeID();if(T===hi.LIGHTTYPEID_DIRECTIONALLIGHT||T===hi.LIGHTTYPEID_SPOTLIGHT||T===hi.LIGHTTYPEID_POINTLIGHT){var f=C.parent;if(f){b=_.AA.Matrix[0];var g=_.AA.Matrix[1];f.getWorldMatrix().invertToRef(b),C.getWorldMatrix().multiplyToRef(b,g),g.decompose(void 0,_.AA.Quaternion[0],_.AA.Vector3[0])}else this._attachedNode._worldMatrix.decompose(void 0,_.AA.Quaternion[0],_.AA.Vector3[0]);C.position=new _.Pq(_.AA.Vector3[0].x,_.AA.Vector3[0].y,_.AA.Vector3[0].z),C.direction&&(C.direction=new _.Pq(C.direction.x,C.direction.y,C.direction.z))}}}},r.prototype._setGizmoMeshMaterial=function(t,e){t&&t.forEach(function(n){n.material=e,n.color&&(n.color=e.diffuseColor)})},r.GizmoAxisPointerObserver=function(t,e){var n=!1,i=t.utilityLayerScene.onPointerObservable.add(function(o){var a,s;if(o.pickInfo){if(o.type===vt.Zp.POINTERMOVE){if(n)return;e.forEach(function(l){var c,u;if(l.colliderMeshes&&l.gizmoMeshes){var d=((c=l.colliderMeshes)===null||c===void 0?void 0:c.indexOf((u=o?.pickInfo)===null||u===void 0?void 0:u.pickedMesh))!=-1,h=l.dragBehavior.enabled?d||l.active?l.hoverMaterial:l.material:l.disableMaterial;l.gizmoMeshes.forEach(function(p){p.material=h,p.color&&(p.color=h.diffuseColor)})}})}o.type===vt.Zp.POINTERDOWN&&e.has((a=o.pickInfo.pickedMesh)===null||a===void 0?void 0:a.parent)&&(n=!0,e.get((s=o.pickInfo.pickedMesh)===null||s===void 0?void 0:s.parent).active=!0,e.forEach(function(l){var c,u,d=(((c=l.colliderMeshes)===null||c===void 0?void 0:c.indexOf((u=o?.pickInfo)===null||u===void 0?void 0:u.pickedMesh))!=-1||l.active)&&l.dragBehavior.enabled?l.hoverMaterial:l.disableMaterial;l.gizmoMeshes.forEach(function(h){h.material=d,h.color&&(h.color=d.diffuseColor)})})),o.type===vt.Zp.POINTERUP&&e.forEach(function(l){l.active=!1,n=!1,l.gizmoMeshes.forEach(function(c){c.material=l.dragBehavior.enabled?l.material:l.disableMaterial,c.color&&(c.color=l.material.diffuseColor)})})}});return i},r.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},r.PreserveScaling=!1,r.UseAbsoluteScaling=!0,r}(),Yr=function(r){function t(e,n,i,o,a,s,l){n===void 0&&(n=z.v9.Gray()),i===void 0&&(i=Fn.DefaultUtilityLayer),o===void 0&&(o=null),a===void 0&&(a=1),s===void 0&&(s=z.v9.Yellow()),l===void 0&&(l=z.v9.Gray());var c,u=this;(u=r.call(this,i)||this)._pointerObserver=null,u.snapDistance=0,u.onSnapObservable=new K.cP,u._isEnabled=!0,u._parent=null,u._dragging=!1,u._parent=o,u._coloredMaterial=new qt("",i.utilityLayerScene),u._coloredMaterial.diffuseColor=n,u._coloredMaterial.specularColor=n.subtract(new z.v9(.1,.1,.1)),u._hoverMaterial=new qt("",i.utilityLayerScene),u._hoverMaterial.diffuseColor=s,u._disableMaterial=new qt("",i.utilityLayerScene),u._disableMaterial.diffuseColor=l,u._disableMaterial.alpha=.4;var d=t._CreateArrow(i.utilityLayerScene,u._coloredMaterial,a),h=t._CreateArrow(i.utilityLayerScene,u._coloredMaterial,a+4,!0);u._gizmoMesh=new xe("",i.utilityLayerScene),u._gizmoMesh.addChild(d),u._gizmoMesh.addChild(h),u._gizmoMesh.lookAt(u._rootMesh.position.add(e)),u._gizmoMesh.scaling.scaleInPlace(1/3),u._gizmoMesh.parent=u._rootMesh;var p=0,m={snapDistance:0};u.dragBehavior=new Gr({dragAxis:e}),u.dragBehavior.moveAttached=!1,u.dragBehavior.updateDragPlane=!1,u._rootMesh.addBehavior(u.dragBehavior),u.dragBehavior.onDragObservable.add(function(E){if(u.attachedNode){var C=!1;if(u.snapDistance==0)u.attachedNode.getWorldMatrix().getTranslationToRef(_.AA.Vector3[2]),_.AA.Vector3[2].addInPlace(E.delta),u.dragBehavior.validateDrag(_.AA.Vector3[2])&&(u.attachedNode.position&&u.attachedNode.position.addInPlaceFromFloats(E.delta.x,E.delta.y,E.delta.z),u.attachedNode.getWorldMatrix().addTranslationFromFloats(E.delta.x,E.delta.y,E.delta.z),u.attachedNode.updateCache(),C=!0);else if(p+=E.dragDistance,Math.abs(p)>u.snapDistance){var T=Math.floor(Math.abs(p)/u.snapDistance);p%=u.snapDistance,E.delta.normalizeToRef(_.AA.Vector3[1]),_.AA.Vector3[1].scaleInPlace(u.snapDistance*T),u.attachedNode.getWorldMatrix().getTranslationToRef(_.AA.Vector3[2]),_.AA.Vector3[2].addInPlace(_.AA.Vector3[1]),u.dragBehavior.validateDrag(_.AA.Vector3[2])&&(u.attachedNode.getWorldMatrix().addTranslationFromFloats(_.AA.Vector3[1].x,_.AA.Vector3[1].y,_.AA.Vector3[1].z),u.attachedNode.updateCache(),m.snapDistance=u.snapDistance*T*Math.sign(p),u.onSnapObservable.notifyObservers(m),C=!0)}C&&u._matrixChanged()}}),u.dragBehavior.onDragStartObservable.add(function(){u._dragging=!0}),u.dragBehavior.onDragEndObservable.add(function(){u._dragging=!1});var v=i._getSharedGizmoLight();v.includedOnlyMeshes=v.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));var b={gizmoMeshes:d.getChildMeshes(),colliderMeshes:h.getChildMeshes(),material:u._coloredMaterial,hoverMaterial:u._hoverMaterial,disableMaterial:u._disableMaterial,active:!1,dragBehavior:u.dragBehavior};return(c=u._parent)===null||c===void 0||c.addToAxisCache(h,b),u._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(E){var C;if(!u._customMeshSet&&(u._isHovered=b.colliderMeshes.indexOf((C=E?.pickInfo)===null||C===void 0?void 0:C.pickedMesh)!=-1,!u._parent)){var T=u.dragBehavior.enabled?u._isHovered||u._dragging?u._hoverMaterial:u._coloredMaterial:u._disableMaterial;u._setGizmoMeshMaterial(b.gizmoMeshes,T)}}),u.dragBehavior.onEnabledObservable.add(function(E){u._setGizmoMeshMaterial(b.gizmoMeshes,E?b.material:b.disableMaterial)}),u}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),t._CreateArrow=function(e,n,i,o){i===void 0&&(i=1),o===void 0&&(o=!1);var a=new jt("arrow",e),s=_i("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(i-1)/4),tessellation:96},e),l=_i("cylinder",{diameterTop:.005*i,height:.275,diameterBottom:.005*i,tessellation:96},e);return s.parent=a,s.material=n,s.rotation.x=Math.PI/2,s.position.z+=.3,l.parent=a,l.material=n,l.position.z+=.1375,l.rotation.x=Math.PI/2,o&&(l.visibility=0,s.visibility=0),a},t._CreateArrowInstance=function(e,n){for(var i=new jt("arrow",e),o=0,a=n.getChildMeshes();o<a.length;o++){var s=a[o];s.createInstance(s.name).parent=i}return i},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(e){e&&e.dispose()}),r.prototype.dispose.call(this)},t}(Jn),ia=function(){function r(t,e,n,i,o,a,s){if(e===void 0&&(e=1),n===void 0&&(n=2),s===void 0&&(s=1),this._scaleLinesFactor=4,this._instanced=!1,this.scene=null,this._scaleLines=1,t=t||Ve.q.LastCreatedScene){if(!i){var l=new qt("xAxisMaterial",t);l.disableLighting=!0,l.emissiveColor=z.v9.Red().scale(.5),i=Yr._CreateArrow(t,l,s)}if(!o){var c=new qt("yAxisMaterial",t);c.disableLighting=!0,c.emissiveColor=z.v9.Green().scale(.5),o=Yr._CreateArrow(t,c,s)}if(!a){var u=new qt("zAxisMaterial",t);u.disableLighting=!0,u.emissiveColor=z.v9.Blue().scale(.5),a=Yr._CreateArrow(t,u,s)}this._xAxis=i,this._yAxis=o,this._zAxis=a,this.scaleLines=e,n!=null&&(r._SetRenderingGroupId(this._xAxis,n),r._SetRenderingGroupId(this._yAxis,n),r._SetRenderingGroupId(this._zAxis,n)),this.scene=t,this.update(new _.Pq,_.Pq.Right(),_.Pq.Up(),_.Pq.Forward())}}return Object.defineProperty(r.prototype,"scaleLines",{get:function(){return this._scaleLines},set:function(t){this._scaleLines=t,this._xAxis.scaling.setAll(this._scaleLines*this._scaleLinesFactor),this._yAxis.scaling.setAll(this._scaleLines*this._scaleLinesFactor),this._zAxis.scaling.setAll(this._scaleLines*this._scaleLinesFactor)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"xAxis",{get:function(){return this._xAxis},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"yAxis",{get:function(){return this._yAxis},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"zAxis",{get:function(){return this._zAxis},enumerable:!1,configurable:!0}),r.prototype.update=function(t,e,n,i){this._xAxis.position.copyFrom(t),this._xAxis.setDirection(e),this._yAxis.position.copyFrom(t),this._yAxis.setDirection(n),this._zAxis.position.copyFrom(t),this._zAxis.setDirection(i)},r.prototype.createInstance=function(){var t=Yr._CreateArrowInstance(this.scene,this._xAxis),e=Yr._CreateArrowInstance(this.scene,this._yAxis),n=Yr._CreateArrowInstance(this.scene,this._zAxis),i=new r(this.scene,this.scaleLines,null,t,e,n);return i._instanced=!0,i},r.prototype.dispose=function(){this._xAxis&&this._xAxis.dispose(!1,!this._instanced),this._yAxis&&this._yAxis.dispose(!1,!this._instanced),this._zAxis&&this._zAxis.dispose(!1,!this._instanced),this.scene=null},r._SetRenderingGroupId=function(t,e){t.getChildMeshes().forEach(function(n){n.renderingGroupId=e})},r}(),Au=function(r){function t(e,n,i,o){o===void 0&&(o=1);var a=r.call(this,e,o)||this;return a.pos=_.Pq.Zero(),a.xaxis=_.Pq.Zero(),a.yaxis=_.Pq.Zero(),a.zaxis=_.Pq.Zero(),a.mesh=i,a.bone=n,a}return(0,A.C6)(t,r),t.prototype.update=function(){if(this.mesh&&this.bone){var e=this.bone;e.getAbsolutePositionToRef(this.mesh,this.pos),e.getDirectionToRef(Qn._0.X,this.mesh,this.xaxis),e.getDirectionToRef(Qn._0.Y,this.mesh,this.yaxis),e.getDirectionToRef(Qn._0.Z,this.mesh,this.zaxis),r.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},t.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,r.prototype.dispose.call(this))},t}(ia);Object.defineProperty(ke.Z.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new Cu(this)),this._debugLayer},enumerable:!0,configurable:!0}),function(r){r[r.Properties=0]="Properties",r[r.Debug=1]="Debug",r[r.Statistics=2]="Statistics",r[r.Tools=3]="Tools",r[r.Settings=4]="Settings"}(Hs||(Hs={}));var Cu=function(){function r(t){var e=this;this.BJSINSPECTOR=this._getGlobalInspector(),this._scene=t||Ve.q.LastCreatedScene,this._scene&&this._scene.onDisposeObservable.add(function(){e._scene._debugLayer&&e._scene._debugLayer.hide()})}return Object.defineProperty(r.prototype,"onPropertyChangedObservable",{get:function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector?this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable:(this._onPropertyChangedObservable||(this._onPropertyChangedObservable=new K.cP),this._onPropertyChangedObservable)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onSelectionChangedObservable",{get:function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector?this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable:(this._onSelectionChangedObservable||(this._onSelectionChangedObservable=new K.cP),this._onSelectionChangedObservable)},enumerable:!1,configurable:!0}),r.prototype._createInspector=function(t){if(!this.isVisible()){if(this._onPropertyChangedObservable){for(var e=0,n=this._onPropertyChangedObservable.observers;e<n.length;e++){var i=n[e];this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(i)}this._onPropertyChangedObservable.clear(),this._onPropertyChangedObservable=void 0}if(this._onSelectionChangedObservable){for(var o=0,a=this._onSelectionChangedObservable.observers;o<a.length;o++)i=a[o],this.BJSINSPECTOR.Inspector.OnSelectionChangedObservable.add(i);this._onSelectionChangedObservable.clear(),this._onSelectionChangedObservable=void 0}var s=(0,A.Cl)((0,A.Cl)({},r.Config),t);this.BJSINSPECTOR=this.BJSINSPECTOR||this._getGlobalInspector(),this.BJSINSPECTOR.Inspector.Show(this._scene,s)}},r.prototype.select=function(t,e){this.BJSINSPECTOR&&(e&&(Object.prototype.toString.call(e)=="[object String]"?this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(e):this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(e)),this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(t))},r.prototype._getGlobalInspector=function(){return typeof INSPECTOR<"u"?INSPECTOR:typeof BABYLON<"u"&&BABYLON.Inspector!==void 0?BABYLON:void 0},r.prototype.isVisible=function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.IsVisible},r.prototype.hide=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.Hide()},r.prototype.setAsActiveScene=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector._SetNewScene(this._scene)},r.prototype.popupSceneExplorer=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.PopupSceneExplorer()},r.prototype.popupInspector=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.PopupInspector()},r.prototype.popupEmbed=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.PopupEmbed()},r.prototype.show=function(t){var e=this;return new Promise(function(n){if(e.BJSINSPECTOR===void 0){var i=t&&t.inspectorURL?t.inspectorURL:r.InspectorURL;ze.S0.LoadBabylonScript(i,function(){e._createInspector(t),n(e)})}else e._createInspector(t),n(e)})},r.InspectorURL="".concat(ze.S0._DefaultCdnUrl,"/v").concat(Be.$.Version,"/inspector/babylon.inspector.bundle.js"),r.Config={overlay:!1,showExplorer:!0,showInspector:!0,embedMode:!1,handleResize:!0,enablePopup:!0},r}();function Ys(r){var t,e=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],n=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],i=[],o=r.width||r.size||1,a=r.height||r.size||1,s=r.depth||r.size||1,l=r.wrap||!1,c=r.topBaseAt===void 0?1:r.topBaseAt,u=r.bottomBaseAt===void 0?0:r.bottomBaseAt,d=[2,0,3,1][c=(c+4)%4],h=[2,0,1,3][u=(u+4)%4],p=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(l){e=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],p=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];for(var m=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],v=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],b=[17,18,19,16],E=[22,23,20,21];d>0;)m.unshift(m.pop()),b.unshift(b.pop()),d--;for(;h>0;)v.unshift(v.pop()),E.unshift(E.pop()),h--;m=m.flat(),v=v.flat(),p=p.concat(m).concat(v),e.push(b[0],b[2],b[3],b[0],b[1],b[2]),e.push(E[0],E[2],E[3],E[0],E[1],E[2])}var C=[o/2,a/2,s/2];t=p.reduce(function(D,B,F){return D.concat(B*C[F%3])},[]);for(var T=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,f=r.faceUV||new Array(6),g=r.faceColors,S=[],y=0;y<6;y++)f[y]===void 0&&(f[y]=new _.IU(0,0,1,1)),g&&g[y]===void 0&&(g[y]=new z.ov(1,1,1,1));for(var x=0;x<6;x++)if(i.push(f[x].z,Xt.rX?1-f[x].w:f[x].w),i.push(f[x].x,Xt.rX?1-f[x].w:f[x].w),i.push(f[x].x,Xt.rX?1-f[x].y:f[x].y),i.push(f[x].z,Xt.rX?1-f[x].y:f[x].y),g)for(var R=0;R<4;R++)S.push(g[x].r,g[x].g,g[x].b,g[x].a);rt._ComputeSides(T,t,e,n,i,r.frontUVs,r.backUVs);var I=new rt;if(I.indices=e,I.positions=t,I.normals=n,I.uvs=i,g){var M=T===rt.DOUBLESIDE?S.concat(S):S;I.colors=M}return I}function ng(r){var t=r.width||r.size||1,e=r.height||r.size||1,n=r.depth||r.size||1,i=0|(r.widthSegments||r.segments||1),o=0|(r.heightSegments||r.segments||1),a=0|(r.depthSegments||r.segments||1),s=new _.uq,l=new _.uq,c=new _.uq,u=Wr({width:t,height:n,subdivisionsX:i,subdivisionsY:a});_.uq.TranslationToRef(0,-e/2,0,l),_.uq.RotationZToRef(Math.PI,s),s.multiplyToRef(l,c),u.transform(c);var d=Wr({width:t,height:n,subdivisionsX:i,subdivisionsY:a});_.uq.TranslationToRef(0,e/2,0,c),d.transform(c);var h=Wr({width:e,height:n,subdivisionsX:o,subdivisionsY:a});_.uq.TranslationToRef(-t/2,0,0,l),_.uq.RotationZToRef(Math.PI/2,s),s.multiplyToRef(l,c),h.transform(c);var p=Wr({width:e,height:n,subdivisionsX:o,subdivisionsY:a});_.uq.TranslationToRef(t/2,0,0,l),_.uq.RotationZToRef(-Math.PI/2,s),s.multiplyToRef(l,c),p.transform(c);var m=Wr({width:t,height:e,subdivisionsX:i,subdivisionsY:o});_.uq.TranslationToRef(0,0,-n/2,l),_.uq.RotationXToRef(-Math.PI/2,s),s.multiplyToRef(l,c),m.transform(c);var v=Wr({width:t,height:e,subdivisionsX:i,subdivisionsY:o});return _.uq.TranslationToRef(0,0,n/2,l),_.uq.RotationXToRef(Math.PI/2,s),s.multiplyToRef(l,c),v.transform(c),u.merge([d,p,h,m,v],!0),u}function Oi(r,t,e){t===void 0&&(t={}),e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ys(t).applyToMesh(n,t.updatable),n}var vE={CreateBox:Oi};function Xs(r){for(var t=0|(r.segments||32),e=r.diameterX||r.diameter||1,n=r.diameterY||r.diameter||1,i=r.diameterZ||r.diameter||1,o=r.arc&&(r.arc<=0||r.arc>1)?1:r.arc||1,a=r.slice&&r.slice<=0?1:r.slice||1,s=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,l=!!r.dedupTopBottomIndices,c=new _.Pq(e/2,n/2,i/2),u=2+t,d=2*u,h=[],p=[],m=[],v=[],b=0;b<=u;b++){for(var E=b/u,C=E*Math.PI*a,T=0;T<=d;T++){var f=T/d,g=f*Math.PI*2*o,S=_.uq.RotationZ(-C),y=_.uq.RotationY(g),x=_.Pq.TransformCoordinates(_.Pq.Up(),S),R=_.Pq.TransformCoordinates(x,y),I=R.multiply(c),M=R.divide(c).normalize();p.push(I.x,I.y,I.z),m.push(M.x,M.y,M.z),v.push(f,Xt.rX?1-E:E)}if(b>0)for(var D=p.length/3,B=D-2*(d+1);B+d+2<D;B++)l?(b>1&&(h.push(B),h.push(B+1),h.push(B+d+1)),(b<u||a<1)&&(h.push(B+d+1),h.push(B+1),h.push(B+d+2))):(h.push(B),h.push(B+1),h.push(B+d+1),h.push(B+d+1),h.push(B+1),h.push(B+d+2))}rt._ComputeSides(s,p,h,m,v,r.frontUVs,r.backUVs);var F=new rt;return F.indices=h,F.positions=p,F.normals=m,F.uvs=v,F}function li(r,t,e){t===void 0&&(t={}),e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Xs(t).applyToMesh(n,t.updatable),n}rt.CreateBox=Ys,xe.CreateBox=function(r,t,e,n,i){return e===void 0&&(e=null),Oi(r,{size:t,sideOrientation:i,updatable:n},e)};var yE={CreateSphere:li};rt.CreateSphere=Xs,xe.CreateSphere=function(r,t,e,n,i,o){return li(r,{segments:t,diameterX:e,diameterY:e,diameterZ:e,sideOrientation:o,updatable:i},n)};var In=function(){function r(t,e){this.type=t,this.jointData=e,e.nativeParams=e.nativeParams||{}}return Object.defineProperty(r.prototype,"physicsJoint",{get:function(){return this._physicsJoint},set:function(t){this._physicsJoint=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"physicsPlugin",{set:function(t){this._physicsPlugin=t},enumerable:!1,configurable:!0}),r.prototype.executeNativeFunction=function(t){t(this._physicsPlugin.world,this._physicsJoint)},r.DistanceJoint=0,r.HingeJoint=1,r.BallAndSocketJoint=2,r.WheelJoint=3,r.SliderJoint=4,r.PrismaticJoint=5,r.UniversalJoint=6,r.Hinge2Joint=r.WheelJoint,r.PointToPointJoint=8,r.SpringJoint=9,r.LockJoint=10,r}(),bE=function(r){function t(e){return r.call(this,In.DistanceJoint,e)||this}return(0,A.C6)(t,r),t.prototype.updateDistance=function(e,n){this._physicsPlugin.updateDistanceJoint(this,e,n)},t}(In),Ru=function(r){function t(e,n){return r.call(this,e,n)||this}return(0,A.C6)(t,r),t.prototype.setMotor=function(e,n){this._physicsPlugin.setMotor(this,e||0,n)},t.prototype.setLimit=function(e,n){this._physicsPlugin.setLimit(this,e,n)},t}(In),TE=function(r){function t(e){return r.call(this,In.HingeJoint,e)||this}return(0,A.C6)(t,r),t.prototype.setMotor=function(e,n){this._physicsPlugin.setMotor(this,e||0,n)},t.prototype.setLimit=function(e,n){this._physicsPlugin.setLimit(this,e,n)},t}(Ru),SE=function(r){function t(e){return r.call(this,In.Hinge2Joint,e)||this}return(0,A.C6)(t,r),t.prototype.setMotor=function(e,n,i){i===void 0&&(i=0),this._physicsPlugin.setMotor(this,e||0,n,i)},t.prototype.setLimit=function(e,n,i){i===void 0&&(i=0),this._physicsPlugin.setLimit(this,e,n,i)},t}(Ru);xe._PhysicsImpostorParser=function(r,t,e){return new Dt(t,e.physicsImpostor,{mass:e.physicsMass,friction:e.physicsFriction,restitution:e.physicsRestitution},r)};var Dt=function(){function r(t,e,n,i){n===void 0&&(n={mass:0});var o=this;this.object=t,this.type=e,this._options=n,this._scene=i,this._pluginData={},this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=_.Pq.Zero(),this._isDisposed=!1,this.soft=!1,this.segments=0,this._tmpQuat=new _.PT,this._tmpQuat2=new _.PT,this.beforeStep=function(){o._physicsEngine&&(o.object.translate(o._deltaPosition,-1),o._deltaRotationConjugated&&o.object.rotationQuaternion&&o.object.rotationQuaternion.multiplyToRef(o._deltaRotationConjugated,o.object.rotationQuaternion),o.object.computeWorldMatrix(!1),o.object.parent&&o.object.rotationQuaternion?(o.getParentsRotation(),o._tmpQuat.multiplyToRef(o.object.rotationQuaternion,o._tmpQuat)):o._tmpQuat.copyFrom(o.object.rotationQuaternion||new _.PT),o._options.disableBidirectionalTransformation||o.object.rotationQuaternion&&o._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(o,o.object.getAbsolutePosition(),o._tmpQuat),o._onBeforePhysicsStepCallbacks.forEach(function(a){a(o)}))},this.afterStep=function(){o._physicsEngine&&(o._onAfterPhysicsStepCallbacks.forEach(function(a){a(o)}),o._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(o),o.object.parent&&o.object.rotationQuaternion&&(o.getParentsRotation(),o._tmpQuat.conjugateInPlace(),o._tmpQuat.multiplyToRef(o.object.rotationQuaternion,o.object.rotationQuaternion)),o.object.setAbsolutePosition(o.object.position),o._deltaRotation?(o.object.rotationQuaternion&&o.object.rotationQuaternion.multiplyToRef(o._deltaRotation,o.object.rotationQuaternion),o._deltaPosition.applyRotationQuaternionToRef(o._deltaRotation,r._TmpVecs[0]),o.object.translate(r._TmpVecs[0],1)):o.object.translate(o._deltaPosition,1),o.object.computeWorldMatrix(!0))},this.onCollideEvent=null,this.onCollide=function(a){if((o._onPhysicsCollideCallbacks.length||o.onCollideEvent)&&o._physicsEngine){var s=o._physicsEngine.getImpostorWithPhysicsBody(a.body);s&&(o.onCollideEvent&&o.onCollideEvent(o,s),o._onPhysicsCollideCallbacks.filter(function(l){return l.otherImpostors.indexOf(s)!==-1}).forEach(function(l){l.callback(o,s,a.point,a.distance,a.impulse,a.normal)}))}},this.object?(this.object.parent&&n.mass!==0&&O.V.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."),!this._scene&&t.getScene&&(this._scene=t.getScene()),this._scene&&(this.type>100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=_.PT.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new _.PT),this._options.mass=n.mass===void 0?0:n.mass,this._options.friction=n.friction===void 0?.2:n.friction,this._options.restitution=n.restitution===void 0?.2:n.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=n.pressure===void 0?200:n.pressure,this._options.stiffness=n.stiffness===void 0?1:n.stiffness,this._options.velocityIterations=n.velocityIterations===void 0?20:n.velocityIterations,this._options.positionIterations=n.positionIterations===void 0?20:n.positionIterations,this._options.fixedPoints=n.fixedPoints===void 0?0:n.fixedPoints,this._options.margin=n.margin===void 0?0:n.margin,this._options.damping=n.damping===void 0?0:n.damping,this._options.path=n.path===void 0?null:n.path,this._options.shape=n.shape===void 0?null:n.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&O.V.Warn("You must affect impostors to children before affecting impostor to parent.")):O.V.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):O.V.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(r.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(t){this.setMass(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(t){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(t){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pressure",{get:function(){if(!this._physicsEngine)return 0;var t=this._physicsEngine.getPhysicsPlugin();return t.setBodyPressure?t.getBodyPressure(this):0},set:function(t){if(this._physicsEngine){var e=this._physicsEngine.getPhysicsPlugin();e.setBodyPressure&&e.setBodyPressure(this,t)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"stiffness",{get:function(){if(!this._physicsEngine)return 0;var t=this._physicsEngine.getPhysicsPlugin();return t.getBodyStiffness?t.getBodyStiffness(this):0},set:function(t){if(this._physicsEngine){var e=this._physicsEngine.getPhysicsPlugin();e.setBodyStiffness&&e.setBodyStiffness(this,t)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"velocityIterations",{get:function(){if(!this._physicsEngine)return 0;var t=this._physicsEngine.getPhysicsPlugin();return t.getBodyVelocityIterations?t.getBodyVelocityIterations(this):0},set:function(t){if(this._physicsEngine){var e=this._physicsEngine.getPhysicsPlugin();e.setBodyVelocityIterations&&e.setBodyVelocityIterations(this,t)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"positionIterations",{get:function(){if(!this._physicsEngine)return 0;var t=this._physicsEngine.getPhysicsPlugin();return t.getBodyPositionIterations?t.getBodyPositionIterations(this):0},set:function(t){if(this._physicsEngine){var e=this._physicsEngine.getPhysicsPlugin();e.setBodyPositionIterations&&e.setBodyPositionIterations(this,t)}},enumerable:!1,configurable:!0}),r.prototype._init=function(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this._isDisposed||this.parent&&!this._options.ignoreParent||this._physicsEngine.addImpostor(this))},r.prototype._getPhysicsParent=function(){return this.object.parent instanceof cn?this.object.parent.physicsImpostor:null},r.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&(!this._parent||!!this._options.ignoreParent)},r.prototype.setScalingUpdated=function(){this.forceUpdate()},r.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(r.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(t){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=t,this.resetUpdateFlags()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(t){this._parent=t},enumerable:!1,configurable:!0}),r.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},r.prototype.getObjectExtents=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion,e=this.object.scaling.clone();this.object.rotationQuaternion=r.IDENTITY_QUATERNION;var n=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);n&&n.decompose(e,void 0,void 0);var i=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(e);return i.x=Math.abs(i.x),i.y=Math.abs(i.y),i.z=Math.abs(i.z),this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),i}return r.DEFAULT_OBJECT_SIZE},r.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},r.prototype.getParam=function(t){return this._options[t]},r.prototype.setParam=function(t,e){this._options[t]=e,this._bodyUpdateRequired=!0},r.prototype.setMass=function(t){this.getParam("mass")!==t&&this.setParam("mass",t),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,t)},r.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):_.Pq.Zero()},r.prototype.setLinearVelocity=function(t){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,t)},r.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):_.Pq.Zero()},r.prototype.setAngularVelocity=function(t){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,t)},r.prototype.executeNativeFunction=function(t){this._physicsEngine&&t(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},r.prototype.registerBeforePhysicsStep=function(t){this._onBeforePhysicsStepCallbacks.push(t)},r.prototype.unregisterBeforePhysicsStep=function(t){var e=this._onBeforePhysicsStepCallbacks.indexOf(t);e>-1?this._onBeforePhysicsStepCallbacks.splice(e,1):O.V.Warn("Function to remove was not found")},r.prototype.registerAfterPhysicsStep=function(t){this._onAfterPhysicsStepCallbacks.push(t)},r.prototype.unregisterAfterPhysicsStep=function(t){var e=this._onAfterPhysicsStepCallbacks.indexOf(t);e>-1?this._onAfterPhysicsStepCallbacks.splice(e,1):O.V.Warn("Function to remove was not found")},r.prototype.registerOnPhysicsCollide=function(t,e){var n=t instanceof Array?t:[t];this._onPhysicsCollideCallbacks.push({callback:e,otherImpostors:n})},r.prototype.unregisterOnPhysicsCollide=function(t,e){var n=t instanceof Array?t:[t],i=-1;this._onPhysicsCollideCallbacks.some(function(o,a){if(o.callback===e&&o.otherImpostors.length===n.length){var s=o.otherImpostors.every(function(l){return n.indexOf(l)>-1});return s&&(i=a),s}return!1})?this._onPhysicsCollideCallbacks.splice(i,1):O.V.Warn("Function to remove was not found")},r.prototype.getParentsRotation=function(){var t=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);t;)t.rotationQuaternion?this._tmpQuat2.copyFrom(t.rotationQuaternion):_.PT.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,t.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),t=t.parent;return this._tmpQuat},r.prototype.applyForce=function(t,e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,t,e),this},r.prototype.applyImpulse=function(t,e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,t,e),this},r.prototype.createJoint=function(t,e,n){var i=new In(e,n);return this.addJoint(t,i),this},r.prototype.addJoint=function(t,e){return this._joints.push({otherImpostor:t,joint:e}),this._physicsEngine&&this._physicsEngine.addJoint(this,t,e),this},r.prototype.addAnchor=function(t,e,n,i,o){if(!this._physicsEngine)return this;var a=this._physicsEngine.getPhysicsPlugin();return a.appendAnchor?(this._physicsEngine&&a.appendAnchor(this,t,e,n,i,o),this):this},r.prototype.addHook=function(t,e,n,i){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendHook(this,t,e,n,i),this):this},r.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},r.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},r.prototype.clone=function(t){return t?new r(t,this.type,this._options,this._scene):null},r.prototype.dispose=function(){var t=this;this._physicsEngine&&(this._joints.forEach(function(e){t._physicsEngine&&t._physicsEngine.removeJoint(t,e.otherImpostor,e.joint)}),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},r.prototype.setDeltaPosition=function(t){this._deltaPosition.copyFrom(t)},r.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new _.PT),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},r.prototype.getBoxSizeToRef=function(t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,t),this},r.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},r.prototype.syncBoneWithImpostor=function(t,e,n,i,o){var a=r._TmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var l=r._TmpQuat;s.rotationQuaternion.multiplyToRef(o,l),t.setRotationQuaternion(l,1,e)}else t.setRotationQuaternion(s.rotationQuaternion,1,e);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,t.getDirectionToRef(a,e,a),i==null&&(i=n.length()),a.x*=i,a.y*=i,a.z*=i),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,e)):(e.setAbsolutePosition(s.getAbsolutePosition()),e.position.x-=a.x,e.position.y-=a.y,e.position.z-=a.z)},r.prototype.syncImpostorWithBone=function(t,e,n,i,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var l=r._TmpQuat;t.getRotationQuaternionToRef(1,e,l),l.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(1,e,s.rotationQuaternion);var c=r._TmpVecs[0],u=r._TmpVecs[1];a||((a=r._TmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,e,u),t.getAbsolutePositionToRef(e,c),i==null&&n&&(i=n.length()),i!=null&&(c.x+=u.x*i,c.y+=u.y*i,c.z+=u.z*i),s.setAbsolutePosition(c)},r.DEFAULT_OBJECT_SIZE=new _.Pq(1,1,1),r.IDENTITY_QUATERNION=_.PT.Identity(),r._TmpVecs=(0,st.mI)(3,_.Pq.Zero),r._TmpQuat=_.PT.Identity(),r.NoImpostor=0,r.SphereImpostor=1,r.BoxImpostor=2,r.PlaneImpostor=3,r.MeshImpostor=4,r.CapsuleImpostor=6,r.CylinderImpostor=7,r.ParticleImpostor=8,r.HeightmapImpostor=9,r.ConvexHullImpostor=10,r.CustomImpostor=100,r.RopeImpostor=101,r.ClothImpostor=102,r.SoftbodyImpostor=103,r}();function js(r){r===void 0&&(r={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var t,e,n=0|Math.max(r.subdivisions?r.subdivisions:2,1),i=0|Math.max(r.tessellation?r.tessellation:16,3),o=Math.max(r.height?r.height:1,0),a=Math.max(r.radius?r.radius:.25,0),s=0|Math.max(r.capSubdivisions?r.capSubdivisions:6,1),l=i,c=n,u=Math.max(r.radiusTop?r.radiusTop:a,0),d=Math.max(r.radiusBottom?r.radiusBottom:a,0),h=o-(u+d),p=2*Math.PI,m=Math.max(r.topCapSubdivisions?r.topCapSubdivisions:s,1),v=Math.max(r.bottomCapSubdivisions?r.bottomCapSubdivisions:s,1),b=Math.acos((d-u)/o),E=[],C=[],T=[],f=[],g=0,S=[],y=.5*h,x=.5*Math.PI,R=_.Pq.Zero(),I=_.Pq.Zero(),M=Math.cos(b),D=Math.sin(b),B=new _.I9(u*D,y+u*M).subtract(new _.I9(d*D,d*M-y)).length(),F=u*b+B+d*(x-b),X=0;for(e=0;e<=m;e++){var $=[],Q=x-b*(e/m);X+=u*b/m;var ie=Math.cos(Q),q=Math.sin(Q),ee=ie*u;for(t=0;t<=l;t++){var te=(ue=t/l)*p+0,ce=Math.sin(te),fe=Math.cos(te);I.x=ee*ce,I.y=y+q*u,I.z=ee*fe,C.push(I.x,I.y,I.z),R.set(ie*ce,q,ie*fe),T.push(R.x,R.y,R.z),f.push(ue,Xt.rX?X/F:1-X/F),$.push(g),g++}S.push($)}var de=o-u-d+M*u-M*d,Te=D*(d-u)/de;for(e=1;e<=c;e++){for($=[],X+=B/c,ee=D*(e*(d-u)/c+u),t=0;t<=l;t++)te=(ue=t/l)*p+0,ce=Math.sin(te),fe=Math.cos(te),I.x=ee*ce,I.y=y+M*u-e*de/c,I.z=ee*fe,C.push(I.x,I.y,I.z),R.set(ce,Te,fe).normalize(),T.push(R.x,R.y,R.z),f.push(ue,Xt.rX?X/F:1-X/F),$.push(g),g++;S.push($)}for(e=1;e<=v;e++){for($=[],Q=x-b-(Math.PI-b)*(e/v),X+=d*b/v,ie=Math.cos(Q),q=Math.sin(Q),ee=ie*d,t=0;t<=l;t++){var ue;te=(ue=t/l)*p+0,ce=Math.sin(te),fe=Math.cos(te),I.x=ee*ce,I.y=q*d-y,I.z=ee*fe,C.push(I.x,I.y,I.z),R.set(ie*ce,q,ie*fe),T.push(R.x,R.y,R.z),f.push(ue,Xt.rX?X/F:1-X/F),$.push(g),g++}S.push($)}for(t=0;t<l;t++)for(e=0;e<m+c+v;e++){var U=S[e][t],N=S[e+1][t],w=S[e+1][t+1],k=S[e][t+1];E.push(U),E.push(N),E.push(k),E.push(N),E.push(w),E.push(k)}if(E=E.reverse(),r.orientation&&!r.orientation.equals(_.Pq.Up())){var J=new _.uq;r.orientation.clone().scale(.5*Math.PI).cross(_.Pq.Up()).toQuaternion().toRotationMatrix(J);for(var le=_.Pq.Zero(),be=0;be<C.length;be+=3)le.set(C[be],C[be+1],C[be+2]),_.Pq.TransformCoordinatesToRef(le.clone(),J,le),C[be]=le.x,C[be+1]=le.y,C[be+2]=le.z}var ve=new rt;return ve.positions=C,ve.normals=T,ve.uvs=f,ve.indices=E,ve}function Fa(r,t,e){t===void 0&&(t={orientation:_.Pq.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6,updatable:!1}),e===void 0&&(e=null);var n=new xe(r,e);return js(t).applyToMesh(n,t.updatable),n}var EE={CreateCapsule:Fa};function Iu(r){var t=r.pathArray,e=r.closeArray||!1,n=r.closePath||!1,i=r.invertUV||!1,o=Math.floor(t[0].length/2),a=r.offset||o;a=a>o?o:Math.floor(a);var s,l,c,u,d=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,h=r.uvs,p=r.colors,m=[],v=[],b=[],E=[],C=[],T=[],f=[],g=[],S=[],y=[];if(t.length<2){var x=[],R=[];for(c=0;c<t[0].length-a;c++)x.push(t[0][c]),R.push(t[0][c+a]);t=[x,R]}var I,M,D,B,F,X=0,$=n?1:0,Q=e?1:0;for(s=t[0].length,l=0;l<t.length+Q;l++){for(f[l]=0,C[l]=[0],s=s<(M=(I=l===t.length?t[0]:t[l]).length)?s:M,u=0;u<M;)m.push(I[u].x,I[u].y,I[u].z),u>0&&(D=I[u].subtract(I[u-1]).length()+f[l],C[l].push(D),f[l]=D),u++;n&&(u--,m.push(I[0].x,I[0].y,I[0].z),D=I[u].subtract(I[0]).length()+f[l],C[l].push(D),f[l]=D),S[l]=M+$,y[l]=X,X+=M+$}var ie,q,ee=null,te=null;for(c=0;c<s+$;c++)for(g[c]=0,T[c]=[0],l=0;l<t.length-1+Q;l++)B=t[l],F=l===t.length-1?t[0]:t[l+1],c===s?(ee=B[0],te=F[0]):(ee=B[c],te=F[c]),D=te.subtract(ee).length()+g[c],T[c].push(D),g[c]=D;if(h)for(l=0;l<h.length;l++)E.push(h[l].x,Xt.rX?1-h[l].y:h[l].y);else for(l=0;l<t.length+Q;l++)for(c=0;c<s+$;c++)ie=f[l]!=0?C[l][c]/f[l]:0,q=g[c]!=0?T[c][l]/g[c]:0,i?E.push(q,ie):E.push(ie,Xt.rX?1-q:q);for(var ce=0,fe=S[l=0]-1,de=S[l+1]-1,Te=fe<de?fe:de,ue=y[1]-y[0],U=S.length-1;ce<=Te&&l<U;)v.push(ce,ce+ue,ce+1),v.push(ce+ue+1,ce+1,ce+ue),(ce+=1)===Te&&(ue=y[1+ ++l]-y[l],fe=S[l]-1,de=S[l+1]-1,ce=y[l],Te=fe<de?fe+ce:de+ce);if(rt.ComputeNormals(m,v,b),n){var N=0,w=0;for(l=0;l<t.length;l++){N=3*y[l],w=l+1<t.length?3*(y[l+1]-1):b.length-3,b[N]=.5*(b[N]+b[w]),b[N+1]=.5*(b[N+1]+b[w+1]),b[N+2]=.5*(b[N+2]+b[w+2]);var k=Math.sqrt(b[N]*b[N]+b[N+1]*b[N+1]+b[N+2]*b[N+2]);b[N]/=k,b[N+1]/=k,b[N+2]/=k,b[w]=b[N],b[w+1]=b[N+1],b[w+2]=b[N+2]}}if(e)for(N=3*y[0],w=3*y[t.length],c=0;c<s+$;c++){b[N]=.5*(b[N]+b[w]),b[N+1]=.5*(b[N+1]+b[w+1]),b[N+2]=.5*(b[N+2]+b[w+2]);var J=Math.sqrt(b[N]*b[N]+b[N+1]*b[N+1]+b[N+2]*b[N+2]);b[N]/=J,b[N+1]/=J,b[N+2]/=J,b[w]=b[N],b[w+1]=b[N+1],b[w+2]=b[N+2],N+=3,w+=3}rt._ComputeSides(d,m,v,b,E,r.frontUVs,r.backUVs);var le=null;if(p){le=new Float32Array(4*p.length);for(var be=0;be<p.length;be++)le[4*be]=p[be].r,le[4*be+1]=p[be].g,le[4*be+2]=p[be].b,le[4*be+3]=p[be].a}var ve=new rt,ye=new Float32Array(m),Me=new Float32Array(b),we=new Float32Array(E);return ve.indices=v,ve.positions=ye,ve.normals=Me,ve.uvs=we,le&&ve.set(le,Y.R.ColorKind),n&&(ve._idx=y),ve}function oo(r,t,e){e===void 0&&(e=null);var n=t.pathArray,i=t.closeArray,o=t.closePath,a=xe._GetDefaultSideOrientation(t.sideOrientation),s=t.instance,l=t.updatable;if(s){var c=_.AA.Vector3[0].setAll(Number.MAX_VALUE),u=_.AA.Vector3[1].setAll(-Number.MAX_VALUE),d=s.getVerticesData(Y.R.PositionKind);if(function(I){for(var M=n[0].length,D=s,B=0,F=D._originalBuilderSideOrientation===xe.DOUBLESIDE?2:1,X=1;X<=F;++X)for(var $=0;$<n.length;++$){var Q=n[$],ie=Q.length;M=M<ie?M:ie;for(var q=0;q<M;++q){var ee=Q[q];I[B]=ee.x,I[B+1]=ee.y,I[B+2]=ee.z,c.minimizeInPlaceFromFloats(ee.x,ee.y,ee.z),u.maximizeInPlaceFromFloats(ee.x,ee.y,ee.z),B+=3}D._creationDataStorage&&D._creationDataStorage.closePath&&(ee=Q[0],I[B]=ee.x,I[B+1]=ee.y,I[B+2]=ee.z,B+=3)}}(d),s.hasBoundingInfo?s.getBoundingInfo().reConstruct(c,u,s._worldMatrix):s.buildBoundingInfo(c,u,s._worldMatrix),s.updateVerticesData(Y.R.PositionKind,d,!1,!1),t.colors){for(var h=s.getVerticesData(Y.R.ColorKind),p=0,m=0;p<t.colors.length;p++,m+=4){var v=t.colors[p];h[m]=v.r,h[m+1]=v.g,h[m+2]=v.b,h[m+3]=v.a}s.updateVerticesData(Y.R.ColorKind,h,!1,!1)}if(t.uvs){for(var b=s.getVerticesData(Y.R.UVKind),E=0;E<t.uvs.length;E++)b[2*E]=t.uvs[E].x,b[2*E+1]=Xt.rX?1-t.uvs[E].y:t.uvs[E].y;s.updateVerticesData(Y.R.UVKind,b,!1,!1)}if(!s.areNormalsFrozen||s.isFacetDataEnabled){var C=s.getIndices(),T=s.getVerticesData(Y.R.NormalKind),f=s.isFacetDataEnabled?s.getFacetDataParameters():null;if(rt.ComputeNormals(d,C,T,f),s._creationDataStorage&&s._creationDataStorage.closePath)for(var g=0,S=0,y=0;y<n.length;y++)g=3*s._creationDataStorage.idx[y],S=y+1<n.length?3*(s._creationDataStorage.idx[y+1]-1):T.length-3,T[g]=.5*(T[g]+T[S]),T[g+1]=.5*(T[g+1]+T[S+1]),T[g+2]=.5*(T[g+2]+T[S+2]),T[S]=T[g],T[S+1]=T[g+1],T[S+2]=T[g+2];s.areNormalsFrozen||s.updateVerticesData(Y.R.NormalKind,T,!1,!1)}return s}var x=new xe(r,e);x._originalBuilderSideOrientation=a,x._creationDataStorage=new Cc;var R=Iu(t);return o&&(x._creationDataStorage.idx=R._idx),x._creationDataStorage.closePath=o,x._creationDataStorage.closeArray=i,R.applyToMesh(x,l),x}xe.CreateCapsule=function(r,t,e){return Fa(r,t,e)},rt.CreateCapsule=js;var xE={CreateRibbon:oo};function qs(r){var t=[],e=[],n=[],i=[],o=r.radius||.5,a=r.tessellation||64,s=r.arc&&(r.arc<=0||r.arc>1)?1:r.arc||1,l=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE;t.push(0,0,0),i.push(.5,.5);for(var c=2*Math.PI*s,u=s===1?c/a:c/(a-1),d=0,h=0;h<a;h++){var p=Math.cos(d),m=Math.sin(d),v=(p+1)/2,b=(1-m)/2;t.push(o*p,o*m,0),i.push(v,Xt.rX?1-b:b),d+=u}s===1&&(t.push(t[3],t[4],t[5]),i.push(i[2],Xt.rX?1-i[3]:i[3]));for(var E=t.length/3,C=1;C<E-1;C++)e.push(C+1,0,C);rt.ComputeNormals(t,e,n),rt._ComputeSides(l,t,e,n,i,r.frontUVs,r.backUVs);var T=new rt;return T.indices=e,T.positions=t,T.normals=n,T.uvs=i,T}function ra(r,t,e){t===void 0&&(t={}),e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,qs(t).applyToMesh(n,t.updatable),n}rt.CreateRibbon=Iu,xe.CreateRibbon=function(r,t,e,n,i,o,a,s,l){return e===void 0&&(e=!1),a===void 0&&(a=!1),oo(r,{pathArray:t,closeArray:e,closePath:n,offset:i,updatable:a,sideOrientation:s,instance:l},o)};var PE={CreateDisc:ra};function oa(r){var t=r.pattern||xe.NO_FLIP,e=r.tileWidth||r.tileSize||1,n=r.tileHeight||r.tileSize||1,i=r.alignHorizontal||0,o=r.alignVertical||0,a=r.width||r.size||1,s=Math.floor(a/e),l=a-s*e,c=r.height||r.size||1,u=Math.floor(c/n),d=c-u*n,h=e*s/2,p=n*u/2,m=0,v=0,b=0,E=0,C=0,T=0;if(l>0||d>0){switch(b=-h,E=-p,C=h,T=p,i){case xe.CENTER:b-=l/=2,C+=l;break;case xe.LEFT:C+=l,m=-l/2;break;case xe.RIGHT:b-=l,m=l/2}switch(o){case xe.CENTER:E-=d/=2,T+=d;break;case xe.BOTTOM:T+=d,v=-d/2;break;case xe.TOP:E-=d,v=d/2}}var f=[],g=[],S=[];S[0]=[0,0,1,0,1,1,0,1],S[1]=[0,0,1,0,1,1,0,1],t!==xe.ROTATE_TILE&&t!==xe.ROTATE_ROW||(S[1]=[1,1,0,1,0,0,1,0]),t!==xe.FLIP_TILE&&t!==xe.FLIP_ROW||(S[1]=[1,0,0,0,0,1,1,1]),t!==xe.FLIP_N_ROTATE_TILE&&t!==xe.FLIP_N_ROTATE_ROW||(S[1]=[0,1,1,1,1,0,0,0]);for(var y=[],x=[],R=[],I=0,M=0;M<u;M++)for(var D=0;D<s;D++)f.push(D*e-h+m,M*n-p+v,0),f.push((D+1)*e-h+m,M*n-p+v,0),f.push((D+1)*e-h+m,(M+1)*n-p+v,0),f.push(D*e-h+m,(M+1)*n-p+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),y=t===xe.FLIP_TILE||t===xe.ROTATE_TILE||t===xe.FLIP_N_ROTATE_TILE?y.concat(S[(D%2+M%2)%2]):t===xe.FLIP_ROW||t===xe.ROTATE_ROW||t===xe.FLIP_N_ROTATE_ROW?y.concat(S[M%2]):y.concat(S[0]),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),I+=4;if(l>0||d>0){var B=d>0&&(o===xe.CENTER||o===xe.TOP),F=d>0&&(o===xe.CENTER||o===xe.BOTTOM),X=l>0&&(i===xe.CENTER||i===xe.RIGHT),$=l>0&&(i===xe.CENTER||i===xe.LEFT),Q=[],ie=void 0,q=void 0,ee=void 0,te=void 0;if(B&&X&&(f.push(b+m,E+v,0),f.push(-h+m,E+v,0),f.push(-h+m,E+d+v,0),f.push(b+m,E+d+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,Q=[ie=1-l/e,q=1-d/n,ee=1,q,ee,te=1,ie,te],t===xe.ROTATE_ROW&&(Q=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),t===xe.FLIP_ROW&&(Q=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),t===xe.FLIP_N_ROTATE_ROW&&(Q=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),y=y.concat(Q),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),B&&$&&(f.push(h+m,E+v,0),f.push(C+m,E+v,0),f.push(C+m,E+d+v,0),f.push(h+m,E+d+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,Q=[ie=0,q=1-d/n,ee=l/e,q,ee,te=1,ie,te],(t===xe.ROTATE_ROW||t===xe.ROTATE_TILE&&s%2==0)&&(Q=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),(t===xe.FLIP_ROW||t===xe.FLIP_TILE&&s%2==0)&&(Q=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),(t===xe.FLIP_N_ROTATE_ROW||t===xe.FLIP_N_ROTATE_TILE&&s%2==0)&&(Q=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),y=y.concat(Q),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),F&&X&&(f.push(b+m,p+v,0),f.push(-h+m,p+v,0),f.push(-h+m,T+v,0),f.push(b+m,T+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,Q=[ie=1-l/e,q=0,ee=1,q,ee,te=d/n,ie,te],(t===xe.ROTATE_ROW&&u%2==1||t===xe.ROTATE_TILE&&u%1==0)&&(Q=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),(t===xe.FLIP_ROW&&u%2==1||t===xe.FLIP_TILE&&u%2==0)&&(Q=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),(t===xe.FLIP_N_ROTATE_ROW&&u%2==1||t===xe.FLIP_N_ROTATE_TILE&&u%2==0)&&(Q=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),y=y.concat(Q),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),F&&$&&(f.push(h+m,p+v,0),f.push(C+m,p+v,0),f.push(C+m,T+v,0),f.push(h+m,T+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,Q=[ie=0,q=0,ee=l/e,q,ee,te=d/n,ie,te],(t===xe.ROTATE_ROW&&u%2==1||t===xe.ROTATE_TILE&&(u+s)%2==1)&&(Q=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),(t===xe.FLIP_ROW&&u%2==1||t===xe.FLIP_TILE&&(u+s)%2==1)&&(Q=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),(t===xe.FLIP_N_ROTATE_ROW&&u%2==1||t===xe.FLIP_N_ROTATE_TILE&&(u+s)%2==1)&&(Q=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),y=y.concat(Q),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),B){var ce=[];for(ie=0,q=1-d/n,ee=1,te=1,ce[0]=[ie,q,ee,q,ee,te,ie,te],ce[1]=[ie,q,ee,q,ee,te,ie,te],t!==xe.ROTATE_TILE&&t!==xe.ROTATE_ROW||(ce[1]=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),t!==xe.FLIP_TILE&&t!==xe.FLIP_ROW||(ce[1]=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),t!==xe.FLIP_N_ROTATE_TILE&&t!==xe.FLIP_N_ROTATE_ROW||(ce[1]=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),D=0;D<s;D++)f.push(D*e-h+m,E+v,0),f.push((D+1)*e-h+m,E+v,0),f.push((D+1)*e-h+m,E+d+v,0),f.push(D*e-h+m,E+d+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,y=t===xe.FLIP_TILE||t===xe.ROTATE_TILE||t===xe.FLIP_N_ROTATE_TILE?y.concat(ce[(D+1)%2]):t===xe.FLIP_ROW||t===xe.ROTATE_ROW||t===xe.FLIP_N_ROTATE_ROW?y.concat(ce[1]):y.concat(ce[0]),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(F){var fe=[];for(ie=0,q=0,ee=1,te=d/n,fe[0]=[ie,q,ee,q,ee,te,ie,te],fe[1]=[ie,q,ee,q,ee,te,ie,te],t!==xe.ROTATE_TILE&&t!==xe.ROTATE_ROW||(fe[1]=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),t!==xe.FLIP_TILE&&t!==xe.FLIP_ROW||(fe[1]=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),t!==xe.FLIP_N_ROTATE_TILE&&t!==xe.FLIP_N_ROTATE_ROW||(fe[1]=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),D=0;D<s;D++)f.push(D*e-h+m,T-d+v,0),f.push((D+1)*e-h+m,T-d+v,0),f.push((D+1)*e-h+m,T+v,0),f.push(D*e-h+m,T+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,y=t===xe.FLIP_TILE||t===xe.ROTATE_TILE||t===xe.FLIP_N_ROTATE_TILE?y.concat(fe[(D+u)%2]):t===xe.FLIP_ROW||t===xe.ROTATE_ROW||t===xe.FLIP_N_ROTATE_ROW?y.concat(fe[u%2]):y.concat(fe[0]),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(X){var de=[];for(ie=1-l/e,q=0,ee=1,te=1,de[0]=[ie,q,ee,q,ee,te,ie,te],de[1]=[ie,q,ee,q,ee,te,ie,te],t!==xe.ROTATE_TILE&&t!==xe.ROTATE_ROW||(de[1]=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),t!==xe.FLIP_TILE&&t!==xe.FLIP_ROW||(de[1]=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),t!==xe.FLIP_N_ROTATE_TILE&&t!==xe.FLIP_N_ROTATE_ROW||(de[1]=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),M=0;M<u;M++)f.push(b+m,M*n-p+v,0),f.push(b+l+m,M*n-p+v,0),f.push(b+l+m,(M+1)*n-p+v,0),f.push(b+m,(M+1)*n-p+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,y=t===xe.FLIP_TILE||t===xe.ROTATE_TILE||t===xe.FLIP_N_ROTATE_TILE?y.concat(de[(M+1)%2]):t===xe.FLIP_ROW||t===xe.ROTATE_ROW||t===xe.FLIP_N_ROTATE_ROW?y.concat(de[M%2]):y.concat(de[0]),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if($){var Te=[];for(ie=0,q=0,ee=l/n,te=1,Te[0]=[ie,q,ee,q,ee,te,ie,te],Te[1]=[ie,q,ee,q,ee,te,ie,te],t!==xe.ROTATE_TILE&&t!==xe.ROTATE_ROW||(Te[1]=[1-ie,1-q,1-ee,1-q,1-ee,1-te,1-ie,1-te]),t!==xe.FLIP_TILE&&t!==xe.FLIP_ROW||(Te[1]=[1-ie,q,1-ee,q,1-ee,te,1-ie,te]),t!==xe.FLIP_N_ROTATE_TILE&&t!==xe.FLIP_N_ROTATE_ROW||(Te[1]=[ie,1-q,ee,1-q,ee,1-te,ie,1-te]),M=0;M<u;M++)f.push(C-l+m,M*n-p+v,0),f.push(C+m,M*n-p+v,0),f.push(C+m,(M+1)*n-p+v,0),f.push(C-l+m,(M+1)*n-p+v,0),R.push(I,I+1,I+3,I+1,I+2,I+3),I+=4,y=t===xe.FLIP_TILE||t===xe.ROTATE_TILE||t===xe.FLIP_N_ROTATE_TILE?y.concat(Te[(M+s)%2]):t===xe.FLIP_ROW||t===xe.ROTATE_ROW||t===xe.FLIP_N_ROTATE_ROW?y.concat(Te[M%2]):y.concat(Te[0]),x.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),g.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}}var ue=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE;rt._ComputeSides(ue,f,R,g,y,r.frontUVs,r.backUVs);var U=new rt;U.indices=R,U.positions=f,U.normals=g,U.uvs=y;var N=ue===rt.DOUBLESIDE?x.concat(x):x;return U.colors=N,U}function Mu(r,t,e){e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,oa(t).applyToMesh(n,t.updatable),n}rt.CreateDisc=qs,xe.CreateDisc=function(r,t,e,n,i,o){return n===void 0&&(n=null),ra(r,{radius:t,tessellation:e,sideOrientation:o,updatable:i},n)};var AE={CreateTiledPlane:Mu};function Ou(r){for(var t=r.faceUV||new Array(6),e=r.faceColors,n=r.pattern||xe.NO_FLIP,i=r.width||r.size||1,o=r.height||r.size||1,a=r.depth||r.size||1,s=r.tileWidth||r.tileSize||1,l=r.tileHeight||r.tileSize||1,c=r.alignHorizontal||0,u=r.alignVertical||0,d=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,h=0;h<6;h++)t[h]===void 0&&(t[h]=new _.IU(0,0,1,1)),e&&e[h]===void 0&&(e[h]=new z.ov(1,1,1,1));var p=i/2,m=o/2,v=a/2,b=[];for(h=0;h<2;h++)b[h]=oa({pattern:n,tileWidth:s,tileHeight:l,width:i,height:o,alignVertical:u,alignHorizontal:c,sideOrientation:d});for(h=2;h<4;h++)b[h]=oa({pattern:n,tileWidth:s,tileHeight:l,width:a,height:o,alignVertical:u,alignHorizontal:c,sideOrientation:d});var E=u;for(u===xe.BOTTOM?E=xe.TOP:u===xe.TOP&&(E=xe.BOTTOM),h=4;h<6;h++)b[h]=oa({pattern:n,tileWidth:s,tileHeight:l,width:i,height:a,alignVertical:E,alignHorizontal:c,sideOrientation:d});var C=[],T=[],f=[],g=[],S=[],y=[],x=[],R=[],I=0,M=0;for(h=0;h<6;h++){var D=b[h].positions.length;y[h]=[],x[h]=[];for(var B=0;B<D/3;B++)y[h].push(new _.Pq(b[h].positions[3*B],b[h].positions[3*B+1],b[h].positions[3*B+2])),x[h].push(new _.Pq(b[h].normals[3*B],b[h].normals[3*B+1],b[h].normals[3*B+2]));I=b[h].uvs.length,R[h]=[];for(var F=0;F<I;F+=2)R[h][F]=t[h].x+(t[h].z-t[h].x)*b[h].uvs[F],R[h][F+1]=t[h].y+(t[h].w-t[h].y)*b[h].uvs[F+1],Xt.rX&&(R[h][F+1]=1-R[h][F+1]);if(f=f.concat(R[h]),g=g.concat(b[h].indices.map(function(ue){return ue+M})),M+=y[h].length,e)for(var X=0;X<4;X++)S.push(e[h].r,e[h].g,e[h].b,e[h].a)}var $=new _.Pq(0,0,v),Q=_.uq.RotationY(Math.PI);C=y[0].map(function(ue){return _.Pq.TransformNormal(ue,Q).add($)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[]),T=x[0].map(function(ue){return _.Pq.TransformNormal(ue,Q)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[]),C=C.concat(y[1].map(function(ue){return ue.subtract($)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[])),T=T.concat(x[1].map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[]));var ie=new _.Pq(p,0,0),q=_.uq.RotationY(-Math.PI/2);C=C.concat(y[2].map(function(ue){return _.Pq.TransformNormal(ue,q).add(ie)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[])),T=T.concat(x[2].map(function(ue){return _.Pq.TransformNormal(ue,q)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[]));var ee=_.uq.RotationY(Math.PI/2);C=C.concat(y[3].map(function(ue){return _.Pq.TransformNormal(ue,ee).subtract(ie)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[])),T=T.concat(x[3].map(function(ue){return _.Pq.TransformNormal(ue,ee)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[]));var te=new _.Pq(0,m,0),ce=_.uq.RotationX(Math.PI/2);C=C.concat(y[4].map(function(ue){return _.Pq.TransformNormal(ue,ce).add(te)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[])),T=T.concat(x[4].map(function(ue){return _.Pq.TransformNormal(ue,ce)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[]));var fe=_.uq.RotationX(-Math.PI/2);C=C.concat(y[5].map(function(ue){return _.Pq.TransformNormal(ue,fe).subtract(te)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[])),T=T.concat(x[5].map(function(ue){return _.Pq.TransformNormal(ue,fe)}).map(function(ue){return[ue.x,ue.y,ue.z]}).reduce(function(ue,U){return ue.concat(U)},[])),rt._ComputeSides(d,C,g,T,f);var de=new rt;if(de.indices=g,de.positions=C,de.normals=T,de.uvs=f,e){var Te=d===rt.DOUBLESIDE?S.concat(S):S;de.colors=Te}return de}function Du(r,t,e){e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ou(t).applyToMesh(n,t.updatable),n}rt.CreateTiledPlane=oa;var CE={CreateTiledBox:Du};function Nu(r){var t,e,n=[],i=[],o=[],a=[],s=r.radius||2,l=r.tube||.5,c=r.radialSegments||32,u=r.tubularSegments||32,d=r.p||2,h=r.q||3,p=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,m=function(F){var X=Math.cos(F),$=Math.sin(F),Q=h/d*F,ie=Math.cos(Q),q=s*(2+ie)*.5*X,ee=s*(2+ie)*$*.5,te=s*Math.sin(Q)*.5;return new _.Pq(q,ee,te)};for(t=0;t<=c;t++){var v=t%c/c*2*d*Math.PI,b=m(v),E=m(v+.01),C=E.subtract(b),T=E.add(b),f=_.Pq.Cross(C,T);for(T=_.Pq.Cross(f,C),f.normalize(),T.normalize(),e=0;e<u;e++){var g=e%u/u*2*Math.PI,S=-l*Math.cos(g),y=l*Math.sin(g);i.push(b.x+S*T.x+y*f.x),i.push(b.y+S*T.y+y*f.y),i.push(b.z+S*T.z+y*f.z),a.push(t/c),a.push(Xt.rX?1-e/u:e/u)}}for(t=0;t<c;t++)for(e=0;e<u;e++){var x=(e+1)%u,R=t*u+e,I=(t+1)*u+e,M=(t+1)*u+x,D=t*u+x;n.push(D),n.push(I),n.push(R),n.push(D),n.push(M),n.push(I)}rt.ComputeNormals(i,n,o),rt._ComputeSides(p,i,n,o,a,r.frontUVs,r.backUVs);var B=new rt;return B.indices=n,B.positions=i,B.normals=o,B.uvs=a,B}function Ks(r,t,e){t===void 0&&(t={});var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Nu(t).applyToMesh(n,t.updatable),n}rt.CreateTiledBox=Ou;var RE={CreateTorusKnot:Ks};rt.CreateTorusKnot=Nu,xe.CreateTorusKnot=function(r,t,e,n,i,o,a,s,l,c){return Ks(r,{radius:t,tube:e,radialSegments:n,tubularSegments:i,p:o,q:a,sideOrientation:c,updatable:l},s)},xe._LinesMeshParser=function(r,t){return aa.Parse(r,t)};var aa=function(r){function t(e,n,i,o,a,s,l,c){n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=null);var u=r.call(this,e,n,i,o,a)||this;u.useVertexColor=s,u.useVertexAlpha=l,u.color=new z.v9(1,1,1),u.alpha=1,u._shaderLanguage=0,o&&(u.color=o.color.clone(),u.alpha=o.alpha,u.useVertexColor=o.useVertexColor,u.useVertexAlpha=o.useVertexAlpha),u.intersectionThreshold=.1;var d={attributes:[Y.R.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:[],useClipPlane:null,shaderLanguage:0};return l===!1?d.needAlphaBlending=!1:d.defines.push("#define VERTEXALPHA"),s?(d.defines.push("#define VERTEXCOLOR"),d.attributes.push(Y.R.ColorKind)):(d.uniforms.push("color"),u._color4=new z.ov),c?u.material=c:(u.getScene().getEngine().isWebGPU&&!t.ForceGLSL&&(u._shaderLanguage=1),d.shaderLanguage=u._shaderLanguage,d.extraInitializationsAsync=function(){return(0,A.sH)(u,void 0,void 0,function(){return(0,A.YH)(this,function(h){switch(h.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,69512)),Promise.resolve().then(L.bind(L,47590))])];case 1:return h.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,32755)),Promise.resolve().then(L.bind(L,38589))])];case 3:h.sent(),h.label=4;case 4:return[2]}})})},u.material=new pi("colorShader",u.getScene(),"color",d,!1),u.material.doNotSerialize=!0),u}return(0,A.C6)(t,r),t.prototype._isShaderMaterial=function(e){return e.getClassName()==="ShaderMaterial"},t.prototype.isReady=function(){return!!this._lineMaterial.isReady(this,!!this._userInstancedBuffersStorage||this.hasThinInstances)&&r.prototype.isReady.call(this)},t.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(t.prototype,"material",{get:function(){return this._lineMaterial},set:function(e){this._lineMaterial=e,this._lineMaterial.fillMode=Lt.LineListDrawMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),t.prototype._bind=function(e,n){var i;if(!this._geometry)return this;var o=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(n,o):this._geometry._bind(n,o,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),!this.useVertexColor&&this._isShaderMaterial(this._lineMaterial)){var a=(i=this.color).r,s=i.g,l=i.b;this._color4.set(a,s,l,this.alpha),this._lineMaterial.setColor4("color",this._color4)}return this},t.prototype._draw=function(e,n,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var o=this.getScene().getEngine();return this._unIndexed?o.drawArraysType(Lt.LineListDrawMode,e.verticesStart,e.verticesCount,i):o.drawElementsType(Lt.LineListDrawMode,e.indexStart,e.indexCount,i),this},t.prototype.dispose=function(e,n,i){i||this._lineMaterial.dispose(!1,!1,!0),r.prototype.dispose.call(this,e)},t.prototype.clone=function(e,n,i){return n===void 0&&(n=null),new t(e,this.getScene(),n,this,i)},t.prototype.createInstance=function(e){var n=new Lu(e,this);if(this.instancedBuffers)for(var i in n.instancedBuffers={},this.instancedBuffers)n.instancedBuffers[i]=this.instancedBuffers[i];return n},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.color=this.color.asArray(),e.alpha=this.alpha},t.Parse=function(e,n){var i=new t(e.name,n);return i.color=z.v9.FromArray(e.color),i.alpha=e.alpha,i},t.ForceGLSL=!1,t}(xe),Lu=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.intersectionThreshold=n.intersectionThreshold,i}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"InstancedLinesMesh"},t}(Co);function Fu(r){for(var t=[],e=[],n=r.lines,i=r.colors,o=[],a=0,s=0;s<n.length;s++)for(var l=n[s],c=0;c<l.length;c++){var u=l[c],d=u.x,h=u.y,p=u.z;if(e.push(d,h,p),i){var m=i[s][c],v=m.r,b=m.g,E=m.b,C=m.a;o.push(v,b,E,C)}c>0&&(t.push(a-1),t.push(a)),a++}var T=new rt;return T.indices=t,T.positions=e,i&&(T.colors=o),T}function wu(r){var t,e,n=r.dashSize||3,i=r.gapSize||1,o=r.dashNb||200,a=r.points,s=[],l=[],c=_.Pq.Zero(),u=0,d=0,h=0,p=0,m=0;for(m=0;m<a.length-1;m++)a[m+1].subtractToRef(a[m],c),u+=c.length();for(e=n*(t=u/o)/(n+i),m=0;m<a.length-1;m++){a[m+1].subtractToRef(a[m],c),d=Math.floor(c.length()/t),c.normalize();for(var v=0;v<d;v++)h=t*v,s.push(a[m].x+h*c.x,a[m].y+h*c.y,a[m].z+h*c.z),s.push(a[m].x+(h+e)*c.x,a[m].y+(h+e)*c.y,a[m].z+(h+e)*c.z),l.push(p,p+1),p+=2}var b=new rt;return b.positions=s,b.indices=l,b}function Do(r,t,e){e===void 0&&(e=null);var n=t.instance,i=t.lines,o=t.colors;if(n){var a=n.getVerticesData(Y.R.PositionKind),s=void 0,l=void 0;o&&(s=n.getVerticesData(Y.R.ColorKind));for(var c=0,u=0,d=0;d<i.length;d++)for(var h=i[d],p=0;p<h.length;p++)a[c]=h[p].x,a[c+1]=h[p].y,a[c+2]=h[p].z,o&&s&&(l=o[d],s[u]=l[p].r,s[u+1]=l[p].g,s[u+2]=l[p].b,s[u+3]=l[p].a,u+=4),c+=3;return n.updateVerticesData(Y.R.PositionKind,a,!1,!1),o&&s&&n.updateVerticesData(Y.R.ColorKind,s,!1,!1),n.refreshBoundingInfo(),n}var m=new aa(r,e,null,void 0,void 0,!!o,t.useVertexAlpha,t.material);return Fu(t).applyToMesh(m,t.updatable),m}function dn(r,t,e){e===void 0&&(e=null);var n=t.colors?[t.colors]:null;return Do(r,{lines:[t.points],updatable:t.updatable,instance:t.instance,colors:n,useVertexAlpha:t.useVertexAlpha,material:t.material},e)}function Zs(r,t,e){e===void 0&&(e=null);var n=t.points,i=t.instance,o=t.gapSize||1,a=t.dashSize||3;if(i)return(t.dashNb||t.dashSize||t.gapSize||t.useVertexAlpha||t.material)&&O.V.Warn("You have used an option other than points with the instance option. Please be aware that these other options will be ignored."),i.updateMeshPositions(function(l){var c,u,d=_.Pq.Zero(),h=l.length/6,p=0,m=0,v=0,b=0,E=0,C=0;for(E=0;E<n.length-1;E++)n[E+1].subtractToRef(n[E],d),p+=d.length();c=p/h;var T=i._creationDataStorage.dashSize;for(u=T*c/(T+i._creationDataStorage.gapSize),E=0;E<n.length-1;E++)for(n[E+1].subtractToRef(n[E],d),m=Math.floor(d.length()/c),d.normalize(),C=0;C<m&&b<l.length;)v=c*C,l[b]=n[E].x+v*d.x,l[b+1]=n[E].y+v*d.y,l[b+2]=n[E].z+v*d.z,l[b+3]=n[E].x+(v+u)*d.x,l[b+4]=n[E].y+(v+u)*d.y,l[b+5]=n[E].z+(v+u)*d.z,b+=6,C++;for(;b<l.length;)l[b]=n[E].x,l[b+1]=n[E].y,l[b+2]=n[E].z,b+=3},!1),i;var s=new aa(r,e,null,void 0,void 0,void 0,t.useVertexAlpha,t.material);return wu(t).applyToMesh(s,t.updatable),s._creationDataStorage=new Cc,s._creationDataStorage.dashSize=a,s._creationDataStorage.gapSize=o,s}var IE={CreateDashedLines:Zs,CreateLineSystem:Do,CreateLines:dn};rt.CreateLineSystem=Fu,rt.CreateDashedLines=wu,xe.CreateLines=function(r,t,e,n,i){return e===void 0&&(e=null),n===void 0&&(n=!1),i===void 0&&(i=null),dn(r,{points:t,updatable:n,instance:i},e)},xe.CreateDashedLines=function(r,t,e,n,i,o,a,s){return o===void 0&&(o=null),Zs(r,{points:t,dashSize:e,gapSize:n,dashNb:i,updatable:a,instance:s},o)};var eD=function(r){function t(e,n){var i=r.call(this,e.x,e.y)||this;return i.index=n,i}return(0,A.C6)(t,r),t}(_.I9),ig=function(){function r(){this.elements=[]}return r.prototype.add=function(t){var e=this,n=[];return t.forEach(function(i){var o=new eD(i,e.elements.length);n.push(o),e.elements.push(o)}),n},r.prototype.computeBounds=function(){var t=new _.I9(this.elements[0].x,this.elements[0].y),e=new _.I9(this.elements[0].x,this.elements[0].y);return this.elements.forEach(function(n){n.x<t.x?t.x=n.x:n.x>e.x&&(e.x=n.x),n.y<t.y?t.y=n.y:n.y>e.y&&(e.y=n.y)}),{min:t,max:e,width:e.x-t.x,height:e.y-t.y}},r}(),ME=function(){function r(){}return r.Rectangle=function(t,e,n,i){return[new _.I9(t,e),new _.I9(n,e),new _.I9(n,i),new _.I9(t,i)]},r.Circle=function(t,e,n,i){e===void 0&&(e=0),n===void 0&&(n=0),i===void 0&&(i=32);for(var o=[],a=0,s=2*Math.PI/i,l=0;l<i;l++)o.push(new _.I9(e+Math.cos(a)*t,n+Math.sin(a)*t)),a-=s;return o},r.Parse=function(t){var e,n=t.split(/[^-+eE.\d]+/).map(parseFloat).filter(function(o){return!isNaN(o)}),i=[];for(e=0;e<(2147483646&n.length);e+=2)i.push(new _.I9(n[e],n[e+1]));return i},r.StartingAt=function(t,e){return Bt.Cu.StartingAt(t,e)},r}(),rg=function(){function r(t,e,n,i){var o;i===void 0&&(i=earcut),this._points=new ig,this._outlinepoints=new ig,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=i,this._name=t,this._scene=n||Ve.q.LastCreatedScene,o=e instanceof Bt.Cu?e.getPoints():e,this._addToepoint(o),this._points.add(o),this._outlinepoints.add(o),this.bjsEarcut===void 0&&O.V.Warn("Earcut was not found, the polygon will not be built.")}return r.prototype._addToepoint=function(t){for(var e=0,n=t;e<n.length;e++){var i=n[e];this._epoints.push(i.x,i.y)}},r.prototype.addHole=function(t){this._points.add(t);var e=new ig;return e.add(t),this._holes.push(e),this._eholes.push(this._epoints.length/2),this._addToepoint(t),this},r.prototype.build=function(t,e,n){t===void 0&&(t=!1),e===void 0&&(e=0),n===void 0&&(n=2);var i=new xe(this._name,this._scene),o=this.buildVertexData(e,n);return i.setVerticesData(Y.R.PositionKind,o.positions,t),i.setVerticesData(Y.R.NormalKind,o.normals,t),i.setVerticesData(Y.R.UVKind,o.uvs,t),i.setIndices(o.indices),i},r.prototype.buildVertexData=function(t,e){var n=this;t===void 0&&(t=0),e===void 0&&(e=2);var i=new rt,o=[],a=[],s=[],l=this._points.computeBounds();this._points.elements.forEach(function(E){o.push(0,1,0),a.push(E.x,0,E.y),s.push((E.x-l.min.x)/l.width,(E.y-l.min.y)/l.height)});for(var c=[],u=this.bjsEarcut(this._epoints,this._eholes,2),d=0;d<u.length;d++)c.push(u[d]);if(t>0){var h=a.length/3;this._points.elements.forEach(function(E){o.push(0,-1,0),a.push(E.x,-t,E.y),s.push(1-(E.x-l.min.x)/l.width,1-(E.y-l.min.y)/l.height)});var p=c.length;for(d=0;d<p;d+=3){var m=c[d+0],v=c[d+1],b=c[d+2];c.push(b+h),c.push(v+h),c.push(m+h)}this._addSide(a,o,s,c,l,this._outlinepoints,t,!1,e),this._holes.forEach(function(E){n._addSide(a,o,s,c,l,E,t,!0,e)})}return i.indices=c,i.positions=a,i.normals=o,i.uvs=s,i},r.prototype._addSide=function(t,e,n,i,o,a,s,l,c){for(var u=t.length/3,d=0,h=0;h<a.elements.length;h++){var p=a.elements[h],m=a.elements[(h+1)%a.elements.length];t.push(p.x,0,p.y),t.push(p.x,-s,p.y),t.push(m.x,0,m.y),t.push(m.x,-s,m.y);var v=a.elements[(h+a.elements.length-1)%a.elements.length],b=a.elements[(h+2)%a.elements.length],E=new _.Pq(-(m.y-p.y),0,m.x-p.x),C=new _.Pq(-(p.y-v.y),0,p.x-v.x),T=new _.Pq(-(b.y-m.y),0,b.x-m.x);l||(E=E.scale(-1),C=C.scale(-1),T=T.scale(-1));var f=E.normalizeToNew(),g=C.normalizeToNew(),S=T.normalizeToNew(),y=_.Pq.Dot(g,f);g=y>c?y<pt.bH-1?new _.Pq(p.x,0,p.y).subtract(new _.Pq(m.x,0,m.y)).normalize():C.add(E).normalize():f;var x=_.Pq.Dot(T,E);S=x>c?x<pt.bH-1?new _.Pq(m.x,0,m.y).subtract(new _.Pq(p.x,0,p.y)).normalize():T.add(E).normalize():f,n.push(d/o.width,0),n.push(d/o.width,1),d+=E.length(),n.push(d/o.width,0),n.push(d/o.width,1),e.push(g.x,g.y,g.z),e.push(g.x,g.y,g.z),e.push(S.x,S.y,S.z),e.push(S.x,S.y,S.z),l?(i.push(u),i.push(u+2),i.push(u+1),i.push(u+1),i.push(u+2),i.push(u+3)):(i.push(u),i.push(u+1),i.push(u+2),i.push(u+1),i.push(u+3),i.push(u+2)),u+=4}},r}();function Bu(r,t,e,n,i,o,a){for(var s=e||new Array(3),l=n,c=[],u=a||!1,d=0;d<3;d++)s[d]===void 0&&(s[d]=new _.IU(0,0,1,1)),l&&l[d]===void 0&&(l[d]=new z.ov(1,1,1,1));var h=r.getVerticesData(Y.R.PositionKind),p=r.getVerticesData(Y.R.NormalKind),m=r.getVerticesData(Y.R.UVKind),v=r.getIndices(),b=h.length/9,E=0,C=0,T=0,f=0,g=[0];if(u)for(var S=b;S<h.length/3;S+=4)C=h[3*(S+2)]-h[3*S],T=h[3*(S+2)+2]-h[3*S+2],f+=Math.sqrt(C*C+T*T),g.push(f);for(var y=0,x=0,R=0;R<p.length;R+=3)Math.abs(p[R+1])<.001&&(x=1),Math.abs(p[R+1]-1)<.001&&(x=0),Math.abs(p[R+1]+1)<.001&&(x=2),y=R/3,x===1?(E=y-b,m[2*y]=E%4<1.5?u?s[x].x+(s[x].z-s[x].x)*g[Math.floor(E/4)]/f:s[x].x:u?s[x].x+(s[x].z-s[x].x)*g[Math.floor(E/4)+1]/f:s[x].z,m[2*y+1]=E%2==0?Xt.rX?1-s[x].w:s[x].w:Xt.rX?1-s[x].y:s[x].y):(m[2*y]=(1-m[2*y])*s[x].x+m[2*y]*s[x].z,m[2*y+1]=(1-m[2*y+1])*s[x].y+m[2*y+1]*s[x].w,Xt.rX&&(m[2*y+1]=1-m[2*y+1])),l&&c.push(l[x].r,l[x].g,l[x].b,l[x].a);rt._ComputeSides(t,h,v,p,m,i,o);var I=new rt;if(I.indices=v,I.positions=h,I.normals=p,I.uvs=m,l){var M=t===rt.DOUBLESIDE?c.concat(c):c;I.colors=M}return I}function wa(r,t,e,n){e===void 0&&(e=null),n===void 0&&(n=earcut),t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation);for(var i=t.shape,o=t.holes||[],a=t.depth||0,s=t.smoothingThreshold||2,l=[],c=[],u=0;u<i.length;u++)l[u]=new _.I9(i[u].x,i[u].z);l[0].equalsWithEpsilon(l[l.length-1],1e-8)&&l.pop();for(var d=new rg(r,l,e||Ve.q.LastCreatedScene,n),h=0;h<o.length;h++){c=[];for(var p=0;p<o[h].length;p++)c.push(new _.I9(o[h][p].x,o[h][p].z));d.addHole(c)}var m=d.build(!1,a,s);return m._originalBuilderSideOrientation=t.sideOrientation,Bu(m,t.sideOrientation,t.faceUV,t.faceColors,t.frontUVs,t.backUVs,t.wrap).applyToMesh(m,t.updatable),m}function Ba(r,t,e,n){return e===void 0&&(e=null),n===void 0&&(n=earcut),wa(r,t,e,n)}var OE={ExtrudePolygon:Ba,CreatePolygon:wa};function Va(r,t,e){e===void 0&&(e=null);var n=t.path,i=t.shape,o=t.scale||1,a=t.rotation||0,s=t.cap===0?0:t.cap||xe.NO_CAP,l=t.updatable,c=xe._GetDefaultSideOrientation(t.sideOrientation),u=t.instance||null,d=t.invertUV||!1,h=t.closeShape||!1;return DE(r,i,n,o,a,null,null,t.closePath||!1,h,s,!1,e,!!l,c,u,d,t.frontUVs||null,t.backUVs||null,t.firstNormal||null,!!t.adjustFrame)}function Ua(r,t,e){e===void 0&&(e=null);var n=t.path,i=t.shape,o=t.scaleFunction||function(){return 1},a=t.rotationFunction||function(){return 0},s=t.closePath||t.ribbonCloseArray||!1,l=t.closeShape||t.ribbonClosePath||!1,c=t.cap===0?0:t.cap||xe.NO_CAP,u=t.updatable,d=t.firstNormal||null,h=t.adjustFrame||!1;return DE(r,i,n,null,null,o,a,s,l,c,!0,e,!!u,xe._GetDefaultSideOrientation(t.sideOrientation),t.instance||null,t.invertUV||!1,t.frontUVs||null,t.backUVs||null,d,h)}function DE(r,t,e,n,i,o,a,s,l,c,u,d,h,p,m,v,b,E,C,T){var f,g,S=function(R,I,M,D,B,F,X,$,Q,ie,q){var ee=M.getTangents(),te=M.getNormals(),ce=M.getBinormals(),fe=M.getDistances();if(q){for(var de=0;de<ee.length;de++)if(ee[de].x==0&&ee[de].y==0&&ee[de].z==0&&ee[de].copyFrom(ee[de-1]),te[de].x==0&&te[de].y==0&&te[de].z==0&&te[de].copyFrom(te[de-1]),ce[de].x==0&&ce[de].y==0&&ce[de].z==0&&ce[de].copyFrom(ce[de-1]),de>0){var Te=ee[de-1];_.Pq.Dot(Te,ee[de])<0&&ee[de].scaleInPlace(-1),Te=te[de-1],_.Pq.Dot(Te,te[de])<0&&te[de].scaleInPlace(-1),Te=ce[de-1],_.Pq.Dot(Te,ce[de])<0&&ce[de].scaleInPlace(-1)}}var ue=0,U=ie&&$?$:function(){return F!==null?F:0},N=ie&&X?X:function(){return B!==null?B:1},w=Q===xe.NO_CAP||Q===xe.CAP_END?0:2,k=_.AA.Matrix[0];for(de=0;de<I.length;de++){var J=[],le=U(de,fe[de]),be=N(de,fe[de]);_.uq.RotationAxisToRef(ee[de],ue,k);for(var ve=0;ve<R.length;ve++){var ye=ee[de].scale(R[ve].z).add(te[de].scale(R[ve].x)).add(ce[de].scale(R[ve].y)),Me=_.Pq.Zero();_.Pq.TransformCoordinatesToRef(ye,k,Me),Me.scaleInPlace(be).addInPlace(I[de]),J[ve]=Me}D[w]=J,ue+=le,w++}var we=function(He){var Ke,Qe=Array(),Je=_.Pq.Zero();for(Ke=0;Ke<He.length;Ke++)Je.addInPlace(He[Ke]);for(Je.scaleInPlace(1/He.length),Ke=0;Ke<He.length;Ke++)Qe.push(Je);return Qe};switch(Q){case xe.NO_CAP:break;case xe.CAP_START:D[0]=we(D[2]),D[1]=D[2];break;case xe.CAP_END:D[w]=D[w-1],D[w+1]=we(D[w-1]);break;case xe.CAP_ALL:D[0]=we(D[2]),D[1]=D[2],D[w]=D[w-1],D[w+1]=we(D[w-1])}return D};if(m){var y=m._creationDataStorage;return f=C?y.path3D.update(e,C):y.path3D.update(e),oo("",{pathArray:g=S(t,e,y.path3D,y.pathArray,n,i,o,a,y.cap,u,T),closeArray:!1,closePath:!1,offset:0,updatable:!1,sideOrientation:0,instance:m},d||void 0)}c=c<0||c>3?0:c;var x=oo(r,{pathArray:g=S(t,e,f=C?new Bt.tO(e,C):new Bt.tO(e),new Array,n,i,o,a,c,u,T),closeArray:s,closePath:l,updatable:h,sideOrientation:p,invertUV:v,frontUVs:b||void 0,backUVs:E||void 0},d);return x._creationDataStorage.pathArray=g,x._creationDataStorage.path3D=f,x._creationDataStorage.cap=c,x}rt.CreatePolygon=Bu,xe.CreatePolygon=function(r,t,e,n,i,o,a){return a===void 0&&(a=earcut),wa(r,{shape:t,holes:n,updatable:i,sideOrientation:o},e,a)},xe.ExtrudePolygon=function(r,t,e,n,i,o,a,s){return s===void 0&&(s=earcut),Ba(r,{shape:t,holes:i,depth:e,updatable:o,sideOrientation:a},n,s)};var NE={ExtrudeShape:Va,ExtrudeShapeCustom:Ua};function Qs(r,t,e){e===void 0&&(e=null);var n,i,o=t.arc?t.arc<=0||t.arc>1?1:t.arc:1,a=t.closed===void 0||t.closed,s=t.shape,l=t.radius||1,c=t.tessellation||64,u=t.clip||0,d=t.updatable,h=xe._GetDefaultSideOrientation(t.sideOrientation),p=t.cap||xe.NO_CAP,m=2*Math.PI,v=[],b=t.invertUV||!1,E=0,C=0,T=m/c*o;for(E=0;E<=c-u;E++){for(i=[],p!=xe.CAP_START&&p!=xe.CAP_ALL||(i.push(new _.Pq(0,s[0].y,0)),i.push(new _.Pq(Math.cos(E*T)*s[0].x*l,s[0].y,Math.sin(E*T)*s[0].x*l))),C=0;C<s.length;C++)n=new _.Pq(Math.cos(E*T)*s[C].x*l,s[C].y,Math.sin(E*T)*s[C].x*l),i.push(n);p!=xe.CAP_END&&p!=xe.CAP_ALL||(i.push(new _.Pq(Math.cos(E*T)*s[s.length-1].x*l,s[s.length-1].y,Math.sin(E*T)*s[s.length-1].x*l)),i.push(new _.Pq(0,s[s.length-1].y,0))),v.push(i)}return oo(r,{pathArray:v,closeArray:a,sideOrientation:h,updatable:d,invertUV:b,frontUVs:t.frontUVs,backUVs:t.backUVs},e)}xe.ExtrudeShape=function(r,t,e,n,i,o,a,s,l,c){return a===void 0&&(a=null),Va(r,{shape:t,path:e,scale:n,rotation:i,cap:o===0?0:o||xe.NO_CAP,sideOrientation:l,instance:c,updatable:s},a)},xe.ExtrudeShapeCustom=function(r,t,e,n,i,o,a,s,l,c,u,d){return Ua(r,{shape:t,path:e,scaleFunction:n,rotationFunction:i,ribbonCloseArray:o,ribbonClosePath:a,cap:s===0?0:s||xe.NO_CAP,sideOrientation:u,instance:d,updatable:c},l)};var LE={CreateLathe:Qs};function Js(r,t,e){e===void 0&&(e=null);var n=t.path,i=t.instance,o=1;t.radius!==void 0?o=t.radius:i&&(o=i._creationDataStorage.radius);var a=t.tessellation||64,s=t.radiusFunction||null,l=t.cap||xe.NO_CAP,c=t.invertUV||!1,u=t.updatable,d=xe._GetDefaultSideOrientation(t.sideOrientation);t.arc=t.arc&&(t.arc<=0||t.arc>1)?1:t.arc||1;var h,p,m=function(C,T,f,g,S,y,x,R){for(var I,M,D,B,F=T.getTangents(),X=T.getNormals(),$=T.getDistances(),Q=2*Math.PI/S*R,ie=y||function(){return g},q=_.AA.Matrix[0],ee=x===xe.NO_CAP||x===xe.CAP_END?0:2,te=0;te<C.length;te++){M=ie(te,$[te]),I=Array(),D=X[te];for(var ce=0;ce<S;ce++)_.uq.RotationAxisToRef(F[te],Q*ce,q),B=I[ce]?I[ce]:_.Pq.Zero(),_.Pq.TransformCoordinatesToRef(D,q,B),B.scaleInPlace(M).addInPlace(C[te]),I[ce]=B;f[ee]=I,ee++}var fe=function(de,Te){for(var ue=Array(),U=0;U<de;U++)ue.push(C[Te]);return ue};switch(x){case xe.NO_CAP:break;case xe.CAP_START:f[0]=fe(S,0),f[1]=f[2].slice(0);break;case xe.CAP_END:f[ee]=f[ee-1].slice(0),f[ee+1]=fe(S,C.length-1);break;case xe.CAP_ALL:f[0]=fe(S,0),f[1]=f[2].slice(0),f[ee]=f[ee-1].slice(0),f[ee+1]=fe(S,C.length-1)}return f};if(i){var v=i._creationDataStorage,b=t.arc||v.arc;return i=oo("",{pathArray:p=m(n,h=v.path3D.update(n),v.pathArray,o,v.tessellation,s,v.cap,b),instance:i}),v.path3D=h,v.pathArray=p,v.arc=b,v.radius=o,i}l=l<0||l>3?0:l;var E=oo(r,{pathArray:p=m(n,h=new Bt.tO(n),new Array,o,a,s,l,t.arc),closePath:!0,closeArray:!1,updatable:u,sideOrientation:d,invertUV:c,frontUVs:t.frontUVs,backUVs:t.backUVs},e);return E._creationDataStorage.pathArray=p,E._creationDataStorage.path3D=h,E._creationDataStorage.tessellation=a,E._creationDataStorage.cap=l,E._creationDataStorage.arc=t.arc,E._creationDataStorage.radius=o,E}xe.CreateLathe=function(r,t,e,n,i,o,a){return Qs(r,{shape:t,radius:e,tessellation:n,sideOrientation:a,updatable:o},i)};var FE={CreateTube:Js};function Vu(r){var t=[];t[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},t[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},t[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},t[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},t[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},t[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},t[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},t[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},t[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},t[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},t[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},t[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},t[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},t[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},t[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var e,n,i,o,a,s,l=r.type&&(r.type<0||r.type>=t.length)?0:r.type||0,c=r.size,u=r.sizeX||c||1,d=r.sizeY||c||1,h=r.sizeZ||c||1,p=r.custom||t[l],m=p.face.length,v=r.faceUV||new Array(m),b=r.faceColors,E=r.flat===void 0||r.flat,C=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,T=[],f=[],g=[],S=[],y=[],x=0,R=0,I=[],M=0,D=0;if(E)for(D=0;D<m;D++)b&&b[D]===void 0&&(b[D]=new z.ov(1,1,1,1)),v&&v[D]===void 0&&(v[D]=new _.IU(0,0,1,1));if(E)for(D=0;D<m;D++){var B=p.face[D].length;for(i=2*Math.PI/B,o=.5*Math.tan(i/2),a=.5,M=0;M<B;M++)T.push(p.vertex[p.face[D][M]][0]*u,p.vertex[p.face[D][M]][1]*d,p.vertex[p.face[D][M]][2]*h),I.push(x),x++,e=v[D].x+(v[D].z-v[D].x)*(.5+o),n=v[D].y+(v[D].w-v[D].y)*(a-.5),S.push(e,Xt.rX?1-n:n),s=o*Math.cos(i)-a*Math.sin(i),a=o*Math.sin(i)+a*Math.cos(i),o=s,b&&y.push(b[D].r,b[D].g,b[D].b,b[D].a);for(M=0;M<B-2;M++)f.push(I[0+R],I[M+2+R],I[M+1+R]);R+=B}else{for(M=0;M<p.vertex.length;M++)T.push(p.vertex[M][0]*u,p.vertex[M][1]*d,p.vertex[M][2]*h),S.push(0,Xt.rX?1:0);for(D=0;D<m;D++)for(M=0;M<p.face[D].length-2;M++)f.push(p.face[D][0],p.face[D][M+2],p.face[D][M+1])}rt.ComputeNormals(T,f,g),rt._ComputeSides(C,T,f,g,S,r.frontUVs,r.backUVs);var F=new rt;return F.positions=T,F.indices=f,F.normals=g,F.uvs=S,b&&E&&(F.colors=y),F}function No(r,t,e){t===void 0&&(t={}),e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Vu(t).applyToMesh(n,t.updatable),n}xe.CreateTube=function(r,t,e,n,i,o,a,s,l,c){return Js(r,{path:t,radius:e,tessellation:n,radiusFunction:i,arc:1,cap:o,updatable:s,sideOrientation:l,instance:c},a)};var wE={CreatePolyhedron:No};function $s(r){var t,e=r.sideOrientation||rt.DEFAULTSIDE,n=r.radius||1,i=r.flat===void 0||r.flat,o=0|(r.subdivisions||4),a=r.radiusX||n,s=r.radiusY||n,l=r.radiusZ||n,c=(1+Math.sqrt(5))/2,u=[-1,c,-0,1,c,0,-1,-c,0,1,-c,0,0,-1,-c,0,1,-c,0,-1,c,0,1,c,c,0,1,c,0,-1,-c,0,1,-c,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],h=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],p=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],m=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],v=[],b=[],E=[],C=[],T=0,f=new Array(3),g=new Array(3);for(t=0;t<3;t++)f[t]=_.Pq.Zero(),g[t]=_.I9.Zero();for(var S=0;S<20;S++){for(t=0;t<3;t++){var y=d[3*S+t];f[t].copyFromFloats(u[3*h[y]],u[3*h[y]+1],u[3*h[y]+2]),f[t].normalize(),g[t].copyFromFloats(.134765625*p[2*y]+.05859375+-.0390625*m[S],.2333984375*p[2*y+1]+.025390625+.01953125*m[S])}for(var x=function(D,B,F,X){var $,Q=_.Pq.Lerp(f[0],f[2],B/o),ie=_.Pq.Lerp(f[1],f[2],B/o),q=o===B?f[2]:_.Pq.Lerp(Q,ie,D/(o-B));if(q.normalize(),i){var ee=_.Pq.Lerp(f[0],f[2],X/o),te=_.Pq.Lerp(f[1],f[2],X/o);$=_.Pq.Lerp(ee,te,F/(o-X))}else $=new _.Pq(q.x,q.y,q.z);$.x/=a,$.y/=s,$.z/=l,$.normalize();var ce=_.I9.Lerp(g[0],g[2],B/o),fe=_.I9.Lerp(g[1],g[2],B/o),de=o===B?g[2]:_.I9.Lerp(ce,fe,D/(o-B));b.push(q.x*a,q.y*s,q.z*l),E.push($.x,$.y,$.z),C.push(de.x,Xt.rX?1-de.y:de.y),v.push(T),T++},R=0;R<o;R++)for(var I=0;I+R<o;I++)x(I,R,I+1/3,R+1/3),x(I+1,R,I+1/3,R+1/3),x(I,R+1,I+1/3,R+1/3),I+R+1<o&&(x(I+1,R,I+2/3,R+2/3),x(I+1,R+1,I+2/3,R+2/3),x(I,R+1,I+2/3,R+2/3))}rt._ComputeSides(e,b,v,E,C,r.frontUVs,r.backUVs);var M=new rt;return M.indices=v,M.positions=b,M.normals=E,M.uvs=C,M}function sa(r,t,e){t===void 0&&(t={}),e===void 0&&(e=null);var n=new xe(r,e);return t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,$s(t).applyToMesh(n,t.updatable),n}rt.CreatePolyhedron=Vu,xe.CreatePolyhedron=function(r,t,e){return No(r,t,e)};var BE={CreateIcoSphere:sa};rt.CreateIcoSphere=$s,xe.CreateIcoSphere=function(r,t,e){return sa(r,t,e)};var tD=new _.Pq(1,0,0),nD=new _.Pq(-1,0,0),iD=new _.Pq(0,1,0),rD=new _.Pq(0,-1,0),oD=new _.Pq(0,0,1),aD=new _.Pq(0,0,-1),VE=function(){function r(t,e,n,i,o,a,s,l,c){t===void 0&&(t=_.Pq.Zero()),e===void 0&&(e=_.Pq.Up()),n===void 0&&(n=_.I9.Zero()),i===void 0&&(i=0),o===void 0&&(o=0),a===void 0&&(a=null),s===void 0&&(s=null),l===void 0&&(l=null),c===void 0&&(c=null),this.position=t,this.normal=e,this.uv=n,this.vertexIdx=i,this.vertexIdxForBones=o,this.localPositionOverride=a,this.localNormalOverride=s,this.matrixIndicesOverride=l,this.matrixWeightsOverride=c}return r.prototype.clone=function(){var t,e,n,i;return new r(this.position.clone(),this.normal.clone(),this.uv.clone(),this.vertexIdx,this.vertexIdxForBones,(t=this.localPositionOverride)===null||t===void 0?void 0:t.slice(),(e=this.localNormalOverride)===null||e===void 0?void 0:e.slice(),(n=this.matrixIndicesOverride)===null||n===void 0?void 0:n.slice(),(i=this.matrixWeightsOverride)===null||i===void 0?void 0:i.slice())},r}();function el(r,t,e){var n,i,o,a,s=!!t.skeleton,l=e.localMode||s,c=t.getIndices(),u=s?t.getPositionData(!0,!0):t.getVerticesData(Y.R.PositionKind),d=s?t.getNormalsData(!0,!0):t.getVerticesData(Y.R.NormalKind),h=l?s?t.getVerticesData(Y.R.PositionKind):u:null,p=l?s?t.getVerticesData(Y.R.NormalKind):d:null,m=t.getVerticesData(Y.R.UVKind),v=s?t.getVerticesData(Y.R.MatricesIndicesKind):null,b=s?t.getVerticesData(Y.R.MatricesWeightsKind):null,E=s?t.getVerticesData(Y.R.MatricesIndicesExtraKind):null,C=s?t.getVerticesData(Y.R.MatricesWeightsExtraKind):null,T=e.position||_.Pq.Zero(),f=e.normal||_.Pq.Up(),g=e.size||_.Pq.One(),S=e.angle||0;if(!f){var y=new _.Pq(0,0,1),x=t.getScene().activeCamera,R=_.Pq.TransformCoordinates(y,x.getWorldMatrix());f=x.globalPosition.subtract(R)}var I=-Math.atan2(f.z,f.x)-Math.PI/2,M=Math.sqrt(f.x*f.x+f.z*f.z),D=Math.atan2(f.y,M),B=new rt;B.indices=[],B.positions=[],B.normals=[],B.uvs=[],B.matricesIndices=s?[]:null,B.matricesWeights=s?[]:null,B.matricesIndicesExtra=E?[]:null,B.matricesWeightsExtra=C?[]:null;var F=0,X=function(ye,Me){var we=new VE;if(!c||!u||!d)return we;var He=c[ye];if(we.vertexIdx=3*He,we.vertexIdxForBones=4*He,we.position=new _.Pq(u[3*He],u[3*He+1],u[3*He+2]),_.Pq.TransformCoordinatesToRef(we.position,Me,we.position),we.normal=new _.Pq(d[3*He],d[3*He+1],d[3*He+2]),_.Pq.TransformNormalToRef(we.normal,Me,we.normal),e.captureUVS&&m){var Ke=m[2*He+1];we.uv=new _.I9(m[2*He],Xt.rX?1-Ke:Ke)}return we},$=[0,0,0,0],Q=function(ye,Me){if(ye.length===0)return ye;var we=.5*Math.abs(_.Pq.Dot(g,Me)),He=function(Et,Vt,ln,Yt){for(var Un=0;Un<Yt;++Un)if(Et[ln+Un]===Vt)return ln+Un;return-1},Ke=function(Et,Vt){var ln,Yt,Un,lr,ii,Li,$r,Xo,jo,Or,Dr,Yi,eo,Nr,mo,go,Pi=_.Pq.GetClipFactor(Et.position,Vt.position,Me,we),yr=$,ai=$;if(v&&b){var Lr=Et.matrixIndicesOverride?0:Et.vertexIdxForBones,xo=(ln=Et.matrixIndicesOverride)!==null&&ln!==void 0?ln:v,vo=(Yt=Et.matrixWeightsOverride)!==null&&Yt!==void 0?Yt:b,br=Vt.matrixIndicesOverride?0:Vt.vertexIdxForBones,Ai=(Un=Vt.matrixIndicesOverride)!==null&&Un!==void 0?Un:v,qo=(lr=Vt.matrixWeightsOverride)!==null&&lr!==void 0?lr:b;yr=[0,0,0,0],ai=[0,0,0,0];for(var Po=0,cr=0;cr<4;++cr)if(vo[Lr+cr]>0){var k_=He(Ai,xo[Lr+cr],br,4);yr[Po]=xo[Lr+cr],ai[Po]=(0,qe.Lerp)(vo[Lr+cr],k_>=0?qo[k_]:0,Pi),Po++}for(cr=0;cr<4&&Po<4;++cr){var Fr=Ai[br+cr];He(xo,Fr,Lr,4)===-1&&(yr[Po]=Fr,ai[Po]=(0,qe.Lerp)(0,qo[br+cr],Pi),Po++)}var to=ai[0]+ai[1]+ai[2]+ai[3];ai[0]/=to,ai[1]/=to,ai[2]/=to,ai[3]/=to}var Ss=Et.localPositionOverride?Et.localPositionOverride[0]:(ii=h?.[Et.vertexIdx])!==null&&ii!==void 0?ii:0,z_=Et.localPositionOverride?Et.localPositionOverride[1]:(Li=h?.[Et.vertexIdx+1])!==null&&Li!==void 0?Li:0,yc=Et.localPositionOverride?Et.localPositionOverride[2]:($r=h?.[Et.vertexIdx+2])!==null&&$r!==void 0?$r:0,bc=Vt.localPositionOverride?Vt.localPositionOverride[0]:(Xo=h?.[Vt.vertexIdx])!==null&&Xo!==void 0?Xo:0,Tc=Vt.localPositionOverride?Vt.localPositionOverride[1]:(jo=h?.[Vt.vertexIdx+1])!==null&&jo!==void 0?jo:0,Sc=Vt.localPositionOverride?Vt.localPositionOverride[2]:(Or=h?.[Vt.vertexIdx+2])!==null&&Or!==void 0?Or:0,W_=Et.localNormalOverride?Et.localNormalOverride[0]:(Dr=p?.[Et.vertexIdx])!==null&&Dr!==void 0?Dr:0,H_=Et.localNormalOverride?Et.localNormalOverride[1]:(Yi=p?.[Et.vertexIdx+1])!==null&&Yi!==void 0?Yi:0,Ec=Et.localNormalOverride?Et.localNormalOverride[2]:(eo=p?.[Et.vertexIdx+2])!==null&&eo!==void 0?eo:0,ba=W_+((Vt.localNormalOverride?Vt.localNormalOverride[0]:(Nr=p?.[Vt.vertexIdx])!==null&&Nr!==void 0?Nr:0)-W_)*Pi,Ko=H_+((Vt.localNormalOverride?Vt.localNormalOverride[1]:(mo=p?.[Vt.vertexIdx+1])!==null&&mo!==void 0?mo:0)-H_)*Pi,yo=Ec+((Vt.localNormalOverride?Vt.localNormalOverride[2]:(go=p?.[Vt.vertexIdx+2])!==null&&go!==void 0?go:0)-Ec)*Pi,xc=Math.sqrt(ba*ba+Ko*Ko+yo*yo);return new VE(_.Pq.Lerp(Et.position,Vt.position,Pi),_.Pq.Lerp(Et.normal,Vt.normal,Pi).normalize(),_.I9.Lerp(Et.uv,Vt.uv,Pi),-1,-1,h?[Ss+(bc-Ss)*Pi,z_+(Tc-z_)*Pi,yc+(Sc-yc)*Pi]:null,p?[ba/xc,Ko/xc,yo/xc]:null,yr,ai)},Qe=null;ye.length>3&&(Qe=[]);for(var Je=0;Je<ye.length;Je+=3){var ht=null,mt=null,yt=null,zt=null,$t=_.Pq.Dot(ye[Je].position,Me)-we>0,St=_.Pq.Dot(ye[Je+1].position,Me)-we>0,Ot=_.Pq.Dot(ye[Je+2].position,Me)-we>0;switch(($t?1:0)+(St?1:0)+(Ot?1:0)){case 0:ye.length>3?(Qe.push(ye[Je]),Qe.push(ye[Je+1]),Qe.push(ye[Je+2])):Qe=ye;break;case 1:if(Qe=Qe??new Array,$t&&(ht=ye[Je+1],mt=ye[Je+2],yt=Ke(ye[Je],ht),zt=Ke(ye[Je],mt)),St){ht=ye[Je],mt=ye[Je+2],yt=Ke(ye[Je+1],ht),zt=Ke(ye[Je+1],mt),Qe.push(yt),Qe.push(mt.clone()),Qe.push(ht.clone()),Qe.push(mt.clone()),Qe.push(yt.clone()),Qe.push(zt);break}Ot&&(ht=ye[Je],mt=ye[Je+1],yt=Ke(ye[Je+2],ht),zt=Ke(ye[Je+2],mt)),ht&&mt&&yt&&zt&&(Qe.push(ht.clone()),Qe.push(mt.clone()),Qe.push(yt),Qe.push(zt),Qe.push(yt.clone()),Qe.push(mt.clone()));break;case 2:Qe=Qe??new Array,$t||(mt=Ke(ht=ye[Je].clone(),ye[Je+1]),yt=Ke(ht,ye[Je+2]),Qe.push(ht),Qe.push(mt),Qe.push(yt)),St||(mt=Ke(ht=ye[Je+1].clone(),ye[Je+2]),yt=Ke(ht,ye[Je]),Qe.push(ht),Qe.push(mt),Qe.push(yt)),Ot||(mt=Ke(ht=ye[Je+2].clone(),ye[Je]),yt=Ke(ht,ye[Je+1]),Qe.push(ht),Qe.push(mt),Qe.push(yt))}}return Qe},ie=t instanceof xe?t:null,q=ie?._thinInstanceDataStorage.matrixData,ee=ie?.thinInstanceCount||1,te=_.AA.Matrix[0];te.copyFrom(_.uq.IdentityReadOnly);for(var ce=0;ce<ee;++ce){if(ie?.hasThinInstances&&q){var fe=16*ce;te.setRowFromFloats(0,q[fe+0],q[fe+1],q[fe+2],q[fe+3]),te.setRowFromFloats(1,q[fe+4],q[fe+5],q[fe+6],q[fe+7]),te.setRowFromFloats(2,q[fe+8],q[fe+9],q[fe+10],q[fe+11]),te.setRowFromFloats(3,q[fe+12],q[fe+13],q[fe+14],q[fe+15])}for(var de=_.uq.RotationYawPitchRoll(I,D,S).multiply(_.uq.Translation(T.x,T.y,T.z)),Te=_.uq.Invert(de),ue=t.getWorldMatrix(),U=te.multiply(ue).multiply(Te),N=new Array(3),w=0;w<c.length;w+=3){var k=N;if(k[0]=X(w,U),k[1]=X(w+1,U),k[2]=X(w+2,U),!(e.cullBackFaces&&-k[0].normal.z<=0&&-k[1].normal.z<=0&&-k[2].normal.z<=0)&&(k=Q(k,tD))&&(k=Q(k,nD))&&(k=Q(k,iD))&&(k=Q(k,rD))&&(k=Q(k,oD))&&(k=Q(k,aD)))for(var J=0;J<k.length;J++){var le=k[J];if(B.indices.push(F),l?(le.localPositionOverride?(B.positions[3*F]=le.localPositionOverride[0],B.positions[3*F+1]=le.localPositionOverride[1],B.positions[3*F+2]=le.localPositionOverride[2]):h&&(B.positions[3*F]=h[le.vertexIdx],B.positions[3*F+1]=h[le.vertexIdx+1],B.positions[3*F+2]=h[le.vertexIdx+2]),le.localNormalOverride?(B.normals[3*F]=le.localNormalOverride[0],B.normals[3*F+1]=le.localNormalOverride[1],B.normals[3*F+2]=le.localNormalOverride[2]):p&&(B.normals[3*F]=p[le.vertexIdx],B.normals[3*F+1]=p[le.vertexIdx+1],B.normals[3*F+2]=p[le.vertexIdx+2])):(le.position.toArray(B.positions,3*F),le.normal.toArray(B.normals,3*F)),B.matricesIndices&&B.matricesWeights&&(le.matrixIndicesOverride?(B.matricesIndices[4*F]=le.matrixIndicesOverride[0],B.matricesIndices[4*F+1]=le.matrixIndicesOverride[1],B.matricesIndices[4*F+2]=le.matrixIndicesOverride[2],B.matricesIndices[4*F+3]=le.matrixIndicesOverride[3]):(v&&(B.matricesIndices[4*F]=v[le.vertexIdxForBones],B.matricesIndices[4*F+1]=v[le.vertexIdxForBones+1],B.matricesIndices[4*F+2]=v[le.vertexIdxForBones+2],B.matricesIndices[4*F+3]=v[le.vertexIdxForBones+3]),E&&B.matricesIndicesExtra&&(B.matricesIndicesExtra[4*F]=E[le.vertexIdxForBones],B.matricesIndicesExtra[4*F+1]=E[le.vertexIdxForBones+1],B.matricesIndicesExtra[4*F+2]=E[le.vertexIdxForBones+2],B.matricesIndicesExtra[4*F+3]=E[le.vertexIdxForBones+3])),le.matrixWeightsOverride?(B.matricesWeights[4*F]=le.matrixWeightsOverride[0],B.matricesWeights[4*F+1]=le.matrixWeightsOverride[1],B.matricesWeights[4*F+2]=le.matrixWeightsOverride[2],B.matricesWeights[4*F+3]=le.matrixWeightsOverride[3]):(b&&(B.matricesWeights[4*F]=b[le.vertexIdxForBones],B.matricesWeights[4*F+1]=b[le.vertexIdxForBones+1],B.matricesWeights[4*F+2]=b[le.vertexIdxForBones+2],B.matricesWeights[4*F+3]=b[le.vertexIdxForBones+3]),C&&B.matricesWeightsExtra&&(B.matricesWeightsExtra[4*F]=C[le.vertexIdxForBones],B.matricesWeightsExtra[4*F+1]=C[le.vertexIdxForBones+1],B.matricesWeightsExtra[4*F+2]=C[le.vertexIdxForBones+2],B.matricesWeightsExtra[4*F+3]=C[le.vertexIdxForBones+3]))),e.captureUVS)le.uv.toArray(B.uvs,2*F);else{B.uvs.push(.5+le.position.x/g.x);var be=.5+le.position.y/g.y;B.uvs.push(Xt.rX?1-be:be)}F++}}}B.indices.length===0&&(B.indices=null),B.positions.length===0&&(B.positions=null),B.normals.length===0&&(B.normals=null),B.uvs.length===0&&(B.uvs=null),((n=B.matricesIndices)===null||n===void 0?void 0:n.length)===0&&(B.matricesIndices=null),((i=B.matricesWeights)===null||i===void 0?void 0:i.length)===0&&(B.matricesWeights=null),((o=B.matricesIndicesExtra)===null||o===void 0?void 0:o.length)===0&&(B.matricesIndicesExtra=null),((a=B.matricesWeightsExtra)===null||a===void 0?void 0:a.length)===0&&(B.matricesWeightsExtra=null);var ve=new xe(r,t.getScene());return B.applyToMesh(ve),l?(ve.skeleton=t.skeleton,ve.parent=t):(ve.position=T.clone(),ve.rotation=new _.Pq(D,I,S)),ve.computeWorldMatrix(!0),ve.refreshBoundingInfo(!0,!0),ve}var UE={CreateDecal:el};xe.CreateDecal=function(r,t,e,n,i,o){return el(r,t,{position:e,normal:n,size:i,angle:o})};var wn=function(){function r(t,e){t===void 0&&(t=0),e===void 0&&(e=0),this.x=t,this.y=e,t!==Math.floor(t)&&(t=Math.floor(t),O.V.Warn("x is not an integer, floor(x) used")),e!==Math.floor(e)&&(e=Math.floor(e),O.V.Warn("y is not an integer, floor(y) used"))}return r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.rotate60About=function(t){var e=this.x;return this.x=t.x+t.y-this.y,this.y=e+this.y-t.x,this},r.prototype.rotateNeg60About=function(t){var e=this.x;return this.x=e+this.y-t.y,this.y=t.x+t.y-e,this},r.prototype.rotate120=function(t,e){t!==Math.floor(t)&&(t=Math.floor(t),O.V.Warn("m not an integer only floor(m) used")),e!==Math.floor(e)&&(e=Math.floor(e),O.V.Warn("n not an integer only floor(n) used"));var n=this.x;return this.x=t-n-this.y,this.y=e+n,this},r.prototype.rotateNeg120=function(t,e){t!==Math.floor(t)&&(t=Math.floor(t),O.V.Warn("m is not an integer, floor(m) used")),e!==Math.floor(e)&&(e=Math.floor(e),O.V.Warn("n is not an integer, floor(n) used"));var n=this.x;return this.x=this.y-e,this.y=t+e-n-this.y,this},r.prototype.toCartesianOrigin=function(t,e){var n=_.Pq.Zero();return n.x=t.x+2*this.x*e+this.y*e,n.y=t.y+Math.sqrt(3)*this.y*e,n},r.Zero=function(){return new r(0,0)},r}(),Uu=function(){function r(){this.cartesian=[],this.vertices=[],this.max=[],this.min=[],this.closestTo=[],this.innerFacets=[],this.isoVecsABOB=[],this.isoVecsOBOA=[],this.isoVecsBAOA=[],this.vertexTypes=[],this.IDATA=new tl("icosahedron","Regular",[[0,pt.a6,-1],[-pt.a6,1,0],[-1,0,-pt.a6],[1,0,-pt.a6],[pt.a6,1,0],[0,pt.a6,1],[-1,0,pt.a6],[-pt.a6,-1,0],[0,-pt.a6,-1],[pt.a6,-1,0],[1,0,pt.a6],[0,-pt.a6,1]],[[0,2,1],[0,3,2],[0,4,3],[0,5,4],[0,1,5],[7,6,1],[8,7,2],[9,8,3],[10,9,4],[6,10,5],[2,7,1],[3,8,2],[4,9,3],[5,10,4],[1,6,5],[11,6,7],[11,7,8],[11,8,9],[11,9,10],[11,10,6]])}return r.prototype.setIndices=function(){var t,e,n,i,o,a,s,l=12,c={},u=this.m,d=this.n,h=u;d!==0&&(h=(0,qe.HighestCommonFactor)(u,d)),t=u/h,e=d/h;var p,m,v,b=wn.Zero(),E=new wn(u,d),C=new wn(-d,u+d),T=wn.Zero(),f=wn.Zero(),g=wn.Zero(),S=[],y=[],x=this.vertByDist,R=function(D,B,F,X){m=B+"|"+X,(p=D+"|"+F)in c||m in c?p in c&&!(m in c)?c[m]=c[p]:m in c&&!(p in c)&&(c[p]=c[m]):(c[p]=l,c[m]=l,l++),x[F][0]>2?y[c[p]]=[-x[F][0],x[F][1],c[p]]:y[c[p]]=[S[x[F][0]],x[F][1],c[p]]};this.IDATA.edgematch=[[1,"B"],[2,"B"],[3,"B"],[4,"B"],[0,"B"],[10,"O",14,"A"],[11,"O",10,"A"],[12,"O",11,"A"],[13,"O",12,"A"],[14,"O",13,"A"],[0,"O"],[1,"O"],[2,"O"],[3,"O"],[4,"O"],[19,"B",5,"A"],[15,"B",6,"A"],[16,"B",7,"A"],[17,"B",8,"A"],[18,"B",9,"A"]];for(var I=0;I<20;I++){if(o=(S=this.IDATA.face[I])[2],a=S[1],s=S[0],v=b.x+"|"+b.y,(p=I+"|"+v)in c||(c[p]=o,y[o]=[S[x[v][0]],x[v][1]]),v=E.x+"|"+E.y,(p=I+"|"+v)in c||(c[p]=a,y[a]=[S[x[v][0]],x[v][1]]),v=C.x+"|"+C.y,(p=I+"|"+v)in c||(c[p]=s,y[s]=[S[x[v][0]],x[v][1]]),n=this.IDATA.edgematch[I][0],(i=this.IDATA.edgematch[I][1])==="B")for(var M=1;M<h;M++)f.x=u-M*(t+e),f.y=d+M*t,g.x=-M*e,g.y=M*(t+e),R(I,n,v=f.x+"|"+f.y,g.x+"|"+g.y);if(i==="O")for(M=1;M<h;M++)g.x=-M*e,g.y=M*(t+e),T.x=M*t,T.y=M*e,R(I,n,v=g.x+"|"+g.y,T.x+"|"+T.y);if(n=this.IDATA.edgematch[I][2],(i=this.IDATA.edgematch[I][3])&&i==="A")for(M=1;M<h;M++)T.x=M*t,T.y=M*e,f.x=u-(h-M)*(t+e),f.y=d+(h-M)*t,R(I,n,v=T.x+"|"+T.y,f.x+"|"+f.y);for(M=0;M<this.vertices.length;M++)v=this.vertices[M].x+"|"+this.vertices[M].y,(p=I+"|"+v)in c||(c[p]=l++,x[v][0]>2?y[c[p]]=[-x[v][0],x[v][1],c[p]]:y[c[p]]=[S[x[v][0]],x[v][1],c[p]])}this.closestTo=y,this.vecToidx=c},r.prototype.calcCoeffs=function(){var t=this.m,e=this.n,n=Math.sqrt(3)/3,i=t*t+e*e+t*e;this.coau=(t+e)/i,this.cobu=-e/i,this.coav=-n*(t-e)/i,this.cobv=n*(2*t+e)/i},r.prototype.createInnerFacets=function(){for(var t=this.m,e=this.n,n=0;n<e+t+1;n++)for(var i=this.min[n];i<this.max[n]+1;i++)i<this.max[n]&&i<this.max[n+1]+1&&this.innerFacets.push(["|"+i+"|"+n,"|"+i+"|"+(n+1),"|"+(i+1)+"|"+n]),n>0&&i<this.max[n-1]&&i+1<this.max[n]+1&&this.innerFacets.push(["|"+i+"|"+n,"|"+(i+1)+"|"+n,"|"+(i+1)+"|"+(n-1)])},r.prototype.edgeVecsABOB=function(){for(var t=this.m,e=this.n,n=new wn(-e,t+e),i=1;i<t+e;i++){var o=new wn(this.min[i],i),a=new wn(this.min[i-1],i-1),s=new wn(this.min[i+1],i+1),l=o.clone(),c=a.clone(),u=s.clone();l.rotate60About(n),c.rotate60About(n),u.rotate60About(n);var d=new wn(this.max[l.y],l.y),h=new wn(this.max[l.y-1],l.y-1),p=new wn(this.max[l.y-1]-1,l.y-1);l.x===d.x&&l.y===d.y||(l.x!==h.x?(this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([o,h,p]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([o,p,d])):l.y===u.y?(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([o,a,h]),this.vertexTypes.push([1,0,1]),this.isoVecsABOB.push([o,h,s])):(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([o,a,h]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([o,h,d])))}},r.prototype.mapABOBtoOBOA=function(){for(var t=new wn(0,0),e=0;e<this.isoVecsABOB.length;e++){for(var n=[],i=0;i<3;i++)t.x=this.isoVecsABOB[e][i].x,t.y=this.isoVecsABOB[e][i].y,this.vertexTypes[e][i]===0&&t.rotateNeg120(this.m,this.n),n.push(t.clone());this.isoVecsOBOA.push(n)}},r.prototype.mapABOBtoBAOA=function(){for(var t=new wn(0,0),e=0;e<this.isoVecsABOB.length;e++){for(var n=[],i=0;i<3;i++)t.x=this.isoVecsABOB[e][i].x,t.y=this.isoVecsABOB[e][i].y,this.vertexTypes[e][i]===1&&t.rotate120(this.m,this.n),n.push(t.clone());this.isoVecsBAOA.push(n)}},r.prototype.MapToFace=function(t,e){for(var n,i=this.IDATA.face[t],o=i[2],a=i[1],s=i[0],l=_.Pq.FromArray(this.IDATA.vertex[o]),c=_.Pq.FromArray(this.IDATA.vertex[a]),u=_.Pq.FromArray(this.IDATA.vertex[s]),d=c.subtract(l),h=u.subtract(l),p=d.scale(this.coau).add(h.scale(this.cobu)),m=d.scale(this.coav).add(h.scale(this.cobv)),v=[],b=_.AA.Vector3[0],E=0;E<this.cartesian.length;E++)b=p.scale(this.cartesian[E].x).add(m.scale(this.cartesian[E].y)).add(l),v[E]=[b.x,b.y,b.z],n=t+"|"+this.vertices[E].x+"|"+this.vertices[E].y,e.vertex[this.vecToidx[n]]=[b.x,b.y,b.z]},r.prototype.build=function(t,e){var n=[],i=wn.Zero(),o=new wn(t,e),a=new wn(-e,t+e);n.push(i,o,a);for(var s=e;s<t+1;s++)for(var l=0;l<t+1-s;l++)n.push(new wn(l,s));if(e>0){for(var c=(0,qe.HighestCommonFactor)(t,e),u=t/c,d=e/c,h=1;h<c;h++)n.push(new wn(h*u,h*d)),n.push(new wn(-h*d,h*(u+d))),n.push(new wn(t-h*(u+d),e+h*u));for(var p=t/e,m=1;m<e;m++)for(var v=0;v<m*p;v++)n.push(new wn(v,m)),n.push(new wn(v,m).rotate120(t,e)),n.push(new wn(v,m).rotateNeg120(t,e))}n.sort(function(X,$){return X.x-$.x}),n.sort(function(X,$){return X.y-$.y});var b=new Array(t+e+1),E=new Array(t+e+1);for(h=0;h<b.length;h++)b[h]=1/0,E[h]=-1/0;var C=0,T=0,f=n.length;for(h=0;h<f;h++)T=n[h].x,b[C=n[h].y]=Math.min(T,b[C]),E[C]=Math.max(T,E[C]);var g=function(X,$){var Q=X.clone();return $==="A"&&Q.rotateNeg120(t,e),$==="B"&&Q.rotate120(t,e),Q.x<0?Q.y:Q.x+Q.y},S=[],y=[],x=[],R=[],I={},M=[],D=-1,B=-1;for(h=0;h<f;h++)S[h]=n[h].toCartesianOrigin(new wn(0,0),.5),y[h]=g(n[h],"O"),x[h]=g(n[h],"A"),R[h]=g(n[h],"B"),y[h]===x[h]&&x[h]===R[h]?(D=3,B=y[h]):y[h]===x[h]?(D=4,B=y[h]):x[h]===R[h]?(D=5,B=x[h]):R[h]===y[h]&&(D=6,B=y[h]),y[h]<x[h]&&y[h]<R[h]&&(D=2,B=y[h]),x[h]<y[h]&&x[h]<R[h]&&(D=1,B=x[h]),R[h]<x[h]&&R[h]<y[h]&&(D=0,B=R[h]),M.push([D,B,n[h].x,n[h].y]);M.sort(function(X,$){return X[2]-$[2]}),M.sort(function(X,$){return X[3]-$[3]}),M.sort(function(X,$){return X[1]-$[1]}),M.sort(function(X,$){return X[0]-$[0]});for(var F=0;F<M.length;F++)I[M[F][2]+"|"+M[F][3]]=[M[F][0],M[F][1],F];return this.m=t,this.n=e,this.vertices=n,this.vertByDist=I,this.cartesian=S,this.min=b,this.max=E,this},r}(),tl=function(r,t,e,n){this.name=r,this.category=t,this.vertex=e,this.face=n},Gu=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.innerToData=function(e,n){for(var i=0;i<n.innerFacets.length;i++)this.face.push(n.innerFacets[i].map(function(o){return n.vecToidx[e+o]}))},t.prototype.mapABOBtoDATA=function(e,n){for(var i=n.IDATA.edgematch[e][0],o=0;o<n.isoVecsABOB.length;o++){for(var a=[],s=0;s<3;s++)n.vertexTypes[o][s]===0?a.push(e+"|"+n.isoVecsABOB[o][s].x+"|"+n.isoVecsABOB[o][s].y):a.push(i+"|"+n.isoVecsABOB[o][s].x+"|"+n.isoVecsABOB[o][s].y);this.face.push([n.vecToidx[a[0]],n.vecToidx[a[1]],n.vecToidx[a[2]]])}},t.prototype.mapOBOAtoDATA=function(e,n){for(var i=n.IDATA.edgematch[e][0],o=0;o<n.isoVecsOBOA.length;o++){for(var a=[],s=0;s<3;s++)n.vertexTypes[o][s]===1?a.push(e+"|"+n.isoVecsOBOA[o][s].x+"|"+n.isoVecsOBOA[o][s].y):a.push(i+"|"+n.isoVecsOBOA[o][s].x+"|"+n.isoVecsOBOA[o][s].y);this.face.push([n.vecToidx[a[0]],n.vecToidx[a[1]],n.vecToidx[a[2]]])}},t.prototype.mapBAOAtoDATA=function(e,n){for(var i=n.IDATA.edgematch[e][2],o=0;o<n.isoVecsBAOA.length;o++){for(var a=[],s=0;s<3;s++)n.vertexTypes[o][s]===1?a.push(e+"|"+n.isoVecsBAOA[o][s].x+"|"+n.isoVecsBAOA[o][s].y):a.push(i+"|"+n.isoVecsBAOA[o][s].x+"|"+n.isoVecsBAOA[o][s].y);this.face.push([n.vecToidx[a[0]],n.vecToidx[a[1]],n.vecToidx[a[2]]])}},t.prototype.orderData=function(e){for(var n=[],i=0;i<13;i++)n[i]=[];var o=e.closestTo;for(i=0;i<o.length;i++)o[i][0]>-1?o[i][1]>0&&n[o[i][0]].push([i,o[i][1]]):n[12].push([i,o[i][0]]);var a=[];for(i=0;i<12;i++)a[i]=i;var s=12;for(i=0;i<12;i++){n[i].sort(function(c,u){return c[1]-u[1]});for(var l=0;l<n[i].length;l++)a[n[i][l][0]]=s++}for(l=0;l<n[12].length;l++)a[n[12][l][0]]=s++;for(i=0;i<this.vertex.length;i++)this.vertex[i].push(a[i]);for(this.vertex.sort(function(c,u){return c[3]-u[3]}),i=0;i<this.vertex.length;i++)this.vertex[i].pop();for(i=0;i<this.face.length;i++)for(l=0;l<this.face[i].length;l++)this.face[i][l]=a[this.face[i][l]];this.sharedNodes=n[12].length,this.poleNodes=this.vertex.length-this.sharedNodes},t.prototype.setOrder=function(e,n){var i=[],o=[],a=n.pop();o.push(a);var s=this.face[a].indexOf(e);s=(s+2)%3;var l=this.face[a][s];i.push(l);for(var c=0;n.length>0;)a=n[c],this.face[a].indexOf(l)>-1?(s=(this.face[a].indexOf(l)+1)%3,l=this.face[a][s],i.push(l),o.push(a),n.splice(c,1),c=0):c++;return this.adjacentFaces.push(i),o},t.prototype.toGoldbergPolyhedronData=function(){var e=this,n=new tl("GeoDual","Goldberg",[],[]);n.name="GD dual";for(var i=this.vertex.length,o=new Array(i),a=0;a<i;a++)o[a]=[];for(var s=0;s<this.face.length;s++)for(var l=0;l<3;l++)o[this.face[s][l]].push(s);var c=0,u=0,d=0,h=[],p=[];this.adjacentFaces=[];for(var m=0;m<o.length;m++)n.face[m]=this.setOrder(m,o[m].concat([])),o[m].forEach(function(v){c=0,u=0,d=0,h=e.face[v];for(var b=0;b<3;b++)p=e.vertex[h[b]],c+=p[0],u+=p[1],d+=p[2];n.vertex[v]=[c/3,u/3,d/3]});return n},t.BuildGeodesicData=function(e){var n=new t("Geodesic-m-n","Geodesic",[[0,pt.a6,-1],[-pt.a6,1,0],[-1,0,-pt.a6],[1,0,-pt.a6],[pt.a6,1,0],[0,pt.a6,1],[-1,0,pt.a6],[-pt.a6,-1,0],[0,-pt.a6,-1],[pt.a6,-1,0],[1,0,pt.a6],[0,-pt.a6,1]],[]);e.setIndices(),e.calcCoeffs(),e.createInnerFacets(),e.edgeVecsABOB(),e.mapABOBtoOBOA(),e.mapABOBtoBAOA();for(var i=0;i<e.IDATA.face.length;i++)e.MapToFace(i,n),n.innerToData(i,e),e.IDATA.edgematch[i][1]==="B"&&n.mapABOBtoDATA(i,e),e.IDATA.edgematch[i][1]==="O"&&n.mapOBOAtoDATA(i,e),e.IDATA.edgematch[i][3]==="A"&&n.mapBAOAtoDATA(i,e);return n.orderData(e),n.vertex=n.vertex.map(function(o){var a=o[0],s=o[1],l=o[2],c=Math.sqrt(a*a+s*s+l*l);return o[0]*=1/c,o[1]*=1/c,o[2]*=1/c,o}),n},t}(tl);function og(r,t,e){e===void 0&&(e=null);var n=t.m||1;n!==Math.floor(n)&&(n=Math.floor(n),O.V.Warn("m not an integer only floor(m) used"));var i=t.n||0;if(i!==Math.floor(i)&&(i=Math.floor(i),O.V.Warn("n not an integer only floor(n) used")),i>n){var o=i;i=n,n=o,O.V.Warn("n > m therefore m and n swapped")}var a=new Uu;return a.build(n,i),No(r,{custom:Gu.BuildGeodesicData(a),size:t.size,sizeX:t.sizeX,sizeY:t.sizeY,sizeZ:t.sizeZ,faceUV:t.faceUV,faceColors:t.faceColors,flat:t.flat,updatable:t.updatable,sideOrientation:t.sideOrientation,frontUVs:t.frontUVs,backUVs:t.backUVs},e)}xe._GoldbergMeshParser=function(r,t){return ku.Parse(r,t)};var ku=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.goldbergData={faceColors:[],faceCenters:[],faceZaxis:[],faceXaxis:[],faceYaxis:[],nbSharedFaces:0,nbUnsharedFaces:0,nbFaces:0,nbFacesAtPole:0,adjacentFaces:[]},e}return(0,A.C6)(t,r),t.prototype.relatedGoldbergFace=function(e,n){return n===void 0?(e>this.goldbergData.nbUnsharedFaces-1&&(O.V.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(O.V.Warn("Last pole used"),e=11),n>this.goldbergData.nbFacesAtPole-1&&(O.V.Warn("Maximum number of faces at a pole used"),n=this.goldbergData.nbFacesAtPole-1),12+e*this.goldbergData.nbFacesAtPole+n)},t.prototype._changeGoldbergFaceColors=function(e){for(var n=0;n<e.length;n++)for(var i=e[n][0],o=e[n][1],a=e[n][2],s=i;s<o+1;s++)this.goldbergData.faceColors[s]=a;var l=[];for(s=0;s<12;s++)for(n=0;n<5;n++)l.push(this.goldbergData.faceColors[s].r,this.goldbergData.faceColors[s].g,this.goldbergData.faceColors[s].b,this.goldbergData.faceColors[s].a);for(s=12;s<this.goldbergData.faceColors.length;s++)for(n=0;n<6;n++)l.push(this.goldbergData.faceColors[s].r,this.goldbergData.faceColors[s].g,this.goldbergData.faceColors[s].b,this.goldbergData.faceColors[s].a);return l},t.prototype.setGoldbergFaceColors=function(e){var n=this._changeGoldbergFaceColors(e);this.setVerticesData(Y.R.ColorKind,n)},t.prototype.updateGoldbergFaceColors=function(e){var n=this._changeGoldbergFaceColors(e);this.updateVerticesData(Y.R.ColorKind,n)},t.prototype._changeGoldbergFaceUVs=function(e){for(var n=this.getVerticesData(Y.R.UVKind),i=0;i<e.length;i++){for(var o=e[i][0],a=e[i][1],s=e[i][2],l=e[i][3],c=e[i][4],u=[],d=[],h=void 0,p=void 0,m=0;m<5;m++)h=s.x+l*Math.cos(c+m*Math.PI/2.5),p=s.y+l*Math.sin(c+m*Math.PI/2.5),h<0&&(h=0),h>1&&(h=1),u.push(h,p);for(m=0;m<6;m++)h=s.x+l*Math.cos(c+m*Math.PI/3),p=s.y+l*Math.sin(c+m*Math.PI/3),h<0&&(h=0),h>1&&(h=1),d.push(h,p);for(var v=o;v<Math.min(12,a+1);v++)for(m=0;m<5;m++)n[10*v+2*m]=u[2*m],n[10*v+2*m+1]=u[2*m+1];for(v=Math.max(12,o);v<a+1;v++)for(m=0;m<6;m++)n[12*v-24+2*m]=d[2*m],n[12*v-23+2*m]=d[2*m+1]}return n},t.prototype.setGoldbergFaceUVs=function(e){var n=this._changeGoldbergFaceUVs(e);this.setVerticesData(Y.R.UVKind,n)},t.prototype.updateGoldbergFaceUVs=function(e){var n=this._changeGoldbergFaceUVs(e);this.updateVerticesData(Y.R.UVKind,n)},t.prototype.placeOnGoldbergFaceAt=function(e,n,i){var o=_.Pq.RotationFromAxis(this.goldbergData.faceXaxis[n],this.goldbergData.faceYaxis[n],this.goldbergData.faceZaxis[n]);e.rotation=o,e.position=this.goldbergData.faceCenters[n].add(this.goldbergData.faceXaxis[n].scale(i.x)).add(this.goldbergData.faceYaxis[n].scale(i.y)).add(this.goldbergData.faceZaxis[n].scale(i.z))},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.type="GoldbergMesh";var n={};if(n.adjacentFaces=this.goldbergData.adjacentFaces,n.nbSharedFaces=this.goldbergData.nbSharedFaces,n.nbUnsharedFaces=this.goldbergData.nbUnsharedFaces,n.nbFaces=this.goldbergData.nbFaces,n.nbFacesAtPole=this.goldbergData.nbFacesAtPole,this.goldbergData.faceColors){n.faceColors=[];for(var i=0,o=this.goldbergData.faceColors;i<o.length;i++){var a=o[i];n.faceColors.push(a.asArray())}}if(this.goldbergData.faceCenters){n.faceCenters=[];for(var s=0,l=this.goldbergData.faceCenters;s<l.length;s++){var c=l[s];n.faceCenters.push(c.asArray())}}if(this.goldbergData.faceZaxis){n.faceZaxis=[];for(var u=0,d=this.goldbergData.faceZaxis;u<d.length;u++)c=d[u],n.faceZaxis.push(c.asArray())}if(this.goldbergData.faceYaxis){n.faceYaxis=[];for(var h=0,p=this.goldbergData.faceYaxis;h<p.length;h++)c=p[h],n.faceYaxis.push(c.asArray())}if(this.goldbergData.faceXaxis){n.faceXaxis=[];for(var m=0,v=this.goldbergData.faceXaxis;m<v.length;m++)c=v[m],n.faceXaxis.push(c.asArray())}e.goldbergData=n},t.Parse=function(e,n){var i=e.goldbergData;i.faceColors=i.faceColors.map(function(a){return z.ov.FromArray(a)}),i.faceCenters=i.faceCenters.map(function(a){return _.Pq.FromArray(a)}),i.faceZaxis=i.faceZaxis.map(function(a){return _.Pq.FromArray(a)}),i.faceXaxis=i.faceXaxis.map(function(a){return _.Pq.FromArray(a)}),i.faceYaxis=i.faceYaxis.map(function(a){return _.Pq.FromArray(a)});var o=new t(e.name,n);return o.goldbergData=i,o},t}(xe);function ag(r,t){for(var e=r.size,n=r.sizeX||e||1,i=r.sizeY||e||1,o=r.sizeZ||e||1,a=r.sideOrientation===0?0:r.sideOrientation||rt.DEFAULTSIDE,s=[],l=[],c=[],u=[],d=1/0,h=-1/0,p=1/0,m=-1/0,v=0;v<t.vertex.length;v++)d=Math.min(d,t.vertex[v][0]*n),h=Math.max(h,t.vertex[v][0]*n),p=Math.min(p,t.vertex[v][1]*i),m=Math.max(m,t.vertex[v][1]*i);for(var b=0,E=0;E<t.face.length;E++){var C=t.face[E],T=_.Pq.FromArray(t.vertex[C[0]]),f=_.Pq.FromArray(t.vertex[C[2]]),g=_.Pq.FromArray(t.vertex[C[1]]),S=f.subtract(T),y=g.subtract(T),x=_.Pq.Cross(y,S).normalize();for(v=0;v<C.length;v++){c.push(x.x,x.y,x.z);var R=t.vertex[C[v]];s.push(R[0]*n,R[1]*i,R[2]*o);var I=(R[1]*i-p)/(m-p);u.push((R[0]*n-d)/(h-d),Xt.rX?1-I:I)}for(v=0;v<C.length-2;v++)l.push(b,b+v+2,b+v+1);b+=C.length}rt._ComputeSides(a,s,l,c,u);var M=new rt;return M.positions=s,M.indices=l,M.normals=c,M.uvs=u,M}function sg(r,t,e){e===void 0&&(e=null);var n=t.size,i=t.sizeX||n||1,o=t.sizeY||n||1,a=t.sizeZ||n||1,s=t.m||1;s!==Math.floor(s)&&(s=Math.floor(s),O.V.Warn("m not an integer only floor(m) used"));var l=t.n||0;if(l!==Math.floor(l)&&(l=Math.floor(l),O.V.Warn("n not an integer only floor(n) used")),l>s){var c=l;l=s,s=c,O.V.Warn("n > m therefore m and n swapped")}var u=new Uu;u.build(s,l);var d=Gu.BuildGeodesicData(u),h=d.toGoldbergPolyhedronData(),p=new ku(r,e);t.sideOrientation=xe._GetDefaultSideOrientation(t.sideOrientation),p._originalBuilderSideOrientation=t.sideOrientation,ag(t,h).applyToMesh(p,t.updatable),p.goldbergData.nbSharedFaces=d.sharedNodes,p.goldbergData.nbUnsharedFaces=d.poleNodes,p.goldbergData.adjacentFaces=d.adjacentFaces,p.goldbergData.nbFaces=p.goldbergData.nbSharedFaces+p.goldbergData.nbUnsharedFaces,p.goldbergData.nbFacesAtPole=(p.goldbergData.nbUnsharedFaces-12)/12;for(var m=0;m<d.vertex.length;m++)p.goldbergData.faceCenters.push(_.Pq.FromArray(d.vertex[m])),p.goldbergData.faceCenters[m].x*=i,p.goldbergData.faceCenters[m].y*=o,p.goldbergData.faceCenters[m].z*=a,p.goldbergData.faceColors.push(new z.ov(1,1,1,1));for(m=0;m<h.face.length;m++){var v=h.face[m],b=_.Pq.FromArray(h.vertex[v[0]]),E=_.Pq.FromArray(h.vertex[v[2]]),C=_.Pq.FromArray(h.vertex[v[1]]),T=E.subtract(b),f=C.subtract(b),g=_.Pq.Cross(f,T).normalize(),S=_.Pq.Cross(f,g).normalize();p.goldbergData.faceXaxis.push(f.normalize()),p.goldbergData.faceYaxis.push(g),p.goldbergData.faceZaxis.push(S)}return p}var sD=function(){function r(t){this._paths=[],this._tempPaths=[],this._holes=[],this._resolution=t}return r.prototype.moveTo=function(t,e){this._currentPath=new Bt.Cu(t,e),this._tempPaths.push(this._currentPath)},r.prototype.lineTo=function(t,e){this._currentPath.addLineTo(t,e)},r.prototype.quadraticCurveTo=function(t,e,n,i){this._currentPath.addQuadraticCurveTo(t,e,n,i,this._resolution)},r.prototype.bezierCurveTo=function(t,e,n,i,o,a){this._currentPath.addBezierCurveTo(t,e,n,i,o,a,this._resolution)},r.prototype.extractHoles=function(){for(var t=0,e=this._tempPaths;t<e.length;t++){var n=e[t];n.area()>0?this._holes.push(n):this._paths.push(n)}if(!this._paths.length&&this._holes.length){var i=this._holes;this._holes=this._paths,this._paths=i}this._tempPaths.length=0},Object.defineProperty(r.prototype,"paths",{get:function(){return this._paths},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"holes",{get:function(){return this._holes},enumerable:!1,configurable:!0}),r}();function lD(r,t,e,n,i,o){var a=o.glyphs[r]||o.glyphs["?"];if(!a)return null;var s=new sD(i);if(a.o)for(var l=a.o.split(" "),c=0,u=l.length;c<u;)switch(l[c++]){case"m":var d=parseInt(l[c++])*t+e,h=parseInt(l[c++])*t+n;s.moveTo(d,h);break;case"l":d=parseInt(l[c++])*t+e,h=parseInt(l[c++])*t+n,s.lineTo(d,h);break;case"q":var p=parseInt(l[c++])*t+e,m=parseInt(l[c++])*t+n,v=parseInt(l[c++])*t+e,b=parseInt(l[c++])*t+n;s.quadraticCurveTo(v,b,p,m);break;case"b":p=parseInt(l[c++])*t+e,m=parseInt(l[c++])*t+n,v=parseInt(l[c++])*t+e,b=parseInt(l[c++])*t+n;var E=parseInt(l[c++])*t+e,C=parseInt(l[c++])*t+n;s.bezierCurveTo(v,b,E,C,p,m)}return s.extractHoles(),{offsetX:a.ha*t,shapePath:s}}function zu(r,t,e,n){for(var i=Array.from(r),o=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*o,s=[],l=0,c=0,u=0;u<i.length;u++){var d=i[u];if(d===`
|
||
`)l=0,c-=a;else{var h=lD(d,o,l,c,e,n);h&&(l+=h.offsetX,s.push(h.shapePath))}}return s}function lg(r,t,e,n,i,o){var a,s;n===void 0&&(n={size:50,resolution:8,depth:1}),i===void 0&&(i=null),o===void 0&&(o=earcut);for(var l=[],c=0,u=0,d=zu(t,n.size||50,n.resolution||8,e);u<d.length;u++){var h=d[u];if(h.paths.length)for(var p=h.holes.slice(),m=0,v=h.paths;m<v.length;m++){for(var b=v[m],E=[],C=[],T=0,f=b.getPoints();T<f.length;T++){var g=f[T];C.push(new _.Pq(g.x,0,g.y))}for(var S=0,y=p.slice();S<y.length;S++){for(var x=(Q=y[S]).getPoints(),R=!1,I=0,M=x;I<M.length;I++)if(g=M[I],b.isPointInside(g)){R=!0;break}if(R){for(var D=[],B=0,F=x;B<F.length;B++)g=F[B],D.push(new _.Pq(g.x,0,g.y));E.push(D),p.splice(p.indexOf(Q),1)}}if(!E.length&&p.length)for(var X=0,$=p;X<$.length;X++){D=[];for(var Q,ie=0,q=(Q=$[X]).getPoints();ie<q.length;ie++)g=q[ie],D.push(new _.Pq(g.x,0,g.y));E.push(D)}var ee=Ba(r,{shape:C,holes:E.length?E:void 0,depth:n.depth||1,faceUV:n.faceUV||((a=n.perLetterFaceUV)===null||a===void 0?void 0:a.call(n,c)),faceColors:n.faceColors||((s=n.perLetterFaceColors)===null||s===void 0?void 0:s.call(n,c)),sideOrientation:xe._GetDefaultSideOrientation(n.sideOrientation||xe.DOUBLESIDE)},i,o);l.push(ee),c++}}var te=xe.MergeMeshes(l,!0,!0);if(te){var ce=te.getBoundingInfo().boundingBox;te.position.x+=-(ce.minimumWorld.x+ce.maximumWorld.x)/2,te.position.y+=-(ce.minimumWorld.y+ce.maximumWorld.y)/2,te.position.z+=-(ce.minimumWorld.z+ce.maximumWorld.z)/2+ce.extendSize.z,te.name=r;var fe=new jt("pivot",i);fe.rotation.x=-Math.PI/2,te.parent=fe,te.bakeCurrentTransformIntoVertices(),te.parent=null,fe.dispose()}return te}var cg={CreateBox:Oi,CreateTiledBox:Du,CreateSphere:li,CreateDisc:ra,CreateIcoSphere:sa,CreateRibbon:oo,CreateCylinder:_i,CreateTorus:Sr,CreateTorusKnot:Ks,CreateLineSystem:Do,CreateLines:dn,CreateDashedLines:Zs,ExtrudeShape:Va,ExtrudeShapeCustom:Ua,CreateLathe:Qs,CreateTiledPlane:Mu,CreatePlane:Ur,CreateGround:ta,CreateTiledGround:Gs,CreateGroundFromHeightMap:ks,CreatePolygon:wa,ExtrudePolygon:Ba,CreateTube:Js,CreatePolyhedron:No,CreateGeodesic:og,CreateGoldberg:sg,CreateDecal:el,CreateCapsule:Fa,CreateText:lg},Wu=function(){function r(t){if(this._impostors=[],this._meshes=[],this._bodies=[],this._inertiaBodies=[],this._constraints=[],this._bodyMeshes=[],this._inertiaMeshes=[],this._constraintMeshes=[],this._numMeshes=0,this._numBodies=0,this._numInertiaBodies=0,this._numConstraints=0,this._debugMeshMeshes=new Array,this._constraintAxesSize=.4,this._scene=t||Ve.q.LastCreatedScene,this._scene){var e=this._scene.getPhysicsEngine();e&&(this._physicsEnginePlugin=e.getPhysicsPlugin()),this._utilityLayer=new Fn(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0}}return r.prototype._updateDebugMeshes=function(){var t=this._physicsEnginePlugin;t?.getPluginVersion()===1?this._updateDebugMeshesV1():this._updateDebugMeshesV2()},r.prototype._updateDebugMeshesV1=function(){for(var t=this._physicsEnginePlugin,e=0;e<this._numMeshes;e++){var n=this._impostors[e];if(n)if(n.isDisposed)this.hideImpostor(this._impostors[e--]);else{if(n.type===Dt.MeshImpostor)continue;var i=this._meshes[e];i&&t&&t.syncMeshWithImpostor(i,n)}}},r.prototype._updateDebugMeshesV2=function(){for(var t=this._physicsEnginePlugin,e=0;e<this._numBodies;){var n=this._bodies[e];if(!(n&&n.isDisposed&&this.hideBody(n))){var i=this._bodyMeshes[e];n&&i&&t.syncTransform(n,i),e++}}},r.prototype._updateInertiaMeshes=function(){for(var t=0;t<this._numInertiaBodies;){var e=this._inertiaBodies[t];if(!(e&&e.isDisposed&&this.hideInertia(e))){var n=this._inertiaMeshes[t];e&&n&&this._updateDebugInertia(e,n),t++}}},r.prototype._updateDebugInertia=function(t,e){var n,i=_.uq.Identity(),o=_.uq.Identity(),a=_.uq.Identity();if(t._pluginDataInstances.length){for(var s=e,l=s._thinInstanceDataStorage.matrixData,c=t.transformNode._thinInstanceDataStorage.matrixData,u=0;u<t._pluginDataInstances.length;u++){var d=t.getMassProperties(u);this._getMeshDebugInertiaMatrixToRef(d,i),_.uq.FromArrayToRef(c,16*u,o),i.multiplyToRef(o,a),a.copyToArray(l,16*u)}s.thinInstanceBufferUpdated("matrix")}else{if(d=t.getMassProperties(),this._getMeshDebugInertiaMatrixToRef(d,i),(n=t.transformNode.rotationQuaternion)===null||n===void 0||n.toRotationMatrix(o),o.setTranslation(t.transformNode.position),t.transformNode.parent){var h=t.transformNode.parent.computeWorldMatrix(!0);o.multiplyToRef(h,o)}i.multiplyToRef(o,i),i.decomposeToTransformNode(e)}},r.prototype._updateDebugConstraints=function(){for(var t=0;t<this._numConstraints;t++){var e=this._constraints[t],n=this._constraintMeshes[t];e&&n&&this._updateDebugConstraint(e,n)}},r.prototype._makeScalingUnitInPlace=function(t){Math.abs(t.x-1)>pt.bH&&(t.x=1*Math.sign(t.x)),Math.abs(t.y-1)>pt.bH&&(t.y=1*Math.sign(t.y)),Math.abs(t.z-1)>pt.bH&&(t.z=1*Math.sign(t.z))},r.prototype._updateDebugConstraint=function(t,e){var n=this;if(t._initOptions){var i=t._initOptions,o=i.pivotA,a=i.pivotB,s=i.axisA,l=i.axisB,c=i.perpAxisA,u=i.perpAxisB;o&&a&&s&&l&&c&&u&&e.getDescendants(!0).forEach(function(d){var h=d.getDescendants(!0)[0],p=d.getDescendants(!0)[1],m=h.metadata,v=m.parentBody,b=m.parentBodyIndex,E=p.metadata,C=E.childBody,T=E.childBodyIndex,f=n._getTransformFromBodyToRef(v,_.AA.Matrix[0],b),g=n._getTransformFromBodyToRef(C,_.AA.Matrix[1],T);f.decomposeToTransformNode(h),n._makeScalingUnitInPlace(h.scaling),g.decomposeToTransformNode(p),n._makeScalingUnitInPlace(p.scaling);var S=h.getDescendants(!0)[0];S.position.copyFrom(o);var y=p.getDescendants(!0)[0];y.position.copyFrom(a),_.PT.FromRotationMatrixToRef(_.uq.FromXYZAxesToRef(s,c,_.Pq.CrossToRef(s,c,_.AA.Vector3[0]),_.AA.Matrix[0]),S.rotationQuaternion),_.PT.FromRotationMatrixToRef(_.uq.FromXYZAxesToRef(l,u,_.Pq.CrossToRef(l,u,_.AA.Vector3[1]),_.AA.Matrix[1]),y.rotationQuaternion)})}},r.prototype.showImpostor=function(t,e){var n=this;if(!this._scene)return null;for(var i=0;i<this._numMeshes;i++)if(this._impostors[i]==t)return null;var o=this._getDebugMesh(t,e);return o&&(this._impostors[this._numMeshes]=t,this._meshes[this._numMeshes]=o,this._numMeshes===0&&(this._renderFunction=function(){return n._updateDebugMeshes()},this._scene.registerBeforeRender(this._renderFunction)),this._numMeshes++),o},r.prototype.showBody=function(t){var e=this;if(!this._scene)return null;for(var n=0;n<this._numBodies;n++)if(this._bodies[n]==t)return null;var i=this._getDebugBodyMesh(t);return i&&(this._bodies[this._numBodies]=t,this._bodyMeshes[this._numBodies]=i,this._numBodies===0&&(this._renderFunction=function(){return e._updateDebugMeshes()},this._scene.registerBeforeRender(this._renderFunction)),this._numBodies++),i},r.prototype.showInertia=function(t){var e=this;if(!this._scene)return null;for(var n=0;n<this._numInertiaBodies;n++)if(this._inertiaBodies[n]==t)return null;var i=this._getDebugInertiaMesh(t);return i&&(this._inertiaBodies[this._numInertiaBodies]=t,this._inertiaMeshes[this._numInertiaBodies]=i,this._numInertiaBodies===0&&(this._inertiaRenderFunction=function(){return e._updateInertiaMeshes()},this._scene.registerBeforeRender(this._inertiaRenderFunction)),this._numInertiaBodies++),i},r.prototype.showConstraint=function(t){var e=this;if(!this._scene)return null;for(var n=0;n<this._numConstraints;n++)if(this._constraints[n]==t)return null;var i=this._getDebugConstraintMesh(t);return i&&(this._constraints[this._numConstraints]=t,this._constraintMeshes[this._numConstraints]=i,this._numConstraints===0&&(this._constraintRenderFunction=function(){return e._updateDebugConstraints()},this._scene.registerBeforeRender(this._constraintRenderFunction)),this._numConstraints++),i},r.prototype.hideImpostor=function(t){if(t&&this._scene&&this._utilityLayer){for(var e=!1,n=this._utilityLayer.utilityLayerScene,i=0;i<this._numMeshes;i++)if(this._impostors[i]==t){var o=this._meshes[i];if(!o)continue;n.removeMesh(o),o.dispose();var a=this._debugMeshMeshes.indexOf(o);a>-1&&this._debugMeshMeshes.splice(a,1),this._numMeshes--,this._numMeshes>0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),e=!0;break}e&&this._numMeshes===0&&this._scene.unregisterBeforeRender(this._renderFunction)}},r.prototype.hideBody=function(t){if(!t||!this._scene||!this._utilityLayer)return!1;for(var e=!1,n=this._utilityLayer.utilityLayerScene,i=0;i<this._numBodies;i++)if(this._bodies[i]===t){var o=this._bodyMeshes[i];if(!o)continue;n.removeMesh(o),o.dispose(),this._numBodies--,this._numBodies>0?(this._bodyMeshes[i]=this._bodyMeshes[this._numBodies],this._bodies[i]=this._bodies[this._numBodies],this._bodyMeshes[this._numBodies]=null,this._bodies[this._numBodies]=null):(this._bodyMeshes[0]=null,this._bodies[0]=null),e=!0;break}return e&&this._numBodies===0&&this._scene.unregisterBeforeRender(this._renderFunction),e},r.prototype.hideInertia=function(t){if(!t||!this._scene||!this._utilityLayer)return!1;for(var e=!1,n=this._utilityLayer.utilityLayerScene,i=0;i<this._numInertiaBodies;i++)if(this._inertiaBodies[i]===t){var o=this._inertiaMeshes[i];if(!o)continue;n.removeMesh(o),o.dispose(),this._inertiaBodies.splice(i,1),this._inertiaMeshes.splice(i,1),this._numInertiaBodies--,e=!0;break}return e&&this._numInertiaBodies===0&&this._scene.unregisterBeforeRender(this._inertiaRenderFunction),e},r.prototype.hideConstraint=function(t){if(t&&this._scene&&this._utilityLayer){for(var e=!1,n=this._utilityLayer.utilityLayerScene,i=0;i<this._numConstraints;i++)if(this._constraints[i]===t){var o=this._constraintMeshes[i];if(!o)continue;n.removeMesh(o),o.dispose(),this._constraints.splice(i,1),this._constraintMeshes.splice(i,1),this._numConstraints--,this._numConstraints>0?(this._constraints[i]=this._constraints[this._numConstraints],this._constraintMeshes[i]=this._constraintMeshes[this._numConstraints],this._constraints[this._numConstraints]=null,this._constraintMeshes[this._numConstraints]=null):(this._constraints[0]=null,this._constraintMeshes[0]=null),e=!0;break}e&&this._numConstraints===0&&this._scene.unregisterBeforeRender(this._constraintRenderFunction)}},r.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new qt("",t),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=z.v9.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},r.prototype._getDebugInertiaMaterial=function(t){return this._debugInertiaMaterial||(this._debugInertiaMaterial=new qt("",t),this._debugInertiaMaterial.disableLighting=!0,this._debugInertiaMaterial.alpha=0),this._debugInertiaMaterial},r.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=Oi("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.rotationQuaternion=_.PT.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),this._debugBoxMesh.setEnabled(!1)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},r.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=li("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.rotationQuaternion=_.PT.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodySphereViewInstance")},r.prototype._getDebugCapsuleMesh=function(t){return this._debugCapsuleMesh||(this._debugCapsuleMesh=Fa("physicsBodyCapsuleViewMesh",{height:1},t),this._debugCapsuleMesh.rotationQuaternion=_.PT.Identity(),this._debugCapsuleMesh.material=this._getDebugMaterial(t),this._debugCapsuleMesh.setEnabled(!1)),this._debugCapsuleMesh.createInstance("physicsBodyCapsuleViewInstance")},r.prototype._getDebugCylinderMesh=function(t){return this._debugCylinderMesh||(this._debugCylinderMesh=_i("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},t),this._debugCylinderMesh.rotationQuaternion=_.PT.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(t),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyCylinderViewInstance")},r.prototype._getDebugMeshMesh=function(t,e){var n=new xe(t.name,e,null,t);return n.setParent(t),n.position=_.Pq.Zero(),n.material=this._getDebugMaterial(e),this._debugMeshMeshes.push(n),n},r.prototype._getDebugMesh=function(t,e){var n=this;if(!this._utilityLayer||e&&e.parent&&e.parent.physicsImpostor)return null;var i=null,o=this._utilityLayer.utilityLayerScene;if(!t.physicsBody)return O.V.Warn("Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor."),null;switch(t.type){case Dt.BoxImpostor:i=this._getDebugBoxMesh(o),t.getBoxSizeToRef(i.scaling);break;case Dt.SphereImpostor:i=this._getDebugSphereMesh(o);var a=t.getRadius();i.scaling.x=2*a,i.scaling.y=2*a,i.scaling.z=2*a;break;case Dt.CapsuleImpostor:i=this._getDebugCapsuleMesh(o);var s=t.object.getBoundingInfo();i.scaling.x=2*(s.boundingBox.maximum.x-s.boundingBox.minimum.x)*t.object.scaling.x,i.scaling.y=(s.boundingBox.maximum.y-s.boundingBox.minimum.y)*t.object.scaling.y,i.scaling.z=2*(s.boundingBox.maximum.z-s.boundingBox.minimum.z)*t.object.scaling.z;break;case Dt.MeshImpostor:e&&(i=this._getDebugMeshMesh(e,o));break;case Dt.NoImpostor:e?e.getChildMeshes().filter(function(l){return l.physicsImpostor?1:0}).forEach(function(l){if(l.physicsImpostor&&l.getClassName()==="Mesh"){var c=l.getBoundingInfo(),u=c.boundingBox.minimum,d=c.boundingBox.maximum;switch(l.physicsImpostor.type){case Dt.BoxImpostor:(i=n._getDebugBoxMesh(o)).position.copyFrom(u),i.position.addInPlace(d),i.position.scaleInPlace(.5);break;case Dt.SphereImpostor:i=n._getDebugSphereMesh(o);break;case Dt.CylinderImpostor:i=n._getDebugCylinderMesh(o);break;default:i=null}i&&(i.scaling.x=d.x-u.x,i.scaling.y=d.y-u.y,i.scaling.z=d.z-u.z,i.parent=l)}}):O.V.Warn("No target mesh parameter provided for NoImpostor. Skipping."),i=null;break;case Dt.CylinderImpostor:i=this._getDebugCylinderMesh(o),s=t.object.getBoundingInfo(),i.scaling.x=(s.boundingBox.maximum.x-s.boundingBox.minimum.x)*t.object.scaling.x,i.scaling.y=(s.boundingBox.maximum.y-s.boundingBox.minimum.y)*t.object.scaling.y,i.scaling.z=(s.boundingBox.maximum.z-s.boundingBox.minimum.z)*t.object.scaling.z}return i},r.prototype._getDebugBodyMesh=function(t){if(!this._utilityLayer)return null;var e=this._utilityLayer.utilityLayerScene,n=new xe("custom",e),i=new rt,o=t.getGeometry();if(i.positions=o.positions,i.indices=o.indices,i.applyToMesh(n),t._pluginDataInstances){var a=new Float32Array(16*t._pluginDataInstances.length);n.thinInstanceSetBuffer("matrix",a,16,!1)}return n.material=this._getDebugMaterial(e),n},r.prototype._getMeshDebugInertiaMatrixToRef=function(t,e){var n,i,o,a=(n=t.inertiaOrientation)!==null&&n!==void 0?n:_.PT.Identity(),s=(i=t.inertia)!==null&&i!==void 0?i:_.Pq.Zero(),l=(o=t.centerOfMass)!==null&&o!==void 0?o:_.Pq.Zero(),c=6*(s.x-s.y+s.z),u=Math.sqrt(Math.max(c,0)),d=12*s.x-c,h=Math.sqrt(Math.max(d,0)),p=12*s.z-c,m=Math.sqrt(Math.max(p,0)),v=_.AA.Vector3[0];v.set(m,u,h);var b=_.uq.ScalingToRef(v.x,v.y,v.z,_.AA.Matrix[0]),E=a.toRotationMatrix(_.AA.Matrix[1]),C=_.uq.TranslationToRef(l.x,l.y,l.z,_.AA.Matrix[2]);return b.multiplyToRef(E,e),e.multiplyToRef(C,e),e},r.prototype._getDebugInertiaMesh=function(t){if(!this._utilityLayer)return null;var e=this._utilityLayer.utilityLayerScene,n=cg.CreateBox("custom",{size:1},e),i=_.uq.Identity();if(t._pluginDataInstances.length){for(var o=new Float32Array(16*t._pluginDataInstances.length),a=0;a<t._pluginDataInstances.length;++a){var s=t.getMassProperties(a);this._getMeshDebugInertiaMatrixToRef(s,i),i.copyToArray(o,16*a)}n.thinInstanceSetBuffer("matrix",o,16,!1)}else s=t.getMassProperties(),this._getMeshDebugInertiaMatrixToRef(s,i),i.decomposeToTransformNode(n);return n.enableEdgesRendering(),n.edgesWidth=2,n.edgesColor=new z.ov(1,0,1,1),n.material=this._getDebugInertiaMaterial(e),n},r.prototype._getTransformFromBodyToRef=function(t,e,n){var i=t.transformNode;return n&&n>=0?_.uq.FromArrayToRef(i._thinInstanceDataStorage.matrixData,n,e):e.copyFrom(i.getWorldMatrix())},r.prototype._getDebugConstraintMesh=function(t){if(!this._utilityLayer)return null;var e=this._utilityLayer.utilityLayerScene;if(!t._initOptions)return null;var n=t._initOptions,i=n.pivotA,o=n.pivotB,a=n.axisA,s=n.axisB,l=n.perpAxisA,c=n.perpAxisB;if(!(i&&o&&a&&s&&l&&c))return null;for(var u=new xe("parentingDebugConstraint",e),d=0,h=t.getBodiesUsingConstraint();d<h.length;d++){var p=h[d],m=new jt("parentOfPair",e);m.parent=u;var v=p.parentBody,b=p.parentBodyIndex,E=p.childBody,C=p.childBodyIndex,T=this._getTransformFromBodyToRef(v,_.AA.Matrix[0],b),f=this._getTransformFromBodyToRef(E,_.AA.Matrix[1],C),g=new jt("parentCoordSystem",e);g.parent=m,g.metadata={parentBody:v,parentBodyIndex:b},T.decomposeToTransformNode(g);var S=new jt("childCoordSystem",e);S.parent=m,S.metadata={childBody:E,childBodyIndex:C},f.decomposeToTransformNode(S);var y=_.PT.FromRotationMatrix(_.uq.FromXYZAxesToRef(a,l,a.cross(l),_.AA.Matrix[0])),x=_.PT.FromRotationMatrix(_.uq.FromXYZAxesToRef(s,c,s.cross(c),_.AA.Matrix[0])),R=i,I=o,M=new jt("constraint_parent",e);M.position.copyFrom(R),M.rotationQuaternion=y,M.parent=g;var D=new jt("constraint_child",e);D.parent=S,D.position.copyFrom(I),D.rotationQuaternion=x;var B=new ia(e,this._constraintAxesSize);B.xAxis.parent=M,B.yAxis.parent=M,B.zAxis.parent=M;var F=new ia(e,this._constraintAxesSize);F.xAxis.parent=D,F.yAxis.parent=D,F.zAxis.parent=D}return u},r.prototype.dispose=function(){for(var t=this._numMeshes-1;t>=0;t--)this.hideImpostor(this._impostors[0]);for(t=this._numBodies-1;t>=0;t--)this.hideBody(this._bodies[0]);for(t=this._numInertiaBodies-1;t>=0;t--)this.hideInertia(this._inertiaBodies[0]);this._debugBoxMesh&&this._debugBoxMesh.dispose(),this._debugSphereMesh&&this._debugSphereMesh.dispose(),this._debugCylinderMesh&&this._debugCylinderMesh.dispose(),this._debugMaterial&&this._debugMaterial.dispose(),this._impostors.length=0,this._scene=null,this._physicsEnginePlugin=null,this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null)},r}(),ug=function(){function r(t){this.ray=t}return r.CreateAndShow=function(t,e,n){var i=new r(t);return i.show(e,n),i},r.prototype.show=function(t,e){var n=this;if(!this._renderFunction&&this.ray){var i=this.ray;this._renderFunction=function(){return n._render()},this._scene=t,this._renderPoints=[i.origin,i.origin.add(i.direction.scale(i.length))],this._renderLine=dn("ray",{points:this._renderPoints,updatable:!0},t),this._renderLine.isPickable=!1,this._renderFunction&&this._scene.registerBeforeRender(this._renderFunction)}e&&this._renderLine&&this._renderLine.color.copyFrom(e)},r.prototype.hide=function(){this._renderFunction&&this._scene&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine&&(this._renderLine.dispose(),this._renderLine=null),this._renderPoints=[])},r.prototype._render=function(){var t,e=this.ray;if(e){var n=this._renderPoints[1],i=Math.min(e.length,1e6);n.copyFrom(e.direction),n.scaleInPlace(i),n.addInPlace(e.origin),this._renderPoints[0].copyFrom(e.origin),dn("ray",{points:this._renderPoints,updatable:!0,instance:this._renderLine},this._scene),(t=this._renderLine)===null||t===void 0||t.refreshBoundingInfo()}},r.prototype.attachToMesh=function(t,e,n,i){var o=this;this._attachedToMesh=t;var a=this.ray;a&&(a.direction||(a.direction=_.Pq.Zero()),a.origin||(a.origin=_.Pq.Zero()),i&&(a.length=i),n||(n=_.Pq.Zero()),e||(e=new _.Pq(0,0,-1)),this._scene||(this._scene=t.getScene()),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(e),this._meshSpaceOrigin.copyFrom(n)):(this._meshSpaceDirection=e.clone(),this._meshSpaceOrigin=n.clone()),this._onAfterRenderObserver||(this._onAfterRenderObserver=this._scene.onBeforeRenderObservable.add(function(){return o._updateToMesh()}),this._onAfterStepObserver=this._scene.onAfterStepObservable.add(function(){return o._updateToMesh()})),this._attachedToMesh.computeWorldMatrix(!0),this._updateToMesh())},r.prototype.detachFromMesh=function(){this._attachedToMesh&&this._scene&&(this._onAfterRenderObserver&&(this._scene.onBeforeRenderObservable.remove(this._onAfterRenderObserver),this._scene.onAfterStepObservable.remove(this._onAfterStepObserver)),this._attachedToMesh=null,this._onAfterRenderObserver=null,this._onAfterStepObserver=null,this._scene=null)},r.prototype._updateToMesh=function(){var t=this.ray;this._attachedToMesh&&t&&(this._attachedToMesh.isDisposed()?this.detachFromMesh():(this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),_.Pq.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)))},r.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},r}(),ti=L(74239),Hu=function(){function r(t,e,n,i,o,a){var s,l,c,u,d,h,p,m,v,b,E,C,T,f;if(i===void 0&&(i=!0),o===void 0&&(o=3),a===void 0&&(a={}),this.skeleton=t,this.mesh=e,this.autoUpdateBonesMatrices=i,this.renderingGroupId=o,this.options=a,this.color=z.v9.White(),this._debugLines=new Array,this._localAxes=null,this._isEnabled=!0,this._obs=null,this._scene=n,this._ready=!1,a.pauseAnimations=(s=a.pauseAnimations)===null||s===void 0||s,a.returnToRest=(l=a.returnToRest)!==null&&l!==void 0&&l,a.displayMode=(c=a.displayMode)!==null&&c!==void 0?c:r.DISPLAY_LINES,a.displayOptions=(u=a.displayOptions)!==null&&u!==void 0?u:{},a.displayOptions.midStep=(d=a.displayOptions.midStep)!==null&&d!==void 0?d:.235,a.displayOptions.midStepFactor=(h=a.displayOptions.midStepFactor)!==null&&h!==void 0?h:.155,a.displayOptions.sphereBaseSize=(p=a.displayOptions.sphereBaseSize)!==null&&p!==void 0?p:.15,a.displayOptions.sphereScaleUnit=(m=a.displayOptions.sphereScaleUnit)!==null&&m!==void 0?m:2,a.displayOptions.sphereFactor=(v=a.displayOptions.sphereFactor)!==null&&v!==void 0?v:.865,a.displayOptions.spurFollowsChild=(b=a.displayOptions.spurFollowsChild)!==null&&b!==void 0&&b,a.displayOptions.showLocalAxes=(E=a.displayOptions.showLocalAxes)!==null&&E!==void 0&&E,a.displayOptions.localAxesSize=(C=a.displayOptions.localAxesSize)!==null&&C!==void 0?C:.075,a.computeBonesUsingShaders=(T=a.computeBonesUsingShaders)===null||T===void 0||T,a.useAllBones=(f=a.useAllBones)===null||f===void 0||f,this._boneIndices=new Set,!a.useAllBones){var g=e?.getVerticesData(Y.R.MatricesIndicesKind),S=e?.getVerticesData(Y.R.MatricesWeightsKind);if(g&&S)for(var y=0;y<g.length;++y){var x=g[y];S[y]!==0&&this._boneIndices.add(x)}}this._utilityLayer=new Fn(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0;var R=this.options.displayMode||0;R>r.DISPLAY_SPHERE_AND_SPURS&&(R=r.DISPLAY_LINES),this.displayMode=R,this.update(),this._bindObs()}return r.CreateBoneWeightShader=function(t,e){var n,i,o,a,s,l,c=t.skeleton,u=(n=t.colorBase)!==null&&n!==void 0?n:z.v9.Black(),d=(i=t.colorZero)!==null&&i!==void 0?i:z.v9.Blue(),h=(o=t.colorQuarter)!==null&&o!==void 0?o:z.v9.Green(),p=(a=t.colorHalf)!==null&&a!==void 0?a:z.v9.Yellow(),m=(s=t.colorFull)!==null&&s!==void 0?s:z.v9.Red(),v=(l=t.targetBoneIndex)!==null&&l!==void 0?l:0;ti.M.ShadersStore["boneWeights:"+c.name+"VertexShader"]=`precision highp float;
|
||
|
||
attribute vec3 position;
|
||
attribute vec2 uv;
|
||
|
||
uniform mat4 view;
|
||
uniform mat4 projection;
|
||
uniform mat4 worldViewProjection;
|
||
|
||
#include<bonesDeclaration>
|
||
#if NUM_BONE_INFLUENCERS == 0
|
||
attribute vec4 matricesIndices;
|
||
attribute vec4 matricesWeights;
|
||
#endif
|
||
#include<bakedVertexAnimationDeclaration>
|
||
|
||
#include<instancesDeclaration>
|
||
|
||
varying vec3 vColor;
|
||
|
||
uniform vec3 colorBase;
|
||
uniform vec3 colorZero;
|
||
uniform vec3 colorQuarter;
|
||
uniform vec3 colorHalf;
|
||
uniform vec3 colorFull;
|
||
|
||
uniform float targetBoneIndex;
|
||
|
||
void main() {
|
||
vec3 positionUpdated = position;
|
||
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
|
||
vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
|
||
|
||
vec3 color = colorBase;
|
||
float totalWeight = 0.;
|
||
if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){
|
||
totalWeight += matricesWeights[0];
|
||
}
|
||
if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){
|
||
totalWeight += matricesWeights[1];
|
||
}
|
||
if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){
|
||
totalWeight += matricesWeights[2];
|
||
}
|
||
if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){
|
||
totalWeight += matricesWeights[3];
|
||
}
|
||
|
||
color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));
|
||
color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));
|
||
color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));
|
||
color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));
|
||
vColor = color;
|
||
|
||
gl_Position = projection * view * worldPos;
|
||
}`,ti.M.ShadersStore["boneWeights:"+c.name+"FragmentShader"]=`
|
||
precision highp float;
|
||
varying vec3 vPosition;
|
||
|
||
varying vec3 vColor;
|
||
|
||
void main() {
|
||
vec4 color = vec4(vColor, 1.0);
|
||
gl_FragColor = color;
|
||
}
|
||
`;var b=new pi("boneWeight:"+c.name,e,{vertex:"boneWeights:"+c.name,fragment:"boneWeights:"+c.name},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorBase","colorZero","colorQuarter","colorHalf","colorFull","targetBoneIndex"]});return b.setColor3("colorBase",u),b.setColor3("colorZero",d),b.setColor3("colorQuarter",h),b.setColor3("colorHalf",p),b.setColor3("colorFull",m),b.setFloat("targetBoneIndex",v),b.getClassName=function(){return"BoneWeightShader"},b.transparencyMode=Lt.MATERIAL_OPAQUE,b},r.CreateSkeletonMapShader=function(t,e){var n,i=t.skeleton,o=(n=t.colorMap)!==null&&n!==void 0?n:[{color:new z.v9(1,.38,.18),location:0},{color:new z.v9(.59,.18,1),location:.2},{color:new z.v9(.59,1,.18),location:.4},{color:new z.v9(1,.87,.17),location:.6},{color:new z.v9(1,.17,.42),location:.8},{color:new z.v9(.17,.68,1),location:1}],a=i.bones.length+1,s=r._CreateBoneMapColorBuffer(a,o,e),l=new pi("boneWeights:"+i.name,e,{vertexSource:`precision highp float;
|
||
|
||
attribute vec3 position;
|
||
attribute vec2 uv;
|
||
|
||
uniform mat4 view;
|
||
uniform mat4 projection;
|
||
uniform mat4 worldViewProjection;
|
||
uniform float colorMap[`+4*i.bones.length+`];
|
||
|
||
#include<bonesDeclaration>
|
||
#if NUM_BONE_INFLUENCERS == 0
|
||
attribute vec4 matricesIndices;
|
||
attribute vec4 matricesWeights;
|
||
#endif
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<instancesDeclaration>
|
||
|
||
varying vec3 vColor;
|
||
|
||
void main() {
|
||
vec3 positionUpdated = position;
|
||
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
|
||
vec3 color = vec3(0.);
|
||
bool first = true;
|
||
|
||
for (int i = 0; i < 4; i++) {
|
||
int boneIdx = int(matricesIndices[i]);
|
||
float boneWgt = matricesWeights[i];
|
||
|
||
vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);
|
||
|
||
if (boneWgt > 0.) {
|
||
if (first) {
|
||
first = false;
|
||
color = c;
|
||
} else {
|
||
color = mix(color, c, boneWgt);
|
||
}
|
||
}
|
||
}
|
||
|
||
vColor = color;
|
||
|
||
vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
|
||
|
||
gl_Position = projection * view * worldPos;
|
||
}`,fragmentSource:`
|
||
precision highp float;
|
||
varying vec3 vColor;
|
||
|
||
void main() {
|
||
vec4 color = vec4( vColor, 1.0 );
|
||
gl_FragColor = color;
|
||
}
|
||
`},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorMap"]});return l.setFloats("colorMap",s),l.getClassName=function(){return"SkeletonMapShader"},l.transparencyMode=Lt.MATERIAL_OPAQUE,l},r._CreateBoneMapColorBuffer=function(t,e,n){var i=new Oo("temp",{width:t,height:1},n,!1),o=i.getContext(),a=o.createLinearGradient(0,0,t,0);e.forEach(function(d){a.addColorStop(d.location,d.color.toHexString())}),o.fillStyle=a,o.fillRect(0,0,t,1),i.update();for(var s=[],l=o.getImageData(0,0,t,1).data,c=1/255,u=0;u<l.length;u++)s.push(l[u]*c);return i.dispose(),s},Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"utilityLayer",{get:function(){return this._utilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isReady",{get:function(){return this._ready},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ready",{set:function(t){this._ready=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"debugMesh",{get:function(){return this._debugMesh},set:function(t){this._debugMesh=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"displayMode",{get:function(){return this.options.displayMode||r.DISPLAY_LINES},set:function(t){t>r.DISPLAY_SPHERE_AND_SPURS&&(t=r.DISPLAY_LINES),this.options.displayMode=t},enumerable:!1,configurable:!0}),r.prototype._bindObs=function(){var t=this;this.displayMode===r.DISPLAY_LINES&&(this._obs=this.scene.onBeforeRenderObservable.add(function(){t._displayLinesUpdate()}))},r.prototype.update=function(){switch(this.displayMode){case r.DISPLAY_LINES:this._displayLinesUpdate();break;case r.DISPLAY_SPHERES:this._buildSpheresAndSpurs(!0);break;case r.DISPLAY_SPHERE_AND_SPURS:this._buildSpheresAndSpurs(!1)}this._buildLocalAxes()},Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this.isEnabled!==t&&(this._isEnabled=t,this.debugMesh&&this.debugMesh.setEnabled(t),t&&!this._obs?this._bindObs():!t&&this._obs&&(this.scene.onBeforeRenderObservable.remove(this._obs),this._obs=null))},enumerable:!1,configurable:!0}),r.prototype._getBonePosition=function(t,e,n,i,o,a){i===void 0&&(i=0),o===void 0&&(o=0),a===void 0&&(a=0);var s=_.AA.Matrix[0],l=e.getParent();if(s.copyFrom(e.getLocalMatrix()),i!==0||o!==0||a!==0){var c=_.AA.Matrix[1];_.uq.IdentityToRef(c),c.setTranslationFromFloats(i,o,a),c.multiplyToRef(s,s)}l&&s.multiplyToRef(l.getAbsoluteMatrix(),s),s.multiplyToRef(n,s),t.x=s.m[12],t.y=s.m[13],t.z=s.m[14]},r.prototype._getLinesForBonesWithLength=function(t,e){var n,i,o=t.length;e?(n=e.getWorldMatrix(),i=e.position):(n=new _.uq,i=t[0].position);for(var a=0,s=0;s<o;s++){var l=t[s],c=this._debugLines[a];l._index!==-1&&(this._boneIndices.has(l.getIndex())||this.options.useAllBones)&&(c||(c=[_.Pq.Zero(),_.Pq.Zero()],this._debugLines[a]=c),this._getBonePosition(c[0],l,n),this._getBonePosition(c[1],l,n,0,l.length,0),c[0].subtractInPlace(i),c[1].subtractInPlace(i),a++)}},r.prototype._getLinesForBonesNoLength=function(t){var e,n,i=t.length,o=0,a=this.mesh;a?(e=a,n=a.position):(e=new jt(""),n=t[0].position);for(var s=i-1;s>=0;s--){var l=t[s],c=l.getParent();if(c&&(this._boneIndices.has(l.getIndex())||this.options.useAllBones)){var u=this._debugLines[o];u||(u=[_.Pq.Zero(),_.Pq.Zero()],this._debugLines[o]=u),l.getAbsolutePositionToRef(e,u[0]),c.getAbsolutePositionToRef(e,u[1]),u[0].subtractInPlace(n),u[1].subtractInPlace(n),o++}}a||e.dispose()},r.prototype._revert=function(t){this.options.pauseAnimations&&(this.scene.animationsEnabled=t,this.utilityLayer.utilityLayerScene.animationsEnabled=t)},r.prototype._getAbsoluteBindPoseToRef=function(t,e){t!==null&&t._index!==-1?(this._getAbsoluteBindPoseToRef(t.getParent(),e),t.getBindMatrix().multiplyToRef(e,e)):e.copyFrom(_.uq.Identity())},r.prototype._createSpur=function(t,e,n,i,o,a){for(var s=n.subtract(t),l=s.length(),c=s.normalize().scale(l),u=o.midStep||.165,d=o.midStepFactor||.215,h=c.scale(u),p=Ua("skeletonViewer",{shape:[new _.Pq(1,-1,0),new _.Pq(1,1,0),new _.Pq(-1,1,0),new _.Pq(-1,-1,0),new _.Pq(1,-1,0)],path:[_.Pq.Zero(),h,c],scaleFunction:function(C){switch(C){case 0:case 2:return 0;case 1:return l*d}return 0},sideOrientation:xe.DEFAULTSIDE,updatable:!1},a),m=p.getTotalVertices(),v=[],b=[],E=0;E<m;E++)v.push(1,0,0,0),i&&o.spurFollowsChild&&E>9?b.push(i.getIndex(),0,0,0):b.push(e.getIndex(),0,0,0);return p.position=t.clone(),p.setVerticesData(Y.R.MatricesWeightsKind,v,!1),p.setVerticesData(Y.R.MatricesIndicesKind,b,!1),p.convertToFlatShadedMesh(),p},r.prototype._getBoundingSphereForBone=function(t){if(!this.mesh)return null;var e=this.mesh.getVerticesData(Y.R.PositionKind),n=this.mesh.getIndices(),i=this.mesh.getVerticesData(Y.R.MatricesWeightsKind),o=this.mesh.getVerticesData(Y.R.MatricesIndicesKind);if(!(e&&n&&i&&o))return null;for(var a=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new _.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=0,c=0;c<n.length;++c)for(var u=n[c],d=0;d<4;++d){var h=o[4*u+d],p=i[4*u+d];if(h===t&&p>1e-5){_.Pq.FromArrayToRef(e,3*u,_.AA.Vector3[0]),a.minimizeInPlace(_.AA.Vector3[0]),s.maximizeInPlace(_.AA.Vector3[0]),l++;break}}return l>1?{center:_.Pq.Center(a,s),radius:_.Pq.Distance(a,s)/2}:null},r.prototype._buildSpheresAndSpurs=function(t){var e,n,i,o=this;t===void 0&&(t=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var a=(n=this.utilityLayer)===null||n===void 0?void 0:n.utilityLayerScene,s=this.skeleton.bones,l=[],c=[],u=this.scene.animationsEnabled;try{this.options.pauseAnimations&&(this.scene.animationsEnabled=!1,a.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteMatrices();for(var d=Number.NEGATIVE_INFINITY,h=this.options.displayOptions||{},p=function(x){var R=s[x];if(R._index===-1||!m._boneIndices.has(R.getIndex())&&!m.options.useAllBones)return"continue";var I=new _.uq;m._getAbsoluteBindPoseToRef(R,I);var M=new _.Pq;if(I.decompose(void 0,void 0,M),R.children.length>0)R.children.forEach(function(ee){var te=new _.uq;ee.getLocalMatrix().multiplyToRef(I,te);var ce=new _.Pq;te.decompose(void 0,void 0,ce);var fe=_.Pq.Distance(M,ce);fe>d&&(d=fe),t||c.push(o._createSpur(M,R,ce,ee,h,a))});else{var D=m._getBoundingSphereForBone(R.getIndex());if(D&&(D.radius>d&&(d=D.radius),!t)){var B=void 0,F=R.getParent();F?(m._getAbsoluteBindPoseToRef(F,I),I.decompose(void 0,void 0,_.AA.Vector3[0]),B=M.subtract(_.AA.Vector3[0]).normalize().scale(D.radius).add(M)):B=D.center.subtract(M).normalize().scale(D.radius).add(M),c.push(m._createSpur(M,R,B,null,h,a))}}for(var X=li("skeletonViewer",{segments:6,diameter:h.sphereBaseSize||.2,updatable:!0},a),$=X.getTotalVertices(),Q=[],ie=[],q=0;q<$;q++)Q.push(1,0,0,0),ie.push(R.getIndex(),0,0,0);X.setVerticesData(Y.R.MatricesWeightsKind,Q,!1),X.setVerticesData(Y.R.MatricesIndicesKind,ie,!1),X.position=M.clone(),l.push([X,R])},m=this,v=0;v<s.length;v++)p(v);var b=h.sphereScaleUnit||2,E=h.sphereFactor||.85,C=[];for(v=0;v<l.length;v++){for(var T=(e=l[v])[0],f=e[1],g=1/(b/d),S=0,y=f;y.getParent()&&y.getParent().getIndex()!==-1;)S++,y=y.getParent();T.scaling.scaleInPlace(g*Math.pow(E,S)),C.push(T)}this.debugMesh=xe.MergeMeshes(C.concat(c),!0,!0),this.debugMesh&&(this.debugMesh.renderingGroupId=this.renderingGroupId,this.debugMesh.skeleton=this.skeleton,this.debugMesh.parent=this.mesh,this.debugMesh.computeBonesUsingShaders=(i=this.options.computeBonesUsingShaders)===null||i===void 0||i,this.debugMesh.alwaysSelectAsActiveMesh=!0),this.utilityLayer._getSharedGizmoLight().intensity=.7,this._revert(u),this.ready=!0}catch(x){O.V.Error(x),this._revert(u),this.dispose()}},r.prototype._buildLocalAxes=function(){var t;this._localAxes&&this._localAxes.dispose(),this._localAxes=null;var e=this.options.displayOptions||{};if(e.showLocalAxes){var n=this._utilityLayer.utilityLayerScene,i=e.localAxesSize||.075,o=[],a=[],s=new z.ov(1,0,0,1),l=new z.ov(0,1,0,1),c=new z.ov(0,0,1,1),u=[],d=[];for(var h in this.skeleton.bones){var p=this.skeleton.bones[h];if(p._index!==-1&&(this._boneIndices.has(p.getIndex())||this.options.useAllBones)){var m=new _.uq,v=new _.Pq;this._getAbsoluteBindPoseToRef(p,m),m.decompose(void 0,_.AA.Quaternion[0],v);var b=new _.uq;_.AA.Quaternion[0].toRotationMatrix(b);var E=_.Pq.TransformCoordinates(new _.Pq(0+i,0,0),b),C=_.Pq.TransformCoordinates(new _.Pq(0,0+i,0),b),T=_.Pq.TransformCoordinates(new _.Pq(0,0,0+i),b),f=[[v,v.add(E)],[v,v.add(C)],[v,v.add(T)]],g=[[s,s],[l,l],[c,c]];o.push.apply(o,f),a.push.apply(a,g);for(var S=0;S<6;S++)u.push(1,0,0,0),d.push(p.getIndex(),0,0,0)}}this._localAxes=Do("localAxes",{lines:o,colors:a,updatable:!0},n),this._localAxes.setVerticesData(Y.R.MatricesWeightsKind,u,!1),this._localAxes.setVerticesData(Y.R.MatricesIndicesKind,d,!1),this._localAxes.skeleton=this.skeleton,this._localAxes.renderingGroupId=this.renderingGroupId+1,this._localAxes.parent=this.mesh,this._localAxes.computeBonesUsingShaders=(t=this.options.computeBonesUsingShaders)===null||t===void 0||t}},r.prototype._displayLinesUpdate=function(){if(this._utilityLayer){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteMatrices(),this.skeleton.bones[0].length===void 0?this._getLinesForBonesNoLength(this.skeleton.bones):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh);var t=this._utilityLayer.utilityLayerScene;t&&(this._debugMesh?Do("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},t):(this._debugMesh=Do("",{lines:this._debugLines,updatable:!0,instance:null},t),this._debugMesh.renderingGroupId=this.renderingGroupId),this.mesh?this._debugMesh.position.copyFrom(this.mesh.position):this._debugMesh.position.copyFrom(this.skeleton.bones[0].position),this._debugMesh.color=this.color)}},r.prototype.changeDisplayMode=function(t){var e=!!this.isEnabled;this.displayMode!==t&&(this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this.displayMode=t,this.update(),this._bindObs(),this.isEnabled=e)},r.prototype.changeDisplayOptions=function(t,e){var n=!!this.isEnabled;this.options.displayOptions[t]=e,this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this.update(),this._bindObs(),this.isEnabled=n},r.prototype.dispose=function(){this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null),this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null),this.ready=!1},r.DISPLAY_LINES=0,r.DISPLAY_SPHERES=1,r.DISPLAY_SPHERE_AND_SPURS=2,r}(),dg=function(){function r(t,e){this._oldPosition=new _.Pq(Number.NaN,Number.NaN,Number.NaN),this._oldDirection=new _.Pq(Number.NaN,Number.NaN,Number.NaN),this._transparency=.3,this._showLines=!0,this._showPlanes=!0,this._scene=t.getScene(),this._light=t,this._camera=e,this._inverseViewMatrix=_.uq.Identity(),this._lightHelperFrustumMeshes=[],this._createGeometry(),this.show(),this.update()}return Object.defineProperty(r.prototype,"transparency",{get:function(){return this._transparency},set:function(t){this._transparency=t;for(var e=6;e<12;++e)this._lightHelperFrustumMeshes[e].material.alpha=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"showLines",{get:function(){return this._showLines},set:function(t){if(this._showLines!==t){this._showLines=t;for(var e=0;e<6;++e)this._lightHelperFrustumMeshes[e].setEnabled(t)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"showPlanes",{get:function(){return this._showPlanes},set:function(t){if(this._showPlanes!==t){this._showPlanes=t;for(var e=6;e<12;++e)this._lightHelperFrustumMeshes[e].setEnabled(t)}},enumerable:!1,configurable:!0}),r.prototype.show=function(){var t=this;this._lightHelperFrustumMeshes.forEach(function(e,n){e.setEnabled(n<6&&t._showLines||n>=6&&t._showPlanes)}),this._oldPosition.set(Number.NaN,Number.NaN,Number.NaN),this._visible=!0},r.prototype.hide=function(){this._lightHelperFrustumMeshes.forEach(function(t){t.setEnabled(!1)}),this._visible=!1},r.prototype.update=function(){var t,e,n,i,o,a;if(this._visible&&(!this._oldPosition.equals(this._light.position)||!this._oldDirection.equals(this._light.direction)||this._oldAutoCalc!==this._light.autoCalcShadowZBounds||this._oldMinZ!==this._light.shadowMinZ||this._oldMaxZ!==this._light.shadowMaxZ)){this._oldPosition.copyFrom(this._light.position),this._oldDirection.copyFrom(this._light.direction),this._oldAutoCalc=this._light.autoCalcShadowZBounds,this._oldMinZ=this._light.shadowMinZ,this._oldMaxZ=this._light.shadowMaxZ,_.AA.Vector3[0].set(this._light.orthoLeft,this._light.orthoBottom,this._light.shadowMinZ!==void 0?this._light.shadowMinZ:this._camera.minZ),_.AA.Vector3[1].set(this._light.orthoRight,this._light.orthoTop,this._light.shadowMaxZ!==void 0?this._light.shadowMaxZ:this._camera.maxZ);var s=this._getInvertViewMatrix();_.AA.Vector3[2].copyFromFloats(_.AA.Vector3[1].x,_.AA.Vector3[1].y,_.AA.Vector3[0].z),_.AA.Vector3[3].copyFromFloats(_.AA.Vector3[1].x,_.AA.Vector3[0].y,_.AA.Vector3[0].z),_.AA.Vector3[4].copyFromFloats(_.AA.Vector3[0].x,_.AA.Vector3[0].y,_.AA.Vector3[0].z),_.AA.Vector3[5].copyFromFloats(_.AA.Vector3[0].x,_.AA.Vector3[1].y,_.AA.Vector3[0].z),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[2],s,_.AA.Vector3[2]),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[3],s,_.AA.Vector3[3]),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[4],s,_.AA.Vector3[4]),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[5],s,_.AA.Vector3[5]),_.AA.Vector3[6].copyFromFloats(_.AA.Vector3[1].x,_.AA.Vector3[1].y,_.AA.Vector3[1].z),_.AA.Vector3[7].copyFromFloats(_.AA.Vector3[1].x,_.AA.Vector3[0].y,_.AA.Vector3[1].z),_.AA.Vector3[8].copyFromFloats(_.AA.Vector3[0].x,_.AA.Vector3[0].y,_.AA.Vector3[1].z),_.AA.Vector3[9].copyFromFloats(_.AA.Vector3[0].x,_.AA.Vector3[1].y,_.AA.Vector3[1].z),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[6],s,_.AA.Vector3[6]),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[7],s,_.AA.Vector3[7]),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[8],s,_.AA.Vector3[8]),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[9],s,_.AA.Vector3[9]),dn("nearlines",{updatable:!0,points:this._nearLinesPoints,instance:this._lightHelperFrustumMeshes[0]},this._scene),dn("farlines",{updatable:!0,points:this._farLinesPoints,instance:this._lightHelperFrustumMeshes[1]},this._scene),dn("trlines",{updatable:!0,points:this._trLinesPoints,instance:this._lightHelperFrustumMeshes[2]},this._scene),dn("brlines",{updatable:!0,points:this._brLinesPoints,instance:this._lightHelperFrustumMeshes[3]},this._scene),dn("tllines",{updatable:!0,points:this._tlLinesPoints,instance:this._lightHelperFrustumMeshes[4]},this._scene),dn("bllines",{updatable:!0,points:this._blLinesPoints,instance:this._lightHelperFrustumMeshes[5]},this._scene),_.AA.Vector3[2].toArray(this._nearPlaneVertices,0),_.AA.Vector3[3].toArray(this._nearPlaneVertices,3),_.AA.Vector3[4].toArray(this._nearPlaneVertices,6),_.AA.Vector3[5].toArray(this._nearPlaneVertices,9),(t=this._lightHelperFrustumMeshes[6].geometry)===null||t===void 0||t.updateVerticesDataDirectly("position",this._nearPlaneVertices,0),_.AA.Vector3[6].toArray(this._farPlaneVertices,0),_.AA.Vector3[7].toArray(this._farPlaneVertices,3),_.AA.Vector3[8].toArray(this._farPlaneVertices,6),_.AA.Vector3[9].toArray(this._farPlaneVertices,9),(e=this._lightHelperFrustumMeshes[7].geometry)===null||e===void 0||e.updateVerticesDataDirectly("position",this._farPlaneVertices,0),_.AA.Vector3[2].toArray(this._rightPlaneVertices,0),_.AA.Vector3[6].toArray(this._rightPlaneVertices,3),_.AA.Vector3[7].toArray(this._rightPlaneVertices,6),_.AA.Vector3[3].toArray(this._rightPlaneVertices,9),(n=this._lightHelperFrustumMeshes[8].geometry)===null||n===void 0||n.updateVerticesDataDirectly("position",this._rightPlaneVertices,0),_.AA.Vector3[5].toArray(this._leftPlaneVertices,0),_.AA.Vector3[9].toArray(this._leftPlaneVertices,3),_.AA.Vector3[8].toArray(this._leftPlaneVertices,6),_.AA.Vector3[4].toArray(this._leftPlaneVertices,9),(i=this._lightHelperFrustumMeshes[9].geometry)===null||i===void 0||i.updateVerticesDataDirectly("position",this._leftPlaneVertices,0),_.AA.Vector3[2].toArray(this._topPlaneVertices,0),_.AA.Vector3[6].toArray(this._topPlaneVertices,3),_.AA.Vector3[9].toArray(this._topPlaneVertices,6),_.AA.Vector3[5].toArray(this._topPlaneVertices,9),(o=this._lightHelperFrustumMeshes[10].geometry)===null||o===void 0||o.updateVerticesDataDirectly("position",this._topPlaneVertices,0),_.AA.Vector3[3].toArray(this._bottomPlaneVertices,0),_.AA.Vector3[7].toArray(this._bottomPlaneVertices,3),_.AA.Vector3[8].toArray(this._bottomPlaneVertices,6),_.AA.Vector3[4].toArray(this._bottomPlaneVertices,9),(a=this._lightHelperFrustumMeshes[11].geometry)===null||a===void 0||a.updateVerticesDataDirectly("position",this._bottomPlaneVertices,0)}},r.prototype.dispose=function(){this._lightHelperFrustumMeshes.forEach(function(t){var e;(e=t.material)===null||e===void 0||e.dispose(),t.dispose()}),this._rootNode.dispose()},r.prototype._createGeometry=function(){var t=this;this._rootNode=new jt("directionalLightHelperRoot_"+this._light.name,this._scene),this._rootNode.parent=this._light.parent,this._nearLinesPoints=[_.AA.Vector3[0],_.AA.Vector3[1],_.AA.Vector3[2],_.AA.Vector3[3],_.AA.Vector3[4]];var e=dn("nearlines",{updatable:!0,points:this._nearLinesPoints},this._scene);e.parent=this._rootNode,e.alwaysSelectAsActiveMesh=!0,this._farLinesPoints=[_.AA.Vector3[5],_.AA.Vector3[6],_.AA.Vector3[7],_.AA.Vector3[8],_.AA.Vector3[9]];var n=dn("farlines",{updatable:!0,points:this._farLinesPoints},this._scene);n.parent=this._rootNode,n.alwaysSelectAsActiveMesh=!0,this._trLinesPoints=[_.AA.Vector3[10],_.AA.Vector3[11]];var i=dn("trlines",{updatable:!0,points:this._trLinesPoints},this._scene);i.parent=this._rootNode,i.alwaysSelectAsActiveMesh=!0,this._brLinesPoints=[_.AA.Vector3[12],_.AA.Vector3[0]];var o=dn("brlines",{updatable:!0,points:this._brLinesPoints},this._scene);o.parent=this._rootNode,o.alwaysSelectAsActiveMesh=!0,this._tlLinesPoints=[_.AA.Vector3[1],_.AA.Vector3[2]];var a=dn("tllines",{updatable:!0,points:this._tlLinesPoints},this._scene);a.parent=this._rootNode,a.alwaysSelectAsActiveMesh=!0,this._blLinesPoints=[_.AA.Vector3[3],_.AA.Vector3[4]];var s=dn("bllines",{updatable:!0,points:this._blLinesPoints},this._scene);s.parent=this._rootNode,s.alwaysSelectAsActiveMesh=!0,this._lightHelperFrustumMeshes.push(e,n,i,o,a,s);var l=function(c,u,d){var h=new xe(c+"plane",t._scene),p=new qt(c+"PlaneMat",t._scene);h.material=p,h.parent=t._rootNode,h.alwaysSelectAsActiveMesh=!0,p.emissiveColor=u,p.alpha=t.transparency,p.backFaceCulling=!1,p.disableLighting=!0;var m=new rt;m.positions=d,m.indices=[0,1,2,0,2,3],m.applyToMesh(h,!0),t._lightHelperFrustumMeshes.push(h)};this._nearPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._farPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._rightPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._leftPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._topPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._bottomPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],l("near",new z.v9(1,0,0),this._nearPlaneVertices),l("far",new z.v9(.3,0,0),this._farPlaneVertices),l("right",new z.v9(0,1,0),this._rightPlaneVertices),l("left",new z.v9(0,.3,0),this._leftPlaneVertices),l("top",new z.v9(0,0,1),this._topPlaneVertices),l("bottom",new z.v9(0,0,.3),this._bottomPlaneVertices),this._nearLinesPoints[0]=_.AA.Vector3[2],this._nearLinesPoints[1]=_.AA.Vector3[3],this._nearLinesPoints[2]=_.AA.Vector3[4],this._nearLinesPoints[3]=_.AA.Vector3[5],this._nearLinesPoints[4]=_.AA.Vector3[2],this._farLinesPoints[0]=_.AA.Vector3[6],this._farLinesPoints[1]=_.AA.Vector3[7],this._farLinesPoints[2]=_.AA.Vector3[8],this._farLinesPoints[3]=_.AA.Vector3[9],this._farLinesPoints[4]=_.AA.Vector3[6],this._trLinesPoints[0]=_.AA.Vector3[2],this._trLinesPoints[1]=_.AA.Vector3[6],this._brLinesPoints[0]=_.AA.Vector3[3],this._brLinesPoints[1]=_.AA.Vector3[7],this._tlLinesPoints[0]=_.AA.Vector3[4],this._tlLinesPoints[1]=_.AA.Vector3[8],this._blLinesPoints[0]=_.AA.Vector3[5],this._blLinesPoints[1]=_.AA.Vector3[9]},r.prototype._getInvertViewMatrix=function(){return _.uq.LookAtLHToRef(this._light.position,this._light.position.add(this._light.direction),_.Pq.UpReadOnly,this._inverseViewMatrix),this._inverseViewMatrix.invertToRef(this._inverseViewMatrix),this._inverseViewMatrix},r}(),rr=L(45158),GE=L(84163),kE=L(67925),hg=L(16106),nl=L(96925),Yu=L(92118),fg=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},pg=function(r){function t(e){e===void 0&&(e=new fg);var n=r.call(this,null)||this;e.deterministicLockstep===void 0&&(e.deterministicLockstep=!1),e.timeStep!==void 0&&(n._timeStep=e.timeStep),e.lockstepMaxSteps===void 0&&(e.lockstepMaxSteps=4),n._options=e,hg.I.SetMatrixPrecision(!!e.useHighPrecisionMatrix),n._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,maxDrawBuffers:0,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,maxFragmentUniformVectors:16,maxVertexUniformVectors:16,standardDerivatives:!1,astc:null,pvrtc:null,etc1:null,etc2:null,bptc:null,maxAnisotropy:0,uintIndices:!1,fragmentDepthSupported:!1,highPrecisionShaderSupported:!0,colorBufferFloat:!1,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!1,texelFetch:!1,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!1,instancedArrays:!1,supportOcclusionQuery:!1,canUseTimestampForTimerQuery:!1,maxMSAASamples:1,blendMinMax:!1,canUseGLInstanceID:!1,canUseGLVertexID:!1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:!1,textureMaxLevel:!1,texture2DArrayMaxLayerCount:128,disableMorphTargetTexture:!1},n._features={forceBitmapOverHTMLImageElement:!1,supportRenderAndCopyToLodForFloatTextures:!1,supportDepthStencilTexture:!1,supportShadowSamplers:!1,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:!1,trackUbosInFrame:!1,checkUbosContentBeforeUpload:!1,supportCSM:!1,basisNeedsPOT:!1,support3DTextures:!1,needTypeSuffixInShaderConstants:!1,supportMSAA:!1,supportSSAO2:!1,supportIBLShadows:!1,supportExtendedTextureFormats:!1,supportSwitchCaseInShader:!1,supportSyncTextureRead:!1,needsInvertingBitmap:!1,useUBOBindingCache:!1,needShaderCodeInlining:!1,needToAlwaysBindUniformBuffers:!1,supportRenderPasses:!0,supportSpriteInstancing:!1,forceVertexBufferStrideAndOffsetMultiple4Bytes:!1,_checkNonFloatVertexBuffersDontRecreatePipelineContext:!1,_collectUbosUpdatedInFrame:!1},e.renderingCanvas&&(n._renderingCanvas=e.renderingCanvas),O.V.Log("Babylon.js v".concat(Zt.Version," - Null engine"));var i=typeof self<"u"?self:L.g!==void 0?L.g:window;return typeof URL>"u"&&(i.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),typeof Blob>"u"&&(i.Blob=function(){}),n}return(0,A.C6)(t,r),t.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},t.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},t.prototype.getHardwareScalingLevel=function(){return 1},t.prototype.createVertexBuffer=function(e){var n=new $o.n;return n.references=1,n},t.prototype.createIndexBuffer=function(e){var n=new $o.n;return n.references=1,n},t.prototype.clear=function(e,n,i,o){},t.prototype.getRenderWidth=function(e){return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},t.prototype.getRenderHeight=function(e){return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},t.prototype.setViewport=function(e,n,i){this._cachedViewport=e},t.prototype.createShaderProgram=function(e,n,i,o,a){return{__SPECTOR_rebuildProgram:null}},t.prototype.getUniforms=function(e,n){return[]},t.prototype.getAttributes=function(e,n){return[]},t.prototype.bindSamplers=function(e){this._currentEffect=null},t.prototype.enableEffect=function(e){e=e!==null&&(0,Yu.E)(e)?e.effect:e,this._currentEffect=e,e&&(e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))},t.prototype.setState=function(e,n,i,o,a,s,l){},t.prototype.setIntArray=function(e,n){return!0},t.prototype.setIntArray2=function(e,n){return!0},t.prototype.setIntArray3=function(e,n){return!0},t.prototype.setIntArray4=function(e,n){return!0},t.prototype.setFloatArray=function(e,n){return!0},t.prototype.setFloatArray2=function(e,n){return!0},t.prototype.setFloatArray3=function(e,n){return!0},t.prototype.setFloatArray4=function(e,n){return!0},t.prototype.setArray=function(e,n){return!0},t.prototype.setArray2=function(e,n){return!0},t.prototype.setArray3=function(e,n){return!0},t.prototype.setArray4=function(e,n){return!0},t.prototype.setMatrices=function(e,n){return!0},t.prototype.setMatrix3x3=function(e,n){return!0},t.prototype.setMatrix2x2=function(e,n){return!0},t.prototype.setFloat=function(e,n){return!0},t.prototype.setFloat2=function(e,n,i){return!0},t.prototype.setFloat3=function(e,n,i,o){return!0},t.prototype.setBool=function(e,n){return!0},t.prototype.setFloat4=function(e,n,i,o,a){return!0},t.prototype.setAlphaMode=function(e,n){n===void 0&&(n=!1),this._alphaMode!==e&&(this.alphaState.alphaBlend=e!==P.Y.ALPHA_DISABLE,n||this.setDepthWrite(e===P.Y.ALPHA_DISABLE),this._alphaMode=e)},t.prototype.bindBuffers=function(e,n,i){},t.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilStateComposer.reset(),this.depthCullingState.reset(),this.alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},t.prototype.draw=function(e,n,i,o){},t.prototype.drawElementsType=function(e,n,i,o){},t.prototype.drawArraysType=function(e,n,i,o){},t.prototype._createTexture=function(){return{}},t.prototype._releaseTexture=function(e){},t.prototype.createTexture=function(e,n,i,o,a,s,l,c,u,d,h,p){a===void 0&&(a=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),s===void 0&&(s=null),d===void 0&&(d=null);var m=new rn.h(this,1),v=String(e);return m.url=v,m.generateMipMaps=!n,m.samplingMode=a,m.invertY=i,m.baseWidth=this._options.textureSize,m.baseHeight=this._options.textureSize,m.width=this._options.textureSize,m.height=this._options.textureSize,d&&(m.format=d),m.isReady=!0,s&&setTimeout(function(){s(m)}),this._internalTexturesCache.push(m),m},t.prototype._createHardwareRenderTargetWrapper=function(e,n,i){var o=new nl.v(e,n,i,this);return this._renderTargetWrapperCache.push(o),o},t.prototype.createRenderTargetTexture=function(e,n){var i=this._createHardwareRenderTargetWrapper(!1,!1,e),o={};n!==void 0&&typeof n=="object"?(o.generateMipMaps=n.generateMipMaps,o.generateDepthBuffer=n.generateDepthBuffer===void 0||n.generateDepthBuffer,o.generateStencilBuffer=o.generateDepthBuffer&&n.generateStencilBuffer,o.type=n.type===void 0?P.Y.TEXTURETYPE_UNSIGNED_INT:n.type,o.samplingMode=n.samplingMode===void 0?P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:n.samplingMode):(o.generateMipMaps=n,o.generateDepthBuffer=!0,o.generateStencilBuffer=!1,o.type=P.Y.TEXTURETYPE_UNSIGNED_INT,o.samplingMode=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE);var a=new rn.h(this,5),s=e.width||e,l=e.height||e;return i._generateDepthBuffer=o.generateDepthBuffer,i._generateStencilBuffer=!!o.generateStencilBuffer,a.baseWidth=s,a.baseHeight=l,a.width=s,a.height=l,a.isReady=!0,a.samples=1,a.generateMipMaps=!!o.generateMipMaps,a.samplingMode=o.samplingMode,a.type=o.type,this._internalTexturesCache.push(a),i},t.prototype.createRenderTargetCubeTexture=function(e,n){var i=this._createHardwareRenderTargetWrapper(!1,!0,e),o=(0,A.Cl)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:P.Y.TEXTURETYPE_UNSIGNED_INT,samplingMode:P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,format:P.Y.TEXTUREFORMAT_RGBA},n);o.generateStencilBuffer=o.generateDepthBuffer&&o.generateStencilBuffer,(o.type!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(o.type!==P.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(o.samplingMode=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),i._generateDepthBuffer=o.generateDepthBuffer,i._generateStencilBuffer=!!o.generateStencilBuffer;var a=new rn.h(this,5);return a.baseWidth=e,a.baseHeight=e,a.width=e,a.height=e,a.isReady=!0,a.isCube=!0,a.samples=1,a.generateMipMaps=!!o.generateMipMaps,a.samplingMode=o.samplingMode,a.type=o.type,this._internalTexturesCache.push(a),i},t.prototype.updateTextureSamplingMode=function(e,n){n.samplingMode=e},t.prototype.createRawTexture=function(e,n,i,o,a,s,l,c,u,d,h){c===void 0&&(c=null),u===void 0&&(u=P.Y.TEXTURETYPE_UNSIGNED_INT),h===void 0&&(h=!1);var p=new rn.h(this,3);return p.baseWidth=n,p.baseHeight=i,p.width=n,p.height=i,p.format=o,p.generateMipMaps=a,p.samplingMode=l,p.invertY=s,p._compression=c,p.type=u,p._useSRGBBuffer=h,this._doNotHandleContextLost||(p._bufferView=e),p},t.prototype.updateRawTexture=function(e,n,i,o,a,s,l){a===void 0&&(a=null),s===void 0&&(s=P.Y.TEXTURETYPE_UNSIGNED_INT),l===void 0&&(l=!1),e&&(e._bufferView=n,e.format=i,e.invertY=o,e._compression=a,e.type=s,e._useSRGBBuffer=l)},t.prototype.bindFramebuffer=function(e,n,i,o,a){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=null,this._cachedViewport&&!a&&this.setViewport(this._cachedViewport,i,o)},t.prototype.unBindFramebuffer=function(e,n,i){this._currentRenderTarget=null,i&&i(),this._currentFramebuffer=null},t.prototype.createDynamicVertexBuffer=function(e){var n=new $o.n;return n.references=1,n.capacity=1,n},t.prototype.updateDynamicTexture=function(e,n,i,o,a){},t.prototype.areAllEffectsReady=function(){return!0},t.prototype.getError=function(){return 0},t.prototype._getUnpackAlignement=function(){return 1},t.prototype._unpackFlipY=function(e){},t.prototype.updateDynamicIndexBuffer=function(e,n,i){},t.prototype.updateDynamicVertexBuffer=function(e,n,i,o){},t.prototype._bindTextureDirectly=function(e,n){return this._boundTexturesCache[this._activeChannel]!==n&&(this._boundTexturesCache[this._activeChannel]=n,!0)},t.prototype._bindTexture=function(e,n){e<0||this._bindTextureDirectly(0,n)},t.prototype._deleteBuffer=function(e){},t.prototype.releaseEffects=function(){},t.prototype.displayLoadingUI=function(){},t.prototype.hideLoadingUI=function(){},Object.defineProperty(t.prototype,"loadingUIText",{set:function(e){},enumerable:!1,configurable:!0}),t.prototype._uploadCompressedDataToTextureDirectly=function(e,n,i,o,a,s,l){},t.prototype._uploadDataToTextureDirectly=function(e,n,i,o){},t.prototype._uploadArrayBufferViewToTexture=function(e,n,i,o){},t.prototype._uploadImageToTexture=function(e,n,i,o){},t}(Zt),_g=(L(19966),function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=cn.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=cn.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,this.forceRenderingWhenOccluded=!1});Be.$.prototype.getGPUFrameTimeCounter=function(){return null},Be.$.prototype.captureGPUFrameTime=function(r){},Be.$.prototype.createQuery=function(){return null},Be.$.prototype.deleteQuery=function(r){return this},Be.$.prototype.isQueryResultAvailable=function(r){return!1},Be.$.prototype.getQueryResult=function(r){return 0},Be.$.prototype.beginOcclusionQuery=function(r,t){return!1},Be.$.prototype.endOcclusionQuery=function(r){return this},Object.defineProperty(cn.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},set:function(r){this._occlusionDataStorage.isOcclusionQueryInProgress=r},enumerable:!1,configurable:!0}),Object.defineProperty(cn.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new _g),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(cn.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(r){this._occlusionDataStorage.isOccluded=r},enumerable:!0,configurable:!0}),Object.defineProperty(cn.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(r){this._occlusionDataStorage.occlusionQueryAlgorithmType=r},enumerable:!0,configurable:!0}),Object.defineProperty(cn.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(r){this._occlusionDataStorage.occlusionType=r},enumerable:!0,configurable:!0}),Object.defineProperty(cn.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(r){this._occlusionDataStorage.occlusionRetryCount=r},enumerable:!0,configurable:!0}),Object.defineProperty(cn.prototype,"forceRenderingWhenOccluded",{get:function(){return this._occlusionDataStorage.forceRenderingWhenOccluded},set:function(r){this._occlusionDataStorage.forceRenderingWhenOccluded=r},enumerable:!0,configurable:!0}),cn.prototype._checkOcclusionQuery=function(){var r=this._occlusionDataStorage;if(r.occlusionType===cn.OCCLUSION_TYPE_NONE)return r.isOccluded=!1,!1;var t=this.getEngine();if(!t.getCaps().supportOcclusionQuery||!t.isQueryResultAvailable)return r.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery!==null&&this._occlusionQuery!==void 0)if(t.isQueryResultAvailable(this._occlusionQuery)){var e=t.getQueryResult(this._occlusionQuery);r.isOcclusionQueryInProgress=!1,r.occlusionInternalRetryCounter=0,r.isOccluded=!(e>0)}else{if(r.occlusionInternalRetryCounter++,!(r.occlusionRetryCount!==-1&&r.occlusionInternalRetryCounter>r.occlusionRetryCount))return r.occlusionType!==cn.OCCLUSION_TYPE_OPTIMISTIC&&r.isOccluded;r.isOcclusionQueryInProgress=!1,r.occlusionInternalRetryCounter=0,r.isOccluded=r.occlusionType!==cn.OCCLUSION_TYPE_OPTIMISTIC&&r.isOccluded}var n=this.getScene();if(n.getBoundingBoxRenderer){var i=n.getBoundingBoxRenderer();this._occlusionQuery===null&&(this._occlusionQuery=t.createQuery()),this._occlusionQuery&&t.beginOcclusionQuery(r.occlusionQueryAlgorithmType,this._occlusionQuery)&&(i.renderOcclusionBoundingBox(this),t.endOcclusionQuery(r.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0)}return r.isOccluded};var zE=function(){},WE=new K.cP,HE=new K.cP;Object.defineProperty(Be.$.prototype,"onBeforeViewRenderObservable",{get:function(){return WE}}),Object.defineProperty(Be.$.prototype,"onAfterViewRenderObservable",{get:function(){return HE}}),Object.defineProperty(Be.$.prototype,"inputElement",{get:function(){return this._inputElement},set:function(r){var t;this._inputElement!==r&&(this._inputElement=r,(t=this._onEngineViewChanged)===null||t===void 0||t.call(this))}}),Be.$.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},Be.$.prototype.registerView=function(r,t,e){var n=this;this.views||(this.views=[]);for(var i=0,o=this.views;i<o.length;i++){var a=o[i];if(a.target===r)return a}var s=this.getRenderingCanvas();s&&(r.width=s.width,r.height=s.height);var l={target:r,camera:t,clearBeforeCopy:e,enabled:!0,id:(1e5*Math.random()).toFixed()};return this.views.push(l),t&&!Array.isArray(t)&&t.onDisposeObservable.add(function(){n.unRegisterView(r)}),l},Be.$.prototype.unRegisterView=function(r){if(!this.views||this.views.length===0)return this;for(var t=0,e=this.views;t<e.length;t++){var n=e[t];if(n.target===r){var i=this.views.indexOf(n);i!==-1&&this.views.splice(i,1);break}}return this},Be.$.prototype._renderViewStep=function(r){var t=r.target,e=t.getContext("2d");if(!e)return!0;var n=this.getRenderingCanvas();WE.notifyObservers(r);var i=r.camera,o=null,a=null,s=null;if(i&&(o=(s=Array.isArray(i)?i[0].getScene():i.getScene()).activeCamera,a=s.activeCameras,Array.isArray(i)?s.activeCameras=i:(s.activeCamera=i,s.activeCameras=null)),this.activeView=r,r.customResize)r.customResize(t);else{var l=Math.floor(t.clientWidth/this._hardwareScalingLevel),c=Math.floor(t.clientHeight/this._hardwareScalingLevel),u=l!==t.width||n.width!==t.width||c!==t.height||n.height!==t.height;t.clientWidth&&t.clientHeight&&u&&(t.width=l,t.height=c,this.setSize(l,c))}return!(!n.width||!n.height||(this._renderFrame(),this.flushFramebuffer(),r.clearBeforeCopy&&e.clearRect(0,0,n.width,n.height),e.drawImage(n,0,0),s&&(s.activeCameras=a,s.activeCamera=o),HE.notifyObservers(r),0))},Be.$.prototype._renderViews=function(){if(!this.views||this.views.length===0)return!1;var r;if(!this.getRenderingCanvas())return!1;for(var t=0,e=this.views;t<e.length;t++){var n=e[t];if(n.enabled)if(n.target!==this.inputElement){if(!this._renderViewStep(n))return!1}else r=n}return!(r&&!this._renderViewStep(r)||(this.activeView=null,0))},Be.$.prototype._debugPushGroup=function(r,t){},Be.$.prototype._debugPopGroup=function(r){},Be.$.prototype._debugInsertMarker=function(r,t){},Be.$.prototype._debugFlushPendingCommands=function(){};var mg=function(){this._timeElapsedQueryEnded=!1};Zt.prototype.createQuery=function(){var r=this._gl.createQuery();if(!r)throw new Error("Unable to create Occlusion Query");return r},Zt.prototype.deleteQuery=function(r){return this._gl.deleteQuery(r),this},Zt.prototype.isQueryResultAvailable=function(r){return this._gl.getQueryParameter(r,this._gl.QUERY_RESULT_AVAILABLE)},Zt.prototype.getQueryResult=function(r){return this._gl.getQueryParameter(r,this._gl.QUERY_RESULT)},Zt.prototype.beginOcclusionQuery=function(r,t){var e=this._getGlAlgorithmType(r);return this._gl.beginQuery(e,t),!0},Zt.prototype.endOcclusionQuery=function(r){var t=this._getGlAlgorithmType(r);return this._gl.endQuery(t),this},Zt.prototype._createTimeQuery=function(){var r=this.getCaps().timerQuery;return r.createQueryEXT?r.createQueryEXT():this.createQuery()},Zt.prototype._deleteTimeQuery=function(r){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(r):this.deleteQuery(r)},Zt.prototype._getTimeQueryResult=function(r){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(r,t.QUERY_RESULT_EXT):this.getQueryResult(r)},Zt.prototype._getTimeQueryAvailability=function(r){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(r,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(r)},Zt.prototype.startTimeQuery=function(){var r=this.getCaps(),t=r.timerQuery;if(!t)return null;var e=new mg;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),r.canUseTimestampForTimerQuery)e._startTimeQuery=this._createTimeQuery(),e._startTimeQuery&&t.queryCounterEXT(e._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;e._timeElapsedQuery=this._createTimeQuery(),e._timeElapsedQuery&&(t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,e._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,e._timeElapsedQuery)),this._currentNonTimestampToken=e}return e},Zt.prototype.endTimeQuery=function(r){var t=this.getCaps(),e=t.timerQuery;if(!e||!r)return-1;if(t.canUseTimestampForTimerQuery){if(!r._startTimeQuery)return-1;r._endTimeQuery||(r._endTimeQuery=this._createTimeQuery(),r._endTimeQuery&&e.queryCounterEXT(r._endTimeQuery,e.TIMESTAMP_EXT))}else if(!r._timeElapsedQueryEnded){if(!r._timeElapsedQuery)return-1;e.endQueryEXT?e.endQueryEXT(e.TIME_ELAPSED_EXT):(this._gl.endQuery(e.TIME_ELAPSED_EXT),this._currentNonTimestampToken=null),r._timeElapsedQueryEnded=!0}var n=this._gl.getParameter(e.GPU_DISJOINT_EXT),i=!1;if(r._endTimeQuery?i=this._getTimeQueryAvailability(r._endTimeQuery):r._timeElapsedQuery&&(i=this._getTimeQueryAvailability(r._timeElapsedQuery)),i&&!n){var o=0;if(t.canUseTimestampForTimerQuery){if(!r._startTimeQuery||!r._endTimeQuery)return-1;var a=this._getTimeQueryResult(r._startTimeQuery);o=this._getTimeQueryResult(r._endTimeQuery)-a,this._deleteTimeQuery(r._startTimeQuery),this._deleteTimeQuery(r._endTimeQuery),r._startTimeQuery=null,r._endTimeQuery=null}else{if(!r._timeElapsedQuery)return-1;o=this._getTimeQueryResult(r._timeElapsedQuery),this._deleteTimeQuery(r._timeElapsedQuery),r._timeElapsedQuery=null,r._timeElapsedQueryEnded=!1}return o}return-1},Zt.prototype._captureGPUFrameTime=!1,Zt.prototype._gpuFrameTime=new Mi.A,Zt.prototype.getGPUFrameTimeCounter=function(){return this._gpuFrameTime},Zt.prototype.captureGPUFrameTime=function(r){var t=this;r!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=r,r?(this._onBeginFrameObserver=this.onBeginFrameObservable.add(function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.startTimeQuery())}),this._onEndFrameObserver=this.onEndFrameObservable.add(function(){if(t._gpuFrameTimeToken){var e=t.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}})):(this.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},Zt.prototype._getGlAlgorithmType=function(r){return r===cn.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED};var YE=!0;Zt.prototype.createTransformFeedback=function(){var r=this._gl.createTransformFeedback();if(!r)throw new Error("Unable to create Transform Feedback");return r},Zt.prototype.deleteTransformFeedback=function(r){this._gl.deleteTransformFeedback(r)},Zt.prototype.bindTransformFeedback=function(r){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,r)},Zt.prototype.beginTransformFeedback=function(r){r===void 0&&(r=!0),this._gl.beginTransformFeedback(r?this._gl.POINTS:this._gl.TRIANGLES)},Zt.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},Zt.prototype.setTranformFeedbackVaryings=function(r,t){this._gl.transformFeedbackVaryings(r,t,this._gl.INTERLEAVED_ATTRIBS)},Zt.prototype.bindTransformFeedbackBuffer=function(r){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,r?r.underlyingResource:null)},Zt.prototype.readTransformFeedbackBuffer=function(r){this._gl.getBufferSubData(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,r)},an.w.prototype.updateVideoTexture=function(r,t,e){if(r&&!r._isDisabled){var n=this._getInternalFormat(r.format),i=this._getRGBABufferInternalSizedFormat(P.Y.TEXTURETYPE_UNSIGNED_BYTE,r.format),o=this._bindTextureDirectly(this._gl.TEXTURE_2D,r,!0);this._unpackFlipY(!e);try{if(this._videoTextureSupported===void 0&&(this._gl.getError(),this._gl.texImage2D(this._gl.TEXTURE_2D,0,i,n,this._gl.UNSIGNED_BYTE,t),this._gl.getError()!==0?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported)this._gl.texImage2D(this._gl.TEXTURE_2D,0,i,n,this._gl.UNSIGNED_BYTE,t);else{if(!r._workingCanvas){r._workingCanvas=this.createCanvas(r.width,r.height);var a=r._workingCanvas.getContext("2d");if(!a)throw new Error("Unable to get 2d context");r._workingContext=a,r._workingCanvas.width=r.width,r._workingCanvas.height=r.height}r._workingContext.clearRect(0,0,r.width,r.height),r._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,r.width,r.height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,i,n,this._gl.UNSIGNED_BYTE,r._workingCanvas)}r.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),o||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r.isReady=!0}catch{r._isDisabled=!0}}},an.w.prototype.restoreSingleAttachment=function(){var r=this._gl;this.bindAttachments([r.BACK])},an.w.prototype.restoreSingleAttachmentForRenderTarget=function(){var r=this._gl;this.bindAttachments([r.COLOR_ATTACHMENT0])},an.w.prototype.buildTextureLayout=function(r){for(var t=this._gl,e=[],n=0;n<r.length;n++)r[n]?e.push(t["COLOR_ATTACHMENT"+n]):e.push(t.NONE);return e},an.w.prototype.bindAttachments=function(r){this._gl.drawBuffers(r)},an.w.prototype.unBindMultiColorAttachmentFramebuffer=function(r,t,e){t===void 0&&(t=!1),this._currentRenderTarget=null;var n=this._gl,i=r._attachments,o=i.length;if(r._MSAAFramebuffer){n.bindFramebuffer(n.READ_FRAMEBUFFER,r._MSAAFramebuffer),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,r._framebuffer);for(var a=0;a<o;a++){for(var s=r.textures[a],l=0;l<o;l++)i[l]=n.NONE;i[a]=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],n.readBuffer(i[a]),n.drawBuffers(i),n.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,n.COLOR_BUFFER_BIT,n.NEAREST)}for(a=0;a<o;a++)i[a]=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];n.drawBuffers(i)}for(a=0;a<o;a++)!((s=r.textures[a])!=null&&s.generateMipMaps)||t||s?.isCube||s?.is3D||(this._bindTextureDirectly(n.TEXTURE_2D,s,!0),n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null));e&&(r._MSAAFramebuffer&&this._bindUnboundFramebuffer(r._framebuffer),e()),this._bindUnboundFramebuffer(null)},an.w.prototype.createMultipleRenderTarget=function(r,t,e){var n,i;e===void 0&&(e=!0);var o=!1,a=!0,s=!1,l=!1,c=P.Y.TEXTUREFORMAT_DEPTH16,u=1,d=P.Y.TEXTURETYPE_UNSIGNED_INT,h=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,p=P.Y.TEXTUREFORMAT_RGBA,m=P.Y.TEXTURE_2D,v=[],b=[],E=[],C=[],T=[],f=[],g=[],S=[],y=this._createHardwareRenderTargetWrapper(!0,!1,r);t!==void 0&&(o=t.generateMipMaps!==void 0&&t.generateMipMaps,a=t.generateDepthBuffer===void 0||t.generateDepthBuffer,s=t.generateStencilBuffer!==void 0&&t.generateStencilBuffer,l=t.generateDepthTexture!==void 0&&t.generateDepthTexture,u=t.textureCount||1,t.types&&(v=t.types),t.samplingModes&&(b=t.samplingModes),t.useSRGBBuffers&&(E=t.useSRGBBuffers),t.formats&&(C=t.formats),t.targetTypes&&(T=t.targetTypes),t.faceIndex&&(f=t.faceIndex),t.layerIndex&&(g=t.layerIndex),t.layerCounts&&(S=t.layerCounts),this.webGLVersion>1&&(t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8||t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH24||t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH32_FLOAT||t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8)&&(c=t.depthTextureFormat)),y.label=(n=t?.label)!==null&&n!==void 0?n:"MultiRenderTargetWrapper";var x=this._gl,R=x.createFramebuffer();this._bindUnboundFramebuffer(R);var I=r.width||r,M=r.height||r,D=[],B=[],F=this.webGLVersion>1&&l&&(t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8||t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||t.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8),X=this._setupFramebufferDepthAttachments(!F&&s,!l&&a,I,M);y._framebuffer=R,y._depthStencilBuffer=X,y._generateDepthBuffer=!l&&a,y._generateStencilBuffer=!F&&s,y._attachments=B;for(var $=0;$<u;$++){var Q=b[$]||h,ie=v[$]||d,q=E[$]||!1,ee=C[$]||p,te=T[$]||m,ce=(i=S[$])!==null&&i!==void 0?i:1;(ie!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(ie!==P.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(Q=P.Y.TEXTURE_NEAREST_SAMPLINGMODE);var fe=this._getSamplingParameters(Q,o);ie!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloat||(ie=P.Y.TEXTURETYPE_UNSIGNED_INT,O.V.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),q=q&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU);var de=this.webGLVersion>1,Te=x[de?"COLOR_ATTACHMENT"+$:"COLOR_ATTACHMENT"+$+"_WEBGL"];if(B.push(Te),te!==-1){var ue=new rn.h(this,6);D[$]=ue,x.activeTexture(x["TEXTURE"+$]),x.bindTexture(te,ue._hardwareTexture.underlyingResource),x.texParameteri(te,x.TEXTURE_MAG_FILTER,fe.mag),x.texParameteri(te,x.TEXTURE_MIN_FILTER,fe.min),x.texParameteri(te,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(te,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE);var U=this._getRGBABufferInternalSizedFormat(ie,ee,q),N=this._getInternalFormat(ee),w=this._getWebGLTextureType(ie);if(!de||te!==P.Y.TEXTURE_2D_ARRAY&&te!==P.Y.TEXTURE_3D)if(te===P.Y.TEXTURE_CUBE_MAP){for(var k=0;k<6;k++)x.texImage2D(x.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,U,I,M,0,N,w,null);ue.isCube=!0}else x.texImage2D(x.TEXTURE_2D,0,U,I,M,0,N,w,null);else te===P.Y.TEXTURE_2D_ARRAY?ue.is2DArray=!0:ue.is3D=!0,ue.baseDepth=ue.depth=ce,x.texImage3D(te,0,U,I,M,ce,0,N,w,null);o&&x.generateMipmap(te),this._bindTextureDirectly(te,null),ue.baseWidth=I,ue.baseHeight=M,ue.width=I,ue.height=M,ue.isReady=!0,ue.samples=1,ue.generateMipMaps=o,ue.samplingMode=Q,ue.type=ie,ue._useSRGBBuffer=q,ue.format=ee,this._internalTexturesCache.push(ue)}}if(l&&this._caps.depthTextureExtension){var J=new rn.h(this,14),le=P.Y.TEXTURETYPE_UNSIGNED_SHORT,be=x.DEPTH_COMPONENT16,ve=x.DEPTH_COMPONENT,ye=x.UNSIGNED_SHORT,Me=x.DEPTH_ATTACHMENT;this.webGLVersion<2?be=x.DEPTH_COMPONENT:c===P.Y.TEXTUREFORMAT_DEPTH32_FLOAT?(le=P.Y.TEXTURETYPE_FLOAT,ye=x.FLOAT,be=x.DEPTH_COMPONENT32F):c===P.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8?(le=P.Y.TEXTURETYPE_UNSIGNED_INT,ye=x.FLOAT_32_UNSIGNED_INT_24_8_REV,be=x.DEPTH32F_STENCIL8,ve=x.DEPTH_STENCIL,Me=x.DEPTH_STENCIL_ATTACHMENT):c===P.Y.TEXTUREFORMAT_DEPTH24?(le=P.Y.TEXTURETYPE_UNSIGNED_INT,ye=x.UNSIGNED_INT,be=x.DEPTH_COMPONENT24,Me=x.DEPTH_ATTACHMENT):c!==P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8&&c!==P.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||(le=P.Y.TEXTURETYPE_UNSIGNED_INT_24_8,ye=x.UNSIGNED_INT_24_8,be=x.DEPTH24_STENCIL8,ve=x.DEPTH_STENCIL,Me=x.DEPTH_STENCIL_ATTACHMENT),x.activeTexture(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,J._hardwareTexture.underlyingResource),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,x.NEAREST),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,x.NEAREST),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE),x.texImage2D(x.TEXTURE_2D,0,be,I,M,0,ve,ye,null),x.framebufferTexture2D(x.FRAMEBUFFER,Me,x.TEXTURE_2D,J._hardwareTexture.underlyingResource,0),J.baseWidth=I,J.baseHeight=M,J.width=I,J.height=M,J.isReady=!0,J.samples=1,J.generateMipMaps=o,J.samplingMode=P.Y.TEXTURE_NEAREST_SAMPLINGMODE,J.format=c,J.type=le,D[u]=J,this._internalTexturesCache.push(J)}return y.setTextures(D),e&&x.drawBuffers(B),this._bindUnboundFramebuffer(null),y.setLayerAndFaceIndices(g,f),this.resetTextureCache(),y},an.w.prototype.updateMultipleRenderTargetTextureSampleCount=function(r,t,e){if(e===void 0&&(e=!0),this.webGLVersion<2||!r||!r.texture)return 1;if(r.samples===t)return t;var n=r._attachments.length;if(n===0)return 1;var i=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples);var o=!!r._depthStencilBuffer;if(o&&(i.deleteRenderbuffer(r._depthStencilBuffer),r._depthStencilBuffer=null),r._MSAAFramebuffer&&(i.deleteFramebuffer(r._MSAAFramebuffer),r._MSAAFramebuffer=null),t>1&&typeof i.renderbufferStorageMultisample=="function"){var a=i.createFramebuffer();if(!a)throw new Error("Unable to create multi sampled framebuffer");r._MSAAFramebuffer=a,this._bindUnboundFramebuffer(a);for(var s=[],l=0;l<n;l++)(u=(c=r.textures[l])._hardwareTexture).releaseMSAARenderBuffers();for(l=0;l<n;l++){var c,u=(c=r.textures[l])._hardwareTexture,d=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+l:"COLOR_ATTACHMENT"+l+"_WEBGL"],h=this._createRenderBuffer(c.width,c.height,t,-1,this._getRGBABufferInternalSizedFormat(c.type,c.format,c._useSRGBBuffer),d);if(!h)throw new Error("Unable to create multi sampled framebuffer");u.addMSAARenderBuffer(h),c.samples=t,s.push(d)}e&&i.drawBuffers(s)}else this._bindUnboundFramebuffer(r._framebuffer);return o&&(r._depthStencilBuffer=this._setupFramebufferDepthAttachments(r._generateStencilBuffer,r._generateDepthBuffer,r.texture.width,r.texture.height,t)),this._bindUnboundFramebuffer(null),t},L(71974);var Xu,Lo=L(51428),Ki=L(28081),gg=L(49611);function cD(r){if(this._excludedCompressedTextures&&this._excludedCompressedTextures.some(function(i){var o="\\b"+i+"\\b";return r&&(r===i||r.match(new RegExp(o,"g")))}))return r;var t=r.lastIndexOf("."),e=r.lastIndexOf("?"),n=e>-1?r.substring(e,r.length):"";return(t>-1?r.substring(0,t):r)+this._textureFormatInUse+n}an.w.prototype.createPrefilteredCubeTexture=function(r,t,e,n,i,o,a,s,l){var c=this;return i===void 0&&(i=null),o===void 0&&(o=null),s===void 0&&(s=null),l===void 0&&(l=!0),this.createCubeTexture(r,t,null,!1,function(u){if(u){var d=u.texture;if(l?u.info.sphericalPolynomial&&(d._sphericalPolynomial=u.info.sphericalPolynomial):d._sphericalPolynomial=new Lo.Q,d._source=9,c.getCaps().textureLOD)i&&i(d);else{var h=c._gl,p=u.width;if(p){for(var m=[],v=0;v<3;v++){var b=1-v/2,E=n,C=Math.log2(p)*e+n,T=E+(C-E)*b,f=Math.round(Math.min(Math.max(T,0),C)),g=new rn.h(c,2);if(g.type=d.type,g.format=d.format,g.width=Math.pow(2,Math.max(Math.log2(p)-f,0)),g.height=g.width,g.isCube=!0,g._cachedWrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,g._cachedWrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE,c._bindTextureDirectly(h.TEXTURE_CUBE_MAP,g,!0),g.samplingMode=P.Y.TEXTURE_LINEAR_LINEAR,h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),u.isDDS){var S=u.info,y=u.data;c._unpackFlipY(S.isCompressed),gg.D.UploadDDSLevels(c,g,y,S,!0,6,f)}else O.V.Warn("DDS is the only prefiltered cube map supported so far.");c._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null);var x=new Ki.t(t);x._isCube=!0,x._texture=g,g.isReady=!0,m.push(x)}d._lodTextureHigh=m[2],d._lodTextureMid=m[1],d._lodTextureLow=m[0],i&&i(d)}}}else i&&i(null)},o,a,s,l,e,n)},L(71073),L(8864),L(64838),L(59012),function(r){r[r.Texture=0]="Texture",r[r.StorageTexture=1]="StorageTexture",r[r.UniformBuffer=2]="UniformBuffer",r[r.StorageBuffer=3]="StorageBuffer",r[r.TextureWithoutSampler=4]="TextureWithoutSampler",r[r.Sampler=5]="Sampler",r[r.ExternalTexture=6]="ExternalTexture",r[r.DataBuffer=7]="DataBuffer"}(Xu||(Xu={})),an.w.prototype.createComputeEffect=function(r,t){throw new Error("createComputeEffect: This engine does not support compute shaders!")},an.w.prototype.createComputePipelineContext=function(){throw new Error("createComputePipelineContext: This engine does not support compute shaders!")},an.w.prototype.createComputeContext=function(){},an.w.prototype.computeDispatch=function(r,t,e,n,i,o,a){throw new Error("computeDispatch: This engine does not support compute shaders!")},an.w.prototype.computeDispatchIndirect=function(r,t,e,n,i,o){throw new Error("computeDispatchIndirect: This engine does not support compute shaders!")},an.w.prototype.areAllComputeEffectsReady=function(){return!0},an.w.prototype.releaseComputeEffects=function(){},an.w.prototype._prepareComputePipelineContext=function(r,t,e,n,i){},an.w.prototype._rebuildComputeEffects=function(){},Be.$.prototype._executeWhenComputeStateIsCompiled=function(r,t){t(null)},an.w.prototype._releaseComputeEffect=function(r){},an.w.prototype._deleteComputePipelineContext=function(r){},Object.defineProperty(Zt.prototype,"texturesSupported",{get:function(){var r=[];return this._caps.astc&&r.push("-astc.ktx"),this._caps.s3tc&&r.push("-dxt.ktx"),this._caps.pvrtc&&r.push("-pvrtc.ktx"),this._caps.etc2&&r.push("-etc2.ktx"),this._caps.etc1&&r.push("-etc1.ktx"),r},enumerable:!0,configurable:!0}),Object.defineProperty(Zt.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse||null},enumerable:!0,configurable:!0}),Zt.prototype.setCompressedTextureExclusions=function(r){this._excludedCompressedTextures=r},Zt.prototype.setTextureFormatToUse=function(r){for(var t=this.texturesSupported,e=0,n=t.length;e<n;e++)for(var i=0,o=r.length;i<o;i++)if(t[e]===r[i].toLowerCase())return this._transformTextureUrl=cD.bind(this),this._textureFormatInUse=t[e];return this._textureFormatInUse="",this._transformTextureUrl=null,null};var il=function(){function r(){var t=this,e=new ArrayBuffer(r.DEFAULT_BUFFER_SIZE);this._uint32s=new Uint32Array(e),this._int32s=new Int32Array(e),this._float32s=new Float32Array(e),this._length=r.DEFAULT_BUFFER_SIZE/4,this._position=0,this._nativeDataStream=new _native.NativeDataStream(function(){t._flush()})}return r.prototype.writeUint32=function(t){this._flushIfNecessary(1),this._uint32s[this._position++]=t},r.prototype.writeInt32=function(t){this._flushIfNecessary(1),this._int32s[this._position++]=t},r.prototype.writeFloat32=function(t){this._flushIfNecessary(1),this._float32s[this._position++]=t},r.prototype.writeUint32Array=function(t){this._flushIfNecessary(1+t.length),this._uint32s[this._position++]=t.length,this._uint32s.set(t,this._position),this._position+=t.length},r.prototype.writeInt32Array=function(t){this._flushIfNecessary(1+t.length),this._uint32s[this._position++]=t.length,this._int32s.set(t,this._position),this._position+=t.length},r.prototype.writeFloat32Array=function(t){this._flushIfNecessary(1+t.length),this._uint32s[this._position++]=t.length,this._float32s.set(t,this._position),this._position+=t.length},r.prototype.writeNativeData=function(t){this._flushIfNecessary(t.length),this._uint32s.set(t,this._position),this._position+=t.length},r.prototype.writeBoolean=function(t){this.writeUint32(t?1:0)},r.prototype._flushIfNecessary=function(t){this._position+t>this._length&&this._flush()},r.prototype._flush=function(){this._nativeDataStream.writeBuffer(this._uint32s.buffer,this._position),this._position=0},r.DEFAULT_BUFFER_SIZE=65536,r}(),ni=L(88309);function ju(r,t,e,n){for(var i=n,o=0,a="";i<e.length;){var s=e.charAt(i);if(a)s===a?a==='"'||a==="'"?e.charAt(i-1)!=="\\"&&(a=""):a="":a==="*/"&&s==="*"&&i+1<e.length&&(e.charAt(i+1)==="/"&&(a=""),a===""&&i++);else switch(s){case r:o++;break;case t:o--;break;case'"':case"'":case"`":a=s;break;case"/":if(i+1<e.length){var l=e.charAt(i+1);l==="/"?a=`
|
||
`:l==="*"&&(a="*/")}}if(i++,o===0)break}return o===0?i-1:-1}function XE(r,t){for(;t<r.length;){var e=r[t];if(e!==" "&&e!==`
|
||
`&&e!=="\r"&&e!==" "&&e!==`
|
||
`&&e!==" ")break;t++}return t}function vg(r){var t=r.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t==95}function yg(r){for(var t=0,e="",n=!1,i=[];t<r.length;){var o=r.charAt(t);if(e)o===e?e==='"'||e==="'"?(r.charAt(t-1)!=="\\"&&(e=""),i.push(o)):(e="",n=!1):e==="*/"&&o==="*"&&t+1<r.length?(r.charAt(t+1)==="/"&&(e=""),e===""&&(n=!1,t++)):n||i.push(o);else{switch(o){case'"':case"'":case"`":e=o;break;case"/":if(t+1<r.length){var a=r.charAt(t+1);a==="/"?(e=`
|
||
`,n=!0):a==="*"&&(e="*/",n=!0)}}n||i.push(o)}t++}return i.join("")}function uD(r,t,e,n){for(;t>=0&&r.charAt(t)!==e&&r.charAt(t)!==n;)t--;return t}function qu(r,t,e,n){var i=r.indexOf(t);if(i<0)return r;if(e){for(;i++<r.length&&r.charAt(i)!="{";);if(i<r.length){var o=r.substring(0,i+1),a=r.substring(i+1);r=o+e+a}}if(n){var s=r.lastIndexOf("}");r=r.substring(0,s),r+=n+`
|
||
}`}return r}var ki,Ga=function(){function r(t,e){e===void 0&&(e=20),this.debug=!1,this._sourceCode=t,this._numMaxIterations=e,this._functionDescr=[],this.inlineToken="#define inline"}return Object.defineProperty(r.prototype,"code",{get:function(){return this._sourceCode},enumerable:!1,configurable:!0}),r.prototype.processCode=function(){this.debug&&O.V.Log("Start inlining process (code size=".concat(this._sourceCode.length,")...")),this._collectFunctions(),this._processInlining(this._numMaxIterations),this.debug&&O.V.Log("End of inlining process.")},r.prototype._collectFunctions=function(){for(var t,e=0;e<this._sourceCode.length;){var n=this._sourceCode.indexOf(this.inlineToken,e);if(n<0)break;var i=this._sourceCode.indexOf("(",n+this.inlineToken.length);if(i<0)this.debug&&O.V.Warn("Could not find the opening parenthesis after the token. startIndex=".concat(e)),e=n+this.inlineToken.length;else{var o=r._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(n+this.inlineToken.length,i));if(o){var a=(t=[o[3],o[4]])[0],s=t[1],l=ju("(",")",this._sourceCode,i);if(l<0)this.debug&&O.V.Warn("Could not extract the parameters the function '".concat(s,"' (type=").concat(a,"). funcParamsStartIndex=").concat(i)),e=n+this.inlineToken.length;else{var c=this._sourceCode.substring(i+1,l),u=XE(this._sourceCode,l+1);if(u!==this._sourceCode.length){var d=ju("{","}",this._sourceCode,u);if(d<0)this.debug&&O.V.Warn("Could not extract the body of the function '".concat(s,"' (type=").concat(a,"). funcBodyStartIndex=").concat(u)),e=n+this.inlineToken.length;else{for(var h=this._sourceCode.substring(u,d+1),p=yg(c).split(","),m=[],v=0;v<p.length;++v){var b=p[v].trim(),E=b.lastIndexOf(" ");E>=0&&m.push(b.substring(E+1))}a!=="void"&&m.push("return"),this._functionDescr.push({name:s,type:a,parameters:m,body:h,callIndex:0}),e=d+1;var C=n>0?this._sourceCode.substring(0,n):"",T=d+1<this._sourceCode.length-1?this._sourceCode.substring(d+1):"";this._sourceCode=C+T,e-=d+1-n}}else this.debug&&O.V.Warn("Could not extract the body of the function '".concat(s,"' (type=").concat(a,"). funcParamsEndIndex=").concat(l)),e=n+this.inlineToken.length}}else this.debug&&O.V.Warn("Could not extract the name/type of the function from: ".concat(this._sourceCode.substring(n+this.inlineToken.length,i))),e=n+this.inlineToken.length}}this.debug&&O.V.Log("Collect functions: ".concat(this._functionDescr.length," functions found. functionDescr=").concat(this._functionDescr))},r.prototype._processInlining=function(t){for(t===void 0&&(t=20);t-->=0&&this._replaceFunctionCallsByCode(););return this.debug&&O.V.Log("numMaxIterations is ".concat(t," after inlining process")),t>=0},r.prototype._replaceFunctionCallsByCode=function(){for(var t=!1,e=0,n=this._functionDescr;e<n.length;e++)for(var i=n[e],o=i.name,a=i.type,s=i.parameters,l=i.body,c=0;c<this._sourceCode.length;){var u=this._sourceCode.indexOf(o,c);if(u<0)break;if(u===0||vg(this._sourceCode.charAt(u-1)))c=u+o.length;else{var d=XE(this._sourceCode,u+o.length);if(d!==this._sourceCode.length&&this._sourceCode.charAt(d)==="("){var h=ju("(",")",this._sourceCode,d);if(h<0)this.debug&&O.V.Warn("Could not extract the parameters of the function call. Function '".concat(o,"' (type=").concat(a,"). callParamsStartIndex=").concat(d)),c=u+o.length;else{var p=this._sourceCode.substring(d+1,h),m=function(x){for(var R=[],I=0,M=0;I<x.length;){if(x.charAt(I)==="("){var D=ju("(",")",x,I);if(D<0)return null;I=D}else x.charAt(I)===","&&(R.push(x.substring(M,I)),M=I+1);I++}return M<I&&R.push(x.substring(M,I)),R}(yg(p));if(m!==null){for(var v=[],b=0;b<m.length;++b){var E=m[b].trim();v.push(E)}var C=a!=="void"?o+"_"+i.callIndex++:null;if(C&&v.push(C+" ="),v.length===s.length){c=h+1;var T=this._replaceNames(l,s,v),f=u>0?this._sourceCode.substring(0,u):"",g=h+1<this._sourceCode.length-1?this._sourceCode.substring(h+1):"";if(C){var S=uD(this._sourceCode,u-1,`
|
||
`,"{");f=this._sourceCode.substring(0,S+1);var y=this._sourceCode.substring(S+1,u);this._sourceCode=f+a+" "+C+`;
|
||
`+T+`
|
||
`+y+C+g,this.debug&&O.V.Log("Replace function call by code. Function '".concat(o,"' (type=").concat(a,"). injectDeclarationIndex=").concat(S,", call parameters=").concat(v))}else this._sourceCode=f+T+g,c+=T.length-(h+1-u),this.debug&&O.V.Log("Replace function call by code. Function '".concat(o,"' (type=").concat(a,"). functionCallIndex=").concat(u,", call parameters=").concat(v));t=!0}else this.debug&&O.V.Warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '".concat(o,"' (type=").concat(a,"). function parameters=").concat(s,", call parameters=").concat(v)),c=u+o.length}else this.debug&&O.V.Warn("Invalid function call: can't extract the parameters of the function call. Function '".concat(o,"' (type=").concat(a,"). callParamsStartIndex=").concat(d,", callParams=")+p),c=u+o.length}}else c=u+o.length}}return t},r.prototype._replaceNames=function(t,e,n){for(var i=function(a){var s=new RegExp(e[a].replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),l=e[a].length,c=n[a];t=t.replace(s,function(u){for(var d=[],h=1;h<arguments.length;h++)d[h-1]=arguments[h];var p=d[0];return vg(t.charAt(p-1))||vg(t.charAt(p+l))?e[a]:c})},o=0;o<e.length;++o)i(o);return t},r._RegexpFindFunctionNameAndType=/((\s+?)(\w+)\s+(\w+)\s*?)$/,r}(),dD=/(flat\s)?\s*varying\s*.*/,hD=function(){function r(){this.shaderLanguage=0}return r.prototype.initializeShaders=function(t){this._nativeProcessingContext=t,this._nativeProcessingContext&&(this._nativeProcessingContext.remappedAttributeNames={},this._nativeProcessingContext.injectInVertexMain="")},r.prototype.attributeProcessor=function(t){if(!this._nativeProcessingContext)return t.replace("attribute","in");var e=/\s*(?:attribute|in)\s+(\S+)\s+(\S+)\s*;/gm.exec(t);if(e!==null){var n=e[1],i=e[2],o=this._nativeProcessingContext.vertexBufferKindToNumberOfComponents[i];if(o!==void 0){var a=o<0?o===-1?"int":"ivec"+-o:o===1?"uint":"uvec"+o,s="_int_".concat(i,"_");t=t.replace(e[0],"in ".concat(a," ").concat(s,"; ").concat(n," ").concat(i,";")),this._nativeProcessingContext.injectInVertexMain+="".concat(i," = ").concat(n,"(").concat(s,`);
|
||
`),this._nativeProcessingContext.remappedAttributeNames[i]=s}else t=t.replace(e[0],"in ".concat(n," ").concat(i,";"))}return t},r.prototype.varyingCheck=function(t,e){return dD.test(t)},r.prototype.varyingProcessor=function(t,e){return t.replace("varying",e?"in":"out")},r.prototype.postProcessor=function(t,e,n){var i,o=t.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1;if(t=(t=t.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"")).replace(/texture2D\s*\(/g,"texture("),n){var a=t.search(/layout *\(location *= *0\) *out/g)!==-1;t=(t=(t=(t=(t=(t=(t=t.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(o||a?"":`layout(location = 0) out vec4 glFragColor;
|
||
`)+"void main(")}else if(!((i=this._nativeProcessingContext)===null||i===void 0)&&i.injectInVertexMain&&(t=qu(t,"void main",this._nativeProcessingContext.injectInVertexMain)),e.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require
|
||
layout (num_views = 2) in;
|
||
`+t;return t},r}(),fD=function(){function r(t,e,n){this.isCompiled=!1,this.vertexBufferKindToType={},this._valueCache={},this._engine=t,this.isAsync=e,this.shaderProcessingContext=n}return Object.defineProperty(r.prototype,"isReady",{get:function(){if(this.compilationError){var t=this.compilationError.message;throw new Error("SHADER ERROR"+(typeof t=="string"?`
|
||
`+t:""))}return this.isCompiled},enumerable:!1,configurable:!0}),r.prototype._getVertexShaderCode=function(){return null},r.prototype._getFragmentShaderCode=function(){return null},r.prototype._fillEffectInformation=function(t,e,n,i,o,a,s,l){var c,u=this._engine;if(u.supportsUniformBuffers)for(var d in e)t.bindUniformBlock(d,e[d]);for(this._engine.getUniforms(this,n).forEach(function(h,p){i[n[p]]=h}),this._uniforms=i,c=0;c<o.length;c++)t.getUniform(o[c])==null&&(o.splice(c,1),c--);o.forEach(function(h,p){a[h]=p}),l.push.apply(l,u.getAttributes(this,s))},r.prototype.setEngine=function(t){this._engine=t},r.prototype.dispose=function(){this._uniforms={}},r.prototype._cacheMatrix=function(t,e){var n=this._valueCache[t],i=e.updateFlag;return(n===void 0||n!==i)&&(this._valueCache[t]=i,!0)},r.prototype._cacheFloat2=function(t,e,n){var i=this._valueCache[t];if(!i)return i=[e,n],this._valueCache[t]=i,!0;var o=!1;return i[0]!==e&&(i[0]=e,o=!0),i[1]!==n&&(i[1]=n,o=!0),o},r.prototype._cacheFloat3=function(t,e,n,i){var o=this._valueCache[t];if(!o)return o=[e,n,i],this._valueCache[t]=o,!0;var a=!1;return o[0]!==e&&(o[0]=e,a=!0),o[1]!==n&&(o[1]=n,a=!0),o[2]!==i&&(o[2]=i,a=!0),a},r.prototype._cacheFloat4=function(t,e,n,i,o){var a=this._valueCache[t];if(!a)return a=[e,n,i,o],this._valueCache[t]=a,!0;var s=!1;return a[0]!==e&&(a[0]=e,s=!0),a[1]!==n&&(a[1]=n,s=!0),a[2]!==i&&(a[2]=i,s=!0),a[3]!==o&&(a[3]=o,s=!0),s},r.prototype.setInt=function(t,e){var n=this._valueCache[t];n!==void 0&&n===e||this._engine.setInt(this._uniforms[t],e)&&(this._valueCache[t]=e)},r.prototype.setInt2=function(t,e,n){this._cacheFloat2(t,e,n)&&(this._engine.setInt2(this._uniforms[t],e,n)||(this._valueCache[t]=null))},r.prototype.setInt3=function(t,e,n,i){this._cacheFloat3(t,e,n,i)&&(this._engine.setInt3(this._uniforms[t],e,n,i)||(this._valueCache[t]=null))},r.prototype.setInt4=function(t,e,n,i,o){this._cacheFloat4(t,e,n,i,o)&&(this._engine.setInt4(this._uniforms[t],e,n,i,o)||(this._valueCache[t]=null))},r.prototype.setIntArray=function(t,e){this._valueCache[t]=null,this._engine.setIntArray(this._uniforms[t],e)},r.prototype.setIntArray2=function(t,e){this._valueCache[t]=null,this._engine.setIntArray2(this._uniforms[t],e)},r.prototype.setIntArray3=function(t,e){this._valueCache[t]=null,this._engine.setIntArray3(this._uniforms[t],e)},r.prototype.setIntArray4=function(t,e){this._valueCache[t]=null,this._engine.setIntArray4(this._uniforms[t],e)},r.prototype.setUInt=function(t,e){var n=this._valueCache[t];n!==void 0&&n===e||this._engine.setUInt(this._uniforms[t],e)&&(this._valueCache[t]=e)},r.prototype.setUInt2=function(t,e,n){this._cacheFloat2(t,e,n)&&(this._engine.setUInt2(this._uniforms[t],e,n)||(this._valueCache[t]=null))},r.prototype.setUInt3=function(t,e,n,i){this._cacheFloat3(t,e,n,i)&&(this._engine.setUInt3(this._uniforms[t],e,n,i)||(this._valueCache[t]=null))},r.prototype.setUInt4=function(t,e,n,i,o){this._cacheFloat4(t,e,n,i,o)&&(this._engine.setUInt4(this._uniforms[t],e,n,i,o)||(this._valueCache[t]=null))},r.prototype.setUIntArray=function(t,e){this._valueCache[t]=null,this._engine.setUIntArray(this._uniforms[t],e)},r.prototype.setUIntArray2=function(t,e){this._valueCache[t]=null,this._engine.setUIntArray2(this._uniforms[t],e)},r.prototype.setUIntArray3=function(t,e){this._valueCache[t]=null,this._engine.setUIntArray3(this._uniforms[t],e)},r.prototype.setUIntArray4=function(t,e){this._valueCache[t]=null,this._engine.setUIntArray4(this._uniforms[t],e)},r.prototype.setFloatArray=function(t,e){this._valueCache[t]=null,this._engine.setFloatArray(this._uniforms[t],e)},r.prototype.setFloatArray2=function(t,e){this._valueCache[t]=null,this._engine.setFloatArray2(this._uniforms[t],e)},r.prototype.setFloatArray3=function(t,e){this._valueCache[t]=null,this._engine.setFloatArray3(this._uniforms[t],e)},r.prototype.setFloatArray4=function(t,e){this._valueCache[t]=null,this._engine.setFloatArray4(this._uniforms[t],e)},r.prototype.setArray=function(t,e){this._valueCache[t]=null,this._engine.setArray(this._uniforms[t],e)},r.prototype.setArray2=function(t,e){this._valueCache[t]=null,this._engine.setArray2(this._uniforms[t],e)},r.prototype.setArray3=function(t,e){this._valueCache[t]=null,this._engine.setArray3(this._uniforms[t],e)},r.prototype.setArray4=function(t,e){this._valueCache[t]=null,this._engine.setArray4(this._uniforms[t],e)},r.prototype.setMatrices=function(t,e){e&&(this._valueCache[t]=null,this._engine.setMatrices(this._uniforms[t],e))},r.prototype.setMatrix=function(t,e){this._cacheMatrix(t,e)&&(this._engine.setMatrices(this._uniforms[t],e.asArray())||(this._valueCache[t]=null))},r.prototype.setMatrix3x3=function(t,e){this._valueCache[t]=null,this._engine.setMatrix3x3(this._uniforms[t],e)},r.prototype.setMatrix2x2=function(t,e){this._valueCache[t]=null,this._engine.setMatrix2x2(this._uniforms[t],e)},r.prototype.setFloat=function(t,e){var n=this._valueCache[t];n!==void 0&&n===e||this._engine.setFloat(this._uniforms[t],e)&&(this._valueCache[t]=e)},r.prototype.setBool=function(t,e){var n=this._valueCache[t];n!==void 0&&n===e||this._engine.setInt(this._uniforms[t],e?1:0)&&(this._valueCache[t]=e?1:0)},r.prototype.setVector2=function(t,e){this._cacheFloat2(t,e.x,e.y)&&(this._engine.setFloat2(this._uniforms[t],e.x,e.y)||(this._valueCache[t]=null))},r.prototype.setFloat2=function(t,e,n){this._cacheFloat2(t,e,n)&&(this._engine.setFloat2(this._uniforms[t],e,n)||(this._valueCache[t]=null))},r.prototype.setVector3=function(t,e){this._cacheFloat3(t,e.x,e.y,e.z)&&(this._engine.setFloat3(this._uniforms[t],e.x,e.y,e.z)||(this._valueCache[t]=null))},r.prototype.setFloat3=function(t,e,n,i){this._cacheFloat3(t,e,n,i)&&(this._engine.setFloat3(this._uniforms[t],e,n,i)||(this._valueCache[t]=null))},r.prototype.setVector4=function(t,e){this._cacheFloat4(t,e.x,e.y,e.z,e.w)&&(this._engine.setFloat4(this._uniforms[t],e.x,e.y,e.z,e.w)||(this._valueCache[t]=null))},r.prototype.setQuaternion=function(t,e){this._cacheFloat4(t,e.x,e.y,e.z,e.w)&&(this._engine.setFloat4(this._uniforms[t],e.x,e.y,e.z,e.w)||(this._valueCache[t]=null))},r.prototype.setFloat4=function(t,e,n,i,o){this._cacheFloat4(t,e,n,i,o)&&(this._engine.setFloat4(this._uniforms[t],e,n,i,o)||(this._valueCache[t]=null))},r.prototype.setColor3=function(t,e){this._cacheFloat3(t,e.r,e.g,e.b)&&(this._engine.setFloat3(this._uniforms[t],e.r,e.g,e.b)||(this._valueCache[t]=null))},r.prototype.setColor4=function(t,e,n){this._cacheFloat4(t,e.r,e.g,e.b,n)&&(this._engine.setFloat4(this._uniforms[t],e.r,e.g,e.b,n)||(this._valueCache[t]=null))},r.prototype.setDirectColor4=function(t,e){this._cacheFloat4(t,e.r,e.g,e.b,e.a)&&(this._engine.setFloat4(this._uniforms[t],e.r,e.g,e.b,e.a)||(this._valueCache[t]=null))},r}(),pD=function(r){function t(e,n,i,o){var a=r.call(this,e,n,i,o)||this;return a.__framebuffer=null,a.__framebufferDepthStencil=null,a._engine=o,a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"_framebuffer",{get:function(){return this.__framebuffer},set:function(e){this.__framebuffer&&this._engine._releaseFramebufferObjects(this.__framebuffer),this.__framebuffer=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_framebufferDepthStencil",{get:function(){return this.__framebufferDepthStencil},set:function(e){this.__framebufferDepthStencil&&this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil),this.__framebufferDepthStencil=e},enumerable:!1,configurable:!0}),t.prototype.dispose=function(e){e===void 0&&(e=!1),this._framebuffer=null,this._framebufferDepthStencil=null,r.prototype.dispose.call(this,e)},t}(nl.v),jE=function(){function r(t,e){this._engine=e,this.set(t)}return Object.defineProperty(r.prototype,"underlyingResource",{get:function(){return this._nativeTexture},enumerable:!1,configurable:!0}),r.prototype.setUsage=function(){},r.prototype.set=function(t){this._nativeTexture=t},r.prototype.reset=function(){this._nativeTexture=null},r.prototype.release=function(){this._nativeTexture&&this._engine.deleteTexture(this._nativeTexture),this.reset()},r}();function bg(r,t){switch(r){case P.Y.TEXTUREFORMAT_DEPTH16:return _native.Engine.TEXTURE_FORMAT_D16;case P.Y.TEXTUREFORMAT_DEPTH24:return _native.Engine.TEXTURE_FORMAT_D24;case P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:return _native.Engine.TEXTURE_FORMAT_D24S8;case P.Y.TEXTUREFORMAT_DEPTH32_FLOAT:return _native.Engine.TEXTURE_FORMAT_D32F;case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:return _native.Engine.TEXTURE_FORMAT_BC7;case P.Y.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:return _native.Engine.TEXTURE_FORMAT_BC6H;case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:return _native.Engine.TEXTURE_FORMAT_BC3;case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:return _native.Engine.TEXTURE_FORMAT_BC2;case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:case P.Y.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:return _native.Engine.TEXTURE_FORMAT_BC1;case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:return _native.Engine.TEXTURE_FORMAT_ASTC4x4;case P.Y.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:return _native.Engine.TEXTURE_FORMAT_ETC1;case P.Y.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:return _native.Engine.TEXTURE_FORMAT_ETC2;case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:return _native.Engine.TEXTURE_FORMAT_ETC2A;case P.Y.TEXTUREFORMAT_RGB:switch(t){case P.Y.TEXTURETYPE_UNSIGNED_BYTE:return _native.Engine.TEXTURE_FORMAT_RGB8;case P.Y.TEXTURETYPE_BYTE:return _native.Engine.TEXTURE_FORMAT_RGB8S;case P.Y.TEXTURETYPE_INT:return _native.Engine.TEXTURE_FORMAT_RGB8I;case P.Y.TEXTURETYPE_UNSIGNED_INTEGER:return _native.Engine.TEXTURE_FORMAT_RGB8U}break;case P.Y.TEXTUREFORMAT_RGBA:switch(t){case P.Y.TEXTURETYPE_UNSIGNED_BYTE:return _native.Engine.TEXTURE_FORMAT_RGBA8;case P.Y.TEXTURETYPE_FLOAT:return _native.Engine.TEXTURE_FORMAT_RGBA32F;case P.Y.TEXTURETYPE_HALF_FLOAT:return _native.Engine.TEXTURE_FORMAT_RGBA16F;case P.Y.TEXTURETYPE_BYTE:return _native.Engine.TEXTURE_FORMAT_RGBA8S;case P.Y.TEXTURETYPE_SHORT:return _native.Engine.TEXTURE_FORMAT_RGBA16I;case P.Y.TEXTURETYPE_UNSIGNED_SHORT:return _native.Engine.TEXTURE_FORMAT_RGBA16U;case P.Y.TEXTURETYPE_INT:return _native.Engine.TEXTURE_FORMAT_RGBA32I;case P.Y.TEXTURETYPE_UNSIGNED_INTEGER:return _native.Engine.TEXTURE_FORMAT_RGBA32U}break;case P.Y.TEXTUREFORMAT_R:switch(t){case P.Y.TEXTURETYPE_UNSIGNED_BYTE:return _native.Engine.TEXTURE_FORMAT_R8;case P.Y.TEXTURETYPE_FLOAT:return _native.Engine.TEXTURE_FORMAT_R32F;case P.Y.TEXTURETYPE_HALF_FLOAT:return _native.Engine.TEXTURE_FORMAT_R16F;case P.Y.TEXTURETYPE_BYTE:return _native.Engine.TEXTURE_FORMAT_R8S;case P.Y.TEXTURETYPE_SHORT:return _native.Engine.TEXTURE_FORMAT_R16S;case P.Y.TEXTURETYPE_UNSIGNED_SHORT:return _native.Engine.TEXTURE_FORMAT_R16U;case P.Y.TEXTURETYPE_INT:return _native.Engine.TEXTURE_FORMAT_R32I;case P.Y.TEXTURETYPE_UNSIGNED_INTEGER:return _native.Engine.TEXTURE_FORMAT_R32U}break;case P.Y.TEXTUREFORMAT_RG:switch(t){case P.Y.TEXTURETYPE_UNSIGNED_BYTE:return _native.Engine.TEXTURE_FORMAT_RG8;case P.Y.TEXTURETYPE_FLOAT:return _native.Engine.TEXTURE_FORMAT_RG32F;case P.Y.TEXTURETYPE_HALF_FLOAT:return _native.Engine.TEXTURE_FORMAT_RG16F;case P.Y.TEXTURETYPE_BYTE:return _native.Engine.TEXTURE_FORMAT_RG8S;case P.Y.TEXTURETYPE_SHORT:return _native.Engine.TEXTURE_FORMAT_RG16S;case P.Y.TEXTURETYPE_UNSIGNED_SHORT:return _native.Engine.TEXTURE_FORMAT_RG16U;case P.Y.TEXTURETYPE_INT:return _native.Engine.TEXTURE_FORMAT_RG32I;case P.Y.TEXTURETYPE_UNSIGNED_INTEGER:return _native.Engine.TEXTURE_FORMAT_RG32U}break;case P.Y.TEXTUREFORMAT_BGRA:if(t===P.Y.TEXTURETYPE_UNSIGNED_BYTE)return _native.Engine.TEXTURE_FORMAT_BGRA8}throw new Bi.bu("Unsupported texture format or type: format ".concat(r,", type ").concat(t,"."),Bi.tG.UnsupportedTextureError)}function rl(r){switch(r){case P.Y.TEXTURE_NEAREST_NEAREST:return _native.Engine.TEXTURE_NEAREST_NEAREST;case P.Y.TEXTURE_LINEAR_LINEAR:return _native.Engine.TEXTURE_LINEAR_LINEAR;case P.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR:return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR;case P.Y.TEXTURE_NEAREST_NEAREST_MIPNEAREST:return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST;case P.Y.TEXTURE_NEAREST_LINEAR_MIPNEAREST:return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST;case P.Y.TEXTURE_NEAREST_LINEAR_MIPLINEAR:return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR;case P.Y.TEXTURE_NEAREST_LINEAR:return _native.Engine.TEXTURE_NEAREST_LINEAR;case P.Y.TEXTURE_NEAREST_NEAREST_MIPLINEAR:return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR;case P.Y.TEXTURE_LINEAR_NEAREST_MIPNEAREST:return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST;case P.Y.TEXTURE_LINEAR_NEAREST_MIPLINEAR:return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR;case P.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST:return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST;case P.Y.TEXTURE_LINEAR_NEAREST:return _native.Engine.TEXTURE_LINEAR_NEAREST;default:throw new Error("Unsupported sampling mode: ".concat(r,"."))}}function Tg(r){switch(r){case P.Y.TEXTURE_WRAP_ADDRESSMODE:return _native.Engine.ADDRESS_MODE_WRAP;case P.Y.TEXTURE_CLAMP_ADDRESSMODE:return _native.Engine.ADDRESS_MODE_CLAMP;case P.Y.TEXTURE_MIRROR_ADDRESSMODE:return _native.Engine.ADDRESS_MODE_MIRROR;default:throw new Error("Unexpected wrap mode: "+r+".")}}function _D(r){switch(r){case Y.R.BYTE:return _native.Engine.ATTRIB_TYPE_INT8;case Y.R.UNSIGNED_BYTE:return _native.Engine.ATTRIB_TYPE_UINT8;case Y.R.SHORT:return _native.Engine.ATTRIB_TYPE_INT16;case Y.R.UNSIGNED_SHORT:return _native.Engine.ATTRIB_TYPE_UINT16;case Y.R.FLOAT:return _native.Engine.ATTRIB_TYPE_FLOAT;default:throw new Error("Unsupported attribute type: ".concat(r,"."))}}var mD=((ki={})[Y.R.PositionKind]=!0,ki[Y.R.NormalKind]=!0,ki[Y.R.TangentKind]=!0,ki[Y.R.UVKind]=!0,ki[Y.R.UV2Kind]=!0,ki[Y.R.UV3Kind]=!0,ki[Y.R.UV4Kind]=!0,ki[Y.R.UV5Kind]=!0,ki[Y.R.UV6Kind]=!0,ki[Y.R.ColorKind]=!0,ki[Y.R.ColorInstanceKind]=!0,ki[Y.R.MatricesIndicesKind]=!0,ki[Y.R.MatricesWeightsKind]=!0,ki[Y.R.MatricesIndicesExtraKind]=!0,ki[Y.R.MatricesWeightsExtraKind]=!0,ki);function gD(r){switch(r){case Y.R.BYTE:case Y.R.SHORT:case Y.R.INT:case Y.R.FLOAT:return!0;case Y.R.UNSIGNED_BYTE:case Y.R.UNSIGNED_SHORT:case Y.R.UNSIGNED_INT:return!1;default:throw new Error("Invalid type '".concat(r,"'"))}}function qE(r,t){var e=t.getEngine(),n=t._pipelineContext;if(n?.vertexBufferKindToType){var i=null;for(var o in r){var a=r[o];if(a&&mD[o]){var s=a.normalized?Y.R.FLOAT:a.type,l=n.vertexBufferKindToType[o];(s!==Y.R.FLOAT&&l===void 0||l!==void 0&&l!==s)&&(i||(i=e._getShaderProcessingContext(t.shaderLanguage,!1)),n.vertexBufferKindToType[o]=s,s!==Y.R.FLOAT&&(i.vertexBufferKindToNumberOfComponents[o]=Y.R.DeduceStride(o),gD(s)&&(i.vertexBufferKindToNumberOfComponents[o]*=-1)))}}if(i){var c=e._caps.parallelShaderCompile;e._caps.parallelShaderCompile=void 0,t._processShaderCodeAsync(null,e._features._checkNonFloatVertexBuffersDontRecreatePipelineContext,i),e._caps.parallelShaderCompile=c}}}var Sg,vD=function(){this.vertexBufferKindToNumberOfComponents={},this.remappedAttributeNames={},this.injectInVertexMain=""},la=L(1235),KE=new K.cP;function Eg(){return new Promise(function(r){typeof _native>"u"?KE.addOnce(function(t){return r(t)}):r(_native)})}function xg(r,t){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return[4,Eg()];case 1:return e.sent()[r]=t,[2]}})})}typeof self>"u"||Object.prototype.hasOwnProperty.call(self,"_native")||Object.defineProperty(self,"_native",{get:function(){return Sg},set:function(r){(Sg=r)&&KE.notifyObservers(Sg)}});var ZE=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t}($o.n),yD=function(){function r(t){this._engine=t,this._pending=new Array,this._isCommandBufferScopeActive=!1,this._commandStream=Ku._createNativeDataStream(),this._engine.setCommandDataStream(this._commandStream)}return r.prototype.beginCommandScope=function(){if(this._isCommandBufferScopeActive)throw new Error("Command scope already active.");this._isCommandBufferScopeActive=!0},r.prototype.endCommandScope=function(){if(!this._isCommandBufferScopeActive)throw new Error("Command scope is not active.");this._isCommandBufferScopeActive=!1,this._submit()},r.prototype.startEncodingCommand=function(t){this._commandStream.writeNativeData(t)},r.prototype.encodeCommandArgAsUInt32=function(t){this._commandStream.writeUint32(t)},r.prototype.encodeCommandArgAsUInt32s=function(t){this._commandStream.writeUint32Array(t)},r.prototype.encodeCommandArgAsInt32=function(t){this._commandStream.writeInt32(t)},r.prototype.encodeCommandArgAsInt32s=function(t){this._commandStream.writeInt32Array(t)},r.prototype.encodeCommandArgAsFloat32=function(t){this._commandStream.writeFloat32(t)},r.prototype.encodeCommandArgAsFloat32s=function(t){this._commandStream.writeFloat32Array(t)},r.prototype.encodeCommandArgAsNativeData=function(t){this._commandStream.writeNativeData(t),this._pending.push(t)},r.prototype.finishEncodingCommand=function(){this._isCommandBufferScopeActive||this._submit()},r.prototype._submit=function(){this._engine.submitCommands(),this._pending.length=0},r}(),Pg=[],Ku=function(r){function t(e){e===void 0&&(e={});var n=r.call(this,null,!1,void 0,e.adaptToDeviceRatio)||this;if(n._engine=new _native.Engine({version:Zt.Version,nonFloatVertexBuffers:!0}),n._camera=_native.Camera?new _native.Camera:null,n._commandBufferEncoder=new yD(n._engine),n._boundBuffersVertexArray=null,n._currentDepthTest=_native.Engine.DEPTH_TEST_LEQUAL,n._stencilTest=!1,n._stencilMask=255,n._stencilFunc=P.Y.ALWAYS,n._stencilFuncRef=0,n._stencilFuncMask=255,n._stencilOpStencilFail=P.Y.KEEP,n._stencilOpDepthFail=P.Y.KEEP,n._stencilOpStencilDepthPass=P.Y.REPLACE,n._zOffset=0,n._zOffsetUnits=0,n._depthWrite=!0,n._fillModeWarningDisplayed=!1,_native.Engine.PROTOCOL_VERSION!==t.PROTOCOL_VERSION)throw new Error("Protocol version mismatch: ".concat(_native.Engine.PROTOCOL_VERSION," (Native) !== ").concat(t.PROTOCOL_VERSION," (JS)"));n._engine.setDeviceLostCallback&&n._engine.setDeviceLostCallback(function(){n.onContextLostObservable.notifyObservers(n),n._contextWasLost=!0,n._restoreEngineAfterContextLost()}),n._webGLVersion=2,n.disableUniformBuffers=!0,n._shaderPlatformName="NATIVE",n._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:_native.Engine.CAPS_LIMITS_MAX_TEXTURE_SIZE,maxCubemapTextureSize:512,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,maxDrawBuffers:8,maxFragmentUniformVectors:16,maxVertexUniformVectors:16,standardDerivatives:!0,astc:null,pvrtc:null,etc1:null,etc2:null,bptc:null,maxAnisotropy:16,uintIndices:!0,fragmentDepthSupported:!1,highPrecisionShaderSupported:!0,colorBufferFloat:!1,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,textureFloat:!0,textureFloatLinearFiltering:!0,textureFloatRender:!0,textureHalfFloat:!0,textureHalfFloatLinearFiltering:!0,textureHalfFloatRender:!0,textureLOD:!0,texelFetch:!1,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!0,instancedArrays:!0,supportOcclusionQuery:!1,canUseTimestampForTimerQuery:!1,blendMinMax:!1,maxMSAASamples:16,canUseGLInstanceID:!0,canUseGLVertexID:!0,supportComputeShaders:!1,supportSRGBBuffers:!0,supportTransformFeedbacks:!1,textureMaxLevel:!1,texture2DArrayMaxLayerCount:_native.Engine.CAPS_LIMITS_MAX_TEXTURE_LAYERS,disableMorphTargetTexture:!1,parallelShaderCompile:{COMPLETION_STATUS_KHR:0}},n._features={forceBitmapOverHTMLImageElement:!0,supportRenderAndCopyToLodForFloatTextures:!1,supportDepthStencilTexture:!1,supportShadowSamplers:!1,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:!1,trackUbosInFrame:!1,checkUbosContentBeforeUpload:!1,supportCSM:!1,basisNeedsPOT:!1,support3DTextures:!1,needTypeSuffixInShaderConstants:!1,supportMSAA:!0,supportSSAO2:!1,supportIBLShadows:!1,supportExtendedTextureFormats:!1,supportSwitchCaseInShader:!1,supportSyncTextureRead:!1,needsInvertingBitmap:!0,useUBOBindingCache:!0,needShaderCodeInlining:!0,needToAlwaysBindUniformBuffers:!1,supportRenderPasses:!0,supportSpriteInstancing:!1,forceVertexBufferStrideAndOffsetMultiple4Bytes:!0,_checkNonFloatVertexBuffersDontRecreatePipelineContext:!1,_collectUbosUpdatedInFrame:!1},ze.S0.Log("Babylon Native (v"+Zt.Version+") launched"),ze.S0.LoadScript=function(a,s,l,c){ze.S0.LoadFile(a,function(u){Function(u).apply(null),s&&s()},void 0,void 0,!1,function(u,d){l&&l("LoadScript Error",d)})},typeof URL>"u"&&(window.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),typeof Blob>"u"&&(window.Blob=function(a){return a}),Array.prototype.flat||Object.defineProperty(Array.prototype,"flat",{configurable:!0,value:function a(){var s=isNaN(arguments[0])?1:Number(arguments[0]);return s?Array.prototype.reduce.call(this,function(l,c){return Array.isArray(c)?l.push.apply(l,a.call(c,s-1)):l.push(c),l},[]):Array.prototype.slice.call(this)},writable:!0});var i=window&&window.devicePixelRatio||1;n._hardwareScalingLevel=e.adaptToDeviceRatio?1/i:1,n._engine.setHardwareScalingLevel(n._hardwareScalingLevel),n._lastDevicePixelRatio=i,n.resize();var o=n.getDepthFunction();return o&&n.setDepthFunction(o),n._shaderProcessor=new hD,n.onNewSceneAddedObservable.add(function(a){var s=a.render;a.render=function(){for(var l=[],c=0;c<arguments.length;c++)l[c]=arguments[c];n._commandBufferEncoder.beginCommandScope(),s.apply(a,l),n._commandBufferEncoder.endCommandScope()}}),n}return(0,A.C6)(t,r),t.prototype.setHardwareScalingLevel=function(e){r.prototype.setHardwareScalingLevel.call(this,e),this._engine.setHardwareScalingLevel(e)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._boundBuffersVertexArray&&this._deleteVertexArray(this._boundBuffersVertexArray),this._engine.dispose()},t._createNativeDataStream=function(){return new il},t.prototype._queueNewFrame=function(e,n){return n.requestAnimationFrame&&n!==window?n.requestAnimationFrame(e):this._engine.requestAnimationFrame(e),0},t.prototype._restoreEngineAfterContextLost=function(){this._clearEmptyResources();var e=this._depthCullingState.depthTest,n=this._depthCullingState.depthFunc,i=this._depthCullingState.depthMask,o=this._stencilState.stencilTest;this._rebuildGraphicsResources(),this._depthCullingState.depthTest=e,this._depthCullingState.depthFunc=n,this._depthCullingState.depthMask=i,this._stencilState.stencilTest=o,this._flagContextRestored()},t.prototype._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._currentFramebuffer&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNBINDFRAMEBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(this._currentFramebuffer),this._commandBufferEncoder.finishEncodingCommand()),e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDFRAMEBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand()),this._currentFramebuffer=e)},t.prototype.getHostDocument=function(){return null},t.prototype.clear=function(e,n,i,o){if(o===void 0&&(o=!1),this.useReverseDepthBuffer)throw new Error("reverse depth buffer is not currently implemented");this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_CLEAR),this._commandBufferEncoder.encodeCommandArgAsUInt32(n&&e?1:0),this._commandBufferEncoder.encodeCommandArgAsFloat32(e?e.r:0),this._commandBufferEncoder.encodeCommandArgAsFloat32(e?e.g:0),this._commandBufferEncoder.encodeCommandArgAsFloat32(e?e.b:0),this._commandBufferEncoder.encodeCommandArgAsFloat32(e?e.a:1),this._commandBufferEncoder.encodeCommandArgAsUInt32(i?1:0),this._commandBufferEncoder.encodeCommandArgAsFloat32(1),this._commandBufferEncoder.encodeCommandArgAsUInt32(o?1:0),this._commandBufferEncoder.encodeCommandArgAsUInt32(0),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.createIndexBuffer=function(e,n,i){var o=this._normalizeIndexData(e),a=new ZE;return a.references=1,a.is32Bits=o.BYTES_PER_ELEMENT===4,o.byteLength&&(a.nativeIndexBuffer=this._engine.createIndexBuffer(o.buffer,o.byteOffset,o.byteLength,a.is32Bits,n!=null&&n)),a},t.prototype.createVertexBuffer=function(e,n,i){var o=ArrayBuffer.isView(e)?e:new Float32Array(e),a=new ZE;return a.references=1,o.byteLength&&(a.nativeVertexBuffer=this._engine.createVertexBuffer(o.buffer,o.byteOffset,o.byteLength,n!=null&&n)),a},t.prototype._recordVertexArrayObject=function(e,n,i,o,a){o._checkedNonFloatVertexBuffers||(qE(n,o),o._checkedNonFloatVertexBuffers=!0),i&&this._engine.recordIndexBuffer(e,i.nativeIndexBuffer);for(var s=o.getAttributesNames(),l=0;l<s.length;l++){var c=o.getAttributeLocation(l);if(c>=0){var u=s[l],d=null;if(a&&(d=a[u]),d||(d=n[u]),d){var h=d.effectiveBuffer;h&&h.nativeVertexBuffer&&this._engine.recordVertexBuffer(e,h.nativeVertexBuffer,c,d.effectiveByteOffset,d.effectiveByteStride,d.getSize(),_D(d.type),d.normalized,d.getInstanceDivisor())}}}},t.prototype.bindBuffers=function(e,n,i){this._boundBuffersVertexArray&&this._deleteVertexArray(this._boundBuffersVertexArray),this._boundBuffersVertexArray=this._engine.createVertexArray(),this._recordVertexArrayObject(this._boundBuffersVertexArray,e,n,i),this.bindVertexArrayObject(this._boundBuffersVertexArray)},t.prototype.recordVertexArrayObject=function(e,n,i,o){var a=this._engine.createVertexArray();return this._recordVertexArrayObject(a,e,n,i,o),a},t.prototype._deleteVertexArray=function(e){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.bindVertexArrayObject=function(e){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.releaseVertexArrayObject=function(e){this._deleteVertexArray(e)},t.prototype.getAttributes=function(e,n){var i,o=e,a=o.shaderProcessingContext;Pg.length=0;for(var s=0;s<n.length;s++){var l=n[s],c=(i=a.remappedAttributeNames[l])!==null&&i!==void 0?i:l;Pg[s]=c}return this._engine.getAttributes(o.program,Pg)},t.prototype._checkSupportedFillMode=function(e){return e!=P.Y.MATERIAL_LineLoopDrawMode&&e!=P.Y.MATERIAL_TriangleFanDrawMode||(this._fillModeWarningDisplayed||(O.V.Warn("Line Loop and Triangle Fan are not supported fill modes with Babylon Native. Elements with these fill mode will not be visible."),this._fillModeWarningDisplayed=!0),!1)},t.prototype.drawElementsType=function(e,n,i,o){this._checkSupportedFillMode(e)&&(this._drawCalls.addCount(1,!1),o&&_native.Engine.COMMAND_DRAWINDEXEDINSTANCED?(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXEDINSTANCED),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.encodeCommandArgAsUInt32(o)):(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.encodeCommandArgAsUInt32(i)),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.drawArraysType=function(e,n,i,o){this._checkSupportedFillMode(e)&&(this._drawCalls.addCount(1,!1),o&&_native.Engine.COMMAND_DRAWINSTANCED?(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINSTANCED),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.encodeCommandArgAsUInt32(o)):(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.encodeCommandArgAsUInt32(i)),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.createPipelineContext=function(e){var n=!(!this._caps.parallelShaderCompile||!this._engine.createProgramAsync);return new fD(this,n,e)},t.prototype.createMaterialContext=function(){},t.prototype.createDrawContext=function(){},t.prototype._preparePipelineContext=function(e,n,i,o,a,s,l,c,u,d,h){o?this.createRawShaderProgram():this.createShaderProgram(e,n,i,c),h()},t.prototype._getShaderProcessingContext=function(e){return new vD},t.prototype._executeWhenRenderingStateIsCompiled=function(e,n){var i=e;if(i.isAsync)if(i.onCompiled){var o=i.onCompiled;i.onCompiled=function(){o(),n()}}else i.onCompiled=n;else n()},t.prototype.createRawShaderProgram=function(){throw new Error("Not Supported")},t.prototype.createShaderProgram=function(e,n,i,o){var a=this,s=e;this.onBeforeShaderCompilationObservable.notifyObservers(this);var l=new Ga(n);l.processCode(),n=l.code;var c=new Ga(i);c.processCode(),i=c.code,n=an.w._ConcatenateShader(n,o),i=an.w._ConcatenateShader(i,o);var u=function(){var h;s.isCompiled=!0,(h=s.onCompiled)===null||h===void 0||h.call(s),a.onAfterShaderCompilationObservable.notifyObservers(a)};if(e.isAsync)s.program=this._engine.createProgramAsync(n,i,u,function(h){s.compilationError=h});else try{s.program=this._engine.createProgram(n,i),u()}catch(h){var d=h?.message;throw new Error("SHADER ERROR"+(typeof d=="string"?`
|
||
`+d:""))}return s.program},t.prototype.inlineShaderCode=function(e){var n=new Ga(e);return n.debug=!1,n.processCode(),n.code},t.prototype._setProgram=function(e){this._currentProgram!==e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand(),this._currentProgram=e)},t.prototype._deletePipelineContext=function(e){var n=e;n&&n.program&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),this._commandBufferEncoder.encodeCommandArgAsNativeData(n.program),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.getUniforms=function(e,n){var i=e;return this._engine.getUniforms(i.program,n)},t.prototype.bindUniformBlock=function(e,n,i){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var n=e.getPipelineContext();this._setProgram(n.program);for(var i=e.getSamplers(),o=0;o<i.length;o++){var a=e.getUniform(i[o]);a&&(this._boundUniforms[o]=a)}this._currentEffect=null},t.prototype.getRenderWidth=function(e){return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._engine.getRenderWidth()},t.prototype.getRenderHeight=function(e){return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._engine.getRenderHeight()},t.prototype.setViewport=function(e,n,i){this._cachedViewport=e,this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETVIEWPORT),this._commandBufferEncoder.encodeCommandArgAsFloat32(e.x),this._commandBufferEncoder.encodeCommandArgAsFloat32(e.y),this._commandBufferEncoder.encodeCommandArgAsFloat32(e.width),this._commandBufferEncoder.encodeCommandArgAsFloat32(e.height),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.enableScissor=function(e,n,i,o){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSCISSOR),this._commandBufferEncoder.encodeCommandArgAsFloat32(e),this._commandBufferEncoder.encodeCommandArgAsFloat32(n),this._commandBufferEncoder.encodeCommandArgAsFloat32(i),this._commandBufferEncoder.encodeCommandArgAsFloat32(o),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.disableScissor=function(){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSCISSOR),this._commandBufferEncoder.encodeCommandArgAsFloat32(0),this._commandBufferEncoder.encodeCommandArgAsFloat32(0),this._commandBufferEncoder.encodeCommandArgAsFloat32(0),this._commandBufferEncoder.encodeCommandArgAsFloat32(0),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.setState=function(e,n,i,o,a,s,l){var c,u;n===void 0&&(n=0),o===void 0&&(o=!1),l===void 0&&(l=0),this._zOffset=n,this._zOffsetUnits=l,this._zOffset!==0&&ze.S0.Warn("zOffset is not supported in Native engine."),this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTATE),this._commandBufferEncoder.encodeCommandArgAsUInt32(e?1:0),this._commandBufferEncoder.encodeCommandArgAsFloat32(n),this._commandBufferEncoder.encodeCommandArgAsFloat32(l),this._commandBufferEncoder.encodeCommandArgAsUInt32((u=(c=this.cullBackFaces)!==null&&c!==void 0?c:a)===null||u===void 0||u?1:0),this._commandBufferEncoder.encodeCommandArgAsUInt32(o?1:0),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.getInputElementClientRect=function(){return{bottom:this.getRenderHeight(),height:this.getRenderHeight(),left:0,right:this.getRenderWidth(),top:0,width:this.getRenderWidth(),x:0,y:0,toJSON:function(){}}},t.prototype.setZOffset=function(e){e!==this._zOffset&&(this._zOffset=e,this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSET),this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer?-e:e),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.getZOffset=function(){return this._zOffset},t.prototype.setZOffsetUnits=function(e){e!==this._zOffsetUnits&&(this._zOffsetUnits=e,this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSETUNITS),this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer?-e:e),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.getZOffsetUnits=function(){return this._zOffsetUnits},t.prototype.setDepthBuffer=function(e){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),this._commandBufferEncoder.encodeCommandArgAsUInt32(e?this._currentDepthTest:_native.Engine.DEPTH_TEST_ALWAYS),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.getDepthWrite=function(){return this._depthWrite},t.prototype.getDepthFunction=function(){switch(this._currentDepthTest){case _native.Engine.DEPTH_TEST_NEVER:return P.Y.NEVER;case _native.Engine.DEPTH_TEST_ALWAYS:return P.Y.ALWAYS;case _native.Engine.DEPTH_TEST_GREATER:return P.Y.GREATER;case _native.Engine.DEPTH_TEST_GEQUAL:return P.Y.GEQUAL;case _native.Engine.DEPTH_TEST_NOTEQUAL:return P.Y.NOTEQUAL;case _native.Engine.DEPTH_TEST_EQUAL:return P.Y.EQUAL;case _native.Engine.DEPTH_TEST_LESS:return P.Y.LESS;case _native.Engine.DEPTH_TEST_LEQUAL:return P.Y.LEQUAL}return null},t.prototype.setDepthFunction=function(e){var n=0;switch(e){case P.Y.NEVER:n=_native.Engine.DEPTH_TEST_NEVER;break;case P.Y.ALWAYS:n=_native.Engine.DEPTH_TEST_ALWAYS;break;case P.Y.GREATER:n=_native.Engine.DEPTH_TEST_GREATER;break;case P.Y.GEQUAL:n=_native.Engine.DEPTH_TEST_GEQUAL;break;case P.Y.NOTEQUAL:n=_native.Engine.DEPTH_TEST_NOTEQUAL;break;case P.Y.EQUAL:n=_native.Engine.DEPTH_TEST_EQUAL;break;case P.Y.LESS:n=_native.Engine.DEPTH_TEST_LESS;break;case P.Y.LEQUAL:n=_native.Engine.DEPTH_TEST_LEQUAL}this._currentDepthTest=n,this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),this._commandBufferEncoder.encodeCommandArgAsUInt32(this._currentDepthTest),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.setDepthWrite=function(e){this._depthWrite=e,this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHWRITE),this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.setColorWrite=function(e){this._colorWrite=e,this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETCOLORWRITE),this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.getColorWrite=function(){return this._colorWrite},t.prototype.applyStencil=function(){this._setStencil(this._stencilMask,function(e){switch(e){case P.Y.KEEP:return _native.Engine.STENCIL_OP_FAIL_S_KEEP;case P.Y.ZERO:return _native.Engine.STENCIL_OP_FAIL_S_ZERO;case P.Y.REPLACE:return _native.Engine.STENCIL_OP_FAIL_S_REPLACE;case P.Y.INCR:return _native.Engine.STENCIL_OP_FAIL_S_INCR;case P.Y.DECR:return _native.Engine.STENCIL_OP_FAIL_S_DECR;case P.Y.INVERT:return _native.Engine.STENCIL_OP_FAIL_S_INVERT;case P.Y.INCR_WRAP:return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT;case P.Y.DECR_WRAP:return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT;default:throw new Error("Unsupported stencil OpFail mode: ".concat(e,"."))}}(this._stencilOpStencilFail),function(e){switch(e){case P.Y.KEEP:return _native.Engine.STENCIL_OP_FAIL_Z_KEEP;case P.Y.ZERO:return _native.Engine.STENCIL_OP_FAIL_Z_ZERO;case P.Y.REPLACE:return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE;case P.Y.INCR:return _native.Engine.STENCIL_OP_FAIL_Z_INCR;case P.Y.DECR:return _native.Engine.STENCIL_OP_FAIL_Z_DECR;case P.Y.INVERT:return _native.Engine.STENCIL_OP_FAIL_Z_INVERT;case P.Y.INCR_WRAP:return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT;case P.Y.DECR_WRAP:return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT;default:throw new Error("Unsupported stencil depthFail mode: ".concat(e,"."))}}(this._stencilOpDepthFail),function(e){switch(e){case P.Y.KEEP:return _native.Engine.STENCIL_OP_PASS_Z_KEEP;case P.Y.ZERO:return _native.Engine.STENCIL_OP_PASS_Z_ZERO;case P.Y.REPLACE:return _native.Engine.STENCIL_OP_PASS_Z_REPLACE;case P.Y.INCR:return _native.Engine.STENCIL_OP_PASS_Z_INCR;case P.Y.DECR:return _native.Engine.STENCIL_OP_PASS_Z_DECR;case P.Y.INVERT:return _native.Engine.STENCIL_OP_PASS_Z_INVERT;case P.Y.INCR_WRAP:return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT;case P.Y.DECR_WRAP:return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT;default:throw new Error("Unsupported stencil opPass mode: ".concat(e,"."))}}(this._stencilOpStencilDepthPass),function(e){switch(e){case P.Y.LESS:return _native.Engine.STENCIL_TEST_LESS;case P.Y.LEQUAL:return _native.Engine.STENCIL_TEST_LEQUAL;case P.Y.EQUAL:return _native.Engine.STENCIL_TEST_EQUAL;case P.Y.GEQUAL:return _native.Engine.STENCIL_TEST_GEQUAL;case P.Y.GREATER:return _native.Engine.STENCIL_TEST_GREATER;case P.Y.NOTEQUAL:return _native.Engine.STENCIL_TEST_NOTEQUAL;case P.Y.NEVER:return _native.Engine.STENCIL_TEST_NEVER;case P.Y.ALWAYS:return _native.Engine.STENCIL_TEST_ALWAYS;default:throw new Error("Unsupported stencil func mode: ".concat(e,"."))}}(this._stencilFunc),this._stencilFuncRef)},t.prototype._setStencil=function(e,n,i,o,a,s){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.encodeCommandArgAsUInt32(o),this._commandBufferEncoder.encodeCommandArgAsUInt32(a),this._commandBufferEncoder.encodeCommandArgAsUInt32(s),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.setStencilBuffer=function(e){this._stencilTest=e,e?this.applyStencil():this._setStencil(255,_native.Engine.STENCIL_OP_FAIL_S_KEEP,_native.Engine.STENCIL_OP_FAIL_Z_KEEP,_native.Engine.STENCIL_OP_PASS_Z_KEEP,_native.Engine.STENCIL_TEST_ALWAYS,0)},t.prototype.getStencilBuffer=function(){return this._stencilTest},t.prototype.getStencilOperationPass=function(){return this._stencilOpStencilDepthPass},t.prototype.setStencilOperationPass=function(e){this._stencilOpStencilDepthPass=e,this.applyStencil()},t.prototype.setStencilMask=function(e){this._stencilMask=e,this.applyStencil()},t.prototype.setStencilFunction=function(e){this._stencilFunc=e,this.applyStencil()},t.prototype.setStencilFunctionReference=function(e){this._stencilFuncRef=e,this.applyStencil()},t.prototype.setStencilFunctionMask=function(e){this._stencilFuncMask=e},t.prototype.setStencilOperationFail=function(e){this._stencilOpStencilFail=e,this.applyStencil()},t.prototype.setStencilOperationDepthFail=function(e){this._stencilOpDepthFail=e,this.applyStencil()},t.prototype.getStencilMask=function(){return this._stencilMask},t.prototype.getStencilFunction=function(){return this._stencilFunc},t.prototype.getStencilFunctionReference=function(){return this._stencilFuncRef},t.prototype.getStencilFunctionMask=function(){return this._stencilFuncMask},t.prototype.getStencilOperationFail=function(){return this._stencilOpStencilFail},t.prototype.getStencilOperationDepthFail=function(){return this._stencilOpDepthFail},t.prototype.setAlphaConstants=function(e,n,i,o){throw new Error("Setting alpha blend constant color not yet implemented.")},t.prototype.setAlphaMode=function(e,n){if(n===void 0&&(n=!1),this._alphaMode!==e){var i=function(o){switch(o){case P.Y.ALPHA_DISABLE:return _native.Engine.ALPHA_DISABLE;case P.Y.ALPHA_ADD:return _native.Engine.ALPHA_ADD;case P.Y.ALPHA_COMBINE:return _native.Engine.ALPHA_COMBINE;case P.Y.ALPHA_SUBTRACT:return _native.Engine.ALPHA_SUBTRACT;case P.Y.ALPHA_MULTIPLY:return _native.Engine.ALPHA_MULTIPLY;case P.Y.ALPHA_MAXIMIZED:return _native.Engine.ALPHA_MAXIMIZED;case P.Y.ALPHA_ONEONE:return _native.Engine.ALPHA_ONEONE;case P.Y.ALPHA_PREMULTIPLIED:return _native.Engine.ALPHA_PREMULTIPLIED;case P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF:return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;case P.Y.ALPHA_INTERPOLATE:return _native.Engine.ALPHA_INTERPOLATE;case P.Y.ALPHA_SCREENMODE:return _native.Engine.ALPHA_SCREENMODE;default:throw new Error("Unsupported alpha mode: ".concat(o,"."))}}(e);this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETBLENDMODE),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.finishEncodingCommand(),n||this.setDepthWrite(e===P.Y.ALPHA_DISABLE),this._alphaMode=e}},t.prototype.setInt=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINT),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsInt32(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setIntArray=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsInt32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setIntArray2=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY2),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsInt32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setIntArray3=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY3),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsInt32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setIntArray4=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY4),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsInt32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloatArray=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloatArray2=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY2),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloatArray3=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY3),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloatArray4=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY4),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setArray=function(e,n){return!!e&&this.setFloatArray(e,new Float32Array(n))},t.prototype.setArray2=function(e,n){return!!e&&this.setFloatArray2(e,new Float32Array(n))},t.prototype.setArray3=function(e,n){return!!e&&this.setFloatArray3(e,new Float32Array(n))},t.prototype.setArray4=function(e,n){return!!e&&this.setFloatArray4(e,new Float32Array(n))},t.prototype.setMatrices=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRICES),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setMatrix3x3=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX3X3),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setMatrix2x2=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX2X2),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32s(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloat=function(e,n){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32(n),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloat2=function(e,n,i){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT2),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32(n),this._commandBufferEncoder.encodeCommandArgAsFloat32(i),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloat3=function(e,n,i,o){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32(n),this._commandBufferEncoder.encodeCommandArgAsFloat32(i),this._commandBufferEncoder.encodeCommandArgAsFloat32(o),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setFloat4=function(e,n,i,o,a){return!!e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsFloat32(n),this._commandBufferEncoder.encodeCommandArgAsFloat32(i),this._commandBufferEncoder.encodeCommandArgAsFloat32(o),this._commandBufferEncoder.encodeCommandArgAsFloat32(a),this._commandBufferEncoder.finishEncodingCommand(),!0)},t.prototype.setColor3=function(e,n){return!!e&&(this.setFloat3(e,n.r,n.g,n.b),!0)},t.prototype.setColor4=function(e,n,i){return!!e&&(this.setFloat4(e,n.r,n.g,n.b,i),!0)},t.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilStateComposer.reset(),this._depthCullingState.reset(),this._alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},t.prototype._createTexture=function(){return this._engine.createTexture()},t.prototype._deleteTexture=function(e){e&&this._engine.deleteTexture(e.underlyingResource)},t.prototype.updateDynamicTexture=function(e,n,i,o,a){if(e&&e._hardwareTexture){var s=n.getCanvasTexture(),l=e._hardwareTexture.underlyingResource;this._engine.copyTexture(l,s),e.isReady=!0}},t.prototype.createDynamicTexture=function(e,n,i,o){return e=Math.max(e,1),n=Math.max(n,1),this.createRawTexture(new Uint8Array(e*n*4),e,n,P.Y.TEXTUREFORMAT_RGBA,!1,!1,o)},t.prototype.createVideoElement=function(e){return this._camera?this._camera.createVideo(e):null},t.prototype.updateVideoTexture=function(e,n,i){if(e&&e._hardwareTexture&&this._camera){var o=e._hardwareTexture.underlyingResource;this._camera.updateVideoTexture(o,n,i)}},t.prototype.createRawTexture=function(e,n,i,o,a,s,l,c,u,d,h){c===void 0&&(c=null),u===void 0&&(u=P.Y.TEXTURETYPE_UNSIGNED_INT),h===void 0&&(h=!1);var p=new rn.h(this,3);if(p.format=o,p.generateMipMaps=a,p.samplingMode=l,p.invertY=s,p.baseWidth=n,p.baseHeight=i,p.width=p.baseWidth,p.height=p.baseHeight,p._compression=c,p.type=u,p._useSRGBBuffer=this._getUseSRGBBuffer(h,!a),this.updateRawTexture(p,e,o,s,c,u,p._useSRGBBuffer),p._hardwareTexture){var m=p._hardwareTexture.underlyingResource,v=rl(l);this._setTextureSampling(m,v)}return this._internalTexturesCache.push(p),p},t.prototype.createRawTexture2DArray=function(e,n,i,o,a,s,l,c,u,d){d===void 0&&(d=P.Y.TEXTURETYPE_UNSIGNED_INT);var h=new rn.h(this,11);if(h.baseWidth=n,h.baseHeight=i,h.baseDepth=o,h.width=n,h.height=i,h.depth=o,h.format=a,h.type=d,h.generateMipMaps=s,h.samplingMode=c,h.is2DArray=!0,h._hardwareTexture){var p=h._hardwareTexture.underlyingResource;this._engine.loadRawTexture2DArray(p,e,n,i,o,bg(a,d),s,l);var m=rl(c);this._setTextureSampling(p,m)}return h.isReady=!0,this._internalTexturesCache.push(h),h},t.prototype.updateRawTexture=function(e,n,i,o,a,s,l){if(s===void 0&&(s=P.Y.TEXTURETYPE_UNSIGNED_INT),e){if(n&&e._hardwareTexture){var c=e._hardwareTexture.underlyingResource;this._engine.loadRawTexture(c,n,e.width,e.height,bg(i,s),e.generateMipMaps,e.invertY)}e.isReady=!0}},t.prototype.createTexture=function(e,n,i,o,a,s,l,c,u,d,h,p,m,v,b){var E=this;a===void 0&&(a=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),s===void 0&&(s=null),l===void 0&&(l=null),c===void 0&&(c=null),u===void 0&&(u=null),d===void 0&&(d=null),h===void 0&&(h=null),b===void 0&&(b=!1);var C=(e=e||"").substring(0,5)==="data:",T=C&&e.indexOf(";base64,")!==-1,f=u||new rn.h(this,1),g=e;!this._transformTextureUrl||T||u||c||(e=this._transformTextureUrl(e));var S=e.lastIndexOf("."),y=h||(S>-1?e.substring(S).toLowerCase():""),x=null;(y.endsWith(".basis")||y.endsWith(".ktx")||y.endsWith(".ktx2")||p==="image/ktx"||p==="image/ktx2")&&(x=(0,la.gT)(y)),o&&o.addPendingData(f),f.url=e,f.generateMipMaps=!n,f.samplingMode=a,f.invertY=i,f._useSRGBBuffer=this._getUseSRGBBuffer(b,n),this.doNotHandleContextLost||(f._buffer=c);var R=null;if(s&&!u&&(R=f.onLoadedObservable.add(s)),u||this._internalTexturesCache.push(f),x)throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");var I=function(M){if(f._hardwareTexture){var D=f._hardwareTexture.underlyingResource;E._engine.loadTexture(D,M,!n,i,f._useSRGBBuffer,function(){f.baseWidth=E._engine.getTextureWidth(D),f.baseHeight=E._engine.getTextureHeight(D),f.width=f.baseWidth,f.height=f.baseHeight,f.isReady=!0;var B=rl(a);E._setTextureSampling(D,B),o&&o.removePendingData(f),f.onLoadedObservable.notifyObservers(f),f.onLoadedObservable.clear()},function(){throw new Error("Could not load a native texture.")})}else o&&o.removePendingData(f)};if(C&&c)if(c instanceof ArrayBuffer)I(new Uint8Array(c));else if(ArrayBuffer.isView(c))I(c);else{if(typeof c!="string")throw new Error("Unsupported buffer type");I(new Uint8Array(ze.S0.DecodeBase64(c)))}else T?I(new Uint8Array(ze.S0.DecodeBase64(e))):this._loadFile(e,function(M){return I(new Uint8Array(M))},void 0,void 0,!0,function(M,D){var B;B="Unable to load "+(M&&M.responseURL,D),o&&o.removePendingData(f),e===g?(R&&f.onLoadedObservable.remove(R),Ve.q.UseFallbackTexture&&E.createTexture(Ve.q.FallbackTexture,n,f.invertY,o,a,null,l,c,f),l&&l((B||"Unknown error")+(Ve.q.UseFallbackTexture?" - Fallback texture was used":""),void 0)):(O.V.Warn("Failed to load ".concat(e,", falling back to ").concat(g)),E.createTexture(g,n,f.invertY,o,a,s,l,c,f,d,h,p,m))});return f},t.prototype.wrapNativeTexture=function(e,n,i){n===void 0&&(n=!1),i===void 0&&(i=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE);var o=new jE(e,this._engine),a=new rn.h(this,0,!0);return a._hardwareTexture=o,a.baseWidth=this._engine.getTextureWidth(e),a.baseHeight=this._engine.getTextureHeight(e),a.width=a.baseWidth,a.height=a.baseHeight,a.isReady=!0,a.useMipMaps=n,this.updateTextureSamplingMode(i,a),a},t.prototype.wrapWebGLTexture=function(){throw new Error("wrapWebGLTexture is not supported, use wrapNativeTexture instead.")},t.prototype._createDepthStencilTexture=function(e,n,i){var o,a,s=n.generateStencil||!1,l=n.samples||1,c=i,u=new rn.h(this,12),d=(o=e.width)!==null&&o!==void 0?o:e,h=(a=e.height)!==null&&a!==void 0?a:e,p=this._engine.createFrameBuffer(u._hardwareTexture.underlyingResource,d,h,s,!0,l);return c._framebufferDepthStencil=p,u},t.prototype._releaseFramebufferObjects=function(e){e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEFRAMEBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand())},t.prototype._createImageBitmapFromSource=function(e,n){var i=this,o=new Promise(function(a,s){var l=i.createCanvasImage();l.onload=function(){try{var c=i._engine.createImageBitmap(l);a(c)}catch(u){s("Error loading image ".concat(l.src," with exception: ").concat(u))}},l.onerror=function(c){s("Error loading image ".concat(l.src," with exception: ").concat(c))},l.src=e});return o},t.prototype.createImageBitmap=function(e,n){var i=this;return new Promise(function(o,a){if(Array.isArray(e)){var s=e;if(s.length){var l=i._engine.createImageBitmap(s[0]);if(l)return void o(l)}}a("Unsupported data for createImageBitmap.")})},t.prototype.resizeImageBitmap=function(e,n,i){return this._engine.resizeImageBitmap(e,n,i)},t.prototype.createCubeTexture=function(e,n,i,o,a,s,l,c,u,d,h,p,m,v,b){var E=this;a===void 0&&(a=null),s===void 0&&(s=null),c===void 0&&(c=null),d===void 0&&(d=0),h===void 0&&(h=0),p===void 0&&(p=null),v===void 0&&(v=!1),b===void 0&&(b=null);var C=p||new rn.h(this,7);C.isCube=!0,C.url=e,C.generateMipMaps=!o,C._lodGenerationScale=d,C._lodGenerationOffset=h,C._useSRGBBuffer=this._getUseSRGBBuffer(v,!!o),this._doNotHandleContextLost||(C._extension=c,C._files=i,C._buffer=b);var T=e.lastIndexOf(".");if((c||(T>-1?e.substring(T).toLowerCase():""))===".env"){var f=function(S){var y=(0,ni.cU)(S);C.width=y.width,C.height=y.width,(0,ni.ow)(C,y);var x=y.specular;if(!x)throw new Error("Nothing else parsed so far");C._lodGenerationScale=x.lodGenerationScale;var R=(0,ni.$h)(S,y);C.format=P.Y.TEXTUREFORMAT_RGBA,C.type=P.Y.TEXTURETYPE_UNSIGNED_INT,C.generateMipMaps=!0,C.getEngine().updateTextureSamplingMode(Ie.g.TRILINEAR_SAMPLINGMODE,C),C._isRGBD=!0,C.invertY=!0,E._engine.loadCubeTextureWithMips(C._hardwareTexture.underlyingResource,R,!1,C._useSRGBBuffer,function(){C.isReady=!0,a&&a()},function(){throw new Error("Could not load a native cube texture.")})};if(b)f(b);else{if(i&&i.length===6)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,function(S){f(new Uint8Array(S,0,S.byteLength))},void 0,void 0,!0,function(S,y){s&&S&&s(S.status+" "+S.statusText,y)})}}else{if(!i||i.length!==6)throw new Error("Cannot load cubemap because 6 files were not defined");var g=[i[0],i[3],i[1],i[4],i[2],i[5]];Promise.all(g.map(function(S){return E._loadFileAsync(S,void 0,!0).then(function(y){return new Uint8Array(y,0,y.byteLength)})})).then(function(S){return new Promise(function(y,x){E._engine.loadCubeTexture(C._hardwareTexture.underlyingResource,S,!o,!0,C._useSRGBBuffer,y,x)})}).then(function(){C.isReady=!0,a&&a()},function(S){s&&s("Failed to load cubemap: ".concat(S.message),S)})}return this._internalTexturesCache.push(C),C},t.prototype._createHardwareTexture=function(){return new jE(this._createTexture(),this._engine)},t.prototype._createHardwareRenderTargetWrapper=function(e,n,i){var o=new pD(e,n,i,this);return this._renderTargetWrapperCache.push(o),o},t.prototype._createInternalTexture=function(e,n,i,o){var a,s,l;o===void 0&&(o=0);var c,u=!1,d=P.Y.TEXTURETYPE_UNSIGNED_INT,h=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,p=P.Y.TEXTUREFORMAT_RGBA,m=!1,v=1;n!==void 0&&typeof n=="object"?(u=!!n.generateMipMaps,d=n.type===void 0?P.Y.TEXTURETYPE_UNSIGNED_INT:n.type,h=n.samplingMode===void 0?P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:n.samplingMode,p=n.format===void 0?P.Y.TEXTUREFORMAT_RGBA:n.format,m=n.useSRGBBuffer!==void 0&&n.useSRGBBuffer,v=(a=n.samples)!==null&&a!==void 0?a:1,c=n.label):u=!!n,m=this._getUseSRGBBuffer(m,!u),(d!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(d!==P.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(h=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),d!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloat||(d=P.Y.TEXTURETYPE_UNSIGNED_INT,O.V.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));var b=new rn.h(this,o),E=(s=e.width)!==null&&s!==void 0?s:e,C=(l=e.height)!==null&&l!==void 0?l:e,T=e.layers||0;if(T!==0)throw new Error("Texture layers are not supported in Babylon Native");var f=b._hardwareTexture.underlyingResource,g=bg(p,d);return this._engine.initializeTexture(f,E,C,u,g,!0,m,v),this._setTextureSampling(f,rl(h)),b._useSRGBBuffer=m,b.baseWidth=E,b.baseHeight=C,b.width=E,b.height=C,b.depth=T,b.isReady=!0,b.samples=v,b.generateMipMaps=u,b.samplingMode=h,b.type=d,b.format=p,b.label=c,this._internalTexturesCache.push(b),b},t.prototype.createRenderTargetTexture=function(e,n){var i,o,a,s,l=this._createHardwareRenderTargetWrapper(!1,!1,e),c=!0,u=!1,d=!1,h=void 0,p=1;n!==void 0&&typeof n=="object"&&(c=(i=n.generateDepthBuffer)===null||i===void 0||i,u=!!n.generateStencilBuffer,d=!!n.noColorAttachment,h=n.colorAttachment,p=(o=n.samples)!==null&&o!==void 0?o:1);var m=h||(d?null:this._createInternalTexture(e,n,!0,5)),v=(a=e.width)!==null&&a!==void 0?a:e,b=(s=e.height)!==null&&s!==void 0?s:e,E=this._engine.createFrameBuffer(m?m._hardwareTexture.underlyingResource:null,v,b,u,c,p);return l._framebuffer=E,l._generateDepthBuffer=c,l._generateStencilBuffer=u,l._samples=p,l.setTextures(m),l},t.prototype.updateRenderTargetTextureSampleCount=function(e,n){return O.V.Warn("Updating render target sample count is not currently supported"),e.samples},t.prototype.updateTextureSamplingMode=function(e,n){if(n._hardwareTexture){var i=rl(e);this._setTextureSampling(n._hardwareTexture.underlyingResource,i)}n.samplingMode=e},t.prototype.bindFramebuffer=function(e,n,i,o,a){var s=e;if(this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,n)throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");if(i||o)throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");s._framebufferDepthStencil?this._bindUnboundFramebuffer(s._framebufferDepthStencil):this._bindUnboundFramebuffer(s._framebuffer)},t.prototype.unBindFramebuffer=function(e,n,i){this._currentRenderTarget=null,i&&i(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){return this.createVertexBuffer(e,!0)},t.prototype.updateDynamicIndexBuffer=function(e,n,i){i===void 0&&(i=0);var o=e,a=this._normalizeIndexData(n);o.is32Bits=a.BYTES_PER_ELEMENT===4,this._engine.updateDynamicIndexBuffer(o.nativeIndexBuffer,a.buffer,a.byteOffset,a.byteLength,i)},t.prototype.updateDynamicVertexBuffer=function(e,n,i,o){i===void 0&&(i=0);var a=e,s=n instanceof Array?new Float32Array(n):n instanceof ArrayBuffer?new Uint8Array(n):n,l=new Uint8Array(s.buffer,s.byteOffset,o??s.byteLength);this._engine.updateDynamicVertexBuffer(a.nativeVertexBuffer,l.buffer,l.byteOffset,l.byteLength,i)},t.prototype._setTexture=function(e,n,i,o){o===void 0&&(o=!1);var a,s=this._boundUniforms[e];if(!s)return!1;if(!n)return this._boundTexturesCache[e]!=null&&(this._activeChannel=e,this._boundTexturesCache[e]=null,this._unsetNativeTexture(s)),!1;if(n.video)this._activeChannel=e,n.update();else if(n.delayLoadState===P.Y.DELAYLOADSTATE_NOTLOADED)return n.delayLoad(),!1;return a=o?n.depthStencilTexture:n.isReady()?n.getInternalTexture():n.isCube?this.emptyCubeTexture:n.is3D?this.emptyTexture3D:n.is2DArray?this.emptyTexture2DArray:this.emptyTexture,this._activeChannel=e,!(!a||!a._hardwareTexture||(this._setTextureWrapMode(a._hardwareTexture.underlyingResource,Tg(n.wrapU),Tg(n.wrapV),Tg(n.wrapR)),this._updateAnisotropicLevel(n),this._setNativeTexture(s,a._hardwareTexture.underlyingResource),0))},t.prototype._setTextureSampling=function(e,n){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._setTextureWrapMode=function(e,n,i,o){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.encodeCommandArgAsUInt32(o),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._setNativeTexture=function(e,n){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsNativeData(n),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._unsetNativeTexture=function(e){_native.Engine.COMMAND_UNSETTEXTURE&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNSETTEXTURE),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand())},t.prototype._updateAnisotropicLevel=function(e){var n=e.getInternalTexture(),i=e.anisotropicFilteringLevel;n&&n._hardwareTexture&&n._cachedAnisotropicFilteringLevel!==i&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL),this._commandBufferEncoder.encodeCommandArgAsNativeData(n._hardwareTexture.underlyingResource),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.finishEncodingCommand(),n._cachedAnisotropicFilteringLevel=i)},t.prototype._bindTexture=function(e,n){var i=this._boundUniforms[e];if(i)if(n&&n._hardwareTexture){var o=n._hardwareTexture.underlyingResource;this._setNativeTexture(i,o)}else this._unsetNativeTexture(i)},t.prototype.unbindAllTextures=function(){_native.Engine.COMMAND_DISCARDALLTEXTURES&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DISCARDALLTEXTURES),this._commandBufferEncoder.finishEncodingCommand())},t.prototype._deleteBuffer=function(e){e.nativeIndexBuffer&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeIndexBuffer),this._commandBufferEncoder.finishEncodingCommand(),delete e.nativeIndexBuffer),e.nativeVertexBuffer&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeVertexBuffer),this._commandBufferEncoder.finishEncodingCommand(),delete e.nativeVertexBuffer)},t.prototype.createCanvas=function(e,n){if(!_native.Canvas)throw new Error("Native Canvas plugin not available.");var i=new _native.Canvas;return i.width=e,i.height=n,i},t.prototype.createCanvasImage=function(){if(!_native.Canvas)throw new Error("Native Canvas plugin not available.");return new _native.Image},t.prototype.updateTextureData=function(e,n,i,o,a,s,l,c,u){throw new Error("updateTextureData not implemented.")},t.prototype._uploadCompressedDataToTextureDirectly=function(e,n,i,o,a,s,l){throw new Error("_uploadCompressedDataToTextureDirectly not implemented.")},t.prototype._uploadDataToTextureDirectly=function(e,n,i,o){throw new Error("_uploadDataToTextureDirectly not implemented.")},t.prototype._uploadArrayBufferViewToTexture=function(e,n,i,o){throw new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._uploadImageToTexture=function(e,n,i,o){throw new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype.getFontOffset=function(e){return{ascent:0,height:0,descent:0}},t.prototype.flushFramebuffer=function(){},t.prototype._readTexturePixels=function(e,n,i,o,a,s,l,c,u,d){var h,p,m,v;if(o!==void 0&&o!==-1)throw new Error("Reading cubemap faces is not supported, but faceIndex is ".concat(o,"."));return this._engine.readTexture((h=e._hardwareTexture)===null||h===void 0?void 0:h.underlyingResource,a??0,u??0,d??0,n,i,(p=s?.buffer)!==null&&p!==void 0?p:null,(m=s?.byteOffset)!==null&&m!==void 0?m:0,(v=s?.byteLength)!==null&&v!==void 0?v:0).then(function(b){return s||(s=new Uint8Array(b)),s})},t.PROTOCOL_VERSION=8,t}(Zt);Ku._createNativeDataStream=function(){return _native.NativeDataStream.VALIDATION_ENABLED?new Ag:new il};var Zu,Qu,Ju,nn,$u,ed,td,nd,id,rd,od,ad,sd,ld,cd,ud,dd,hd,fd,pd,_d,md,gd,vd,yd,bd,Td,Sd,Ed,xd,Pd,Ad,Cd,Rd,Id,Md,Od,Dd,Nd,Ld,Ag=function(r){function t(){return r.call(this)||this}return(0,A.C6)(t,r),t.prototype.writeUint32=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_UINT_32),r.prototype.writeUint32.call(this,e)},t.prototype.writeInt32=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_INT_32),r.prototype.writeInt32.call(this,e)},t.prototype.writeFloat32=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_FLOAT_32),r.prototype.writeFloat32.call(this,e)},t.prototype.writeUint32Array=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_UINT_32_ARRAY),r.prototype.writeUint32Array.call(this,e)},t.prototype.writeInt32Array=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_INT_32_ARRAY),r.prototype.writeInt32Array.call(this,e)},t.prototype.writeFloat32Array=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY),r.prototype.writeFloat32Array.call(this,e)},t.prototype.writeNativeData=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_NATIVE_DATA),r.prototype.writeNativeData.call(this,e)},t.prototype.writeBoolean=function(e){r.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_BOOLEAN),r.prototype.writeBoolean.call(this,e)},t}(il),Ge=L(51322);(function(r){r.LowPower="low-power",r.HighPerformance="high-performance"})(Zu||(Zu={})),function(r){r.DepthClipControl="depth-clip-control",r.Depth32FloatStencil8="depth32float-stencil8",r.TextureCompressionBC="texture-compression-bc",r.TextureCompressionETC2="texture-compression-etc2",r.TextureCompressionASTC="texture-compression-astc",r.TimestampQuery="timestamp-query",r.IndirectFirstInstance="indirect-first-instance",r.ShaderF16="shader-f16",r.RG11B10UFloatRenderable="rg11b10ufloat-renderable",r.BGRA8UnormStorage="bgra8unorm-storage",r.Float32Filterable="float32-filterable"}(Qu||(Qu={})),function(r){r.Unmapped="unmapped",r.Pending="pending",r.Mapped="mapped"}(Ju||(Ju={})),function(r){r[r.MapRead=1]="MapRead",r[r.MapWrite=2]="MapWrite",r[r.CopySrc=4]="CopySrc",r[r.CopyDst=8]="CopyDst",r[r.Index=16]="Index",r[r.Vertex=32]="Vertex",r[r.Uniform=64]="Uniform",r[r.Storage=128]="Storage",r[r.Indirect=256]="Indirect",r[r.QueryResolve=512]="QueryResolve"}(nn||(nn={})),function(r){r[r.Read=1]="Read",r[r.Write=2]="Write"}($u||($u={})),function(r){r.E1d="1d",r.E2d="2d",r.E3d="3d"}(ed||(ed={})),function(r){r[r.CopySrc=1]="CopySrc",r[r.CopyDst=2]="CopyDst",r[r.TextureBinding=4]="TextureBinding",r[r.StorageBinding=8]="StorageBinding",r[r.RenderAttachment=16]="RenderAttachment"}(td||(td={})),function(r){r.E1d="1d",r.E2d="2d",r.E2dArray="2d-array",r.Cube="cube",r.CubeArray="cube-array",r.E3d="3d"}(nd||(nd={})),function(r){r.All="all",r.StencilOnly="stencil-only",r.DepthOnly="depth-only"}(id||(id={})),function(r){r.R8Unorm="r8unorm",r.R8Snorm="r8snorm",r.R8Uint="r8uint",r.R8Sint="r8sint",r.R16Uint="r16uint",r.R16Sint="r16sint",r.R16Float="r16float",r.RG8Unorm="rg8unorm",r.RG8Snorm="rg8snorm",r.RG8Uint="rg8uint",r.RG8Sint="rg8sint",r.R32Uint="r32uint",r.R32Sint="r32sint",r.R32Float="r32float",r.RG16Uint="rg16uint",r.RG16Sint="rg16sint",r.RG16Float="rg16float",r.RGBA8Unorm="rgba8unorm",r.RGBA8UnormSRGB="rgba8unorm-srgb",r.RGBA8Snorm="rgba8snorm",r.RGBA8Uint="rgba8uint",r.RGBA8Sint="rgba8sint",r.BGRA8Unorm="bgra8unorm",r.BGRA8UnormSRGB="bgra8unorm-srgb",r.RGB9E5UFloat="rgb9e5ufloat",r.RGB10A2UINT="rgb10a2uint",r.RGB10A2Unorm="rgb10a2unorm",r.RG11B10UFloat="rg11b10ufloat",r.RG32Uint="rg32uint",r.RG32Sint="rg32sint",r.RG32Float="rg32float",r.RGBA16Uint="rgba16uint",r.RGBA16Sint="rgba16sint",r.RGBA16Float="rgba16float",r.RGBA32Uint="rgba32uint",r.RGBA32Sint="rgba32sint",r.RGBA32Float="rgba32float",r.Stencil8="stencil8",r.Depth16Unorm="depth16unorm",r.Depth24Plus="depth24plus",r.Depth24PlusStencil8="depth24plus-stencil8",r.Depth32Float="depth32float",r.BC1RGBAUnorm="bc1-rgba-unorm",r.BC1RGBAUnormSRGB="bc1-rgba-unorm-srgb",r.BC2RGBAUnorm="bc2-rgba-unorm",r.BC2RGBAUnormSRGB="bc2-rgba-unorm-srgb",r.BC3RGBAUnorm="bc3-rgba-unorm",r.BC3RGBAUnormSRGB="bc3-rgba-unorm-srgb",r.BC4RUnorm="bc4-r-unorm",r.BC4RSnorm="bc4-r-snorm",r.BC5RGUnorm="bc5-rg-unorm",r.BC5RGSnorm="bc5-rg-snorm",r.BC6HRGBUFloat="bc6h-rgb-ufloat",r.BC6HRGBFloat="bc6h-rgb-float",r.BC7RGBAUnorm="bc7-rgba-unorm",r.BC7RGBAUnormSRGB="bc7-rgba-unorm-srgb",r.ETC2RGB8Unorm="etc2-rgb8unorm",r.ETC2RGB8UnormSRGB="etc2-rgb8unorm-srgb",r.ETC2RGB8A1Unorm="etc2-rgb8a1unorm",r.ETC2RGB8A1UnormSRGB="etc2-rgb8a1unorm-srgb",r.ETC2RGBA8Unorm="etc2-rgba8unorm",r.ETC2RGBA8UnormSRGB="etc2-rgba8unorm-srgb",r.EACR11Unorm="eac-r11unorm",r.EACR11Snorm="eac-r11snorm",r.EACRG11Unorm="eac-rg11unorm",r.EACRG11Snorm="eac-rg11snorm",r.ASTC4x4Unorm="astc-4x4-unorm",r.ASTC4x4UnormSRGB="astc-4x4-unorm-srgb",r.ASTC5x4Unorm="astc-5x4-unorm",r.ASTC5x4UnormSRGB="astc-5x4-unorm-srgb",r.ASTC5x5Unorm="astc-5x5-unorm",r.ASTC5x5UnormSRGB="astc-5x5-unorm-srgb",r.ASTC6x5Unorm="astc-6x5-unorm",r.ASTC6x5UnormSRGB="astc-6x5-unorm-srgb",r.ASTC6x6Unorm="astc-6x6-unorm",r.ASTC6x6UnormSRGB="astc-6x6-unorm-srgb",r.ASTC8x5Unorm="astc-8x5-unorm",r.ASTC8x5UnormSRGB="astc-8x5-unorm-srgb",r.ASTC8x6Unorm="astc-8x6-unorm",r.ASTC8x6UnormSRGB="astc-8x6-unorm-srgb",r.ASTC8x8Unorm="astc-8x8-unorm",r.ASTC8x8UnormSRGB="astc-8x8-unorm-srgb",r.ASTC10x5Unorm="astc-10x5-unorm",r.ASTC10x5UnormSRGB="astc-10x5-unorm-srgb",r.ASTC10x6Unorm="astc-10x6-unorm",r.ASTC10x6UnormSRGB="astc-10x6-unorm-srgb",r.ASTC10x8Unorm="astc-10x8-unorm",r.ASTC10x8UnormSRGB="astc-10x8-unorm-srgb",r.ASTC10x10Unorm="astc-10x10-unorm",r.ASTC10x10UnormSRGB="astc-10x10-unorm-srgb",r.ASTC12x10Unorm="astc-12x10-unorm",r.ASTC12x10UnormSRGB="astc-12x10-unorm-srgb",r.ASTC12x12Unorm="astc-12x12-unorm",r.ASTC12x12UnormSRGB="astc-12x12-unorm-srgb",r.Depth32FloatStencil8="depth32float-stencil8"}(rd||(rd={})),function(r){r.ClampToEdge="clamp-to-edge",r.Repeat="repeat",r.MirrorRepeat="mirror-repeat"}(od||(od={})),function(r){r.Nearest="nearest",r.Linear="linear"}(ad||(ad={})),function(r){r.Nearest="nearest",r.Linear="linear"}(sd||(sd={})),function(r){r.Never="never",r.Less="less",r.Equal="equal",r.LessEqual="less-equal",r.Greater="greater",r.NotEqual="not-equal",r.GreaterEqual="greater-equal",r.Always="always"}(ld||(ld={})),function(r){r[r.Vertex=1]="Vertex",r[r.Fragment=2]="Fragment",r[r.Compute=4]="Compute"}(cd||(cd={})),function(r){r.Uniform="uniform",r.Storage="storage",r.ReadOnlyStorage="read-only-storage"}(ud||(ud={})),function(r){r.Filtering="filtering",r.NonFiltering="non-filtering",r.Comparison="comparison"}(dd||(dd={})),function(r){r.Float="float",r.UnfilterableFloat="unfilterable-float",r.Depth="depth",r.Sint="sint",r.Uint="uint"}(hd||(hd={})),function(r){r.WriteOnly="write-only",r.ReadOnly="read-only",r.ReadWrite="read-write"}(fd||(fd={})),function(r){r.Error="error",r.Warning="warning",r.Info="info"}(pd||(pd={})),function(r){r.Validation="validation",r.Internal="internal"}(_d||(_d={})),function(r){r.Auto="auto"}(md||(md={})),function(r){r.PointList="point-list",r.LineList="line-list",r.LineStrip="line-strip",r.TriangleList="triangle-list",r.TriangleStrip="triangle-strip"}(gd||(gd={})),function(r){r.CCW="ccw",r.CW="cw"}(vd||(vd={})),function(r){r.None="none",r.Front="front",r.Back="back"}(yd||(yd={})),function(r){r[r.Red=1]="Red",r[r.Green=2]="Green",r[r.Blue=4]="Blue",r[r.Alpha=8]="Alpha",r[r.All=15]="All"}(bd||(bd={})),function(r){r.Zero="zero",r.One="one",r.Src="src",r.OneMinusSrc="one-minus-src",r.SrcAlpha="src-alpha",r.OneMinusSrcAlpha="one-minus-src-alpha",r.Dst="dst",r.OneMinusDst="one-minus-dst",r.DstAlpha="dst-alpha",r.OneMinusDstAlpha="one-minus-dst-alpha",r.SrcAlphaSaturated="src-alpha-saturated",r.Constant="constant",r.OneMinusConstant="one-minus-constant"}(Td||(Td={})),function(r){r.Add="add",r.Subtract="subtract",r.ReverseSubtract="reverse-subtract",r.Min="min",r.Max="max"}(Sd||(Sd={})),function(r){r.Keep="keep",r.Zero="zero",r.Replace="replace",r.Invert="invert",r.IncrementClamp="increment-clamp",r.DecrementClamp="decrement-clamp",r.IncrementWrap="increment-wrap",r.DecrementWrap="decrement-wrap"}(Ed||(Ed={})),function(r){r.Uint16="uint16",r.Uint32="uint32"}(xd||(xd={})),function(r){r.Uint8x2="uint8x2",r.Uint8x4="uint8x4",r.Sint8x2="sint8x2",r.Sint8x4="sint8x4",r.Unorm8x2="unorm8x2",r.Unorm8x4="unorm8x4",r.Snorm8x2="snorm8x2",r.Snorm8x4="snorm8x4",r.Uint16x2="uint16x2",r.Uint16x4="uint16x4",r.Sint16x2="sint16x2",r.Sint16x4="sint16x4",r.Unorm16x2="unorm16x2",r.Unorm16x4="unorm16x4",r.Snorm16x2="snorm16x2",r.Snorm16x4="snorm16x4",r.Float16x2="float16x2",r.Float16x4="float16x4",r.Float32="float32",r.Float32x2="float32x2",r.Float32x3="float32x3",r.Float32x4="float32x4",r.Uint32="uint32",r.Uint32x2="uint32x2",r.Uint32x3="uint32x3",r.Uint32x4="uint32x4",r.Sint32="sint32",r.Sint32x2="sint32x2",r.Sint32x3="sint32x3",r.Sint32x4="sint32x4",r.UNORM10x10x10x2="unorm10-10-10-2"}(Pd||(Pd={})),function(r){r.Vertex="vertex",r.Instance="instance"}(Ad||(Ad={})),function(r){r.Beginning="beginning",r.End="end"}(Cd||(Cd={})),function(r){r.Beginning="beginning",r.End="end"}(Rd||(Rd={})),function(r){r.Load="load",r.Clear="clear"}(Id||(Id={})),function(r){r.Store="store",r.Discard="discard"}(Md||(Md={})),function(r){r.Occlusion="occlusion",r.Timestamp="timestamp"}(Od||(Od={})),function(r){r.Opaque="opaque",r.Premultiplied="premultiplied"}(Dd||(Dd={})),function(r){r.Unknown="unknown",r.Destroyed="destroyed"}(Nd||(Nd={})),function(r){r.Validation="validation",r.OutOfMemory="out-of-memory",r.Internal="internal"}(Ld||(Ld={}));var Er,ka,or=function(){function r(){this.shaderLanguage=0}return r.prototype._addUniformToLeftOverUBO=function(t,e,n){var i,o;t=(i=this._getArraySize(t,e,n))[0],e=i[1],o=i[2];for(var a=0;a<this._webgpuProcessingContext.leftOverUniforms.length;a++)if(this._webgpuProcessingContext.leftOverUniforms[a].name===t)return;this._webgpuProcessingContext.leftOverUniforms.push({name:t,type:e,length:o})},r.prototype._buildLeftOverUBO=function(){if(!this._webgpuProcessingContext.leftOverUniforms.length)return"";var t=r.LeftOvertUBOName,e=this._webgpuProcessingContext.availableBuffers[t];return e||(e={binding:this._webgpuProcessingContext.getNextFreeUBOBinding()},this._webgpuProcessingContext.availableBuffers[t]=e,this._addBufferBindingDescription(t,e,"uniform",!0),this._addBufferBindingDescription(t,e,"uniform",!1)),this._generateLeftOverUBOCode(t,e)},r.prototype._collectBindingNames=function(){for(var t=0;t<this._webgpuProcessingContext.bindGroupLayoutEntries.length;t++){var e=this._webgpuProcessingContext.bindGroupLayoutEntries[t];if(e!==void 0)for(var n=0;n<e.length;n++){var i=this._webgpuProcessingContext.bindGroupLayoutEntries[t][n],o=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[t][i.binding].name,a=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[t][i.binding].nameInArrayOfTexture;i&&(i.texture||i.externalTexture||i.storageTexture?this._webgpuProcessingContext.textureNames.push(a):i.sampler?this._webgpuProcessingContext.samplerNames.push(o):i.buffer&&this._webgpuProcessingContext.bufferNames.push(o))}else this._webgpuProcessingContext.bindGroupLayoutEntries[t]=[]}},r.prototype._preCreateBindGroupEntries=function(){for(var t=this._webgpuProcessingContext.bindGroupEntries,e=0;e<this._webgpuProcessingContext.bindGroupLayoutEntries.length;e++){for(var n=this._webgpuProcessingContext.bindGroupLayoutEntries[e],i=[],o=0;o<n.length;o++){var a=this._webgpuProcessingContext.bindGroupLayoutEntries[e][o];a.sampler||a.texture||a.storageTexture||a.externalTexture?i.push({binding:a.binding,resource:void 0}):a.buffer&&i.push({binding:a.binding,resource:{buffer:void 0,offset:0,size:0}})}t[e]=i}},r.prototype._addTextureBindingDescription=function(t,e,n,i,o,a){var s,l=(s=e.textures[n]).groupIndex,c=s.bindingIndex;if(this._webgpuProcessingContext.bindGroupLayoutEntries[l]||(this._webgpuProcessingContext.bindGroupLayoutEntries[l]=[],this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l]=[]),!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l][c]){var u;u=i===null?this._webgpuProcessingContext.bindGroupLayoutEntries[l].push({binding:c,visibility:0,externalTexture:{}}):o?this._webgpuProcessingContext.bindGroupLayoutEntries[l].push({binding:c,visibility:0,storageTexture:{access:"write-only",format:o,viewDimension:i}}):this._webgpuProcessingContext.bindGroupLayoutEntries[l].push({binding:c,visibility:0,texture:{sampleType:e.sampleType,viewDimension:i,multisampled:!1}});var d=e.isTextureArray?t+n:t;this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l][c]={name:t,index:u-1,nameInArrayOfTexture:d}}c=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[l][c].index,this._webgpuProcessingContext.bindGroupLayoutEntries[l][c].visibility|=a?1:2},r.prototype._addSamplerBindingDescription=function(t,e,n){var i,o=(i=e.binding).groupIndex,a=i.bindingIndex;if(this._webgpuProcessingContext.bindGroupLayoutEntries[o]||(this._webgpuProcessingContext.bindGroupLayoutEntries[o]=[],this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o]=[]),!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a]){var s=this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({binding:a,visibility:0,sampler:{type:e.type}});this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a]={name:t,index:s-1}}a=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a].index,this._webgpuProcessingContext.bindGroupLayoutEntries[o][a].visibility|=n?1:2},r.prototype._addBufferBindingDescription=function(t,e,n,i){var o,a=(o=e.binding).groupIndex,s=o.bindingIndex;if(this._webgpuProcessingContext.bindGroupLayoutEntries[a]||(this._webgpuProcessingContext.bindGroupLayoutEntries[a]=[],this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a]=[]),!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a][s]){var l=this._webgpuProcessingContext.bindGroupLayoutEntries[a].push({binding:s,visibility:0,buffer:{type:n}});this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a][s]={name:t,index:l-1}}s=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[a][s].index,this._webgpuProcessingContext.bindGroupLayoutEntries[a][s].visibility|=i?1:2},r.LeftOvertUBOName="LeftOver",r.InternalsUBOName="Internals",r.UniformSizes={bool:1,int:1,float:1,vec2:2,ivec2:2,uvec2:2,vec3:3,ivec3:3,uvec3:3,vec4:4,ivec4:4,uvec4:4,mat2:4,mat3:12,mat4:16,i32:1,u32:1,f32:1,mat2x2:4,mat3x3:12,mat4x4:16,mat2x2f:4,mat3x3f:12,mat4x4f:16,vec2i:2,vec3i:3,vec4i:4,vec2u:2,vec3u:3,vec4u:4,vec2f:2,vec3f:3,vec4f:4,vec2h:1,vec3h:2,vec4h:2},r._SamplerFunctionByWebGLSamplerType={sampler2D:"sampler2D",sampler2DArray:"sampler2DArray",sampler2DShadow:"sampler2DShadow",sampler2DArrayShadow:"sampler2DArrayShadow",samplerCube:"samplerCube",sampler3D:"sampler3D"},r._TextureTypeByWebGLSamplerType={sampler2D:"texture2D",sampler2DArray:"texture2DArray",sampler2DShadow:"texture2D",sampler2DArrayShadow:"texture2DArray",samplerCube:"textureCube",samplerCubeArray:"textureCubeArray",sampler3D:"texture3D"},r._GpuTextureViewDimensionByWebGPUTextureType={textureCube:"cube",textureCubeArray:"cube-array",texture2D:"2d",texture2DArray:"2d-array",texture3D:"3d"},r._SamplerTypeByWebGLSamplerType={sampler2DShadow:"samplerShadow",sampler2DArrayShadow:"samplerShadow"},r._IsComparisonSamplerByWebGPUSamplerType={samplerShadow:!0,samplerArrayShadow:!0,sampler:!1},r}(),bD=function(){function r(t,e){this.bindGroupLayouts={},this._name="unnamed",this.shaderProcessingContext=t,this._leftOverUniformsByName={},this.engine=e,this.vertexBufferKindToType={}}return Object.defineProperty(r.prototype,"isAsync",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isReady",{get:function(){return!!this.stages},enumerable:!1,configurable:!0}),r.prototype._handlesSpectorRebuildCallback=function(){},r.prototype._fillEffectInformation=function(t,e,n,i,o,a,s,l){var c=this.engine;c._doNotHandleContextLost&&(t._fragmentSourceCode="",t._vertexSourceCode="");var u,d=this.shaderProcessingContext.availableTextures;for(u=0;u<o.length;u++){var h=o[u],p=d[o[u]];p==null||p==null?(o.splice(u,1),u--):a[h]=u}for(var m=0,v=c.getAttributes(this,s);m<v.length;m++){var b=v[m];l.push(b)}this.buildUniformLayout();var E=[],C=[];for(u=0;u<s.length;u++){var T=l[u];T>=0&&(E.push(s[u]),C.push(T))}this.shaderProcessingContext.attributeNamesFromEffect=E,this.shaderProcessingContext.attributeLocationsFromEffect=C},r.prototype.buildUniformLayout=function(){if(this.shaderProcessingContext.leftOverUniforms.length){this.uniformBuffer=new Ui.D(this.engine,void 0,void 0,"leftOver-"+this._name);for(var t=0,e=this.shaderProcessingContext.leftOverUniforms;t<e.length;t++){var n=e[t],i=n.type.replace(/^(.*?)(<.*>)?$/,"$1"),o=or.UniformSizes[i];this.uniformBuffer.addUniform(n.name,o,n.length),this._leftOverUniformsByName[n.name]=n.type}this.uniformBuffer.create()}},r.prototype.setEngine=function(t){this.engine=t},r.prototype.dispose=function(){this.uniformBuffer&&this.uniformBuffer.dispose()},r.prototype.setInt=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateInt(t,e)},r.prototype.setInt2=function(t,e,n){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateInt2(t,e,n)},r.prototype.setInt3=function(t,e,n,i){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateInt3(t,e,n,i)},r.prototype.setInt4=function(t,e,n,i,o){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateInt4(t,e,n,i,o)},r.prototype.setIntArray=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateIntArray(t,e)},r.prototype.setIntArray2=function(t,e){this.setIntArray(t,e)},r.prototype.setIntArray3=function(t,e){this.setIntArray(t,e)},r.prototype.setIntArray4=function(t,e){this.setIntArray(t,e)},r.prototype.setUInt=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateUInt(t,e)},r.prototype.setUInt2=function(t,e,n){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateUInt2(t,e,n)},r.prototype.setUInt3=function(t,e,n,i){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateUInt3(t,e,n,i)},r.prototype.setUInt4=function(t,e,n,i,o){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateUInt4(t,e,n,i,o)},r.prototype.setUIntArray=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateUIntArray(t,e)},r.prototype.setUIntArray2=function(t,e){this.setUIntArray(t,e)},r.prototype.setUIntArray3=function(t,e){this.setUIntArray(t,e)},r.prototype.setUIntArray4=function(t,e){this.setUIntArray(t,e)},r.prototype.setArray=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateArray(t,e)},r.prototype.setArray2=function(t,e){this.setArray(t,e)},r.prototype.setArray3=function(t,e){this.setArray(t,e)},r.prototype.setArray4=function(t,e){this.setArray(t,e)},r.prototype.setMatrices=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateMatrices(t,e)},r.prototype.setMatrix=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateMatrix(t,e)},r.prototype.setMatrix3x3=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateMatrix3x3(t,e)},r.prototype.setMatrix2x2=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateMatrix2x2(t,e)},r.prototype.setFloat=function(t,e){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateFloat(t,e)},r.prototype.setVector2=function(t,e){this.setFloat2(t,e.x,e.y)},r.prototype.setFloat2=function(t,e,n){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateFloat2(t,e,n)},r.prototype.setVector3=function(t,e){this.setFloat3(t,e.x,e.y,e.z)},r.prototype.setFloat3=function(t,e,n,i){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateFloat3(t,e,n,i)},r.prototype.setVector4=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},r.prototype.setQuaternion=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},r.prototype.setFloat4=function(t,e,n,i,o){this.uniformBuffer&&this._leftOverUniformsByName[t]&&this.uniformBuffer.updateFloat4(t,e,n,i,o)},r.prototype.setColor3=function(t,e){this.setFloat3(t,e.r,e.g,e.b)},r.prototype.setColor4=function(t,e,n){this.setFloat4(t,e.r,e.g,e.b,n)},r.prototype.setDirectColor4=function(t,e){this.setFloat4(t,e.r,e.g,e.b,e.a)},r.prototype._getVertexShaderCode=function(){var t;return(t=this.sources)===null||t===void 0?void 0:t.vertex},r.prototype._getFragmentShaderCode=function(){var t;return(t=this.sources)===null||t===void 0?void 0:t.fragment},r}(),QE={mat2:2,mat3:3,mat4:4,mat2x2:2,mat3x3:3,mat4x4:4},za=function(){function r(t,e){e===void 0&&(e=!1),this.vertexBufferKindToNumberOfComponents={},this.shaderLanguage=t,this._attributeNextLocation=0,this._varyingNextLocation=0,this.freeGroupIndex=0,this.freeBindingIndex=0,this.availableVaryings={},this.availableAttributes={},this.availableBuffers={},this.availableTextures={},this.availableSamplers={},this.orderedAttributes=[],this.bindGroupLayoutEntries=[],this.bindGroupLayoutEntryInfo=[],this.bindGroupEntries=[],this.bufferNames=[],this.textureNames=[],this.samplerNames=[],this.leftOverUniforms=[],e||this._findStartingGroupBinding()}return Object.defineProperty(r,"KnownUBOs",{get:function(){return r._SimplifiedKnownBindings?r._SimplifiedKnownUBOs:r._KnownUBOs},enumerable:!1,configurable:!0}),r.prototype._findStartingGroupBinding=function(){var t=r.KnownUBOs,e=[];for(var n in t){var i=t[n].binding;i.groupIndex!==-1&&(e[i.groupIndex]===void 0?e[i.groupIndex]=i.bindingIndex:e[i.groupIndex]=Math.max(e[i.groupIndex],i.bindingIndex))}this.freeGroupIndex=e.length-1,this.freeGroupIndex===0?(this.freeGroupIndex++,this.freeBindingIndex=0):this.freeBindingIndex=e[e.length-1]+1},r.prototype.getAttributeNextLocation=function(t,e){var n;e===void 0&&(e=0);var i=this._attributeNextLocation;return this._attributeNextLocation+=((n=QE[t])!==null&&n!==void 0?n:1)*(e||1),i},r.prototype.getVaryingNextLocation=function(t,e){var n;e===void 0&&(e=0);var i=this._varyingNextLocation;return this._varyingNextLocation+=((n=QE[t])!==null&&n!==void 0?n:1)*(e||1),i},r.prototype.getNextFreeUBOBinding=function(){return this._getNextFreeBinding(1)},r.prototype._getNextFreeBinding=function(t){if(this.freeBindingIndex>65536-t&&(this.freeGroupIndex++,this.freeBindingIndex=0),this.freeGroupIndex===4)throw"Too many textures or UBOs have been declared and it is not supported in WebGPU.";var e={groupIndex:this.freeGroupIndex,bindingIndex:this.freeBindingIndex};return this.freeBindingIndex+=t,e},r._SimplifiedKnownBindings=!0,r._SimplifiedKnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:-1,bindingIndex:-1}},Light1:{binding:{groupIndex:-1,bindingIndex:-1}},Light2:{binding:{groupIndex:-1,bindingIndex:-1}},Light3:{binding:{groupIndex:-1,bindingIndex:-1}},Light4:{binding:{groupIndex:-1,bindingIndex:-1}},Light5:{binding:{groupIndex:-1,bindingIndex:-1}},Light6:{binding:{groupIndex:-1,bindingIndex:-1}},Light7:{binding:{groupIndex:-1,bindingIndex:-1}},Light8:{binding:{groupIndex:-1,bindingIndex:-1}},Light9:{binding:{groupIndex:-1,bindingIndex:-1}},Light10:{binding:{groupIndex:-1,bindingIndex:-1}},Light11:{binding:{groupIndex:-1,bindingIndex:-1}},Light12:{binding:{groupIndex:-1,bindingIndex:-1}},Light13:{binding:{groupIndex:-1,bindingIndex:-1}},Light14:{binding:{groupIndex:-1,bindingIndex:-1}},Light15:{binding:{groupIndex:-1,bindingIndex:-1}},Light16:{binding:{groupIndex:-1,bindingIndex:-1}},Light17:{binding:{groupIndex:-1,bindingIndex:-1}},Light18:{binding:{groupIndex:-1,bindingIndex:-1}},Light19:{binding:{groupIndex:-1,bindingIndex:-1}},Light20:{binding:{groupIndex:-1,bindingIndex:-1}},Light21:{binding:{groupIndex:-1,bindingIndex:-1}},Light22:{binding:{groupIndex:-1,bindingIndex:-1}},Light23:{binding:{groupIndex:-1,bindingIndex:-1}},Light24:{binding:{groupIndex:-1,bindingIndex:-1}},Light25:{binding:{groupIndex:-1,bindingIndex:-1}},Light26:{binding:{groupIndex:-1,bindingIndex:-1}},Light27:{binding:{groupIndex:-1,bindingIndex:-1}},Light28:{binding:{groupIndex:-1,bindingIndex:-1}},Light29:{binding:{groupIndex:-1,bindingIndex:-1}},Light30:{binding:{groupIndex:-1,bindingIndex:-1}},Light31:{binding:{groupIndex:-1,bindingIndex:-1}},Material:{binding:{groupIndex:-1,bindingIndex:-1}},Mesh:{binding:{groupIndex:-1,bindingIndex:-1}},Internals:{binding:{groupIndex:-1,bindingIndex:-1}}},r._KnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:1,bindingIndex:0}},Light1:{binding:{groupIndex:1,bindingIndex:1}},Light2:{binding:{groupIndex:1,bindingIndex:2}},Light3:{binding:{groupIndex:1,bindingIndex:3}},Light4:{binding:{groupIndex:1,bindingIndex:4}},Light5:{binding:{groupIndex:1,bindingIndex:5}},Light6:{binding:{groupIndex:1,bindingIndex:6}},Light7:{binding:{groupIndex:1,bindingIndex:7}},Light8:{binding:{groupIndex:1,bindingIndex:8}},Light9:{binding:{groupIndex:1,bindingIndex:9}},Light10:{binding:{groupIndex:1,bindingIndex:10}},Light11:{binding:{groupIndex:1,bindingIndex:11}},Light12:{binding:{groupIndex:1,bindingIndex:12}},Light13:{binding:{groupIndex:1,bindingIndex:13}},Light14:{binding:{groupIndex:1,bindingIndex:14}},Light15:{binding:{groupIndex:1,bindingIndex:15}},Light16:{binding:{groupIndex:1,bindingIndex:16}},Light17:{binding:{groupIndex:1,bindingIndex:17}},Light18:{binding:{groupIndex:1,bindingIndex:18}},Light19:{binding:{groupIndex:1,bindingIndex:19}},Light20:{binding:{groupIndex:1,bindingIndex:20}},Light21:{binding:{groupIndex:1,bindingIndex:21}},Light22:{binding:{groupIndex:1,bindingIndex:22}},Light23:{binding:{groupIndex:1,bindingIndex:23}},Light24:{binding:{groupIndex:1,bindingIndex:24}},Light25:{binding:{groupIndex:1,bindingIndex:25}},Light26:{binding:{groupIndex:1,bindingIndex:26}},Light27:{binding:{groupIndex:1,bindingIndex:27}},Light28:{binding:{groupIndex:1,bindingIndex:28}},Light29:{binding:{groupIndex:1,bindingIndex:29}},Light30:{binding:{groupIndex:1,bindingIndex:30}},Light31:{binding:{groupIndex:1,bindingIndex:31}},Material:{binding:{groupIndex:2,bindingIndex:0}},Mesh:{binding:{groupIndex:2,bindingIndex:1}},Internals:{binding:{groupIndex:2,bindingIndex:2}}},r}(),TD=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._missingVaryings=[],e._textureArrayProcessing=[],e._vertexIsGLES3=!1,e._fragmentIsGLES3=!1,e.shaderLanguage=0,e.parseGLES3=!0,e}return(0,A.C6)(t,r),t.prototype._getArraySize=function(e,n,i){var o=0,a=e.indexOf("["),s=e.indexOf("]");if(a>0&&s>0){var l=e.substring(a+1,s);o=+l,isNaN(o)&&(o=+i[l.trim()]),e=e.substring(0,a)}return[e,n,o]},t.prototype.initializeShaders=function(e){this._webgpuProcessingContext=e,this._missingVaryings.length=0,this._textureArrayProcessing.length=0,this.attributeKeywordName=void 0,this.varyingVertexKeywordName=void 0,this.varyingFragmentKeywordName=void 0},t.prototype.preProcessShaderCode=function(e,n){var i=`// Internals UBO
|
||
uniform `.concat(or.InternalsUBOName,` {
|
||
float yFactor_;
|
||
float textureOutputHeight_;
|
||
};
|
||
`),o=e.indexOf("// Internals UBO")!==-1;return n?(this._fragmentIsGLES3=e.indexOf("#version 3")!==-1,this._fragmentIsGLES3&&(this.varyingFragmentKeywordName="in"),o?e:i+`##INJECTCODE##
|
||
`+e):(this._vertexIsGLES3=e.indexOf("#version 3")!==-1,this._vertexIsGLES3&&(this.attributeKeywordName="in",this.varyingVertexKeywordName="out"),o?e:i+e)},t.prototype.varyingCheck=function(e,n){return(n&&this._fragmentIsGLES3?/(flat\s)?\s*\bin\b/:!n&&this._vertexIsGLES3?/(flat\s)?\s*\bout\b/:/(flat\s)?\s*\bvarying\b/).test(e)},t.prototype.varyingProcessor=function(e,n,i){var o;this._preProcessors=i;var a=(n&&this._fragmentIsGLES3?/\s*(flat)?\s*in\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm:!n&&this._vertexIsGLES3?/\s*(flat)?\s*out\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm:/\s*(flat)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm).exec(e);if(a!==null){var s,l=(o=a[1])!==null&&o!==void 0?o:"",c=a[2],u=a[3];n?(s=this._webgpuProcessingContext.availableVaryings[u],this._missingVaryings[s]="",s===void 0&&O.V.Warn('Invalid fragment shader: The varying named "'.concat(u,'" is not declared in the vertex shader! This declaration will be ignored.'))):(s=this._webgpuProcessingContext.getVaryingNextLocation(c,this._getArraySize(u,c,i)[2]),this._webgpuProcessingContext.availableVaryings[u]=s,this._missingVaryings[s]="layout(location = ".concat(s,") ").concat(l," in ").concat(c," ").concat(u,";")),e=e.replace(a[0],s===void 0?"":"layout(location = ".concat(s,") ").concat(l," ").concat(n?"in":"out"," ").concat(c," ").concat(u,";"))}return e},t.prototype.attributeProcessor=function(e,n){this._preProcessors=n;var i=(this._vertexIsGLES3?/\s*in\s+(\S+)\s+(\S+)\s*;/gm:/\s*attribute\s+(\S+)\s+(\S+)\s*;/gm).exec(e);if(i!==null){var o=i[1],a=i[2],s=this._webgpuProcessingContext.getAttributeNextLocation(o,this._getArraySize(a,o,n)[2]);this._webgpuProcessingContext.availableAttributes[a]=s,this._webgpuProcessingContext.orderedAttributes[s]=a;var l=this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents[a];if(l!==void 0){var c=l<0?l===-1?"int":"ivec"+-l:l===1?"uint":"uvec"+l,u="_int_".concat(a,"_");e=e.replace(i[0],"layout(location = ".concat(s,") in ").concat(c," ").concat(u,"; ").concat(o," ").concat(a," = ").concat(o,"(").concat(u,");"))}else e=e.replace(i[0],"layout(location = ".concat(s,") in ").concat(o," ").concat(a,";"))}return e},t.prototype.uniformProcessor=function(e,n,i){var o,a;this._preProcessors=i;var s=/\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);if(s!==null){var l=s[1],c=s[2];if(l.indexOf("sampler")===0||l.indexOf("sampler")===1){var u=0;c=(o=this._getArraySize(c,l,i))[0],l=o[1],u=o[2];var d=this._webgpuProcessingContext.availableTextures[c];if(!d){d={autoBindSampler:!0,isTextureArray:u>0,isStorageTexture:!1,textures:[],sampleType:"float"};for(var h=0;h<(u||1);++h)d.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())}var p=(a=or._SamplerTypeByWebGLSamplerType[l])!==null&&a!==void 0?a:"sampler",m=!!or._IsComparisonSamplerByWebGPUSamplerType[p],v=m?"comparison":"filtering",b=c+P.Y.AUTOSAMPLERSUFFIX,E=this._webgpuProcessingContext.availableSamplers[b];E||(E={binding:this._webgpuProcessingContext.getNextFreeUBOBinding(),type:v});var C=l.charAt(0)==="u"?"u":l.charAt(0)==="i"?"i":"";C&&(l=l.substring(1));var T=m?"depth":C==="u"?"uint":C==="i"?"sint":"float";d.sampleType=T;var f=u>0,g=E.binding.groupIndex,S=E.binding.bindingIndex,y=or._SamplerFunctionByWebGLSamplerType[l],x=or._TextureTypeByWebGLSamplerType[l],R=or._GpuTextureViewDimensionByWebGPUTextureType[x];if(f){var I=[];for(I.push("layout(set = ".concat(g,", binding = ").concat(S,") uniform ").concat(C).concat(p," ").concat(b,";")),e=`
|
||
`,h=0;h<u;++h){var M=d.textures[h].groupIndex,D=d.textures[h].bindingIndex;I.push("layout(set = ".concat(M,", binding = ").concat(D,") uniform ").concat(x," ").concat(c,"Texture").concat(h,";")),e+="".concat(h>0?`
|
||
`:"","#define ").concat(c).concat(h," ").concat(C).concat(y,"(").concat(c,"Texture").concat(h,", ").concat(b,")")}e=I.join(`
|
||
`)+e,this._textureArrayProcessing.push(c)}else u=1,e="layout(set = ".concat(g,", binding = ").concat(S,") uniform ").concat(p," ").concat(b,`;
|
||
layout(set = `).concat(d.textures[0].groupIndex,", binding = ").concat(d.textures[0].bindingIndex,") uniform ").concat(C).concat(x," ").concat(c,`Texture;
|
||
#define `).concat(c," ").concat(C).concat(y,"(").concat(c,"Texture, ").concat(b,")");for(this._webgpuProcessingContext.availableTextures[c]=d,this._webgpuProcessingContext.availableSamplers[b]=E,this._addSamplerBindingDescription(b,E,!n),h=0;h<u;++h)this._addTextureBindingDescription(c,d,h,R,null,!n)}else this._addUniformToLeftOverUBO(c,l,i),e=""}return e},t.prototype.uniformBufferProcessor=function(e,n){var i=/uniform\s+(\w+)/gm.exec(e);if(i!==null){var o=i[1],a=this._webgpuProcessingContext.availableBuffers[o];if(!a){var s=za.KnownUBOs[o];a={binding:s&&s.binding.groupIndex!==-1?s.binding:this._webgpuProcessingContext.getNextFreeUBOBinding()},this._webgpuProcessingContext.availableBuffers[o]=a}this._addBufferBindingDescription(o,a,"uniform",!n),e=e.replace("uniform","layout(set = ".concat(a.binding.groupIndex,", binding = ").concat(a.binding.bindingIndex,") uniform"))}return e},t.prototype.postProcessor=function(e,n,i,o,a){var s=e.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1;if(e=(e=e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"")).replace(/texture2D\s*\(/g,"texture("),i){var l=e.indexOf("gl_FragCoord")>=0,c=l?`vec4 glFragCoord_;
|
||
`:"",u=e.search(/layout *\(location *= *0\) *out/g)!==-1;if(e=(e=(e=(e=(e=(e=(e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/gl_FragCoord/g,"glFragCoord_"),this._fragmentIsGLES3){var d=/^\s*out\s+\S+\s+\S+\s*;/gm.exec(e);d!==null&&(e=e.substring(0,d.index)+"layout(location = 0) "+e.substring(d.index))}else e=e.replace(/void\s+?main\s*\(/g,(s||u?"":`layout(location = 0) out vec4 glFragColor;
|
||
`)+"void main(");e=(e=e.replace(/dFdy/g,"(-yFactor_)*dFdy")).replace("##INJECTCODE##",c),l&&(e=qu(e,"void main",`
|
||
glFragCoord_ = gl_FragCoord;
|
||
if (yFactor_ == 1.) {
|
||
glFragCoord_.y = textureOutputHeight_ - glFragCoord_.y;
|
||
}
|
||
`))}else if(e=(e=e.replace(/gl_InstanceID/g,"gl_InstanceIndex")).replace(/gl_VertexID/g,"gl_VertexIndex"),n.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require
|
||
layout (num_views = 2) in;
|
||
`+e;if(!i){var h=e.lastIndexOf("}");e=e.substring(0,h),e+=`gl_Position.y *= yFactor_;
|
||
`,e+="}"}return e},t.prototype._applyTextureArrayProcessing=function(e,n){for(var i=new RegExp(n+"\\s*\\[(.+)?\\]","gm"),o=i.exec(e);o!==null;){var a=o[1],s=+a;this._preProcessors&&isNaN(s)&&(s=+this._preProcessors[a.trim()]),e=e.replace(o[0],n+s),o=i.exec(e)}return e},t.prototype._generateLeftOverUBOCode=function(e,n){for(var i="layout(set = ".concat(n.binding.groupIndex,", binding = ").concat(n.binding.bindingIndex,") uniform ").concat(e,` {
|
||
`),o=0,a=this._webgpuProcessingContext.leftOverUniforms;o<a.length;o++){var s=a[o];s.length>0?i+=" ".concat(s.type," ").concat(s.name,"[").concat(s.length,`];
|
||
`):i+=" ".concat(s.type," ").concat(s.name,`;
|
||
`)}return i+`};
|
||
|
||
`},t.prototype.finalizeShaders=function(e,n){for(var i=0;i<this._textureArrayProcessing.length;++i){var o=this._textureArrayProcessing[i];e=this._applyTextureArrayProcessing(e,o),n=this._applyTextureArrayProcessing(n,o)}for(i=0;i<this._missingVaryings.length;++i){var a=this._missingVaryings[i];a&&a.length>0&&(n=a+`
|
||
`+n)}var s=this._buildLeftOverUBO();return e=s+e,n=s+n,this._collectBindingNames(),this._preCreateBindGroupEntries(),this._preProcessors=null,this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents={},{vertexCode:e,fragmentCode:n}},t}(or),JE=(L(27279),L(86615),L(63866),L(21310),L(17393)),SD=(L(92331),L(40647),L(36644),L(65969),"fragmentOutputs.fragDepth"),ED={texture_1d:"1d",texture_2d:"2d",texture_2d_array:"2d-array",texture_3d:"3d",texture_cube:"cube",texture_cube_array:"cube-array",texture_multisampled_2d:"2d",texture_depth_2d:"2d",texture_depth_2d_array:"2d-array",texture_depth_cube:"cube",texture_depth_cube_array:"cube-array",texture_depth_multisampled_2d:"2d",texture_storage_1d:"1d",texture_storage_2d:"2d",texture_storage_2d_array:"2d-array",texture_storage_3d:"3d",texture_external:null},xD=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.shaderLanguage=1,e.uniformRegexp=/uniform\s+(\w+)\s*:\s*(.+)\s*;/,e.textureRegexp=/var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,e.noPrecision=!0,e.pureMode=!1,e}return(0,A.C6)(t,r),t.prototype.preProcessor=function(e,n,i,o,a){for(var s in i)if(s!=="__VERSION__"){var l=i[s];isNaN(parseInt(l))&&isNaN(parseFloat(l))||(e="const ".concat(s," = ").concat(l,`;
|
||
`)+e)}return e},t.prototype._getArraySize=function(e,n,i){var o=0,a=n.lastIndexOf(">");if(n.indexOf("array")>=0&&a>0){for(var s=a;s>0&&n.charAt(s)!==" "&&n.charAt(s)!==",";)s--;var l=n.substring(s+1,a);for(o=+l,isNaN(o)&&(o=+i[l.trim()]);s>0&&(n.charAt(s)===" "||n.charAt(s)===",");)s--;n=n.substring(n.indexOf("<")+1,s+1)}return[e,n,o]},t.prototype.initializeShaders=function(e){this._webgpuProcessingContext=e,this._attributesInputWGSL=[],this._attributesWGSL=[],this._attributesConversionCodeWGSL=[],this._hasNonFloatAttribute=!1,this._varyingsWGSL=[],this._varyingNamesWGSL=[],this._stridedUniformArrays=[]},t.prototype.preProcessShaderCode=function(e){var n=this.pureMode?"":"struct ".concat(or.InternalsUBOName,` {
|
||
yFactor_: f32,
|
||
textureOutputHeight_: f32,
|
||
};
|
||
var<uniform> `).concat("internals"," : ").concat(or.InternalsUBOName,`;
|
||
`);return e.indexOf(n)!==-1?e:n+yg(e)},t.prototype.varyingCheck=function(e){return/(flat|linear|perspective)?\s*(center|centroid|sample)?\s*\bvarying\b/.test(e)},t.prototype.varyingProcessor=function(e,n,i){var o,a,s=/\s*(flat|linear|perspective)?\s*(center|centroid|sample)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(s!==null){var l,c=(o=s[1])!==null&&o!==void 0?o:"perspective",u=(a=s[2])!==null&&a!==void 0?a:"center",d=s[4],h=s[3],p=c==="flat"?"@interpolate(".concat(c,")"):"@interpolate(".concat(c,", ").concat(u,")");n?(l=this._webgpuProcessingContext.availableVaryings[h])===void 0&&O.V.Warn('Invalid fragment shader: The varying named "'.concat(h,'" is not declared in the vertex shader! This declaration will be ignored.')):(l=this._webgpuProcessingContext.getVaryingNextLocation(d,this._getArraySize(h,d,i)[2]),this._webgpuProcessingContext.availableVaryings[h]=l,this._varyingsWGSL.push(" @location(".concat(l,") ").concat(p," ").concat(h," : ").concat(d,",")),this._varyingNamesWGSL.push(h)),e=""}return e},t.prototype.attributeProcessor=function(e,n){var i=/\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(i!==null){var o=i[2],a=i[1],s=this._webgpuProcessingContext.getAttributeNextLocation(o,this._getArraySize(a,o,n)[2]);this._webgpuProcessingContext.availableAttributes[a]=s,this._webgpuProcessingContext.orderedAttributes[s]=a;var l=this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents[a];if(l!==void 0){var c=l<0?l===-1?"i32":"vec"+-l+"<i32>":l===1?"u32":"vec"+l+"<u32>",u="_int_".concat(a,"_");this._attributesInputWGSL.push("@location(".concat(s,") ").concat(u," : ").concat(c,",")),this._attributesWGSL.push("".concat(a," : ").concat(o,",")),this._attributesConversionCodeWGSL.push("vertexInputs.".concat(a," = ").concat(o,"(vertexInputs_.").concat(u,");")),this._hasNonFloatAttribute=!0}else this._attributesInputWGSL.push("@location(".concat(s,") ").concat(a," : ").concat(o,",")),this._attributesWGSL.push("".concat(a," : ").concat(o,",")),this._attributesConversionCodeWGSL.push("vertexInputs.".concat(a," = vertexInputs_.").concat(a,";"));e=""}return e},t.prototype.uniformProcessor=function(e,n,i){var o=this.uniformRegexp.exec(e);if(o!==null){var a=o[2],s=o[1];this._addUniformToLeftOverUBO(s,a,i),e=""}return e},t.prototype.textureProcessor=function(e,n,i){var o=this.textureRegexp.exec(e);if(o!==null){var a=o[1],s=o[2],l=!!o[3],c=o[4],u=c.indexOf("storage")>0,d=o[6],h=u?d.substring(0,d.indexOf(",")).trim():null,p=l?this._getArraySize(a,s,i)[2]:0,m=this._webgpuProcessingContext.availableTextures[a];if(m)p=m.textures.length;else{m={isTextureArray:p>0,isStorageTexture:u,textures:[],sampleType:"float"},p=p||1;for(var v=0;v<p;++v)m.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())}this._webgpuProcessingContext.availableTextures[a]=m;var b=c.indexOf("depth")>0,E=ED[c],C=b?"depth":d==="u32"?"uint":d==="i32"?"sint":"float";if(m.sampleType=C,E===void 0)throw`Can't get the texture dimension corresponding to the texture function "`.concat(c,'"!');for(v=0;v<p;++v){var T=m.textures[v],f=T.groupIndex,g=T.bindingIndex;v===0&&(e="@group(".concat(f,") @binding(").concat(g,") ").concat(e)),this._addTextureBindingDescription(a,m,v,E,h,!n)}}return e},t.prototype.postProcessor=function(e){for(var n,i=/#define (.+?) (.+?)$/gm;(n=i.exec(e))!==null;)e=e.replace(new RegExp(n[1],"g"),n[2]);return e},t.prototype.finalizeShaders=function(e,n){var i=n.indexOf("fragmentInputs.position")>=0&&!this.pureMode?`
|
||
if (internals.yFactor_ == 1.) {
|
||
fragmentInputs.position.y = internals.textureOutputHeight_ - fragmentInputs.position.y;
|
||
}
|
||
`:"";e=this._processSamplers(e,!0),n=this._processSamplers(n,!1),e=this._processCustomBuffers(e,!0),n=this._processCustomBuffers(n,!1);var o=this._buildLeftOverUBO();n=o+n,e=(e=(e=o+e).replace(/#define (\w+)\s+(\d+\.?\d*)/g,"const $1 = $2;")).replace(/#define /g,"//#define "),e=this._processStridedUniformArrays(e);var a=`struct VertexInputs {
|
||
@builtin(vertex_index) vertexIndex : u32,
|
||
@builtin(instance_index) instanceIndex : u32,
|
||
`;this._attributesInputWGSL.length>0&&(a+=this._attributesInputWGSL.join(`
|
||
`)),a+=`
|
||
};
|
||
var<private> vertexInputs`+(this._hasNonFloatAttribute?"_":"")+` : VertexInputs;
|
||
`,this._hasNonFloatAttribute&&(a+=`struct VertexInputs_ {
|
||
vertexIndex : u32, instanceIndex : u32,
|
||
`,a+=this._attributesWGSL.join(`
|
||
`),a+=`
|
||
};
|
||
var<private> vertexInputs : VertexInputs_;
|
||
`);var s=`struct FragmentInputs {
|
||
@builtin(position) position : vec4<f32>,
|
||
`;this._varyingsWGSL.length>0&&(s+=this._varyingsWGSL.join(`
|
||
`)),e=a+(s+=`
|
||
};
|
||
var<private> vertexOutputs : FragmentInputs;
|
||
`)+e;var l=`
|
||
vertexInputs`.concat(this._hasNonFloatAttribute?"_":"",` = input;
|
||
`);this._hasNonFloatAttribute&&(l+=`vertexInputs.vertexIndex = vertexInputs_.vertexIndex;
|
||
vertexInputs.instanceIndex = vertexInputs_.instanceIndex;
|
||
`,l+=this._attributesConversionCodeWGSL.join(`
|
||
`),l+=`
|
||
`);var c=this.pureMode?" return vertexOutputs;":` vertexOutputs.position.y = vertexOutputs.position.y * internals.yFactor_;
|
||
return vertexOutputs;`,u=e.indexOf(P.Y.DISABLEUA)!==-1;e=(u?`diagnostic(off, derivative_uniformity);
|
||
`:"")+qu(e,"fn main",l,c),n=(n=n.replace(/#define (\w+)\s+(\d+\.?\d*)/g,"const $1 = $2;")).replace(/#define /g,"//#define "),n=this._processStridedUniformArrays(n),this.pureMode||(n=n.replace(/dpdy/g,"(-internals.yFactor_)*dpdy"));var d=`struct FragmentInputs {
|
||
@builtin(position) position : vec4<f32>,
|
||
@builtin(front_facing) frontFacing : bool,
|
||
`;this._varyingsWGSL.length>0&&(d+=this._varyingsWGSL.join(`
|
||
`)),d+=`
|
||
};
|
||
var<private> fragmentInputs : FragmentInputs;
|
||
`;var h=`struct FragmentOutputs {
|
||
`,p="fragmentOutputs\\.fragData",m=n.match(new RegExp(p+"0","g")),v=0;if(m){h+=" @location(".concat(v,`) fragData0 : vec4<f32>,
|
||
`),v++;for(var b=1;b<8;b++)(m=n.match(new RegExp(p+b,"g")))&&(h+=" @location(".concat(v,") fragData").concat(v,` : vec4<f32>,
|
||
`),v++);n.indexOf("MRT_AND_COLOR")!==-1&&(h+=" @location(".concat(v,`) color : vec4<f32>,
|
||
`),v++)}(m=n.match(/oitDepthSampler/))&&(h+=" @location(".concat(v++,`) depth : vec2<f32>,
|
||
`),h+=" @location(".concat(v++,`) frontColor : vec4<f32>,
|
||
`),h+=" @location(".concat(v++,`) backColor : vec4<f32>,
|
||
`)),v===0&&(h+=` @location(0) color : vec4<f32>,
|
||
`,v++);for(var E=!1,C=0;!(E||(C=n.indexOf(SD,C))<0);){var T=C;for(E=!0;C>1&&n.charAt(C)!==`
|
||
`;){if(n.charAt(C)==="/"&&n.charAt(C-1)==="/"){E=!1;break}C--}C=T+25}E&&(h+=` @builtin(frag_depth) fragDepth: f32,
|
||
`);var f=` fragmentInputs = input;
|
||
`+i;return u=(n=d+(h+=`};
|
||
var<private> fragmentOutputs : FragmentOutputs;
|
||
`)+n).indexOf(P.Y.DISABLEUA)!==-1,n=(u?`diagnostic(off, derivative_uniformity);
|
||
`:"")+qu(n,"fn main",f," return fragmentOutputs;"),this._collectBindingNames(),this._preCreateBindGroupEntries(),this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents={},{vertexCode:e,fragmentCode:n}},t.prototype._generateLeftOverUBOCode=function(e,n){for(var i="",o="struct ".concat(e,` {
|
||
`),a=0,s=this._webgpuProcessingContext.leftOverUniforms;a<s.length;a++){var l=s[a],c=l.type.replace(/^(.*?)(<.*>)?$/,"$1"),u=or.UniformSizes[c];if(l.length>0)if(u<=2){var d="".concat(e,"_").concat(this._stridedUniformArrays.length,"_strided_arr");i+="struct ".concat(d,` {
|
||
@size(16)
|
||
el: `).concat(c,`,
|
||
}`),this._stridedUniformArrays.push(l.name),o+=" @align(16) ".concat(l.name," : array<").concat(d,", ").concat(l.length,`>,
|
||
`)}else o+=" ".concat(l.name," : array<").concat(l.type,", ").concat(l.length,`>,
|
||
`);else o+=" ".concat(l.name," : ").concat(l.type,`,
|
||
`)}return o+=`};
|
||
`,(o="".concat(i,`
|
||
`).concat(o))+"@group(".concat(n.binding.groupIndex,") @binding(").concat(n.binding.bindingIndex,") var<uniform> ").concat("uniforms"," : ").concat(e,`;
|
||
`)},t.prototype._processSamplers=function(e,n){for(var i=/var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm;;){var o=i.exec(e);if(o===null)break;var a=o[1],s=o[2],l=a.length-P.Y.AUTOSAMPLERSUFFIX.length,c=a.lastIndexOf(P.Y.AUTOSAMPLERSUFFIX)===l?a.substring(0,l):null,u=s==="sampler_comparison"?"comparison":"filtering";if(c){var d=this._webgpuProcessingContext.availableTextures[c];d&&(d.autoBindSampler=!0)}var h=this._webgpuProcessingContext.availableSamplers[a];h||(h={binding:this._webgpuProcessingContext.getNextFreeUBOBinding(),type:u},this._webgpuProcessingContext.availableSamplers[a]=h),this._addSamplerBindingDescription(a,h,n);var p=e.substring(0,o.index),m="@group(".concat(h.binding.groupIndex,") @binding(").concat(h.binding.bindingIndex,") "),v=e.substring(o.index);e=p+m+v,i.lastIndex+=m.length}return e},t.prototype._processCustomBuffers=function(e,n){for(var i,o=/var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm;;){var a=o.exec(e);if(a===null)break;var s=a[1],l=a[3],c=a[4],u=a[5],d=this._webgpuProcessingContext.availableBuffers[c];if(!d){var h=s==="uniform"?za.KnownUBOs[u]:null,p=void 0;h?(c=u,(p=h.binding).groupIndex===-1&&((p=(i=this._webgpuProcessingContext.availableBuffers[c])===null||i===void 0?void 0:i.binding)||(p=this._webgpuProcessingContext.getNextFreeUBOBinding()))):p=this._webgpuProcessingContext.getNextFreeUBOBinding(),d={binding:p},this._webgpuProcessingContext.availableBuffers[c]=d}this._addBufferBindingDescription(c,this._webgpuProcessingContext.availableBuffers[c],l==="read_write"?"storage":s==="storage"?"read-only-storage":"uniform",n);var m=d.binding.groupIndex,v=d.binding.bindingIndex,b=e.substring(0,a.index),E="@group(".concat(m,") @binding(").concat(v,") "),C=e.substring(a.index);e=b+E+C,o.lastIndex+=E.length}return e},t.prototype._processStridedUniformArrays=function(e){for(var n=0,i=this._stridedUniformArrays;n<i.length;n++){var o=i[n];e=e.replace(new RegExp("".concat(o,"\\s*\\[(.*?)\\]"),"g"),"".concat(o,"[$1].el"))}return e},t}(or),en=function(){function r(){}return r.ComputeNumMipmapLevels=function(t,e){return(0,qe.ILog2)(Math.max(t,e))+1},r.GetTextureTypeFromFormat=function(t){switch(t){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb10a2uint":case"rgb10a2unorm":case"rgb9e5ufloat":case"rg11b10ufloat":case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc5-rg-unorm":case"bc5-rg-snorm":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"eac-r11unorm":case"eac-r11snorm":case"eac-rg11unorm":case"eac-rg11snorm":case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":case"stencil8":return P.Y.TEXTURETYPE_UNSIGNED_BYTE;case"r16uint":case"r16sint":case"rg16uint":case"rg16sint":case"rgba16uint":case"rgba16sint":case"depth16unorm":return P.Y.TEXTURETYPE_UNSIGNED_SHORT;case"r16float":case"rg16float":case"rgba16float":return P.Y.TEXTURETYPE_HALF_FLOAT;case"r32uint":case"r32sint":case"rg32uint":case"rg32sint":case"rgba32uint":case"rgba32sint":return P.Y.TEXTURETYPE_UNSIGNED_INTEGER;case"r32float":case"rg32float":case"rgba32float":case"depth32float":case"depth32float-stencil8":case"depth24plus":case"depth24plus-stencil8":return P.Y.TEXTURETYPE_FLOAT}return P.Y.TEXTURETYPE_UNSIGNED_BYTE},r.GetBlockInformationFromFormat=function(t){switch(t){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2uint":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw"No fixed size for Stencil8 format!";case"depth24plus":throw"No fixed size for Depth24Plus format!";case"depth24plus-stencil8":throw"No fixed size for Depth24PlusStencil8 format!";case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc5-rg-unorm":case"bc5-rg-snorm":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"eac-rg11unorm":case"eac-rg11snorm":case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"eac-r11unorm":case"eac-r11snorm":return{width:4,height:4,length:8};case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":return{width:5,height:4,length:16};case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":return{width:5,height:5,length:16};case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":return{width:6,height:5,length:16};case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":return{width:6,height:6,length:16};case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":return{width:8,height:5,length:16};case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":return{width:8,height:6,length:16};case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":return{width:8,height:8,length:16};case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":return{width:10,height:5,length:16};case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":return{width:10,height:6,length:16};case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":return{width:10,height:8,length:16};case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":return{width:10,height:10,length:16};case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":return{width:12,height:10,length:16};case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":return{width:12,height:12,length:16}}return{width:1,height:1,length:4}},r.IsHardwareTexture=function(t){return!!t.release},r.IsInternalTexture=function(t){return!!t.dispose},r.IsImageBitmap=function(t){return t.close!==void 0},r.IsImageBitmapArray=function(t){return Array.isArray(t)&&t[0].close!==void 0},r.IsCompressedFormat=function(t){switch(t){case"bc7-rgba-unorm-srgb":case"bc7-rgba-unorm":case"bc6h-rgb-float":case"bc6h-rgb-ufloat":case"bc5-rg-snorm":case"bc5-rg-unorm":case"bc4-r-snorm":case"bc4-r-unorm":case"bc3-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc1-rgba-unorm-srgb":case"bc1-rgba-unorm":case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"eac-r11unorm":case"eac-r11snorm":case"eac-rg11unorm":case"eac-rg11snorm":case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":return!0}return!1},r.GetWebGPUTextureFormat=function(t,e,n){switch(n===void 0&&(n=!1),e){case P.Y.TEXTUREFORMAT_DEPTH16:return"depth16unorm";case P.Y.TEXTUREFORMAT_DEPTH24:return"depth24plus";case P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:return"depth24plus-stencil8";case P.Y.TEXTUREFORMAT_DEPTH32_FLOAT:return"depth32float";case P.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8:return"depth32float-stencil8";case P.Y.TEXTUREFORMAT_STENCIL8:return"stencil8";case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:return n?"bc7-rgba-unorm-srgb":"bc7-rgba-unorm";case P.Y.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:return"bc6h-rgb-ufloat";case P.Y.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:return"bc6h-rgb-float";case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:return n?"bc3-rgba-unorm-srgb":"bc3-rgba-unorm";case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:return n?"bc2-rgba-unorm-srgb":"bc2-rgba-unorm";case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:case P.Y.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:return n?"bc1-rgba-unorm-srgb":"bc1-rgba-unorm";case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:return n?"astc-4x4-unorm-srgb":"astc-4x4-unorm";case P.Y.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:case P.Y.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:return n?"etc2-rgb8unorm-srgb":"etc2-rgb8unorm";case P.Y.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:return n?"etc2-rgba8unorm-srgb":"etc2-rgba8unorm"}switch(t){case P.Y.TEXTURETYPE_BYTE:switch(e){case P.Y.TEXTUREFORMAT_RED:return"r8snorm";case P.Y.TEXTUREFORMAT_RG:return"rg8snorm";case P.Y.TEXTUREFORMAT_RGB:throw"RGB format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RED_INTEGER:return"r8sint";case P.Y.TEXTUREFORMAT_RG_INTEGER:return"rg8sint";case P.Y.TEXTUREFORMAT_RGB_INTEGER:throw"RGB_INTEGER format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:return"rgba8sint";default:return"rgba8snorm"}case P.Y.TEXTURETYPE_UNSIGNED_BYTE:switch(e){case P.Y.TEXTUREFORMAT_RED:return"r8unorm";case P.Y.TEXTUREFORMAT_RG:return"rg8unorm";case P.Y.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA:return n?"rgba8unorm-srgb":"rgba8unorm";case P.Y.TEXTUREFORMAT_BGRA:return n?"bgra8unorm-srgb":"bgra8unorm";case P.Y.TEXTUREFORMAT_RED_INTEGER:return"r8uint";case P.Y.TEXTUREFORMAT_RG_INTEGER:return"rg8uint";case P.Y.TEXTUREFORMAT_RGB_INTEGER:throw"RGB_INTEGER format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:return"rgba8uint";case P.Y.TEXTUREFORMAT_ALPHA:throw"TEXTUREFORMAT_ALPHA format not supported in WebGPU";case P.Y.TEXTUREFORMAT_LUMINANCE:throw"TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";case P.Y.TEXTUREFORMAT_LUMINANCE_ALPHA:throw"TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";default:return"rgba8unorm"}case P.Y.TEXTURETYPE_SHORT:switch(e){case P.Y.TEXTUREFORMAT_RED_INTEGER:return"r16sint";case P.Y.TEXTUREFORMAT_RG_INTEGER:return"rg16sint";case P.Y.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return"rgba16sint"}case P.Y.TEXTURETYPE_UNSIGNED_SHORT:switch(e){case P.Y.TEXTUREFORMAT_RED_INTEGER:return"r16uint";case P.Y.TEXTUREFORMAT_RG_INTEGER:return"rg16uint";case P.Y.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return"rgba16uint"}case P.Y.TEXTURETYPE_INT:switch(e){case P.Y.TEXTUREFORMAT_RED_INTEGER:return"r32sint";case P.Y.TEXTUREFORMAT_RG_INTEGER:return"rg32sint";case P.Y.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return"rgba32sint"}case P.Y.TEXTURETYPE_UNSIGNED_INTEGER:switch(e){case P.Y.TEXTUREFORMAT_RED_INTEGER:return"r32uint";case P.Y.TEXTUREFORMAT_RG_INTEGER:return"rg32uint";case P.Y.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:default:return"rgba32uint"}case P.Y.TEXTURETYPE_FLOAT:switch(e){case P.Y.TEXTUREFORMAT_RED:return"r32float";case P.Y.TEXTUREFORMAT_RG:return"rg32float";case P.Y.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA:default:return"rgba32float"}case P.Y.TEXTURETYPE_HALF_FLOAT:switch(e){case P.Y.TEXTUREFORMAT_RED:return"r16float";case P.Y.TEXTUREFORMAT_RG:return"rg16float";case P.Y.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case P.Y.TEXTUREFORMAT_RGBA:default:return"rgba16float"}case P.Y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:throw"TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";case P.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:switch(e){case P.Y.TEXTUREFORMAT_RGBA:return"rg11b10ufloat";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:throw"TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV";default:return"rg11b10ufloat"}case P.Y.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:switch(e){case P.Y.TEXTUREFORMAT_RGBA:return"rgb9e5ufloat";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:throw"TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV";default:return"rgb9e5ufloat"}case P.Y.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:throw"TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";case P.Y.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:throw"TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";case P.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(e){case P.Y.TEXTUREFORMAT_RGBA:return"rgb10a2unorm";case P.Y.TEXTUREFORMAT_RGBA_INTEGER:return"rgb10a2uint";default:return"rgb10a2unorm"}}return n?"rgba8unorm-srgb":"rgba8unorm"},r.GetNumChannelsFromWebGPUTextureFormat=function(t){switch(t){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":case"bc4-r-unorm":case"bc4-r-snorm":case"r16uint":case"r16sint":case"depth16unorm":case"r16float":case"r32uint":case"r32sint":case"r32float":case"depth32float":case"stencil8":case"depth24plus":case"eac-r11unorm":case"eac-r11snorm":return 1;case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth32float-stencil8":case"bc5-rg-unorm":case"bc5-rg-snorm":case"rg16uint":case"rg16sint":case"rg16float":case"rg32uint":case"rg32sint":case"rg32float":case"depth24plus-stencil8":case"eac-rg11unorm":case"eac-rg11snorm":return 2;case"rgb9e5ufloat":case"rg11b10ufloat":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":return 3;case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb10a2uint":case"rgb10a2unorm":case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":case"rgba16uint":case"rgba16sint":case"rgba16float":case"rgba32uint":case"rgba32sint":case"rgba32float":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":return 4}throw"Unknown format ".concat(t,"!")},r.HasStencilAspect=function(t){switch(t){case"stencil8":case"depth32float-stencil8":case"depth24plus-stencil8":return!0}return!1},r.HasDepthAndStencilAspects=function(t){switch(t){case"depth32float-stencil8":case"depth24plus-stencil8":return!0}return!1},r.GetDepthFormatOnly=function(t){switch(t){case"depth16unorm":return"depth16unorm";case"depth24plus":case"depth24plus-stencil8":return"depth24plus";case"depth32float":case"depth32float-stencil8":return"depth32float"}return t},r.GetSample=function(t){return t>1?4:1},r}(),Fd=function(){function r(t){t===void 0&&(t=null),this._originalFormatIsRGB=!1,this.format="rgba8unorm",this.textureUsages=0,this.textureAdditionalUsages=0,this._webgpuTexture=t,this._webgpuMSAATexture=null,this.view=null,this.viewForWriting=null}return Object.defineProperty(r.prototype,"underlyingResource",{get:function(){return this._webgpuTexture},enumerable:!1,configurable:!0}),r.prototype.getMSAATexture=function(t){var e,n;return t===void 0&&(t=0),(n=(e=this._webgpuMSAATexture)===null||e===void 0?void 0:e[t])!==null&&n!==void 0?n:null},r.prototype.setMSAATexture=function(t,e){e===void 0&&(e=-1),this._webgpuMSAATexture||(this._webgpuMSAATexture=[]),e===-1&&(e=this._webgpuMSAATexture.length),this._webgpuMSAATexture[e]=t},r.prototype.releaseMSAATexture=function(){if(this._webgpuMSAATexture){for(var t=0,e=this._webgpuMSAATexture;t<e.length;t++){var n=e[t];n?.destroy()}this._webgpuMSAATexture=null}},r.prototype.set=function(t){this._webgpuTexture=t},r.prototype.setUsage=function(t,e,n,i,o,a,s,l){var c="2d",u=1;i?(c=n?"cube-array":"cube",u=6*(l||1)):o?(c="3d",u=1):n&&(c="2d-array",u=l);var d=en.GetDepthFormatOnly(this.format),h=en.HasDepthAndStencilAspects(this.format)?"depth-only":"all";this.createView({label:"TextureView".concat(o?"3D":i?"Cube":"2D").concat(n?"_Array"+u:"","_").concat(a,"x").concat(s,"_").concat(e?"wmips":"womips","_").concat(this.format,"_").concat(c),format:d,dimension:c,mipLevelCount:e?(0,qe.ILog2)(Math.max(a,s))+1:1,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:u,aspect:h})},r.prototype.createView=function(t,e){if(e===void 0&&(e=!1),this.view=this._webgpuTexture.createView(t),e&&t){var n=t.mipLevelCount;t.mipLevelCount=1,this.viewForWriting=this._webgpuTexture.createView(t),t.mipLevelCount=n}},r.prototype.reset=function(){this._webgpuTexture=null,this._webgpuMSAATexture=null,this.view=null,this.viewForWriting=null},r.prototype.release=function(){var t,e;(t=this._webgpuTexture)===null||t===void 0||t.destroy(),this.releaseMSAATexture(),(e=this._copyInvertYTempTexture)===null||e===void 0||e.destroy(),this.reset()},r}(),$E=`
|
||
const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));
|
||
const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));
|
||
|
||
var img: texture_2d<f32>;
|
||
|
||
#ifdef INVERTY
|
||
varying vTextureSize: vec2f;
|
||
#endif
|
||
|
||
@vertex
|
||
fn main(input : VertexInputs) -> FragmentInputs {
|
||
#ifdef INVERTY
|
||
vertexOutputs.vTextureSize = vec2f(textureDimensions(img, 0));
|
||
#endif
|
||
vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);
|
||
}
|
||
`,PD=$E;(function(r){r[r.MipMap=0]="MipMap",r[r.InvertYPremultiplyAlpha=1]="InvertYPremultiplyAlpha",r[r.Clear=2]="Clear",r[r.InvertYPremultiplyAlphaWithOfst=3]="InvertYPremultiplyAlphaWithOfst"})(Er||(Er={})),function(r){r[r.DontInvertY=0]="DontInvertY",r[r.InvertY=1]="InvertY"}(ka||(ka={}));var Bn,ex=[{vertex:`
|
||
const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));
|
||
const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));
|
||
|
||
varying vTex: vec2f;
|
||
|
||
@vertex
|
||
fn main(input : VertexInputs) -> FragmentInputs {
|
||
vertexOutputs.vTex = tex[input.vertexIndex];
|
||
vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);
|
||
}
|
||
`,fragment:`
|
||
var imgSampler: sampler;
|
||
var img: texture_2d<f32>;
|
||
|
||
varying vTex: vec2f;
|
||
|
||
@fragment
|
||
fn main(input: FragmentInputs) -> FragmentOutputs {
|
||
fragmentOutputs.color = textureSample(img, imgSampler, input.vTex);
|
||
}
|
||
`},{vertex:$E,fragment:`
|
||
var img: texture_2d<f32>;
|
||
|
||
#ifdef INVERTY
|
||
varying vTextureSize: vec2f;
|
||
#endif
|
||
|
||
@fragment
|
||
fn main(input: FragmentInputs) -> FragmentOutputs {
|
||
#ifdef INVERTY
|
||
var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(input.vTextureSize.y - input.position.y)), 0);
|
||
#else
|
||
var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);
|
||
#endif
|
||
#ifdef PREMULTIPLYALPHA
|
||
fragmentOutputs.color = vec4f(color.rgb * color.a, color.a);
|
||
#endif
|
||
fragmentOutputs.color = color;
|
||
}
|
||
`},{vertex:`
|
||
const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));
|
||
|
||
@vertex
|
||
fn main(input : VertexInputs) -> FragmentInputs {
|
||
vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);
|
||
}
|
||
`,fragment:`
|
||
uniform color: vec4f;
|
||
|
||
|
||
@fragment
|
||
fn main(input: FragmentInputs) -> FragmentOutputs {
|
||
fragmentOutputs.color = uniforms.color;
|
||
}
|
||
`},{vertex:PD,fragment:`
|
||
var img: texture_2d<f32>;
|
||
uniform ofstX: f32;
|
||
uniform ofstY: f32;
|
||
uniform width: f32;
|
||
uniform height: f32;
|
||
|
||
#ifdef INVERTY
|
||
varying vTextureSize: vec2f;
|
||
#endif
|
||
|
||
@fragment
|
||
fn main(input: FragmentInputs) -> FragmentOutputs {
|
||
if (input.position.x < uniforms.ofstX || input.position.x >= uniforms.ofstX + uniforms.width) {
|
||
discard;
|
||
}
|
||
if (input.position.y < uniforms.ofstY || input.position.y >= uniforms.ofstY + uniforms.height) {
|
||
discard;
|
||
}
|
||
#ifdef INVERTY
|
||
var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(uniforms.ofstY + uniforms.height - (input.position.y - uniforms.ofstY))), 0);
|
||
#else
|
||
var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);
|
||
#endif
|
||
#ifdef PREMULTIPLYALPHA
|
||
color = vec4f(color.rgb * color.a, color.a);
|
||
#endif
|
||
fragmentOutputs.color = color;
|
||
}
|
||
`}],ao={"":0,r8unorm:1,r8uint:2,r8sint:3,r16uint:4,r16sint:5,r16float:6,rg8unorm:7,rg8uint:8,rg8sint:9,r32uint:10,r32sint:11,r32float:12,rg16uint:13,rg16sint:14,rg16float:15,rgba8unorm:16,"rgba8unorm-srgb":17,rgba8uint:18,rgba8sint:19,bgra8unorm:20,"bgra8unorm-srgb":21,rgb10a2uint:22,rgb10a2unorm:23,rg32uint:24,rg32sint:25,rg32float:26,rgba16uint:27,rgba16sint:28,rgba16float:29,rgba32uint:30,rgba32sint:31,rgba32float:32,stencil8:33,depth16unorm:34,depth24plus:35,"depth24plus-stencil8":36,depth32float:37,"depth32float-stencil8":38},AD=function(){function r(t,e,n,i){if(this._pipelines={},this._compiledShaders=[],this._videoPipelines={},this._videoCompiledShaders=[],this._deferredReleaseTextures=[],this._engine=t,this._device=e,this._bufferManager=n,i.indexOf("rg11b10ufloat-renderable")!==-1){var o=Object.keys(ao);ao.rg11b10ufloat=ao[o[o.length-1]]+1}this._mipmapSampler=e.createSampler({minFilter:"linear"}),this._videoSampler=e.createSampler({minFilter:"linear"}),this._ubCopyWithOfst=this._bufferManager.createBuffer(16,nn.Uniform|nn.CopyDst,"UBCopyWithOffset").underlyingResource,this._getPipeline("rgba8unorm"),this._getVideoPipeline("rgba8unorm")}return r.prototype._getPipeline=function(t,e,n){e===void 0&&(e=Er.MipMap);var i=e===Er.MipMap?1:e===Er.InvertYPremultiplyAlpha?((n.invertY?1:0)<<1)+((n.premultiplyAlpha?1:0)<<2):e===Er.Clear?8:e===Er.InvertYPremultiplyAlphaWithOfst?((n.invertY?1:0)<<4)+((n.premultiplyAlpha?1:0)<<5):0;this._pipelines[t]||(this._pipelines[t]=[]);var o=this._pipelines[t][i];if(!o){var a="";e!==Er.InvertYPremultiplyAlpha&&e!==Er.InvertYPremultiplyAlphaWithOfst||(n.invertY&&(a+=`#define INVERTY
|
||
`),n.premultiplyAlpha&&(a+=`#define PREMULTIPLYALPHA
|
||
`));var s=this._compiledShaders[i];if(!s){var l=ex[e].vertex,c=ex[e].fragment,u={defines:a.split(`
|
||
`),indexParameters:null,isFragment:!1,shouldUseHighPrecisionShader:!0,processor:this._engine._getShaderProcessor(1),supportsUniformBuffers:!0,shadersRepository:"",includesShadersStore:{},version:(100*this._engine.version).toString(),platformName:this._engine.shaderPlatformName,processingContext:this._engine._getShaderProcessingContext(1,!0),isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer};(0,Io.pB)(u),u.processor.pureMode=!0,(0,Io.M0)(l,u,function(v){l=v},this._engine),u.isFragment=!0,(0,Io.M0)(c,u,function(v){c=v},this._engine);var d=(0,Io.nO)(l,c,u);u.processor.pureMode=!1;var h=this._device.createShaderModule({code:d.vertexCode}),p=this._device.createShaderModule({code:d.fragmentCode});s=this._compiledShaders[i]=[h,p]}var m=this._device.createRenderPipeline({layout:"auto",vertex:{module:s[0],entryPoint:"main"},fragment:{module:s[1],entryPoint:"main",targets:[{format:t}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint16"}});o=this._pipelines[t][i]=[m,m.getBindGroupLayout(0)]}return o},r.prototype._getVideoPipeline=function(t,e){e===void 0&&(e=ka.DontInvertY);var n=e===ka.InvertY?1:0;this._videoPipelines[t]||(this._videoPipelines[t]=[]);var i=this._videoPipelines[t][n];if(!i){var o=this._videoCompiledShaders[n];if(!o){var a=this._device.createShaderModule({code:`
|
||
struct VertexOutput {
|
||
@builtin(position) Position : vec4<f32>,
|
||
@location(0) fragUV : vec2<f32>
|
||
}
|
||
|
||
@vertex
|
||
fn main(
|
||
@builtin(vertex_index) VertexIndex : u32
|
||
) -> VertexOutput {
|
||
var pos = array<vec2<f32>, 4>(
|
||
vec2(-1.0, 1.0),
|
||
vec2( 1.0, 1.0),
|
||
vec2(-1.0, -1.0),
|
||
vec2( 1.0, -1.0)
|
||
);
|
||
var tex = array<vec2<f32>, 4>(
|
||
vec2(0.0, 0.0),
|
||
vec2(1.0, 0.0),
|
||
vec2(0.0, 1.0),
|
||
vec2(1.0, 1.0)
|
||
);
|
||
|
||
var output: VertexOutput;
|
||
|
||
output.Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||
output.fragUV = tex[VertexIndex];
|
||
|
||
return output;
|
||
}
|
||
`}),s=this._device.createShaderModule({code:n===0?`
|
||
@group(0) @binding(0) var videoSampler: sampler;
|
||
@group(0) @binding(1) var videoTexture: texture_external;
|
||
|
||
@fragment
|
||
fn main(
|
||
@location(0) fragUV: vec2<f32>
|
||
) -> @location(0) vec4<f32> {
|
||
return textureSampleBaseClampToEdge(videoTexture, videoSampler, fragUV);
|
||
}
|
||
`:`
|
||
@group(0) @binding(0) var videoSampler: sampler;
|
||
@group(0) @binding(1) var videoTexture: texture_external;
|
||
|
||
@fragment
|
||
fn main(
|
||
@location(0) fragUV: vec2<f32>
|
||
) -> @location(0) vec4<f32> {
|
||
return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2<f32>(fragUV.x, 1.0 - fragUV.y));
|
||
}
|
||
`});o=this._videoCompiledShaders[n]=[a,s]}var l=this._device.createRenderPipeline({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_CopyVideoToTexture_").concat(t,"_").concat(n===0?"DontInvertY":"InvertY"),layout:"auto",vertex:{module:o[0],entryPoint:"main"},fragment:{module:o[1],entryPoint:"main",targets:[{format:t}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint16"}});i=this._videoPipelines[t][n]=[l,l.getBindGroupLayout(0)]}return i},r.prototype.setCommandEncoder=function(t){this._commandEncoderForCreation=t},r.prototype.copyVideoToTexture=function(t,e,n,i,o){var a,s,l,c;i===void 0&&(i=!1);var u=o===void 0,d=this._getVideoPipeline(n,i?ka.InvertY:ka.DontInvertY),h=d[0],p=d[1];u&&(o=this._device.createCommandEncoder({})),(s=(a=o).pushDebugGroup)===null||s===void 0||s.call(a,"copy video to texture - invertY=".concat(i));var m=e._hardwareTexture,v={label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_copyVideoToTexture_").concat(n,"_").concat(i?"InvertY":"DontInvertY").concat(e.label?"_"+e.label:""),colorAttachments:[{view:m.underlyingResource.createView({format:n,dimension:"2d",mipLevelCount:1,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:1,aspect:"all"}),loadOp:"load",storeOp:"store"}]},b=o.beginRenderPass(v),E={layout:p,entries:[{binding:0,resource:this._videoSampler},{binding:1,resource:this._device.importExternalTexture({source:t.underlyingResource})}]},C=this._device.createBindGroup(E);b.setPipeline(h),b.setBindGroup(0,C),b.draw(4,1,0,0),b.end(),(c=(l=o).popDebugGroup)===null||c===void 0||c.call(l),u&&(this._device.queue.submit([o.finish()]),o=null)},r.prototype.invertYPreMultiplyAlpha=function(t,e,n,i,o,a,s,l,c,u,d,h,p,m,v){var b,E,C,T,f,g;o===void 0&&(o=!1),a===void 0&&(a=!1),s===void 0&&(s=0),l===void 0&&(l=0),c===void 0&&(c=1),u===void 0&&(u=0),d===void 0&&(d=0),h===void 0&&(h=0),p===void 0&&(p=0);var S,y=h!==0,x=m===void 0,R=this._getPipeline(i,y?Er.InvertYPremultiplyAlphaWithOfst:Er.InvertYPremultiplyAlpha,{invertY:o,premultiplyAlpha:a}),I=R[0],M=R[1];if(s=Math.max(s,0),x&&(m=this._device.createCommandEncoder({})),(E=(b=m).pushDebugGroup)===null||E===void 0||E.call(b,"internal process texture - invertY=".concat(o," premultiplyAlpha=").concat(a)),en.IsHardwareTexture(t)?(S=t.underlyingResource,o&&!a&&c===1&&s===0||(t=void 0)):(S=t,t=void 0),S){y&&this._bufferManager.setRawData(this._ubCopyWithOfst,0,new Float32Array([u,d,h,p]),0,16);var D=t,B=(C=D?._copyInvertYTempTexture)!==null&&C!==void 0?C:this.createTexture({width:e,height:n,layers:1},!1,!1,!1,!1,!1,i,1,m,21,void 0,"TempTextureForCopyWithInvertY"),F=(T=D?._copyInvertYRenderPassDescr)!==null&&T!==void 0?T:{label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_invertYPreMultiplyAlpha_").concat(i,"_").concat(o?"InvertY":"DontInvertY","_").concat(a?"PremultiplyAlpha":"DontPremultiplyAlpha"),colorAttachments:[{view:B.createView({format:i,dimension:"2d",baseMipLevel:0,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:0}),loadOp:"load",storeOp:"store"}]},X=m.beginRenderPass(F),$=y?D?._copyInvertYBindGroupWithOfst:D?._copyInvertYBindGroup;if(!$){var Q={layout:M,entries:[{binding:0,resource:S.createView({format:i,dimension:"2d",baseMipLevel:l,mipLevelCount:1,arrayLayerCount:c,baseArrayLayer:s})}]};y&&Q.entries.push({binding:1,resource:{buffer:this._ubCopyWithOfst}}),$=this._device.createBindGroup(Q)}X.setPipeline(I),X.setBindGroup(0,$),X.draw(4,1,0,0),X.end(),m.copyTextureToTexture({texture:B},{texture:S,mipLevel:l,origin:{x:0,y:0,z:s}},{width:e,height:n,depthOrArrayLayers:1}),D?(D._copyInvertYTempTexture=B,D._copyInvertYRenderPassDescr=F,y?D._copyInvertYBindGroupWithOfst=$:D._copyInvertYBindGroup=$):this._deferredReleaseTextures.push([B,null]),(g=(f=m).popDebugGroup)===null||g===void 0||g.call(f),x&&(this._device.queue.submit([m.finish()]),m=null)}},r.prototype.copyWithInvertY=function(t,e,n,i){var o,a,s,l,c=i===void 0,u=this._getPipeline(e,Er.InvertYPremultiplyAlpha,{invertY:!0,premultiplyAlpha:!1}),d=u[0],h=u[1];c&&(i=this._device.createCommandEncoder({})),(a=(o=i).pushDebugGroup)===null||a===void 0||a.call(o,"internal copy texture with invertY");var p=i.beginRenderPass(n),m=this._device.createBindGroup({layout:h,entries:[{binding:0,resource:t}]});p.setPipeline(d),p.setBindGroup(0,m),p.draw(4,1,0,0),p.end(),(l=(s=i).popDebugGroup)===null||l===void 0||l.call(s),c&&(this._device.queue.submit([i.finish()]),i=null)},r.prototype.createTexture=function(t,e,n,i,o,a,s,l,c,u,d,h){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=!1),a===void 0&&(a=!1),s===void 0&&(s="rgba8unorm"),l===void 0&&(l=1),u===void 0&&(u=-1),d===void 0&&(d=0),l=en.GetSample(l);var p=t.layers||1,m={width:t.width,height:t.height,depthOrArrayLayers:p},v=ao[s]?16:0,b=en.IsCompressedFormat(s),E=e?en.ComputeNumMipmapLevels(t.width,t.height):1,C=u>=0?u:7;d|=e&&!b?1|v:0,b||a||(d|=2|v);var T=this._device.createTexture({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_Texture").concat(a?"3D":"2D","_").concat(h?h+"_":"").concat(m.width,"x").concat(m.height,"x").concat(m.depthOrArrayLayers,"_").concat(e?"wmips":"womips","_").concat(s,"_samples").concat(l),size:m,dimension:a?"3d":"2d",format:s,usage:C|d,sampleCount:l,mipLevelCount:E});return en.IsImageBitmap(t)&&(this.updateTexture(t,T,t.width,t.height,p,s,0,0,i,o,0,0),e&&n&&this.generateMipmaps(T,s,E,0,a,c)),T},r.prototype.createCubeTexture=function(t,e,n,i,o,a,s,l,c,u,d){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=!1),a===void 0&&(a="rgba8unorm"),s===void 0&&(s=1),c===void 0&&(c=-1),u===void 0&&(u=0),s=en.GetSample(s);var h=en.IsImageBitmapArray(t)?t[0].width:t.width,p=en.IsImageBitmapArray(t)?t[0].height:t.height,m=ao[a]?16:0,v=en.IsCompressedFormat(a),b=e?en.ComputeNumMipmapLevels(h,p):1,E=c>=0?c:7;u|=e&&!v?1|m:0,v||(u|=2|m);var C=this._device.createTexture({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_TextureCube_").concat(d?d+"_":"").concat(h,"x").concat(p,"x6_").concat(e?"wmips":"womips","_").concat(a,"_samples").concat(s),size:{width:h,height:p,depthOrArrayLayers:6},dimension:"2d",format:a,usage:E|u,sampleCount:s,mipLevelCount:b});return en.IsImageBitmapArray(t)&&(this.updateCubeTextures(t,C,h,p,a,i,o,0,0),e&&n&&this.generateCubeMipmaps(C,a,b,l)),C},r.prototype.generateCubeMipmaps=function(t,e,n,i){var o,a,s,l,c=i===void 0;c&&(i=this._device.createCommandEncoder({})),(a=(o=i).pushDebugGroup)===null||a===void 0||a.call(o,"create cube mipmaps - ".concat(n," levels"));for(var u=0;u<6;++u)this.generateMipmaps(t,e,n,u,!1,i);(l=(s=i).popDebugGroup)===null||l===void 0||l.call(s),c&&(this._device.queue.submit([i.finish()]),i=null)},r.prototype.generateMipmaps=function(t,e,n,i,o,a){var s,l,c,u,d,h,p,m;i===void 0&&(i=0),o===void 0&&(o=!1);var v,b=a===void 0,E=this._getPipeline(e),C=E[0],T=E[1];if(i=Math.max(i,0),b&&(a=this._device.createCommandEncoder({})),(l=(s=a).pushDebugGroup)===null||l===void 0||l.call(s,"create mipmaps for face #".concat(i," - ").concat(n," levels")),en.IsHardwareTexture(t)?(v=t.underlyingResource,t._mipmapGenRenderPassDescr=t._mipmapGenRenderPassDescr||[],t._mipmapGenBindGroup=t._mipmapGenBindGroup||[]):(v=t,t=void 0),v){for(var f=t,g=1;g<n;++g){var S=(u=(c=f?._mipmapGenRenderPassDescr[i])===null||c===void 0?void 0:c[g-1])!==null&&u!==void 0?u:{label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_generateMipmaps_").concat(e,"_faceIndex").concat(i,"_level").concat(g),colorAttachments:[{view:v.createView({format:e,dimension:o?"3d":"2d",baseMipLevel:g,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:i}),loadOp:"load",storeOp:"store"}]};f&&(f._mipmapGenRenderPassDescr[i]=f._mipmapGenRenderPassDescr[i]||[],f._mipmapGenRenderPassDescr[i][g-1]=S);var y=a.beginRenderPass(S),x=(h=(d=f?._mipmapGenBindGroup[i])===null||d===void 0?void 0:d[g-1])!==null&&h!==void 0?h:this._device.createBindGroup({layout:T,entries:[{binding:0,resource:v.createView({format:e,dimension:o?"3d":"2d",baseMipLevel:g-1,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:i})},{binding:1,resource:this._mipmapSampler}]});f&&(f._mipmapGenBindGroup[i]=f._mipmapGenBindGroup[i]||[],f._mipmapGenBindGroup[i][g-1]=x),y.setPipeline(C),y.setBindGroup(0,x),y.draw(4,1,0,0),y.end()}(m=(p=a).popDebugGroup)===null||m===void 0||m.call(p),b&&(this._device.queue.submit([a.finish()]),a=null)}},r.prototype.createGPUTextureForInternalTexture=function(t,e,n,i,o){var a,s;t._hardwareTexture||(t._hardwareTexture=new Fd),e===void 0&&(e=t.width),n===void 0&&(n=t.height),i===void 0&&(i=t.depth);var l=t._hardwareTexture,c=!!((o??0)&P.Y.TEXTURE_CREATIONFLAG_STORAGE);l.format=en.GetWebGPUTextureFormat(t.type,t.format,t._useSRGBBuffer),l.textureUsages=t._source===5||t.source===6?21:t._source===12?20:-1,l.textureAdditionalUsages=c?8:0;var u,d=t.generateMipMaps,h=i||1;if(u=t._maxLodLevel!==null?t._maxLodLevel:d?en.ComputeNumMipmapLevels(e,n):1,t.isCube){var p=this.createCubeTexture({width:e,height:n},t.generateMipMaps,t.generateMipMaps,t.invertY,!1,l.format,1,this._commandEncoderForCreation,l.textureUsages,l.textureAdditionalUsages,t.label);l.set(p);var m=t.is3D?1:h,v=en.GetDepthFormatOnly(l.format),b=en.HasDepthAndStencilAspects(l.format)?"depth-only":"all",E=t.is2DArray?"cube-array":"cube";l.createView({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_TextureViewCube").concat(t.is2DArray?"_Array"+m:"","_").concat(e,"x").concat(n,"_").concat(d?"wmips":"womips","_").concat(v,"_").concat(E,"_").concat(b,"_").concat((a=t.label)!==null&&a!==void 0?a:"noname"),format:v,dimension:E,mipLevelCount:u,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:6,aspect:b},c)}else p=this.createTexture({width:e,height:n,layers:h},t.generateMipMaps,t.generateMipMaps,t.invertY,!1,t.is3D,l.format,1,this._commandEncoderForCreation,l.textureUsages,l.textureAdditionalUsages,t.label),l.set(p),m=t.is3D?1:h,v=en.GetDepthFormatOnly(l.format),b=en.HasDepthAndStencilAspects(l.format)?"depth-only":"all",E=t.is2DArray?"2d-array":t.is3D?"3d":"2d",l.createView({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_TextureView").concat(t.is3D?"3D":"2D").concat(t.is2DArray?"_Array"+m:"","_").concat(e,"x").concat(n).concat(t.is3D?"x"+h:"","_").concat(d?"wmips":"womips","_").concat(v,"_").concat(E,"_").concat(b,"_").concat((s=t.label)!==null&&s!==void 0?s:"noname"),format:v,dimension:E,mipLevelCount:u,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:m,aspect:b},c);return t.width=t.baseWidth=e,t.height=t.baseHeight=n,t.depth=t.baseDepth=i,this.createMSAATexture(t,t.samples),l},r.prototype.createMSAATexture=function(t,e,n,i){n===void 0&&(n=!0),i===void 0&&(i=-1);var o=t._hardwareTexture;if(n&&o?.releaseMSAATexture(),o&&!((e??1)<=1)){var a=t.width,s=t.height,l=this.createTexture({width:a,height:s,layers:1},!1,!1,!1,!1,!1,o.format,e,this._commandEncoderForCreation,16,0,t.label?"MSAA"+t.label:void 0);o.setMSAATexture(l,i)}},r.prototype.updateCubeTextures=function(t,e,n,i,o,a,s,l,c){a===void 0&&(a=!1),s===void 0&&(s=!1),l===void 0&&(l=0),c===void 0&&(c=0);for(var u=[0,3,1,4,2,5],d=0;d<u.length;++d){var h=t[u[d]];this.updateTexture(h,e,n,i,1,o,d,0,a,s,l,c)}},r.prototype.updateTexture=function(t,e,n,i,o,a,s,l,c,u,d,h,p){s===void 0&&(s=0),l===void 0&&(l=0),c===void 0&&(c=!1),u===void 0&&(u=!1),d===void 0&&(d=0),h===void 0&&(h=0);var m=en.IsInternalTexture(e)?e._hardwareTexture.underlyingResource:e,v=en.GetBlockInformationFromFormat(a),b=en.IsInternalTexture(e)?e._hardwareTexture:e,E={texture:m,origin:{x:d,y:h,z:Math.max(s,0)},mipLevel:l,premultipliedAlpha:u},C={width:Math.ceil(n/v.width)*v.width,height:Math.ceil(i/v.height)*v.height,depthOrArrayLayers:o||1};if(t.byteLength!==void 0){var T=Math.ceil(n/v.width)*v.length;if(256*Math.ceil(T/256)===T){var f=this._device.createCommandEncoder({}),g=this._bufferManager.createRawBuffer(t.byteLength,nn.MapWrite|nn.CopySrc,!0,"TempBufferForUpdateTexture"+(m?"_"+m.label:"")),S=g.getMappedRange();new Uint8Array(S).set(t),g.unmap(),f.copyBufferToTexture({buffer:g,offset:0,bytesPerRow:T,rowsPerImage:i},E,C),this._device.queue.submit([f.finish()]),this._bufferManager.releaseBuffer(g)}else this._device.queue.writeTexture(E,t,{offset:0,bytesPerRow:T,rowsPerImage:i},C);if(c||u){if(!en.IsInternalTexture(e))throw"updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!";var y=d===0&&h===0&&n===e.width&&i===e.height;this.invertYPreMultiplyAlpha(b,e.width,e.height,a,c,u,s,l,o||1,d,h,y?0:n,y?0:i,void 0,p)}}else if(c)if(E.premultipliedAlpha=!1,en.IsInternalTexture(e)&&d===0&&h===0&&n===e.width&&i===e.height)this._device.queue.copyExternalImageToTexture({source:t},E,C),this.invertYPreMultiplyAlpha(b,n,i,a,c,u,s,l,o||1,0,0,0,0,void 0,p);else{f=this._device.createCommandEncoder({});var x=this.createTexture({width:n,height:i,layers:1},!1,!1,!1,!1,!1,a,1,f,5,void 0,"TempTextureForUpdateTexture");this._deferredReleaseTextures.push([x,null]),C.depthOrArrayLayers=1,this._device.queue.copyExternalImageToTexture({source:t},{texture:x},C),C.depthOrArrayLayers=o||1,this.invertYPreMultiplyAlpha(x,n,i,a,c,u,s,l,o||1,0,0,0,0,f,p),f.copyTextureToTexture({texture:x},E,C),this._device.queue.submit([f.finish()])}else this._device.queue.copyExternalImageToTexture({source:t},E,C)},r.prototype.readPixels=function(t,e,n,i,o,a,s,l,c,u){s===void 0&&(s=0),l===void 0&&(l=0),c===void 0&&(c=null),u===void 0&&(u=!1);var d=en.GetBlockInformationFromFormat(a),h=Math.ceil(i/d.width)*d.length,p=256*Math.ceil(h/256),m=p*o,v=this._bufferManager.createRawBuffer(m,nn.MapRead|nn.CopyDst,void 0,"TempBufferForReadPixels"+(t.label?"_"+t.label:"")),b=this._device.createCommandEncoder({});return b.copyTextureToBuffer({texture:t,mipLevel:l,origin:{x:e,y:n,z:Math.max(s,0)}},{buffer:v,offset:0,bytesPerRow:p},{width:i,height:o,depthOrArrayLayers:1}),this._device.queue.submit([b.finish()]),this._bufferManager.readDataFromBuffer(v,m,i,o,h,p,en.GetTextureTypeFromFormat(a),0,c,!0,u)},r.prototype.releaseTexture=function(t){if(en.IsInternalTexture(t)){var e=t._hardwareTexture,n=t._irradianceTexture;this._deferredReleaseTextures.push([e,n])}else this._deferredReleaseTextures.push([t,null])},r.prototype.destroyDeferredTextures=function(){for(var t=0;t<this._deferredReleaseTextures.length;++t){var e=this._deferredReleaseTextures[t],n=e[0],i=e[1];n&&(en.IsHardwareTexture(n)?n.release():n.destroy()),i?.dispose()}this._deferredReleaseTextures.length=0},r}(),Cg=function(r){function t(e,n){n===void 0&&(n=0);var i=r.call(this)||this;return i.engineId=-1,i.capacity=n,i._buffer=e,i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"underlyingResource",{get:function(){return this._buffer},enumerable:!1,configurable:!0}),t}($o.n),Si=L(35877),CD=function(){function r(t,e){this._deferredReleaseBuffers=[],this._engine=t,this._device=e}return r._IsGPUBuffer=function(t){return t.underlyingResource===void 0},r._FlagsToString=function(t,e){e===void 0&&(e="");for(var n=e,i=0;i<=9;++i)t&1<<i&&(n&&(n+="_"),n+=nn[1<<i]);return n},r.prototype.createRawBuffer=function(t,e,n,i){n===void 0&&(n=!1);var o=t.byteLength!==void 0?t.byteLength+3&-4:t+3&-4,a={label:"BabylonWebGPUDevice"+this._engine.uniqueId+"_"+r._FlagsToString(e,i??"Buffer")+"_size"+o,mappedAtCreation:n,size:o,usage:e};return this._device.createBuffer(a)},r.prototype.createBuffer=function(t,e,n){var i=t.byteLength!==void 0,o=this.createRawBuffer(t,e,void 0,n),a=new Cg(o);return a.references=1,a.capacity=i?t.byteLength:t,a.engineId=this._engine.uniqueId,i&&this.setSubData(a,0,t),a},r.prototype.setRawData=function(t,e,n,i,o){this._device.queue.writeBuffer(t,e,n.buffer,i,o)},r.prototype.setSubData=function(t,e,n,i,o){i===void 0&&(i=0),o===void 0&&(o=0);var a=t.underlyingResource;o=o||n.byteLength,o=Math.min(o,t.capacity-e);var s=n.byteOffset+i,l=s+o,c=o+3&-4;if(c!==o){var u=new Uint8Array(n.buffer.slice(s,l));(n=new Uint8Array(c)).set(u),i=0,s=0,l=c,o=c}for(var d=15728640,h=0;l-(s+h)>d;)this._device.queue.writeBuffer(a,e+h,n.buffer,s+h,d),h+=d;this._device.queue.writeBuffer(a,e+h,n.buffer,s+h,o-h)},r.prototype._getHalfFloatAsFloatRGBAArrayBuffer=function(t,e,n){n||(n=new Float32Array(t));for(var i=new Uint16Array(e);t--;)n[t]=(0,Si.SX)(i[t]);return n},r.prototype.readDataFromBuffer=function(t,e,n,i,o,a,s,l,c,u,d){var h=this;s===void 0&&(s=P.Y.TEXTURETYPE_UNSIGNED_BYTE),l===void 0&&(l=0),c===void 0&&(c=null),u===void 0&&(u=!0),d===void 0&&(d=!1);var p=s===P.Y.TEXTURETYPE_FLOAT?2:s===P.Y.TEXTURETYPE_HALF_FLOAT?1:0,m=this._engine.uniqueId;return new Promise(function(v,b){t.mapAsync(1,l,e).then(function(){var E=t.getMappedRange(l,e),C=c;if(d)C=C===null?(0,cu.k)(s,e,!0,E):(0,cu.k)(s,C.buffer,void 0,E);else if(C===null)switch(p){case 0:(C=new Uint8Array(e)).set(new Uint8Array(E));break;case 1:C=h._getHalfFloatAsFloatRGBAArrayBuffer(e/2,E);break;case 2:(C=new Float32Array(e/4)).set(new Float32Array(E))}else switch(p){case 0:(C=new Uint8Array(C.buffer)).set(new Uint8Array(E));break;case 1:C=h._getHalfFloatAsFloatRGBAArrayBuffer(e/2,E,c);break;case 2:(C=new Float32Array(C.buffer)).set(new Float32Array(E))}if(o!==a){p!==1||d||(o*=2,a*=2);for(var T=new Uint8Array(C.buffer),f=o,g=0,S=1;S<i;++S){g=S*a;for(var y=0;y<o;++y)T[f++]=T[g++]}C=p===0||d?new Uint8Array(T.buffer,0,f):new Float32Array(T.buffer,0,f/4)}t.unmap(),u&&h.releaseBuffer(t),v(C)},function(E){h._engine.isDisposed||h._engine.uniqueId!==m?v(new Uint8Array):b(E)})})},r.prototype.releaseBuffer=function(t){return r._IsGPUBuffer(t)?(this._deferredReleaseBuffers.push(t),!0):(t.references--,t.references===0&&(this._deferredReleaseBuffers.push(t.underlyingResource),!0))},r.prototype.destroyDeferredBuffers=function(){for(var t=0;t<this._deferredReleaseBuffers.length;++t)this._deferredReleaseBuffers[t].destroy();this._deferredReleaseBuffers.length=0},r}(),RD=[0,0,3,7,0,2,6,2,4,1,5,3,1],ID=[0,64,32,96,16,80,48,112,8],MD=[0,128,128,0,0,0,0,128,0,0,0,0,128],wd=function(){function r(t){this._samplers={},this._device=t,this.disabled=!1}return r.GetSamplerHashCode=function(t){var e,n,i,o=t._cachedAnisotropicFilteringLevel&&t._cachedAnisotropicFilteringLevel>1?4:1;return RD[t.samplingMode]+ID[(t._comparisonFunction||514)-512+1]+MD[t.samplingMode]+(((e=t._cachedWrapU)!==null&&e!==void 0?e:1)<<8)+(((n=t._cachedWrapV)!==null&&n!==void 0?n:1)<<10)+(((i=t._cachedWrapR)!==null&&i!==void 0?i:1)<<12)+((t.useMipMaps?1:0)<<14)+(o<<15)},r._GetSamplerFilterDescriptor=function(t,e){var n,i,o,a,s,l=t.useMipMaps;switch(t.samplingMode){case P.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST:n="linear",i="linear",o="nearest",l||(a=s=0);break;case P.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR:case P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:n="linear",i="linear",l?o="linear":(o="nearest",a=s=0);break;case P.Y.TEXTURE_NEAREST_NEAREST_MIPLINEAR:n="nearest",i="nearest",l?o="linear":(o="nearest",a=s=0);break;case P.Y.TEXTURE_NEAREST_NEAREST_MIPNEAREST:n="nearest",i="nearest",o="nearest",l||(a=s=0);break;case P.Y.TEXTURE_NEAREST_LINEAR_MIPNEAREST:n="nearest",i="linear",o="nearest",l||(a=s=0);break;case P.Y.TEXTURE_NEAREST_LINEAR_MIPLINEAR:n="nearest",i="linear",l?o="linear":(o="nearest",a=s=0);break;case P.Y.TEXTURE_NEAREST_LINEAR:n="nearest",i="linear",o="nearest",a=s=0;break;case P.Y.TEXTURE_NEAREST_NEAREST:case P.Y.TEXTURE_NEAREST_SAMPLINGMODE:n="nearest",i="nearest",o="nearest",a=s=0;break;case P.Y.TEXTURE_LINEAR_NEAREST_MIPNEAREST:n="linear",i="nearest",o="nearest",l||(a=s=0);break;case P.Y.TEXTURE_LINEAR_NEAREST_MIPLINEAR:n="linear",i="nearest",l?o="linear":(o="nearest",a=s=0);break;case P.Y.TEXTURE_LINEAR_LINEAR:case P.Y.TEXTURE_BILINEAR_SAMPLINGMODE:n="linear",i="linear",o="nearest",a=s=0;break;case P.Y.TEXTURE_LINEAR_NEAREST:n="linear",i="nearest",o="nearest",a=s=0;break;default:n="nearest",i="nearest",o="nearest",a=s=0}return e>1&&(a!==0||s!==0)&&o!=="nearest"?{magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",anisotropyEnabled:!0}:{magFilter:n,minFilter:i,mipmapFilter:o,lodMinClamp:a,lodMaxClamp:s}},r._GetWrappingMode=function(t){switch(t){case P.Y.TEXTURE_WRAP_ADDRESSMODE:return"repeat";case P.Y.TEXTURE_CLAMP_ADDRESSMODE:return"clamp-to-edge";case P.Y.TEXTURE_MIRROR_ADDRESSMODE:return"mirror-repeat"}return"repeat"},r._GetSamplerWrappingDescriptor=function(t){return{addressModeU:this._GetWrappingMode(t._cachedWrapU),addressModeV:this._GetWrappingMode(t._cachedWrapV),addressModeW:this._GetWrappingMode(t._cachedWrapR)}},r._GetSamplerDescriptor=function(t,e){var n=t.useMipMaps&&t._cachedAnisotropicFilteringLevel&&t._cachedAnisotropicFilteringLevel>1?4:1,i=this._GetSamplerFilterDescriptor(t,n);return(0,A.Cl)((0,A.Cl)((0,A.Cl)({label:e},i),this._GetSamplerWrappingDescriptor(t)),{compare:t._comparisonFunction?r.GetCompareFunction(t._comparisonFunction):void 0,maxAnisotropy:i.anisotropyEnabled?n:1})},r.GetCompareFunction=function(t){switch(t){case P.Y.ALWAYS:return"always";case P.Y.EQUAL:return"equal";case P.Y.GREATER:return"greater";case P.Y.GEQUAL:return"greater-equal";case P.Y.LESS:return"less";case P.Y.LEQUAL:return"less-equal";case P.Y.NEVER:return"never";case P.Y.NOTEQUAL:return"not-equal";default:return"less"}},r.prototype.getSampler=function(t,e,n,i){if(e===void 0&&(e=!1),n===void 0&&(n=0),this.disabled)return this._device.createSampler(r._GetSamplerDescriptor(t,i));e?n=0:n===0&&(n=r.GetSamplerHashCode(t));var o=e?void 0:this._samplers[n];return o||(o=this._device.createSampler(r._GetSamplerDescriptor(t,i)),e||(this._samplers[n]=o)),o},r}();(function(r){r[r.StencilReadMask=0]="StencilReadMask",r[r.StencilWriteMask=1]="StencilWriteMask",r[r.DepthBias=2]="DepthBias",r[r.DepthBiasSlopeScale=3]="DepthBiasSlopeScale",r[r.DepthStencilState=4]="DepthStencilState",r[r.MRTAttachments1=5]="MRTAttachments1",r[r.MRTAttachments2=6]="MRTAttachments2",r[r.RasterizationState=7]="RasterizationState",r[r.ColorStates=8]="ColorStates",r[r.ShaderStage=9]="ShaderStage",r[r.TextureStage=10]="TextureStage",r[r.VertexState=11]="VertexState",r[r.NumStates=12]="NumStates"})(Bn||(Bn={}));var Bd={0:1,1:2,768:3,769:4,770:5,771:6,772:7,773:8,774:9,775:10,776:11,32769:12,32770:13,32771:12,32772:13},Wa={0:0,7680:1,7681:2,7682:3,7683:4,5386:5,34055:6,34056:7},Rg=function(){function r(t,e){this.mrtTextureCount=0,this._device=t,this._useTextureStage=!0,this._states=new Array(30),this._statesLength=0,this._stateDirtyLowestIndex=0,this._emptyVertexBuffer=e,this._mrtFormats=[],this._parameter={token:void 0,pipeline:null},this.disabled=!1,this.vertexBuffers=[],this._kMaxVertexBufferStride=t.limits.maxVertexBufferArrayStride||2048,this.reset()}return r.prototype.reset=function(){this._isDirty=!0,this.vertexBuffers.length=0,this.setAlphaToCoverage(!1),this.resetDepthCullingState(),this.setClampDepth(!1),this.setDepthBias(0),this._webgpuColorFormat=["bgra8unorm"],this.setColorFormat("bgra8unorm"),this.setMRT([]),this.setAlphaBlendEnabled(!1),this.setAlphaBlendFactors([null,null,null,null],[null,null]),this.setWriteMask(15),this.setDepthStencilFormat("depth24plus-stencil8"),this.setStencilEnabled(!1),this.resetStencilState(),this.setBuffers(null,null,null),this._setTextureState(0)},Object.defineProperty(r.prototype,"colorFormats",{get:function(){return this._mrtAttachments1>0?this._mrtFormats:this._webgpuColorFormat},enumerable:!1,configurable:!0}),r.prototype.getRenderPipeline=function(t,e,n,i){if(i===void 0&&(i=0),n=en.GetSample(n),this.disabled){var o=r._GetTopology(t);return this._setVertexState(e),this._setTextureState(i),this._parameter.pipeline=this._createRenderPipeline(e,o,n),r.NumCacheMiss++,r._NumPipelineCreationCurrentFrame++,this._parameter.pipeline}if(this._setShaderStage(e.uniqueId),this._setRasterizationState(t,n),this._setColorStates(),this._setDepthStencilState(),this._setVertexState(e),this._setTextureState(i),this.lastStateDirtyLowestIndex=this._stateDirtyLowestIndex,!this._isDirty&&this._parameter.pipeline)return this._stateDirtyLowestIndex=this._statesLength,r.NumCacheHitWithoutHash++,this._parameter.pipeline;if(this._getRenderPipeline(this._parameter),this._isDirty=!1,this._stateDirtyLowestIndex=this._statesLength,this._parameter.pipeline)return r.NumCacheHitWithHash++,this._parameter.pipeline;var a=r._GetTopology(t);return this._parameter.pipeline=this._createRenderPipeline(e,a,n),this._setRenderPipeline(this._parameter),r.NumCacheMiss++,r._NumPipelineCreationCurrentFrame++,this._parameter.pipeline},r.prototype.endFrame=function(){r.NumPipelineCreationLastFrame=r._NumPipelineCreationCurrentFrame,r._NumPipelineCreationCurrentFrame=0},r.prototype.setAlphaToCoverage=function(t){this._alphaToCoverageEnabled=t},r.prototype.setFrontFace=function(t){this._frontFace=t},r.prototype.setCullEnabled=function(t){this._cullEnabled=t},r.prototype.setCullFace=function(t){this._cullFace=t},r.prototype.setClampDepth=function(t){this._clampDepth=t},r.prototype.resetDepthCullingState=function(){this.setDepthCullingState(!1,2,1,0,0,!0,!0,P.Y.ALWAYS)},r.prototype.setDepthCullingState=function(t,e,n,i,o,a,s,l){this._depthWriteEnabled=s,this._depthTestEnabled=a,this._depthCompare=(l??P.Y.ALWAYS)-512,this._cullFace=n,this._cullEnabled=t,this._frontFace=e,this.setDepthBiasSlopeScale(i),this.setDepthBias(o)},r.prototype.setDepthBias=function(t){this._depthBias!==t&&(this._depthBias=t,this._states[Bn.DepthBias]=t,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.DepthBias))},r.prototype.setDepthBiasSlopeScale=function(t){this._depthBiasSlopeScale!==t&&(this._depthBiasSlopeScale=t,this._states[Bn.DepthBiasSlopeScale]=t,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.DepthBiasSlopeScale))},r.prototype.setColorFormat=function(t){this._webgpuColorFormat[0]=t,this._colorFormat=ao[t??""]},r.prototype.setMRTAttachments=function(t){this.mrtAttachments=t;for(var e=0,n=0;n<t.length;++n)t[n]!==0&&(e+=1<<n);this._mrtEnabledMask!==e&&(this._mrtEnabledMask=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.MRTAttachments1))},r.prototype.setMRT=function(t,e){var n,i;if((e=e??t.length)>10)throw"Can't handle more than 10 attachments for a MRT in cache render pipeline!";this.mrtTextureArray=t,this.mrtTextureCount=e,this._mrtEnabledMask=65535;for(var o=[0,0],a=0,s=0,l=0,c=0;c<e;++c){var u=t[c],d=u?._hardwareTexture;this._mrtFormats[l]=(n=d?.format)!==null&&n!==void 0?n:this._webgpuColorFormat[0],o[a]+=ao[(i=this._mrtFormats[l])!==null&&i!==void 0?i:""]<<s,l++,(s+=6)>=32&&(s=0,a++)}this._mrtFormats.length=l,this._mrtAttachments1===o[0]&&this._mrtAttachments2===o[1]||(this._mrtAttachments1=o[0],this._mrtAttachments2=o[1],this._states[Bn.MRTAttachments1]=o[0],this._states[Bn.MRTAttachments2]=o[1],this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.MRTAttachments1))},r.prototype.setAlphaBlendEnabled=function(t){this._alphaBlendEnabled=t},r.prototype.setAlphaBlendFactors=function(t,e){this._alphaBlendFuncParams=t,this._alphaBlendEqParams=e},r.prototype.setWriteMask=function(t){this._writeMask=t},r.prototype.setDepthStencilFormat=function(t){this._webgpuDepthStencilFormat=t,this._depthStencilFormat=t===void 0?0:ao[t]},r.prototype.setDepthTestEnabled=function(t){this._depthTestEnabled=t},r.prototype.setDepthWriteEnabled=function(t){this._depthWriteEnabled=t},r.prototype.setDepthCompare=function(t){this._depthCompare=(t??P.Y.ALWAYS)-512},r.prototype.setStencilEnabled=function(t){this._stencilEnabled=t},r.prototype.setStencilCompare=function(t){this._stencilFrontCompare=(t??P.Y.ALWAYS)-512},r.prototype.setStencilDepthFailOp=function(t){this._stencilFrontDepthFailOp=t===null?1:Wa[t]},r.prototype.setStencilPassOp=function(t){this._stencilFrontPassOp=t===null?2:Wa[t]},r.prototype.setStencilFailOp=function(t){this._stencilFrontFailOp=t===null?1:Wa[t]},r.prototype.setStencilReadMask=function(t){this._stencilReadMask!==t&&(this._stencilReadMask=t,this._states[Bn.StencilReadMask]=t,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.StencilReadMask))},r.prototype.setStencilWriteMask=function(t){this._stencilWriteMask!==t&&(this._stencilWriteMask=t,this._states[Bn.StencilWriteMask]=t,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.StencilWriteMask))},r.prototype.resetStencilState=function(){this.setStencilState(!1,P.Y.ALWAYS,P.Y.KEEP,P.Y.REPLACE,P.Y.KEEP,255,255)},r.prototype.setStencilState=function(t,e,n,i,o,a,s){this._stencilEnabled=t,this._stencilFrontCompare=(e??P.Y.ALWAYS)-512,this._stencilFrontDepthFailOp=n===null?1:Wa[n],this._stencilFrontPassOp=i===null?2:Wa[i],this._stencilFrontFailOp=o===null?1:Wa[o],this.setStencilReadMask(a),this.setStencilWriteMask(s)},r.prototype.setBuffers=function(t,e,n){this._vertexBuffers=t,this._overrideVertexBuffers=n,this._indexBuffer=e},r._GetTopology=function(t){switch(t){case P.Y.MATERIAL_TriangleFillMode:return"triangle-list";case P.Y.MATERIAL_PointFillMode:return"point-list";case P.Y.MATERIAL_WireFrameFillMode:return"line-list";case P.Y.MATERIAL_PointListDrawMode:return"point-list";case P.Y.MATERIAL_LineListDrawMode:return"line-list";case P.Y.MATERIAL_LineLoopDrawMode:throw"LineLoop is an unsupported fillmode in WebGPU";case P.Y.MATERIAL_LineStripDrawMode:return"line-strip";case P.Y.MATERIAL_TriangleStripDrawMode:return"triangle-strip";case P.Y.MATERIAL_TriangleFanDrawMode:throw"TriangleFan is an unsupported fillmode in WebGPU";default:return"triangle-list"}},r._GetAphaBlendOperation=function(t){switch(t){case P.Y.GL_ALPHA_EQUATION_ADD:return"add";case P.Y.GL_ALPHA_EQUATION_SUBTRACT:return"subtract";case P.Y.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:return"reverse-subtract";case P.Y.GL_ALPHA_EQUATION_MIN:return"min";case P.Y.GL_ALPHA_EQUATION_MAX:return"max";default:return"add"}},r._GetAphaBlendFactor=function(t){switch(t){case 0:return"zero";case 1:return"one";case P.Y.GL_ALPHA_FUNCTION_SRC:return"src";case P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:return"one-minus-src";case P.Y.GL_ALPHA_FUNCTION_SRC_ALPHA:return"src-alpha";case P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:return"one-minus-src-alpha";case P.Y.GL_ALPHA_FUNCTION_DST_ALPHA:return"dst-alpha";case P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:return"one-minus-dst-alpha";case P.Y.GL_ALPHA_FUNCTION_DST_COLOR:return"dst";case P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:return"one-minus-dst";case P.Y.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:return"src-alpha-saturated";case P.Y.GL_ALPHA_FUNCTION_CONSTANT_COLOR:return"constant";case P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:return"one-minus-constant";case P.Y.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:return"constant";case P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:return"one-minus-constant";default:return"one"}},r._GetCompareFunction=function(t){switch(t){case 0:return"never";case 1:return"less";case 2:return"equal";case 3:return"less-equal";case 4:return"greater";case 5:return"not-equal";case 6:return"greater-equal";case 7:return"always"}return"never"},r._GetStencilOpFunction=function(t){switch(t){case 0:return"zero";case 1:return"keep";case 2:return"replace";case 3:return"increment-clamp";case 4:return"decrement-clamp";case 5:return"invert";case 6:return"increment-wrap";case 7:return"decrement-wrap"}return"keep"},r._GetVertexInputDescriptorFormat=function(t){var e=t.type,n=t.normalized,i=t.getSize();switch(e){case Y.R.BYTE:switch(i){case 1:case 2:return n?"snorm8x2":"sint8x2";case 3:case 4:return n?"snorm8x4":"sint8x4"}break;case Y.R.UNSIGNED_BYTE:switch(i){case 1:case 2:return n?"unorm8x2":"uint8x2";case 3:case 4:return n?"unorm8x4":"uint8x4"}break;case Y.R.SHORT:switch(i){case 1:case 2:return n?"snorm16x2":"sint16x2";case 3:case 4:return n?"snorm16x4":"sint16x4"}break;case Y.R.UNSIGNED_SHORT:switch(i){case 1:case 2:return n?"unorm16x2":"uint16x2";case 3:case 4:return n?"unorm16x4":"uint16x4"}break;case Y.R.INT:switch(i){case 1:return"sint32";case 2:return"sint32x2";case 3:return"sint32x3";case 4:return"sint32x4"}break;case Y.R.UNSIGNED_INT:switch(i){case 1:return"uint32";case 2:return"uint32x2";case 3:return"uint32x3";case 4:return"uint32x4"}break;case Y.R.FLOAT:switch(i){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4"}}throw new Error("Invalid Format '".concat(t.getKind(),"' - type=").concat(e,", normalized=").concat(n,", size=").concat(i))},r.prototype._getAphaBlendState=function(){return this._alphaBlendEnabled?{srcFactor:r._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),dstFactor:r._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),operation:r._GetAphaBlendOperation(this._alphaBlendEqParams[1])}:null},r.prototype._getColorBlendState=function(){return this._alphaBlendEnabled?{srcFactor:r._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),dstFactor:r._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),operation:r._GetAphaBlendOperation(this._alphaBlendEqParams[0])}:null},r.prototype._setShaderStage=function(t){this._shaderId!==t&&(this._shaderId=t,this._states[Bn.ShaderStage]=t,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.ShaderStage))},r.prototype._setRasterizationState=function(t,e){var n=this._frontFace-1+((this._cullEnabled?this._cullFace:0)<<1)+((this._clampDepth?1:0)<<3)+((this._alphaToCoverageEnabled?1:0)<<4)+(t<<5)+(e<<8);this._rasterizationState!==n&&(this._rasterizationState=n,this._states[Bn.RasterizationState]=this._rasterizationState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.RasterizationState))},r.prototype._setColorStates=function(){var t=((this._writeMask?1:0)<<22)+(this._colorFormat<<23)+((this._depthWriteEnabled?1:0)<<29);this._alphaBlendEnabled&&(t+=(0|(this._alphaBlendFuncParams[0]===null?2:Bd[this._alphaBlendFuncParams[0]]))+((this._alphaBlendFuncParams[1]===null?2:Bd[this._alphaBlendFuncParams[1]])<<4)+((this._alphaBlendFuncParams[2]===null?2:Bd[this._alphaBlendFuncParams[2]])<<8)+((this._alphaBlendFuncParams[3]===null?2:Bd[this._alphaBlendFuncParams[3]])<<12)+((this._alphaBlendEqParams[0]===null?1:this._alphaBlendEqParams[0]-32773)<<16)+((this._alphaBlendEqParams[1]===null?1:this._alphaBlendEqParams[1]-32773)<<19)),t!==this._colorStates&&(this._colorStates=t,this._states[Bn.ColorStates]=this._colorStates,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.ColorStates))},r.prototype._setDepthStencilState=function(){var t=this._stencilEnabled?this._stencilFrontCompare+(this._stencilFrontDepthFailOp<<3)+(this._stencilFrontPassOp<<6)+(this._stencilFrontFailOp<<9):591,e=this._depthStencilFormat+((this._depthTestEnabled?this._depthCompare:7)<<6)+(t<<10);this._depthStencilState!==e&&(this._depthStencilState=e,this._states[Bn.DepthStencilState]=this._depthStencilState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.DepthStencilState))},r.prototype._setVertexState=function(t){for(var e,n,i,o=this._statesLength,a=Bn.VertexState,s=t._pipelineContext,l=s.shaderProcessingContext.attributeNamesFromEffect,c=s.shaderProcessingContext.attributeLocationsFromEffect,u=0,d=0;d<l.length;d++){var h=c[d],p=(e=this._overrideVertexBuffers&&this._overrideVertexBuffers[l[d]])!==null&&e!==void 0?e:this._vertexBuffers[l[d]];p||(p=this._emptyVertexBuffer);var m=(n=p.effectiveBuffer)===null||n===void 0?void 0:n.underlyingResource;if(p._validOffsetRange===void 0){var v=p.effectiveByteOffset,b=p.getSize(!0),E=p.effectiveByteStride;p._validOffsetRange=v+b<=this._kMaxVertexBufferStride&&E===0||E!==0&&v+b<=E}i&&i===m&&p._validOffsetRange||(this.vertexBuffers[u++]=p,i=p._validOffsetRange?m:null);var C=p.hashCode+(h<<7);this._isDirty=this._isDirty||this._states[a]!==C,this._states[a++]=C}this.vertexBuffers.length=u,this._statesLength=a,this._isDirty=this._isDirty||a!==o,this._isDirty&&(this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.VertexState))},r.prototype._setTextureState=function(t){this._textureState!==t&&(this._textureState=t,this._states[Bn.TextureStage]=this._textureState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Bn.TextureStage))},r.prototype._createPipelineLayout=function(t){if(this._useTextureStage)return this._createPipelineLayoutWithTextureStage(t);for(var e=[],n=t.shaderProcessingContext.bindGroupLayoutEntries,i=0;i<n.length;i++){var o=n[i];e[i]=this._device.createBindGroupLayout({entries:o})}return t.bindGroupLayouts[0]=e,this._device.createPipelineLayout({bindGroupLayouts:e})},r.prototype._createPipelineLayoutWithTextureStage=function(t){for(var e,n=t.shaderProcessingContext,i=n.bindGroupLayoutEntries,o=1,a=0;a<i.length;a++)for(var s=i[a],l=0;l<s.length;l++){var c=i[a][l];if(c.texture){var u=n.bindGroupLayoutEntryInfo[a][c.binding].name,d=n.availableTextures[u],h=d.autoBindSampler?n.availableSamplers[u+P.Y.AUTOSAMPLERSUFFIX]:null,p=d.sampleType,m=(e=h?.type)!==null&&e!==void 0?e:"filtering";if(this._textureState&o&&p!=="depth"&&(d.autoBindSampler&&(m="non-filtering"),p="unfilterable-float"),c.texture.sampleType=p,h){var v=n.bindGroupLayoutEntryInfo[h.binding.groupIndex][h.binding.bindingIndex].index;i[h.binding.groupIndex][v].sampler.type=m}o<<=1}}var b=[];for(a=0;a<i.length;++a)b[a]=this._device.createBindGroupLayout({entries:i[a]});return t.bindGroupLayouts[this._textureState]=b,this._device.createPipelineLayout({bindGroupLayouts:b})},r.prototype._getVertexInputDescriptor=function(t){for(var e,n,i,o,a=[],s=t._pipelineContext,l=s.shaderProcessingContext.attributeNamesFromEffect,c=s.shaderProcessingContext.attributeLocationsFromEffect,u=0;u<l.length;u++){var d=c[u],h=(e=this._overrideVertexBuffers&&this._overrideVertexBuffers[l[u]])!==null&&e!==void 0?e:this._vertexBuffers[l[u]];h||(h=this._emptyVertexBuffer);var p=(n=h.effectiveBuffer)===null||n===void 0?void 0:n.underlyingResource,m=h.effectiveByteOffset,v=!h._validOffsetRange;if(!i||!o||i!==p||v){var b={arrayStride:h.effectiveByteStride,stepMode:h.getIsInstanced()?"instance":"vertex",attributes:[]};a.push(b),o=b.attributes,v&&(m=0,p=null)}o.push({shaderLocation:d,offset:m,format:r._GetVertexInputDescriptorFormat(h)}),i=p}return a},r.prototype._createRenderPipeline=function(t,e,n){var i,o,a,s=t._pipelineContext,l=this._getVertexInputDescriptor(t),c=this._createPipelineLayout(s),u=[],d=this._getAphaBlendState(),h=this._getColorBlendState();if(this._vertexBuffers&&qE(this._vertexBuffers,t),this._mrtAttachments1>0)for(var p=0;p<this._mrtFormats.length;++p){var m=this._mrtFormats[p];if(m){var v={format:m,writeMask:this._mrtEnabledMask&1<<p?this._writeMask:0};d&&h&&(v.blend={alpha:d,color:h}),u.push(v)}else u.push(null)}else this._webgpuColorFormat[0]?(v={format:this._webgpuColorFormat[0],writeMask:this._writeMask},d&&h&&(v.blend={alpha:d,color:h}),u.push(v)):u.push(null);var b={compare:r._GetCompareFunction(this._stencilEnabled?this._stencilFrontCompare:7),depthFailOp:r._GetStencilOpFunction(this._stencilEnabled?this._stencilFrontDepthFailOp:1),failOp:r._GetStencilOpFunction(this._stencilEnabled?this._stencilFrontFailOp:1),passOp:r._GetStencilOpFunction(this._stencilEnabled?this._stencilFrontPassOp:1)},E=void 0;e!=="line-strip"&&e!=="triangle-strip"||(E=!this._indexBuffer||this._indexBuffer.is32Bits?"uint32":"uint16");var C=!!this._webgpuDepthStencilFormat&&en.HasStencilAspect(this._webgpuDepthStencilFormat);return this._device.createRenderPipeline({label:"RenderPipeline_".concat((o=(i=u[0])===null||i===void 0?void 0:i.format)!==null&&o!==void 0?o:"nooutput","_").concat((a=this._webgpuDepthStencilFormat)!==null&&a!==void 0?a:"nodepth","_samples").concat(n,"_textureState").concat(this._textureState),layout:c,vertex:{module:s.stages.vertexStage.module,entryPoint:s.stages.vertexStage.entryPoint,buffers:l},primitive:{topology:e,stripIndexFormat:E,frontFace:this._frontFace===1?"ccw":"cw",cullMode:this._cullEnabled?this._cullFace===2?"front":"back":"none"},fragment:s.stages.fragmentStage?{module:s.stages.fragmentStage.module,entryPoint:s.stages.fragmentStage.entryPoint,targets:u}:void 0,multisample:{count:n},depthStencil:this._webgpuDepthStencilFormat===void 0?void 0:{depthWriteEnabled:this._depthWriteEnabled,depthCompare:this._depthTestEnabled?r._GetCompareFunction(this._depthCompare):"always",format:this._webgpuDepthStencilFormat,stencilFront:this._stencilEnabled&&C?b:void 0,stencilBack:this._stencilEnabled&&C?b:void 0,stencilReadMask:this._stencilEnabled&&C?this._stencilReadMask:void 0,stencilWriteMask:this._stencilEnabled&&C?this._stencilWriteMask:void 0,depthBias:this._depthBias,depthBiasClamp:this._depthBiasClamp,depthBiasSlopeScale:this._depthBiasSlopeScale}})},r.NumCacheHitWithoutHash=0,r.NumCacheHitWithHash=0,r.NumCacheMiss=0,r.NumPipelineCreationLastFrame=0,r._NumPipelineCreationCurrentFrame=0,r}(),Ig=function(){function r(){this.values={}}return r.prototype.count=function(){var t=0,e=this.pipeline?1:0;for(var n in this.values){var i=this.values[n].count();t+=i[0],e+=i[1],t++}return[t,e]},r}(),ol=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.GetNodeCounts=function(){var e=t._Cache.count();return{nodeCount:e[0],pipelineCount:e[1]}},t._GetPipelines=function(e,n,i,o){if(e.pipeline){var a=i.slice();a.length=o,n.push(a)}for(var s in e.values){var l=e.values[s];i[o]=parseInt(s),t._GetPipelines(l,n,i,o+1)}},t.GetPipelines=function(){var e=[];return t._GetPipelines(t._Cache,e,[],0),e},t.ResetCache=function(){t._Cache=new Ig},t.prototype.reset=function(){this._nodeStack=[],this._nodeStack[0]=t._Cache,r.prototype.reset.call(this)},t.prototype._getRenderPipeline=function(e){for(var n=this._nodeStack[this._stateDirtyLowestIndex],i=this._stateDirtyLowestIndex;i<this._statesLength;++i){var o=n.values[this._states[i]];o||(o=new Ig,n.values[this._states[i]]=o),n=o,this._nodeStack[i+1]=n}e.token=n,e.pipeline=n.pipeline},t.prototype._setRenderPipeline=function(e){e.token.pipeline=e.pipeline},t._Cache=new Ig,t}(Rg),Mg=L(75781),OD=function(r){function t(e){var n=r.call(this,!1)||this;return n._cache=e,n.reset(),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"func",{get:function(){return this._func},set:function(e){this._func!==e&&(this._func=e,this._cache.setStencilCompare(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"funcMask",{get:function(){return this._funcMask},set:function(e){this._funcMask!==e&&(this._funcMask=e,this._cache.setStencilReadMask(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"opStencilFail",{get:function(){return this._opStencilFail},set:function(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._cache.setStencilFailOp(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"opDepthFail",{get:function(){return this._opDepthFail},set:function(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._cache.setStencilDepthFailOp(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"opStencilDepthPass",{get:function(){return this._opStencilDepthPass},set:function(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._cache.setStencilPassOp(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask!==e&&(this._mask=e,this._cache.setStencilWriteMask(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this._cache.setStencilEnabled(e))},enumerable:!1,configurable:!0}),t.prototype.reset=function(){r.prototype.reset.call(this),this._cache.resetStencilState()},t.prototype.apply=function(){var e,n=(e=this.stencilMaterial)===null||e===void 0?void 0:e.enabled;this.enabled=n?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.enabled&&(this.func=n?this.stencilMaterial.func:this.stencilGlobal.func,this.funcRef=n?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=n?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=n?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=n?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=n?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.mask=n?this.stencilMaterial.mask:this.stencilGlobal.mask)},t}(Mg.u),Og=L(48424),DD=function(r){function t(e){var n=r.call(this,!1)||this;return n._cache=e,n.reset(),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0,this._cache.setDepthBiasSlopeScale(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zOffsetUnits",{get:function(){return this._zOffsetUnits},set:function(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=e,this._isZOffsetDirty=!0,this._cache.setDepthBias(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0,this._cache.setCullFace(e??1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0,this._cache.setCullEnabled(!!e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0,this._cache.setDepthCompare(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0,this._cache.setDepthWriteEnabled(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0,this._cache.setDepthTestEnabled(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frontFace",{get:function(){return this._frontFace},set:function(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0,this._cache.setFrontFace(e??2))},enumerable:!1,configurable:!0}),t.prototype.reset=function(){r.prototype.reset.call(this),this._cache.resetDepthCullingState()},t.prototype.apply=function(){},t}(Og.N),Vd=function(){function r(t){this.useMipMaps=!1,this.type=P.Y.TEXTURETYPE_UNDEFINED,this.format=P.Y.TEXTUREFORMAT_UNDEFINED,this._video=t,this.uniqueId=rn.h._Counter++}return r.IsExternalTexture=function(t){return t.underlyingResource!==void 0},r.prototype.getClassName=function(){return"ExternalTexture"},Object.defineProperty(r.prototype,"underlyingResource",{get:function(){return this._video},enumerable:!1,configurable:!0}),r.prototype.isReady=function(){return this._video.readyState>=this._video.HAVE_CURRENT_DATA},r.prototype.dispose=function(){},r}(),ND=function(){function r(){this.uniqueId=r._Counter++,this.updateId=0,this.textureState=0,this.reset()}return Object.defineProperty(r.prototype,"forceBindGroupCreation",{get:function(){return this._numExternalTextures>0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasFloatOrDepthTextures",{get:function(){return this._numFloatOrDepthTextures>0},enumerable:!1,configurable:!0}),r.prototype.reset=function(){this.samplers={},this.textures={},this.isDirty=!0,this._numFloatOrDepthTextures=0,this._numExternalTextures=0},r.prototype.setSampler=function(t,e){var n=this.samplers[t],i=-1;n?i=n.hashCode:this.samplers[t]=n={sampler:e,hashCode:0},n.sampler=e,n.hashCode=e?wd.GetSamplerHashCode(e):0;var o=i!==n.hashCode;o&&this.updateId++,this.isDirty||(this.isDirty=o)},r.prototype.setTexture=function(t,e){var n,i,o,a=this.textures[t],s=-1;a?s=(i=(n=a.texture)===null||n===void 0?void 0:n.uniqueId)!==null&&i!==void 0?i:-1:this.textures[t]=a={texture:e,isFloatOrDepthTexture:!1,isExternalTexture:!1},a.isExternalTexture&&this._numExternalTextures--,a.isFloatOrDepthTexture&&this._numFloatOrDepthTextures--,e?(a.isFloatOrDepthTexture=e.type===P.Y.TEXTURETYPE_FLOAT||e.format>=P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8&&e.format<=P.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8,a.isExternalTexture=Vd.IsExternalTexture(e),a.isFloatOrDepthTexture&&this._numFloatOrDepthTextures++,a.isExternalTexture&&this._numExternalTextures++):(a.isFloatOrDepthTexture=!1,a.isExternalTexture=!1),a.texture=e;var l=s!==((o=e?.uniqueId)!==null&&o!==void 0?o:-1);l&&this.updateId++,this.isDirty||(this.isDirty=l)},r._Counter=0,r}(),Dg=function(){function r(t){this._bufferManager=t,this.uniqueId=r._Counter++,this._useInstancing=!1,this._currentInstanceCount=0,this.reset()}return r.prototype.isDirty=function(t){return this._isDirty||this._materialContextUpdateId!==t},r.prototype.resetIsDirty=function(t){this._isDirty=!1,this._materialContextUpdateId=t},Object.defineProperty(r.prototype,"useInstancing",{get:function(){return this._useInstancing},set:function(t){this._useInstancing!==t&&(t?(this.indirectDrawBuffer=this._bufferManager.createRawBuffer(20,nn.CopyDst|nn.Indirect|nn.Storage,void 0,"IndirectDrawBuffer"),this._indirectDrawData=new Uint32Array(5),this._indirectDrawData[3]=0,this._indirectDrawData[4]=0):(this.indirectDrawBuffer&&this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this._useInstancing=t,this._currentInstanceCount=-1)},enumerable:!1,configurable:!0}),r.prototype.reset=function(){this.buffers={},this._isDirty=!0,this._materialContextUpdateId=0,this.fastBundle=void 0,this.bindGroups=void 0},r.prototype.setBuffer=function(t,e){var n;this._isDirty||(this._isDirty=e?.uniqueId!==((n=this.buffers[t])===null||n===void 0?void 0:n.uniqueId)),this.buffers[t]=e},r.prototype.setIndirectData=function(t,e,n){e!==this._currentInstanceCount&&this.indirectDrawBuffer&&this._indirectDrawData&&(this._currentInstanceCount=e,this._indirectDrawData[0]=t,this._indirectDrawData[1]=e,this._indirectDrawData[2]=n,this._bufferManager.setRawData(this.indirectDrawBuffer,0,this._indirectDrawData,0,20))},r.prototype.dispose=function(){this.indirectDrawBuffer&&(this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this.fastBundle=void 0,this.bindGroups=void 0,this.buffers=void 0},r._Counter=0,r}(),al=function(){this.values={}},Ud=function(){function r(t,e,n){this.disabled=!1,this._device=t,this._cacheSampler=e,this._engine=n}return Object.defineProperty(r,"Statistics",{get:function(){return{totalCreated:r.NumBindGroupsCreatedTotal,lastFrameCreated:r.NumBindGroupsCreatedLastFrame,lookupLastFrame:r.NumBindGroupsLookupLastFrame,noLookupLastFrame:r.NumBindGroupsNoLookupLastFrame}},enumerable:!1,configurable:!0}),r.ResetCache=function(){r._Cache=new al,r.NumBindGroupsCreatedTotal=0,r.NumBindGroupsCreatedLastFrame=0,r.NumBindGroupsLookupLastFrame=0,r.NumBindGroupsNoLookupLastFrame=0,r._NumBindGroupsCreatedCurrentFrame=0,r._NumBindGroupsLookupCurrentFrame=0,r._NumBindGroupsNoLookupCurrentFrame=0},r.prototype.endFrame=function(){r.NumBindGroupsCreatedLastFrame=r._NumBindGroupsCreatedCurrentFrame,r.NumBindGroupsLookupLastFrame=r._NumBindGroupsLookupCurrentFrame,r.NumBindGroupsNoLookupLastFrame=r._NumBindGroupsNoLookupCurrentFrame,r._NumBindGroupsCreatedCurrentFrame=0,r._NumBindGroupsLookupCurrentFrame=0,r._NumBindGroupsNoLookupCurrentFrame=0},r.prototype.getBindGroups=function(t,e,n){var i,o,a,s,l,c,u,d,h,p,m=void 0,v=r._Cache,b=this.disabled||n.forceBindGroupCreation;if(!b){if(!e.isDirty(n.updateId)&&!n.isDirty)return r._NumBindGroupsNoLookupCurrentFrame++,e.bindGroups;for(var E=0,C=t.shaderProcessingContext.bufferNames;E<C.length;E++){var T=C[E],f=(o=(i=e.buffers[T])===null||i===void 0?void 0:i.uniqueId)!==null&&o!==void 0?o:0;(M=v.values[f])||(M=new al,v.values[f]=M),v=M}for(var g=0,S=t.shaderProcessingContext.samplerNames;g<S.length;g++){var y=S[g],x=(s=(a=n.samplers[y])===null||a===void 0?void 0:a.hashCode)!==null&&s!==void 0?s:0;(M=v.values[x])||(M=new al,v.values[x]=M),v=M}for(var R=0,I=t.shaderProcessingContext.textureNames;R<I.length;R++){var M,D=I[R],B=(u=(c=(l=n.textures[D])===null||l===void 0?void 0:l.texture)===null||c===void 0?void 0:c.uniqueId)!==null&&u!==void 0?u:0;(M=v.values[B])||(M=new al,v.values[B]=M),v=M}m=v.bindGroups}if(e.resetIsDirty(n.updateId),n.isDirty=!1,m)return e.bindGroups=m,r._NumBindGroupsLookupCurrentFrame++,m;m=[],e.bindGroups=m,b||(v.bindGroups=m),r.NumBindGroupsCreatedTotal++,r._NumBindGroupsCreatedCurrentFrame++;for(var F=t.bindGroupLayouts[n.textureState],X=0;X<t.shaderProcessingContext.bindGroupLayoutEntries.length;X++){for(var $=t.shaderProcessingContext.bindGroupLayoutEntries[X],Q=t.shaderProcessingContext.bindGroupEntries[X],ie=0;ie<$.length;ie++){var q=t.shaderProcessingContext.bindGroupLayoutEntries[X][ie],ee=t.shaderProcessingContext.bindGroupLayoutEntryInfo[X][q.binding],te=(d=ee.nameInArrayOfTexture)!==null&&d!==void 0?d:ee.name;if(q.sampler)if(de=n.samplers[te]){var ce=de.sampler;if(!ce){this._engine.dbgSanityChecks&&O.V.Error("Trying to bind a null sampler! entry=".concat(JSON.stringify(q),", name=").concat(te,", bindingInfo=").concat(JSON.stringify(de,function(w,k){return w==="texture"?"<no dump>":k}),", materialContext.uniqueId=").concat(n.uniqueId),50);continue}Q[ie].resource=this._cacheSampler.getSampler(ce,!1,de.hashCode,ce.label)}else O.V.Error('Sampler "'.concat(te,'" could not be bound. entry=').concat(JSON.stringify(q),", materialContext=").concat(JSON.stringify(n,function(w,k){return w==="texture"||w==="sampler"?"<no dump>":k})),50);else if(q.texture||q.storageTexture)if(de=n.textures[te]){if(this._engine.dbgSanityChecks&&de.texture===null){O.V.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(q),", bindingInfo=").concat(JSON.stringify(de,function(w,k){return w==="texture"?"<no dump>":k}),", materialContext.uniqueId=").concat(n.uniqueId),50);continue}var fe=de.texture._hardwareTexture;if(this._engine.dbgSanityChecks&&(!fe||q.texture&&!fe.view||q.storageTexture&&!fe.viewForWriting)){O.V.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(q),", name=").concat(te,", bindingInfo=").concat(JSON.stringify(de,function(w,k){return w==="texture"?"<no dump>":k}),", isReady=").concat((h=de.texture)===null||h===void 0?void 0:h.isReady,", materialContext.uniqueId=").concat(n.uniqueId),50);continue}Q[ie].resource=q.storageTexture?fe.viewForWriting:fe.view}else O.V.Error('Texture "'.concat(te,'" could not be bound. entry=').concat(JSON.stringify(q),", materialContext=").concat(JSON.stringify(n,function(w,k){return w==="texture"||w==="sampler"?"<no dump>":k})),50);else if(q.externalTexture){var de;if(de=n.textures[te]){if(this._engine.dbgSanityChecks&&de.texture===null){O.V.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(q),", name=").concat(te,", bindingInfo=").concat(JSON.stringify(de,function(w,k){return w==="texture"?"<no dump>":k}),", materialContext.uniqueId=").concat(n.uniqueId),50);continue}var Te=de.texture.underlyingResource;if(this._engine.dbgSanityChecks&&!Te){O.V.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(q),", name=").concat(te,", bindingInfo=").concat(JSON.stringify(de,function(w,k){return w==="texture"?"<no dump>":k}),", isReady=").concat((p=de.texture)===null||p===void 0?void 0:p.isReady,", materialContext.uniqueId=").concat(n.uniqueId),50);continue}Q[ie].resource=this._device.importExternalTexture({source:Te})}else O.V.Error('Texture "'.concat(te,'" could not be bound. entry=').concat(JSON.stringify(q),", materialContext=").concat(JSON.stringify(n,function(w,k){return w==="texture"||w==="sampler"?"<no dump>":k})),50)}else if(q.buffer){var ue=e.buffers[te];if(ue){var U=ue.underlyingResource;Q[ie].resource.buffer=U,Q[ie].resource.size=ue.capacity}else O.V.Error(`Can't find buffer "`.concat(te,'". entry=').concat(JSON.stringify(q),", buffers=").concat(JSON.stringify(e.buffers),", drawContext.uniqueId=").concat(e.uniqueId),50)}}var N=F[X];m[X]=this._device.createBindGroup({layout:N,entries:Q})}return m},r.NumBindGroupsCreatedTotal=0,r.NumBindGroupsCreatedLastFrame=0,r.NumBindGroupsLookupLastFrame=0,r.NumBindGroupsNoLookupLastFrame=0,r._Cache=new al,r._NumBindGroupsCreatedCurrentFrame=0,r._NumBindGroupsLookupCurrentFrame=0,r._NumBindGroupsNoLookupCurrentFrame=0,r}();Gt.l.ShadersStoreWGSL.clearQuadVertexShader=`uniform depthValue: f32;const pos=array(
|
||
vec2f(-1.0,1.0),
|
||
vec2f(1.0,1.0),
|
||
vec2f(-1.0,-1.0),
|
||
vec2f(1.0,-1.0)
|
||
);
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
@vertex
|
||
fn main(input : VertexInputs)->FragmentInputs {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vertexOutputs.position=vec4f(pos[input.vertexIndex],uniforms.depthValue,1.0);
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}
|
||
`,Gt.l.ShadersStoreWGSL.clearQuadPixelShader=`uniform color: vec4f;@fragment
|
||
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=uniforms.color;}
|
||
`;var LD=function(){function r(t,e,n){this._bindGroups={},this._bundleCache={},this._keyTemp=[],this._device=t,this._engine=e,this._cacheRenderPipeline=new ol(this._device,n),this._cacheRenderPipeline.setDepthTestEnabled(!1),this._cacheRenderPipeline.setStencilReadMask(255),this._effect=e.createEffect("clearQuad",[],["color","depthValue"],void 0,void 0,void 0,void 0,void 0,void 0,1)}return r.prototype.setDepthStencilFormat=function(t){this._depthTextureFormat=t,this._cacheRenderPipeline.setDepthStencilFormat(t)},r.prototype.setColorFormat=function(t){this._cacheRenderPipeline.setColorFormat(t)},r.prototype.setMRTAttachments=function(t,e,n){this._cacheRenderPipeline.setMRT(e,n),this._cacheRenderPipeline.setMRTAttachments(t)},r.prototype.clear=function(t,e,n,i,o){var a,s,l;o===void 0&&(o=1);var c,u=null,d=!!this._engine._currentRenderTarget;if(t)l=t;else{var h=0;this._keyTemp.length=0;for(var p=0;p<this._cacheRenderPipeline.colorFormats.length;++p)this._keyTemp[h++]=ao[(a=this._cacheRenderPipeline.colorFormats[p])!==null&&a!==void 0?a:""];var m=ao[(s=this._depthTextureFormat)!==null&&s!==void 0?s:0];if(this._keyTemp[h]=(e?e.r+256*e.g+256*e.b*256+256*e.a*256*256:0)+(n?Math.pow(2,32):0)+(i?Math.pow(2,33):0)+(this._engine.useReverseDepthBuffer?Math.pow(2,34):0)+(d?Math.pow(2,35):0)+(o>1?Math.pow(2,36):0)+m*Math.pow(2,37),c=this._keyTemp.join("_"),u=this._bundleCache[c])return u;l=this._device.createRenderBundleEncoder({label:"clearQuadRenderBundle",colorFormats:this._cacheRenderPipeline.colorFormats,depthStencilFormat:this._depthTextureFormat,sampleCount:en.GetSample(o)})}this._cacheRenderPipeline.setDepthWriteEnabled(!!n),this._cacheRenderPipeline.setStencilEnabled(!!i&&!!this._depthTextureFormat&&en.HasStencilAspect(this._depthTextureFormat)),this._cacheRenderPipeline.setStencilWriteMask(i?255:0),this._cacheRenderPipeline.setStencilCompare(i?P.Y.ALWAYS:P.Y.NEVER),this._cacheRenderPipeline.setStencilPassOp(i?P.Y.REPLACE:P.Y.KEEP),this._cacheRenderPipeline.setWriteMask(e?15:0);var v=this._cacheRenderPipeline.getRenderPipeline(P.Y.MATERIAL_TriangleStripDrawMode,this._effect,o),b=this._effect._pipelineContext;e&&this._effect.setDirectColor4("color",e),this._effect.setFloat("depthValue",this._engine.useReverseDepthBuffer?this._engine._clearReverseDepthValue:this._engine._clearDepthValue),b.uniformBuffer.update();var E=d?this._engine._ubInvertY:this._engine._ubDontInvertY,C=b.uniformBuffer.getBuffer(),T=C.uniqueId+"-"+E.uniqueId,f=this._bindGroups[T];if(!f){var g=b.bindGroupLayouts[0];(f=this._bindGroups[T]=[]).push(this._device.createBindGroup({label:"clearQuadBindGroup0-".concat(T),layout:g[0],entries:[]})),za._SimplifiedKnownBindings||f.push(this._device.createBindGroup({label:"clearQuadBindGroup1-".concat(T),layout:g[1],entries:[]})),f.push(this._device.createBindGroup({label:"clearQuadBindGroup".concat(za._SimplifiedKnownBindings?1:2,"-").concat(T),layout:g[za._SimplifiedKnownBindings?1:2],entries:[{binding:0,resource:{buffer:E.underlyingResource,size:E.capacity}},{binding:1,resource:{buffer:C.underlyingResource,size:C.capacity}}]}))}for(l.setPipeline(v),p=0;p<f.length;++p)l.setBindGroup(p,f[p]);return l.draw(4,1,0,0),t||(u=l.finish(),this._bundleCache[c]=u),u},r}(),FD=function(){function r(t,e,n,i){this.x=Math.floor(t),this.y=Math.floor(e),this.w=Math.floor(n),this.h=Math.floor(i)}return r.prototype.run=function(t){t.setViewport(this.x,this.y,this.w,this.h,0,1)},r.prototype.clone=function(){return new r(this.x,this.y,this.w,this.h)},r}(),wD=function(){function r(t,e,n,i){this.x=t,this.y=e,this.w=n,this.h=i}return r.prototype.run=function(t){t.setScissorRect(this.x,this.y,this.w,this.h)},r.prototype.clone=function(){return new r(this.x,this.y,this.w,this.h)},r}(),tx=function(){function r(t){this.ref=t}return r.prototype.run=function(t){t.setStencilReference(this.ref)},r.prototype.clone=function(){return new r(this.ref)},r}(),BD=function(){function r(t){this.color=t}return r.prototype.run=function(t){t.setBlendConstant(this.color)},r.prototype.clone=function(){return new r(this.color)},r}(),VD=function(){function r(t){this.query=t}return r.prototype.run=function(t){t.beginOcclusionQuery(this.query)},r.prototype.clone=function(){return new r(this.query)},r}(),UD=function(){function r(){}return r.prototype.run=function(t){t.endOcclusionQuery()},r.prototype.clone=function(){return new r},r}(),GD=function(){function r(){this.bundles=[]}return r.prototype.run=function(t){t.executeBundles(this.bundles)},r.prototype.clone=function(){var t=new r;return t.bundles=this.bundles,t},r}(),kD=function(){function r(t){this.numDrawCalls=0,this._device=t,this._list=new Array(10),this._listLength=0}return r.prototype.addBundle=function(t){if(!this._currentItemIsBundle){var e=new GD;this._list[this._listLength++]=e,this._currentBundleList=e.bundles,this._currentItemIsBundle=!0}t&&this._currentBundleList.push(t)},r.prototype._finishBundle=function(){this._currentItemIsBundle&&this._bundleEncoder&&(this._currentBundleList.push(this._bundleEncoder.finish()),this._bundleEncoder=void 0,this._currentItemIsBundle=!1)},r.prototype.addItem=function(t){this._finishBundle(),this._list[this._listLength++]=t,this._currentItemIsBundle=!1},r.prototype.getBundleEncoder=function(t,e,n){return this._currentItemIsBundle||(this.addBundle(),this._bundleEncoder=this._device.createRenderBundleEncoder({colorFormats:t,depthStencilFormat:e,sampleCount:en.GetSample(n)})),this._bundleEncoder},r.prototype.close=function(){this._finishBundle()},r.prototype.run=function(t){this.close();for(var e=0;e<this._listLength;++e)this._list[e].run(t)},r.prototype.reset=function(){this._listLength=0,this._currentItemIsBundle=!1,this.numDrawCalls=0},r.prototype.clone=function(){this.close();var t=new r(this._device);t._list=new Array(this._listLength),t._listLength=this._listLength,t.numDrawCalls=this.numDrawCalls;for(var e=0;e<this._listLength;++e)t._list[e]=this._list[e].clone();return t},r}(),nx=function(){function r(t,e,n,i,o,a,s){a===void 0&&(a=!0),this._dstBuffers=[],this._engine=t,this._device=i,this._bufferManager=o,this._count=e,this._canUseMultipleBuffers=a,this._querySet=i.createQuerySet({label:s??"QuerySet",type:n,count:e}),this._queryBuffer=o.createRawBuffer(8*e,nn.QueryResolve|nn.CopySrc,void 0,"QueryBuffer"),a||this._dstBuffers.push(this._bufferManager.createRawBuffer(8*this._count,nn.MapRead|nn.CopyDst,void 0,"QueryBufferNoMultipleBuffers"))}return Object.defineProperty(r.prototype,"querySet",{get:function(){return this._querySet},enumerable:!1,configurable:!0}),r.prototype._getBuffer=function(t,e){if(!this._canUseMultipleBuffers&&this._dstBuffers.length===0)return null;var n,i=this._device.createCommandEncoder();return this._dstBuffers.length===0?n=this._bufferManager.createRawBuffer(8*this._count,nn.MapRead|nn.CopyDst,void 0,"QueryBufferAdditionalBuffer"):(n=this._dstBuffers[this._dstBuffers.length-1],this._dstBuffers.length--),i.resolveQuerySet(this._querySet,t,e,this._queryBuffer,0),i.copyBufferToBuffer(this._queryBuffer,0,n,0,8*e),this._device.queue.submit([i.finish()]),n},r.prototype.readValues=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=1),(0,A.sH)(this,void 0,void 0,function(){var n,i,o=this;return(0,A.YH)(this,function(a){return(n=this._getBuffer(t,e))===null?[2,null]:(i=this._engine.uniqueId,[2,n.mapAsync(1).then(function(){var s=new BigUint64Array(n.getMappedRange()).slice();return n.unmap(),o._dstBuffers[o._dstBuffers.length]=n,s},function(s){if(o._engine.isDisposed||o._engine.uniqueId!==i)return null;throw s})])})})},r.prototype.readValue=function(t){return t===void 0&&(t=0),(0,A.sH)(this,void 0,void 0,function(){var e,n,i=this;return(0,A.YH)(this,function(o){return(e=this._getBuffer(t,1))===null?[2,null]:(n=this._engine.uniqueId,[2,e.mapAsync(1).then(function(){var a=new BigUint64Array(e.getMappedRange()),s=Number(a[0]);return e.unmap(),i._dstBuffers[i._dstBuffers.length]=e,s},function(a){if(i._engine.isDisposed||i._engine.uniqueId!==n)return 0;throw a})])})})},r.prototype.readTwoValuesAndSubtract=function(t){return t===void 0&&(t=0),(0,A.sH)(this,void 0,void 0,function(){var e,n,i=this;return(0,A.YH)(this,function(o){return(e=this._getBuffer(t,2))===null?[2,null]:(n=this._engine.uniqueId,[2,e.mapAsync(1).then(function(){var a=new BigUint64Array(e.getMappedRange()),s=Number(a[1]-a[0]);return e.unmap(),i._dstBuffers[i._dstBuffers.length]=e,s},function(a){if(i._engine.isDisposed||i._engine.uniqueId!==n)return 0;throw a})])})})},r.prototype.dispose=function(){this._querySet.destroy(),this._bufferManager.releaseBuffer(this._queryBuffer);for(var t=0;t<this._dstBuffers.length;++t)this._bufferManager.releaseBuffer(this._dstBuffers[t])},r}(),zD=function(){function r(t,e,n){this._enabled=!1,this._gpuFrameTimeCounter=new Mi.A,this._measureDurationState=0,this._engine=t,this._device=e,this._bufferManager=n}return Object.defineProperty(r.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTimeCounter},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enable",{get:function(){return this._enabled},set:function(t){if(this._enabled!==t)if(this._enabled=t,this._measureDurationState=0,t)try{this._measureDuration=new WD(this._engine,this._device,this._bufferManager,2e3,"QuerySet_TimestampQuery")}catch(e){return this._enabled=!1,void O.V.Error(`Could not create a WebGPUDurationMeasure!
|
||
Error: `+e.message+`
|
||
Make sure timestamp query is supported and enabled in your browser.`)}else this._measureDuration.dispose()},enumerable:!1,configurable:!0}),r.prototype.startFrame=function(t){this._enabled&&this._measureDurationState===0&&(this._measureDuration.start(t),this._measureDurationState=1)},r.prototype.endFrame=function(t){var e=this;this._measureDurationState===1&&(this._measureDurationState=2,this._measureDuration.stop(t).then(function(n){n!==null&&n>=0&&(e._gpuFrameTimeCounter.fetchNewFrame(),e._gpuFrameTimeCounter.addCount(n,!0)),e._measureDurationState=0}))},r.prototype.startPass=function(t,e){this._enabled?this._measureDuration.startPass(t,e):t.timestampWrites=void 0},r.prototype.endPass=function(t,e){if(this._enabled&&e){var n=this._engine.frameId;this._measureDuration.stopPass(t).then(function(i){e._addDuration(n,i!==null&&i>0?i:0)})}},r.prototype.dispose=function(){var t;(t=this._measureDuration)===null||t===void 0||t.dispose()},r}(),WD=function(){function r(t,e,n,i,o){i===void 0&&(i=2),this._count=i,this._querySet=new nx(t,i,"timestamp",e,n,!0,o)}return r.prototype.start=function(t){var e;(e=t.writeTimestamp)===null||e===void 0||e.call(t,this._querySet.querySet,0)},r.prototype.stop=function(t){var e;return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){return(e=t.writeTimestamp)===null||e===void 0||e.call(t,this._querySet.querySet,1),[2,t.writeTimestamp?this._querySet.readTwoValuesAndSubtract(0):0]})})},r.prototype.startPass=function(t,e){if(e+3>this._count)throw new Error("WebGPUDurationMeasure: index out of range ("+e+")");t.timestampWrites={querySet:this._querySet.querySet,beginningOfPassWriteIndex:e+2,endOfPassWriteIndex:e+3}},r.prototype.stopPass=function(t){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){return[2,this._querySet.readTwoValuesAndSubtract(t+2)]})})},r.prototype.dispose=function(){this._querySet.dispose()},r}(),HD=function(){function r(t,e,n,i,o){i===void 0&&(i=50),o===void 0&&(o=100),this._availableIndices=[],this._frameQuerySetIsDirty=-1,this._queryFrameId=[],this._engine=t,this._device=e,this._bufferManager=n,this._frameLastBuffer=-1,this._currentTotalIndices=0,this._countIncrement=o,this._allocateNewIndices(i)}return Object.defineProperty(r.prototype,"querySet",{get:function(){return this._querySet.querySet},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasQueries",{get:function(){return this._currentTotalIndices!==this._availableIndices.length},enumerable:!1,configurable:!0}),r.prototype.canBeginQuery=function(t){if(this._frameQuerySetIsDirty===this._engine.frameId||this._queryFrameId[t]===this._engine.frameId)return!1;var e=this._engine._getCurrentRenderPassWrapper().renderPassDescriptor.occlusionQuerySet!==void 0;return e&&(this._queryFrameId[t]=this._engine.frameId),e},r.prototype.createQuery=function(){this._availableIndices.length===0&&this._allocateNewIndices();var t=this._availableIndices[this._availableIndices.length-1];return this._availableIndices.length--,t},r.prototype.deleteQuery=function(t){this._availableIndices[this._availableIndices.length]=t},r.prototype.isQueryResultAvailable=function(t){return this._retrieveQueryBuffer(),!!this._lastBuffer&&t<this._lastBuffer.length},r.prototype.getQueryResult=function(t){var e,n;return Number((n=(e=this._lastBuffer)===null||e===void 0?void 0:e[t])!==null&&n!==void 0?n:-1)},r.prototype._retrieveQueryBuffer=function(){var t=this;this._lastBuffer&&this._frameLastBuffer===this._engine.frameId||this._frameLastBuffer!==this._engine.frameId&&(this._frameLastBuffer=this._engine.frameId,this._querySet.readValues(0,this._currentTotalIndices).then(function(e){t._lastBuffer=e}))},r.prototype._allocateNewIndices=function(t){t=t??this._countIncrement,this._delayQuerySetDispose();for(var e=0;e<t;++e)this._availableIndices.push(this._currentTotalIndices+e);this._currentTotalIndices+=t,this._querySet=new nx(this._engine,this._currentTotalIndices,"occlusion",this._device,this._bufferManager,!1,"QuerySet_OcclusionQuery_count_"+this._currentTotalIndices),this._frameQuerySetIsDirty=this._engine.frameId},r.prototype._delayQuerySetDispose=function(){var t=this._querySet;t&&setTimeout(function(){return t.dispose},1e3)},r.prototype.dispose=function(){var t;(t=this._querySet)===null||t===void 0||t.dispose(),this._availableIndices.length=0},r}(),Ng=function(){function r(){}return r.prototype.initTwgsl=function(t){return(0,A.sH)(this,void 0,void 0,function(){var e;return(0,A.YH)(this,function(n){switch(n.label){case 0:return r._Twgsl?[2]:(t=t||{},(t=(0,A.Cl)((0,A.Cl)({},r._TWgslDefaultOptions),t)).twgsl?(r._Twgsl=t.twgsl,[2,Promise.resolve()]):t.jsPath&&t.wasmPath?[4,ze.S0.LoadBabylonScriptAsync(t.jsPath)]:[3,2]);case 1:n.sent(),n.label=2;case 2:return self.twgsl?(e=r,[4,self.twgsl(ze.S0.GetBabylonScriptURL(t.wasmPath))]):[3,4];case 3:return e._Twgsl=n.sent(),[2,Promise.resolve()];case 4:return[2,Promise.reject("twgsl is not available.")]}})})},r.prototype.convertSpirV2WGSL=function(t,e){e===void 0&&(e=!1);var n=r._Twgsl.convertSpirV2WGSL(t,r.DisableUniformityAnalysis||e);return r.ShowWGSLShaderCode&&(O.V.Log(n),O.V.Log("***********************************************")),r.DisableUniformityAnalysis||e?`diagnostic(off, derivative_uniformity);
|
||
`+n:n},r._TWgslDefaultOptions={jsPath:"".concat(ze.S0._DefaultCdnUrl,"/twgsl/twgsl.js"),wasmPath:"".concat(ze.S0._DefaultCdnUrl,"/twgsl/twgsl.wasm")},r.ShowWGSLShaderCode=!1,r.DisableUniformityAnalysis=!1,r._Twgsl=null,r}(),YD=function(){function r(t,e,n){this._record=!1,this._play=!1,this._playBundleListIndex=0,this._allBundleLists=[],this._enabled=!1,this._engine=t,this._mode=e,this._bundleList=n}return Object.defineProperty(r.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this._allBundleLists.length=0,this._record=this._enabled=t,this._play=!1,t&&(this._modeSaved=this._mode,this._mode=P.Y.SNAPSHOTRENDERING_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"play",{get:function(){return this._play},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"record",{get:function(){return this._record},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mode",{get:function(){return this._mode},set:function(t){this._record?this._modeSaved=t:this._mode=t},enumerable:!1,configurable:!0}),r.prototype.endRenderPass=function(t){if(!this._record&&!this._play)return!1;var e;if(this._record)e=this._bundleList.clone(),this._allBundleLists.push(e),this._bundleList.reset();else{if(this._playBundleListIndex>=this._allBundleLists.length)throw new Error("Invalid playBundleListIndex! Your snapshot is no longer valid for the current frame, you should recreate a new one. playBundleListIndex=".concat(this._playBundleListIndex,", allBundleLists.length=").concat(this._allBundleLists.length,"}"));e=this._allBundleLists[this._playBundleListIndex++]}return e.run(t),this._mode===P.Y.SNAPSHOTRENDERING_FAST&&this._engine._reportDrawCall(e.numDrawCalls),!0},r.prototype.endFrame=function(){this._record&&(this._record=!1,this._play=!0,this._mode=this._modeSaved),this._playBundleListIndex=0},r.prototype.reset=function(){this.enabled=!1,this.enabled=!0},r}(),ix=L(37411),XD=L(76320),jD=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t}(Vd),rx={label:"TextureView_SwapChain_ResolveTarget",dimension:"2d",format:void 0,mipLevelCount:1,arrayLayerCount:1},ox={label:"TextureView_SwapChain",dimension:"2d",format:void 0,mipLevelCount:1,arrayLayerCount:1},qD=new Ge.ov,It=function(r){function t(e,n){n===void 0&&(n={});var i,o,a=this;return(a=r.call(this,(i=n.antialias)===null||i===void 0||i,n)||this).uniqueId=-1,a._uploadEncoderDescriptor={label:"upload"},a._renderEncoderDescriptor={label:"render"},a._clearDepthValue=1,a._clearReverseDepthValue=0,a._clearStencilValue=0,a._defaultSampleCount=4,a._glslang=null,a._tintWASM=null,a._glslangAndTintAreFullyLoaded=!1,a._adapterInfo={vendor:"",architecture:"",device:"",description:""},a._timestampIndex=0,a._compiledComputeEffects={},a._counters={numEnableEffects:0,numEnableDrawWrapper:0,numBundleCreationNonCompatMode:0,numBundleReuseNonCompatMode:0},a.countersLastFrame={numEnableEffects:0,numEnableDrawWrapper:0,numBundleCreationNonCompatMode:0,numBundleReuseNonCompatMode:0},a.numMaxUncapturedErrors=20,a.scenes=[],a._virtualScenes=new Array,a._commandBuffers=[null,null],a._currentRenderPass=null,a._mainRenderPassWrapper={renderPassDescriptor:null,colorAttachmentViewDescriptor:null,depthAttachmentViewDescriptor:null,colorAttachmentGPUTextures:[],depthTextureFormat:void 0},a._rttRenderPassWrapper={renderPassDescriptor:null,colorAttachmentViewDescriptor:null,depthAttachmentViewDescriptor:null,colorAttachmentGPUTextures:[],depthTextureFormat:void 0},a._pendingDebugCommands=[],a._currentOverrideVertexBuffers=null,a._currentIndexBuffer=null,a._colorWriteLocal=!0,a._forceEnableEffect=!1,a.dbgShowShaderCode=!1,a.dbgSanityChecks=!0,a.dbgVerboseLogsForFirstFrames=!1,a.dbgVerboseLogsNumFrames=10,a.dbgLogIfNotDrawWrapper=!0,a.dbgShowEmptyEnableEffectCalls=!0,a._snapshotRenderingMode=P.Y.SNAPSHOTRENDERING_STANDARD,a.isNDCHalfZRange=!0,a.hasOriginBottomLeft=!1,a._workingGlslangAndTintPromise=null,a._viewportsCurrent={x:0,y:0,w:0,h:0},a._scissorsCurrent={x:0,y:0,w:0,h:0},a._scissorCached={x:0,y:0,z:0,w:0},a._stencilRefsCurrent=-1,a._blendColorsCurrent=[null,null,null,null],a._performanceMonitor=new lu,a._name="WebGPU",a._drawCalls=new Mi.A,n.deviceDescriptor=n.deviceDescriptor||{},n.enableGPUDebugMarkers=(o=n.enableGPUDebugMarkers)!==null&&o!==void 0&&o,O.V.Log("Babylon.js v".concat(Be.$.Version," - ").concat(a.description," engine")),navigator.gpu?(n.swapChainFormat=n.swapChainFormat||navigator.gpu.getPreferredCanvasFormat(),a._isWebGPU=!0,a._shaderPlatformName="WEBGPU",a._renderingCanvas=e,a._options=n,a._mainPassSampleCount=n.antialias?a._defaultSampleCount:1,navigator&&navigator.userAgent&&a._setupMobileChecks(),a._sharedInit(a._renderingCanvas),a._shaderProcessor=new TD,a._shaderProcessorWGSL=new xD,a):(O.V.Error("WebGPU is not supported by your browser."),a)}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"snapshotRenderingMode",{get:function(){return this._snapshotRendering.mode},set:function(e){this._snapshotRendering.mode=e},enumerable:!1,configurable:!0}),t.prototype.snapshotRenderingReset=function(){this._snapshotRendering.reset()},Object.defineProperty(t.prototype,"snapshotRendering",{get:function(){return this._snapshotRendering.enabled},set:function(e){this._snapshotRendering.enabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableCacheSamplers",{get:function(){return!!this._cacheSampler&&this._cacheSampler.disabled},set:function(e){this._cacheSampler&&(this._cacheSampler.disabled=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableCacheRenderPipelines",{get:function(){return!!this._cacheRenderPipeline&&this._cacheRenderPipeline.disabled},set:function(e){this._cacheRenderPipeline&&(this._cacheRenderPipeline.disabled=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableCacheBindGroups",{get:function(){return!!this._cacheBindGroups&&this._cacheBindGroups.disabled},set:function(e){this._cacheBindGroups&&(this._cacheBindGroups.disabled=e)},enumerable:!1,configurable:!0}),t.prototype.areAllEffectsReady=function(){return!0},t.prototype.getFontOffset=function(e){return hu(e)},Object.defineProperty(t,"IsSupportedAsync",{get:function(){return navigator.gpu?navigator.gpu.requestAdapter().then(function(e){return!!e},function(){return!1}).catch(function(){return!1}):Promise.resolve(!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){return O.V.Warn("You must call IsSupportedAsync for WebGPU!"),!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportsUniformBuffers",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportedExtensions",{get:function(){return this._adapterSupportedExtensions},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enabledExtensions",{get:function(){return this._deviceEnabledExtensions},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supportedLimits",{get:function(){return this._adapterSupportedLimits},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentLimits",{get:function(){return this._deviceLimits},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"description",{get:function(){return this.name+this.version},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return 1},enumerable:!1,configurable:!0}),t.prototype.getInfo=function(){return{vendor:this._adapterInfo.vendor||"unknown vendor",renderer:this._adapterInfo.architecture||"unknown renderer",version:this._adapterInfo.description||"unknown version"}},Object.defineProperty(t.prototype,"compatibilityMode",{get:function(){return this._compatibilityMode},set:function(e){this._compatibilityMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableGPUTimingMeasurements",{get:function(){return this._timestampQuery.enable},set:function(e){this._timestampQuery.enable!==e&&(this.gpuTimeInFrameForMainPass=e?new ix.e:void 0,this._timestampQuery.enable=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentSampleCount",{get:function(){return this._currentRenderTarget?this._currentRenderTarget.samples:this._mainPassSampleCount},enumerable:!1,configurable:!0}),t.CreateAsync=function(e,n){n===void 0&&(n={});var i=new t(e,n);return new Promise(function(o){i.initAsync(n.glslangOptions,n.twgslOptions).then(function(){return o(i)})})},t.prototype.prepareGlslangAndTintAsync=function(){var e=this;return this._workingGlslangAndTintPromise||(this._workingGlslangAndTintPromise=new Promise(function(n){var i,o;e._initGlslang((i=e._glslangOptions)!==null&&i!==void 0?i:(o=e._options)===null||o===void 0?void 0:o.glslangOptions).then(function(a){var s,l;e._glslang=a,e._tintWASM=new Ng,e._tintWASM.initTwgsl((s=e._twgslOptions)!==null&&s!==void 0?s:(l=e._options)===null||l===void 0?void 0:l.twgslOptions).then(function(){e._glslangAndTintAreFullyLoaded=!0,n()})})})),this._workingGlslangAndTintPromise},t.prototype.initAsync=function(e,n){var i=this;return this.uniqueId=t._InstanceId++,this._glslangOptions=e,this._twgslOptions=n,navigator.gpu.requestAdapter(this._options).then(function(o){var a,s,l;if(o){i._adapter=o,i._adapterSupportedExtensions=[],(a=i._adapter.features)===null||a===void 0||a.forEach(function(b){return i._adapterSupportedExtensions.push(b)}),i._adapterSupportedLimits=i._adapter.limits,i._adapter.requestAdapterInfo().then(function(b){i._adapterInfo=b});var c=(s=i._options.deviceDescriptor)!==null&&s!==void 0?s:{},u=(l=c?.requiredFeatures)!==null&&l!==void 0?l:i._options.enableAllFeatures?i._adapterSupportedExtensions:void 0;if(u){for(var d=[],h=0,p=u;h<p.length;h++){var m=p[h];i._adapterSupportedExtensions.indexOf(m)!==-1&&d.push(m)}c.requiredFeatures=d}if(i._options.setMaximumLimits&&!c.requiredLimits)for(var v in c.requiredLimits={},i._adapterSupportedLimits)v!=="minSubgroupSize"&&v!=="maxSubgroupSize"&&(c.requiredLimits[v]=i._adapterSupportedLimits[v]);return c.label="BabylonWebGPUDevice".concat(i.uniqueId),i._adapter.requestDevice(c)}throw"Could not retrieve a WebGPU adapter (adapter is null)."}).then(function(o){var a,s;i._device=o,i._deviceEnabledExtensions=[],(a=i._device.features)===null||a===void 0||a.forEach(function(c){return i._deviceEnabledExtensions.push(c)}),i._deviceLimits=o.limits;var l=-1;i._device.addEventListener("uncapturederror",function(c){++l<i.numMaxUncapturedErrors?O.V.Warn("WebGPU uncaptured error (".concat(l+1,"): ").concat(c.error," - ").concat(c.error.message)):l++===i.numMaxUncapturedErrors&&O.V.Warn("WebGPU uncaptured error: too many warnings (".concat(i.numMaxUncapturedErrors,"), no more warnings will be reported to the console for this engine."))}),i._doNotHandleContextLost||(s=i._device.lost)===null||s===void 0||s.then(function(c){i._isDisposed||(i._contextWasLost=!0,O.V.Warn("WebGPU context lost. "+c),i.onContextLostObservable.notifyObservers(i),i._restoreEngineAfterContextLost(function(){return(0,A.sH)(i,void 0,void 0,function(){var u,d,h,p,m,v,b,E,C,T;return(0,A.YH)(this,function(f){switch(f.label){case 0:return u=this.snapshotRenderingMode,d=this.snapshotRendering,h=this.disableCacheSamplers,p=this.disableCacheRenderPipelines,m=this.disableCacheBindGroups,v=this.enableGPUTimingMeasurements,[4,this.initAsync((b=this._glslangOptions)!==null&&b!==void 0?b:(E=this._options)===null||E===void 0?void 0:E.glslangOptions,(C=this._twgslOptions)!==null&&C!==void 0?C:(T=this._options)===null||T===void 0?void 0:T.twgslOptions)];case 1:return f.sent(),this.snapshotRenderingMode=u,this.snapshotRendering=d,this.disableCacheSamplers=h,this.disableCacheRenderPipelines=p,this.disableCacheBindGroups=m,this.enableGPUTimingMeasurements=v,this._currentRenderPass=null,[2]}})})}))})}).then(function(){i._initializeLimits(),i._bufferManager=new CD(i,i._device),i._textureHelper=new AD(i,i._device,i._bufferManager,i._deviceEnabledExtensions),i._cacheSampler=new wd(i._device),i._cacheBindGroups=new Ud(i._device,i._cacheSampler,i),i._timestampQuery=new zD(i,i._device,i._bufferManager),i._occlusionQuery=i._device.createQuerySet?new HD(i,i._device,i._bufferManager):void 0,i._bundleList=new kD(i._device),i._snapshotRendering=new YD(i,i._snapshotRenderingMode,i._bundleList),i._ubInvertY=i._bufferManager.createBuffer(new Float32Array([-1,0]),nn.Uniform|nn.CopyDst,"UBInvertY"),i._ubDontInvertY=i._bufferManager.createBuffer(new Float32Array([1,0]),nn.Uniform|nn.CopyDst,"UBDontInvertY"),i.dbgVerboseLogsForFirstFrames&&i._count===void 0&&(i._count=0,O.V.Log(["%c frame #"+i._count+" - begin","background: #ffff00"])),i._uploadEncoder=i._device.createCommandEncoder(i._uploadEncoderDescriptor),i._renderEncoder=i._device.createCommandEncoder(i._renderEncoderDescriptor),i._emptyVertexBuffer=new Y.R(i,[0],"",{stride:1,offset:0,size:1,label:"EmptyVertexBuffer"}),i._cacheRenderPipeline=new ol(i._device,i._emptyVertexBuffer),i._depthCullingState=new DD(i._cacheRenderPipeline),i._stencilStateComposer=new OD(i._cacheRenderPipeline),i._stencilStateComposer.stencilGlobal=i._stencilState,i._depthCullingState.depthTest=!0,i._depthCullingState.depthFunc=P.Y.LEQUAL,i._depthCullingState.depthMask=!0,i._textureHelper.setCommandEncoder(i._uploadEncoder),i._clearQuad=new LD(i._device,i,i._emptyVertexBuffer),i._defaultDrawContext=i.createDrawContext(),i._currentDrawContext=i._defaultDrawContext,i._defaultMaterialContext=i.createMaterialContext(),i._currentMaterialContext=i._defaultMaterialContext,i._initializeContextAndSwapChain(),i._initializeMainAttachments(),i.resize()}).catch(function(o){throw O.V.Error("A fatal error occurred during WebGPU creation/initialization."),o})},t.prototype._initGlslang=function(e){return e=e||{},(e=(0,A.Cl)((0,A.Cl)({},t._GlslangDefaultOptions),e)).glslang?Promise.resolve(e.glslang):self.glslang?self.glslang(e.wasmPath):e.jsPath&&e.wasmPath?ze.S0.LoadBabylonScriptAsync(e.jsPath).then(function(){return self.glslang(ze.S0.GetBabylonScriptURL(e.wasmPath))}):Promise.reject("gslang is not available.")},t.prototype._initializeLimits=function(){this._caps={maxTexturesImageUnits:this._deviceLimits.maxSampledTexturesPerShaderStage,maxVertexTextureImageUnits:this._deviceLimits.maxSampledTexturesPerShaderStage,maxCombinedTexturesImageUnits:2*this._deviceLimits.maxSampledTexturesPerShaderStage,maxTextureSize:this._deviceLimits.maxTextureDimension2D,maxCubemapTextureSize:this._deviceLimits.maxTextureDimension2D,maxRenderTextureSize:this._deviceLimits.maxTextureDimension2D,maxVertexAttribs:this._deviceLimits.maxVertexAttributes,maxDrawBuffers:8,maxVaryingVectors:this._deviceLimits.maxInterStageShaderVariables,maxFragmentUniformVectors:Math.floor(this._deviceLimits.maxUniformBufferBindingSize/4),maxVertexUniformVectors:Math.floor(this._deviceLimits.maxUniformBufferBindingSize/4),standardDerivatives:!0,astc:this._deviceEnabledExtensions.indexOf("texture-compression-astc")>=0||void 0,s3tc:this._deviceEnabledExtensions.indexOf("texture-compression-bc")>=0||void 0,pvrtc:null,etc1:null,etc2:this._deviceEnabledExtensions.indexOf("texture-compression-etc2")>=0||void 0,bptc:this._deviceEnabledExtensions.indexOf("texture-compression-bc")>=0||void 0,maxAnisotropy:16,uintIndices:!0,fragmentDepthSupported:!0,highPrecisionShaderSupported:!0,colorBufferFloat:!0,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:this._deviceEnabledExtensions.indexOf("rg11b10ufloat-renderable")>=0,textureFloat:!0,textureFloatLinearFiltering:this._deviceEnabledExtensions.indexOf("float32-filterable")>=0,textureFloatRender:!0,textureHalfFloat:!0,textureHalfFloatLinearFiltering:!0,textureHalfFloatRender:!0,textureLOD:!0,texelFetch:!0,drawBuffersExtension:!0,depthTextureExtension:!0,vertexArrayObject:!1,instancedArrays:!0,timerQuery:typeof BigUint64Array<"u"&&this._deviceEnabledExtensions.indexOf("timestamp-query")!==-1||void 0,supportOcclusionQuery:typeof BigUint64Array<"u",canUseTimestampForTimerQuery:!0,multiview:!1,oculusMultiview:!1,parallelShaderCompile:void 0,blendMinMax:!0,maxMSAASamples:4,canUseGLInstanceID:!0,canUseGLVertexID:!0,supportComputeShaders:!0,supportSRGBBuffers:!0,supportTransformFeedbacks:!1,textureMaxLevel:!0,texture2DArrayMaxLayerCount:this._deviceLimits.maxTextureArrayLayers,disableMorphTargetTexture:!1},this._features={forceBitmapOverHTMLImageElement:!0,supportRenderAndCopyToLodForFloatTextures:!0,supportDepthStencilTexture:!0,supportShadowSamplers:!0,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:!0,trackUbosInFrame:!0,checkUbosContentBeforeUpload:!0,supportCSM:!0,basisNeedsPOT:!1,support3DTextures:!0,needTypeSuffixInShaderConstants:!0,supportMSAA:!0,supportSSAO2:!0,supportIBLShadows:!0,supportExtendedTextureFormats:!0,supportSwitchCaseInShader:!0,supportSyncTextureRead:!1,needsInvertingBitmap:!1,useUBOBindingCache:!1,needShaderCodeInlining:!0,needToAlwaysBindUniformBuffers:!0,supportRenderPasses:!0,supportSpriteInstancing:!0,forceVertexBufferStrideAndOffsetMultiple4Bytes:!0,_checkNonFloatVertexBuffersDontRecreatePipelineContext:!0,_collectUbosUpdatedInFrame:!1}},t.prototype._initializeContextAndSwapChain=function(){if(!this._renderingCanvas)throw"The rendering canvas has not been set!";this._context=this._renderingCanvas.getContext("webgpu"),this._configureContext(),this._colorFormat=this._options.swapChainFormat,this._mainRenderPassWrapper.colorAttachmentGPUTextures=[new Fd],this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format=this._colorFormat,this._setColorFormat(this._mainRenderPassWrapper)},t.prototype._initializeMainAttachments=function(){if(this._bufferManager){this.flushFramebuffer(),this._mainTextureExtends={width:this.getRenderWidth(!0),height:this.getRenderHeight(!0),depthOrArrayLayers:1};var e,n=new Float32Array([this.getRenderHeight(!0)]);if(this._bufferManager.setSubData(this._ubInvertY,4,n),this._bufferManager.setSubData(this._ubDontInvertY,4,n),this._options.antialias){var i={label:"Texture_MainColor_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height,"_antialiasing"),size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:"2d",format:this._options.swapChainFormat,usage:16};this._mainTexture&&this._textureHelper.releaseTexture(this._mainTexture),this._mainTexture=this._device.createTexture(i),e=[{view:this._mainTexture.createView({label:"TextureView_MainColor_antialiasing",dimension:"2d",format:this._options.swapChainFormat,mipLevelCount:1,arrayLayerCount:1}),clearValue:new Ge.ov(0,0,0,1),loadOp:"clear",storeOp:"store"}]}else e=[{view:void 0,clearValue:new Ge.ov(0,0,0,1),loadOp:"clear",storeOp:"store"}];this._mainRenderPassWrapper.depthTextureFormat=this.isStencilEnable?"depth24plus-stencil8":"depth32float",this._setDepthTextureFormat(this._mainRenderPassWrapper),this._setColorFormat(this._mainRenderPassWrapper);var o={label:"Texture_MainDepthStencil_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height),size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:"2d",format:this._mainRenderPassWrapper.depthTextureFormat,usage:16};this._depthTexture&&this._textureHelper.releaseTexture(this._depthTexture),this._depthTexture=this._device.createTexture(o);var a={view:this._depthTexture.createView({label:"TextureView_MainDepthStencil_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height),dimension:"2d",format:this._depthTexture.format,mipLevelCount:1,arrayLayerCount:1}),depthClearValue:this._clearDepthValue,depthLoadOp:"clear",depthStoreOp:"store",stencilClearValue:this._clearStencilValue,stencilLoadOp:this.isStencilEnable?"clear":void 0,stencilStoreOp:this.isStencilEnable?"store":void 0};this._mainRenderPassWrapper.renderPassDescriptor={label:"MainRenderPass",colorAttachments:e,depthStencilAttachment:a}}},t.prototype._sharedInit=function(e){r.prototype._sharedInit.call(this,e),uu(this,e,this._creationOptions)},t.prototype._configureContext=function(){this._context.configure({device:this._device,format:this._options.swapChainFormat,usage:17,alphaMode:this.premultipliedAlpha?"premultiplied":"opaque"})},t.prototype.resizeImageBitmap=function(e,n,i){return pu(this,e,n,i)},t.prototype._createImageBitmapFromSource=function(e,n){return fu(this,e,n)},t.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},t.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&_u(this._renderingCanvas))},t.prototype.exitFullscreen=function(){this.isFullscreen&&mu()},t.prototype.enterPointerlock=function(){this._renderingCanvas&&Ls(this._renderingCanvas)},t.prototype.exitPointerlock=function(){gu()},t.prototype._rebuildBuffers=function(){r.prototype._rebuildBuffers.call(this);for(var e=0,n=this._storageBuffers;e<n.length;e++){var i=n[e];i.getBuffer().engineId!==this.uniqueId&&i._rebuild()}},t.prototype._restoreEngineAfterContextLost=function(e){ol.ResetCache(),Ud.ResetCache();var n=function(l){for(var c,u=0,d=l;u<d.length;u++){for(var h=d[u],p=0,m=h.meshes;p<m.length;p++){var v=m[p].subMeshes;if(v)for(var b=0,E=v;b<E.length;b++)E[b]._drawWrappers=[]}for(var C=0,T=h.materials;C<T.length;C++)(c=T[C]._materialContext)===null||c===void 0||c.reset()}};n(this.scenes),n(this._virtualScenes);for(var i=[],o=0,a=this._uniformBuffers;o<a.length;o++){var s=a[o];s.name.indexOf("leftOver")<0&&i.push(s)}this._uniformBuffers=i,r.prototype._restoreEngineAfterContextLost.call(this,e)},t.prototype.setSize=function(e,n,i){return i===void 0&&(i=!1),!!r.prototype.setSize.call(this,e,n,i)&&(this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log(["frame #"+this._count+" - setSize -",e,n])),this._initializeMainAttachments(),this.snapshotRendering&&this.snapshotRenderingReset(),!0)},t.prototype._getShaderProcessor=function(e){return e===1?this._shaderProcessorWGSL:this._shaderProcessor},t.prototype._getShaderProcessingContext=function(e,n){return new za(e,n)},t.prototype._currentPassIsMainPass=function(){return this._currentRenderTarget===null},t.prototype._getCurrentRenderPass=function(){return this._currentRenderTarget&&!this._currentRenderPass?this._startRenderTargetRenderPass(this._currentRenderTarget,!1,null,!1,!1):this._currentRenderPass||this._startMainRenderPass(!1),this._currentRenderPass},t.prototype._getCurrentRenderPassWrapper=function(){return this._currentRenderTarget?this._rttRenderPassWrapper:this._mainRenderPassWrapper},t.prototype.applyStates=function(){this._stencilStateComposer.apply(),this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend)},t.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames&&!e||(this._forceEnableEffect=!0,this._currentIndexBuffer=null,this._currentOverrideVertexBuffers=null,this._cacheRenderPipeline.setBuffers(null,null,null),e&&(this._stencilStateComposer.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=P.Y.LEQUAL,this._alphaState.reset(),this._alphaMode=P.Y.ALPHA_ADD,this._alphaEquation=P.Y.ALPHA_DISABLE,this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters,this._alphaState._blendEquationParameters),this._cacheRenderPipeline.setAlphaBlendEnabled(!1),this.setColorWrite(!0)),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},t.prototype.setColorWrite=function(e){this._colorWriteLocal=e,this._cacheRenderPipeline.setWriteMask(e?15:0)},t.prototype.getColorWrite=function(){return this._colorWriteLocal},t.prototype._mustUpdateViewport=function(){var e=this._viewportCached.x,n=this._viewportCached.y,i=this._viewportCached.z,o=this._viewportCached.w,a=this._viewportsCurrent.x!==e||this._viewportsCurrent.y!==n||this._viewportsCurrent.w!==i||this._viewportsCurrent.h!==o;return a&&(this._viewportsCurrent.x=this._viewportCached.x,this._viewportsCurrent.y=this._viewportCached.y,this._viewportsCurrent.w=this._viewportCached.z,this._viewportsCurrent.h=this._viewportCached.w),a},t.prototype._applyViewport=function(e){var n=Math.floor(this._viewportCached.x),i=Math.floor(this._viewportCached.z),o=Math.floor(this._viewportCached.w),a=Math.floor(this._viewportCached.y);this._currentRenderTarget||(a=this.getRenderHeight(!0)-a-o),e?e.addItem(new FD(n,a,i,o)):this._getCurrentRenderPass().setViewport(n,a,i,o,0,1),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log(["frame #"+this._count+" - viewport applied - (",this._viewportCached.x,this._viewportCached.y,this._viewportCached.z,this._viewportCached.w,") current pass is main pass="+this._currentPassIsMainPass()]))},t.prototype._viewport=function(e,n,i,o){this._viewportCached.x=e,this._viewportCached.y=n,this._viewportCached.z=i,this._viewportCached.w=o},t.prototype._mustUpdateScissor=function(){var e=this._scissorCached.x,n=this._scissorCached.y,i=this._scissorCached.z,o=this._scissorCached.w,a=this._scissorsCurrent.x!==e||this._scissorsCurrent.y!==n||this._scissorsCurrent.w!==i||this._scissorsCurrent.h!==o;return a&&(this._scissorsCurrent.x=this._scissorCached.x,this._scissorsCurrent.y=this._scissorCached.y,this._scissorsCurrent.w=this._scissorCached.z,this._scissorsCurrent.h=this._scissorCached.w),a},t.prototype._applyScissor=function(e){var n=this._currentRenderTarget?this._scissorCached.y:this.getRenderHeight()-this._scissorCached.w-this._scissorCached.y;e?e.addItem(new wD(this._scissorCached.x,n,this._scissorCached.z,this._scissorCached.w)):this._getCurrentRenderPass().setScissorRect(this._scissorCached.x,n,this._scissorCached.z,this._scissorCached.w),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log(["frame #"+this._count+" - scissor applied - (",this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w,") current pass is main pass="+this._currentPassIsMainPass()]))},t.prototype._scissorIsActive=function(){return this._scissorCached.x!==0||this._scissorCached.y!==0||this._scissorCached.z!==0||this._scissorCached.w!==0},t.prototype.enableScissor=function(e,n,i,o){this._scissorCached.x=e,this._scissorCached.y=n,this._scissorCached.z=i,this._scissorCached.w=o},t.prototype.disableScissor=function(){this._scissorCached.x=this._scissorCached.y=this._scissorCached.z=this._scissorCached.w=0,this._scissorsCurrent.x=this._scissorsCurrent.y=this._scissorsCurrent.w=this._scissorsCurrent.h=0},t.prototype._mustUpdateStencilRef=function(){var e=this._stencilStateComposer.funcRef!==this._stencilRefsCurrent;return e&&(this._stencilRefsCurrent=this._stencilStateComposer.funcRef),e},t.prototype._applyStencilRef=function(e){var n,i;e?e.addItem(new tx((n=this._stencilStateComposer.funcRef)!==null&&n!==void 0?n:0)):this._getCurrentRenderPass().setStencilReference((i=this._stencilStateComposer.funcRef)!==null&&i!==void 0?i:0)},t.prototype._mustUpdateBlendColor=function(){var e=this._alphaState._blendConstants,n=e[0]!==this._blendColorsCurrent[0]||e[1]!==this._blendColorsCurrent[1]||e[2]!==this._blendColorsCurrent[2]||e[3]!==this._blendColorsCurrent[3];return n&&(this._blendColorsCurrent[0]=e[0],this._blendColorsCurrent[1]=e[1],this._blendColorsCurrent[2]=e[2],this._blendColorsCurrent[3]=e[3]),n},t.prototype._applyBlendColor=function(e){e?e.addItem(new BD(this._alphaState._blendConstants.slice())):this._getCurrentRenderPass().setBlendConstant(this._alphaState._blendConstants)},t.prototype._resetRenderPassStates=function(){this._viewportsCurrent.x=this._viewportsCurrent.y=this._viewportsCurrent.w=this._viewportsCurrent.h=0,this._scissorsCurrent.x=this._scissorsCurrent.y=this._scissorsCurrent.w=this._scissorsCurrent.h=0,this._stencilRefsCurrent=-1,this._blendColorsCurrent[0]=this._blendColorsCurrent[1]=this._blendColorsCurrent[2]=this._blendColorsCurrent[3]=null},t.prototype.clear=function(e,n,i,o){o===void 0&&(o=!1),e&&e.a===void 0&&(e.a=1);var a=this._scissorIsActive();this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log(["frame #"+this._count+" - clear - backBuffer=",n," depth=",i," stencil=",o," scissor is active=",a])),this._currentRenderTarget?a?(this._currentRenderPass||this._startRenderTargetRenderPass(this._currentRenderTarget,!1,n?e:null,i,o),this._applyScissor(this.compatibilityMode?null:this._bundleList),this._clearFullQuad(n?e:null,i,o)):(this._currentRenderPass&&this._endCurrentRenderPass(),this._startRenderTargetRenderPass(this._currentRenderTarget,!0,n?e:null,i,o)):(this._currentRenderPass&&a||this._startMainRenderPass(!a,n?e:null,i,o),a&&(this._applyScissor(this.compatibilityMode?null:this._bundleList),this._clearFullQuad(n?e:null,i,o)))},t.prototype._clearFullQuad=function(e,n,i){var o,a,s=this.compatibilityMode?this._getCurrentRenderPass():null;this._clearQuad.setColorFormat(this._colorFormat),this._clearQuad.setDepthStencilFormat(this._depthTextureFormat),this._clearQuad.setMRTAttachments((o=this._cacheRenderPipeline.mrtAttachments)!==null&&o!==void 0?o:[],(a=this._cacheRenderPipeline.mrtTextureArray)!==null&&a!==void 0?a:[],this._cacheRenderPipeline.mrtTextureCount),this.compatibilityMode?s.setStencilReference(this._clearStencilValue):this._bundleList.addItem(new tx(this._clearStencilValue));var l=this._clearQuad.clear(s,e,n,i,this.currentSampleCount);this.compatibilityMode?this._applyStencilRef(null):(this._bundleList.addBundle(l),this._applyStencilRef(this._bundleList),this._reportDrawCall())},t.prototype.createVertexBuffer=function(e,n,i){var o;return o=e instanceof Array?new Float32Array(e):e instanceof ArrayBuffer?new Uint8Array(e):e,this._bufferManager.createBuffer(o,nn.Vertex|nn.CopyDst,i)},t.prototype.createDynamicVertexBuffer=function(e,n){return this.createVertexBuffer(e,void 0,n)},t.prototype.createIndexBuffer=function(e,n,i){var o,a=!0;e instanceof Uint32Array||e instanceof Int32Array?o=e:e instanceof Uint16Array?(o=e,a=!1):e.length>65535?o=new Uint32Array(e):(o=new Uint16Array(e),a=!1);var s=this._bufferManager.createBuffer(o,nn.Index|nn.CopyDst,i);return s.is32Bits=a,s},t.prototype.updateDynamicIndexBuffer=function(e,n,i){i===void 0&&(i=0);var o,a=e;o=e.is32Bits?n instanceof Uint32Array?n:new Uint32Array(n):n instanceof Uint16Array?n:new Uint16Array(n),this._bufferManager.setSubData(a,i,o)},t.prototype.updateDynamicVertexBuffer=function(e,n,i,o){var a,s=e;i===void 0&&(i=0),o===void 0?o=(a=n instanceof Array?new Float32Array(n):n instanceof ArrayBuffer?new Uint8Array(n):n).byteLength:a=n instanceof Array?new Float32Array(n):n instanceof ArrayBuffer?new Uint8Array(n):n,this._bufferManager.setSubData(s,i,a,0,o)},t.prototype._createBuffer=function(e,n,i){var o;o=e instanceof Array?new Float32Array(e):e instanceof ArrayBuffer?new Uint8Array(e):e;var a=0;return n&P.Y.BUFFER_CREATIONFLAG_READ&&(a|=nn.CopySrc),n&P.Y.BUFFER_CREATIONFLAG_WRITE&&(a|=nn.CopyDst),n&P.Y.BUFFER_CREATIONFLAG_UNIFORM&&(a|=nn.Uniform),n&P.Y.BUFFER_CREATIONFLAG_VERTEX&&(a|=nn.Vertex),n&P.Y.BUFFER_CREATIONFLAG_INDEX&&(a|=nn.Index),n&P.Y.BUFFER_CREATIONFLAG_STORAGE&&(a|=nn.Storage),n&P.Y.BUFFER_CREATIONFLAG_INDIRECT&&(a|=nn.Indirect),this._bufferManager.createBuffer(o,a,i)},t.prototype.bindBuffersDirectly=function(){throw"Not implemented on WebGPU"},t.prototype.updateAndBindInstancesBuffer=function(){throw"Not implemented on WebGPU"},t.prototype.unbindInstanceAttributes=function(){},t.prototype.bindBuffers=function(e,n,i,o){this._currentIndexBuffer=n,this._currentOverrideVertexBuffers=o??null,this._cacheRenderPipeline.setBuffers(e,n,this._currentOverrideVertexBuffers)},t.prototype._releaseBuffer=function(e){return this._bufferManager.releaseBuffer(e)},t.prototype.createUniformBuffer=function(e,n){var i;return i=e instanceof Array?new Float32Array(e):e,this._bufferManager.createBuffer(i,nn.Uniform|nn.CopyDst,n)},t.prototype.createDynamicUniformBuffer=function(e,n){return this.createUniformBuffer(e,n)},t.prototype.updateUniformBuffer=function(e,n,i,o){i===void 0&&(i=0);var a,s=e;o===void 0?o=(a=n instanceof Float32Array?n:new Float32Array(n)).byteLength:a=n instanceof Float32Array?n:new Float32Array(n),this._bufferManager.setSubData(s,i,a,0,o)},t.prototype.bindUniformBufferBase=function(e,n,i){this._currentDrawContext.setBuffer(i,e)},t.prototype.bindUniformBlock=function(){},t.prototype.createEffect=function(e,n,i,o,a,s,l,c,u,d,h){var p,m,v;d===void 0&&(d=0);var b=typeof e=="string"?e:e.vertexToken||e.vertexSource||e.vertexElement||e.vertex,E=typeof e=="string"?e:e.fragmentToken||e.fragmentSource||e.fragmentElement||e.fragment,C=this._getGlobalDefines(),T=(p=a??n.defines)!==null&&p!==void 0?p:"";C&&(T+=`
|
||
`+C);var f=b+"+"+E+"@"+T;if(this._compiledEffects[f]){var g=this._compiledEffects[f];return l&&g.isReady()&&l(g),g._refCount++,g}var S=new ti.M(e,n,i,o,this,a,s,l,c,u,f,(m=n.shaderLanguage)!==null&&m!==void 0?m:d,(v=n.extraInitializationsAsync)!==null&&v!==void 0?v:h);return this._compiledEffects[f]=S,S},t.prototype._compileRawShaderToSpirV=function(e,n){return this._glslang.compileGLSL(e,n)},t.prototype._compileShaderToSpirV=function(e,n,i,o){return this._compileRawShaderToSpirV(o+(i?i+`
|
||
`:"")+e,n)},t.prototype._getWGSLShader=function(e,n,i){return(i=i?"//"+i.split(`
|
||
`).join(`
|
||
//`)+`
|
||
`:"")+e},t.prototype._createPipelineStageDescriptor=function(e,n,i,o,a){return this._tintWASM&&i===0&&(e=this._tintWASM.convertSpirV2WGSL(e,o),n=this._tintWASM.convertSpirV2WGSL(n,a)),{vertexStage:{module:this._device.createShaderModule({label:"vertex",code:e}),entryPoint:"main"},fragmentStage:{module:this._device.createShaderModule({label:"fragment",code:n}),entryPoint:"main"}}},t.prototype._compileRawPipelineStageDescriptor=function(e,n,i){var o=e.indexOf(P.Y.DISABLEUA)>=0,a=n.indexOf(P.Y.DISABLEUA)>=0,s=i===0?this._compileRawShaderToSpirV(e,"vertex"):e,l=i===0?this._compileRawShaderToSpirV(n,"fragment"):n;return this._createPipelineStageDescriptor(s,l,i,o,a)},t.prototype._compilePipelineStageDescriptor=function(e,n,i,o){this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=e.indexOf(P.Y.DISABLEUA)>=0,s=n.indexOf(P.Y.DISABLEUA)>=0,l=`#version 450
|
||
`,c=o===0?this._compileShaderToSpirV(e,"vertex",i,l):this._getWGSLShader(e,"vertex",i),u=o===0?this._compileShaderToSpirV(n,"fragment",i,l):this._getWGSLShader(n,"fragment",i),d=this._createPipelineStageDescriptor(c,u,o,a,s);return this.onAfterShaderCompilationObservable.notifyObservers(this),d},t.prototype.createRawShaderProgram=function(){throw"Not available on WebGPU"},t.prototype.createShaderProgram=function(){throw"Not available on WebGPU"},t.prototype.inlineShaderCode=function(e){var n=new Ga(e);return n.debug=!1,n.processCode(),n.code},t.prototype.createPipelineContext=function(e){return new bD(e,this)},t.prototype.createMaterialContext=function(){return new ND},t.prototype.createDrawContext=function(){return new Dg(this._bufferManager)},t.prototype._preparePipelineContext=function(e,n,i,o,a,s,l,c,u,d,h){return(0,A.sH)(this,void 0,void 0,function(){var p,m;return(0,A.YH)(this,function(v){switch(v.label){case 0:return(m=(p=e).shaderProcessingContext.shaderLanguage)!==0||this._glslangAndTintAreFullyLoaded?[3,2]:[4,this.prepareGlslangAndTintAsync()];case 1:v.sent(),v.label=2;case 2:return this.dbgShowShaderCode&&(O.V.Log(["defines",c]),O.V.Log(n),O.V.Log(i),O.V.Log("***********************************************")),p.sources={fragment:i,vertex:n,rawVertex:a,rawFragment:s},p.stages=o?this._compileRawPipelineStageDescriptor(n,i,m):this._compilePipelineStageDescriptor(n,i,c,m),h(),[2]}})})},t.prototype.getAttributes=function(e,n){for(var i=new Array(n.length),o=e,a=0;a<n.length;a++){var s=n[a],l=o.shaderProcessingContext.availableAttributes[s];l!==void 0&&(i[a]=l)}return i},t.prototype.enableEffect=function(e){if(e){if((0,Yu.E)(e)){if(!e.effect||e.effect===this._currentEffect&&e.materialContext===this._currentMaterialContext&&e.drawContext===this._currentDrawContext&&!this._forceEnableEffect){if(!e.effect&&this.dbgShowEmptyEnableEffectCalls)throw O.V.Log(["drawWrapper=",e]),"Invalid call to enableEffect: the effect property is empty!";return}if(this._currentEffect=e.effect,this._currentMaterialContext=e.materialContext,this._currentDrawContext=e.drawContext,this._counters.numEnableDrawWrapper++,!this._currentMaterialContext)throw O.V.Log(["drawWrapper=",e]),"Invalid call to enableEffect: the materialContext property is empty!"}else this._currentEffect=e,this._currentMaterialContext=this._defaultMaterialContext,this._currentDrawContext=this._defaultDrawContext,this._counters.numEnableEffects++,this.dbgLogIfNotDrawWrapper&&O.V.Warn("enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=".concat(e.uniqueId,", effect.name=").concat(e.name,", effect.name.vertex=").concat(typeof e.name=="string"?"":e.name.vertex,", effect.name.fragment=").concat(typeof e.name=="string"?"":e.name.fragment),10);this._stencilStateComposer.stencilMaterial=void 0,this._forceEnableEffect=!1,this._currentEffect.onBind&&this._currentEffect.onBind(this._currentEffect),this._currentEffect._onBindObservable&&this._currentEffect._onBindObservable.notifyObservers(this._currentEffect)}},t.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deletePipelineContext(e.getPipelineContext()))},t.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var n=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(n)}this._compiledEffects={}},t.prototype._deletePipelineContext=function(e){var n=e;n&&(0,XD.mO)(n)},Object.defineProperty(t.prototype,"needPOTTextures",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype._createHardwareTexture=function(){return new Fd},t.prototype._releaseTexture=function(e){var n=this._internalTexturesCache.indexOf(e);n!==-1&&this._internalTexturesCache.splice(n,1),this._textureHelper.releaseTexture(e)},t.prototype._getRGBABufferInternalSizedFormat=function(){return P.Y.TEXTUREFORMAT_RGBA},t.prototype.updateTextureComparisonFunction=function(e,n){e._comparisonFunction=n},t.prototype._createInternalTexture=function(e,n,i,o){var a,s,l;i===void 0&&(i=!0),o===void 0&&(o=0);var c={};n!==void 0&&typeof n=="object"?(c.generateMipMaps=n.generateMipMaps,c.type=n.type===void 0?P.Y.TEXTURETYPE_UNSIGNED_INT:n.type,c.samplingMode=n.samplingMode===void 0?P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:n.samplingMode,c.format=n.format===void 0?P.Y.TEXTUREFORMAT_RGBA:n.format,c.samples=(a=n.samples)!==null&&a!==void 0?a:1,c.creationFlags=(s=n.creationFlags)!==null&&s!==void 0?s:0,c.useSRGBBuffer=(l=n.useSRGBBuffer)!==null&&l!==void 0&&l,c.label=n.label):(c.generateMipMaps=n,c.type=P.Y.TEXTURETYPE_UNSIGNED_INT,c.samplingMode=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,c.format=P.Y.TEXTUREFORMAT_RGBA,c.samples=1,c.creationFlags=0,c.useSRGBBuffer=!1),(c.type!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(c.type!==P.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(c.samplingMode=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),c.type!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c.type=P.Y.TEXTURETYPE_UNSIGNED_INT,O.V.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));var u=new rn.h(this,o),d=e.width||e,h=e.height||e,p=e.depth||0,m=e.layers||0;return u.baseWidth=d,u.baseHeight=h,u.width=d,u.height=h,u.depth=p||m,u.isReady=!0,u.samples=c.samples,u.generateMipMaps=!!c.generateMipMaps,u.samplingMode=c.samplingMode,u.type=c.type,u.format=c.format,u.is2DArray=m>0,u.is3D=p>0,u._cachedWrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,u._cachedWrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE,u._useSRGBBuffer=c.useSRGBBuffer,u.label=c.label,this._internalTexturesCache.push(u),i||this._textureHelper.createGPUTextureForInternalTexture(u,d,h,m||1,c.creationFlags),u},t.prototype.createTexture=function(e,n,i,o,a,s,l,c,u,d,h,p,m,v,b){var E=this;return a===void 0&&(a=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),s===void 0&&(s=null),l===void 0&&(l=null),c===void 0&&(c=null),u===void 0&&(u=null),d===void 0&&(d=null),h===void 0&&(h=null),this._createTextureBase(e,n,i,o,a,s,l,function(C,T,f,g,S,y,x,R){var I,M=g;if(C.baseWidth=M.width,C.baseHeight=M.height,C.width=M.width,C.height=M.height,C.format=C.format!==-1?C.format:d??P.Y.TEXTUREFORMAT_RGBA,C.type=C.type!==-1?C.type:P.Y.TEXTURETYPE_UNSIGNED_BYTE,C._creationFlags=v??0,R(C.width,C.height,M,T,C,function(){}),(I=C._hardwareTexture)===null||I===void 0?void 0:I.underlyingResource)y||x||E._generateMipmaps(C,E._uploadEncoder);else{var D=E._textureHelper.createGPUTextureForInternalTexture(C,M.width,M.height,void 0,v);en.IsImageBitmap(M)&&(E._textureHelper.updateTexture(M,C,M.width,M.height,C.depth,D.format,0,0,S,!1,0,0),y||x||E._generateMipmaps(C,E._uploadEncoder))}f&&f.removePendingData(C),C.isReady=!0,C.onLoadedObservable.notifyObservers(C),C.onLoadedObservable.clear()},function(){return!1},c,u,d,h,p,m,b)},t.prototype.wrapWebGPUTexture=function(e){var n=new Fd(e),i=new rn.h(this,0,!0);return i._hardwareTexture=n,i.isReady=!0,i},t.prototype.wrapWebGLTexture=function(){throw new Error("wrapWebGLTexture is not supported, use wrapWebGPUTexture instead.")},t.prototype._getUseSRGBBuffer=function(e,n){return e&&this._caps.supportSRGBBuffers},t.prototype._unpackFlipY=function(e){},t.prototype.updateTextureSamplingMode=function(e,n,i){i===void 0&&(i=!1),i&&(n.generateMipMaps=!0,this._generateMipmaps(n)),n.samplingMode=e},t.prototype.updateTextureWrappingMode=function(e,n,i,o){i===void 0&&(i=null),o===void 0&&(o=null),n!==null&&(e._cachedWrapU=n),i!==null&&(e._cachedWrapV=i),(e.is2DArray||e.is3D)&&o!==null&&(e._cachedWrapR=o)},t.prototype.updateTextureDimensions=function(e,n,i,o){if(o===void 0&&(o=1),e._hardwareTexture&&(e.width!==n||e.height!==i||e.depth!==o)){var a=e._hardwareTexture.textureAdditionalUsages;e._hardwareTexture.release(),this._textureHelper.createGPUTextureForInternalTexture(e,n,i,o,a)}},t.prototype._setInternalTexture=function(e,n,i){if(i=i??e,this._currentEffect){var o=this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[i];if(this._currentMaterialContext.setTexture(e,n),o&&o.autoBindSampler){var a=i+P.Y.AUTOSAMPLERSUFFIX;this._currentMaterialContext.setSampler(a,n)}}},t.prototype.createPrefilteredCubeTexture=function(e,n,i,o,a,s,l,c,u){return a===void 0&&(a=null),s===void 0&&(s=null),c===void 0&&(c=null),u===void 0&&(u=!0),this.createCubeTexture(e,n,null,!1,function(d){if(d){var h=d.texture;u?d.info.sphericalPolynomial&&(h._sphericalPolynomial=d.info.sphericalPolynomial):h._sphericalPolynomial=new Lo.Q,h._source=9,a&&a(h)}else a&&a(null)},s,l,c,u,i,o)},t.prototype.setTexture=function(e,n,i,o){this._setTexture(e,i,!1,!1,o,o)},t.prototype.setTextureArray=function(e,n,i,o){for(var a=0;a<i.length;a++)this._setTexture(-1,i[a],!0,!1,o+a.toString(),o)},t.prototype._setTexture=function(e,n,i,o,a,s){if(o===void 0&&(o=!1),a===void 0&&(a=""),s=s??a,this._currentEffect){if(!n)return this._currentMaterialContext.setTexture(a,null),!1;if(n.video)n.update();else if(n.delayLoadState===P.Y.DELAYLOADSTATE_NOTLOADED)return n.delayLoad(),!1;var l=null;if((l=o?n.depthStencilTexture:n.isReady()?n.getInternalTexture():n.isCube?this.emptyCubeTexture:n.is3D?this.emptyTexture3D:n.is2DArray?this.emptyTexture2DArray:this.emptyTexture)&&!l.isMultiview){if(l.isCube&&l._cachedCoordinatesMode!==n.coordinatesMode){l._cachedCoordinatesMode=n.coordinatesMode;var c=n.coordinatesMode!==P.Y.TEXTURE_CUBIC_MODE&&n.coordinatesMode!==P.Y.TEXTURE_SKYBOX_MODE?P.Y.TEXTURE_WRAP_ADDRESSMODE:P.Y.TEXTURE_CLAMP_ADDRESSMODE;n.wrapU=c,n.wrapV=c}l._cachedWrapU=n.wrapU,l._cachedWrapV=n.wrapV,l.is3D&&(l._cachedWrapR=n.wrapR),this._setAnisotropicLevel(0,l,n.anisotropicFilteringLevel)}this._setInternalTexture(a,l,s)}else this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log(["frame #"+this._count+" - _setTexture called with a null _currentEffect! texture=",n]));return!0},t.prototype._setAnisotropicLevel=function(e,n,i){n._cachedAnisotropicFilteringLevel!==i&&(n._cachedAnisotropicFilteringLevel=Math.min(i,this._caps.maxAnisotropy))},t.prototype._bindTexture=function(e,n,i){e!==void 0&&this._setInternalTexture(i,n)},t.prototype.generateMipmaps=function(e){this._generateMipmaps(e)},t.prototype._generateMipmaps=function(e,n){n=n??this._renderEncoder;var i=e._hardwareTexture;if(i){n===this._renderEncoder&&this._endCurrentRenderPass();var o=e._hardwareTexture.format,a=en.ComputeNumMipmapLevels(e.width,e.height);this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log("frame #"+this._count+" - generate mipmaps - width="+e.width+", height="+e.height+", isCube="+e.isCube+", command encoder="+(n===this._renderEncoder?"render":"copy"))),e.isCube?this._textureHelper.generateCubeMipmaps(i,o,a,n):this._textureHelper.generateMipmaps(i,o,a,0,e.is3D,n)}},t.prototype.updateTextureData=function(e,n,i,o,a,s,l,c,u){var d;l===void 0&&(l=0),c===void 0&&(c=0),u===void 0&&(u=!1);var h=e._hardwareTexture;!((d=e._hardwareTexture)===null||d===void 0)&&d.underlyingResource||(h=this._textureHelper.createGPUTextureForInternalTexture(e));var p=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);this._textureHelper.updateTexture(p,e,a,s,e.depth,h.format,l,c,e.invertY,!1,i,o),u&&this._generateMipmaps(e)},t.prototype._uploadCompressedDataToTextureDirectly=function(e,n,i,o,a,s,l){var c;s===void 0&&(s=0),l===void 0&&(l=0);var u=e._hardwareTexture;!((c=e._hardwareTexture)===null||c===void 0)&&c.underlyingResource||(e.format=n,u=this._textureHelper.createGPUTextureForInternalTexture(e,i,o));var d=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);this._textureHelper.updateTexture(d,e,i,o,e.depth,u.format,s,l,!1,!1,0,0)},t.prototype._uploadDataToTextureDirectly=function(e,n,i,o,a,s){var l;i===void 0&&(i=0),o===void 0&&(o=0),s===void 0&&(s=!1);var c=Math.round(Math.log(e.width)*Math.LOG2E),u=Math.round(Math.log(e.height)*Math.LOG2E),d=s?e.width:Math.pow(2,Math.max(c-o,0)),h=s?e.height:Math.pow(2,Math.max(u-o,0)),p=e._hardwareTexture;!((l=e._hardwareTexture)===null||l===void 0)&&l.underlyingResource||(p=this._textureHelper.createGPUTextureForInternalTexture(e,d,h));var m=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);this._textureHelper.updateTexture(m,e,d,h,e.depth,p.format,i,o,e.invertY,!1,0,0)},t.prototype._uploadArrayBufferViewToTexture=function(e,n,i,o){i===void 0&&(i=0),o===void 0&&(o=0),this._uploadDataToTextureDirectly(e,n,i,o)},t.prototype._uploadImageToTexture=function(e,n,i,o){var a;i===void 0&&(i=0),o===void 0&&(o=0);var s=e._hardwareTexture;if(!((a=e._hardwareTexture)===null||a===void 0)&&a.underlyingResource||(s=this._textureHelper.createGPUTextureForInternalTexture(e)),n instanceof HTMLImageElement)throw"WebGPU engine: HTMLImageElement not supported in _uploadImageToTexture!";var l=n,c=Math.ceil(e.width/(1<<o)),u=Math.ceil(e.height/(1<<o));this._textureHelper.updateTexture(l,e,c,u,e.depth,s.format,i,o,e.invertY,!1,0,0)},t.prototype.readPixels=function(e,n,i,o,a,s){s===void 0&&(s=!0);var l=this._getCurrentRenderPassWrapper().colorAttachmentGPUTextures[0];if(!l)return Promise.resolve(new Uint8Array(0));var c=l.underlyingResource,u=l.format;return c?(s&&this.flushFramebuffer(),this._textureHelper.readPixels(c,e,n,i,o,u)):Promise.resolve(new Uint8Array(0))},t.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},Object.defineProperty(t.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!1,configurable:!0}),t.prototype.beginFrame=function(){this._measureFps(),r.prototype.beginFrame.call(this)},t.prototype.endFrame=function(){if(this._endCurrentRenderPass(),this._snapshotRendering.endFrame(),this._timestampQuery.endFrame(this._renderEncoder),this._timestampIndex=0,this.flushFramebuffer(),this._textureHelper.destroyDeferredTextures(),this._bufferManager.destroyDeferredBuffers(),this._features._collectUbosUpdatedInFrame){if(this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),!this._count||this._count<this.dbgVerboseLogsNumFrames)){var e=[];for(var n in Ui.D._UpdatedUbosInFrame)e.push(n+":"+Ui.D._UpdatedUbosInFrame[n]);O.V.Log(["frame #"+this._count+" - updated ubos -",e.join(", ")])}Ui.D._UpdatedUbosInFrame={}}this.countersLastFrame.numEnableEffects=this._counters.numEnableEffects,this.countersLastFrame.numEnableDrawWrapper=this._counters.numEnableDrawWrapper,this.countersLastFrame.numBundleCreationNonCompatMode=this._counters.numBundleCreationNonCompatMode,this.countersLastFrame.numBundleReuseNonCompatMode=this._counters.numBundleReuseNonCompatMode,this._counters.numEnableEffects=0,this._counters.numEnableDrawWrapper=0,this._counters.numBundleCreationNonCompatMode=0,this._counters.numBundleReuseNonCompatMode=0,this._cacheRenderPipeline.endFrame(),this._cacheBindGroups.endFrame(),this._pendingDebugCommands.length=0,this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),this._count<this.dbgVerboseLogsNumFrames&&O.V.Log(["%c frame #"+this._count+" - end","background: #ffff00"]),this._count<this.dbgVerboseLogsNumFrames&&(this._count++,this._count!==this.dbgVerboseLogsNumFrames&&O.V.Log(["%c frame #"+this._count+" - begin","background: #ffff00"]))),r.prototype.endFrame.call(this)},t.prototype.extractDriverInfo=function(){return""},t.prototype.flushFramebuffer=function(){this._endCurrentRenderPass(),this._commandBuffers[0]=this._uploadEncoder.finish(),this._commandBuffers[1]=this._renderEncoder.finish(),this._device.queue.submit(this._commandBuffers),this._uploadEncoder=this._device.createCommandEncoder(this._uploadEncoderDescriptor),this._renderEncoder=this._device.createCommandEncoder(this._renderEncoderDescriptor),this._timestampQuery.startFrame(this._uploadEncoder),this._textureHelper.setCommandEncoder(this._uploadEncoder),this._bundleList.reset()},t.prototype._currentFrameBufferIsDefaultFrameBuffer=function(){return this._currentPassIsMainPass()},t.prototype._startRenderTargetRenderPass=function(e,n,i,o,a){var s,l,c,u,d,h,p,m;this._endCurrentRenderPass();var v=e,b=v._depthStencilTexture,E=b?._hardwareTexture,C=E?.underlyingResource,T=E?.getMSAATexture(),f=C?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor),g=T?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor),S=!!E&&en.HasStencilAspect(E.format),y=[];this.useReverseDepthBuffer&&this.setDepthFunctionToGreaterOrEqual();var x=qD;i&&(x.r=255*i.r,x.g=255*i.g,x.b=255*i.b,x.a=255*i.a);var R=n&&i,I=n&&o,M=n&&a;if(v._attachments&&v.isMulti){this._mrtAttachments&&this._mrtAttachments.length!==0||(this._mrtAttachments=v._defaultAttachments);for(var D=0;D<this._mrtAttachments.length;++D){var B=this._mrtAttachments[D],F=v.textures[D],X=F?._hardwareTexture,$=X?.underlyingResource;if(X&&$){var Q=X.getMSAATexture(D),ie=(l=(s=v.layerIndices)===null||s===void 0?void 0:s[D])!==null&&l!==void 0?l:0,q=(u=(c=v.faceIndices)===null||c===void 0?void 0:c[D])!==null&&u!==void 0?u:0,ee=(0,A.Cl)((0,A.Cl)({},this._rttRenderPassWrapper.colorAttachmentViewDescriptor),{dimension:F.is3D?"3d":"2d",format:X.format,baseArrayLayer:F.isCube?6*ie+q:F.is3D?0:ie}),te=(0,A.Cl)((0,A.Cl)({},this._rttRenderPassWrapper.colorAttachmentViewDescriptor),{dimension:F.is3D?"3d":"2d",format:X.format,baseArrayLayer:0}),ce=F.type===P.Y.TEXTURETYPE_UNSIGNED_INTEGER||F.type===P.Y.TEXTURETYPE_UNSIGNED_SHORT,fe=$.createView(ee),de=Q?.createView(te);y.push({view:de||fe,resolveTarget:Q?fe:void 0,depthSlice:F.is3D?ie:void 0,clearValue:B!==0&&R?ce?x:i:void 0,loadOp:B!==0&&R?"clear":"load",storeOp:"store"})}}this._cacheRenderPipeline.setMRT(v.textures,this._mrtAttachments.length),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)}else if(N=v.texture){var Te=N._hardwareTexture,ue=Te.underlyingResource,U=void 0;v.is3D&&(U=this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer,this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer=0),Q=Te.getMSAATexture(),fe=ue.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),de=Q?.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),ce=N.type===P.Y.TEXTURETYPE_UNSIGNED_INTEGER||N.type===P.Y.TEXTURETYPE_UNSIGNED_SHORT,y.push({view:de||fe,resolveTarget:Q?fe:void 0,depthSlice:U,clearValue:R?ce?x:i:void 0,loadOp:R?"clear":"load",storeOp:"store"})}else y.push(null);if((d=this._debugPushGroup)===null||d===void 0||d.call(this,"render target pass"+(e.label?" ("+e.label+")":""),1),this._rttRenderPassWrapper.renderPassDescriptor={label:((h=e.label)!==null&&h!==void 0?h:"RTT")+"RenderPass",colorAttachments:y,depthStencilAttachment:b&&C?{view:g||f,depthClearValue:I?this.useReverseDepthBuffer?this._clearReverseDepthValue:this._clearDepthValue:void 0,depthLoadOp:I?"clear":"load",depthStoreOp:"store",stencilClearValue:v._depthStencilTextureWithStencil&&M?this._clearStencilValue:void 0,stencilLoadOp:S?v._depthStencilTextureWithStencil&&M?"clear":"load":void 0,stencilStoreOp:S?"store":void 0}:void 0,occlusionQuerySet:!((p=this._occlusionQuery)===null||p===void 0)&&p.hasQueries?this._occlusionQuery.querySet:void 0},this._timestampQuery.startPass(this._rttRenderPassWrapper.renderPassDescriptor,this._timestampIndex),this._currentRenderPass=this._renderEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),!this._count||this._count<this.dbgVerboseLogsNumFrames)){var N=v.texture;O.V.Log(["frame #"+this._count+" - render target begin pass - rtt name="+e.label+", internalTexture.uniqueId="+N.uniqueId+", width="+N.width+", height="+N.height+", setClearStates="+n,"renderPassDescriptor=",this._rttRenderPassWrapper.renderPassDescriptor])}(m=this._debugFlushPendingCommands)===null||m===void 0||m.call(this),this._resetRenderPassStates(),E&&en.HasStencilAspect(E.format)||(this._stencilStateComposer.enabled=!1)},t.prototype._startMainRenderPass=function(e,n,i,o){var a,s,l;this._endCurrentRenderPass(),this.useReverseDepthBuffer&&this.setDepthFunctionToGreaterOrEqual();var c=e&&n,u=e&&i,d=e&&o;this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue=c?n:void 0,this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp=c?"clear":"load",this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue=u?this.useReverseDepthBuffer?this._clearReverseDepthValue:this._clearDepthValue:void 0,this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp=u?"clear":"load",this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue=d?this._clearStencilValue:void 0,this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp=this.isStencilEnable?d?"clear":"load":void 0,this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet=!((a=this._occlusionQuery)===null||a===void 0)&&a.hasQueries?this._occlusionQuery.querySet:void 0;var h=this._context.getCurrentTexture();this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(h),this._options.antialias?(rx.format=h.format,this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget=h.createView(rx)):(ox.format=h.format,this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view=h.createView(ox)),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log(["frame #"+this._count+" - main begin pass - texture width="+this._mainTextureExtends.width," height="+this._mainTextureExtends.height+", setClearStates="+e,"renderPassDescriptor=",this._mainRenderPassWrapper.renderPassDescriptor])),(s=this._debugPushGroup)===null||s===void 0||s.call(this,"main pass",0),this._timestampQuery.startPass(this._mainRenderPassWrapper.renderPassDescriptor,this._timestampIndex),this._currentRenderPass=this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor),this._setDepthTextureFormat(this._mainRenderPassWrapper),this._setColorFormat(this._mainRenderPassWrapper),(l=this._debugFlushPendingCommands)===null||l===void 0||l.call(this),this._resetRenderPassStates(),this._isStencilEnable||(this._stencilStateComposer.enabled=!1)},t.prototype._endCurrentRenderPass=function(){var e,n,i;if(!this._currentRenderPass)return 0;var o=this._currentPassIsMainPass()?2:1;return this._snapshotRendering.endRenderPass(this._currentRenderPass)||this.compatibilityMode||(this._bundleList.run(this._currentRenderPass),this._bundleList.reset()),this._currentRenderPass.end(),this._timestampQuery.endPass(this._timestampIndex,this._currentRenderTarget&&this._currentRenderTarget.gpuTimeInFrame?this._currentRenderTarget.gpuTimeInFrame:this.gpuTimeInFrameForMainPass),this._timestampIndex+=2,this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log("frame #"+this._count+" - "+(o===2?"main":"render target")+" end pass"+(o===1?" - internalTexture.uniqueId="+((n=(e=this._currentRenderTarget)===null||e===void 0?void 0:e.texture)===null||n===void 0?void 0:n.uniqueId):""))),(i=this._debugPopGroup)===null||i===void 0||i.call(this,0),this._currentRenderPass=null,o},t.prototype.bindFramebuffer=function(e,n,i,o,a,s,l){var c,u;n===void 0&&(n=0),s===void 0&&(s=0),l===void 0&&(l=0);var d=(c=e.texture)===null||c===void 0?void 0:c._hardwareTexture;this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._endCurrentRenderPass(),this._currentRenderTarget=e;var h=this._currentRenderTarget._depthStencilTexture;this._rttRenderPassWrapper.colorAttachmentGPUTextures[0]=d,this._rttRenderPassWrapper.depthTextureFormat=h?en.GetWebGPUTextureFormat(-1,h.format):void 0,this._setDepthTextureFormat(this._rttRenderPassWrapper),this._setColorFormat(this._rttRenderPassWrapper),this._rttRenderPassWrapper.colorAttachmentViewDescriptor={format:this._colorFormat,dimension:e.is3D?"3d":"2d",mipLevelCount:1,baseArrayLayer:e.isCube?6*l+n:l,baseMipLevel:s,arrayLayerCount:1,aspect:"all"},this._rttRenderPassWrapper.depthAttachmentViewDescriptor={format:this._depthTextureFormat,dimension:h&&h.is3D?"3d":"2d",mipLevelCount:1,baseArrayLayer:h?h.isCube?6*l+n:l:0,baseMipLevel:0,arrayLayerCount:1,aspect:"all"},this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log(["frame #"+this._count+" - bindFramebuffer - rtt name="+e.label+", internalTexture.uniqueId="+((u=e.texture)===null||u===void 0?void 0:u.uniqueId)+", face="+n+", lodLevel="+s+", layer="+l,"colorAttachmentViewDescriptor=",this._rttRenderPassWrapper.colorAttachmentViewDescriptor,"depthAttachmentViewDescriptor=",this._rttRenderPassWrapper.depthAttachmentViewDescriptor])),this._cachedViewport&&!a?this.setViewport(this._cachedViewport,i,o):(i||(i=e.width,s&&(i/=Math.pow(2,s))),o||(o=e.height,s&&(o/=Math.pow(2,s))),this._viewport(0,0,i,o)),this.wipeCaches()},t.prototype.unBindFramebuffer=function(e,n,i){var o,a;n===void 0&&(n=!1);var s=this._currentRenderTarget;this._currentRenderTarget=null,i&&i(),this._currentRenderTarget=s,this._endCurrentRenderPass(),!(!((o=e.texture)===null||o===void 0)&&o.generateMipMaps)||n||e.isCube||this._generateMipmaps(e.texture),this._currentRenderTarget=null,this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&O.V.Log("frame #"+this._count+" - unBindFramebuffer - rtt name="+e.label+", internalTexture.uniqueId=",(a=e.texture)===null||a===void 0?void 0:a.uniqueId)),this._mrtAttachments=[],this._cacheRenderPipeline.setMRT([]),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)},t.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._currentRenderPass||this._startMainRenderPass(!1),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},t.prototype._setColorFormat=function(e){var n,i,o=(i=(n=e.colorAttachmentGPUTextures[0])===null||n===void 0?void 0:n.format)!==null&&i!==void 0?i:null;this._cacheRenderPipeline.setColorFormat(o),this._colorFormat!==o&&(this._colorFormat=o)},t.prototype._setDepthTextureFormat=function(e){this._cacheRenderPipeline.setDepthStencilFormat(e.depthTextureFormat),this._depthTextureFormat!==e.depthTextureFormat&&(this._depthTextureFormat=e.depthTextureFormat)},t.prototype.setDitheringState=function(){},t.prototype.setRasterizerState=function(){},t.prototype._executeWhenRenderingStateIsCompiled=function(e,n){n()},t.prototype.bindSamplers=function(){},t.prototype._getUnpackAlignement=function(){return 1},t.prototype._bindTextureDirectly=function(){return!1},t.prototype.setState=function(e,n,i,o,a,s,l){var c,u;n===void 0&&(n=0),o===void 0&&(o=!1),l===void 0&&(l=0),(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);var d=(u=(c=this.cullBackFaces)!==null&&c!==void 0?c:a)===null||u===void 0||u?1:2;(this._depthCullingState.cullFace!==d||i)&&(this._depthCullingState.cullFace=d),this.setZOffset(n),this.setZOffsetUnits(l);var h=o?this._currentRenderTarget?1:2:this._currentRenderTarget?2:1;(this._depthCullingState.frontFace!==h||i)&&(this._depthCullingState.frontFace=h),this._stencilStateComposer.stencilMaterial=s},t.prototype._applyRenderPassChanges=function(e){var n=!!this._stencilStateComposer.enabled&&this._mustUpdateStencilRef(),i=!!this._alphaState.alphaBlend&&this._mustUpdateBlendColor();this._mustUpdateViewport()&&this._applyViewport(e),this._mustUpdateScissor()&&this._applyScissor(e),n&&this._applyStencilRef(e),i&&this._applyBlendColor(e)},t.prototype._draw=function(e,n,i,o,a){var s,l=this._getCurrentRenderPass(),c=this._bundleList;this.applyStates();var u=this._currentEffect._pipelineContext;if(this.bindUniformBufferBase(this._currentRenderTarget?this._ubInvertY:this._ubDontInvertY,0,or.InternalsUBOName),u.uniformBuffer&&(u.uniformBuffer.update(),this.bindUniformBufferBase(u.uniformBuffer.getBuffer(),0,or.LeftOvertUBOName)),this._snapshotRendering.play)this._reportDrawCall();else{!this.compatibilityMode&&(this._currentDrawContext.isDirty(this._currentMaterialContext.updateId)||this._currentMaterialContext.isDirty||this._currentMaterialContext.forceBindGroupCreation)&&(this._currentDrawContext.fastBundle=void 0);var d=l;if(!this.compatibilityMode&&this._currentDrawContext.fastBundle||this._snapshotRendering.record){if(this._applyRenderPassChanges(c),!this._snapshotRendering.record)return this._counters.numBundleReuseNonCompatMode++,this._currentDrawContext.indirectDrawBuffer&&this._currentDrawContext.setIndirectData(o,a||1,i),c.addBundle(this._currentDrawContext.fastBundle),void this._reportDrawCall();d=c.getBundleEncoder(this._cacheRenderPipeline.colorFormats,this._depthTextureFormat,this.currentSampleCount),c.numDrawCalls++}var h=0;if(this._currentMaterialContext.hasFloatOrDepthTextures)for(var p=1,m=0;m<u.shaderProcessingContext.textureNames.length;++m){var v=u.shaderProcessingContext.textureNames[m],b=(s=this._currentMaterialContext.textures[v])===null||s===void 0?void 0:s.texture,E=b&&b.format>=P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8&&b.format<=P.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8;(b?.type===P.Y.TEXTURETYPE_FLOAT&&!this._caps.textureFloatLinearFiltering||E)&&(h|=p),p<<=1}this._currentMaterialContext.textureState=h;var C=this._cacheRenderPipeline.getRenderPipeline(n,this._currentEffect,this.currentSampleCount,h),T=this._cacheBindGroups.getBindGroups(u,this._currentDrawContext,this._currentMaterialContext);this._snapshotRendering.record||(this._applyRenderPassChanges(this.compatibilityMode?null:c),this.compatibilityMode||(this._counters.numBundleCreationNonCompatMode++,d=this._device.createRenderBundleEncoder({colorFormats:this._cacheRenderPipeline.colorFormats,depthStencilFormat:this._depthTextureFormat,sampleCount:en.GetSample(this.currentSampleCount)}))),d.setPipeline(C),this._currentIndexBuffer&&d.setIndexBuffer(this._currentIndexBuffer.underlyingResource,this._currentIndexBuffer.is32Bits?"uint32":"uint16",0);for(var f=this._cacheRenderPipeline.vertexBuffers,g=0;g<f.length;g++){var S=f[g],y=S.effectiveBuffer;y&&d.setVertexBuffer(g,y.underlyingResource,S._validOffsetRange?0:S.byteOffset)}for(m=0;m<T.length;m++)d.setBindGroup(m,T[m]);var x=!this.compatibilityMode&&!this._snapshotRendering.record;x&&this._currentDrawContext.indirectDrawBuffer?(this._currentDrawContext.setIndirectData(o,a||1,i),e===0?d.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer,0):d.drawIndirect(this._currentDrawContext.indirectDrawBuffer,0)):e===0?d.drawIndexed(o,a||1,i,0,0):d.draw(o,a||1,i,0),x&&(this._currentDrawContext.fastBundle=d.finish(),c.addBundle(this._currentDrawContext.fastBundle)),this._reportDrawCall()}},t.prototype.drawElementsType=function(e,n,i,o){o===void 0&&(o=1),this._draw(0,e,n,i,o)},t.prototype.drawArraysType=function(e,n,i,o){o===void 0&&(o=1),this._currentIndexBuffer=null,this._draw(1,e,n,i,o)},t.prototype.dispose=function(){var e,n;this._isDisposed=!0,this.hideLoadingUI(),this._timestampQuery.dispose(),(e=this._mainTexture)===null||e===void 0||e.destroy(),(n=this._depthTexture)===null||n===void 0||n.destroy(),this._textureHelper.destroyDeferredTextures(),this._bufferManager.destroyDeferredBuffers(),this._device.destroy(),du(this,this._renderingCanvas),r.prototype.dispose.call(this)},t.prototype.getRenderWidth=function(e){var n,i;return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:(i=(n=this._renderingCanvas)===null||n===void 0?void 0:n.width)!==null&&i!==void 0?i:0},t.prototype.getRenderHeight=function(e){var n,i;return e===void 0&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:(i=(n=this._renderingCanvas)===null||n===void 0?void 0:n.height)!==null&&i!==void 0?i:0},t.prototype.getError=function(){return 0},t.prototype.createExternalTexture=function(e){return new jD(e)},t.prototype.setExternalTexture=function(e,n){n?this._setInternalTexture(e,n):this._currentMaterialContext.setTexture(e,null)},t.prototype.setTextureSampler=function(e,n){var i;(i=this._currentMaterialContext)===null||i===void 0||i.setSampler(e,n)},t.prototype.createStorageBuffer=function(e,n,i){return this._createBuffer(e,n|P.Y.BUFFER_CREATIONFLAG_STORAGE,i)},t.prototype.updateStorageBuffer=function(e,n,i,o){var a,s=e;i===void 0&&(i=0),o===void 0?o=(a=n instanceof Array?new Float32Array(n):n instanceof ArrayBuffer?new Uint8Array(n):n).byteLength:a=n instanceof Array?new Float32Array(n):n instanceof ArrayBuffer?new Uint8Array(n):n,this._bufferManager.setSubData(s,i,a,0,o)},t.prototype._readFromGPUBuffer=function(e,n,i,o){var a=this;return new Promise(function(s,l){var c=function(){e.mapAsync(1,0,n).then(function(){var u=e.getMappedRange(0,n),d=i;if(d===void 0)(d=new Uint8Array(n)).set(new Uint8Array(u));else{var h=d.constructor;(d=new h(d.buffer)).set(new h(u))}e.unmap(),a._bufferManager.releaseBuffer(e),s(d)},function(u){a.isDisposed?s(new Uint8Array):l(u)})};o?(a.flushFramebuffer(),c()):a.onEndFrameObservable.addOnce(function(){c()})})},t.prototype.readFromStorageBuffer=function(e,n,i,o,a){i=i||e.capacity;var s=this._bufferManager.createRawBuffer(i,nn.MapRead|nn.CopyDst,void 0,"TempReadFromStorageBuffer");return this._renderEncoder.copyBufferToBuffer(e.underlyingResource,n??0,s,0,i),this._readFromGPUBuffer(s,i,o,a)},t.prototype.readFromMultipleStorageBuffers=function(e,n,i,o,a){i=i||e[0].capacity;for(var s=this._bufferManager.createRawBuffer(i*e.length,nn.MapRead|nn.CopyDst,void 0,"TempReadFromMultipleStorageBuffers"),l=0;l<e.length;l++)this._renderEncoder.copyBufferToBuffer(e[l].underlyingResource,n??0,s,l*i,i);return this._readFromGPUBuffer(s,i*e.length,o,a)},t.prototype.setStorageBuffer=function(e,n){var i,o;(i=this._currentDrawContext)===null||i===void 0||i.setBuffer(e,(o=n?.getBuffer())!==null&&o!==void 0?o:null)},t._GlslangDefaultOptions={jsPath:"".concat(ze.S0._DefaultCdnUrl,"/glslang/glslang.js"),wasmPath:"".concat(ze.S0._DefaultCdnUrl,"/glslang/glslang.wasm")},t._InstanceId=0,t}(Be.$);It.prototype.setAlphaMode=function(r,t){if(t===void 0&&(t=!1),this._alphaMode===r&&(r===P.Y.ALPHA_DISABLE&&!this._alphaState.alphaBlend||r!==P.Y.ALPHA_DISABLE&&this._alphaState.alphaBlend)){if(!t){var e=r===P.Y.ALPHA_DISABLE;this.depthCullingState.depthMask!==e&&(this.setDepthWrite(e),this._cacheRenderPipeline.setDepthWriteEnabled(e))}}else{switch(r){case P.Y.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case P.Y.ALPHA_PREMULTIPLIED:this._alphaState.setAlphaBlendFunctionParameters(1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA,1,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF:this._alphaState.setAlphaBlendFunctionParameters(1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA,1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_COMBINE:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_SRC_ALPHA,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA,1,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(1,1,0,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_SRC_ALPHA,1,0,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_SUBTRACT:this._alphaState.setAlphaBlendFunctionParameters(0,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR,1,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_DST_COLOR,0,1,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_SRC_ALPHA,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR,1,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_INTERPOLATE:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_CONSTANT_COLOR,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR,P.Y.GL_ALPHA_FUNCTION_CONSTANT_ALPHA,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_SCREENMODE:this._alphaState.setAlphaBlendFunctionParameters(1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR,1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ONEONE_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(1,1,1,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ALPHATOCOLOR:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_DST_ALPHA,1,0,0),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_REVERSEONEMINUS:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_SRC_DSTONEMINUSSRCALPHA:this._alphaState.setAlphaBlendFunctionParameters(1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA,1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_ONEONE_ONEZERO:this._alphaState.setAlphaBlendFunctionParameters(1,1,1,0),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_EXCLUSION:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR,0,1),this._alphaState.alphaBlend=!0;break;case P.Y.ALPHA_LAYER_ACCUMULATE:this._alphaState.setAlphaBlendFunctionParameters(P.Y.GL_ALPHA_FUNCTION_SRC_ALPHA,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA,1,P.Y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}t||(this.setDepthWrite(r===P.Y.ALPHA_DISABLE),this._cacheRenderPipeline.setDepthWriteEnabled(r===P.Y.ALPHA_DISABLE)),this._alphaMode=r,this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend),this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters,this._alphaState._blendEquationParameters)}},It.prototype.setAlphaEquation=function(r){Be.$.prototype.setAlphaEquation.call(this,r),this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters,this._alphaState._blendEquationParameters)};var KD=function(){function r(t,e){this._device=t,this._cacheSampler=e,this.uniqueId=r._Counter++,this._bindGroupEntries=[],this.clear()}return r.prototype.getBindGroups=function(t,e,n){if(!n)throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!");if(this._bindGroups.length===0){var i=this._bindGroupEntries.length>0;for(var o in t){var a=t[o],s=n[o],l=s.group,c=s.binding,u=a.type,d=a.object,h=a.indexInGroupEntries;switch((f=this._bindGroupEntries[l])||(f=this._bindGroupEntries[l]=[]),u){case 5:var p=d;h!==void 0&&i?f[h].resource=this._cacheSampler.getSampler(p):(a.indexInGroupEntries=f.length,f.push({binding:c,resource:this._cacheSampler.getSampler(p)}));break;case 0:case 4:var m=(v=d)._texture._hardwareTexture;h!==void 0&&i?(u===0&&(f[h++].resource=this._cacheSampler.getSampler(v._texture)),f[h].resource=m.view):(a.indexInGroupEntries=f.length,u===0&&f.push({binding:c-1,resource:this._cacheSampler.getSampler(v._texture)}),f.push({binding:c,resource:m.view}));break;case 1:8&(m=(v=d)._texture._hardwareTexture).textureAdditionalUsages||O.V.Error("computeDispatch: The texture (name=".concat(v.name,", uniqueId=").concat(v.uniqueId,") is not a storage texture!"),50),h!==void 0&&i?f[h].resource=m.viewForWriting:(a.indexInGroupEntries=f.length,f.push({binding:c,resource:m.viewForWriting}));break;case 6:var v,b=(v=d).underlyingResource;h!==void 0&&i?f[h].resource=this._device.importExternalTexture({source:b}):(a.indexInGroupEntries=f.length,f.push({binding:c,resource:this._device.importExternalTexture({source:b})}));break;case 2:case 3:case 7:var E=u===7?d:d.getBuffer(),C=E.underlyingResource;h!==void 0&&i?(f[h].resource.buffer=C,f[h].resource.size=E.capacity):(a.indexInGroupEntries=f.length,f.push({binding:c,resource:{buffer:C,offset:0,size:E.capacity}}))}}for(var T=0;T<this._bindGroupEntries.length;++T){var f;(f=this._bindGroupEntries[T])?this._bindGroups[T]=this._device.createBindGroup({layout:e.getBindGroupLayout(T),entries:f}):this._bindGroups[T]=void 0}this._bindGroups.length=this._bindGroupEntries.length}return this._bindGroups},r.prototype.clear=function(){this._bindGroups=[]},r._Counter=0,r}(),ZD=function(){function r(t){this._name="unnamed",this.engine=t}return Object.defineProperty(r.prototype,"isAsync",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isReady",{get:function(){return this.isAsync,!1},enumerable:!1,configurable:!0}),r.prototype._getComputeShaderCode=function(){var t;return(t=this.sources)===null||t===void 0?void 0:t.compute},r.prototype.dispose=function(){},r}(),ax={};function sl(r,t,e,n){var i,o=1;n===P.Y.TEXTURETYPE_FLOAT?i=new Float32Array(t*e*4):n===P.Y.TEXTURETYPE_HALF_FLOAT?(i=new Uint16Array(t*e*4),o=15360):i=n===P.Y.TEXTURETYPE_UNSIGNED_INTEGER?new Uint32Array(t*e*4):new Uint8Array(t*e*4);for(var a=0;a<t;a++)for(var s=0;s<e;s++){var l=3*(s*t+a),c=4*(s*t+a);i[c+0]=r[l+0],i[c+1]=r[l+1],i[c+2]=r[l+2],i[c+3]=o}return i}It.prototype.createComputeContext=function(){return new KD(this._device,this._cacheSampler)},It.prototype.createComputeEffect=function(r,t){var e=(typeof r=="string"?r:r.computeToken||r.computeSource||r.computeElement||r.compute)+"@"+t.defines;if(this._compiledComputeEffects[e]){var n=this._compiledComputeEffects[e];return t.onCompiled&&n.isReady()&&t.onCompiled(n),n}var i=new $m(r,t,this,e);return this._compiledComputeEffects[e]=i,i},It.prototype.createComputePipelineContext=function(){return new ZD(this)},It.prototype.areAllComputeEffectsReady=function(){for(var r in this._compiledComputeEffects)if(!this._compiledComputeEffects[r].isReady())return!1;return!0},It.prototype.computeDispatch=function(r,t,e,n,i,o,a,s){i===void 0&&(i=1),o===void 0&&(o=1),this._computeDispatch(r,t,e,n,i,o,void 0,void 0,a,s)},It.prototype.computeDispatchIndirect=function(r,t,e,n,i,o,a){i===void 0&&(i=0),this._computeDispatch(r,t,e,void 0,void 0,void 0,n,i,o,a)},It.prototype._computeDispatch=function(r,t,e,n,i,o,a,s,l,c){this._endCurrentRenderPass();var u=r._pipelineContext,d=t;u.computePipeline||(u.computePipeline=this._device.createComputePipeline({layout:"auto",compute:u.stage})),c&&this._timestampQuery.startPass(ax,this._timestampIndex);var h=this._renderEncoder.beginComputePass(ax);h.setPipeline(u.computePipeline);for(var p=d.getBindGroups(e,u.computePipeline,l),m=0;m<p.length;++m){var v=p[m];v&&h.setBindGroup(m,v)}a!==void 0?h.dispatchWorkgroupsIndirect(a.underlyingResource,s):n+i+o>0&&h.dispatchWorkgroups(n,i,o),h.end(),c&&(this._timestampQuery.endPass(this._timestampIndex,c),this._timestampIndex+=2)},It.prototype.releaseComputeEffects=function(){for(var r in this._compiledComputeEffects){var t=this._compiledComputeEffects[r].getPipelineContext();this._deleteComputePipelineContext(t)}this._compiledComputeEffects={}},It.prototype._prepareComputePipelineContext=function(r,t,e,n,i){var o=r;this.dbgShowShaderCode&&(O.V.Log(n),O.V.Log(t)),o.sources={compute:t,rawCompute:e},o.stage=this._createComputePipelineStageDescriptor(t,n,i)},It.prototype._releaseComputeEffect=function(r){this._compiledComputeEffects[r._key]&&(delete this._compiledComputeEffects[r._key],this._deleteComputePipelineContext(r.getPipelineContext()))},It.prototype._rebuildComputeEffects=function(){for(var r in this._compiledComputeEffects){var t=this._compiledComputeEffects[r];t._pipelineContext=null,t._wasPreviouslyReady=!1,t._prepareEffect()}},It.prototype._executeWhenComputeStateIsCompiled=function(r,t){r.stage.module.getCompilationInfo().then(function(e){for(var n={numErrors:0,messages:[]},i=0,o=e.messages;i<o.length;i++){var a=o[i];a.type==="error"&&n.numErrors++,n.messages.push({type:a.type,text:a.message,line:a.lineNum,column:a.linePos,length:a.length,offset:a.offset})}t(n)})},It.prototype._deleteComputePipelineContext=function(r){r&&r.dispose()},It.prototype._createComputePipelineStageDescriptor=function(r,t,e){return t=t?"//"+t.split(`
|
||
`).join(`
|
||
//`)+`
|
||
`:"",{module:this._device.createShaderModule({code:t+r}),entryPoint:e}},It.prototype._createDepthStencilCubeTexture=function(r,t){var e=new rn.h(this,t.generateStencil?12:14);e.isCube=!0,e.label=t.label;var n=(0,A.Cl)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,samples:1,depthTextureFormat:t.generateStencil?P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:P.Y.TEXTUREFORMAT_DEPTH32_FLOAT},t);e.format=n.depthTextureFormat,this._setupDepthStencilTexture(e,r,n.bilinearFiltering,n.comparisonFunction,n.samples),this._textureHelper.createGPUTextureForInternalTexture(e);var i=e._hardwareTexture;return e.type=en.GetTextureTypeFromFormat(i.format),this._internalTexturesCache.push(e),e},It.prototype.createCubeTexture=function(r,t,e,n,i,o,a,s,l,c,u,d,h,p,m){var v=this;return i===void 0&&(i=null),o===void 0&&(o=null),s===void 0&&(s=null),l===void 0&&(l=!1),c===void 0&&(c=0),u===void 0&&(u=0),d===void 0&&(d=null),p===void 0&&(p=!1),m===void 0&&(m=null),this.createCubeTextureBase(r,t,e,!!n,i,o,a,s,l,c,u,d,null,function(b,E){var C=E,T=C[0].width,f=T;v._setCubeMapTextureParams(b,!n),b.format=a??-1;var g=v._textureHelper.createGPUTextureForInternalTexture(b,T,f);v._textureHelper.updateCubeTextures(C,g.underlyingResource,T,f,g.format,!1,!1,0,0),n||v._generateMipmaps(b,v._uploadEncoder),b.isReady=!0,b.onLoadedObservable.notifyObservers(b),b.onLoadedObservable.clear(),i&&i()},!!p,m)},It.prototype._setCubeMapTextureParams=function(r,t,e){r.samplingMode=t?P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,r._cachedWrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,r._cachedWrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE,e&&(r._maxLodLevel=e)},It.prototype.generateMipMapsForCubemap=function(r){var t;r.generateMipMaps&&(!((t=r._hardwareTexture)===null||t===void 0)&&t.underlyingResource||this._textureHelper.createGPUTextureForInternalTexture(r),this._generateMipmaps(r))},It.prototype._debugPushGroup=function(r,t){this._options.enableGPUDebugMarkers&&(t===0||t===1?this._renderEncoder.pushDebugGroup(r):this._currentRenderPass?this._currentRenderPass.pushDebugGroup(r):this._pendingDebugCommands.push(["push",r]))},It.prototype._debugPopGroup=function(r){this._options.enableGPUDebugMarkers&&(r===0||r===1?this._renderEncoder.popDebugGroup():this._currentRenderPass?this._currentRenderPass.popDebugGroup():this._pendingDebugCommands.push(["pop",null]))},It.prototype._debugInsertMarker=function(r,t){this._options.enableGPUDebugMarkers&&(t===0||t===1?this._renderEncoder.insertDebugMarker(r):this._currentRenderPass?this._currentRenderPass.insertDebugMarker(r):this._pendingDebugCommands.push(["insert",r]))},It.prototype._debugFlushPendingCommands=function(){for(var r=0;r<this._pendingDebugCommands.length;++r){var t=this._pendingDebugCommands[r],e=t[0],n=t[1];switch(e){case"push":this._debugPushGroup(n);break;case"pop":this._debugPopGroup();break;case"insert":this._debugInsertMarker(n)}}this._pendingDebugCommands.length=0},It.prototype.createDynamicTexture=function(r,t,e,n){var i=new rn.h(this,4);return i.baseWidth=r,i.baseHeight=t,e&&(r=this.needPOTTextures?(0,ir.R)(r,this._caps.maxTextureSize):r,t=this.needPOTTextures?(0,ir.R)(t,this._caps.maxTextureSize):t),i.width=r,i.height=t,i.isReady=!1,i.generateMipMaps=e,i.samplingMode=n,this.updateTextureSamplingMode(n,i),this._internalTexturesCache.push(i),r&&t&&this._textureHelper.createGPUTextureForInternalTexture(i,r,t),i},It.prototype.updateDynamicTexture=function(r,t,e,n,i,o,a){var s;if(n===void 0&&(n=!1),r){var l=t.width,c=t.height,u=r._hardwareTexture;!((s=r._hardwareTexture)===null||s===void 0)&&s.underlyingResource||(u=this._textureHelper.createGPUTextureForInternalTexture(r,l,c)),this._textureHelper.updateTexture(t,r,l,c,r.depth,u.format,0,0,e,n,0,0,a),r.generateMipMaps&&this._generateMipmaps(r),r._dynamicTextureSource=t,r._premulAlpha=n,r.invertY=e||!1,r.isReady=!0}},It.prototype.unBindMultiColorAttachmentFramebuffer=function(r,t,e){t===void 0&&(t=!1),e&&e();var n=r._attachments.length;this._endCurrentRenderPass();for(var i=0;i<n;i++){var o=r.textures[i];!o.generateMipMaps||t||o.isCube||o.is3D||this._generateMipmaps(o)}this._currentRenderTarget=null,this._mrtAttachments=[],this._cacheRenderPipeline.setMRT([]),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)},It.prototype.createMultipleRenderTarget=function(r,t,e){var n,i,o,a,s=!1,l=!0,c=!1,u=!1,d=P.Y.TEXTUREFORMAT_DEPTH16,h=1,p=P.Y.TEXTURETYPE_UNSIGNED_INT,m=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,v=P.Y.TEXTUREFORMAT_RGBA,b=P.Y.TEXTURE_2D,E=[],C=[],T=[],f=[],g=[],S=[],y=[],x=[],R=[],I=this._createHardwareRenderTargetWrapper(!0,!1,r);t!==void 0&&(s=t.generateMipMaps!==void 0&&t.generateMipMaps,l=t.generateDepthBuffer===void 0||t.generateDepthBuffer,c=t.generateStencilBuffer!==void 0&&t.generateStencilBuffer,u=t.generateDepthTexture!==void 0&&t.generateDepthTexture,h=t.textureCount||1,d=(n=t.depthTextureFormat)!==null&&n!==void 0?n:P.Y.TEXTUREFORMAT_DEPTH16,t.types&&(E=t.types),t.samplingModes&&(C=t.samplingModes),t.useSRGBBuffers&&(T=t.useSRGBBuffers),t.formats&&(f=t.formats),t.targetTypes&&(g=t.targetTypes),t.faceIndex&&(S=t.faceIndex),t.layerIndex&&(y=t.layerIndex),t.layerCounts&&(x=t.layerCounts),R=(i=t.labels)!==null&&i!==void 0?i:R),I.label=(o=t?.label)!==null&&o!==void 0?o:"MultiRenderTargetWrapper";var M=r.width||r,D=r.height||r,B=null;(l||c||u)&&(u||(d=l&&c?P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:l?P.Y.TEXTUREFORMAT_DEPTH32_FLOAT:P.Y.TEXTUREFORMAT_STENCIL8),B=I.createDepthStencilTexture(0,!1,c,1,d,"MultipleRenderTargetDepthStencil"));var F=[],X=[],$=[];I._generateDepthBuffer=l,I._generateStencilBuffer=c,I._attachments=X,I._defaultAttachments=$;for(var Q=0;Q<h;Q++){var ie=C[Q]||m,q=E[Q]||p,ee=f[Q]||v,te=!!T[Q]&&this._caps.supportSRGBBuffers,ce=g[Q]||b,fe=(a=x[Q])!==null&&a!==void 0?a:1;if((q!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(q!==P.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(ie=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),q!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloat||(q=P.Y.TEXTURETYPE_UNSIGNED_INT,O.V.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),X.push(Q+1),$.push(e?Q+1:Q===0?1:0),ce!==-1){var de=new rn.h(this,6);switch(F[Q]=de,ce){case P.Y.TEXTURE_CUBE_MAP:de.isCube=!0;break;case P.Y.TEXTURE_3D:de.is3D=!0,de.baseDepth=de.depth=fe;break;case P.Y.TEXTURE_2D_ARRAY:de.is2DArray=!0,de.baseDepth=de.depth=fe}de.baseWidth=M,de.baseHeight=D,de.width=M,de.height=D,de.isReady=!0,de.samples=1,de.generateMipMaps=s,de.samplingMode=ie,de.type=q,de._cachedWrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,de._cachedWrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE,de._useSRGBBuffer=te,de.format=ee,de.label=R[Q],this._internalTexturesCache.push(de),this._textureHelper.createGPUTextureForInternalTexture(de)}}return B&&(B.incrementReferences(),F[h]=B,this._internalTexturesCache.push(B)),I.setTextures(F),I.setLayerAndFaceIndices(y,S),I},It.prototype.updateMultipleRenderTargetTextureSampleCount=function(r,t){if(!r||!r.textures||r.textures[0].samples===t)return t;var e=r.textures.length;if(e===0)return 1;t=Math.min(t,this.getCaps().maxMSAASamples);for(var n=0;n<e;++n){var i=(a=r.textures[n])._hardwareTexture;i?.releaseMSAATexture()}var o=r._depthStencilTexture===r.textures[e-1];for(n=0;n<e;++n){var a=r.textures[n];this._textureHelper.createMSAATexture(a,t,!1,n===e-1&&o?0:n),a.samples=t}return r._depthStencilTexture&&!o&&(this._textureHelper.createMSAATexture(r._depthStencilTexture,t),r._depthStencilTexture.samples=t),t},It.prototype.bindAttachments=function(r){r.length!==0&&this._currentRenderTarget&&(this._mrtAttachments=r,this._currentRenderPass&&this._cacheRenderPipeline.setMRTAttachments(r))},It.prototype.buildTextureLayout=function(r){for(var t=[],e=0;e<r.length;e++)r[e]?t.push(e+1):t.push(0);return t},It.prototype.restoreSingleAttachment=function(){},It.prototype.restoreSingleAttachmentForRenderTarget=function(){},It.prototype.getGPUFrameTimeCounter=function(){return this._timestampQuery.gpuFrameTimeCounter},It.prototype.captureGPUFrameTime=function(r){this._timestampQuery.enable=r&&!!this._caps.timerQuery},It.prototype.createQuery=function(){return this._occlusionQuery.createQuery()},It.prototype.deleteQuery=function(r){return this._occlusionQuery.deleteQuery(r),this},It.prototype.isQueryResultAvailable=function(r){return this._occlusionQuery.isQueryResultAvailable(r)},It.prototype.getQueryResult=function(r){return this._occlusionQuery.getQueryResult(r)},It.prototype.beginOcclusionQuery=function(r,t){var e;return this.compatibilityMode?!!this._occlusionQuery.canBeginQuery(t)&&((e=this._currentRenderPass)===null||e===void 0||e.beginOcclusionQuery(t),!0):(this._bundleList.addItem(new VD(t)),!0)},It.prototype.endOcclusionQuery=function(){var r;return this.compatibilityMode?(r=this._currentRenderPass)===null||r===void 0||r.endOcclusionQuery():this._bundleList.addItem(new UD),this},It.prototype.createRawTexture=function(r,t,e,n,i,o,a,s,l,c,u){s===void 0&&(s=null),l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT),c===void 0&&(c=0),u===void 0&&(u=!1);var d=new rn.h(this,3);return d.baseWidth=t,d.baseHeight=e,d.width=t,d.height=e,d.format=n,d.generateMipMaps=i,d.samplingMode=a,d.invertY=o,d._compression=s,d.type=l,d._creationFlags=c,d._useSRGBBuffer=u,this._doNotHandleContextLost||(d._bufferView=r),this._textureHelper.createGPUTextureForInternalTexture(d,t,e,void 0,c),this.updateRawTexture(d,r,n,o,s,l,u),this._internalTexturesCache.push(d),d},It.prototype.updateRawTexture=function(r,t,e,n,i,o,a){if(i===void 0&&(i=null),o===void 0&&(o=P.Y.TEXTURETYPE_UNSIGNED_INT),a===void 0&&(a=!1),r){if(this._doNotHandleContextLost||(r._bufferView=t,r.invertY=n,r._compression=i,r._useSRGBBuffer=a),t){var s=r._hardwareTexture;e===P.Y.TEXTUREFORMAT_RGB&&(t=sl(t,r.width,r.height,o));var l=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(l,r,r.width,r.height,r.depth,s.format,0,0,n,!1,0,0),r.generateMipMaps&&this._generateMipmaps(r,this._uploadEncoder)}r.isReady=!0}},It.prototype.createRawCubeTexture=function(r,t,e,n,i,o,a,s){s===void 0&&(s=null);var l=new rn.h(this,8);return n!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?n!==P.Y.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering?n!==P.Y.TEXTURETYPE_FLOAT||this._caps.textureFloatRender?n!==P.Y.TEXTURETYPE_HALF_FLOAT||this._caps.colorBufferFloat||(i=!1,O.V.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(i=!1,O.V.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(i=!1,a=P.Y.TEXTURE_NEAREST_SAMPLINGMODE,O.V.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(i=!1,a=P.Y.TEXTURE_NEAREST_SAMPLINGMODE,O.V.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")),l.isCube=!0,l._originalFormat=e,l.format=e===P.Y.TEXTUREFORMAT_RGB?P.Y.TEXTUREFORMAT_RGBA:e,l.type=n,l.generateMipMaps=i,l.width=t,l.height=t,l.samplingMode=a,this._doNotHandleContextLost||(l._bufferViewArray=r),l.invertY=o,l._compression=s,l._cachedWrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,l._cachedWrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE,this._textureHelper.createGPUTextureForInternalTexture(l),e===P.Y.TEXTUREFORMAT_RGB&&(l._hardwareTexture._originalFormatIsRGB=!0),r&&this.updateRawCubeTexture(l,r,e,n,o,s),l.isReady=!0,l},It.prototype.updateRawCubeTexture=function(r,t,e,n,i,o){o===void 0&&(o=null),r._bufferViewArray=t,r.invertY=i,r._compression=o;for(var a=r._hardwareTexture,s=a._originalFormatIsRGB,l=[0,2,4,1,3,5],c=[],u=0;u<t.length;++u){var d=t[l[u]];s&&(d=sl(d,r.width,r.height,n)),c.push(new Uint8Array(d.buffer,d.byteOffset,d.byteLength))}this._textureHelper.updateCubeTextures(c,a.underlyingResource,r.width,r.height,a.format,i,!1,0,0),r.generateMipMaps&&this._generateMipmaps(r,this._uploadEncoder),r.isReady=!0},It.prototype.createRawCubeTextureFromUrl=function(r,t,e,n,i,o,a,s,l,c,u,d){var h=this;l===void 0&&(l=null),c===void 0&&(c=null),u===void 0&&(u=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),d===void 0&&(d=!1);var p=this.createRawCubeTexture(null,e,n,i,!o,d,u,null);return t?.addPendingData(p),p.url=r,p.isReady=!1,this._internalTexturesCache.push(p),this._loadFile(r,function(m){(function(v){var b=p.width,E=a(v);if(E){if(s)for(var C=n===P.Y.TEXTUREFORMAT_RGB,T=s(E),f=p._hardwareTexture,g=[0,1,2,3,4,5],S=0;S<T.length;S++){for(var y=b>>S,x=[],R=0;R<6;R++){var I=T[S][g[R]];C&&(I=sl(I,y,y,i)),x.push(new Uint8Array(I.buffer,I.byteOffset,I.byteLength))}h._textureHelper.updateCubeTextures(x,f.underlyingResource,y,y,f.format,d,!1,0,0)}else h.updateRawCubeTexture(p,E,n,i,d);p.isReady=!0,t?.removePendingData(p),l&&l()}})(m)},void 0,t?.offlineProvider,!0,function(m,v){t?.removePendingData(p),c&&m&&c(m.status+" "+m.statusText,v)}),p},It.prototype.createRawTexture3D=function(r,t,e,n,i,o,a,s,l,c,u){l===void 0&&(l=null),c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=0);var d=new rn.h(this,10);return d.baseWidth=t,d.baseHeight=e,d.baseDepth=n,d.width=t,d.height=e,d.depth=n,d.format=i,d.type=c,d.generateMipMaps=o,d.samplingMode=s,d.is3D=!0,d._creationFlags=u,this._doNotHandleContextLost||(d._bufferView=r),this._textureHelper.createGPUTextureForInternalTexture(d,t,e,void 0,u),this.updateRawTexture3D(d,r,i,a,l,c),this._internalTexturesCache.push(d),d},It.prototype.updateRawTexture3D=function(r,t,e,n,i,o){if(i===void 0&&(i=null),o===void 0&&(o=P.Y.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(r._bufferView=t,r.format=e,r.invertY=n,r._compression=i),t){var a=r._hardwareTexture;e===P.Y.TEXTUREFORMAT_RGB&&(t=sl(t,r.width,r.height,o));var s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(s,r,r.width,r.height,r.depth,a.format,0,0,n,!1,0,0),r.generateMipMaps&&this._generateMipmaps(r,this._uploadEncoder)}r.isReady=!0},It.prototype.createRawTexture2DArray=function(r,t,e,n,i,o,a,s,l,c,u){l===void 0&&(l=null),c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=0);var d=new rn.h(this,11);return d.baseWidth=t,d.baseHeight=e,d.baseDepth=n,d.width=t,d.height=e,d.depth=n,d.format=i,d.type=c,d.generateMipMaps=o,d.samplingMode=s,d.is2DArray=!0,d._creationFlags=u,this._doNotHandleContextLost||(d._bufferView=r),this._textureHelper.createGPUTextureForInternalTexture(d,t,e,n,u),this.updateRawTexture2DArray(d,r,i,a,l,c),this._internalTexturesCache.push(d),d},It.prototype.updateRawTexture2DArray=function(r,t,e,n,i,o){if(i===void 0&&(i=null),o===void 0&&(o=P.Y.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(r._bufferView=t,r.format=e,r.invertY=n,r._compression=i),t){var a=r._hardwareTexture;e===P.Y.TEXTUREFORMAT_RGB&&(t=sl(t,r.width,r.height,o));var s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(s,r,r.width,r.height,r.depth,a.format,0,0,n,!1,0,0),r.generateMipMaps&&this._generateMipmaps(r,this._uploadEncoder)}r.isReady=!0},It.prototype._readTexturePixels=function(r,t,e,n,i,o,a,s,l,c){n===void 0&&(n=-1),i===void 0&&(i=0),o===void 0&&(o=null),a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=0),c===void 0&&(c=0);var u=r._hardwareTexture;return a&&this.flushFramebuffer(),this._textureHelper.readPixels(u.underlyingResource,l,c,t,e,u.format,n,i,o,s)},It.prototype._readTexturePixelsSync=function(){throw"_readTexturePixelsSync is unsupported in WebGPU!"};var Lg=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,i,o,a)||this;return o.enableGPUTimingMeasurements&&(s.gpuTimeInFrame=new ix.e),s}return(0,A.C6)(t,r),t}(nl.v);It.prototype._createHardwareRenderTargetWrapper=function(r,t,e){var n=new Lg(r,t,e,this);return this._renderTargetWrapperCache.push(n),n},It.prototype.createRenderTargetTexture=function(r,t){var e,n,i,o=this._createHardwareRenderTargetWrapper(!1,!1,r),a={};t!==void 0&&typeof t=="object"?(a.generateMipMaps=t.generateMipMaps,a.generateDepthBuffer=t.generateDepthBuffer===void 0||t.generateDepthBuffer,a.generateStencilBuffer=a.generateDepthBuffer&&t.generateStencilBuffer,a.samplingMode=t.samplingMode===void 0?P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,a.creationFlags=(e=t.creationFlags)!==null&&e!==void 0?e:0,a.noColorAttachment=!!t.noColorAttachment,a.colorAttachment=t.colorAttachment,a.samples=t.samples,a.label=t.label):(a.generateMipMaps=t,a.generateDepthBuffer=!0,a.generateStencilBuffer=!1,a.samplingMode=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,a.creationFlags=0,a.noColorAttachment=!1);var s=a.colorAttachment||(a.noColorAttachment?null:this._createInternalTexture(r,t,!0,5));return o.label=(n=a.label)!==null&&n!==void 0?n:"RenderTargetWrapper",o._samples=(i=a.samples)!==null&&i!==void 0?i:1,o._generateDepthBuffer=a.generateDepthBuffer,o._generateStencilBuffer=!!a.generateStencilBuffer,o.setTextures(s),(o._generateDepthBuffer||o._generateStencilBuffer)&&o.createDepthStencilTexture(0,!1,o._generateStencilBuffer,o.samples,a.generateStencilBuffer?P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:P.Y.TEXTUREFORMAT_DEPTH32_FLOAT,a.label?a.label+"-DepthStencil":void 0),s&&(t!==void 0&&typeof t=="object"&&t.createMipMaps&&!a.generateMipMaps&&(s.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(s,void 0,void 0,void 0,a.creationFlags),t!==void 0&&typeof t=="object"&&t.createMipMaps&&!a.generateMipMaps&&(s.generateMipMaps=!1)),o},It.prototype._createDepthStencilTexture=function(r,t,e){var n=(0,A.Cl)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,samples:1,depthTextureFormat:t.generateStencil?P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:P.Y.TEXTUREFORMAT_DEPTH32_FLOAT},t),i=n.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||n.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8||n.depthTextureFormat===P.Y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8;e._depthStencilTextureWithStencil=i;var o=new rn.h(this,i?12:14);o.label=t.label,o.format=n.depthTextureFormat,this._setupDepthStencilTexture(o,r,n.bilinearFiltering,n.comparisonFunction,n.samples),this._textureHelper.createGPUTextureForInternalTexture(o);var a=o._hardwareTexture;return o.type=en.GetTextureTypeFromFormat(a.format),this._internalTexturesCache.push(o),o},It.prototype._setupDepthStencilTexture=function(r,t,e,n,i){i===void 0&&(i=1);var o=t.width||t,a=t.height||t,s=t.layers||0,l=t.depth||0;r.baseWidth=o,r.baseHeight=a,r.width=o,r.height=a,r.is2DArray=s>0,r.is3D=l>0,r.depth=s||l,r.isReady=!0,r.samples=i,r.generateMipMaps=!1,r.samplingMode=e?P.Y.TEXTURE_BILINEAR_SAMPLINGMODE:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,r.type=P.Y.TEXTURETYPE_FLOAT,r._comparisonFunction=n,r._cachedWrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,r._cachedWrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE},It.prototype.updateRenderTargetTextureSampleCount=function(r,t){return r&&r.texture&&r.samples!==t&&(t=Math.min(t,this.getCaps().maxMSAASamples),this._textureHelper.createMSAATexture(r.texture,t),r._depthStencilTexture&&(this._textureHelper.createMSAATexture(r._depthStencilTexture,t),r._depthStencilTexture.samples=t),r._samples=t,r.texture.samples=t),t},It.prototype.createRenderTargetCubeTexture=function(r,t){var e,n=this._createHardwareRenderTargetWrapper(!1,!0,r),i=(0,A.Cl)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:P.Y.TEXTURETYPE_UNSIGNED_INT,samplingMode:P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,format:P.Y.TEXTUREFORMAT_RGBA,samples:1},t);i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,n.label=(e=i.label)!==null&&e!==void 0?e:"RenderTargetWrapper",n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=i.generateStencilBuffer;var o=new rn.h(this,5);return o.width=r,o.height=r,o.depth=0,o.isReady=!0,o.isCube=!0,o.samples=i.samples,o.generateMipMaps=i.generateMipMaps,o.samplingMode=i.samplingMode,o.type=i.type,o.format=i.format,this._internalTexturesCache.push(o),n.setTextures(o),(n._generateDepthBuffer||n._generateStencilBuffer)&&n.createDepthStencilTexture(0,i.samplingMode===void 0||i.samplingMode===P.Y.TEXTURE_BILINEAR_SAMPLINGMODE||i.samplingMode===P.Y.TEXTURE_LINEAR_LINEAR||i.samplingMode===P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE||i.samplingMode===P.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR||i.samplingMode===P.Y.TEXTURE_NEAREST_LINEAR_MIPNEAREST||i.samplingMode===P.Y.TEXTURE_NEAREST_LINEAR_MIPLINEAR||i.samplingMode===P.Y.TEXTURE_NEAREST_LINEAR||i.samplingMode===P.Y.TEXTURE_LINEAR_LINEAR_MIPNEAREST,n._generateStencilBuffer,n.samples),t&&t.createMipMaps&&!i.generateMipMaps&&(o.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(o),t&&t.createMipMaps&&!i.generateMipMaps&&(o.generateMipMaps=!1),n},It.prototype.setDepthStencilTexture=function(r,t,e,n){e&&e.depthStencilTexture?this._setTexture(r,e,!1,!0,n):this._setTexture(r,null,void 0,void 0,n)},It.prototype.updateVideoTexture=function(r,t,e){var n,i=this;if(r&&!r._isDisabled){this._videoTextureSupported===void 0&&(this._videoTextureSupported=!0);var o=r._hardwareTexture;if(!((n=r._hardwareTexture)===null||n===void 0)&&n.underlyingResource||(o=this._textureHelper.createGPUTextureForInternalTexture(r)),function(a){return!(!a||a.underlyingResource===void 0)}(t)){if(t.isReady()){try{this._textureHelper.copyVideoToTexture(t,r,o.format,!e),r.generateMipMaps&&this._generateMipmaps(r)}catch{}r.isReady=!0}}else t&&this.createImageBitmap(t).then(function(a){i._textureHelper.updateTexture(a,r,r.width,r.height,r.depth,o.format,0,0,!e,!1,0,0),r.generateMipMaps&&i._generateMipmaps(r),r.isReady=!0}).catch(function(){r.isReady=!0})}};var sx=L(14737),lx=L(24054),cx=function(){function r(){}return r.CreateAsync=function(t,e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return[4,It.IsSupportedAsync];case 1:return n.sent()?[2,It.CreateAsync(t,e)]:Zt.IsSupported?[2,new Zt(t,void 0,e)]:[2,new pg(e)]}})})},r}(),ll=function(){function r(){}return r.COPY=1,r.CUT=2,r.PASTE=3,r}(),ux=function(){function r(t,e){this.type=t,this.event=e}return r.GetTypeFromCharacter=function(t){switch(t){case 67:return ll.COPY;case 86:return ll.PASTE;case 88:return ll.CUT;default:return-1}},r}(),Ha=function(r){function t(e,n,i,o,a,s,l){var c;n===void 0&&(n=z.v9.Gray()),i===void 0&&(i=Fn.DefaultUtilityLayer),o===void 0&&(o=null),a===void 0&&(a=1),s===void 0&&(s=z.v9.Yellow()),l===void 0&&(l=z.v9.Gray());var u,d,h,p,m,v,b,E=this;(E=r.call(this,i)||this)._pointerObserver=null,E.snapDistance=0,E.onSnapObservable=new K.cP,E.uniformScaling=!1,E.sensitivity=1,E.dragScale=1,E.incrementalSnap=!1,E._isEnabled=!0,E._parent=null,E._dragging=!1,E._tmpVector=new _.Pq(0,0,0),E._incrementalStartupValue=_.Pq.Zero(),E._parent=o,E._coloredMaterial=new qt("",i.utilityLayerScene),E._coloredMaterial.diffuseColor=n,E._coloredMaterial.specularColor=n.subtract(new z.v9(.1,.1,.1)),E._hoverMaterial=new qt("",i.utilityLayerScene),E._hoverMaterial.diffuseColor=s,E._disableMaterial=new qt("",i.utilityLayerScene),E._disableMaterial.diffuseColor=l,E._disableMaterial.alpha=.4,E._gizmoMesh=new xe("axis",i.utilityLayerScene);var C=(c=E._createGizmoMesh(E._gizmoMesh,a)).arrowMesh,T=c.arrowTail,f=E._createGizmoMesh(E._gizmoMesh,a+4,!0);E._gizmoMesh.lookAt(E._rootMesh.position.add(e)),E._rootMesh.addChild(E._gizmoMesh,Jn.PreserveScaling),E._gizmoMesh.scaling.scaleInPlace(1/3);var g=C.position.clone(),S=T.position.clone(),y=T.scaling.clone(),x=function(X){var $=X*(3/E._rootMesh.scaling.length())*6;C.position.z+=$/3.5,T.scaling.y+=$,E.dragScale=T.scaling.y,T.position.z=C.position.z/2},R=function(){C.position.set(g.x,g.y,g.z),T.position.set(S.x,S.y,S.z),T.scaling.set(y.x,y.y,y.z),E.dragScale=T.scaling.y,E._dragging=!1};E.dragBehavior=new Gr({dragAxis:e}),E.dragBehavior.moveAttached=!1,E.dragBehavior.updateDragPlane=!1,E._rootMesh.addBehavior(E.dragBehavior);var I=0,M=0,D={snapDistance:0};E.dragBehavior.onDragObservable.add(function(X){if(E.attachedNode){var $=E.sensitivity*X.dragDistance*(3*E.scaleRatio/E._rootMesh.scaling.length()),Q=E._tmpVector,ie=!1,q=0;if(E.uniformScaling?Q.setAll(.57735):Q.copyFrom(e),E.snapDistance==0)Q.scaleToRef($,Q);else{I+=$,M+=$;var ee=E.incrementalSnap?M:I;Math.abs(ee)>E.snapDistance?(q=Math.floor(Math.abs(ee)/E.snapDistance),ee<0&&(q*=-1),I%=E.snapDistance,Q.scaleToRef(E.snapDistance*q,Q),ie=!0):Q.scaleInPlace(0)}Q.addInPlaceFromFloats(1,1,1),Q.x=Math.abs(Q.x)<t.MinimumAbsoluteScale?t.MinimumAbsoluteScale*(Q.x<0?-1:1):Q.x,Q.y=Math.abs(Q.y)<t.MinimumAbsoluteScale?t.MinimumAbsoluteScale*(Q.y<0?-1:1):Q.y,Q.z=Math.abs(Q.z)<t.MinimumAbsoluteScale?t.MinimumAbsoluteScale*(Q.z<0?-1:1):Q.z;var te=E.attachedNode._isMesh?E.attachedNode:void 0;Math.abs(E.snapDistance)>0&&E.incrementalSnap?(E.attachedNode.getWorldMatrix().decompose(void 0,_.AA.Quaternion[0],_.AA.Vector3[2],Jn.PreserveScaling?te:void 0),Q.addInPlace(E._incrementalStartupValue),Q.addInPlaceFromFloats(-1,-1,-1),Q.x=Math.abs(Q.x)*(E._incrementalStartupValue.x>0?1:-1),Q.y=Math.abs(Q.y)*(E._incrementalStartupValue.y>0?1:-1),Q.z=Math.abs(Q.z)*(E._incrementalStartupValue.z>0?1:-1),_.uq.ComposeToRef(Q,_.AA.Quaternion[0],_.AA.Vector3[2],_.AA.Matrix[1])):(_.uq.ScalingToRef(Q.x,Q.y,Q.z,_.AA.Matrix[2]),_.AA.Matrix[2].multiplyToRef(E.attachedNode.getWorldMatrix(),_.AA.Matrix[1])),_.AA.Matrix[1].decompose(_.AA.Vector3[1],void 0,void 0,Jn.PreserveScaling?te:void 0);var ce=1e5;Math.abs(_.AA.Vector3[1].x)<ce&&Math.abs(_.AA.Vector3[1].y)<ce&&Math.abs(_.AA.Vector3[1].z)<ce&&E.attachedNode.getWorldMatrix().copyFrom(_.AA.Matrix[1]),ie&&(D.snapDistance=E.snapDistance*q,E.onSnapObservable.notifyObservers(D)),E._matrixChanged()}}),E.dragBehavior.onDragStartObservable.add(function(){var X;E._dragging=!0;var $=E.attachedNode._isMesh?E.attachedNode:void 0;(X=E.attachedNode)===null||X===void 0||X.getWorldMatrix().decompose(E._incrementalStartupValue,void 0,void 0,Jn.PreserveScaling?$:void 0),I=0,M=0}),E.dragBehavior.onDragObservable.add(function(X){return x(X.dragDistance)}),E.dragBehavior.onDragEndObservable.add(R),(h=(d=(u=o?.uniformScaleGizmo)===null||u===void 0?void 0:u.dragBehavior)===null||d===void 0?void 0:d.onDragObservable)===null||h===void 0||h.add(function(X){return x(X.delta.y)}),(v=(m=(p=o?.uniformScaleGizmo)===null||p===void 0?void 0:p.dragBehavior)===null||m===void 0?void 0:m.onDragEndObservable)===null||v===void 0||v.add(R);var B={gizmoMeshes:[C,T],colliderMeshes:[f.arrowMesh,f.arrowTail],material:E._coloredMaterial,hoverMaterial:E._hoverMaterial,disableMaterial:E._disableMaterial,active:!1,dragBehavior:E.dragBehavior};(b=E._parent)===null||b===void 0||b.addToAxisCache(E._gizmoMesh,B),E._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(X){var $,Q,ie,q;if(!E._customMeshSet){var ee=($=E._parent)===null||$===void 0?void 0:$.getAxisCache(E._gizmoMesh);if(E._isHovered=!(!ee||ee.colliderMeshes.indexOf((Q=X?.pickInfo)===null||Q===void 0?void 0:Q.pickedMesh)==-1),ee=(ie=E._parent)===null||ie===void 0?void 0:ie.getAxisCache(E._rootMesh),E._isHovered||(E._isHovered=!(!ee||ee.colliderMeshes.indexOf((q=X?.pickInfo)===null||q===void 0?void 0:q.pickedMesh)==-1)),!E._parent){var te=E.dragBehavior.enabled?E._isHovered||E._dragging?E._hoverMaterial:E._coloredMaterial:E._disableMaterial;E._setGizmoMeshMaterial(B.gizmoMeshes,te)}}}),E.dragBehavior.onEnabledObservable.add(function(X){E._setGizmoMeshMaterial(B.gizmoMeshes,X?E._coloredMaterial:E._disableMaterial)});var F=i._getSharedGizmoLight();return F.includedOnlyMeshes=F.includedOnlyMeshes.concat(E._rootMesh.getChildMeshes()),E}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),t.prototype._createGizmoMesh=function(e,n,i){i===void 0&&(i=!1);var o=Oi("yPosMesh",{size:.4*(1+(n-1)/4)},this.gizmoLayer.utilityLayerScene),a=_i("cylinder",{diameterTop:.005*n,height:.275,diameterBottom:.005*n,tessellation:96},this.gizmoLayer.utilityLayerScene);return o.scaling.scaleInPlace(.1),o.material=this._coloredMaterial,o.rotation.x=Math.PI/2,o.position.z+=.3,a.material=this._coloredMaterial,a.position.z+=.1375,a.rotation.x=Math.PI/2,i&&(o.visibility=0,a.visibility=0),e.addChild(o),e.addChild(a),{arrowMesh:o,arrowTail:a}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(e){e&&e.dispose()}),r.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(e,n){var i=this;n===void 0&&(n=!1),r.prototype.setCustomMesh.call(this,e),n&&(this._rootMesh.getChildMeshes().forEach(function(o){o.material=i._coloredMaterial,o.color&&(o.color=i._coloredMaterial.diffuseColor)}),this._customMeshSet=!1)},t.MinimumAbsoluteScale=pt.bH,t}(Jn),Fg=function(r){function t(e,n){e===void 0&&(e=z.v9.Gray()),n===void 0&&(n=Fn.DefaultKeepDepthUtilityLayer);var i=r.call(this,n)||this;i._boundingDimensions=new _.Pq(1,1,1),i._renderObserver=null,i._pointerObserver=null,i._scaleDragSpeed=.2,i._rotateAnchorsDragBehaviors=[],i._scaleBoxesDragBehaviors=[],i._dragging=!1,i._tmpQuaternion=new _.PT,i._tmpVector=new _.Pq(0,0,0),i._tmpRotationMatrix=new _.uq,i._incrementalStartupValue=_.Pq.Zero(),i._incrementalAnchorStartupValue=_.Pq.Zero(),i.ignoreChildren=!1,i.includeChildPredicate=null,i.rotationSphereSize=.1,i.scaleBoxSize=.1,i.fixedDragMeshScreenSize=!1,i.fixedDragMeshBoundsSize=!1,i.fixedDragMeshScreenSizeDistanceFactor=10,i.scalingSnapDistance=0,i.rotationSnapDistance=0,i.onDragStartObservable=new K.cP,i.onScaleBoxDragObservable=new K.cP,i.onScaleBoxDragEndObservable=new K.cP,i.onRotationSphereDragObservable=new K.cP,i.onRotationSphereDragEndObservable=new K.cP,i.scalePivot=null,i._axisFactor=new _.Pq(1,1,1),i.incrementalSnap=!1,i._existingMeshScale=new _.Pq,i._dragMesh=null,i._pointerDragBehavior=new Gr,i._cornerMesh=null,i.updateScale=!1,i._anchorMesh=new jt("anchor",n.utilityLayerScene),i._coloredMaterial=new qt("",n.utilityLayerScene),i._coloredMaterial.disableLighting=!0,i._hoverColoredMaterial=new qt("",n.utilityLayerScene),i._hoverColoredMaterial.disableLighting=!0,i._lineBoundingBox=new jt("",n.utilityLayerScene),i._lineBoundingBox.rotationQuaternion=new _.PT;var o=[];o.push(dn("lines",{points:[new _.Pq(0,0,0),new _.Pq(i._boundingDimensions.x,0,0)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(0,0,0),new _.Pq(0,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(0,0,0),new _.Pq(0,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(i._boundingDimensions.x,0,0),new _.Pq(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(i._boundingDimensions.x,0,0),new _.Pq(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(0,i._boundingDimensions.y,0),new _.Pq(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(0,i._boundingDimensions.y,0),new _.Pq(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(0,0,i._boundingDimensions.z),new _.Pq(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(0,0,i._boundingDimensions.z),new _.Pq(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new _.Pq(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new _.Pq(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),o.push(dn("lines",{points:[new _.Pq(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new _.Pq(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),o.forEach(function(m){m.color=e,m.position.addInPlace(new _.Pq(-i._boundingDimensions.x/2,-i._boundingDimensions.y/2,-i._boundingDimensions.z/2)),m.isPickable=!1,i._lineBoundingBox.addChild(m)}),i._rootMesh.addChild(i._lineBoundingBox),i.setColor(e),i._rotateAnchorsParent=new jt("",n.utilityLayerScene),i._rotateAnchorsParent.rotationQuaternion=new _.PT;for(var a=function(m){var v=Oi("",{width:m<4||m>=8?1.6:.4,height:m>=4&&m<8?1.6:.4,depth:.4},n.utilityLayerScene);v.rotation.x=m<4||m>=8?.25*Math.PI:0,v.rotation.y=m>=4&&m<8?.25*Math.PI:0,v.bakeTransformIntoVertices(v.computeWorldMatrix(!0)),v.rotationQuaternion=new _.PT,v.material=s._coloredMaterial,v.isNearGrabbable=!0;var b=new Gr({});b.moveAttached=!1,b.updateDragPlane=!1,v.addBehavior(b);var E=new _.Pq(1,0,0),C=0,T=0;b.onDragStartObservable.add(function(){E.copyFrom(v.forward),C=0,T=0}),b.onDragObservable.add(function(f){if(i.onRotationSphereDragObservable.notifyObservers({}),i.attachedMesh){var g=i.attachedMesh.parent;if(g&&g.scaling&&g.scaling.isNonUniformWithinEpsilon(.001))return void O.V.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");Gi._RemoveAndStorePivotPoint(i.attachedMesh);var S=E,y=f.dragPlaneNormal.scale(_.Pq.Dot(f.dragPlaneNormal,S)),x=S.subtract(y).normalizeToNew(),R=_.Pq.Dot(x,f.delta)<0?Math.abs(f.delta.length()):-Math.abs(f.delta.length());if(R=R/i._boundingDimensions.length()*i._anchorMesh.scaling.length(),i.attachedMesh.rotationQuaternion||(i.attachedMesh.rotationQuaternion=_.PT.RotationYawPitchRoll(i.attachedMesh.rotation.y,i.attachedMesh.rotation.x,i.attachedMesh.rotation.z)),i._anchorMesh.rotationQuaternion||(i._anchorMesh.rotationQuaternion=_.PT.RotationYawPitchRoll(i._anchorMesh.rotation.y,i._anchorMesh.rotation.x,i._anchorMesh.rotation.z)),C+=R,Math.abs(C)<=2*Math.PI){if(i.rotationSnapDistance>0){var I=Math.floor(Math.abs(C)/i.rotationSnapDistance)*(C<0?-1:1),M=i.rotationSnapDistance*I;R=M-T,T=M}m>=8?_.PT.RotationYawPitchRollToRef(0,0,R,i._tmpQuaternion):m>=4?_.PT.RotationYawPitchRollToRef(R,0,0,i._tmpQuaternion):_.PT.RotationYawPitchRollToRef(0,R,0,i._tmpQuaternion),i.attachedMesh.isUsingPivotMatrix()&&i._anchorMesh.position.copyFrom(i.attachedMesh.position),i._anchorMesh.addChild(i.attachedMesh),i._anchorMesh.getScene().useRightHandedSystem&&i._tmpQuaternion.conjugateInPlace(),i._tmpQuaternion.normalize(),i._anchorMesh.rotationQuaternion.multiplyToRef(i._tmpQuaternion,i._anchorMesh.rotationQuaternion),i._anchorMesh.rotationQuaternion.normalize(),i._anchorMesh.removeChild(i.attachedMesh),i.attachedMesh.setParent(g)}i.updateBoundingBox(),Gi._RestorePivotPoint(i.attachedMesh)}i._updateDummy()}),b.onDragStartObservable.add(function(){i.onDragStartObservable.notifyObservers({}),i._dragging=!0,i._selectNode(v)}),b.onDragEndObservable.add(function(f){i.onRotationSphereDragEndObservable.notifyObservers({}),i._dragging=!1,i._selectNode(null),i._updateDummy(),i._unhoverMeshOnTouchUp(f.pointerInfo,v)}),s._rotateAnchorsDragBehaviors.push(b),s._rotateAnchorsParent.addChild(v)},s=this,l=0;l<12;l++)a(l);for(i._rootMesh.addChild(i._rotateAnchorsParent),i._scaleBoxesParent=new jt("",n.utilityLayerScene),i._scaleBoxesParent.rotationQuaternion=new _.PT,l=0;l<3;l++)for(var c=0;c<3;c++)for(var u=function(m){var v=(l===1?1:0)+(c===1?1:0)+(m===1?1:0);if(v===1||v===3)return"continue";var b=v===2?Oi("",{size:1},n.utilityLayerScene):d._getCornerMesh(n);v===0&&(b.rotationQuaternion=_.PT.FromEulerAngles(.25*c*Math.PI,.25*(m+3*l-l*m)*Math.PI,0)),b.material=d._coloredMaterial,b._internalMetadata=v===2,b.isNearGrabbable=!0,_.AA.Vector3[0].set(l-1,c-1,m-1),_.AA.Vector3[0].normalize(),b.computeWorldMatrix(!0).invertToRef(_.AA.Matrix[0]);var E=_.Pq.TransformCoordinates(_.AA.Vector3[0],_.AA.Matrix[0]);E.normalize();var C=new Gr({dragAxis:E});C.updateDragPlane=!1,C.moveAttached=!1;var T=0,f=0;b.addBehavior(C),C.onDragObservable.add(function(g){if(i.onScaleBoxDragObservable.notifyObservers({}),i.attachedMesh){var S=i.attachedMesh.parent;if(S&&S.scaling&&S.scaling.isNonUniformWithinEpsilon(.001))return void O.V.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");Gi._RemoveAndStorePivotPoint(i.attachedMesh);var y=g.dragDistance/i._boundingDimensions.length()*i._anchorMesh.scaling.length();if(T+=y,i.scalingSnapDistance>0){var x=Math.floor(Math.abs(T)/i.scalingSnapDistance)*(T<0?-1:1),R=i.scalingSnapDistance*x;y=R-f,f=R}var I=new _.Pq(y,y,y),M=new _.Pq(f,f,f);v===2&&(I.x*=Math.abs(E.x),I.y*=Math.abs(E.y),I.z*=Math.abs(E.z)),I.scaleInPlace(i._scaleDragSpeed),I.multiplyInPlace(i._axisFactor),M.scaleInPlace(i._scaleDragSpeed),M.multiplyInPlace(i._axisFactor),M.addInPlace(i._incrementalStartupValue),i.updateBoundingBox(),i.scalePivot?(i.attachedMesh.getWorldMatrix().getRotationMatrixToRef(i._tmpRotationMatrix),i._boundingDimensions.scaleToRef(.5,i._tmpVector),_.Pq.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector),i._boundingDimensions.multiplyToRef(i.scalePivot,i._tmpVector),_.Pq.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.addInPlace(i._tmpVector)):(b.absolutePosition.subtractToRef(i._anchorMesh.position,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector),i.attachedMesh.isUsingPivotMatrix()&&i._anchorMesh.position.subtractInPlace(i.attachedMesh.getPivotPoint())),i._anchorMesh.addChild(i.attachedMesh),i.incrementalSnap?(M.x/=Math.abs(i._incrementalStartupValue.x)<pt.bH?1:i._incrementalStartupValue.x,M.y/=Math.abs(i._incrementalStartupValue.y)<pt.bH?1:i._incrementalStartupValue.y,M.z/=Math.abs(i._incrementalStartupValue.z)<pt.bH?1:i._incrementalStartupValue.z,M.x=Math.max(i._incrementalAnchorStartupValue.x*M.x,i.scalingSnapDistance),M.y=Math.max(i._incrementalAnchorStartupValue.y*M.y,i.scalingSnapDistance),M.z=Math.max(i._incrementalAnchorStartupValue.z*M.z,i.scalingSnapDistance),i._anchorMesh.scaling.x+=(M.x-i._anchorMesh.scaling.x)*Math.abs(E.x),i._anchorMesh.scaling.y+=(M.y-i._anchorMesh.scaling.y)*Math.abs(E.y),i._anchorMesh.scaling.z+=(M.z-i._anchorMesh.scaling.z)*Math.abs(E.z)):(i._anchorMesh.scaling.addInPlace(I),(i._anchorMesh.scaling.x<0||i._anchorMesh.scaling.y<0||i._anchorMesh.scaling.z<0)&&i._anchorMesh.scaling.subtractInPlace(I)),i._anchorMesh.removeChild(i.attachedMesh),i.attachedMesh.setParent(S),Gi._RestorePivotPoint(i.attachedMesh)}i._updateDummy()}),C.onDragStartObservable.add(function(){i.onDragStartObservable.notifyObservers({}),i._dragging=!0,i._selectNode(b),T=0,f=0,i._incrementalStartupValue.copyFrom(i.attachedMesh.scaling),i._incrementalAnchorStartupValue.copyFrom(i._anchorMesh.scaling)}),C.onDragEndObservable.add(function(g){i.onScaleBoxDragEndObservable.notifyObservers({}),i._dragging=!1,i._selectNode(null),i._updateDummy(),i._unhoverMeshOnTouchUp(g.pointerInfo,b)}),d._scaleBoxesParent.addChild(b),d._scaleBoxesDragBehaviors.push(C)},d=this,h=0;h<3;h++)u(h);i._rootMesh.addChild(i._scaleBoxesParent);var p=[];return i._pointerObserver=n.utilityLayerScene.onPointerObservable.add(function(m){p[m.event.pointerId]?m.pickInfo&&m.pickInfo.pickedMesh!=p[m.event.pointerId]&&(p[m.event.pointerId].material=i._coloredMaterial,delete p[m.event.pointerId],i._isHovered=!1):i._rotateAnchorsParent.getChildMeshes().concat(i._scaleBoxesParent.getChildMeshes()).forEach(function(v){m.pickInfo&&m.pickInfo.pickedMesh==v&&(p[m.event.pointerId]=v,v.material=i._hoverColoredMaterial,i._isHovered=!0)})}),i._renderObserver=i.gizmoLayer.originalScene.onBeforeRenderObservable.add(function(){i.attachedMesh&&!i._existingMeshScale.equals(i.attachedMesh.scaling)?i.updateBoundingBox():(i.fixedDragMeshScreenSize||i.fixedDragMeshBoundsSize)&&(i._updateRotationAnchors(),i._updateScaleBoxes()),i._dragMesh&&i.attachedMesh&&i._pointerDragBehavior.dragging&&(i._lineBoundingBox.position.rotateByQuaternionToRef(i._rootMesh.rotationQuaternion,i._tmpVector),i.attachedMesh.setAbsolutePosition(i._dragMesh.position.add(i._tmpVector.scale(-1))))}),i.updateBoundingBox(),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"axisFactor",{get:function(){return this._axisFactor},set:function(e){this._axisFactor=e;for(var n=this._scaleBoxesParent.getChildMeshes(),i=0,o=0;o<3;o++)for(var a=0;a<3;a++)for(var s=0;s<3;s++){var l=(o===1?1:0)+(a===1?1:0)+(s===1?1:0);if(l!==1&&l!==3){if(n[i]){var c=new _.Pq(o-1,a-1,s-1);c.multiplyInPlace(this._axisFactor),n[i].setEnabled(c.lengthSquared()>pt.bH)}i++}}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleDragSpeed",{get:function(){return this._scaleDragSpeed},set:function(e){this._scaleDragSpeed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverColoredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerDragBehavior",{get:function(){return this._pointerDragBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this._dragging||this._pointerDragBehavior.dragging},enumerable:!1,configurable:!0}),t.prototype.setColor=function(e){this._coloredMaterial.emissiveColor=e,this._hoverColoredMaterial.emissiveColor=e.clone().add(new z.v9(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach(function(n){n.color&&(n.color=e)})},t.prototype._getCornerMesh=function(e){if(!this._cornerMesh){var n=Oi("",{width:.4,height:.4,depth:1.6},e.utilityLayerScene);n.position.z=.6;var i=Oi("",{width:.4,height:1.6,depth:.4},e.utilityLayerScene);i.position.y=.6;var o=Oi("",{width:1.6,height:.4,depth:.4},e.utilityLayerScene);return o.position.x=.6,this._cornerMesh=xe.MergeMeshes([o,i,n],!0),this._cornerMesh}return this._cornerMesh.clone()},t.prototype._attachedNodeChanged=function(e){var n=this;if(e){this._anchorMesh.scaling.setAll(1),Gi._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),Gi._RestorePivotPoint(e),this.updateBoundingBox(),e.getChildMeshes(!1).forEach(function(o){o.markAsDirty("scaling")}),this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function(){n._updateDummy()})}},t.prototype._selectNode=function(e){this._rotateAnchorsParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(n){n.isVisible=!e||n==e})},t.prototype._unhoverMeshOnTouchUp=function(e,n){e?.event instanceof PointerEvent&&e?.event.pointerType==="touch"&&(n.material=this._coloredMaterial)},t.prototype.getScaleBoxes=function(){return this._scaleBoxesParent.getChildMeshes()},t.prototype.updateBoundingBox=function(){if(this.attachedMesh){Gi._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=_.PT.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=_.PT.RotationYawPitchRoll(this._anchorMesh.rotation.y,this._anchorMesh.rotation.x,this._anchorMesh.rotation.z)),this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var n=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);n.max.subtractToRef(n.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((n.max.x+n.min.x)/2,(n.max.y+n.min.y)/2,(n.max.z+n.min.z)/2),this._rotateAnchorsParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),this.attachedMesh.setParent(e)}this._updateRotationAnchors(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),Gi._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationAnchors=function(){for(var e=this._rotateAnchorsParent.getChildMeshes(),n=0;n<3;n++)for(var i=0;i<2;i++)for(var o=0;o<2;o++){var a=4*n+2*i+o;e[a].position.normalizeToRef(_.AA.Vector3[0]),n==0&&(e[a].position.set(0,this._boundingDimensions.y*(i-.5),this._boundingDimensions.z*(o-.5)),_.AA.Vector3[1].set(1,0,0)),n==1&&(e[a].position.set(this._boundingDimensions.x*(i-.5),0,this._boundingDimensions.z*(o-.5)),_.AA.Vector3[1].set(0,1,0)),n==2&&(e[a].position.set(this._boundingDimensions.x*(i-.5),this._boundingDimensions.y*(o-.5),0),_.AA.Vector3[1].set(0,0,1));var s=_.AA.Vector3[2];if(_.Pq.CrossToRef(_.AA.Vector3[0],_.AA.Vector3[1],s),s.normalize(),s.addInPlace(e[a].position),e[a].lookAt(s),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[a].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var l=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[a].scaling.set(l,l,l)}else this.fixedDragMeshBoundsSize?e[a].scaling.set(this.rotationSphereSize*this._boundingDimensions.x,this.rotationSphereSize*this._boundingDimensions.y,this.rotationSphereSize*this._boundingDimensions.z):e[a].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),n=0,i=0;i<3;i++)for(var o=0;o<3;o++)for(var a=0;a<3;a++){var s=(i===1?1:0)+(o===1?1:0)+(a===1?1:0);if(s!==1&&s!==3){if(e[n])if(e[n].position.set(this._boundingDimensions.x*(i/2),this._boundingDimensions.y*(o/2),this._boundingDimensions.z*(a/2)),e[n].position.addInPlace(new _.Pq(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[n].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition,this._tmpVector);var l=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[n].scaling.set(l,l,l)}else this.fixedDragMeshBoundsSize?e[n].scaling.set(this.scaleBoxSize*this._boundingDimensions.x,this.scaleBoxSize*this._boundingDimensions.y,this.scaleBoxSize*this._boundingDimensions.z):e[n].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize);n++}}},t.prototype.setEnabledRotationAxis=function(e){this._rotateAnchorsParent.getChildMeshes().forEach(function(n,i){i<4?n.setEnabled(e.indexOf("x")!=-1):i<8?n.setEnabled(e.indexOf("y")!=-1):n.setEnabled(e.indexOf("z")!=-1)})},t.prototype.setEnabledScaling=function(e,n){n===void 0&&(n=!1),this._scaleBoxesParent.getChildMeshes().forEach(function(i){var o=e;n&&i._internalMetadata===!0&&(o=!1),i.setEnabled(o)})},t.prototype._updateDummy=function(){this._dragMesh&&(this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))},t.prototype.enableDragBehavior=function(){this._dragMesh=Oi("dummy",{size:1},this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new _.PT,this._pointerDragBehavior.useObjectOrientationForDragging=!1,this._dragMesh.addBehavior(this._pointerDragBehavior)},t.prototype.releaseDrag=function(){this._scaleBoxesDragBehaviors.forEach(function(e){e.releaseDrag()}),this._rotateAnchorsDragBehaviors.forEach(function(e){e.releaseDrag()}),this._pointerDragBehavior.releaseDrag()},t.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateAnchorsParent.dispose(),this._scaleBoxesParent.dispose(),this._dragMesh&&this._dragMesh.dispose(),this._scaleBoxesDragBehaviors.length=0,this._rotateAnchorsDragBehaviors.length=0,r.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var n=function(l){l.isPickable=!1,l.getChildMeshes().forEach(function(c){n(c)})};n(e),e.rotationQuaternion||(e.rotationQuaternion=_.PT.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var i=e.position.clone(),o=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var a=Oi("box",{size:1},e.getScene()),s=e.getHierarchyBoundingVectors();return s.max.subtractToRef(s.min,a.scaling),a.scaling.y===0&&(a.scaling.y=pt.bH),a.scaling.x===0&&(a.scaling.x=pt.bH),a.scaling.z===0&&(a.scaling.z=pt.bH),a.position.set((s.max.x+s.min.x)/2,(s.max.y+s.min.y)/2,(s.max.z+s.min.z)/2),e.addChild(a),e.rotationQuaternion.copyFrom(o),e.position.copyFrom(i),e.removeChild(a),a.addChild(e),a.visibility=0,a},t.prototype.setCustomMesh=function(){O.V.Error("Custom meshes are not supported on this gizmo")},t}(Jn),cl=function(r){function t(e,n,i,o,a,s,l,c,u){var d;n===void 0&&(n=z.v9.Gray()),i===void 0&&(i=Fn.DefaultUtilityLayer),o===void 0&&(o=32),a===void 0&&(a=null),l===void 0&&(l=1),c===void 0&&(c=z.v9.Yellow()),u===void 0&&(u=z.v9.Gray());var h,p=this;(p=r.call(this,i)||this)._pointerObserver=null,p.snapDistance=0,p.onSnapObservable=new K.cP,p.angle=0,p.sensitivity=1,p._isEnabled=!0,p._parent=null,p._dragging=!1,p._angles=new _.Pq,p._parent=a,p._coloredMaterial=new qt("",i.utilityLayerScene),p._coloredMaterial.diffuseColor=n,p._coloredMaterial.specularColor=n.subtract(new z.v9(.1,.1,.1)),p._hoverMaterial=new qt("",i.utilityLayerScene),p._hoverMaterial.diffuseColor=c,p._hoverMaterial.specularColor=c,p._disableMaterial=new qt("",i.utilityLayerScene),p._disableMaterial.diffuseColor=u,p._disableMaterial.alpha=.4,p._gizmoMesh=new xe("",i.utilityLayerScene);var m=(d=p._createGizmoMesh(p._gizmoMesh,l,o)).rotationMesh,v=d.collider;p._rotationDisplayPlane=Ur("rotationDisplay",{size:.6,updatable:!1},p.gizmoLayer.utilityLayerScene),p._rotationDisplayPlane.rotation.z=.5*Math.PI,p._rotationDisplayPlane.parent=p._gizmoMesh,p._rotationDisplayPlane.setEnabled(!1),ti.M.ShadersStore.rotationGizmoVertexShader=t._RotationGizmoVertexShader,ti.M.ShadersStore.rotationGizmoFragmentShader=t._RotationGizmoFragmentShader,p._rotationShaderMaterial=new pi("shader",p.gizmoLayer.utilityLayerScene,{vertex:"rotationGizmo",fragment:"rotationGizmo"},{attributes:["position","uv"],uniforms:["worldViewProjection","angles","rotationColor"]}),p._rotationShaderMaterial.backFaceCulling=!1,p.rotationColor=c,p._rotationDisplayPlane.material=p._rotationShaderMaterial,p._rotationDisplayPlane.visibility=.999,p._gizmoMesh.lookAt(p._rootMesh.position.add(e)),p._rootMesh.addChild(p._gizmoMesh,Jn.PreserveScaling),p._gizmoMesh.scaling.scaleInPlace(1/3),p.dragBehavior=new Gr({dragPlaneNormal:e}),p.dragBehavior.moveAttached=!1,p.dragBehavior.maxDragAngle=t.MaxDragAngle,p.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,p._rootMesh.addBehavior(p.dragBehavior);var b=new _.Pq,E=new _.uq,C=new _.Pq,T=new _.Pq;p.dragBehavior.onDragStartObservable.add(function(I){p.attachedNode&&(b.copyFrom(I.dragPlanePoint),p._rotationDisplayPlane.setEnabled(!0),p._rotationDisplayPlane.getWorldMatrix().invertToRef(E),_.Pq.TransformCoordinatesToRef(I.dragPlanePoint,E,b),p._angles.x=Math.atan2(b.y,b.x)+Math.PI,p._angles.y=0,p._angles.z=p.updateGizmoRotationToMatchAttachedMesh?1:0,p._dragging=!0,b.copyFrom(I.dragPlanePoint),p._rotationShaderMaterial.setVector3("angles",p._angles),p.angle=0)}),p.dragBehavior.onDragEndObservable.add(function(){p._dragging=!1,p._rotationDisplayPlane.setEnabled(!1)});var f={snapDistance:0},g=0,S=new _.uq,y=new _.PT;p.dragBehavior.onDragObservable.add(function(I){if(p.attachedNode){var M=new _.Pq(1,1,1),D=new _.PT(0,0,0,1),B=new _.Pq(0,0,0);if(p.attachedNode.getWorldMatrix().decompose(M,D,B),!(Math.abs(Math.abs(M.x)-Math.abs(M.y))<=pt.bH&&Math.abs(Math.abs(M.x)-Math.abs(M.z))<=pt.bH)&&p.updateGizmoRotationToMatchAttachedMesh)return void O.V.Warn("Unable to use a rotation gizmo matching mesh rotation with non uniform scaling. Use uniform scaling or set updateGizmoRotationToMatchAttachedMesh to false.");D.normalize();var F=p.updateGizmoPositionToMatchAttachedMesh?B:p._rootMesh.absolutePosition,X=I.dragPlanePoint.subtract(F).normalize(),$=b.subtract(F).normalize(),Q=_.Pq.Cross(X,$),ie=_.Pq.Dot(X,$),q=Math.atan2(Q.length(),ie)*p.sensitivity;C.copyFrom(e),T.copyFrom(e),p.updateGizmoRotationToMatchAttachedMesh&&(D.toRotationMatrix(E),T=_.Pq.TransformCoordinates(C,E));var ee=!1;if(i.utilityLayerScene.activeCamera){var te=i.utilityLayerScene.activeCamera.position.subtract(F).normalize();_.Pq.Dot(te,T)>0&&(C.scaleInPlace(-1),T.scaleInPlace(-1),ee=!0)}_.Pq.Dot(T,Q)>0&&(q=-q),_.AA.Vector3[0].set(q,0,0),p.dragBehavior.validateDrag(_.AA.Vector3[0])||(q=0);var ce=!1;if(p.snapDistance!=0)if(g+=q,Math.abs(g)>p.snapDistance){var fe=Math.floor(Math.abs(g)/p.snapDistance);g<0&&(fe*=-1),g%=p.snapDistance,q=p.snapDistance*fe,ce=!0}else q=0;var de=Math.sin(q/2);if(y.set(C.x*de,C.y*de,C.z*de,Math.cos(q/2)),S.determinant()>0){var Te=new _.Pq;y.toEulerAnglesToRef(Te),_.PT.RotationYawPitchRollToRef(Te.y,-Te.x,-Te.z,y)}if(p.updateGizmoRotationToMatchAttachedMesh)D.multiplyToRef(y,D),D.normalize(),_.uq.ComposeToRef(M,D,B,p.attachedNode.getWorldMatrix());else{y.toRotationMatrix(_.AA.Matrix[0]);var ue=p.attachedNode.getWorldMatrix().getTranslation();p.attachedNode.getWorldMatrix().multiplyToRef(_.AA.Matrix[0],p.attachedNode.getWorldMatrix()),p.attachedNode.getWorldMatrix().setTranslation(ue)}b.copyFrom(I.dragPlanePoint),ce&&(f.snapDistance=q,p.onSnapObservable.notifyObservers(f)),p._angles.y+=q,p.angle+=ee?-q:q,p._rotationShaderMaterial.setVector3("angles",p._angles),p._matrixChanged()}});var x=i._getSharedGizmoLight();x.includedOnlyMeshes=x.includedOnlyMeshes.concat(p._rootMesh.getChildMeshes(!1));var R={colliderMeshes:[v],gizmoMeshes:[m],material:p._coloredMaterial,hoverMaterial:p._hoverMaterial,disableMaterial:p._disableMaterial,active:!1,dragBehavior:p.dragBehavior};return(h=p._parent)===null||h===void 0||h.addToAxisCache(p._gizmoMesh,R),p._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(I){var M;if(!p._customMeshSet&&(p.dragBehavior.maxDragAngle=t.MaxDragAngle,p._isHovered=R.colliderMeshes.indexOf((M=I?.pickInfo)===null||M===void 0?void 0:M.pickedMesh)!=-1,!p._parent)){var D=R.dragBehavior.enabled?p._isHovered||p._dragging?p._hoverMaterial:p._coloredMaterial:p._disableMaterial;p._setGizmoMeshMaterial(R.gizmoMeshes,D)}}),p.dragBehavior.onEnabledObservable.add(function(I){p._setGizmoMeshMaterial(R.gizmoMeshes,I?p._coloredMaterial:p._disableMaterial)}),p}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationColor",{set:function(e){this._rotationShaderMaterial.setColor3("rotationColor",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),t.prototype._createGizmoMesh=function(e,n,i){var o=Sr("ignore",{diameter:.6,thickness:.03*n,tessellation:i},this.gizmoLayer.utilityLayerScene);o.visibility=0;var a=Sr("",{diameter:.6,thickness:.005*n,tessellation:i},this.gizmoLayer.utilityLayerScene);return a.material=this._coloredMaterial,a.rotation.x=Math.PI/2,o.rotation.x=Math.PI/2,e.addChild(a,Jn.PreserveScaling),e.addChild(o,Jn.PreserveScaling),{rotationMesh:a,collider:o}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh):this.attachedMesh=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),this._rotationDisplayPlane&&this._rotationDisplayPlane.dispose(),this._rotationShaderMaterial&&this._rotationShaderMaterial.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(e){e&&e.dispose()}),r.prototype.dispose.call(this)},t.MaxDragAngle=9*Math.PI/20,t._RotationGizmoVertexShader=`
|
||
precision highp float;
|
||
attribute vec3 position;
|
||
attribute vec2 uv;
|
||
uniform mat4 worldViewProjection;
|
||
varying vec3 vPosition;
|
||
varying vec2 vUV;
|
||
|
||
void main(void) {
|
||
gl_Position = worldViewProjection * vec4(position, 1.0);
|
||
vUV = uv;
|
||
}`,t._RotationGizmoFragmentShader=`
|
||
precision highp float;
|
||
varying vec2 vUV;
|
||
varying vec3 vPosition;
|
||
uniform vec3 angles;
|
||
uniform vec3 rotationColor;
|
||
|
||
#define twopi 6.283185307
|
||
|
||
void main(void) {
|
||
vec2 uv = vUV - vec2(0.5);
|
||
float angle = atan(uv.y, uv.x) + 3.141592;
|
||
float delta = gl_FrontFacing ? angles.y : -angles.y;
|
||
float begin = angles.x - delta * angles.z;
|
||
float start = (begin < (begin + delta)) ? begin : (begin + delta);
|
||
float end = (begin > (begin + delta)) ? begin : (begin + delta);
|
||
float len = sqrt(dot(uv,uv));
|
||
float opacity = 1. - step(0.5, len);
|
||
|
||
float base = abs(floor(start / twopi)) * twopi;
|
||
start += base;
|
||
end += base;
|
||
|
||
float intensity = 0.;
|
||
for (int i = 0; i < 5; i++)
|
||
{
|
||
intensity += max(step(start, angle) - step(end, angle), 0.);
|
||
angle += twopi;
|
||
}
|
||
gl_FragColor = vec4(rotationColor, min(intensity * 0.25, 0.8)) * opacity;
|
||
}
|
||
`,t}(Jn),wg=function(r){function t(e,n,i,o,a,s){e===void 0&&(e=Fn.DefaultUtilityLayer),n===void 0&&(n=32),i===void 0&&(i=!1),o===void 0&&(o=1);var l=r.call(this,e)||this;l.onDragStartObservable=new K.cP,l.onDragObservable=new K.cP,l.onDragEndObservable=new K.cP,l._observables=[],l._sensitivity=1,l._gizmoAxisCache=new Map;var c=s&&s.xOptions&&s.xOptions.color?s.xOptions.color:z.v9.Red().scale(.5),u=s&&s.yOptions&&s.yOptions.color?s.yOptions.color:z.v9.Green().scale(.5),d=s&&s.zOptions&&s.zOptions.color?s.zOptions.color:z.v9.Blue().scale(.5);return l.xGizmo=new cl(new _.Pq(1,0,0),c,e,n,l,i,o),l.yGizmo=new cl(new _.Pq(0,1,0),u,e,n,l,i,o),l.zGizmo=new cl(new _.Pq(0,0,1),d,e,n,l,i,o),l.additionalTransformNode=s?.additionalTransformNode,[l.xGizmo,l.yGizmo,l.zGizmo].forEach(function(h){s&&s.updateScale!=null&&(h.updateScale=s.updateScale),h.dragBehavior.onDragStartObservable.add(function(){l.onDragStartObservable.notifyObservers({})}),h.dragBehavior.onDragObservable.add(function(){l.onDragObservable.notifyObservers({})}),h.dragBehavior.onDragEndObservable.add(function(){l.onDragEndObservable.notifyObservers({})})}),l.attachedMesh=null,l.attachedNode=null,a?a.addToAxisCache(l._gizmoAxisCache):Jn.GizmoAxisPointerObserver(e,l._gizmoAxisCache),l}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){n.isEnabled?n.attachedMesh=e:n.attachedMesh=null})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){n.isEnabled?n.attachedNode=e:n.attachedNode=null})},enumerable:!1,configurable:!0}),t.prototype._checkBillboardTransform=function(){this._nodeAttached&&this._nodeAttached.billboardMode&&O.V.Log("Rotation Gizmo will not work with transforms in billboard mode.")},Object.defineProperty(t.prototype,"sensitivity",{get:function(){return this._sensitivity},set:function(e){this._sensitivity=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){n&&(n.sensitivity=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){return this.xGizmo.isHovered||this.yGizmo.isHovered||this.zGizmo.isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this.xGizmo.dragBehavior.dragging||this.yGizmo.dragBehavior.dragging||this.zGizmo.dragBehavior.dragging},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){n.additionalTransformNode=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoPositionToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoPositionToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoPositionToMatchAttachedMesh=e,this.yGizmo.updateGizmoPositionToMatchAttachedMesh=e,this.zGizmo.updateGizmoPositionToMatchAttachedMesh=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(e){this._anchorPoint=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){n.anchorPoint=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){n.coordinatesMode=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateScale",{get:function(){return this.xGizmo.updateScale},set:function(e){this.xGizmo&&(this.xGizmo.updateScale=e,this.yGizmo.updateScale=e,this.zGizmo.updateScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(e){this._customRotationQuaternion=e,[this.xGizmo,this.yGizmo,this.zGizmo].forEach(function(n){n&&(n.customRotationQuaternion=e)})},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,n){this._gizmoAxisCache.set(e,n)},t.prototype.releaseDrag=function(){this.xGizmo.dragBehavior.releaseDrag(),this.yGizmo.dragBehavior.releaseDrag(),this.zGizmo.dragBehavior.releaseDrag()},t.prototype.dispose=function(){var e=this;this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragObservable.clear(),this.onDragEndObservable.clear(),this._observables.forEach(function(n){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(n)})},t.prototype.setCustomMesh=function(){O.V.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},t}(Jn),ul=function(r){function t(e,n,i,o,a,s){n===void 0&&(n=z.v9.Gray()),i===void 0&&(i=Fn.DefaultUtilityLayer),o===void 0&&(o=null),a===void 0&&(a=z.v9.Yellow()),s===void 0&&(s=z.v9.Gray());var l,c=this;(c=r.call(this,i)||this)._pointerObserver=null,c.snapDistance=0,c.onSnapObservable=new K.cP,c._isEnabled=!1,c._parent=null,c._dragging=!1,c._parent=o,c._coloredMaterial=new qt("",i.utilityLayerScene),c._coloredMaterial.diffuseColor=n,c._coloredMaterial.specularColor=n.subtract(new z.v9(.1,.1,.1)),c._hoverMaterial=new qt("",i.utilityLayerScene),c._hoverMaterial.diffuseColor=a,c._disableMaterial=new qt("",i.utilityLayerScene),c._disableMaterial.diffuseColor=s,c._disableMaterial.alpha=.4,c._gizmoMesh=t._CreatePlane(i.utilityLayerScene,c._coloredMaterial),c._gizmoMesh.lookAt(c._rootMesh.position.add(e)),c._gizmoMesh.scaling.scaleInPlace(1/3),c._gizmoMesh.parent=c._rootMesh;var u=0,d=new _.Pq,h={snapDistance:0};c.dragBehavior=new Gr({dragPlaneNormal:e}),c.dragBehavior.moveAttached=!1,c._rootMesh.addBehavior(c.dragBehavior),c.dragBehavior.onDragObservable.add(function(v){if(c.attachedNode){if(c.snapDistance==0)c.attachedNode.getWorldMatrix().getTranslationToRef(_.AA.Vector3[0]),_.AA.Vector3[0].addToRef(v.delta,_.AA.Vector3[0]),c.dragBehavior.validateDrag(_.AA.Vector3[0])&&c.attachedNode.getWorldMatrix().addTranslationFromFloats(v.delta.x,v.delta.y,v.delta.z);else if(u+=v.dragDistance,Math.abs(u)>c.snapDistance){var b=Math.floor(Math.abs(u)/c.snapDistance);u%=c.snapDistance,v.delta.normalizeToRef(d),d.scaleInPlace(c.snapDistance*b),c.attachedNode.getWorldMatrix().getTranslationToRef(_.AA.Vector3[0]),_.AA.Vector3[0].addToRef(d,_.AA.Vector3[0]),c.dragBehavior.validateDrag(_.AA.Vector3[0])&&(c.attachedNode.getWorldMatrix().addTranslationFromFloats(d.x,d.y,d.z),h.snapDistance=c.snapDistance*b,c.onSnapObservable.notifyObservers(h))}c._matrixChanged()}}),c.dragBehavior.onDragStartObservable.add(function(){c._dragging=!0}),c.dragBehavior.onDragEndObservable.add(function(){c._dragging=!1});var p=i._getSharedGizmoLight();p.includedOnlyMeshes=p.includedOnlyMeshes.concat(c._rootMesh.getChildMeshes(!1));var m={gizmoMeshes:c._gizmoMesh.getChildMeshes(),colliderMeshes:c._gizmoMesh.getChildMeshes(),material:c._coloredMaterial,hoverMaterial:c._hoverMaterial,disableMaterial:c._disableMaterial,active:!1,dragBehavior:c.dragBehavior};return(l=c._parent)===null||l===void 0||l.addToAxisCache(c._gizmoMesh,m),c._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(v){var b;if(!c._customMeshSet&&(c._isHovered=m.colliderMeshes.indexOf((b=v?.pickInfo)===null||b===void 0?void 0:b.pickedMesh)!=-1,!c._parent)){var E=m.dragBehavior.enabled?c._isHovered||c._dragging?c._hoverMaterial:c._coloredMaterial:c._disableMaterial;c._setGizmoMeshMaterial(m.gizmoMeshes,E)}}),c.dragBehavior.onEnabledObservable.add(function(v){c._setGizmoMeshMaterial(m.gizmoMeshes,v?c._coloredMaterial:c._disableMaterial)}),c}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),t._CreatePlane=function(e,n){var i=new jt("plane",e),o=Ur("dragPlane",{width:.1375,height:.1375,sideOrientation:2},e);return o.material=n,o.parent=i,i},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedNode=this._parent.attachedNode):this.attachedNode=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),r.prototype.dispose.call(this),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(e){e&&e.dispose()})},t}(Jn),Bg=function(r){function t(e,n,i,o){e===void 0&&(e=Fn.DefaultUtilityLayer),n===void 0&&(n=1);var a=r.call(this,e)||this;return a._meshAttached=null,a._nodeAttached=null,a._observables=[],a._gizmoAxisCache=new Map,a.onDragStartObservable=new K.cP,a.onDragObservable=new K.cP,a.onDragEndObservable=new K.cP,a._planarGizmoEnabled=!1,a.xGizmo=new Yr(new _.Pq(1,0,0),z.v9.Red().scale(.5),e,a,n),a.yGizmo=new Yr(new _.Pq(0,1,0),z.v9.Green().scale(.5),e,a,n),a.zGizmo=new Yr(new _.Pq(0,0,1),z.v9.Blue().scale(.5),e,a,n),a.xPlaneGizmo=new ul(new _.Pq(1,0,0),z.v9.Red().scale(.5),a.gizmoLayer,a),a.yPlaneGizmo=new ul(new _.Pq(0,1,0),z.v9.Green().scale(.5),a.gizmoLayer,a),a.zPlaneGizmo=new ul(new _.Pq(0,0,1),z.v9.Blue().scale(.5),a.gizmoLayer,a),a.additionalTransformNode=o?.additionalTransformNode,[a.xGizmo,a.yGizmo,a.zGizmo,a.xPlaneGizmo,a.yPlaneGizmo,a.zPlaneGizmo].forEach(function(s){s.dragBehavior.onDragStartObservable.add(function(){a.onDragStartObservable.notifyObservers({})}),s.dragBehavior.onDragObservable.add(function(){a.onDragObservable.notifyObservers({})}),s.dragBehavior.onDragEndObservable.add(function(){a.onDragEndObservable.notifyObservers({})})}),a.attachedMesh=null,i?i.addToAxisCache(a._gizmoAxisCache):Jn.GizmoAxisPointerObserver(e,a._gizmoAxisCache),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n.isEnabled?n.attachedMesh=e:n.attachedMesh=null})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n.isEnabled?n.attachedNode=e:n.attachedNode=null})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){return this.xGizmo.isHovered||this.yGizmo.isHovered||this.zGizmo.isHovered||this.xPlaneGizmo.isHovered||this.yPlaneGizmo.isHovered||this.zPlaneGizmo.isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this.xGizmo.dragBehavior.dragging||this.yGizmo.dragBehavior.dragging||this.zGizmo.dragBehavior.dragging||this.xPlaneGizmo.dragBehavior.dragging||this.yPlaneGizmo.dragBehavior.dragging||this.zPlaneGizmo.dragBehavior.dragging},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n.additionalTransformNode=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"planarGizmoEnabled",{get:function(){return this._planarGizmoEnabled},set:function(e){var n=this;this._planarGizmoEnabled=e,[this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(i){i&&(i.isEnabled=e,e&&(i.attachedMesh?i.attachedMesh=n.attachedMesh:i.attachedNode=n.attachedNode))},this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(e){this._customRotationQuaternion=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n&&(n.customRotationQuaternion=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n&&(n.updateGizmoRotationToMatchAttachedMesh=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoPositionToMatchAttachedMesh",{get:function(){return this._updateGizmoPositionToMatchAttachedMesh},set:function(e){this._updateGizmoPositionToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n&&(n.updateGizmoPositionToMatchAttachedMesh=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(e){this._anchorPoint=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n.anchorPoint=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n.coordinatesMode=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateScale",{get:function(){return this.xGizmo.updateScale},set:function(e){this.xGizmo&&(this.xGizmo.updateScale=e,this.yGizmo.updateScale=e,this.zGizmo.updateScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n&&(n.snapDistance=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n&&(n.scaleRatio=e)})},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,n){this._gizmoAxisCache.set(e,n)},t.prototype.releaseDrag=function(){this.xGizmo.dragBehavior.releaseDrag(),this.yGizmo.dragBehavior.releaseDrag(),this.zGizmo.dragBehavior.releaseDrag(),this.xPlaneGizmo.dragBehavior.releaseDrag(),this.yPlaneGizmo.dragBehavior.releaseDrag(),this.zPlaneGizmo.dragBehavior.releaseDrag()},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach(function(n){n&&n.dispose()}),this._observables.forEach(function(n){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(n)}),this.onDragStartObservable.clear(),this.onDragObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(){O.V.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)")},t}(Jn),Vg=function(r){function t(e,n,i,o){e===void 0&&(e=Fn.DefaultUtilityLayer),n===void 0&&(n=1);var a=r.call(this,e)||this;return a._meshAttached=null,a._nodeAttached=null,a._incrementalSnap=!1,a._sensitivity=1,a._observables=[],a._gizmoAxisCache=new Map,a.onDragStartObservable=new K.cP,a.onDragObservable=new K.cP,a.onDragEndObservable=new K.cP,a.uniformScaleGizmo=a._createUniformScaleMesh(),a.xGizmo=new Ha(new _.Pq(1,0,0),z.v9.Red().scale(.5),e,a,n),a.yGizmo=new Ha(new _.Pq(0,1,0),z.v9.Green().scale(.5),e,a,n),a.zGizmo=new Ha(new _.Pq(0,0,1),z.v9.Blue().scale(.5),e,a,n),a.additionalTransformNode=o?.additionalTransformNode,[a.xGizmo,a.yGizmo,a.zGizmo,a.uniformScaleGizmo].forEach(function(s){s.dragBehavior.onDragStartObservable.add(function(){a.onDragStartObservable.notifyObservers({})}),s.dragBehavior.onDragObservable.add(function(){a.onDragObservable.notifyObservers({})}),s.dragBehavior.onDragEndObservable.add(function(){a.onDragEndObservable.notifyObservers({})})}),a.attachedMesh=null,a.attachedNode=null,i?i.addToAxisCache(a._gizmoAxisCache):Jn.GizmoAxisPointerObserver(e,a._gizmoAxisCache),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"coloredMaterial",{get:function(){return this._coloredMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hoverMaterial",{get:function(){return this._hoverMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disableMaterial",{get:function(){return this._disableMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n.isEnabled?n.attachedMesh=e:n.attachedMesh=null})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n.isEnabled?n.attachedNode=e:n.attachedNode=null})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateScale",{get:function(){return this.xGizmo.updateScale},set:function(e){this.xGizmo&&(this.xGizmo.updateScale=e,this.yGizmo.updateScale=e,this.zGizmo.updateScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){return this.xGizmo.isHovered||this.yGizmo.isHovered||this.zGizmo.isHovered||this.uniformScaleGizmo.isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDragging",{get:function(){return this.xGizmo.dragBehavior.dragging||this.yGizmo.dragBehavior.dragging||this.zGizmo.dragBehavior.dragging||this.uniformScaleGizmo.dragBehavior.dragging},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(e){[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n.additionalTransformNode=e})},enumerable:!1,configurable:!0}),t.prototype._createUniformScaleMesh=function(){this._coloredMaterial=new qt("",this.gizmoLayer.utilityLayerScene),this._coloredMaterial.diffuseColor=z.v9.Gray(),this._hoverMaterial=new qt("",this.gizmoLayer.utilityLayerScene),this._hoverMaterial.diffuseColor=z.v9.Yellow(),this._disableMaterial=new qt("",this.gizmoLayer.utilityLayerScene),this._disableMaterial.diffuseColor=z.v9.Gray(),this._disableMaterial.alpha=.4;var e=new Ha(new _.Pq(0,1,0),z.v9.Gray().scale(.5),this.gizmoLayer,this);e.updateGizmoRotationToMatchAttachedMesh=!1,e.uniformScaling=!0,this._uniformScalingMesh=No("uniform",{type:1},e.gizmoLayer.utilityLayerScene),this._uniformScalingMesh.scaling.scaleInPlace(.01),this._uniformScalingMesh.visibility=0,this._octahedron=No("",{type:1},e.gizmoLayer.utilityLayerScene),this._octahedron.scaling.scaleInPlace(.007),this._uniformScalingMesh.addChild(this._octahedron),e.setCustomMesh(this._uniformScalingMesh,!0);var n=this.gizmoLayer._getSharedGizmoLight();n.includedOnlyMeshes=n.includedOnlyMeshes.concat(this._octahedron);var i={gizmoMeshes:[this._octahedron,this._uniformScalingMesh],colliderMeshes:[this._octahedron,this._uniformScalingMesh],material:this._coloredMaterial,hoverMaterial:this._hoverMaterial,disableMaterial:this._disableMaterial,active:!1,dragBehavior:e.dragBehavior};return this.addToAxisCache(e._rootMesh,i),e},Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){e?(this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&(n.updateGizmoRotationToMatchAttachedMesh=e)})):O.V.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anchorPoint",{get:function(){return this._anchorPoint},set:function(e){this._anchorPoint=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&(n.anchorPoint=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"customRotationQuaternion",{get:function(){return this._customRotationQuaternion},set:function(e){this._customRotationQuaternion=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&(n.customRotationQuaternion=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{set:function(e){e==0&&O.V.Warn("Setting coordinates Mode to world on scaling gizmo is not supported."),[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n.coordinatesMode=1})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&(n.snapDistance=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"incrementalSnap",{get:function(){return this._incrementalSnap},set:function(e){this._incrementalSnap=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&(n.incrementalSnap=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&(n.scaleRatio=e)})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sensitivity",{get:function(){return this._sensitivity},set:function(e){this._sensitivity=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&(n.sensitivity=e)})},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,n){this._gizmoAxisCache.set(e,n)},t.prototype.getAxisCache=function(e){return this._gizmoAxisCache.get(e)},t.prototype.releaseDrag=function(){this.xGizmo.dragBehavior.releaseDrag(),this.yGizmo.dragBehavior.releaseDrag(),this.zGizmo.dragBehavior.releaseDrag(),this.uniformScaleGizmo.dragBehavior.releaseDrag()},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach(function(n){n&&n.dispose()}),this._observables.forEach(function(n){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(n)}),this.onDragStartObservable.clear(),this.onDragObservable.clear(),this.onDragEndObservable.clear(),[this._uniformScalingMesh,this._octahedron].forEach(function(n){n&&n.dispose()}),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach(function(n){n&&n.dispose()})},t}(Jn),dx=function(){function r(t,e,n,i){e===void 0&&(e=1),n===void 0&&(n=Fn.DefaultUtilityLayer),i===void 0&&(i=Fn.DefaultKeepDepthUtilityLayer),this._scene=t,this.clearGizmoOnEmptyPointerEvent=!1,this.enableAutoPicking=!0,this.onAttachedToMeshObservable=new K.cP,this.onAttachedToNodeObservable=new K.cP,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObservers=[],this._attachedMesh=null,this._attachedNode=null,this._boundingBoxColor=z.v9.FromHexString("#0984e3"),this._thickness=1,this._scaleRatio=1,this._coordinatesMode=1,this._gizmoAxisCache=new Map,this.boundingBoxDragBehavior=new lm,this.attachableMeshes=null,this.attachableNodes=null,this.usePointerToAttachGizmos=!0,this._defaultUtilityLayer=n,this._defaultKeepDepthUtilityLayer=i,this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,this._thickness=e,this.gizmos={positionGizmo:null,rotationGizmo:null,scaleGizmo:null,boundingBoxGizmo:null};var o=this._attachToMeshPointerObserver(t),a=Jn.GizmoAxisPointerObserver(this._defaultUtilityLayer,this._gizmoAxisCache);this._pointerObservers=[o,a]}return Object.defineProperty(r.prototype,"keepDepthUtilityLayer",{get:function(){return this._defaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"utilityLayer",{get:function(){return this._defaultUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isHovered",{get:function(){var t=!1;for(var e in this.gizmos){var n=this.gizmos[e];if(n&&n.isHovered){t=!0;break}}return t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isDragging",{get:function(){var t=!1;return[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo,this.gizmos.boundingBoxGizmo].forEach(function(e){e&&e.isDragging&&(t=!0)}),t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(t){this._scaleRatio=t,[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo].forEach(function(e){e&&(e.scaleRatio=t)})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(t){this._coordinatesMode=t,[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo].forEach(function(e){e&&(e.coordinatesMode=t)})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"attachedMesh",{get:function(){return this._attachedMesh},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"attachedNode",{get:function(){return this._attachedNode},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"additionalTransformNode",{get:function(){return this._additionalTransformNode},set:function(t){this._additionalTransformNode=t,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),r.prototype._attachToMeshPointerObserver=function(t){var e=this;return t.onPointerObservable.add(function(n){if(e.usePointerToAttachGizmos&&n.type==vt.Zp.POINTERDOWN)if(n.pickInfo&&n.pickInfo.pickedMesh){if(e.enableAutoPicking){var i=n.pickInfo.pickedMesh;if(e.attachableMeshes==null)for(;i&&i.parent!=null;)i=i.parent;else{var o=!1;e.attachableMeshes.forEach(function(a){i&&(i==a||i.isDescendantOf(a))&&(i=a,o=!0)}),o||(i=null)}i instanceof cn?e._attachedMesh!=i&&e.attachToMesh(i):e.clearGizmoOnEmptyPointerEvent&&e.attachToMesh(null)}}else e.clearGizmoOnEmptyPointerEvent&&e.attachToMesh(null)})},r.prototype.attachToMesh=function(t){for(var e in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=t,this._attachedNode=null,this.gizmos){var n=this.gizmos[e];n&&this._gizmosEnabled[e]&&(n.attachedMesh=t)}this.boundingBoxGizmoEnabled&&this._attachedMesh&&this._attachedMesh.addBehavior(this.boundingBoxDragBehavior),this.onAttachedToMeshObservable.notifyObservers(t)},r.prototype.attachToNode=function(t){for(var e in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=null,this._attachedNode=t,this.gizmos){var n=this.gizmos[e];n&&this._gizmosEnabled[e]&&(n.attachedNode=t)}this.boundingBoxGizmoEnabled&&this._attachedNode&&this._attachedNode.addBehavior(this.boundingBoxDragBehavior),this.onAttachedToNodeObservable.notifyObservers(t)},Object.defineProperty(r.prototype,"positionGizmoEnabled",{get:function(){return this._gizmosEnabled.positionGizmo},set:function(t){t?(this.gizmos.positionGizmo||(this.gizmos.positionGizmo=new Bg(this._defaultUtilityLayer,this._thickness,this)),this._attachedNode?this.gizmos.positionGizmo.attachedNode=this._attachedNode:this.gizmos.positionGizmo.attachedMesh=this._attachedMesh):this.gizmos.positionGizmo&&(this.gizmos.positionGizmo.attachedNode=null),this._gizmosEnabled.positionGizmo=t,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rotationGizmoEnabled",{get:function(){return this._gizmosEnabled.rotationGizmo},set:function(t){t?(this.gizmos.rotationGizmo||(this.gizmos.rotationGizmo=new wg(this._defaultUtilityLayer,32,!1,this._thickness,this)),this._attachedNode?this.gizmos.rotationGizmo.attachedNode=this._attachedNode:this.gizmos.rotationGizmo.attachedMesh=this._attachedMesh):this.gizmos.rotationGizmo&&(this.gizmos.rotationGizmo.attachedNode=null),this._gizmosEnabled.rotationGizmo=t,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"scaleGizmoEnabled",{get:function(){return this._gizmosEnabled.scaleGizmo},set:function(t){t?(this.gizmos.scaleGizmo=this.gizmos.scaleGizmo||new Vg(this._defaultUtilityLayer,this._thickness,this),this._attachedNode?this.gizmos.scaleGizmo.attachedNode=this._attachedNode:this.gizmos.scaleGizmo.attachedMesh=this._attachedMesh):this.gizmos.scaleGizmo&&(this.gizmos.scaleGizmo.attachedNode=null),this._gizmosEnabled.scaleGizmo=t,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"boundingBoxGizmoEnabled",{get:function(){return this._gizmosEnabled.boundingBoxGizmo},set:function(t){t?(this.gizmos.boundingBoxGizmo=this.gizmos.boundingBoxGizmo||new Fg(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),this._attachedMesh?this.gizmos.boundingBoxGizmo.attachedMesh=this._attachedMesh:this.gizmos.boundingBoxGizmo.attachedNode=this._attachedNode,this._attachedMesh?(this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)):this._attachedNode&&(this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode.addBehavior(this.boundingBoxDragBehavior))):this.gizmos.boundingBoxGizmo&&(this._attachedMesh?this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior):this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this.gizmos.boundingBoxGizmo.attachedNode=null),this._gizmosEnabled.boundingBoxGizmo=t,this._setAdditionalTransformNode()},enumerable:!1,configurable:!0}),r.prototype._setAdditionalTransformNode=function(){for(var t in this.gizmos){var e=this.gizmos[t];e&&this._gizmosEnabled[t]&&(e.additionalTransformNode=this._additionalTransformNode)}},r.prototype.addToAxisCache=function(t){var e=this;t.size>0&&t.forEach(function(n,i){e._gizmoAxisCache.set(i,n)})},r.prototype.releaseDrag=function(){[this.gizmos.positionGizmo,this.gizmos.rotationGizmo,this.gizmos.scaleGizmo,this.gizmos.boundingBoxGizmo].forEach(function(t){t?.releaseDrag()})},r.prototype.dispose=function(){var t,e,n=this;for(var i in this._pointerObservers.forEach(function(a){n._scene.onPointerObservable.remove(a)}),this.gizmos){var o=this.gizmos[i];o&&o.dispose()}this._defaultKeepDepthUtilityLayer!==Fn._DefaultKeepDepthUtilityLayer&&((t=this._defaultKeepDepthUtilityLayer)===null||t===void 0||t.dispose()),this._defaultUtilityLayer!==Fn._DefaultUtilityLayer&&((e=this._defaultUtilityLayer)===null||e===void 0||e.dispose()),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},r}(),dl=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e._viewMatrix=_.uq.Identity(),e._projectionMatrix=_.uq.Identity(),e}return(0,A.C6)(t,r),t.prototype._setPosition=function(e){this._position=e},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!1,configurable:!0}),t.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix||(this.transformedPosition||(this.transformedPosition=_.Pq.Zero()),_.Pq.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=_.Pq.Zero()),_.Pq.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),0))},t.prototype.getDepthScale=function(){return 50},t.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},t.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},t.prototype.setDirectionToTarget=function(e){return this.direction=_.Pq.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=_.Pq.Cross(this.direction,Qn._0.Y),n=_.Pq.Cross(e,this.direction);return _.Pq.RotationFromAxis(e,n,this.direction)},t.prototype.needCube=function(){return!1},t.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},t.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},t.prototype._initCache=function(){r.prototype._initCache.call(this),this._cache.position=_.Pq.Zero()},t.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},t.prototype.computeWorldMatrix=function(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=_.uq.Identity()),_.uq.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)},t.prototype.getDepthMinZ=function(e){return this.shadowMinZ!==void 0?this.shadowMinZ:e.minZ},t.prototype.getDepthMaxZ=function(e){return this.shadowMaxZ!==void 0?this.shadowMaxZ:e.maxZ},t.prototype.setShadowProjectionMatrix=function(e,n,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(n,i,e):this._setDefaultShadowProjectionMatrix(e,n,i),this},t.prototype._syncParentEnabledState=function(){r.prototype._syncParentEnabledState.call(this),this.parent&&this.parent.getWorldMatrix||(this.transformedPosition=null,this.transformedDirection=null)},t.prototype.getViewMatrix=function(e){var n=_.AA.Vector3[0],i=this.position;this.computeTransformedInformation()&&(i=this.transformedPosition),_.Pq.NormalizeToRef(this.getShadowDirection(e),n),Math.abs(_.Pq.Dot(n,_.Pq.Up()))===1&&(n.z=1e-13);var o=_.AA.Vector3[1];return i.addToRef(n,o),_.uq.LookAtLHToRef(i,o,_.Pq.Up(),this._viewMatrix),this._viewMatrix},t.prototype.getProjectionMatrix=function(e,n){return this.setShadowProjectionMatrix(this._projectionMatrix,e??this._viewMatrix,n??[]),this._projectionMatrix},(0,A.Cg)([(0,V.P_)()],t.prototype,"position",null),(0,A.Cg)([(0,V.P_)()],t.prototype,"direction",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"shadowMinZ",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"shadowMaxZ",null),t}(hi);At.AddNodeConstructor("Light_Type_1",function(r,t){return function(){return new Ya(r,_.Pq.Zero(),t)}});var Ya=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._shadowFrustumSize=0,o._shadowOrthoScale=.1,o.autoUpdateExtends=!0,o.autoCalcShadowZBounds=!1,o._orthoLeft=Number.MAX_VALUE,o._orthoRight=Number.MIN_VALUE,o._orthoTop=Number.MIN_VALUE,o._orthoBottom=Number.MAX_VALUE,o.position=n.scale(-1),o.direction=n,o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoLeft",{get:function(){return this._orthoLeft},set:function(e){this._orthoLeft=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoRight",{get:function(){return this._orthoRight},set:function(e){this._orthoRight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoTop",{get:function(){return this._orthoTop},set:function(e){this._orthoTop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoBottom",{get:function(){return this._orthoBottom},set:function(e){this._orthoBottom=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DirectionalLight"},t.prototype.getTypeID=function(){return hi.LIGHTTYPEID_DIRECTIONALLIGHT},t.prototype._setDefaultShadowProjectionMatrix=function(e,n,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,n,i)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var n=this.getScene().activeCamera;n&&_.uq.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,this.shadowMinZ!==void 0?this.shadowMinZ:n.minZ,this.shadowMaxZ!==void 0?this.shadowMaxZ:n.maxZ,e,this.getScene().getEngine().isNDCHalfZRange)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,n,i){var o=this.getScene().activeCamera;if(o){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var a=_.Pq.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=Number.MAX_VALUE,l=-Number.MAX_VALUE,c=0;c<i.length;c++){var u=i[c];if(u)for(var d=u.getBoundingInfo().boundingBox,h=0;h<d.vectorsWorld.length;h++)_.Pq.TransformCoordinatesToRef(d.vectorsWorld[h],n,a),a.x<this._orthoLeft&&(this._orthoLeft=a.x),a.y<this._orthoBottom&&(this._orthoBottom=a.y),a.x>this._orthoRight&&(this._orthoRight=a.x),a.y>this._orthoTop&&(this._orthoTop=a.y),this.autoCalcShadowZBounds&&(a.z<s&&(s=a.z),a.z>l&&(l=a.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=s,this._shadowMaxZ=l)}var p=this._orthoRight-this._orthoLeft,m=this._orthoTop-this._orthoBottom,v=this.shadowMinZ!==void 0?this.shadowMinZ:o.minZ,b=this.shadowMaxZ!==void 0?this.shadowMaxZ:o.maxZ,E=this.getScene().getEngine().useReverseDepthBuffer;_.uq.OrthoOffCenterLHToRef(this._orthoLeft-p*this.shadowOrthoScale,this._orthoRight+p*this.shadowOrthoScale,this._orthoBottom-m*this.shadowOrthoScale,this._orthoTop+m*this.shadowOrthoScale,E?b:v,E?v:b,e,this.getScene().getEngine().isNDCHalfZRange)}},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,n){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,n),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,n),this)},t.prototype.transferToNodeMaterialEffect=function(e,n){return this.computeTransformedInformation()?(e.setFloat3(n,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(n,this.direction.x,this.direction.y,this.direction.z),this)},t.prototype.getDepthMinZ=function(e){var n=this._scene.getEngine();return!n.useReverseDepthBuffer&&n.isNDCHalfZRange?0:1},t.prototype.getDepthMaxZ=function(e){var n=this._scene.getEngine();return n.useReverseDepthBuffer&&n.isNDCHalfZRange?0:1},t.prototype.prepareLightSpecificDefines=function(e,n){e["DIRLIGHT"+n]=!0},(0,A.Cg)([(0,V.lK)()],t.prototype,"shadowFrustumSize",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"shadowOrthoScale",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"autoUpdateExtends",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"autoCalcShadowZBounds",void 0),(0,A.Cg)([(0,V.lK)("orthoLeft")],t.prototype,"_orthoLeft",void 0),(0,A.Cg)([(0,V.lK)("orthoRight")],t.prototype,"_orthoRight",void 0),(0,A.Cg)([(0,V.lK)("orthoTop")],t.prototype,"_orthoTop",void 0),(0,A.Cg)([(0,V.lK)("orthoBottom")],t.prototype,"_orthoBottom",void 0),t}(dl);function Xa(r,t,e){t===void 0&&(t={}),t.diameter||(t.diameter=1),t.segments||(t.segments=16);var n=li("",{slice:.5,diameter:t.diameter,segments:t.segments},e),i=ra("",{radius:t.diameter/2,tessellation:3*t.segments+(4-t.segments)},e);i.rotation.x=-Math.PI/2,i.parent=n;var o=xe.MergeMeshes([i,n],!0);return o.name=r,o}(0,j.Y5)("BABYLON.DirectionalLight",Ya);var hx={CreateHemisphere:Xa};xe.CreateHemisphere=function(r,t,e,n){return Xa(r,{segments:t,diameter:e},n)},At.AddNodeConstructor("Light_Type_2",function(r,t){return function(){return new hl(r,_.Pq.Zero(),_.Pq.Zero(),0,0,t)}});var hl=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e,s)||this;return l._innerAngle=0,l._projectionTextureMatrix=_.uq.Zero(),l._projectionTextureLightNear=1e-6,l._projectionTextureLightFar=1e3,l._projectionTextureUpDirection=_.Pq.Up(),l._projectionTextureViewLightDirty=!0,l._projectionTextureProjectionLightDirty=!0,l._projectionTextureDirty=!0,l._projectionTextureViewTargetVector=_.Pq.Zero(),l._projectionTextureViewLightMatrix=_.uq.Zero(),l._projectionTextureProjectionLightMatrix=_.uq.Zero(),l._projectionTextureScalingMatrix=_.uq.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),l.position=n,l.direction=i,l.angle=o,l.exponent=a,l}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){var n=this;this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady()&&(t._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled(function(){n._markMeshesAsLightDirty()}):t._IsTexture(this._projectionTexture)&&this._projectionTexture.onLoadObservable.addOnce(function(){n._markMeshesAsLightDirty()})))},enumerable:!1,configurable:!0}),t._IsProceduralTexture=function(e){return e.onGeneratedObservable!==void 0},t._IsTexture=function(e){return e.onLoadObservable!==void 0},Object.defineProperty(t.prototype,"projectionTextureProjectionLightMatrix",{get:function(){return this._projectionTextureProjectionLightMatrix},set:function(e){this._projectionTextureProjectionLightMatrix=e,this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return hi.LIGHTTYPEID_SPOTLIGHT},t.prototype._setDirection=function(e){r.prototype._setDirection.call(this,e),this._projectionTextureViewLightDirty=!0},t.prototype._setPosition=function(e){r.prototype._setPosition.call(this,e),this._projectionTextureViewLightDirty=!0},t.prototype._setDefaultShadowProjectionMatrix=function(e,n,i){var o=this.getScene().activeCamera;if(o){this._shadowAngleScale=this._shadowAngleScale||1;var a=this._shadowAngleScale*this._angle,s=this.shadowMinZ!==void 0?this.shadowMinZ:o.minZ,l=this.shadowMaxZ!==void 0?this.shadowMaxZ:o.maxZ,c=this.getScene().getEngine().useReverseDepthBuffer;_.uq.PerspectiveFovLHToRef(a,1,c?l:s,c?s:l,e,!0,this._scene.getEngine().isNDCHalfZRange,void 0,c)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.getAbsolutePosition().addToRef(this.getShadowDirection(),this._projectionTextureViewTargetVector),_.uq.LookAtLHToRef(this.getAbsolutePosition(),this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},t.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,n=this.projectionTextureLightNear,i=e/(e-n),o=-i*n,a=1/Math.tan(this._angle/2);_.uq.FromValuesToRef(a/1,0,0,0,0,a,0,0,0,0,i,1,0,0,o,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof Ie.g){var e=this._projectionTexture.uScale/2,n=this._projectionTexture.vScale/2;_.uq.FromValuesToRef(e,0,0,0,0,n,0,0,0,0,.5,0,.5,.5,.5,1,this._projectionTextureScalingMatrix)}this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype._computeAngleValues=function(){this._lightAngleScale=1/Math.max(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},t.prototype.transferTexturesToEffect=function(e,n){return this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+n,this._projectionTextureMatrix),e.setTexture("projectionLightTexture"+n,this.projectionTexture)),this},t.prototype.transferToEffect=function(e,n){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,n),i=_.Pq.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,n),i=_.Pq.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,this._cosHalfAngle,n),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,n),this},t.prototype.transferToNodeMaterialEffect=function(e,n){var i;return i=this.computeTransformedInformation()?_.Pq.Normalize(this.transformedDirection):_.Pq.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(n,-i.x,-i.y,-i.z):e.setFloat3(n,i.x,i.y,i.z),this},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},t.prototype.getDepthMinZ=function(e){var n=this._scene.getEngine(),i=this.shadowMinZ!==void 0?this.shadowMinZ:e.minZ;return n.useReverseDepthBuffer&&n.isNDCHalfZRange?i:this._scene.getEngine().isNDCHalfZRange?0:i},t.prototype.getDepthMaxZ=function(e){var n=this._scene.getEngine(),i=this.shadowMaxZ!==void 0?this.shadowMaxZ:e.maxZ;return n.useReverseDepthBuffer&&n.isNDCHalfZRange?0:i},t.prototype.prepareLightSpecificDefines=function(e,n){e["SPOTLIGHT"+n]=!0,e["PROJECTEDLIGHTTEXTURE"+n]=!(!this.projectionTexture||!this.projectionTexture.isReady())},(0,A.Cg)([(0,V.lK)()],t.prototype,"angle",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"innerAngle",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"shadowAngleScale",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"exponent",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"projectionTextureLightNear",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"projectionTextureLightFar",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"projectionTextureUpDirection",null),(0,A.Cg)([(0,V.uM)("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(dl);(0,j.Y5)("BABYLON.SpotLight",hl);var fx=function(r){function t(e){e===void 0&&(e=Fn.DefaultUtilityLayer);var n=r.call(this,e)||this;return n._cachedPosition=new _.Pq,n._cachedForward=new _.Pq(0,0,1),n._pointerObserver=null,n.onClickedObservable=new K.cP,n._light=null,n.attachedMesh=new xe("",n.gizmoLayer.utilityLayerScene),n._attachedMeshParent=new jt("parent",n.gizmoLayer.utilityLayerScene),n.attachedMesh.parent=n._attachedMeshParent,n._material=new qt("light",n.gizmoLayer.utilityLayerScene),n._material.diffuseColor=new z.v9(.5,.5,.5),n._material.specularColor=new z.v9(.1,.1,.1),n._pointerObserver=e.utilityLayerScene.onPointerObservable.add(function(i){n._light&&(n._isHovered=!(!i.pickInfo||n._rootMesh.getChildMeshes().indexOf(i.pickInfo.pickedMesh)==-1),n._isHovered&&i.event.button===0&&n.onClickedObservable.notifyObservers(n._light))},vt.Zp.POINTERDOWN),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this.attachedMesh},set:function(e){O.V.Warn("Nodes cannot be attached to LightGizmo. Attach to a mesh instead.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"light",{get:function(){return this._light},set:function(e){var n=this;if(this._light=e,e){this._lightMesh&&this._lightMesh.dispose(),this._lightMesh=e instanceof na?t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Ya?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof hl?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach(function(a){a.material=n._material}),this._lightMesh.parent=this._rootMesh;var i=this.gizmoLayer._getSharedGizmoLight();if(i.includedOnlyMeshes=i.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new _.PT,this.attachedMesh.reservedDataStore||(this.attachedMesh.reservedDataStore={}),this.attachedMesh.reservedDataStore.lightGizmo=this,e.parent&&this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()),e.position&&(this.attachedMesh.position.copyFrom(e.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)),e.direction){this.attachedMesh.setDirection(e.direction),this.attachedMesh.computeWorldMatrix(!0);var o=this._getMeshForward();this._cachedForward.copyFrom(o)}this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._getMeshForward=function(){var e=this.attachedMesh.forward;return this.attachedMesh.getScene().useRightHandedSystem&&(e.negateToRef(_.AA.Vector3[0]),e=_.AA.Vector3[0]),e},t.prototype._update=function(){if(r.prototype._update.call(this),this._light){if(this._light.parent&&this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()),this._light.position)if(this.attachedMesh.position.equals(this._cachedPosition))this.attachedMesh.position.copyFrom(this._light.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position);else{var e=this.attachedMesh.position;this._light.position=new _.Pq(e.x,e.y,e.z),this._cachedPosition.copyFrom(this.attachedMesh.position)}if(this._light.direction){var n=this._getMeshForward();if(_.Pq.DistanceSquared(n,this._cachedForward)>1e-4){var i=n;this._light.direction=new _.Pq(i.x,i.y,i.z),this._cachedForward.copyFrom(n)}else _.Pq.DistanceSquared(n,this._light.direction)>1e-4&&(this.attachedMesh.setDirection(this._light.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(n))}}},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._material.dispose(),r.prototype.dispose.call(this),this._attachedMeshParent.dispose()},t._CreateHemisphericLightMesh=function(e){var n=new xe("hemisphereLight",e),i=Xa(n.name,{segments:10,diameter:1},e);return i.position.z=-.15,i.rotation.x=Math.PI/2,i.parent=n,this._CreateLightLines(3,e).parent=n,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreatePointLightMesh=function(e){var n=new xe("pointLight",e),i=li(n.name,{segments:10,diameter:1},e);return i.rotation.x=Math.PI/2,i.parent=n,this._CreateLightLines(5,e).parent=n,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreateSpotLightMesh=function(e){var n=new xe("spotLight",e);li(n.name,{segments:10,diameter:1},e).parent=n;var i=Xa(n.name,{segments:10,diameter:2},e);return i.parent=n,i.rotation.x=-Math.PI/2,this._CreateLightLines(2,e).parent=n,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreateDirectionalLightMesh=function(e){var n=new xe("directionalLight",e),i=new xe(n.name,e);i.parent=n,li(n.name,{diameter:1.2,segments:10},e).parent=i;var o=_i(n.name,{updatable:!1,height:6,diameterTop:.3,diameterBottom:.3,tessellation:6,subdivisions:1},e);o.parent=i;var a=o.clone(n.name);a.scaling.y=.5,a.position.x+=1.25;var s=o.clone(n.name);s.scaling.y=.5,s.position.x+=-1.25;var l=_i(n.name,{updatable:!1,height:1,diameterTop:0,diameterBottom:.6,tessellation:6,subdivisions:1},e);return l.position.y+=3,l.parent=i,(a=l.clone(n.name)).position.y=1.5,a.position.x+=1.25,(s=l.clone(n.name)).position.y=1.5,s.position.x+=-1.25,i.scaling.scaleInPlace(t._Scale),i.rotation.z=Math.PI/2,i.rotation.y=Math.PI/2,n},t._Scale=.007,t._CreateLightLines=function(e,n){var i=new xe("root",n);i.rotation.x=Math.PI/2;var o=new xe("linePivot",n);o.parent=i;var a=_i("line",{updatable:!1,height:2,diameterTop:.2,diameterBottom:.3,tessellation:6,subdivisions:1},n);if(a.position.y=a.scaling.y/2+1.2,a.parent=o,e<2)return o;for(var s=0;s<4;s++){var l=o.clone("lineParentClone");l.rotation.z=Math.PI/4,l.rotation.y=Math.PI/2+Math.PI/2*s,l.getChildMeshes()[0].scaling.y=.5,l.getChildMeshes()[0].scaling.x=l.getChildMeshes()[0].scaling.z=.8,l.getChildMeshes()[0].position.y=l.getChildMeshes()[0].scaling.y/2+1.2}if(e<3)return i;for(s=0;s<4;s++){var c=o.clone("linePivotClone");c.rotation.z=Math.PI/2,c.rotation.y=Math.PI/2*s}if(e<4)return i;for(s=0;s<4;s++){var u=o.clone("linePivotClone");u.rotation.z=Math.PI+Math.PI/4,u.rotation.y=Math.PI/2+Math.PI/2*s,u.getChildMeshes()[0].scaling.y=.5,u.getChildMeshes()[0].scaling.x=u.getChildMeshes()[0].scaling.z=.8,u.getChildMeshes()[0].position.y=u.getChildMeshes()[0].scaling.y/2+1.2}return e<5||(o.clone("linePivotClone").rotation.z=Math.PI),i},t}(Jn),px=function(r){function t(e,n,i){e===void 0&&(e=Fn.DefaultUtilityLayer);var o=r.call(this,e)||this;return o._pointerObserver=null,o.onClickedObservable=new K.cP,o._camera=null,o._invProjection=new Ge.uq,o._material=new qt("cameraGizmoMaterial",o.gizmoLayer.utilityLayerScene),o._frustumLinesColor=i,o._material.diffuseColor=n??new z.v9(.5,.5,.5),o._material.specularColor=new z.v9(.1,.1,.1),o._pointerObserver=e.utilityLayerScene.onPointerObservable.add(function(a){o._camera&&(o._isHovered=!(!a.pickInfo||o._rootMesh.getChildMeshes().indexOf(a.pickInfo.pickedMesh)==-1),o._isHovered&&a.event.button===0&&o.onClickedObservable.notifyObservers(o._camera))},vt.Zp.POINTERDOWN),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"displayFrustum",{get:function(){return this._cameraLinesMesh.isEnabled()},set:function(e){this._cameraLinesMesh.setEnabled(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(e){var n,i,o=this;if(this._camera=e,this.attachedNode=e,e){this._customMeshSet||(this._cameraMesh&&this._cameraMesh.dispose(),this._cameraMesh=t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),this._cameraMesh.getChildMeshes(!1).forEach(function(l){l.material=o._material}),this._cameraMesh.parent=this._rootMesh),this._cameraLinesMesh&&this._cameraLinesMesh.dispose();var a=(i=(n=this._frustumLinesColor)===null||n===void 0?void 0:n.toColor4(1))!==null&&i!==void 0?i:new z.ov(1,1,1,1);this._cameraLinesMesh=t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene,a),this._cameraLinesMesh.parent=this._rootMesh,this.gizmoLayer.utilityLayerScene.activeCamera&&this.gizmoLayer.utilityLayerScene.activeCamera.maxZ<1.5*e.maxZ&&(this.gizmoLayer.utilityLayerScene.activeCamera.maxZ=1.5*e.maxZ),this.attachedNode.reservedDataStore||(this.attachedNode.reservedDataStore={}),this.attachedNode.reservedDataStore.cameraGizmo=this;var s=this.gizmoLayer._getSharedGizmoLight();s.includedOnlyMeshes=s.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){r.prototype._update.call(this),this._camera&&(this._camera.getProjectionMatrix().invertToRef(this._invProjection),this._cameraLinesMesh.setPivotMatrix(this._invProjection,!1),this._cameraLinesMesh.scaling.x=1/this._rootMesh.scaling.x,this._cameraLinesMesh.scaling.y=1/this._rootMesh.scaling.y,this._cameraLinesMesh.scaling.z=1/this._rootMesh.scaling.z,this._cameraMesh.parent=null,this._cameraMesh.rotation.y=.5*Math.PI*(this._camera.getScene().useRightHandedSystem?1:-1),this._cameraMesh.parent=this._rootMesh)},t.prototype.setCustomMesh=function(e){if(e.getScene()!=this.gizmoLayer.utilityLayerScene)throw"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";this._cameraMesh&&this._cameraMesh.dispose(),this._cameraMesh=e,this._cameraMesh.parent=this._rootMesh,this._customMeshSet=!0},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._material.dispose(),r.prototype.dispose.call(this)},t._CreateCameraMesh=function(e){var n=new xe("rootCameraGizmo",e),i=new xe(n.name,e);i.parent=n,Oi(n.name,{width:1,height:.8,depth:.5},e).parent=i;var o=_i(n.name,{height:.5,diameterTop:.8,diameterBottom:.8},e);o.parent=i,o.position.y=.3,o.position.x=-.6,o.rotation.x=.5*Math.PI;var a=_i(n.name,{height:.5,diameterTop:.6,diameterBottom:.6},e);a.parent=i,a.position.y=.5,a.position.x=.4,a.rotation.x=.5*Math.PI;var s=_i(n.name,{height:.5,diameterTop:.5,diameterBottom:.5},e);return s.parent=i,s.position.y=0,s.position.x=.6,s.rotation.z=.5*Math.PI,n.scaling.scaleInPlace(t._Scale),i.position.x=-.9,n},t._CreateCameraFrustum=function(e,n){var i=new xe("rootCameraGizmo",e),o=new xe(i.name,e);o.parent=i;for(var a=0;a<4;a+=2)for(var s=0;s<4;s+=2){var l=dn("lines",{points:[new _.Pq(-1+s,-1+a,-1),new _.Pq(-1+s,-1+a,1)],colors:[n,n]},e);l.parent=o,l.alwaysSelectAsActiveMesh=!0,l.isPickable=!1,(l=dn("lines",{points:[new _.Pq(-1,-1+s,-1+a),new _.Pq(1,-1+s,-1+a)],colors:[n,n]},e)).parent=o,l.alwaysSelectAsActiveMesh=!0,l.isPickable=!1,(l=dn("lines",{points:[new _.Pq(-1+s,-1,-1+a),new _.Pq(-1+s,1,-1+a)],colors:[n,n]},e)).parent=o,l.alwaysSelectAsActiveMesh=!0,l.isPickable=!1}return i},t._Scale=.05,t}(Jn),ci=function(r){function t(e,n,i,o,a,s,l,c,u,d,h,p){s===void 0&&(s=Ie.g.BILINEAR_SAMPLINGMODE),u===void 0&&(u=P.Y.TEXTURETYPE_UNSIGNED_INT),d===void 0&&(d=""),h===void 0&&(h=!1),p===void 0&&(p=P.Y.TEXTUREFORMAT_RGBA);var m=r.call(this,e,"kernelBlur",["delta","direction"],["circleOfConfusionSampler"],o,a,s,l,c,null,u,"kernelBlur",{varyingCount:0,depCount:0},!0,p)||this;return m._blockCompilation=h,m._packedFloat=!1,m._staticDefines="",m._staticDefines=d,m.direction=n,m.onApplyObservable.add(function(v){m._outputTexture?v.setFloat2("delta",1/m._outputTexture.width*m.direction.x,1/m._outputTexture.height*m.direction.y):v.setFloat2("delta",1/m.width*m.direction.x,1/m.height*m.direction.y)}),m.kernel=i,m}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this._blockCompilation||this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this._blockCompilation||this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"BlurPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,76832)),Promise.resolve().then(L.bind(L,7621))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,42015)),Promise.resolve().then(L.bind(L,41182))])),r.prototype._gatherImports.call(this,e,n)},t.prototype.updateEffect=function(e,n,i,o,a,s){this._updateParameters(a,s)},t.prototype._updateParameters=function(e,n){for(var i=this._kernel,o=(i-1)/2,a=[],s=[],l=0,c=0;c<i;c++){var u=c/(i-1),d=this._gaussianWeight(2*u-1);a[c]=c-o,s[c]=d,l+=d}for(c=0;c<s.length;c++)s[c]/=l;var h=[],p=[],m=[];for(c=0;c<=o;c+=2){var v=Math.min(c+1,Math.floor(o));if(c===v)m.push({o:a[c],w:s[c]});else{var b=v===o,E=s[c]+s[v]*(b?.5:1),C=a[c]+1/(1+s[c]/s[v]);C===0?(m.push({o:a[c],w:s[c]}),m.push({o:a[c+1],w:s[c+1]})):(m.push({o:C,w:E}),m.push({o:-C,w:E}))}}for(c=0;c<m.length;c++)p[c]=m[c].o,h[c]=m[c].w;a=p,s=h;var T=this.getEngine().getCaps().maxVaryingVectors-(this.shaderLanguage===1?1:0),f=Math.max(T,0)-1,g=Math.min(a.length,f),S="";for(S+=this._staticDefines,this._staticDefines.indexOf("DOF")!=-1&&(S+="#define CENTER_WEIGHT ".concat(this._glslFloat(s[g-1]),`
|
||
`),g--),c=0;c<g;c++)S+="#define KERNEL_OFFSET".concat(c," ").concat(this._glslFloat(a[c]),`
|
||
`),S+="#define KERNEL_WEIGHT".concat(c," ").concat(this._glslFloat(s[c]),`
|
||
`);var y=0;for(c=f;c<a.length;c++)S+="#define KERNEL_DEP_OFFSET".concat(y," ").concat(this._glslFloat(a[c]),`
|
||
`),S+="#define KERNEL_DEP_WEIGHT".concat(y," ").concat(this._glslFloat(s[c]),`
|
||
`),y++;this.packedFloat&&(S+="#define PACKEDFLOAT 1"),this._blockCompilation=!1,r.prototype.updateEffect.call(this,S,null,null,{varyingCount:g,depCount:y},e,n)},t.prototype._nearestBestKernel=function(e){for(var n=Math.round(e),i=0,o=[n,n-1,n+1,n-2,n+2];i<o.length;i++){var a=o[i];if(a%2!=0&&Math.floor(a/2)%2==0&&a>0)return Math.max(a,3)}return Math.max(n,3)},t.prototype._gaussianWeight=function(e){var n=.3333333333333333,i=-e*e/(2*n*n);return 1/(Math.sqrt(2*Math.PI)*n)*Math.exp(i)},t.prototype._glslFloat=function(e,n){return n===void 0&&(n=8),e.toFixed(n).replace(/0+$/,"")},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.direction,e.kernel,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,void 0,!1)},e,i,o)},(0,A.Cg)([(0,V.lK)("kernel")],t.prototype,"_kernel",void 0),(0,A.Cg)([(0,V.lK)("packedFloat")],t.prototype,"_packedFloat",void 0),(0,A.Cg)([(0,V.WM)()],t.prototype,"direction",void 0),t}(_t.w);(0,j.Y5)("BABYLON.BlurPostProcess",ci);var Gd=function(r){function t(e,n,i,o,a,s,l){a===void 0&&(a=P.Y.TEXTURETYPE_UNSIGNED_INT),s===void 0&&(s=Ie.g.BILINEAR_SAMPLINGMODE),l===void 0&&(l=!0);var c=r.call(this,e,n,i,o,!0,a,!1,s,l)||this;if(c.mirrorPlane=new Qo.Z(0,1,0,1),c._transformMatrix=_.uq.Zero(),c._mirrorMatrix=_.uq.Zero(),c._adaptiveBlurKernel=0,c._blurKernelX=0,c._blurKernelY=0,c._blurRatio=1,!(i=c.getScene()))return c;c.ignoreCameraViewport=!0,c._updateGammaSpace(),c._imageProcessingConfigChangeObserver=i.imageProcessingConfiguration.onUpdateParameters.add(function(){c._updateGammaSpace()});var u,d=i.getEngine();return d.supportsUniformBuffers&&(c._sceneUBO=i.createSceneUniformBuffer('Scene for Mirror Texture (name "'.concat(e,'")'))),c.onBeforeBindObservable.add(function(){var h;(h=d._debugPushGroup)===null||h===void 0||h.call(d,"mirror generation for ".concat(e),1)}),c.onAfterUnbindObservable.add(function(){var h;(h=d._debugPopGroup)===null||h===void 0||h.call(d,1)}),c.onBeforeRenderObservable.add(function(){c._sceneUBO&&(c._currentSceneUBO=i.getSceneUniformBuffer(),i.setSceneUniformBuffer(c._sceneUBO),i.getSceneUniformBuffer().unbindEffect()),_.uq.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._mirrorMatrix.multiplyToRef(i.getViewMatrix(),c._transformMatrix),i.setTransformMatrix(c._transformMatrix,i.getProjectionMatrix()),u=i.clipPlane,i.clipPlane=c.mirrorPlane,i._mirroredCameraPosition=_.Pq.TransformCoordinates(i.activeCamera.globalPosition,c._mirrorMatrix)}),c.onAfterRenderObservable.add(function(){c._sceneUBO&&i.setSceneUniformBuffer(c._currentSceneUBO),i.updateTransformMatrix(),i._mirroredCameraPosition=null,i.clipPlane=u}),c}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),n=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*n,this.blurKernelY=this._adaptiveBlurKernel*i},t.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},t.prototype._updateGammaSpace=function(){var e=this.getScene();e&&(this.gammaSpace=!e.imageProcessingConfiguration.isEnabled||!e.imageProcessingConfiguration.applyByPostProcess)},t.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var e=this.getScene().getEngine(),n=e.getCaps().textureFloatRender&&e.getCaps().textureFloatLinearFiltering?P.Y.TEXTURETYPE_FLOAT:P.Y.TEXTURETYPE_HALF_FLOAT;this._blurX=new ci("horizontal blur",new _.I9(1,0),this._blurKernelX,this._blurRatio,null,Ie.g.BILINEAR_SAMPLINGMODE,e,!1,n),this._blurX.autoClear=!1,this._blurRatio===1&&this.samples<2&&this._texture?this._blurX.inputTexture=this._renderTarget:this._blurX.alwaysForcePOT=!0,this._blurY=new ci("vertical blur",new _.I9(0,1),this._blurKernelY,this._blurRatio,null,Ie.g.BILINEAR_SAMPLINGMODE,e,!1,n),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=this._blurRatio!==1,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}else this._blurY&&(this.removePostProcess(this._blurY),this._blurY.dispose(),this._blurY=null),this._blurX&&(this.removePostProcess(this._blurX),this._blurX.dispose(),this._blurX=null)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=this.getSize(),i=new t(this.name,n.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(i.renderList=this.renderList.slice(0)),i},t.prototype.serialize=function(){if(!this.name)return null;var e=r.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},t.prototype.dispose=function(){var e;r.prototype.dispose.call(this);var n=this.getScene();n&&n.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),(e=this._sceneUBO)===null||e===void 0||e.dispose()},t}(un.$);Ie.g._CreateMirror=function(r,t,e,n){return new Gd(r,t,e,n)};var mr=function(r){function t(e,n,i,o,a,s,l,c,u,d,h,p,m,v,b){i===void 0&&(i=null),o===void 0&&(o=!1),a===void 0&&(a=null),s===void 0&&(s=null),l===void 0&&(l=null),c===void 0&&(c=P.Y.TEXTUREFORMAT_RGBA),u===void 0&&(u=!1),d===void 0&&(d=null),h===void 0&&(h=!1),p===void 0&&(p=.8),m===void 0&&(m=0);var E,C,T,f,g,S,y,x,R,I,M,D,B,F=this;(F=r.call(this,n)||this).onLoadObservable=new K.cP,F.boundingBoxPosition=_.Pq.Zero(),F._rotationY=0,F._files=null,F._forcedExtension=null,F._extensions=null,F._textureMatrixRefraction=new _.uq,F._buffer=null,F.name=e,F.url=e,F._noMipmap=o,F.hasAlpha=!1,F.isCube=!0,F._textureMatrix=_.uq.Identity(),F.coordinatesMode=Ie.g.CUBIC_MODE;var X=null,$=null;return i===null||Array.isArray(i)?(F._noMipmap=o,F._format=c,F._createPolynomials=h,X=i,F._loaderOptions=v,F._useSRGBBuffer=b,F._lodScale=p,F._lodOffset=m):(X=(E=i.extensions)!==null&&E!==void 0?E:null,F._noMipmap=(C=i.noMipmap)!==null&&C!==void 0&&C,a=(T=i.files)!==null&&T!==void 0?T:null,$=(f=i.buffer)!==null&&f!==void 0?f:null,F._format=(g=i.format)!==null&&g!==void 0?g:P.Y.TEXTUREFORMAT_RGBA,u=(S=i.prefiltered)!==null&&S!==void 0&&S,d=(y=i.forcedExtension)!==null&&y!==void 0?y:null,F._createPolynomials=(x=i.createPolynomials)!==null&&x!==void 0&&x,F._lodScale=(R=i.lodScale)!==null&&R!==void 0?R:.8,F._lodOffset=(I=i.lodOffset)!==null&&I!==void 0?I:0,F._loaderOptions=i.loaderOptions,F._useSRGBBuffer=i.useSRGBBuffer,s=(M=i.onLoad)!==null&&M!==void 0?M:null,l=(D=i.onError)!==null&&D!==void 0?D:null),(e||a)&&F.updateURL(e,d,s,u,l,X,(B=F.getScene())===null||B===void 0?void 0:B.useDelayedTextureLoading,a,$),F}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var n=this.getScene();n&&n.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(_.uq.RotationY(this._rotationY))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forcedExtension",{get:function(){return this._forcedExtension},enumerable:!1,configurable:!0}),t.CreateFromImages=function(e,n,i){var o="";return e.forEach(function(a){return o+=a}),new t(o,n,null,i,e)},t.CreateFromPrefilteredData=function(e,n,i,o){i===void 0&&(i=null),o===void 0&&(o=!0);var a=n.useDelayedTextureLoading;n.useDelayedTextureLoading=!1;var s=new t(e,n,null,!1,null,null,null,void 0,!0,i,o);return n.useDelayedTextureLoading=a,s},t.prototype.getClassName=function(){return"CubeTexture"},t.prototype.updateURL=function(e,n,i,o,a,s,l,c,u){n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=!1),a===void 0&&(a=null),s===void 0&&(s=null),l===void 0&&(l=!1),c===void 0&&(c=null),u===void 0&&(u=null),this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,n&&(this._forcedExtension=n);var d=e.lastIndexOf("."),h=n||(d>-1?e.substring(d).toLowerCase():""),p=h.indexOf(".dds")===0,m=h.indexOf(".env")===0,v=h.indexOf(".basis")===0;if(m?(this.gammaSpace=!1,this._prefiltered=!1,this.anisotropicFilteringLevel=1):(this._prefiltered=o,o&&(this.gammaSpace=!1,this.anisotropicFilteringLevel=1)),c)this._files=c;else if(v||m||p||s||(s=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),this._files=this._files||[],this._files.length=0,s){for(var b=0;b<s.length;b++)this._files.push(e+s[b]);this._extensions=s}this._buffer=u,l?(this.delayLoadState=P.Y.DELAYLOADSTATE_NOTLOADED,this._delayedOnLoad=i,this._delayedOnError=a):this._loadTexture(i,a)},t.prototype.delayLoad=function(e){this.delayLoadState===P.Y.DELAYLOADSTATE_NOTLOADED&&(e&&(this._forcedExtension=e),this.delayLoadState=P.Y.DELAYLOADSTATE_LOADED,this._loadTexture(this._delayedOnLoad,this._delayedOnError))},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var n,i,o=this;if(e.updateFlag!==this._textureMatrix.updateFlag&&(e.isIdentity()!==this._textureMatrix.isIdentity()&&((n=this.getScene())===null||n===void 0||n.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(c){return c.getActiveTextures().indexOf(o)!==-1})),this._textureMatrix=e,(i=this.getScene())===null||i===void 0?void 0:i.useRightHandedSystem)){var a=_.AA.Vector3[0],s=_.AA.Quaternion[0],l=_.AA.Vector3[1];this._textureMatrix.decompose(a,s,l),s.z*=-1,s.w*=-1,_.uq.ComposeToRef(a,s,l,this._textureMatrixRefraction)}},t.prototype.getRefractionTextureMatrix=function(){var e;return!((e=this.getScene())===null||e===void 0)&&e.useRightHandedSystem?this._textureMatrixRefraction:this._textureMatrix},t.prototype._loadTexture=function(e,n){var i,o=this;e===void 0&&(e=null),n===void 0&&(n=null);var a=this.getScene(),s=this._texture;this._texture=this._getFromCache(this.url,this._noMipmap,void 0,void 0,this._useSRGBBuffer,this.isCube);var l=function(){var u;o.onLoadObservable.notifyObservers(o),s&&(s.dispose(),(u=o.getScene())===null||u===void 0||u.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag)),e&&e()},c=function(u,d){o._loadingError=!0,o._errorObject={message:u,exception:d},n&&n(u,d),Ie.g.OnTextureLoadErrorObservable.notifyObservers(o)};this._texture?this._texture.isReady?ze.S0.SetImmediate(function(){return l()}):this._texture.onLoadedObservable.add(function(){return l()}):(this._prefiltered?this._texture=this._getEngine().createPrefilteredCubeTexture(this.url,a,this._lodScale,this._lodOffset,e,c,this._format,this._forcedExtension,this._createPolynomials):this._texture=this._getEngine().createCubeTexture(this.url,a,this._files,this._noMipmap,e,c,this._format,this._forcedExtension,!1,this._lodScale,this._lodOffset,null,this._loaderOptions,!!this._useSRGBBuffer,this._buffer),(i=this._texture)===null||i===void 0||i.onLoadedObservable.add(function(){return o.onLoadObservable.notifyObservers(o)}))},t.Parse=function(e,n,i){var o=tt.p.Parse(function(){var c,u=!1;return e.prefiltered&&(u=e.prefiltered),new t(i+((c=e.url)!==null&&c!==void 0?c:e.name),n,e.extensions,!1,e.files||null,null,null,void 0,u,e.forcedExtension)},e,n);if(e.boundingBoxPosition&&(o.boundingBoxPosition=_.Pq.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(o.boundingBoxSize=_.Pq.FromArray(e.boundingBoxSize)),e.animations)for(var a=0;a<e.animations.length;a++){var s=e.animations[a],l=(0,j.n9)("BABYLON.Animation");l&&o.animations.push(l.Parse(s))}return o},t.prototype.clone=function(){var e=this,n=0,i=tt.p.Clone(function(){var o=new t(e.url,e.getScene()||e._getEngine(),e._extensions,e._noMipmap,e._files);return n=o.uniqueId,o},this);return i.uniqueId=n,i},(0,A.Cg)([(0,V.lK)()],t.prototype,"url",void 0),(0,A.Cg)([(0,V.P_)()],t.prototype,"boundingBoxPosition",void 0),(0,A.Cg)([(0,V.P_)()],t.prototype,"boundingBoxSize",null),(0,A.Cg)([(0,V.lK)("rotationY")],t.prototype,"rotationY",null),(0,A.Cg)([(0,V.lK)("files")],t.prototype,"_files",void 0),(0,A.Cg)([(0,V.lK)("forcedExtension")],t.prototype,"_forcedExtension",void 0),(0,A.Cg)([(0,V.lK)("extensions")],t.prototype,"_extensions",void 0),(0,A.Cg)([(0,V.GG)("textureMatrix")],t.prototype,"_textureMatrix",void 0),(0,A.Cg)([(0,V.GG)("textureMatrixRefraction")],t.prototype,"_textureMatrixRefraction",void 0),t}(Ki.t);Ie.g._CubeTextureParser=mr.Parse,(0,j.Y5)("BABYLON.CubeTexture",mr);var QD=function(r){function t(){var e=r.call(this)||this;return e.DIFFUSE=!1,e.DIFFUSEDIRECTUV=0,e.GAMMADIFFUSE=!1,e.DIFFUSEHASALPHA=!1,e.OPACITYFRESNEL=!1,e.REFLECTIONBLUR=!1,e.REFLECTIONFRESNEL=!1,e.REFLECTIONFALLOFF=!1,e.TEXTURELODSUPPORT=!1,e.PREMULTIPLYALPHA=!1,e.USERGBCOLOR=!1,e.USEHIGHLIGHTANDSHADOWCOLORS=!1,e.BACKMAT_SHADOWONLY=!1,e.NOISE=!1,e.REFLECTIONBGR=!1,e.PROJECTED_GROUND=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.DITHER=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.SKIPFINALCOLORCLAMP=!1,e.EXPOSURE=!1,e.MULTIVIEW=!1,e.REFLECTION=!1,e.REFLECTIONMAP_3D=!1,e.REFLECTIONMAP_SPHERICAL=!1,e.REFLECTIONMAP_PLANAR=!1,e.REFLECTIONMAP_CUBIC=!1,e.REFLECTIONMAP_PROJECTION=!1,e.REFLECTIONMAP_SKYBOX=!1,e.REFLECTIONMAP_EXPLICIT=!1,e.REFLECTIONMAP_EQUIRECTANGULAR=!1,e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.INVERTCUBICMAP=!1,e.REFLECTIONMAP_OPPOSITEZ=!1,e.LODINREFLECTIONALPHA=!1,e.GAMMAREFLECTION=!1,e.RGBDREFLECTION=!1,e.EQUIRECTANGULAR_RELFECTION_FOV=!1,e.MAINUV1=!1,e.MAINUV2=!1,e.UV1=!1,e.UV2=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.POINTSIZE=!1,e.FOG=!1,e.NORMAL=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.SHADOWFLOAT=!1,e.LOGARITHMICDEPTH=!1,e.NONUNIFORMSCALING=!1,e.ALPHATEST=!1,e.rebuild(),e}return(0,A.C6)(t,r),t}(si),ja=function(r){function t(e,n,i){i===void 0&&(i=!1);var o=r.call(this,e,n)||this;o.primaryColor=z.v9.White(),o._primaryColorShadowLevel=0,o._primaryColorHighlightLevel=0,o.reflectionTexture=null,o.reflectionBlur=0,o.diffuseTexture=null,o._shadowLights=null,o.shadowLights=null,o.shadowLevel=0,o.sceneCenter=_.Pq.Zero(),o.opacityFresnel=!0,o.reflectionFresnel=!1,o.reflectionFalloffDistance=0,o.reflectionAmount=1,o.reflectionReflectance0=.05,o.reflectionReflectance90=.5,o.useRGBColor=!0,o.enableNoise=!1,o._fovMultiplier=1,o.useEquirectangularFOV=!1,o._maxSimultaneousLights=4,o.maxSimultaneousLights=4,o._shadowOnly=!1,o.shadowOnly=!1,o._imageProcessingObserver=null,o.switchToBGR=!1,o._enableGroundProjection=!1,o.enableGroundProjection=!1,o.projectedGroundRadius=1e3,o.projectedGroundHeight=10,o._renderTargets=new er.L(16),o._reflectionControls=_.IU.Zero(),o._white=z.v9.White(),o._primaryShadowColor=z.v9.Black(),o._primaryHighlightColor=z.v9.Black(),o._shadersLoaded=!1;var a=o.getScene().getEngine();return a.isWebGPU&&!i&&(o._uniformBuffer&&o._uniformBuffer.dispose(),o._uniformBuffer=new Ui.D(a,void 0,void 0,o.name,!0),o._shaderLanguage=1),o._attachImageProcessingConfiguration(null),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._diffuseTexture&&o._diffuseTexture.isRenderTarget&&o._renderTargets.push(o._diffuseTexture),o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),o._renderTargets},o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"_perceptualColor",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorShadowLevel",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorHighlightLevel",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionStandardFresnelWeight",{set:function(e){var n=e;n<.5?(n*=2,this.reflectionReflectance0=t.StandardReflectance0*n,this.reflectionReflectance90=t.StandardReflectance90*n):(n=2*n-1,this.reflectionReflectance0=t.StandardReflectance0+(1-t.StandardReflectance0)*n,this.reflectionReflectance90=t.StandardReflectance90+(1-t.StandardReflectance90)*n)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._fovMultiplier},set:function(e){isNaN(e)&&(e=1),this._fovMultiplier=Math.max(0,Math.min(2,e))},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var n=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._computePrimaryColorFromPerceptualColor(),n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!1,configurable:!0}),t.prototype.needAlphaTesting=function(){return!0},t.prototype.needAlphaBlending=function(){return this.alpha<1||this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._shadowOnly},t.prototype.isReadyForSubMesh=function(e,n,i){var o=this;i===void 0&&(i=!1);var a=n._drawWrapper;if(a.effect&&this.isFrozen&&a._wasPreviouslyReady&&a._wasPreviouslyUsingInstances===i)return!0;n.materialDefines||(n.materialDefines=new QD);var s=this.getScene(),l=n.materialDefines;if(this._isReadyForSubMesh(n))return!0;var c=s.getEngine();if((0,Re.az)(s,e,l,!1,this._maxSimultaneousLights),l._needNormals=!0,(0,Re.VO)(s,l),l._areTexturesDirty){if(l._needUVs=!1,s.texturesEnabled){if(s.getEngine().getCaps().textureLOD&&(l.TEXTURELODSUPPORT=!0),this._diffuseTexture&&$e.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;(0,Re.YT)(this._diffuseTexture,l,"DIFFUSE"),l.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,l.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,l.OPACITYFRESNEL=this._opacityFresnel}else l.DIFFUSE=!1,l.DIFFUSEDIRECTUV=0,l.DIFFUSEHASALPHA=!1,l.GAMMADIFFUSE=!1,l.OPACITYFRESNEL=!1;var u=this._reflectionTexture;if(u&&$e.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;switch(l.REFLECTION=!0,l.GAMMAREFLECTION=u.gammaSpace,l.RGBDREFLECTION=u.isRGBD,l.REFLECTIONBLUR=this._reflectionBlur>0,l.LODINREFLECTIONALPHA=u.lodLevelInAlpha,l.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,l.REFLECTIONBGR=this.switchToBGR,u.coordinatesMode===Ie.g.INVCUBIC_MODE&&(l.INVERTCUBICMAP=!0),l.REFLECTIONMAP_3D=u.isCube,l.REFLECTIONMAP_OPPOSITEZ=l.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!u.invertZ:u.invertZ,u.coordinatesMode){case Ie.g.EXPLICIT_MODE:l.REFLECTIONMAP_EXPLICIT=!0;break;case Ie.g.PLANAR_MODE:l.REFLECTIONMAP_PLANAR=!0;break;case Ie.g.PROJECTION_MODE:l.REFLECTIONMAP_PROJECTION=!0;break;case Ie.g.SKYBOX_MODE:l.REFLECTIONMAP_SKYBOX=!0;break;case Ie.g.SPHERICAL_MODE:l.REFLECTIONMAP_SPHERICAL=!0;break;case Ie.g.EQUIRECTANGULAR_MODE:l.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ie.g.FIXED_EQUIRECTANGULAR_MODE:l.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ie.g.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:l.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ie.g.CUBIC_MODE:case Ie.g.INVCUBIC_MODE:default:l.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(l.REFLECTIONFRESNEL=!0,l.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(l.REFLECTIONFRESNEL=!1,l.REFLECTIONFALLOFF=!1)}else l.REFLECTION=!1,l.REFLECTIONFRESNEL=!1,l.REFLECTIONFALLOFF=!1,l.REFLECTIONBLUR=!1,l.REFLECTIONMAP_3D=!1,l.REFLECTIONMAP_SPHERICAL=!1,l.REFLECTIONMAP_PLANAR=!1,l.REFLECTIONMAP_CUBIC=!1,l.REFLECTIONMAP_PROJECTION=!1,l.REFLECTIONMAP_SKYBOX=!1,l.REFLECTIONMAP_EXPLICIT=!1,l.REFLECTIONMAP_EQUIRECTANGULAR=!1,l.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,l.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,l.INVERTCUBICMAP=!1,l.REFLECTIONMAP_OPPOSITEZ=!1,l.LODINREFLECTIONALPHA=!1,l.GAMMAREFLECTION=!1,l.RGBDREFLECTION=!1}l.PREMULTIPLYALPHA=this.alphaMode===P.Y.ALPHA_PREMULTIPLIED||this.alphaMode===P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF,l.USERGBCOLOR=this._useRGBColor,l.NOISE=this._enableNoise}if(l._areLightsDirty&&(l.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(this._primaryColorShadowLevel!==0||this._primaryColorHighlightLevel!==0),l.BACKMAT_SHADOWONLY=this._shadowOnly),l._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(l)}if(l._areMiscDirty&&(l.REFLECTIONMAP_3D&&this._enableGroundProjection?(l.PROJECTED_GROUND=!0,l.REFLECTIONMAP_SKYBOX=!0):l.PROJECTED_GROUND=!1),(0,Re.fm)(e,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),l),(0,Re.OR)(s,c,this,l,i,null,n.getRenderingMesh().hasThinInstances),(0,Re.qB)(e,l,!1,!0,!1)&&e&&(s.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(Y.R.NormalKind)||(e.createNormals(!0),O.V.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),l.isDirty){l.markAsProcessed(),s.resetCachedMaterial();var d=new Tr;l.FOG&&d.addFallback(0,"FOG"),l.POINTSIZE&&d.addFallback(1,"POINTSIZE"),l.MULTIVIEW&&d.addFallback(0,"MULTIVIEW"),(0,Re.c4)(l,d,this._maxSimultaneousLights);var h=[Y.R.PositionKind];l.NORMAL&&h.push(Y.R.NormalKind),l.UV1&&h.push(Y.R.UVKind),l.UV2&&h.push(Y.R.UV2Kind),(0,Re.ni)(h,e,l,d),(0,Re.ER)(h,l);var p=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix","projectedGroundInfos","logarithmicDepthConstant"];(0,tn.TV)(p);var m=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],v=["Material","Scene"];Ti.p&&(Ti.p.PrepareUniforms(p,l),Ti.p.PrepareSamplers(m,l)),(0,Re.Bb)({uniformsNames:p,uniformBuffersNames:v,samplers:m,defines:l,maxSimultaneousLights:this._maxSimultaneousLights});var b=l.toString(),E=s.getEngine().createEffect("background",{attributes:h,uniformsNames:p,uniformBuffersNames:v,samplers:m,defines:b,fallbacks:d,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights},shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:function(){return(0,A.sH)(o,void 0,void 0,function(){return(0,A.YH)(this,function(C){switch(C.label){case 0:return this.shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,71433)),Promise.resolve().then(L.bind(L,40387))])];case 1:return C.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,57826)),Promise.resolve().then(L.bind(L,7590))])];case 3:C.sent(),C.label=4;case 4:return this._shadersLoaded=!0,[2]}})})}},c);n.setEffect(E,l,this._materialContext),this.buildUniformLayout()}return!(!n.effect||!n.effect.isReady()||(l._renderId=s.getRenderId(),a._wasPreviouslyReady=!0,a._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),0))},t.prototype._computePrimaryColorFromPerceptualColor=function(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor,this.getScene().getEngine().useExactSrgbConversions),this._imageProcessingConfiguration&&this._primaryColor.scaleToRef(1/this._imageProcessingConfiguration.exposure,this._primaryColor),this._computePrimaryColors())},t.prototype._computePrimaryColors=function(){this._primaryColorShadowLevel===0&&this._primaryColorHighlightLevel===0||(this._primaryColor.scaleToRef(this._primaryColorShadowLevel,this._primaryShadowColor),this._primaryColor.subtractToRef(this._primaryShadowColor,this._primaryShadowColor),this._white.subtractToRef(this._primaryColor,this._primaryHighlightColor),this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel,this._primaryHighlightColor),this._primaryColor.addToRef(this._primaryHighlightColor,this._primaryHighlightColor))},t.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vPrimaryColorShadow",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("fFovMultiplier",1),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroundCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.addUniform("projectedGroundInfos",2),this._uniformBuffer.create()},t.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),r.prototype.unbind.call(this)},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindForSubMesh=function(e,n,i){var o=this.getScene(),a=i.materialDefines;if(a){var s=i.effect;if(s){this._activeEffect=s,this.bindOnlyWorldMatrix(e),(0,Re.f$)(n,this._activeEffect);var l=this._mustRebind(o,s,i,n.visibility);if(l){this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s);var c=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync&&!i._drawWrapper._forceRebindOnNextCall||(o.texturesEnabled&&(this._diffuseTexture&&$e.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),(0,Re.mA)(this._diffuseTexture,this._uniformBuffer,"diffuse")),c&&$e.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",c.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",c.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",c.getSize().width,c.lodGenerationScale,c.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),a.USEHIGHLIGHTANDSHADOWCOLORS?(this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryHighlightColor,1),this._uniformBuffer.updateColor4("vPrimaryColorShadow",this._primaryShadowColor,1)):this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,1)),this._uniformBuffer.updateFloat("fFovMultiplier",this._fovMultiplier),o.texturesEnabled&&(this._diffuseTexture&&$e.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),c&&$e.ReflectionTextureEnabled&&(a.REFLECTIONBLUR&&a.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",c):a.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",c._lodTextureMid||c),this._uniformBuffer.setTexture("reflectionSamplerLow",c._lodTextureLow||c),this._uniformBuffer.setTexture("reflectionSamplerHigh",c._lodTextureHigh||c)):this._uniformBuffer.setTexture("reflectionSampler",c),a.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w))),a.PROJECTED_GROUND&&this._uniformBuffer.updateFloat2("projectedGroundInfos",this.projectedGroundRadius,this.projectedGroundHeight)),(0,tn.gS)(this._activeEffect,this,o),o.bindEyePosition(s)}else o.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._uniformBuffer.bindToEffect(s,"Material"),this._needToBindSceneUbo=!0);!l&&this.isFrozen||(o.lightsEnabled&&(0,Re.RL)(o,n,this._activeEffect,a,this._maxSimultaneousLights),this.bindView(s),(0,Re.Yy)(o,n,this._activeEffect,!0),this._useLogarithmicDepth&&(0,Re.DL)(a,s,o),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(n,this._activeEffect,i),this._uniformBuffer.update()}}},t.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||this._reflectionTexture===e||this._diffuseTexture===e},t.prototype.dispose=function(e,n){e===void 0&&(e=!1),n===void 0&&(n=!1),n&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e)},t.prototype.clone=function(e){var n=this;return tt.p.Clone(function(){return new t(e,n.getScene())},this)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,n,i){return tt.p.Parse(function(){return new t(e.name,n)},e,n,i)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,(0,A.Cg)([(0,V.jT)()],t.prototype,"_primaryColor",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"__perceptualColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_primaryColorShadowLevel",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_primaryColorHighlightLevel",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),(0,A.Cg)([(0,V.uM)()],t.prototype,"_reflectionTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_reflectionBlur",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),(0,A.Cg)([(0,V.uM)()],t.prototype,"_diffuseTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_shadowLevel",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),(0,A.Cg)([(0,V.P_)()],t.prototype,"_sceneCenter",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_opacityFresnel",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_reflectionFresnel",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_reflectionFalloffDistance",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_reflectionAmount",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_reflectionReflectance0",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_reflectionReflectance90",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_useRGBColor",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_enableNoise",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_maxSimultaneousLights",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_shadowOnly",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"shadowOnly",void 0),(0,A.Cg)([(0,V.n1)()],t.prototype,"_imageProcessingConfiguration",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"enableGroundProjection",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"projectedGroundRadius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"projectedGroundHeight",void 0),t}(Ro);(0,j.Y5)("BABYLON.BackgroundMaterial",ja);var kd=function(){function r(t,e){var n=this;this._errorHandler=function(i,o){n.onErrorObservable.notifyObservers({message:i,exception:o})},this._options=(0,A.Cl)((0,A.Cl)({},r._GetDefaultOptions(e)),t),this._scene=e,this.onErrorObservable=new K.cP,this._setupBackground(),this._setupImageProcessing()}return r._GetDefaultOptions=function(t){return{createGround:!0,groundSize:15,groundTexture:this._GroundTextureCDNUrl,groundColor:new z.v9(.2,.2,.3).toLinearSpace(t.getEngine().useExactSrgbConversions).scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:P.Y.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._SkyboxTextureCDNUrl,skyboxColor:new z.v9(.2,.2,.3).toLinearSpace(t.getEngine().useExactSrgbConversions).scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:_.Pq.Zero(),setupImageProcessing:!0,environmentTexture:this._EnvironmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(r.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"skybox",{get:function(){return this._skybox},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ground",{get:function(){return this._ground},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!1,configurable:!0}),r.prototype.updateOptions=function(t){var e=(0,A.Cl)((0,A.Cl)({},this._options),t);this._ground&&!e.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!e.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=e.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!e.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!e.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=e.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!e.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=e.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=e,this._setupBackground(),this._setupImageProcessing()},r.prototype.setMainColor=function(t){this.groundMaterial&&(this.groundMaterial.primaryColor=t),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=t),this.groundMirror&&(this.groundMirror.clearColor=new z.ov(t.r,t.g,t.b,1))},r.prototype._setupImageProcessing=function(){this._options.setupImageProcessing&&(this._scene.imageProcessingConfiguration.contrast=this._options.cameraContrast,this._scene.imageProcessingConfiguration.exposure=this._options.cameraExposure,this._scene.imageProcessingConfiguration.toneMappingEnabled=this._options.toneMappingEnabled,this._setupEnvironmentTexture())},r.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof Ki.t)this._scene.environmentTexture=this._options.environmentTexture;else{var t=mr.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=t}},r.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new xe("BackgroundHelper",this._scene)),this._rootMesh.rotation.y=this._options.backgroundYRotation;var t=this._getSceneSize();this._options.createGround&&(this._setupGround(t),this._setupGroundMaterial(),this._setupGroundDiffuseTexture(),this._options.enableGroundMirror&&this._setupGroundMirrorTexture(t),this._setupMirrorInGroundMaterial()),this._options.createSkybox&&(this._setupSkybox(t),this._setupSkyboxMaterial(),this._setupSkyboxReflectionTexture()),this._rootMesh.position.x=t.rootPosition.x,this._rootMesh.position.z=t.rootPosition.z,this._rootMesh.position.y=t.rootPosition.y},r.prototype._getSceneSize=function(){var t=this,e=this._options.groundSize,n=this._options.skyboxSize,i=this._options.rootPosition;if(!this._scene.meshes||this._scene.meshes.length===1)return{groundSize:e,skyboxSize:n,rootPosition:i};var o=this._scene.getWorldExtends(function(l){return l!==t._ground&&l!==t._rootMesh&&l!==t._skybox}),a=o.max.subtract(o.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof zr&&this._scene.activeCamera.upperRadiusLimit&&(n=e=2*this._scene.activeCamera.upperRadiusLimit);var s=a.length();s>e&&(n=e=2*s),e*=1.1,n*=1.5,(i=o.min.add(a.scale(.5))).y=o.min.y-this._options.groundYBias}return{groundSize:e,skyboxSize:n,rootPosition:i}},r.prototype._setupGround=function(t){var e=this;this._ground&&!this._ground.isDisposed()||(this._ground=Ur("BackgroundPlane",{size:t.groundSize},this._scene),this._ground.rotation.x=Math.PI/2,this._ground.isPickable=!1,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add(function(){e._ground=null})),this._ground.receiveShadows=this._options.enableGroundShadow},r.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new ja("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},r.prototype._setupGroundDiffuseTexture=function(){this._groundMaterial&&(this._groundTexture||(this._options.groundTexture instanceof Ki.t?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new Ie.g(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._groundTexture.gammaSpace=!1,this._groundTexture.hasAlpha=!0,this._groundMaterial.diffuseTexture=this._groundTexture)))},r.prototype._setupGroundMirrorTexture=function(t){var e=Ie.g.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new Gd("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Ie.g.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new Qo.Z(0,-1,0,t.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=e,this._groundMirror.wrapV=e,this._groundMirror.renderList))for(var n=0;n<this._scene.meshes.length;n++){var i=this._scene.meshes[n];i!==this._ground&&i!==this._skybox&&i!==this._rootMesh&&this._groundMirror.renderList.push(i)}var o=this._options.groundColor.toGammaSpace(this._scene.getEngine().useExactSrgbConversions);this._groundMirror.clearColor=new z.ov(o.r,o.g,o.b,1),this._groundMirror.adaptiveBlurKernel=this._options.groundMirrorBlurKernel},r.prototype._setupMirrorInGroundMaterial=function(){this._groundMaterial&&(this._groundMaterial.reflectionTexture=this._groundMirror,this._groundMaterial.reflectionFresnel=!0,this._groundMaterial.reflectionAmount=this._options.groundMirrorAmount,this._groundMaterial.reflectionStandardFresnelWeight=this._options.groundMirrorFresnelWeight,this._groundMaterial.reflectionFalloffDistance=this._options.groundMirrorFallOffDistance)},r.prototype._setupSkybox=function(t){var e=this;this._skybox&&!this._skybox.isDisposed()||(this._skybox=Oi("BackgroundSkybox",{size:t.skyboxSize,sideOrientation:xe.BACKSIDE},this._scene),this._skybox.isPickable=!1,this._skybox.onDisposeObservable.add(function(){e._skybox=null})),this._skybox.parent=this._rootMesh},r.prototype._setupSkyboxMaterial=function(){this._skybox&&(this._skyboxMaterial||(this._skyboxMaterial=new ja("BackgroundSkyboxMaterial",this._scene)),this._skyboxMaterial.useRGBColor=!1,this._skyboxMaterial.primaryColor=this._options.skyboxColor,this._skyboxMaterial.enableNoise=!0,this._skybox.material=this._skyboxMaterial)},r.prototype._setupSkyboxReflectionTexture=function(){this._skyboxMaterial&&(this._skyboxTexture||(this._options.skyboxTexture instanceof Ki.t?this._skyboxMaterial.reflectionTexture=this._options.skyboxTexture:(this._skyboxTexture=new mr(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._skyboxTexture.coordinatesMode=Ie.g.SKYBOX_MODE,this._skyboxTexture.gammaSpace=!1,this._skyboxMaterial.reflectionTexture=this._skyboxTexture)))},r.prototype.dispose=function(){this._groundMaterial&&this._groundMaterial.dispose(!0,!0),this._skyboxMaterial&&this._skyboxMaterial.dispose(!0,!0),this._rootMesh.dispose(!1)},r._GroundTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundGround.png",r._SkyboxTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundSkybox.dds",r._EnvironmentTextureCDNUrl="https://assets.babylonjs.com/environments/environmentSpecular.env",r}(),Fo=function(r){function t(e,n,i,o,a){a===void 0&&(a=null);var s=r.call(this,e,o)||this;s.onError=a,s._halfDome=!1,s._crossEye=!1,s._useDirectMapping=!1,s._textureMode=t.MODE_MONOSCOPIC,s._onBeforeCameraRenderObserver=null,s.onLoadErrorObservable=new K.cP,s.onLoadObservable=new K.cP,o=s.getScene(),e=e||"textureDome",i.resolution=0|Math.abs(i.resolution)||32,i.clickToPlay=!!i.clickToPlay,i.autoPlay=i.autoPlay===void 0||!!i.autoPlay,i.loop=i.loop===void 0||!!i.loop,i.size=Math.abs(i.size)||(o.activeCamera?.48*o.activeCamera.maxZ:1e3),i.useDirectMapping===void 0?s._useDirectMapping=!0:s._useDirectMapping=i.useDirectMapping,i.faceForward===void 0&&(i.faceForward=!0),s._setReady(!1),i.mesh?s._mesh=i.mesh:s._mesh=li(e+"_mesh",{segments:i.resolution,diameter:i.size,updatable:!1,sideOrientation:xe.BACKSIDE},o);var l=s._material=new ja(e+"_material",o);l.useEquirectangularFOV=!0,l.fovMultiplier=1,l.opacityFresnel=!1;var c=s._initTexture(n,o,i);if(s.texture=c,s._mesh.material=l,s._mesh.parent=s,s._halfDomeMask=li("",{slice:.5,diameter:.98*i.size,segments:2*i.resolution,sideOrientation:xe.BACKSIDE},o),s._halfDomeMask.rotate(Ge._0.X,-Math.PI/2),s._halfDomeMask.parent=s._mesh,s._halfDome=!!i.halfDomeMode,s._halfDomeMask.setEnabled(s._halfDome),s._crossEye=!!i.crossEyeMode,s._texture.anisotropicFilteringLevel=1,s._texture.onLoadObservable.addOnce(function(){s._setReady(!0)}),i.faceForward&&o.activeCamera){var u=o.activeCamera,d=_.Pq.Forward(),h=_.Pq.TransformNormal(d,u.getViewMatrix());h.normalize(),s.rotation.y=Math.acos(_.Pq.Dot(d,h))}return s._changeTextureMode(s._textureMode),s}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._useDirectMapping?(this._texture.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._texture.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._material.diffuseTexture=this._texture):(this._texture.coordinatesMode=Ie.g.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,this._texture.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._material.reflectionTexture=this._texture),this._changeTextureMode(this._textureMode))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureMode",{get:function(){return this._textureMode},set:function(e){this._textureMode!==e&&this._changeTextureMode(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"halfDome",{get:function(){return this._halfDome},set:function(e){this._halfDome=e,this._halfDomeMask.setEnabled(e),this._changeTextureMode(this._textureMode)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"crossEye",{get:function(){return this._crossEye},set:function(e){this._crossEye=e,this._changeTextureMode(this._textureMode)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._changeTextureMode=function(e){var n=this;switch(this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._textureMode=e,this._texture.uScale=1,this._texture.vScale=1,this._texture.uOffset=0,this._texture.vOffset=0,this._texture.vAng=0,e){case t.MODE_MONOSCOPIC:this._halfDome&&(this._texture.uScale=2,this._texture.uOffset=-1);break;case t.MODE_SIDEBYSIDE:this._texture.uScale=this._halfDome?.99999:.5;var i=this._halfDome?0:.5,o=this._halfDome?-.5:0;this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add(function(a){var s=a.isRightCamera;n._crossEye&&(s=!s),n._texture.uOffset=s?i:o});break;case t.MODE_TOPBOTTOM:this._texture.vScale=this._halfDome?.99999:.5,this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add(function(a){var s=a.isRightCamera;n._crossEye&&(s=!s),n._texture.vOffset=s?.5:0})}},t.prototype.dispose=function(e,n){n===void 0&&(n=!1),this._texture.dispose(),this._mesh.dispose(),this._material.dispose(),this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this.onLoadErrorObservable.clear(),this.onLoadObservable.clear(),r.prototype.dispose.call(this,e,n)},t.MODE_MONOSCOPIC=0,t.MODE_TOPBOTTOM=1,t.MODE_SIDEBYSIDE=2,t}(jt),_x=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"photoTexture",{get:function(){return this.texture},set:function(e){this.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageMode",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,n,i){var o=this;return new Ie.g(e,n,!i.generateMipMaps,!this._useDirectMapping,void 0,function(){o.onLoadObservable.notifyObservers()},function(a,s){o.onLoadErrorObservable.notifyObservers(a||"Unknown error occured"),o.onError&&o.onError(a,s)})},t.MODE_MONOSCOPIC=Fo.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=Fo.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=Fo.MODE_SIDEBYSIDE,t}(Fo),zd=L(97411),JD=0,qa=function(r){if(!r.environmentBRDFTexture){var t=r.useDelayedTextureLoading;r.useDelayedTextureLoading=!1;var e=r._blockEntityCollection;r._blockEntityCollection=!1;var n=Ie.g.CreateFromBase64String("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==","EnvironmentBRDFTexture"+JD++,r,!0,!1,Ie.g.BILINEAR_SAMPLINGMODE);r._blockEntityCollection=e;var i=r.getEngine().getLoadedTexturesCache(),o=i.indexOf(n.getInternalTexture());o!==-1&&i.splice(o,1),n.isRGBD=!0,n.wrapU=Ie.g.CLAMP_ADDRESSMODE,n.wrapV=Ie.g.CLAMP_ADDRESSMODE,r.environmentBRDFTexture=n,r.useDelayedTextureLoading=t,zd.G.ExpandRGBDTexture(n);var a=r.getEngine().onContextRestoredObservable.add(function(){n.isRGBD=!0;var s=r.onBeforeRenderObservable.add(function(){n.isReady()&&(r.onBeforeRenderObservable.remove(s),zd.G.ExpandRGBDTexture(n))})});r.onDisposeObservable.add(function(){r.getEngine().onContextRestoredObservable.remove(a)})}return r.environmentBRDFTexture},mx={GetEnvironmentBRDFTexture:qa},$D=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.BRDF_V_HEIGHT_CORRELATED=!1,e.MS_BRDF_ENERGY_CONSERVATION=!1,e.SPHERICAL_HARMONICS=!1,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1,e}return(0,A.C6)(t,r),t}(si),gx=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"PBRBRDF",90,new $D,n)||this;return i._useEnergyConservation=t.DEFAULT_USE_ENERGY_CONSERVATION,i.useEnergyConservation=t.DEFAULT_USE_ENERGY_CONSERVATION,i._useSmithVisibilityHeightCorrelated=t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,i.useSmithVisibilityHeightCorrelated=t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,i._useSphericalHarmonics=t.DEFAULT_USE_SPHERICAL_HARMONICS,i.useSphericalHarmonics=t.DEFAULT_USE_SPHERICAL_HARMONICS,i._useSpecularGlossinessInputEnergyConservation=t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,i.useSpecularGlossinessInputEnergyConservation=t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,i._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[P.Y.MATERIAL_MiscDirtyFlag],i._enable(!0),i}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsMiscDirty=function(){this._internalMarkAllSubMeshesAsMiscDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.prepareDefines=function(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation},t.prototype.getClassName=function(){return"PBRBRDFConfiguration"},t.DEFAULT_USE_ENERGY_CONSERVATION=!0,t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,t.DEFAULT_USE_SPHERICAL_HARMONICS=!0,t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0,(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"useEnergyConservation",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"useSmithVisibilityHeightCorrelated",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"useSphericalHarmonics",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"useSpecularGlossinessInputEnergyConservation",void 0),t}(qi),Ug=(L(39813),function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.CLEARCOAT=!1,e.CLEARCOAT_DEFAULTIOR=!1,e.CLEARCOAT_TEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,e.CLEARCOAT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_BUMPDIRECTUV=0,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.CLEARCOAT_REMAP_F0=!1,e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1,e.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TINT_GAMMATEXTURE=!1,e}return(0,A.C6)(t,r),t}(si)),Ka=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"PBRClearCoat",100,new Ug,n)||this;return i._isEnabled=!1,i.isEnabled=!1,i.intensity=1,i.roughness=0,i._indexOfRefraction=t._DefaultIndexOfRefraction,i.indexOfRefraction=t._DefaultIndexOfRefraction,i._texture=null,i.texture=null,i._useRoughnessFromMainTexture=!0,i.useRoughnessFromMainTexture=!0,i._textureRoughness=null,i.textureRoughness=null,i._remapF0OnInterfaceChange=!0,i.remapF0OnInterfaceChange=!0,i._bumpTexture=null,i.bumpTexture=null,i._isTintEnabled=!1,i.isTintEnabled=!1,i.tintColor=z.v9.White(),i.tintColorAtDistance=1,i.tintThickness=1,i._tintTexture=null,i.tintTexture=null,i._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],i}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n,i){if(!this._isEnabled)return!0;var o=this._material._disableBumpMap;return!(e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&$e.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&$e.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()||i.getCaps().standardDerivatives&&this._bumpTexture&&$e.ClearCoatBumpTextureEnabled&&!o&&!this._bumpTexture.isReady()||this._isTintEnabled&&this._tintTexture&&$e.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking()))},t.prototype.prepareDefinesBeforeAttributes=function(e,n){this._isEnabled?(e.CLEARCOAT=!0,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.CLEARCOAT_REMAP_F0=this._remapF0OnInterfaceChange,e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&$e.ClearCoatTextureEnabled?(0,Re.YT)(this._texture,e,"CLEARCOAT_TEXTURE"):e.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&$e.ClearCoatTextureEnabled?(0,Re.YT)(this._textureRoughness,e,"CLEARCOAT_TEXTURE_ROUGHNESS"):e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&$e.ClearCoatBumpTextureEnabled?(0,Re.YT)(this._bumpTexture,e,"CLEARCOAT_BUMP"):e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===t._DefaultIndexOfRefraction,this._isTintEnabled?(e.CLEARCOAT_TINT=!0,this._tintTexture&&$e.ClearCoatTintTextureEnabled?((0,Re.YT)(this._tintTexture,e,"CLEARCOAT_TINT_TEXTURE"),e.CLEARCOAT_TINT_GAMMATEXTURE=this._tintTexture.gammaSpace):e.CLEARCOAT_TINT_TEXTURE=!1):(e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1))):(e.CLEARCOAT=!1,e.CLEARCOAT_TEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.CLEARCOAT_DEFAULTIOR=!1,e.CLEARCOAT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,e.CLEARCOAT_BUMPDIRECTUV=0,e.CLEARCOAT_REMAP_F0=!1,e.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TINT_GAMMATEXTURE=!1)},t.prototype.bindForSubMesh=function(e,n,i,o){var a,s,l,c,u,d,h,p;if(this._isEnabled){var m=o.materialDefines,v=this._material.isFrozen,b=this._material._disableBumpMap,E=this._material._invertNormalMapX,C=this._material._invertNormalMapY;if(!e.useUbo||!v||!e.isSync){(this._texture||this._textureRoughness)&&$e.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",(s=(a=this._texture)===null||a===void 0?void 0:a.coordinatesIndex)!==null&&s!==void 0?s:0,(c=(l=this._texture)===null||l===void 0?void 0:l.level)!==null&&c!==void 0?c:0,(d=(u=this._textureRoughness)===null||u===void 0?void 0:u.coordinatesIndex)!==null&&d!==void 0?d:0,(p=(h=this._textureRoughness)===null||h===void 0?void 0:h.level)!==null&&p!==void 0?p:0),this._texture&&(0,Re.mA)(this._texture,e,"clearCoat"),this._textureRoughness&&!m.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&(0,Re.mA)(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&$e.ClearCoatTextureEnabled&&!b&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),(0,Re.mA)(this._bumpTexture,e,"clearCoatBump"),n._mirroredCameraPosition?e.updateFloat2("vClearCoatTangentSpaceParams",E?1:-1,C?1:-1):e.updateFloat2("vClearCoatTangentSpaceParams",E?-1:1,C?-1:1)),this._tintTexture&&$e.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),(0,Re.mA)(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);var T=1-this._indexOfRefraction,f=1+this._indexOfRefraction,g=Math.pow(-T/f,2),S=1/this._indexOfRefraction;e.updateFloat4("vClearCoatRefractionParams",g,S,T,f),this._isTintEnabled&&(e.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),e.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}n.texturesEnabled&&(this._texture&&$e.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!m.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&$e.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&$e.ClearCoatBumpTextureEnabled&&!b&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&$e.ClearCoatTintTextureEnabled&&e.setTexture("clearCoatTintSampler",this._tintTexture))}},t.prototype.hasTexture=function(e){return this._texture===e||this._textureRoughness===e||this._bumpTexture===e||this._tintTexture===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness),this._bumpTexture&&e.push(this._bumpTexture),this._tintTexture&&e.push(this._tintTexture)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)},t.prototype.dispose=function(e){var n,i,o,a;e&&((n=this._texture)===null||n===void 0||n.dispose(),(i=this._textureRoughness)===null||i===void 0||i.dispose(),(o=this._bumpTexture)===null||o===void 0||o.dispose(),(a=this._tintTexture)===null||a===void 0||a.dispose())},t.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},t.prototype.addFallbacks=function(e,n,i){return e.CLEARCOAT_BUMP&&n.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&n.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&n.addFallback(i++,"CLEARCOAT"),i},t.prototype.getSamplers=function(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vClearCoatParams",size:2,type:"vec2"},{name:"vClearCoatRefractionParams",size:4,type:"vec4"},{name:"vClearCoatInfos",size:4,type:"vec4"},{name:"clearCoatMatrix",size:16,type:"mat4"},{name:"clearCoatRoughnessMatrix",size:16,type:"mat4"},{name:"vClearCoatBumpInfos",size:2,type:"vec2"},{name:"vClearCoatTangentSpaceParams",size:2,type:"vec2"},{name:"clearCoatBumpMatrix",size:16,type:"mat4"},{name:"vClearCoatTintParams",size:4,type:"vec4"},{name:"clearCoatColorAtDistance",size:1,type:"float"},{name:"vClearCoatTintInfos",size:2,type:"vec2"},{name:"clearCoatTintMatrix",size:16,type:"mat4"}]}},t._DefaultIndexOfRefraction=1.5,(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"intensity",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"roughness",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"remapF0OnInterfaceChange",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTintEnabled",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"tintColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"tintColorAtDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"tintThickness",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"tintTexture",void 0),t}(qi),Gg=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.IRIDESCENCE=!1,e.IRIDESCENCE_TEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTURE=!1,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0,e}return(0,A.C6)(t,r),t}(si),Za=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"PBRIridescence",110,new Gg,n)||this;return i._isEnabled=!1,i.isEnabled=!1,i.intensity=1,i.minimumThickness=t._DefaultMinimumThickness,i.maximumThickness=t._DefaultMaximumThickness,i.indexOfRefraction=t._DefaultIndexOfRefraction,i._texture=null,i.texture=null,i._thicknessTexture=null,i.thicknessTexture=null,i._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],i}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n){return this._isEnabled?!(e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&$e.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._thicknessTexture&&$e.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())):!0},t.prototype.prepareDefinesBeforeAttributes=function(e,n){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&$e.IridescenceTextureEnabled?(0,Re.YT)(this._texture,e,"IRIDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&$e.IridescenceTextureEnabled?(0,Re.YT)(this._thicknessTexture,e,"IRIDESCENCE_THICKNESS_TEXTURE"):e.IRIDESCENCE_THICKNESS_TEXTURE=!1)):(e.IRIDESCENCE=!1,e.IRIDESCENCE_TEXTURE=!1,e.IRIDESCENCE_THICKNESS_TEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0)},t.prototype.bindForSubMesh=function(e,n){var i,o,a,s,l,c,u,d;if(this._isEnabled){var h=this._material.isFrozen;e.useUbo&&h&&e.isSync||((this._texture||this._thicknessTexture)&&$e.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",(o=(i=this._texture)===null||i===void 0?void 0:i.coordinatesIndex)!==null&&o!==void 0?o:0,(s=(a=this._texture)===null||a===void 0?void 0:a.level)!==null&&s!==void 0?s:0,(c=(l=this._thicknessTexture)===null||l===void 0?void 0:l.coordinatesIndex)!==null&&c!==void 0?c:0,(d=(u=this._thicknessTexture)===null||u===void 0?void 0:u.level)!==null&&d!==void 0?d:0),this._texture&&(0,Re.mA)(this._texture,e,"iridescence"),this._thicknessTexture&&(0,Re.mA)(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),n.texturesEnabled&&(this._texture&&$e.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&$e.IridescenceTextureEnabled&&e.setTexture("iridescenceThicknessSampler",this._thicknessTexture))}},t.prototype.hasTexture=function(e){return this._texture===e||this._thicknessTexture===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._thicknessTexture&&e.push(this._thicknessTexture)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture)},t.prototype.dispose=function(e){var n,i;e&&((n=this._texture)===null||n===void 0||n.dispose(),(i=this._thicknessTexture)===null||i===void 0||i.dispose())},t.prototype.getClassName=function(){return"PBRIridescenceConfiguration"},t.prototype.addFallbacks=function(e,n,i){return e.IRIDESCENCE&&n.addFallback(i++,"IRIDESCENCE"),i},t.prototype.getSamplers=function(e){e.push("iridescenceSampler","iridescenceThicknessSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vIridescenceParams",size:4,type:"vec4"},{name:"vIridescenceInfos",size:4,type:"vec4"},{name:"iridescenceMatrix",size:16,type:"mat4"},{name:"iridescenceThicknessMatrix",size:16,type:"mat4"}]}},t._DefaultMinimumThickness=100,t._DefaultMaximumThickness=400,t._DefaultIndexOfRefraction=1.3,(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"intensity",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"minimumThickness",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"maximumThickness",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"indexOfRefraction",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"thicknessTexture",void 0),t}(qi),kg=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.ANISOTROPIC_LEGACY=!1,e.MAINUV1=!1,e}return(0,A.C6)(t,r),t}(si),Wd=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"PBRAnisotropic",110,new kg,n)||this;return i._isEnabled=!1,i.isEnabled=!1,i.intensity=1,i.direction=new _.I9(1,0),i._texture=null,i.texture=null,i._legacy=!1,i.legacy=!1,i._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],i._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[P.Y.MATERIAL_MiscDirtyFlag],i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"angle",{get:function(){return Math.atan2(this.direction.y,this.direction.x)},set:function(e){this.direction.x=Math.cos(e),this.direction.y=Math.sin(e)},enumerable:!1,configurable:!0}),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype._markAllSubMeshesAsMiscDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsMiscDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n){return!this._isEnabled||!(e._areTexturesDirty&&n.texturesEnabled&&this._texture&&$e.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},t.prototype.prepareDefinesBeforeAttributes=function(e,n,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(Y.R.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&$e.AnisotropicTextureEnabled?(0,Re.YT)(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1),e._areMiscDirty&&(e.ANISOTROPIC_LEGACY=this._legacy)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.ANISOTROPIC_LEGACY=!1)},t.prototype.bindForSubMesh=function(e,n){if(this._isEnabled){var i=this._material.isFrozen;e.useUbo&&i&&e.isSync||(this._texture&&$e.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),(0,Re.mA)(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),n.texturesEnabled&&this._texture&&$e.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)}},t.prototype.hasTexture=function(e){return this._texture===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},t.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},t.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},t.prototype.addFallbacks=function(e,n,i){return e.ANISOTROPIC&&n.addFallback(i++,"ANISOTROPIC"),i},t.prototype.getSamplers=function(e){e.push("anisotropySampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vAnisotropy",size:3,type:"vec3"},{name:"vAnisotropyInfos",size:2,type:"vec2"},{name:"anisotropyMatrix",size:16,type:"mat4"}]}},t.prototype.parse=function(e,n,i){r.prototype.parse.call(this,e,n,i),e.legacy===void 0&&(this.legacy=!0)},(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"intensity",void 0),(0,A.Cg)([(0,V.WM)()],t.prototype,"direction",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"legacy",void 0),t}(qi),zg=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_GAMMATEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_TEXTUREDIRECTUV=0,e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e}return(0,A.C6)(t,r),t}(si),Hd=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"Sheen",120,new zg,n)||this;return i._isEnabled=!1,i.isEnabled=!1,i._linkSheenWithAlbedo=!1,i.linkSheenWithAlbedo=!1,i.intensity=1,i.color=z.v9.White(),i._texture=null,i.texture=null,i._useRoughnessFromMainTexture=!0,i.useRoughnessFromMainTexture=!0,i._roughness=null,i.roughness=null,i._textureRoughness=null,i.textureRoughness=null,i._albedoScaling=!1,i.albedoScaling=!1,i._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],i}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n){return this._isEnabled?!(e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&$e.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&$e.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())):!0},t.prototype.prepareDefinesBeforeAttributes=function(e,n){this._isEnabled?(e.SHEEN=!0,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=this._roughness!==null,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&$e.SheenTextureEnabled?((0,Re.YT)(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&$e.SheenTextureEnabled?(0,Re.YT)(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_GAMMATEXTURE=!1,e.SHEEN_TEXTUREDIRECTUV=0,e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0)},t.prototype.bindForSubMesh=function(e,n,i,o){var a,s,l,c,u,d,h,p;if(this._isEnabled){var m=o.materialDefines,v=this._material.isFrozen;e.useUbo&&v&&e.isSync||((this._texture||this._textureRoughness)&&$e.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",(s=(a=this._texture)===null||a===void 0?void 0:a.coordinatesIndex)!==null&&s!==void 0?s:0,(c=(l=this._texture)===null||l===void 0?void 0:l.level)!==null&&c!==void 0?c:0,(d=(u=this._textureRoughness)===null||u===void 0?void 0:u.coordinatesIndex)!==null&&d!==void 0?d:0,(p=(h=this._textureRoughness)===null||h===void 0?void 0:h.level)!==null&&p!==void 0?p:0),this._texture&&(0,Re.mA)(this._texture,e,"sheen"),this._textureRoughness&&!m.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&(0,Re.mA)(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),this._roughness!==null&&e.updateFloat("vSheenRoughness",this._roughness)),n.texturesEnabled&&(this._texture&&$e.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!m.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&$e.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))}},t.prototype.hasTexture=function(e){return this._texture===e||this._textureRoughness===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)},t.prototype.dispose=function(e){var n,i;e&&((n=this._texture)===null||n===void 0||n.dispose(),(i=this._textureRoughness)===null||i===void 0||i.dispose())},t.prototype.getClassName=function(){return"PBRSheenConfiguration"},t.prototype.addFallbacks=function(e,n,i){return e.SHEEN&&n.addFallback(i++,"SHEEN"),i},t.prototype.getSamplers=function(e){e.push("sheenSampler","sheenRoughnessSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vSheenColor",size:4,type:"vec4"},{name:"vSheenRoughness",size:1,type:"float"},{name:"vSheenInfos",size:4,type:"vec4"},{name:"sheenMatrix",size:16,type:"mat4"},{name:"sheenRoughnessMatrix",size:16,type:"mat4"}]}},(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkSheenWithAlbedo",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"intensity",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"color",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoScaling",void 0),t}(qi),Wg=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.SUBSURFACE=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_SCATTERING=!1,e.SS_DISPERSION=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,e.SS_HAS_THICKNESS=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,e.SS_REFRACTIONMAP_3D=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_USE_GLTF_TEXTURES=!1,e}return(0,A.C6)(t,r),t}(si),Yd=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"PBRSubSurface",130,new Wg,n)||this;return i._isRefractionEnabled=!1,i.isRefractionEnabled=!1,i._isTranslucencyEnabled=!1,i.isTranslucencyEnabled=!1,i._isDispersionEnabled=!1,i.isDispersionEnabled=!1,i._isScatteringEnabled=!1,i.isScatteringEnabled=!1,i._scatteringDiffusionProfileIndex=0,i.refractionIntensity=1,i.translucencyIntensity=1,i.useAlbedoToTintRefraction=!1,i.useAlbedoToTintTranslucency=!1,i._thicknessTexture=null,i.thicknessTexture=null,i._refractionTexture=null,i.refractionTexture=null,i._indexOfRefraction=1.5,i.indexOfRefraction=1.5,i._volumeIndexOfRefraction=-1,i._invertRefractionY=!1,i.invertRefractionY=!1,i._linkRefractionWithTransparency=!1,i.linkRefractionWithTransparency=!1,i.minimumThickness=0,i.maximumThickness=1,i.useThicknessAsDepth=!1,i.tintColor=z.v9.White(),i.tintColorAtDistance=1,i.dispersion=0,i.diffusionDistance=z.v9.White(),i._useMaskFromThicknessTexture=!1,i.useMaskFromThicknessTexture=!1,i._refractionIntensityTexture=null,i.refractionIntensityTexture=null,i._translucencyIntensityTexture=null,i.translucencyIntensityTexture=null,i.translucencyColor=null,i._translucencyColorTexture=null,i.translucencyColorTexture=null,i._useGltfStyleTextures=!0,i.useGltfStyleTextures=!0,i._scene=e.getScene(),i.registerForExtraEvents=!0,i._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],i._internalMarkScenePrePassDirty=e._dirtyCallbacks[P.Y.MATERIAL_PrePassDirtyFlag],i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"scatteringDiffusionProfile",{get:function(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null},set:function(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"volumeIndexOfRefraction",{get:function(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction},set:function(e){this._volumeIndexOfRefraction=e>=1?e:-1},enumerable:!1,configurable:!0}),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype._markScenePrePassDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return!0;if(e._areTexturesDirty&&n.texturesEnabled){if(this._thicknessTexture&&$e.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking()||this._translucencyColorTexture&&$e.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking()||this._translucencyIntensityTexture&&$e.TranslucencyIntensityTextureEnabled&&!this._translucencyIntensityTexture.isReadyOrNotBlocking())return!1;var i=this._getRefractionTexture(n);if(i&&$e.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefinesBeforeAttributes=function(e,n){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return e.SUBSURFACE=!1,e.SS_DISPERSION=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,e.SS_HAS_THICKNESS=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,e.SS_REFRACTIONMAP_3D=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,void(e.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0);if(e._areTexturesDirty){if(e.SUBSURFACE=!0,e.SS_DISPERSION=this._isDispersionEnabled,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_HAS_THICKNESS=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e._areTexturesDirty&&n.texturesEnabled&&(this._thicknessTexture&&$e.ThicknessTextureEnabled&&(0,Re.YT)(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&$e.RefractionIntensityTextureEnabled&&(0,Re.YT)(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&$e.TranslucencyIntensityTextureEnabled&&(0,Re.YT)(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&$e.TranslucencyColorTextureEnabled&&(0,Re.YT)(this._translucencyColorTexture,e,"SS_TRANSLUCENCYCOLOR_TEXTURE")),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!=0,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._refractionIntensityTexture,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._translucencyIntensityTexture,this._isRefractionEnabled&&n.texturesEnabled){var i=this._getRefractionTexture(n);i&&$e.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=this._scene.useRightHandedSystem&&i.isCube?!i.invertZ:i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=i.isCube&&i.boundingBoxSize,e.SS_USE_THICKNESS_AS_DEPTH=this.useThicknessAsDepth)}this._isTranslucencyEnabled&&(e.SS_ALBEDOFORTRANSLUCENCYTINT=this.useAlbedoToTintTranslucency)}},t.prototype.hardBindForSubMesh=function(e,n,i,o){if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)if(this.maximumThickness===0&&this.minimumThickness===0)e.updateFloat2("vThicknessParam",0,0);else{o.getRenderingMesh().getWorldMatrix().decompose(_.AA.Vector3[0]);var a=Math.max(Math.abs(_.AA.Vector3[0].x),Math.abs(_.AA.Vector3[0].y),Math.abs(_.AA.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*a,(this.maximumThickness-this.minimumThickness)*a)}},t.prototype.bindForSubMesh=function(e,n,i,o){var a;if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled){var s=o.materialDefines,l=this._material.isFrozen,c=this._material.realTimeFiltering,u=s.LODBASEDMICROSFURACE,d=this._getRefractionTexture(n);if(!e.useUbo||!l||!e.isSync){if(this._thicknessTexture&&$e.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),(0,Re.mA)(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&$e.RefractionIntensityTextureEnabled&&s.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),(0,Re.mA)(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&$e.TranslucencyColorTextureEnabled&&s.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),(0,Re.mA)(this._translucencyColorTexture,e,"translucencyColor")),this._translucencyIntensityTexture&&$e.TranslucencyIntensityTextureEnabled&&s.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),(0,Re.mA)(this._translucencyIntensityTexture,e,"translucencyIntensity")),d&&$e.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",d.getRefractionTextureMatrix());var h=1;d.isCube||d.depth&&(h=d.depth);var p=d.getSize().width,m=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",d.level,1/m,h,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",p,d.lodGenerationScale,d.lodGenerationOffset,1/this.indexOfRefraction),c&&e.updateFloat2("vRefractionFilteringInfo",p,Math.log2(p)),d.boundingBoxSize){var v=d;e.updateVector3("vRefractionPosition",v.boundingBoxPosition),e.updateVector3("vRefractionSize",v.boundingBoxSize)}}this._isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintColorAtDistance)),e.updateColor4("vTranslucencyColor",(a=this.translucencyColor)!==null&&a!==void 0?a:this.tintColor,0),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0),e.updateFloat("dispersion",this.dispersion)}n.texturesEnabled&&(this._thicknessTexture&&$e.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&$e.RefractionIntensityTextureEnabled&&s.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&$e.TranslucencyIntensityTextureEnabled&&s.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&$e.TranslucencyColorTextureEnabled&&s.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),d&&$e.RefractionTextureEnabled&&(u?e.setTexture("refractionSampler",d):(e.setTexture("refractionSampler",d._lodTextureMid||d),e.setTexture("refractionSamplerLow",d._lodTextureLow||d),e.setTexture("refractionSamplerHigh",d._lodTextureHigh||d))))}},t.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(t.prototype,"disableAlphaBlending",{get:function(){return this._isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!1,configurable:!0}),t.prototype.fillRenderTargetTextures=function(e){$e.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},t.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e||this._refractionIntensityTexture===e||this._translucencyIntensityTexture===e||this._translucencyColorTexture===e},t.prototype.hasRenderTargetTextures=function(){return!!($e.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},t.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture),this._translucencyColorTexture&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&e.push(this._translucencyIntensityTexture)},t.prototype.getAnimatables=function(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this._translucencyColorTexture&&this._translucencyColorTexture.animations&&this._translucencyColorTexture.animations.length>0&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.animations&&this._translucencyIntensityTexture.animations.length>0&&e.push(this._translucencyIntensityTexture)},t.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._translucencyColorTexture&&this._translucencyColorTexture.dispose(),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.dispose())},t.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},t.prototype.addFallbacks=function(e,n,i){return e.SS_SCATTERING&&n.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&n.addFallback(i++,"SS_TRANSLUCENCY"),i},t.prototype.getSamplers=function(e){e.push("thicknessSampler","refractionIntensitySampler","translucencyIntensitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","translucencyColorSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vRefractionMicrosurfaceInfos",size:4,type:"vec4"},{name:"vRefractionFilteringInfo",size:2,type:"vec2"},{name:"vTranslucencyIntensityInfos",size:2,type:"vec2"},{name:"vRefractionInfos",size:4,type:"vec4"},{name:"refractionMatrix",size:16,type:"mat4"},{name:"vThicknessInfos",size:2,type:"vec2"},{name:"vRefractionIntensityInfos",size:2,type:"vec2"},{name:"thicknessMatrix",size:16,type:"mat4"},{name:"refractionIntensityMatrix",size:16,type:"mat4"},{name:"translucencyIntensityMatrix",size:16,type:"mat4"},{name:"vThicknessParam",size:2,type:"vec2"},{name:"vDiffusionDistance",size:3,type:"vec3"},{name:"vTintColor",size:4,type:"vec4"},{name:"vSubSurfaceIntensity",size:3,type:"vec3"},{name:"vRefractionPosition",size:3,type:"vec3"},{name:"vRefractionSize",size:3,type:"vec3"},{name:"scatteringDiffusionProfile",size:1,type:"float"},{name:"dispersion",size:1,type:"float"},{name:"vTranslucencyColor",size:4,type:"vec4"},{name:"vTranslucencyColorInfos",size:2,type:"vec2"},{name:"translucencyColorMatrix",size:16,type:"mat4"}]}},(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isRefractionEnabled",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTranslucencyEnabled",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isDispersionEnabled",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markScenePrePassDirty")],t.prototype,"isScatteringEnabled",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_scatteringDiffusionProfileIndex",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"refractionIntensity",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"translucencyIntensity",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"useAlbedoToTintRefraction",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"useAlbedoToTintTranslucency",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"thicknessTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_volumeIndexOfRefraction",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"volumeIndexOfRefraction",null),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"minimumThickness",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"maximumThickness",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"useThicknessAsDepth",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"tintColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"tintColorAtDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"dispersion",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"diffusionDistance",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMaskFromThicknessTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionIntensityTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"translucencyIntensityTexture",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"translucencyColor",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"translucencyColorTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGltfStyleTextures",void 0),t}(qi),Qa={effect:null,subMesh:null},Xd=function(r){function t(e){var n=r.call(this,e)||this;return n.PBR=!0,n.NUM_SAMPLES="0",n.REALTIME_FILTERING=!1,n.MAINUV1=!1,n.MAINUV2=!1,n.MAINUV3=!1,n.MAINUV4=!1,n.MAINUV5=!1,n.MAINUV6=!1,n.UV1=!1,n.UV2=!1,n.UV3=!1,n.UV4=!1,n.UV5=!1,n.UV6=!1,n.ALBEDO=!1,n.GAMMAALBEDO=!1,n.ALBEDODIRECTUV=0,n.VERTEXCOLOR=!1,n.BAKED_VERTEX_ANIMATION_TEXTURE=!1,n.AMBIENT=!1,n.AMBIENTDIRECTUV=0,n.AMBIENTINGRAYSCALE=!1,n.OPACITY=!1,n.VERTEXALPHA=!1,n.OPACITYDIRECTUV=0,n.OPACITYRGB=!1,n.ALPHATEST=!1,n.DEPTHPREPASS=!1,n.ALPHABLEND=!1,n.ALPHAFROMALBEDO=!1,n.ALPHATESTVALUE="0.5",n.SPECULAROVERALPHA=!1,n.RADIANCEOVERALPHA=!1,n.ALPHAFRESNEL=!1,n.LINEARALPHAFRESNEL=!1,n.PREMULTIPLYALPHA=!1,n.EMISSIVE=!1,n.EMISSIVEDIRECTUV=0,n.GAMMAEMISSIVE=!1,n.REFLECTIVITY=!1,n.REFLECTIVITY_GAMMA=!1,n.REFLECTIVITYDIRECTUV=0,n.SPECULARTERM=!1,n.MICROSURFACEFROMREFLECTIVITYMAP=!1,n.MICROSURFACEAUTOMATIC=!1,n.LODBASEDMICROSFURACE=!1,n.MICROSURFACEMAP=!1,n.MICROSURFACEMAPDIRECTUV=0,n.METALLICWORKFLOW=!1,n.ROUGHNESSSTOREINMETALMAPALPHA=!1,n.ROUGHNESSSTOREINMETALMAPGREEN=!1,n.METALLNESSSTOREINMETALMAPBLUE=!1,n.AOSTOREINMETALMAPRED=!1,n.METALLIC_REFLECTANCE=!1,n.METALLIC_REFLECTANCE_GAMMA=!1,n.METALLIC_REFLECTANCEDIRECTUV=0,n.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=!1,n.REFLECTANCE=!1,n.REFLECTANCE_GAMMA=!1,n.REFLECTANCEDIRECTUV=0,n.ENVIRONMENTBRDF=!1,n.ENVIRONMENTBRDF_RGBD=!1,n.NORMAL=!1,n.TANGENT=!1,n.BUMP=!1,n.BUMPDIRECTUV=0,n.OBJECTSPACE_NORMALMAP=!1,n.PARALLAX=!1,n.PARALLAX_RHS=!1,n.PARALLAXOCCLUSION=!1,n.NORMALXYSCALE=!0,n.LIGHTMAP=!1,n.LIGHTMAPDIRECTUV=0,n.USELIGHTMAPASSHADOWMAP=!1,n.GAMMALIGHTMAP=!1,n.RGBDLIGHTMAP=!1,n.REFLECTION=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.INVERTCUBICMAP=!1,n.USESPHERICALFROMREFLECTIONMAP=!1,n.USEIRRADIANCEMAP=!1,n.USESPHERICALINVERTEX=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.LODINREFLECTIONALPHA=!1,n.GAMMAREFLECTION=!1,n.RGBDREFLECTION=!1,n.LINEARSPECULARREFLECTION=!1,n.RADIANCEOCCLUSION=!1,n.HORIZONOCCLUSION=!1,n.INSTANCES=!1,n.THIN_INSTANCES=!1,n.INSTANCESCOLOR=!1,n.PREPASS=!1,n.PREPASS_IRRADIANCE=!1,n.PREPASS_IRRADIANCE_INDEX=-1,n.PREPASS_ALBEDO_SQRT=!1,n.PREPASS_ALBEDO_SQRT_INDEX=-1,n.PREPASS_DEPTH=!1,n.PREPASS_DEPTH_INDEX=-1,n.PREPASS_SCREENSPACE_DEPTH=!1,n.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,n.PREPASS_NORMAL=!1,n.PREPASS_NORMAL_INDEX=-1,n.PREPASS_NORMAL_WORLDSPACE=!1,n.PREPASS_WORLD_NORMAL=!1,n.PREPASS_WORLD_NORMAL_INDEX=-1,n.PREPASS_POSITION=!1,n.PREPASS_POSITION_INDEX=-1,n.PREPASS_LOCAL_POSITION=!1,n.PREPASS_LOCAL_POSITION_INDEX=-1,n.PREPASS_VELOCITY=!1,n.PREPASS_VELOCITY_INDEX=-1,n.PREPASS_VELOCITY_LINEAR=!1,n.PREPASS_VELOCITY_LINEAR_INDEX=-1,n.PREPASS_REFLECTIVITY=!1,n.PREPASS_REFLECTIVITY_INDEX=-1,n.SCENE_MRT_COUNT=0,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.BONETEXTURE=!1,n.BONES_VELOCITY_ENABLED=!1,n.NONUNIFORMSCALING=!1,n.MORPHTARGETS=!1,n.MORPHTARGETS_NORMAL=!1,n.MORPHTARGETS_TANGENT=!1,n.MORPHTARGETS_UV=!1,n.NUM_MORPH_INFLUENCERS=0,n.MORPHTARGETS_TEXTURE=!1,n.IMAGEPROCESSING=!1,n.VIGNETTE=!1,n.VIGNETTEBLENDMODEMULTIPLY=!1,n.VIGNETTEBLENDMODEOPAQUE=!1,n.TONEMAPPING=0,n.CONTRAST=!1,n.COLORCURVES=!1,n.COLORGRADING=!1,n.COLORGRADING3D=!1,n.SAMPLER3DGREENDEPTH=!1,n.SAMPLER3DBGRMAP=!1,n.DITHER=!1,n.IMAGEPROCESSINGPOSTPROCESS=!1,n.SKIPFINALCOLORCLAMP=!1,n.EXPOSURE=!1,n.MULTIVIEW=!1,n.ORDER_INDEPENDENT_TRANSPARENCY=!1,n.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,n.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!1,n.TWOSIDEDLIGHTING=!1,n.SHADOWFLOAT=!1,n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.POINTSIZE=!1,n.FOG=!1,n.LOGARITHMICDEPTH=!1,n.CAMERA_ORTHOGRAPHIC=!1,n.CAMERA_PERSPECTIVE=!1,n.FORCENORMALFORWARD=!1,n.SPECULARAA=!1,n.UNLIT=!1,n.DECAL_AFTER_DETAIL=!1,n.DEBUGMODE=0,n.rebuild(),n}return(0,A.C6)(t,r),t.prototype.reset=function(){r.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0},t}(si),Tn=function(r){function t(e,n,i){i===void 0&&(i=!1);var o=r.call(this,e,n)||this;o._directIntensity=1,o._emissiveIntensity=1,o._environmentIntensity=1,o._specularIntensity=1,o._lightingInfos=new _.IU(o._directIntensity,o._emissiveIntensity,o._environmentIntensity,o._specularIntensity),o._disableBumpMap=!1,o._albedoTexture=null,o._ambientTexture=null,o._ambientTextureStrength=1,o._ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,o._opacityTexture=null,o._reflectionTexture=null,o._emissiveTexture=null,o._reflectivityTexture=null,o._metallicTexture=null,o._metallic=null,o._roughness=null,o._metallicF0Factor=1,o._metallicReflectanceColor=z.v9.White(),o._useOnlyMetallicFromMetallicReflectanceTexture=!1,o._metallicReflectanceTexture=null,o._reflectanceTexture=null,o._microSurfaceTexture=null,o._bumpTexture=null,o._lightmapTexture=null,o._ambientColor=new z.v9(0,0,0),o._albedoColor=new z.v9(1,1,1),o._reflectivityColor=new z.v9(1,1,1),o._reflectionColor=new z.v9(1,1,1),o._emissiveColor=new z.v9(0,0,0),o._microSurface=.9,o._useLightmapAsShadowmap=!1,o._useHorizonOcclusion=!0,o._useRadianceOcclusion=!0,o._useAlphaFromAlbedoTexture=!1,o._useSpecularOverAlpha=!0,o._useMicroSurfaceFromReflectivityMapAlpha=!1,o._useRoughnessFromMetallicTextureAlpha=!0,o._useRoughnessFromMetallicTextureGreen=!1,o._useMetallnessFromMetallicTextureBlue=!1,o._useAmbientOcclusionFromMetallicTextureRed=!1,o._useAmbientInGrayScale=!1,o._useAutoMicroSurfaceFromReflectivityMap=!1,o._lightFalloff=t.LIGHTFALLOFF_PHYSICAL,o._useRadianceOverAlpha=!0,o._useObjectSpaceNormalMap=!1,o._useParallax=!1,o._useParallaxOcclusion=!1,o._parallaxScaleBias=.05,o._disableLighting=!1,o._maxSimultaneousLights=4,o._invertNormalMapX=!1,o._invertNormalMapY=!1,o._twoSidedLighting=!1,o._alphaCutOff=.4,o._forceAlphaTest=!1,o._useAlphaFresnel=!1,o._useLinearAlphaFresnel=!1,o._environmentBRDFTexture=null,o._forceIrradianceInFragment=!1,o._realTimeFiltering=!1,o._realTimeFilteringQuality=P.Y.TEXTURE_FILTERING_QUALITY_LOW,o._forceNormalForward=!1,o._enableSpecularAntiAliasing=!1,o._imageProcessingObserver=null,o._renderTargets=new er.L(16),o._globalAmbientColor=new z.v9(0,0,0),o._unlit=!1,o._applyDecalMapAfterDetailMap=!1,o._debugMode=0,o._shadersLoaded=!1,o._breakShaderLoadedCheck=!1,o.debugMode=0,o.debugLimit=-1,o.debugFactor=1,o._cacheHasRenderTargetTextures=!1;var a=o.getScene().getEngine();return!a.isWebGPU||i||t.ForceGLSL||(o._uniformBuffer&&o._uniformBuffer.dispose(),o._uniformBuffer=new Ui.D(a,void 0,void 0,o.name,!0),o._shaderLanguage=1),o.brdf=new gx(o),o.clearCoat=new Ka(o),o.iridescence=new Za(o),o.anisotropy=new Wd(o),o.sheen=new Hd(o),o.subSurface=new Yd(o),o.detailMap=new Bs(o),o._attachImageProcessingConfiguration(null),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),$e.ReflectionTextureEnabled&&o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),o._eventInfo.renderTargets=o._renderTargets,o._callbackPluginEventFillRenderTargetTextures(o._eventInfo),o._renderTargets},o._environmentBRDFTexture=qa(o.getScene()),o.prePassConfiguration=new Da,o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"realTimeFiltering",{get:function(){return this._realTimeFiltering},set:function(e){this._realTimeFiltering=e,this.markAsDirty(P.Y.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"realTimeFilteringQuality",{get:function(){return this._realTimeFilteringQuality},set:function(e){this._realTimeFilteringQuality=e,this.markAsDirty(P.Y.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canRenderToMRT",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var n=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!!($e.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||this._cacheHasRenderTargetTextures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPrePassCapable",{get:function(){return!this.disableDepthWrite},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(t.prototype,"_disableAlphaBlending",{get:function(){var e;return this._transparencyMode===t.PBRMATERIAL_OPAQUE||this._transparencyMode===t.PBRMATERIAL_ALPHATEST||((e=this.subSurface)===null||e===void 0?void 0:e.disableAlphaBlending)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromAlbedoTexture())},t.prototype.needAlphaTesting=function(){var e;return!!this._forceAlphaTest||!(!((e=this.subSurface)===null||e===void 0)&&e.disableAlphaBlending)&&this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===t.PBRMATERIAL_ALPHATEST)},t.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==t.PBRMATERIAL_OPAQUE},t.prototype._hasAlphaChannel=function(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha||this._opacityTexture!=null},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,n,i){var o;this._uniformBufferLayoutBuilt||this.buildUniformLayout();var a=n._drawWrapper;if(a.effect&&this.isFrozen&&a._wasPreviouslyReady&&a._wasPreviouslyUsingInstances===i)return!0;n.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),n.materialDefines=new Xd(this._eventInfo.defineNames));var s=n.materialDefines;if(this._isReadyForSubMesh(n))return!0;var l=this.getScene(),c=l.getEngine();if(s._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,l.texturesEnabled)){if(this._albedoTexture&&$e.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._ambientTexture&&$e.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&$e.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var u=this._getReflectionTexture();if(u&&$e.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;if(u.irradianceTexture){if(!u.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!u.sphericalPolynomial&&(!((o=u.getInternalTexture())===null||o===void 0)&&o._sphericalPolynomialPromise))return!1}if(this._lightmapTexture&&$e.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&$e.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if($e.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking()||this._reflectanceTexture&&!this._reflectanceTexture.isReadyOrNotBlocking()||this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(c.getCaps().standardDerivatives&&this._bumpTexture&&$e.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&$e.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._eventInfo.subMesh=n,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||s._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;c.getCaps().standardDerivatives||e.isVerticesDataPresent(Y.R.NormalKind)||(e.createNormals(!0),O.V.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var d=n.effect,h=s._areLightsDisposed,p=this._prepareEffect(e,s,this.onCompiled,this.onError,i,null,n.getRenderingMesh().hasThinInstances),m=!1;if(p)if(this._onEffectCreatedObservable&&(Qa.effect=p,Qa.subMesh=n,this._onEffectCreatedObservable.notifyObservers(Qa)),this.allowShaderHotSwapping&&d&&!p.isReady()){if(p=d,s.markAsUnprocessed(),m=this.isFrozen,h)return s._areLightsDisposed=!0,!1}else l.resetCachedMaterial(),n.setEffect(p,s,this._materialContext);return!(!n.effect||!n.effect.isReady()||(s._renderId=l.getRenderId(),a._wasPreviouslyReady=!m,a._wasPreviouslyUsingInstances=!!i,this._checkScenePerformancePriority(),0))},t.prototype.isMetallicWorkflow=function(){return!(this._metallic==null&&this._roughness==null&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,n,i,o,a,s,l){var c=this;if(i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),this._prepareDefines(e,n,a,s,l),!n.isDirty)return null;n.markAsProcessed();var u=this.getScene().getEngine(),d=new Tr,h=0;n.USESPHERICALINVERTEX&&d.addFallback(h++,"USESPHERICALINVERTEX"),n.FOG&&d.addFallback(h,"FOG"),n.SPECULARAA&&d.addFallback(h,"SPECULARAA"),n.POINTSIZE&&d.addFallback(h,"POINTSIZE"),n.LOGARITHMICDEPTH&&d.addFallback(h,"LOGARITHMICDEPTH"),n.PARALLAX&&d.addFallback(h,"PARALLAX"),n.PARALLAX_RHS&&d.addFallback(h,"PARALLAX_RHS"),n.PARALLAXOCCLUSION&&d.addFallback(h++,"PARALLAXOCCLUSION"),n.ENVIRONMENTBRDF&&d.addFallback(h++,"ENVIRONMENTBRDF"),n.TANGENT&&d.addFallback(h++,"TANGENT"),n.BUMP&&d.addFallback(h++,"BUMP"),h=(0,Re.c4)(n,d,this._maxSimultaneousLights,h++),n.SPECULARTERM&&d.addFallback(h++,"SPECULARTERM"),n.USESPHERICALFROMREFLECTIONMAP&&d.addFallback(h++,"USESPHERICALFROMREFLECTIONMAP"),n.USEIRRADIANCEMAP&&d.addFallback(h++,"USEIRRADIANCEMAP"),n.LIGHTMAP&&d.addFallback(h++,"LIGHTMAP"),n.NORMAL&&d.addFallback(h++,"NORMAL"),n.AMBIENT&&d.addFallback(h++,"AMBIENT"),n.EMISSIVE&&d.addFallback(h++,"EMISSIVE"),n.VERTEXCOLOR&&d.addFallback(h++,"VERTEXCOLOR"),n.MORPHTARGETS&&d.addFallback(h++,"MORPHTARGETS"),n.MULTIVIEW&&d.addFallback(0,"MULTIVIEW");var p=[Y.R.PositionKind];n.NORMAL&&p.push(Y.R.NormalKind),n.TANGENT&&p.push(Y.R.TangentKind);for(var m=1;m<=P.Y.MAX_SUPPORTED_UV_SETS;++m)n["UV"+m]&&p.push("uv".concat(m===1?"":m));n.VERTEXCOLOR&&p.push(Y.R.ColorKind),(0,Re.ni)(p,e,n,d),(0,Re.ER)(p,n),(0,Re.IF)(p,e,n),(0,Re.J2)(p,e,n);var v="pbr",b=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vMetallicReflectanceFactors","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vReflectionFilteringInfo","vMetallicReflectanceInfos","vReflectanceInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","reflectanceMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX_ZZ","vSphericalYY_ZZ","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vSphericalL00","vSphericalL1_1","vSphericalL10","vSphericalL11","vSphericalL2_2","vSphericalL2_1","vSphericalL20","vSphericalL21","vSphericalL22","vReflectionMicrosurfaceInfos","vTangentSpaceParams","boneTextureWidth","vDebugMode","morphTargetTextureInfo","morphTargetTextureIndices"],E=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler","reflectanceSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],C=["Material","Scene","Mesh"],T={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:n.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=d,this._eventInfo.fallbackRank=h,this._eventInfo.defines=n,this._eventInfo.uniforms=b,this._eventInfo.attributes=p,this._eventInfo.samplers=E,this._eventInfo.uniformBuffersNames=C,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=T,this._callbackPluginEventGeneric(128,this._eventInfo),Da.AddUniforms(b),Da.AddSamplers(E),(0,tn.TV)(b),Ti.p&&(Ti.p.PrepareUniforms(b,n),Ti.p.PrepareSamplers(E,n)),(0,Re.Bb)({uniformsNames:b,uniformBuffersNames:C,samplers:E,defines:n,maxSimultaneousLights:this._maxSimultaneousLights});var f={};this.customShaderNameResolve&&(v=this.customShaderNameResolve(v,b,C,E,n,p,f));var g=n.toString(),S=u.createEffect(v,{attributes:p,uniformsNames:b,uniformBuffersNames:C,samplers:E,defines:g,fallbacks:d,onCompiled:i,onError:o,indexParameters:T,processFinalCode:f.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:n.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:function(){return(0,A.sH)(c,void 0,void 0,function(){return(0,A.YH)(this,function(y){switch(y.label){case 0:return this.shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,10721)),Promise.resolve().then(L.bind(L,36934))])];case 1:return y.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,17152)),Promise.resolve().then(L.bind(L,62338))])];case 3:y.sent(),y.label=4;case 4:return this._shadersLoaded=!0,[2]}})})}},u);return this._eventInfo.customCode=void 0,S},t.prototype._prepareDefines=function(e,n,i,o,a){i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=!1);var s=this.getScene(),l=s.getEngine();(0,Re.az)(s,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._needNormals=!0,(0,Re.VO)(s,n);var c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if((0,Re.N4)(s,n,this.canRenderToMRT&&!c),(0,Re.Nc)(s,n,c),n.METALLICWORKFLOW=this.isMetallicWorkflow(),n._areTexturesDirty){n._needUVs=!1;for(var u=1;u<=P.Y.MAX_SUPPORTED_UV_SETS;++u)n["MAINUV"+u]=!1;if(s.texturesEnabled){n.ALBEDODIRECTUV=0,n.AMBIENTDIRECTUV=0,n.OPACITYDIRECTUV=0,n.EMISSIVEDIRECTUV=0,n.REFLECTIVITYDIRECTUV=0,n.MICROSURFACEMAPDIRECTUV=0,n.METALLIC_REFLECTANCEDIRECTUV=0,n.REFLECTANCEDIRECTUV=0,n.BUMPDIRECTUV=0,n.LIGHTMAPDIRECTUV=0,l.getCaps().textureLOD&&(n.LODBASEDMICROSFURACE=!0),this._albedoTexture&&$e.DiffuseTextureEnabled?((0,Re.YT)(this._albedoTexture,n,"ALBEDO"),n.GAMMAALBEDO=this._albedoTexture.gammaSpace):n.ALBEDO=!1,this._ambientTexture&&$e.AmbientTextureEnabled?((0,Re.YT)(this._ambientTexture,n,"AMBIENT"),n.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):n.AMBIENT=!1,this._opacityTexture&&$e.OpacityTextureEnabled?((0,Re.YT)(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):n.OPACITY=!1;var d=this._getReflectionTexture();if(d&&$e.ReflectionTextureEnabled){switch(n.REFLECTION=!0,n.GAMMAREFLECTION=d.gammaSpace,n.RGBDREFLECTION=d.isRGBD,n.LODINREFLECTIONALPHA=d.lodLevelInAlpha,n.LINEARSPECULARREFLECTION=d.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(n.NUM_SAMPLES=""+this.realTimeFilteringQuality,l._features.needTypeSuffixInShaderConstants&&(n.NUM_SAMPLES=n.NUM_SAMPLES+"u"),n.REALTIME_FILTERING=!0):n.REALTIME_FILTERING=!1,n.INVERTCUBICMAP=d.coordinatesMode===Ie.g.INVCUBIC_MODE,n.REFLECTIONMAP_3D=d.isCube,n.REFLECTIONMAP_OPPOSITEZ=n.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!d.invertZ:d.invertZ,n.REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,d.coordinatesMode){case Ie.g.EXPLICIT_MODE:n.REFLECTIONMAP_EXPLICIT=!0;break;case Ie.g.PLANAR_MODE:n.REFLECTIONMAP_PLANAR=!0;break;case Ie.g.PROJECTION_MODE:n.REFLECTIONMAP_PROJECTION=!0;break;case Ie.g.SKYBOX_MODE:n.REFLECTIONMAP_SKYBOX=!0;break;case Ie.g.SPHERICAL_MODE:n.REFLECTIONMAP_SPHERICAL=!0;break;case Ie.g.EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ie.g.FIXED_EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ie.g.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ie.g.CUBIC_MODE:case Ie.g.INVCUBIC_MODE:default:n.REFLECTIONMAP_CUBIC=!0,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!!d.boundingBoxSize}d.coordinatesMode!==Ie.g.SKYBOX_MODE&&(d.irradianceTexture?(n.USEIRRADIANCEMAP=!0,n.USESPHERICALFROMREFLECTIONMAP=!1):d.isCube&&(n.USESPHERICALFROMREFLECTIONMAP=!0,n.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||l.getCaps().maxVaryingVectors<=8?n.USESPHERICALINVERTEX=!1:n.USESPHERICALINVERTEX=!0))}else n.REFLECTION=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.INVERTCUBICMAP=!1,n.USESPHERICALFROMREFLECTIONMAP=!1,n.USEIRRADIANCEMAP=!1,n.USESPHERICALINVERTEX=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.LODINREFLECTIONALPHA=!1,n.GAMMAREFLECTION=!1,n.RGBDREFLECTION=!1,n.LINEARSPECULARREFLECTION=!1;this._lightmapTexture&&$e.LightmapTextureEnabled?((0,Re.YT)(this._lightmapTexture,n,"LIGHTMAP"),n.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,n.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,n.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):n.LIGHTMAP=!1,this._emissiveTexture&&$e.EmissiveTextureEnabled?((0,Re.YT)(this._emissiveTexture,n,"EMISSIVE"),n.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):n.EMISSIVE=!1,$e.SpecularTextureEnabled?(this._metallicTexture?((0,Re.YT)(this._metallicTexture,n,"REFLECTIVITY"),n.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,n.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,n.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,n.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,n.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?((0,Re.YT)(this._reflectivityTexture,n,"REFLECTIVITY"),n.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,n.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,n.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):n.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture?(n.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture,this._metallicReflectanceTexture?((0,Re.YT)(this._metallicReflectanceTexture,n,"METALLIC_REFLECTANCE"),n.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):n.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?((0,Re.YT)(this._reflectanceTexture,n,"REFLECTANCE"),n.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):n.REFLECTANCE=!1):(n.METALLIC_REFLECTANCE=!1,n.REFLECTANCE=!1),this._microSurfaceTexture?(0,Re.YT)(this._microSurfaceTexture,n,"MICROSURFACEMAP"):n.MICROSURFACEMAP=!1):(n.REFLECTIVITY=!1,n.MICROSURFACEMAP=!1),l.getCaps().standardDerivatives&&this._bumpTexture&&$e.BumpTextureEnabled&&!this._disableBumpMap?((0,Re.YT)(this._bumpTexture,n,"BUMP"),this._useParallax&&this._albedoTexture&&$e.DiffuseTextureEnabled?(n.PARALLAX=!0,n.PARALLAX_RHS=s.useRightHandedSystem,n.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):n.PARALLAX=!1,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(n.BUMP=!1,n.PARALLAX=!1,n.PARALLAX_RHS=!1,n.PARALLAXOCCLUSION=!1,n.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&$e.ReflectionTextureEnabled?(n.ENVIRONMENTBRDF=!0,n.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(n.ENVIRONMENTBRDF=!1,n.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?n.ALPHAFROMALBEDO=!0:n.ALPHAFROMALBEDO=!1}n.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===t.LIGHTFALLOFF_STANDARD?(n.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===t.LIGHTFALLOFF_GLTF?(n.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!0):(n.USEPHYSICALLIGHTFALLOFF=!0,n.USEGLTFLIGHTFALLOFF=!1),n.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?n.TWOSIDEDLIGHTING=!0:n.TWOSIDEDLIGHTING=!1,n.SPECULARAA=l.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(n._areTexturesDirty||n._areMiscDirty)&&(n.ALPHATESTVALUE="".concat(this._alphaCutOff).concat(this._alphaCutOff%1==0?".":""),n.PREMULTIPLYALPHA=this.alphaMode===P.Y.ALPHA_PREMULTIPLIED||this.alphaMode===P.Y.ALPHA_PREMULTIPLIED_PORTERDUFF,n.ALPHABLEND=this.needAlphaBlendingForMesh(e),n.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,n.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),n._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(n),n.FORCENORMALFORWARD=this._forceNormalForward,n.RADIANCEOCCLUSION=this._useRadianceOcclusion,n.HORIZONOCCLUSION=this._useHorizonOcclusion,n._areMiscDirty&&((0,Re.fm)(e,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,n,this._applyDecalMapAfterDetailMap),n.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(Y.R.NormalKind),n.DEBUGMODE=this._debugMode),(0,Re.OR)(s,l,this,n,!!i,o,a),this._eventInfo.defines=n,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),(0,Re.qB)(e,n,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)},t.prototype.forceCompilation=function(e,n,i){var o=this,a=(0,A.Cl)({clipPlane:!1,useInstances:!1},i);this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(4,this._eventInfo),function(){if(!o._breakShaderLoadedCheck){var s=new Xd(o._eventInfo.defineNames),l=o._prepareEffect(e,s,void 0,void 0,a.useInstances,a.clipPlane,e.hasThinInstances);o._onEffectCreatedObservable&&(Qa.effect=l,Qa.subMesh=null,o._onEffectCreatedObservable.notifyObservers(Qa)),l.isReady()?n&&n(o):l.onCompileObservable.add(function(){n&&n(o)})}}()},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionFilteringInfo",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("reflectionMatrix",16),e.addUniform("vReflectionColor",3),e.addUniform("vAlbedoColor",4),e.addUniform("vLightingIntensity",4),e.addUniform("vReflectionMicrosurfaceInfos",3),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vAmbientColor",3),e.addUniform("vDebugMode",2),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),e.addUniform("vReflectanceInfos",2),e.addUniform("reflectanceMatrix",16),e.addUniform("vSphericalL00",3),e.addUniform("vSphericalL1_1",3),e.addUniform("vSphericalL10",3),e.addUniform("vSphericalL11",3),e.addUniform("vSphericalL2_2",3),e.addUniform("vSphericalL2_1",3),e.addUniform("vSphericalL20",3),e.addUniform("vSphericalL21",3),e.addUniform("vSphericalL22",3),e.addUniform("vSphericalX",3),e.addUniform("vSphericalY",3),e.addUniform("vSphericalZ",3),e.addUniform("vSphericalXX_ZZ",3),e.addUniform("vSphericalYY_ZZ",3),e.addUniform("vSphericalZZ",3),e.addUniform("vSphericalXY",3),e.addUniform("vSphericalYZ",3),e.addUniform("vSphericalZX",3),r.prototype.buildUniformLayout.call(this)},t.prototype.bindForSubMesh=function(e,n,i){var o,a,s,l,c=this.getScene(),u=i.materialDefines;if(u){var d=i.effect;if(d){this._activeEffect=d,n.getMeshUniformBuffer().bindToEffect(d,"Mesh"),n.transferToEffect(e);var h=c.getEngine();this._uniformBuffer.bindToEffect(d,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,c,n,e,this.isFrozen),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),u.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var p=this._mustRebind(c,d,i,n.visibility);(0,Re.f$)(n,this._activeEffect,this.prePassConfiguration);var m=null,v=this._uniformBuffer;if(p){if(this.bindViewProjection(d),m=this._getReflectionTexture(),!v.useUbo||!this.isFrozen||!v.isSync||i._drawWrapper._forceRebindOnNextCall){if(c.texturesEnabled){if(this._albedoTexture&&$e.DiffuseTextureEnabled&&(v.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),(0,Re.mA)(this._albedoTexture,v,"albedo")),this._ambientTexture&&$e.AmbientTextureEnabled&&(v.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),(0,Re.mA)(this._ambientTexture,v,"ambient")),this._opacityTexture&&$e.OpacityTextureEnabled&&(v.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),(0,Re.mA)(this._opacityTexture,v,"opacity")),m&&$e.ReflectionTextureEnabled){if(v.updateMatrix("reflectionMatrix",m.getReflectionTextureMatrix()),v.updateFloat2("vReflectionInfos",m.level,0),m.boundingBoxSize){var b=m;v.updateVector3("vReflectionPosition",b.boundingBoxPosition),v.updateVector3("vReflectionSize",b.boundingBoxSize)}if(this.realTimeFiltering){var E=m.getSize().width;v.updateFloat2("vReflectionFilteringInfo",E,Math.log2(E))}if(!u.USEIRRADIANCEMAP){var C=m.sphericalPolynomial;if(u.USESPHERICALFROMREFLECTIONMAP&&C)if(u.SPHERICAL_HARMONICS){var T=C.preScaledHarmonics;v.updateVector3("vSphericalL00",T.l00),v.updateVector3("vSphericalL1_1",T.l1_1),v.updateVector3("vSphericalL10",T.l10),v.updateVector3("vSphericalL11",T.l11),v.updateVector3("vSphericalL2_2",T.l2_2),v.updateVector3("vSphericalL2_1",T.l2_1),v.updateVector3("vSphericalL20",T.l20),v.updateVector3("vSphericalL21",T.l21),v.updateVector3("vSphericalL22",T.l22)}else v.updateFloat3("vSphericalX",C.x.x,C.x.y,C.x.z),v.updateFloat3("vSphericalY",C.y.x,C.y.y,C.y.z),v.updateFloat3("vSphericalZ",C.z.x,C.z.y,C.z.z),v.updateFloat3("vSphericalXX_ZZ",C.xx.x-C.zz.x,C.xx.y-C.zz.y,C.xx.z-C.zz.z),v.updateFloat3("vSphericalYY_ZZ",C.yy.x-C.zz.x,C.yy.y-C.zz.y,C.yy.z-C.zz.z),v.updateFloat3("vSphericalZZ",C.zz.x,C.zz.y,C.zz.z),v.updateFloat3("vSphericalXY",C.xy.x,C.xy.y,C.xy.z),v.updateFloat3("vSphericalYZ",C.yz.x,C.yz.y,C.yz.z),v.updateFloat3("vSphericalZX",C.zx.x,C.zx.y,C.zx.z)}v.updateFloat3("vReflectionMicrosurfaceInfos",m.getSize().width,m.lodGenerationScale,m.lodGenerationOffset)}this._emissiveTexture&&$e.EmissiveTextureEnabled&&(v.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),(0,Re.mA)(this._emissiveTexture,v,"emissive")),this._lightmapTexture&&$e.LightmapTextureEnabled&&(v.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),(0,Re.mA)(this._lightmapTexture,v,"lightmap")),$e.SpecularTextureEnabled&&(this._metallicTexture?(v.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),(0,Re.mA)(this._metallicTexture,v,"reflectivity")):this._reflectivityTexture&&(v.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),(0,Re.mA)(this._reflectivityTexture,v,"reflectivity")),this._metallicReflectanceTexture&&(v.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),(0,Re.mA)(this._metallicReflectanceTexture,v,"metallicReflectance")),this._reflectanceTexture&&u.REFLECTANCE&&(v.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),(0,Re.mA)(this._reflectanceTexture,v,"reflectance")),this._microSurfaceTexture&&(v.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),(0,Re.mA)(this._microSurfaceTexture,v,"microSurfaceSampler"))),this._bumpTexture&&h.getCaps().standardDerivatives&&$e.BumpTextureEnabled&&!this._disableBumpMap&&(v.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),(0,Re.mA)(this._bumpTexture,v,"bump"),c._mirroredCameraPosition?v.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):v.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&v.updateFloat("pointSize",this.pointSize),u.METALLICWORKFLOW){z.IG.Color3[0].r=this._metallic===void 0||this._metallic===null?1:this._metallic,z.IG.Color3[0].g=this._roughness===void 0||this._roughness===null?1:this._roughness,v.updateColor4("vReflectivityColor",z.IG.Color3[0],1);var f=(a=(o=this.subSurface)===null||o===void 0?void 0:o._indexOfRefraction)!==null&&a!==void 0?a:1.5,g=Math.pow((f-1)/(f+1),2);this._metallicReflectanceColor.scaleToRef(g*this._metallicF0Factor,z.IG.Color3[0]);var S=this._metallicF0Factor;v.updateColor4("vMetallicReflectanceFactors",z.IG.Color3[0],S)}else v.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);v.updateColor3("vEmissiveColor",$e.EmissiveTextureEnabled?this._emissiveColor:z.v9.BlackReadOnly),v.updateColor3("vReflectionColor",this._reflectionColor),!u.SS_REFRACTION&&(!((s=this.subSurface)===null||s===void 0)&&s._linkRefractionWithTransparency)?v.updateColor4("vAlbedoColor",this._albedoColor,1):v.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*c.environmentIntensity,this._lightingInfos.w=this._specularIntensity,v.updateVector4("vLightingIntensity",this._lightingInfos),c.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),v.updateColor3("vAmbientColor",this._globalAmbientColor),v.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}c.texturesEnabled&&(this._albedoTexture&&$e.DiffuseTextureEnabled&&v.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&$e.AmbientTextureEnabled&&v.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&$e.OpacityTextureEnabled&&v.setTexture("opacitySampler",this._opacityTexture),m&&$e.ReflectionTextureEnabled&&(u.LODBASEDMICROSFURACE?v.setTexture("reflectionSampler",m):(v.setTexture("reflectionSampler",m._lodTextureMid||m),v.setTexture("reflectionSamplerLow",m._lodTextureLow||m),v.setTexture("reflectionSamplerHigh",m._lodTextureHigh||m)),u.USEIRRADIANCEMAP&&v.setTexture("irradianceSampler",m.irradianceTexture)),u.ENVIRONMENTBRDF&&v.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&$e.EmissiveTextureEnabled&&v.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&$e.LightmapTextureEnabled&&v.setTexture("lightmapSampler",this._lightmapTexture),$e.SpecularTextureEnabled&&(this._metallicTexture?v.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&v.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&v.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&u.REFLECTANCE&&v.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&v.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&h.getCaps().standardDerivatives&&$e.BumpTextureEnabled&&!this._disableBumpMap&&v.setTexture("bumpSampler",this._bumpTexture)),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(n)&&this.getScene().depthPeelingRenderer.bind(d),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),(0,tn.gS)(this._activeEffect,this,c),this.bindEyePosition(d)}else c.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!p&&this.isFrozen||(c.lightsEnabled&&!this._disableLighting&&(0,Re.RL)(c,n,this._activeEffect,u,this._maxSimultaneousLights),(c.fogEnabled&&n.applyFog&&c.fogMode!==ke.Z.FOGMODE_NONE||m||this.subSurface.refractionTexture||n.receiveShadows||u.PREPASS)&&this.bindView(d),(0,Re.Yy)(c,n,this._activeEffect,!0),u.NUM_MORPH_INFLUENCERS&&(0,Re.nR)(n,this._activeEffect),u.BAKED_VERTEX_ANIMATION_TEXTURE&&((l=n.bakedVertexAnimationManager)===null||l===void 0||l.bind(d,u.INSTANCES)),this._imageProcessingConfiguration.bind(this._activeEffect),(0,Re.DL)(u,this._activeEffect,c)),this._afterBind(n,this._activeEffect,i),v.update()}}},t.prototype.getAnimatables=function(){var e=r.prototype.getAnimatables.call(this);return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._metallicReflectanceTexture&&this._metallicReflectanceTexture.animations&&this._metallicReflectanceTexture.animations.length>0&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&this._reflectanceTexture.animations&&this._reflectanceTexture.animations.length>0&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&this._microSurfaceTexture.animations&&this._microSurfaceTexture.animations.length>0&&e.push(this._microSurfaceTexture),e},t.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},t.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._metallicReflectanceTexture&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),e},t.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||this._albedoTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._reflectivityTexture===e||this._metallicTexture===e||this._metallicReflectanceTexture===e||this._reflectanceTexture===e||this._microSurfaceTexture===e||this._bumpTexture===e||this._lightmapTexture===e},t.prototype.setPrePassRenderer=function(){var e;if(!(!((e=this.subSurface)===null||e===void 0)&&e.isScatteringEnabled))return!1;var n=this.getScene().enableSubSurfaceForPrePass();return n&&(n.enabled=!0),!0},t.prototype.dispose=function(e,n){var i,o,a,s,l,c,u,d,h,p,m,v;this._breakShaderLoadedCheck=!0,n&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),(i=this._albedoTexture)===null||i===void 0||i.dispose(),(o=this._ambientTexture)===null||o===void 0||o.dispose(),(a=this._opacityTexture)===null||a===void 0||a.dispose(),(s=this._reflectionTexture)===null||s===void 0||s.dispose(),(l=this._emissiveTexture)===null||l===void 0||l.dispose(),(c=this._metallicTexture)===null||c===void 0||c.dispose(),(u=this._reflectivityTexture)===null||u===void 0||u.dispose(),(d=this._bumpTexture)===null||d===void 0||d.dispose(),(h=this._lightmapTexture)===null||h===void 0||h.dispose(),(p=this._metallicReflectanceTexture)===null||p===void 0||p.dispose(),(m=this._reflectanceTexture)===null||m===void 0||m.dispose(),(v=this._microSurfaceTexture)===null||v===void 0||v.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,n)},t.PBRMATERIAL_OPAQUE=Lt.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=Lt.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=Lt.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=Lt.MATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,t.ForceGLSL=!1,(0,A.Cg)([(0,V.n1)()],t.prototype,"_imageProcessingConfiguration",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),t}(Ro),fl=function(r){function t(e,n,i){i===void 0&&(i=!1);var o=r.call(this,e,n,i)||this;return o.directIntensity=1,o.emissiveIntensity=1,o.environmentIntensity=1,o.specularIntensity=1,o.disableBumpMap=!1,o.ambientTextureStrength=1,o.ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,o.metallicF0Factor=1,o.metallicReflectanceColor=z.v9.White(),o.useOnlyMetallicFromMetallicReflectanceTexture=!1,o.ambientColor=new z.v9(0,0,0),o.albedoColor=new z.v9(1,1,1),o.reflectivityColor=new z.v9(1,1,1),o.reflectionColor=new z.v9(1,1,1),o.emissiveColor=new z.v9(0,0,0),o.microSurface=1,o.useLightmapAsShadowmap=!1,o.useAlphaFromAlbedoTexture=!1,o.forceAlphaTest=!1,o.alphaCutOff=.4,o.useSpecularOverAlpha=!0,o.useMicroSurfaceFromReflectivityMapAlpha=!1,o.useRoughnessFromMetallicTextureAlpha=!0,o.useRoughnessFromMetallicTextureGreen=!1,o.useMetallnessFromMetallicTextureBlue=!1,o.useAmbientOcclusionFromMetallicTextureRed=!1,o.useAmbientInGrayScale=!1,o.useAutoMicroSurfaceFromReflectivityMap=!1,o.useRadianceOverAlpha=!0,o.useObjectSpaceNormalMap=!1,o.useParallax=!1,o.useParallaxOcclusion=!1,o.parallaxScaleBias=.05,o.disableLighting=!1,o.forceIrradianceInFragment=!1,o.maxSimultaneousLights=4,o.invertNormalMapX=!1,o.invertNormalMapY=!1,o.twoSidedLighting=!1,o.useAlphaFresnel=!1,o.useLinearAlphaFresnel=!1,o.environmentBRDFTexture=null,o.forceNormalForward=!1,o.enableSpecularAntiAliasing=!1,o.useHorizonOcclusion=!0,o.useRadianceOcclusion=!0,o.unlit=!1,o.applyDecalMapAfterDetailMap=!1,o._environmentBRDFTexture=qa(o.getScene()),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this.subSurface.refractionTexture},set:function(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"invertRefractionY",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkRefractionWithTransparency",{get:function(){return this.subSurface.linkRefractionWithTransparency},set:function(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===Tn.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?Tn.LIGHTFALLOFF_PHYSICAL:Tn.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===Tn.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?Tn.LIGHTFALLOFF_GLTF:Tn.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.clone=function(e,n,i){var o=this;n===void 0&&(n=!0),i===void 0&&(i="");var a=tt.p.Clone(function(){return new t(e,o.getScene())},this,{cloneTexturesOnlyOnce:n});return a.id=e,a.name=e,this.stencil.copyTo(a.stencil),this._clonePlugins(a,i),a},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.customType="BABYLON.PBRMaterial",e},t.Parse=function(e,n,i){var o=tt.p.Parse(function(){return new t(e.name,n)},e,n,i);return e.stencil&&o.stencil.parse(e.stencil,n,i),Lt._ParsePlugins(e,o,n,i),e.clearCoat&&o.clearCoat.parse(e.clearCoat,n,i),e.anisotropy&&o.anisotropy.parse(e.anisotropy,n,i),e.brdf&&o.brdf.parse(e.brdf,n,i),e.sheen&&o.sheen.parse(e.sheen,n,i),e.subSurface&&o.subSurface.parse(e.subSurface,n,i),e.iridescence&&o.iridescence.parse(e.iridescence,n,i),o},t.PBRMATERIAL_OPAQUE=Tn.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=Tn.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=Tn.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=Tn.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=Tn.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),(0,A.Cg)([(0,V.jT)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceColor",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectanceTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),(0,A.Cg)([(0,V.jT)("ambient"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),(0,A.Cg)([(0,V.jT)("albedo"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),(0,A.Cg)([(0,V.jT)("reflectivity"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),(0,A.Cg)([(0,V.jT)("reflection"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),(0,A.Cg)([(0,V.jT)("emissive"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"usePhysicalLightFalloff",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"useGLTFLightFalloff",null),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),(0,A.Cg)([(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsMiscDirty")],t.prototype,"applyDecalMapAfterDetailMap",void 0),t}(Tn);(0,j.Y5)("BABYLON.PBRMaterial",fl);var jd,vx=L(19135),yx=L(71545),bx=L(81867),Hg=function(r){function t(e,n,i){var o=r.call(this,e,_.Pq.Zero(),n)||this;return o._xrSessionManager=i,o._firstFrame=!1,o._referenceQuaternion=_.PT.Identity(),o._referencedPosition=new _.Pq,o._trackingState=0,o.onXRCameraInitializedObservable=new K.cP,o.onBeforeCameraTeleport=new K.cP,o.onAfterCameraTeleport=new K.cP,o.onTrackingStateChanged=new K.cP,o.compensateOnFirstFrame=!0,o._rotate180=new _.PT(0,1,0,0),o.minZ=.1,o.rotationQuaternion=new _.PT,o.cameraRigMode=Pt.RIG_MODE_CUSTOM,o.updateUpVectorFromRotation=!0,o._updateNumberOfRigCameras(1),o.freezeProjectionMatrix(),o._deferOnly=!0,o._xrSessionManager.onXRSessionInit.add(function(){o._referencedPosition.copyFromFloats(0,0,0),o._referenceQuaternion.copyFromFloats(0,0,0,1),o._firstFrame=o.compensateOnFirstFrame,o._xrSessionManager.onWorldScaleFactorChangedObservable.add(function(){o._xrSessionManager.currentFrame&&o._updateDepthNearFar()})}),o._xrSessionManager.onXRFrameObservable.add(function(){o._firstFrame&&o._updateFromXRSession(),o.onXRCameraInitializedObservable.hasObservers()&&(o.onXRCameraInitializedObservable.notifyObservers(o),o.onXRCameraInitializedObservable.clear()),o._deferredUpdated&&(o.position.copyFrom(o._deferredPositionUpdate),o.rotationQuaternion.copyFrom(o._deferredRotationQuaternionUpdate)),o._updateReferenceSpace(),o._updateFromXRSession()},void 0,!0),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"trackingState",{get:function(){return this._trackingState},enumerable:!1,configurable:!0}),t.prototype._setTrackingState=function(e){this._trackingState!==e&&(this._trackingState=e,this.onTrackingStateChanged.notifyObservers(e))},Object.defineProperty(t.prototype,"realWorldHeight",{get:function(){var e=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);return e&&e.transform?e.transform.position.y*this._xrSessionManager.worldScalingFactor:0},enumerable:!1,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new Br.L(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Br.L(.5,0,.5,1),this.rigCameras[1].outputRenderTarget=null},t.prototype.setTransformationFromNonVRCamera=function(e,n){e===void 0&&(e=this.getScene().activeCamera),n===void 0&&(n=!0),e&&e!==this&&(e.computeWorldMatrix().decompose(void 0,this.rotationQuaternion,this.position),this.position.y=0,_.PT.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,n&&this._xrSessionManager.resetReferenceSpace())},t.prototype.getClassName=function(){return"WebXRCamera"},t.prototype.setTarget=function(e){var n=_.AA.Vector3[1];e.subtractToRef(this.position,n),n.y=0,n.normalize();var i=Math.atan2(n.x,n.z);this.rotationQuaternion.toEulerAnglesToRef(n),_.PT.FromEulerAnglesToRef(n.x,i,n.z,this.rotationQuaternion)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._lastXRViewerPose=void 0},t.prototype._updateDepthNearFar=function(){var e=(this.maxZ||1e4)*this._xrSessionManager.worldScalingFactor,n={depthFar:e,depthNear:this.minZ};this._xrSessionManager.updateRenderState(n),this._cache.minZ=this.minZ,this._cache.maxZ=e},t.prototype._updateFromXRSession=function(){var e=this,n=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);if(this._lastXRViewerPose=n||void 0,n){var i=n.emulatedPosition?1:2;if(this._setTrackingState(i),this.minZ===this._cache.minZ&&this.maxZ===this._cache.maxZ||this._updateDepthNearFar(),n.transform){var o=n.transform.orientation;if(n.transform.orientation.x===void 0)return;var a=n.transform.position;this._referencedPosition.set(a.x,a.y,a.z).scaleInPlace(this._xrSessionManager.worldScalingFactor),this._referenceQuaternion.set(o.x,o.y,o.z,o.w),this._scene.useRightHandedSystem||(this._referencedPosition.z*=-1,this._referenceQuaternion.z*=-1,this._referenceQuaternion.w*=-1),this._firstFrame?(this._firstFrame=!1,this.position.y+=this._referencedPosition.y,this._referenceQuaternion.copyFromFloats(0,0,0,1)):(this.rotationQuaternion.copyFrom(this._referenceQuaternion),this.position.copyFrom(this._referencedPosition))}this.rigCameras.length!==n.views.length&&this._updateNumberOfRigCameras(n.views.length),n.views.forEach(function(s,l){var c,u=e.rigCameras[l];u.isLeftCamera||u.isRightCamera||(s.eye==="right"?u._isRightCamera=!0:s.eye==="left"&&(u._isLeftCamera=!0));for(var d=e.getScene().customRenderTargets,h=0;h<d.length;h++){var p=d[h];u.customRenderTargets.indexOf(p)===-1&&u.customRenderTargets.push(p)}var m=s.transform.position,v=s.transform.orientation;u.parent=e.parent,u.position.set(m.x,m.y,m.z).scaleInPlace(e._xrSessionManager.worldScalingFactor),u.rotationQuaternion.set(v.x,v.y,v.z,v.w),e._scene.useRightHandedSystem?u.rotationQuaternion.multiplyInPlace(e._rotate180):(u.position.z*=-1,u.rotationQuaternion.z*=-1,u.rotationQuaternion.w*=-1),_.uq.FromFloat32ArrayToRefScaled(s.projectionMatrix,0,1,u._projectionMatrix),e._scene.useRightHandedSystem||u._projectionMatrix.toggleProjectionMatrixHandInPlace();var b=2*Math.atan2(1,s.projectionMatrix[5]);u.fov=b,l===0&&(e.fov=b,e._projectionMatrix.copyFrom(u._projectionMatrix));var E=e._xrSessionManager.getRenderTargetTextureForView(s);e._renderingMultiview=((c=E?._texture)===null||c===void 0?void 0:c.isMultiview)||!1,e._renderingMultiview?l==0&&(e._xrSessionManager.trySetViewportForView(e.viewport,s),e.outputRenderTarget=E):(e._xrSessionManager.trySetViewportForView(u.viewport,s),u.outputRenderTarget=E||e._xrSessionManager.getRenderTargetTextureForView(s)),u.layerMask=e.layerMask})}else this._setTrackingState(0)},t.prototype._updateNumberOfRigCameras=function(e){for(e===void 0&&(e=1);this.rigCameras.length<e;){var n=new kr("XR-RigCamera: "+this.rigCameras.length,_.Pq.Zero(),this.getScene());n.minZ=.1,n.rotationQuaternion=new _.PT,n.updateUpVectorFromRotation=!0,n.isRigCamera=!0,n.rigParent=this,n.freezeProjectionMatrix(),this.rigCameras.push(n)}for(;this.rigCameras.length>e;){var i=this.rigCameras.pop();i&&i.dispose()}},t.prototype._updateReferenceSpace=function(){if(!this.position.equals(this._referencedPosition)||!this.rotationQuaternion.equals(this._referenceQuaternion)){var e=_.AA.Matrix[0],n=_.AA.Matrix[1],i=_.AA.Matrix[2];_.uq.ComposeToRef(t._ScaleReadOnly,this._referenceQuaternion,this._referencedPosition,e),_.uq.ComposeToRef(t._ScaleReadOnly,this.rotationQuaternion,this.position,n),e.invert().multiplyToRef(n,i),i.invert(),this._scene.useRightHandedSystem||i.toggleModelMatrixHandInPlace(),i.decompose(void 0,this._referenceQuaternion,this._referencedPosition);var o=new XRRigidTransform({x:this._referencedPosition.x/this._xrSessionManager.worldScalingFactor,y:this._referencedPosition.y/this._xrSessionManager.worldScalingFactor,z:this._referencedPosition.z/this._xrSessionManager.worldScalingFactor},{x:this._referenceQuaternion.x,y:this._referenceQuaternion.y,z:this._referenceQuaternion.z,w:this._referenceQuaternion.w});this._xrSessionManager.referenceSpace=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(o)}},t._ScaleReadOnly=_.Pq.One(),t}(_r),Yg=function(){function r(t){var e=this;this._scene=t,this._nonVRCamera=null,this._attachedToElement=!1,this._spectatorCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this._spectatorMode=!1,this._lastTimestamp=0,this.onInitialXRPoseSetObservable=new K.cP,this.onStateChangedObservable=new K.cP,this.state=3,this.sessionManager=new bu(t),this.camera=new Hg("webxr",t,this.sessionManager),this.featuresManager=new kn(this.sessionManager),t.onDisposeObservable.addOnce(function(){e.dispose()})}return r.CreateAsync=function(t){var e=new r(t);return e.sessionManager.initializeAsync().then(function(){return e._supported=!0,e}).catch(function(n){throw e._setState(3),e.dispose(),n})},r.prototype.dispose=function(){var t;this.exitXRAsync(),this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),(t=this._spectatorCamera)===null||t===void 0||t.dispose(),this._nonVRCamera&&(this._scene.activeCamera=this._nonVRCamera)},r.prototype.enterXRAsync=function(t,e,n,i){var o,a,s,l;return n===void 0&&(n=this.sessionManager.getWebXRRenderTarget()),i===void 0&&(i={}),(0,A.sH)(this,void 0,void 0,function(){var c,u,d,h=this;return(0,A.YH)(this,function(p){switch(p.label){case 0:if(!this._supported)throw"WebXR not supported in this browser or environment";return this._setState(0),e!=="viewer"&&e!=="local"&&(i.optionalFeatures=i.optionalFeatures||[],i.optionalFeatures.push(e)),[4,this.featuresManager._extendXRSessionInitObject(i)];case 1:i=p.sent(),t==="immersive-ar"&&e!=="unbounded"&&O.V.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),p.label=2;case 2:return p.trys.push([2,7,,8]),[4,this.sessionManager.initializeSessionAsync(t,i)];case 3:return p.sent(),[4,this.sessionManager.setReferenceSpaceTypeAsync(e)];case 4:return p.sent(),c={depthFar:this.camera.maxZ||1e4,depthNear:this.camera.minZ},this.featuresManager.getEnabledFeature(vn.LAYERS)?[3,6]:[4,n.initializeXRLayerAsync(this.sessionManager.session)];case 5:u=p.sent(),c.baseLayer=u,p.label=6;case 6:return this.sessionManager.updateRenderState(c),this.sessionManager.runXRRenderLoop(),this._originalSceneAutoClear=this._scene.autoClear,this._nonVRCamera=this._scene.activeCamera,this._attachedToElement=!!(!((a=(o=this._nonVRCamera)===null||o===void 0?void 0:o.inputs)===null||a===void 0)&&a.attachedToElement),(s=this._nonVRCamera)===null||s===void 0||s.detachControl(),this._scene.activeCamera=this.camera,t!=="immersive-ar"?this._nonXRToXRCamera():(this._scene.autoClear=!1,this.camera.compensateOnFirstFrame=!1,this.camera.position.set(0,0,0),this.camera.rotationQuaternion.set(0,0,0,1),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)),(l=Be.$.audioEngine)===null||l===void 0||l._resumeAudioContextOnStateChange(),this.sessionManager.onXRSessionEnded.addOnce(function(){h.state!==1&&h._setState(1),h.camera.rigCameras.forEach(function(m){m.outputRenderTarget=null}),h._scene.autoClear=h._originalSceneAutoClear,h._scene.activeCamera=h._nonVRCamera,h._attachedToElement&&h._nonVRCamera&&h._nonVRCamera.attachControl(!!h._nonVRCamera.inputs.noPreventDefault),t!=="immersive-ar"&&h.camera.compensateOnFirstFrame&&(h._nonVRCamera.setPosition?h._nonVRCamera.setPosition(h.camera.position):h._nonVRCamera.position.copyFrom(h.camera.position)),h._setState(3)}),this.sessionManager.onXRFrameObservable.addOnce(function(){h._setState(2)}),[2,this.sessionManager];case 7:throw d=p.sent(),O.V.Log(d),O.V.Log(d.message),this._setState(3),d;case 8:return[2]}})})},r.prototype.exitXRAsync=function(){return this.state!==2?Promise.resolve():(this._setState(1),this.sessionManager.exitXRAsync())},r.prototype.enableSpectatorMode=function(t){this._spectatorMode||(this._spectatorMode=!0,this._switchSpectatorMode(t))},r.prototype.disableSpecatatorMode=function(){this._spectatorMode&&(this._spectatorMode=!1,this._switchSpectatorMode())},r.prototype._switchSpectatorMode=function(t){var e=this,n=1/(t?.fps?t.fps:1e3)*1e3,i=t?.preferredCameraIndex?t?.preferredCameraIndex:0,o=function(){e._spectatorCamera&&e.sessionManager.currentTimestamp-e._lastTimestamp>=n&&(e._lastTimestamp=e.sessionManager.currentTimestamp,e._spectatorCamera.position.copyFrom(e.camera.rigCameras[i].globalPosition),e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[i].absoluteRotation))};if(this._spectatorMode){if(i>=this.camera.rigCameras.length)throw new Error("the preferred camera index is beyond the length of rig camera array.");var a=function(){e.state===2?(e._spectatorCamera=new So("webxr-spectator",_.Pq.Zero(),e._scene),e._spectatorCamera.rotationQuaternion=new _.PT,e._scene.activeCameras=[e.camera,e._spectatorCamera],e.sessionManager.onXRFrameObservable.add(o),e._scene.onAfterRenderCameraObservable.add(function(s){s===e.camera&&(e._scene.getEngine().framebufferDimensionsObject=null)})):e.state===1&&(e.sessionManager.onXRFrameObservable.removeCallback(o),e._scene.activeCameras=null)};this.onStateChangedObservable.add(a),a()}else this.sessionManager.onXRFrameObservable.removeCallback(o),this._scene.activeCameras=[this.camera]},r.prototype._nonXRToXRCamera=function(){this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)},r.prototype._setState=function(t){this.state!==t&&(this.state=t,this.onStateChangedObservable.notifyObservers(this.state))},r}(),Xr=function(){function r(t,e,n,i){n===void 0&&(n=-1),i===void 0&&(i=[]),this.id=t,this.type=e,this._buttonIndex=n,this._axesIndices=i,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new K.cP,this.onButtonStateChangedObservable=new K.cP}return Object.defineProperty(r.prototype,"axes",{get:function(){return this._axes},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"changes",{get:function(){return this._changes},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasChanges",{get:function(){return this._hasChanges},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pressed",{get:function(){return this._pressed},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"touched",{get:function(){return this._touched},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()},r.prototype.isAxes=function(){return this._axesIndices.length!==0},r.prototype.isButton=function(){return this._buttonIndex!==-1},r.prototype.update=function(t){var e=!1,n=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var i=t.buttons[this._buttonIndex];if(!i)return;this._currentValue!==i.value&&(this.changes.value={current:i.value,previous:this._currentValue},e=!0,this._currentValue=i.value),this._touched!==i.touched&&(this.changes.touched={current:i.touched,previous:this._touched},e=!0,this._touched=i.touched),this._pressed!==i.pressed&&(this.changes.pressed={current:i.pressed,previous:this._pressed},e=!0,this._pressed=i.pressed)}this.isAxes()&&(this._axes.x!==t.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:t.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=t.axes[this._axesIndices[0]],n=!0),this._axes.y!==t.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=t.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:t.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=t.axes[this._axesIndices[1]],n=!0)),e&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),n&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))},r.BUTTON_TYPE="button",r.SQUEEZE_TYPE="squeeze",r.THUMBSTICK_TYPE="thumbstick",r.TOUCHPAD_TYPE="touchpad",r.TRIGGER_TYPE="trigger",r}(),hn=L(17347),Eo=L(23885);(function(r){r[r.Clean=0]="Clean",r[r.Stop=1]="Stop",r[r.Sync=2]="Sync",r[r.NoSync=3]="NoSync"})(jd||(jd={}));var Tx=new K.cP,wo={},Xg=!1;function jg(){return wo[".babylon"]}function qg(r){return wo[r]||(O.V.Warn("Unable to find a plugin to load "+r+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"),jg())}function Kg(r,t,e){var n="Unable to load from "+(r.rawData?"binary data":r.url);return t?n+=": ".concat(t):e&&(n+=": ".concat(e)),n}function Zg(r,t,e,n,i,o,a,s,l){var c,u,d=(u=r.url).substring(0,5)==="data:"?u.substring(5):null;if(r.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";var h=a?qg(a):d?function(p){for(var m in wo){var v=wo[m].plugin;if(v.canDirectLoad&&v.canDirectLoad(p))return wo[m]}return jg()}(r.url):function(p){var m=p.indexOf("?");m!==-1&&(p=p.substring(0,m));var v=p.lastIndexOf(".");return qg(p.substring(v,p.length).toLowerCase())}(r.url);if(!h)throw new Error("No plugin or fallback for ".concat(a??r.url));if(((c=l?.[h.plugin.name])===null||c===void 0?void 0:c.enabled)===!1)throw new Error("The '".concat(h.plugin.name,"' plugin is disabled via the loader options passed to the loading operation."));if(r.rawData&&!h.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return function(p){if(h.plugin.createPlugin){var m=h.plugin.createPlugin(l??{});return m instanceof Promise?(m.then(p).catch(function(v){i("Error instantiating plugin.",v)}),null):(p(m),m)}return p(h.plugin),h.plugin}(function(p){var m;if(!p)throw"The loader plugin corresponding to the '".concat(a,"' file type has not been found. If using es6, please import the plugin you wish to use before.");if(Tx.notifyObservers(p),d&&(p.canDirectLoad&&p.canDirectLoad(r.url)||!(0,hn.f2)(r.url)))if(p.directLoad){var v=p.directLoad(t,d);v instanceof Promise?v.then(function(I){e(p,I)}).catch(function(I){i("Error in directLoad of _loadData: "+I,I)}):e(p,v)}else e(p,d);else{var b=h.isBinary,E=function(I,M){t.isDisposed?i("Scene has been disposed"):e(p,I,M)},C=null,T=!1;(m=p.onDisposeObservable)===null||m===void 0||m.add(function(){T=!0,C&&(C.abort(),C=null),o()});var f=function(){if(!T){var I=function(M,D){i(M?.statusText,D)};if(!p.loadFile&&r.rawData)throw"Plugin does not support loading ArrayBufferView.";C=p.loadFile?p.loadFile(t,r.rawData||r.file||r.url,r.rootUrl,E,n,b,I,s):t._loadFile(r.file||r.url,E,n,!0,b,I)}},g=t.getEngine(),S=g.enableOfflineSupport;if(S){for(var y=!1,x=0,R=t.disableOfflineSupportExceptionRules;x<R.length;x++)if(R[x].test(r.url)){y=!0;break}S=!y}S&&Be.$.OfflineProviderFactory?t.offlineProvider=Be.$.OfflineProviderFactory(r.url,f,g.disableManifestCheck):f()}})}function Qg(r,t){var e,n,i=null,o=null;if(t)if(t.name)e="file:".concat(t.name),n=t.name,i=t;else if(ArrayBuffer.isView(t))e="",n=(0,Eo.z)(),o=t;else if(t.startsWith("data:"))e=t,n="";else if(r){var a=t;if(a.substring(0,1)==="/")return ze.S0.Error("Wrong sceneFilename parameter"),null;e=r+a,n=a}else e=t,n=ze.S0.GetFilename(t),r=ze.S0.GetFolderPath(t);else e=r,n=ze.S0.GetFilename(r),r=ze.S0.GetFolderPath(r);return{url:e,rootUrl:r,name:n,file:i,rawData:o}}function Jg(r){if(typeof r.extensions=="string"){var t=r.extensions;wo[t.toLowerCase()]={plugin:r,isBinary:!1}}else{var e=r.extensions;Object.keys(e).forEach(function(n){wo[n.toLowerCase()]={plugin:r,isBinary:e[n].isBinary}})}}function Sx(r,t,e,n,i,o,a,s,l,c){if(e===void 0&&(e=""),n===void 0&&(n=Ve.q.LastCreatedScene),i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),l===void 0&&(l=""),c===void 0&&(c={}),!n)return O.V.Error("No scene available to import mesh to"),null;var u=Qg(t,e);if(!u)return null;var d={};n.addPendingData(d);var h=function(){n.removePendingData(d)},p=function(b,E){var C=Kg(u,b,E);a?a(n,C,new Bi.bu(C,Bi.tG.SceneLoaderError,E)):O.V.Error(C),h()},m=o?function(b){try{o(b)}catch(E){p("Error in onProgress callback: "+E,E)}}:void 0,v=function(b,E,C,T,f,g,S,y){if(n.importedMeshesFiles.push(u.url),i)try{i(b,E,C,T,f,g,S,y)}catch(x){p("Error in onSuccess callback: "+x,x)}n.removePendingData(d)};return Zg(u,n,function(b,E,C){if(b.rewriteRootURL&&(u.rootUrl=b.rewriteRootURL(u.rootUrl,C)),b.importMesh){var T=[],f=[],g=[];if(!b.importMesh(r,n,E,u.rootUrl,T,f,g,p))return;n.loadingPluginName=b.name,v(T,f,g,[],[],[],[],[])}else b.importMeshAsync(r,n,E,u.rootUrl,m,u.name).then(function(S){n.loadingPluginName=b.name,v(S.meshes,S.particleSystems,S.skeletons,S.animationGroups,S.transformNodes,S.geometries,S.lights,S.spriteManagers)}).catch(function(S){p(S.message,S)})},m,p,h,s,l,c)}function Ex(r,t,e,n,i,o,a,s,l){return t===void 0&&(t=""),e===void 0&&(e=Ve.q.LastCreatedEngine),n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=""),l===void 0&&(l={}),e?$g(r,t,new ke.Z(e),n,i,o,a,s,l):(ze.S0.Error("No engine available"),null)}function xx(r,t,e){var n=e??{},i=n.rootUrl;return Px(i===void 0?"":i,r,t,n.onProgress,n.pluginExtension,n.name,n.pluginOptions)}function Px(r,t,e,n,i,o,a){return new Promise(function(s,l){Ex(r,t,e,function(c){s(c)},n,function(c,u,d){l(d||new Error(u))},i,o,a)})}function $g(r,t,e,n,i,o,a,s,l){if(t===void 0&&(t=""),e===void 0&&(e=Ve.q.LastCreatedScene),n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=""),l===void 0&&(l={}),!e)return O.V.Error("No scene available to append to"),null;var c=Qg(r,t);if(!c)return null;var u={};e.addPendingData(u);var d=function(){e.removePendingData(u)};pr.ShowLoadingScreen&&!Xg&&(Xg=!0,e.getEngine().displayLoadingUI(),e.executeWhenReady(function(){e.getEngine().hideLoadingUI(),Xg=!1}));var h=function(v,b){var E=Kg(c,v,b);o?o(e,E,new Bi.bu(E,Bi.tG.SceneLoaderError,b)):O.V.Error(E),d()},p=i?function(v){try{i(v)}catch(b){h("Error in onProgress callback",b)}}:void 0,m=function(){if(n)try{n(e)}catch(v){h("Error in onSuccess callback",v)}e.removePendingData(u)};return Zg(c,e,function(v,b){if(v.load){if(!v.load(e,b,c.rootUrl,h))return;e.loadingPluginName=v.name,m()}else v.loadAsync(e,b,c.rootUrl,p,c.name).then(function(){e.loadingPluginName=v.name,m()}).catch(function(E){h(E.message,E)})},p,h,d,a,s,l)}function Ax(r,t,e){return(0,A.sH)(this,void 0,void 0,function(){var n,i,o,a,s,l,c;return(0,A.YH)(this,function(u){switch(u.label){case 0:return i=(n=e??{}).rootUrl,o=i===void 0?"":i,a=n.onProgress,s=n.pluginExtension,l=n.name,c=n.pluginOptions,[4,Cx(o,r,t,a,s,l,c)];case 1:return u.sent(),[2]}})})}function Cx(r,t,e,n,i,o,a){return new Promise(function(s,l){$g(r,t,e,function(c){s(c)},n,function(c,u,d){l(d||new Error(u))},i,o,a)})}function ev(r,t,e,n,i,o,a,s,l){if(t===void 0&&(t=""),e===void 0&&(e=Ve.q.LastCreatedScene),n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=""),l===void 0&&(l={}),!e)return O.V.Error("No scene available to load asset container to"),null;var c=Qg(r,t);if(!c)return null;var u={};e.addPendingData(u);var d=function(){e.removePendingData(u)},h=function(v,b){var E=Kg(c,v,b);o?o(e,E,new Bi.bu(E,Bi.tG.SceneLoaderError,b)):O.V.Error(E),d()},p=i?function(v){try{i(v)}catch(b){h("Error in onProgress callback",b)}}:void 0,m=function(v){if(n)try{n(v)}catch(b){h("Error in onSuccess callback",b)}e.removePendingData(u)};return Zg(c,e,function(v,b){if(v.loadAssetContainer){var E=v.loadAssetContainer(e,b,c.rootUrl,h);if(!E)return;E.populateRootNodes(),e.loadingPluginName=v.name,m(E)}else v.loadAssetContainerAsync?v.loadAssetContainerAsync(e,b,c.rootUrl,p,c.name).then(function(C){C.populateRootNodes(),e.loadingPluginName=v.name,m(C)}).catch(function(C){h(C.message,C)}):h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},p,h,d,a,s,l)}function Rx(r,t,e){var n=e??{},i=n.rootUrl;return Ix(i===void 0?"":i,r,t,n.onProgress,n.pluginExtension,n.name,n.pluginOptions)}function Ix(r,t,e,n,i,o,a){return new Promise(function(s,l){ev(r,t,e,function(c){s(c)},n,function(c,u,d){l(d||new Error(u))},i,o,a)})}function Mx(r,t,e,n,i,o,a,s,l,c,u,d){if(t===void 0&&(t=""),e===void 0&&(e=Ve.q.LastCreatedScene),n===void 0&&(n=!0),i===void 0&&(i=0),o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),l===void 0&&(l=null),c===void 0&&(c=null),u===void 0&&(u=""),d===void 0&&(d={}),e){if(n){for(var h=0,p=e.animatables;h<p.length;h++)p[h].reset();e.stopAllAnimations(),e.animationGroups.slice().forEach(function(v){v.dispose()}),e.getNodes().forEach(function(v){v.animations&&(v.animations=[])})}else switch(i){case 0:e.animationGroups.slice().forEach(function(v){v.dispose()});break;case 1:e.animationGroups.forEach(function(v){v.stop()});break;case 2:e.animationGroups.forEach(function(v){v.reset(),v.restart()});break;case 3:break;default:return void O.V.Error("Unknown animation group loading mode value '"+i+"'")}var m=e.animatables.length;ev(r,t,e,function(v){v.mergeAnimationsTo(e,e.animatables.slice(m),o),v.dispose(),e.onAnimationFileImportedObservable.notifyObservers(e),a&&a(e)},s,l,c,u,d)}else O.V.Error("No scene available to load animations to")}function Ox(r,t,e){return(0,A.sH)(this,void 0,void 0,function(){var n,i,o,a,s,l,c,u,d,h;return(0,A.YH)(this,function(p){switch(p.label){case 0:return i=(n=e??{}).rootUrl,o=i===void 0?"":i,a=n.overwriteAnimations,s=n.animationGroupLoadingMode,l=n.targetConverter,c=n.onProgress,u=n.pluginExtension,d=n.name,h=n.pluginOptions,[4,Dx(o,r,t,a,s,l,c,u,d,h)];case 1:return p.sent(),[2]}})})}function Dx(r,t,e,n,i,o,a,s,l,c){return new Promise(function(u,d){Mx(r,t,e,n,i,o,function(h){u(h)},a,function(h,p,m){d(m||new Error(p))},s,l,c)})}var yn=function(){function r(){}return Object.defineProperty(r,"ForceFullSceneLoadingForIncremental",{get:function(){return pr.ForceFullSceneLoadingForIncremental},set:function(t){pr.ForceFullSceneLoadingForIncremental=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"ShowLoadingScreen",{get:function(){return pr.ShowLoadingScreen},set:function(t){pr.ShowLoadingScreen=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"loggingLevel",{get:function(){return pr.loggingLevel},set:function(t){pr.loggingLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(r,"CleanBoneMatrixWeights",{get:function(){return pr.CleanBoneMatrixWeights},set:function(t){pr.CleanBoneMatrixWeights=t},enumerable:!1,configurable:!0}),r.GetDefaultPlugin=function(){return jg()},r.GetPluginForExtension=function(t){var e;return(e=qg(t))===null||e===void 0?void 0:e.plugin},r.IsPluginForExtensionAvailable=function(t){return function(e){return!!wo[e]}(t)},r.RegisterPlugin=function(t){Jg(t)},r.ImportMesh=function(t,e,n,i,o,a,s,l,c){return Sx(t,e,n,i,o,a,s,l,c)},r.ImportMeshAsync=function(t,e,n,i,o,a,s){return function(l,c,u,d,h,p,m){return new Promise(function(v,b){Sx(l,c,u,d,function(E,C,T,f,g,S,y,x){v({meshes:E,particleSystems:C,skeletons:T,animationGroups:f,transformNodes:g,geometries:S,lights:y,spriteManagers:x})},h,function(E,C,T){b(T||new Error(C))},p,m,void 0)})}(t,e,n,i,o,a,s)},r.Load=function(t,e,n,i,o,a,s,l){return Ex(t,e,n,i,o,a,s,l)},r.LoadAsync=function(t,e,n,i,o,a){return Px(t,e,n,i,o,a)},r.Append=function(t,e,n,i,o,a,s,l){return $g(t,e,n,i,o,a,s,l)},r.AppendAsync=function(t,e,n,i,o,a){return Cx(t,e,n,i,o,a)},r.LoadAssetContainer=function(t,e,n,i,o,a,s,l){return ev(t,e,n,i,o,a,s,l)},r.LoadAssetContainerAsync=function(t,e,n,i,o,a){return Ix(t,e,n,i,o,a)},r.ImportAnimations=function(t,e,n,i,o,a,s,l,c,u,d){Mx(t,e,n,i,o,a,s,l,c,u,d)},r.ImportAnimationsAsync=function(t,e,n,i,o,a,s,l,c,u,d){return Dx(t,e,n,i,o,a,l,u,d)},r.NO_LOGGING=P.Y.SCENELOADER_NO_LOGGING,r.MINIMAL_LOGGING=P.Y.SCENELOADER_MINIMAL_LOGGING,r.SUMMARY_LOGGING=P.Y.SCENELOADER_SUMMARY_LOGGING,r.DETAILED_LOGGING=P.Y.SCENELOADER_DETAILED_LOGGING,r.OnPluginActivatedObservable=Tx,r}(),Bo=function(){function r(t,e,n,i,o,a){o===void 0&&(o=!1);var s=this;this.scene=t,this.layout=e,this.gamepadObject=n,this.handedness=i,this._doNotLoadControllerMesh=o,this._controllerCache=a,this._initComponent=function(l){if(l){var c=s.layout.components[l],u=c.type,d=c.gamepadIndices.button,h=[];c.gamepadIndices.xAxis!==void 0&&c.gamepadIndices.yAxis!==void 0&&h.push(c.gamepadIndices.xAxis,c.gamepadIndices.yAxis),s.components[l]=new Xr(l,u,d,h)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new K.cP,e.components&&Object.keys(e.components).forEach(this._initComponent)}return r.prototype.dispose=function(){var t=this;this.getComponentIds().forEach(function(e){return t.getComponent(e).dispose()}),this.rootMesh&&(this.rootMesh.getChildren(void 0,!0).forEach(function(e){e.setEnabled(!1)}),this.rootMesh.dispose(!!this._controllerCache,!this._controllerCache))},r.prototype.getAllComponentsOfType=function(t){var e=this;return this.getComponentIds().map(function(n){return e.components[n]}).filter(function(n){return n.type===t})},r.prototype.getComponent=function(t){return this.components[t]},r.prototype.getComponentIds=function(){return Object.keys(this.components)},r.prototype.getComponentOfType=function(t){return this.getAllComponentsOfType(t)[0]||null},r.prototype.getMainComponent=function(){return this.getComponent(this.layout.selectComponentId)},r.prototype.loadModel=function(){return(0,A.sH)(this,void 0,void 0,function(){var t,e,n=this;return(0,A.YH)(this,function(i){return t=!this._getModelLoadingConstraints(),e=this._getGenericFilenameAndPath(),t?O.V.Warn("Falling back to generic models"):e=this._getFilenameAndPath(),[2,new Promise(function(o,a){var s=function(c){t?n._getGenericParentMesh(c):n._setRootMesh(c),n._processLoadedModel(c),n._modelReady=!0,n.onModelLoadedObservable.notifyObservers(n),o(!0)};if(n._controllerCache){var l=n._controllerCache.filter(function(c){return c.filename===e.filename&&c.path===e.path});if(l[0])return l[0].meshes.forEach(function(c){return c.setEnabled(!0)}),void s(l[0].meshes)}yn.ImportMesh("",e.path,e.filename,n.scene,function(c){n._controllerCache&&n._controllerCache.push((0,A.Cl)((0,A.Cl)({},e),{meshes:c})),s(c)},null,function(c,u){O.V.Log(u),O.V.Warn("Failed to retrieve controller model of type ".concat(n.profileId," from the remote server: ").concat(e.path).concat(e.filename)),a(u)})})]})})},r.prototype.updateFromXRFrame=function(t){var e=this;this.getComponentIds().forEach(function(n){return e.getComponent(n).update(e.gamepadObject)}),this.updateModel(t)},Object.defineProperty(r.prototype,"handness",{get:function(){return this.handedness},enumerable:!1,configurable:!0}),r.prototype.pulse=function(t,e,n){return n===void 0&&(n=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[n]?this.gamepadObject.hapticActuators[n].pulse(t,e):Promise.resolve(!1)},r.prototype._getChildByName=function(t,e){return t.getChildren(function(n){return n.name===e},!1)[0]},r.prototype._getImmediateChildByName=function(t,e){return t.getChildren(function(n){return n.name==e},!0)[0]},r.prototype._lerpTransform=function(t,e,n){if(t.minMesh&&t.maxMesh&&t.valueMesh&&t.minMesh.rotationQuaternion&&t.maxMesh.rotationQuaternion&&t.valueMesh.rotationQuaternion){var i=n?.5*e+.5:e;_.PT.SlerpToRef(t.minMesh.rotationQuaternion,t.maxMesh.rotationQuaternion,i,t.valueMesh.rotationQuaternion),_.Pq.LerpToRef(t.minMesh.position,t.maxMesh.position,i,t.valueMesh.position)}},r.prototype.updateModel=function(t){this._modelReady&&this._updateModel(t)},r.prototype._getGenericFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},r.prototype._getGenericParentMesh=function(t){var e=this;this.rootMesh=new xe(this.profileId+" "+this.handedness,this.scene),t.forEach(function(n){n.parent||(n.isPickable=!1,n.setParent(e.rootMesh))}),this.rootMesh.rotationQuaternion=_.PT.FromEulerAngles(0,Math.PI,0)},r}(),qd=function(r){function t(e,n,i){var o=r.call(this,e,eN[i],n,i)||this;return o.profileId=t.ProfileId,o}return(0,A.C6)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){},t.prototype._setRootMesh=function(e){var n=this;this.rootMesh=new xe(this.profileId+" "+this.handedness,this.scene),e.forEach(function(i){i.isPickable=!1,i.parent||i.setParent(n.rootMesh)}),this.rootMesh.rotationQuaternion=_.PT.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(Bo),eN={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-right",assetPath:"right.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-none",assetPath:"none.glb"}},tv=function(r){function t(e,n,i,o,a){var s=r.call(this,e,i.layouts[n.handedness||"none"],n.gamepad,n.handedness,void 0,a)||this;return s._repositoryUrl=o,s.controllerCache=a,s._buttonMeshMapping={},s._touchDots={},s.profileId=i.profileId,s}return(0,A.C6)(t,r),t.prototype.dispose=function(){var e=this;r.prototype.dispose.call(this),this.controllerCache||Object.keys(this._touchDots).forEach(function(n){e._touchDots[n].dispose()})},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:"".concat(this._repositoryUrl,"/profiles/").concat(this.profileId,"/")}},t.prototype._getModelLoadingConstraints=function(){var e=yn.IsPluginForExtensionAvailable(".glb");return e||O.V.Warn("glTF / glb loader was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var n=this;this.getComponentIds().forEach(function(i){var o=n.layout.components[i];n._buttonMeshMapping[i]={mainMesh:n._getChildByName(n.rootMesh,o.rootNodeName),states:{}},Object.keys(o.visualResponses).forEach(function(a){var s=o.visualResponses[a];if(s.valueNodeProperty==="transform")n._buttonMeshMapping[i].states[a]={valueMesh:n._getChildByName(n.rootMesh,s.valueNodeName),minMesh:n._getChildByName(n.rootMesh,s.minNodeName),maxMesh:n._getChildByName(n.rootMesh,s.maxNodeName)};else{var l=o.type===Xr.TOUCHPAD_TYPE&&o.touchPointNodeName?o.touchPointNodeName:s.valueNodeName;if(n._buttonMeshMapping[i].states[a]={valueMesh:n._getChildByName(n.rootMesh,l)},o.type===Xr.TOUCHPAD_TYPE&&!n._touchDots[a]){var c=li(a+"dot",{diameter:.0015,segments:8},n.scene);c.material=new qt(a+"mat",n.scene),c.material.diffuseColor=z.v9.Red(),c.parent=n._buttonMeshMapping[i].states[a].valueMesh||null,c.isVisible=!1,n._touchDots[a]=c}}})})},t.prototype._setRootMesh=function(e){var n;this.rootMesh=new xe(this.profileId+"-"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i<e.length;i++){var o=e[i];o.isPickable=!1,o.parent||(n=o)}n&&n.setParent(this.rootMesh),this.scene.useRightHandedSystem||this.rootMesh.rotate(Qn._0.Y,Math.PI,1)},t.prototype._updateModel=function(e){var n=this;this.disableAnimation||this.getComponentIds().forEach(function(i){var o=n.getComponent(i);if(o.hasChanges){var a=n._buttonMeshMapping[i],s=n.layout.components[i];Object.keys(s.visualResponses).forEach(function(l){var c=s.visualResponses[l],u=o.value;if(c.componentProperty==="xAxis"?u=o.axes.x:c.componentProperty==="yAxis"&&(u=o.axes.y),c.valueNodeProperty==="transform")n._lerpTransform(a.states[l],u,c.componentProperty!=="button");else{var d=a.states[l].valueMesh;d&&(d.isVisible=o.touched||o.pressed),n._touchDots[l]&&(n._touchDots[l].isVisible=o.touched||o.pressed)}})}})},t}(Bo),nv=[],Di=function(){function r(){}return r.ClearProfilesCache=function(){this._ProfilesList=null,this._ProfileLoadingPromises={}},r.DefaultFallbacks=function(){this.RegisterFallbacksForProfileId("google-daydream",["generic-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive-focus",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("magicleap-one",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("windows-mixed-reality",["generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("microsoft-mixed-reality",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-go",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("oculus-touch-v2",["oculus-touch","generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-touch",["generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-gearvr",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-odyssey",["generic-touchpad"]),this.RegisterFallbacksForProfileId("valve-index",["generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("generic-hand-select",["generic-trigger"])},r.FindFallbackWithProfileId=function(t){var e=this._Fallbacks[t]||[];return e.unshift(t),e},r.GetMotionControllerWithXRInput=function(t,e,n){var i=this,o=[];n&&o.push(n),o.push.apply(o,t.profiles||[]),o.length&&!o[0]&&o.pop(),t.gamepad&&t.gamepad.id&&t.gamepad.id===(t.gamepad.id.match(/oculus touch/gi)?t.gamepad.id:void 0)&&o.push("oculus-touch-v2");var a=o.indexOf("windows-mixed-reality");if(a!==-1&&o.splice(a,0,"microsoft-mixed-reality"),o.length||o.push("generic-trigger"),this.UseOnlineRepository){var s=this.PrioritizeOnlineRepository?this._LoadProfileFromRepository:this._LoadProfilesFromAvailableControllers,l=this.PrioritizeOnlineRepository?this._LoadProfilesFromAvailableControllers:this._LoadProfileFromRepository;return s.call(this,o,t,e).catch(function(){return l.call(i,o,t,e)})}return this._LoadProfilesFromAvailableControllers(o,t,e)},r.RegisterController=function(t,e){this._AvailableControllers[t]=e},r.RegisterFallbacksForProfileId=function(t,e){var n;this._Fallbacks[t]?(n=this._Fallbacks[t]).push.apply(n,e):this._Fallbacks[t]=e},r.UpdateProfilesList=function(){return this._ProfilesList=ze.S0.LoadFileAsync(this.BaseRepositoryUrl+"/profiles/profilesList.json",!1).then(function(t){return JSON.parse(t)}),this._ProfilesList},r.ClearControllerCache=function(){nv.forEach(function(t){t.meshes.forEach(function(e){e.dispose(!1,!0)})}),nv.length=0},r._LoadProfileFromRepository=function(t,e,n){var i=this;return Promise.resolve().then(function(){return i._ProfilesList?i._ProfilesList:i.UpdateProfilesList()}).then(function(o){for(var a=0;a<t.length;++a)if(t[a]&&o[t[a]])return t[a];throw new Error("neither controller ".concat(t[0]," nor all fallbacks were found in the repository,"))}).then(function(o){return i._ProfileLoadingPromises[o]||(i._ProfileLoadingPromises[o]=ze.S0.LoadFileAsync("".concat(i.BaseRepositoryUrl,"/profiles/").concat(o,"/profile.json"),!1).then(function(a){return JSON.parse(a)})),i._ProfileLoadingPromises[o]}).then(function(o){return new tv(n,e,o,i.BaseRepositoryUrl,i.DisableControllerCache?void 0:nv)})},r._LoadProfilesFromAvailableControllers=function(t,e,n){for(var i=0;i<t.length;++i)if(t[i])for(var o=this.FindFallbackWithProfileId(t[i]),a=0;a<o.length;++a){var s=this._AvailableControllers[o[a]];if(s)return Promise.resolve(s(e,n))}throw new Error("no controller requested was found in the available controllers list")},r._AvailableControllers={},r._Fallbacks={},r._ProfileLoadingPromises={},r.BaseRepositoryUrl="https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist",r.PrioritizeOnlineRepository=!0,r.UseOnlineRepository=!0,r.DisableControllerCache=!0,r}();Di.RegisterController(qd.ProfileId,function(r,t){return new qd(t,r.gamepad,r.handedness)}),Di.DefaultFallbacks();var G,_e,tN=0,iv=function(){function r(t,e,n){n===void 0&&(n={});var i=this;this._scene=t,this.inputSource=e,this._options=n,this._tmpVector=new _.Pq,this._disposed=!1,this.onDisposeObservable=new K.cP,this.onMeshLoadedObservable=new K.cP,this.onMotionControllerInitObservable=new K.cP,this._uniqueId="controller-".concat(tN++,"-").concat(e.targetRayMode,"-").concat(e.handedness),this.pointer=new xe("".concat(this._uniqueId,"-pointer"),t),this.pointer.rotationQuaternion=new _.PT,this.inputSource.gripSpace&&(this.grip=new xe("".concat(this._uniqueId,"-grip"),this._scene),this.grip.rotationQuaternion=new _.PT),this._tmpVector.set(0,0,this._scene.useRightHandedSystem?-1:1),this.inputSource.gamepad&&this.inputSource.targetRayMode==="tracked-pointer"&&Di.GetMotionControllerWithXRInput(e,t,this._options.forceControllerProfile).then(function(o){i.motionController=o,i.onMotionControllerInitObservable.notifyObservers(o),i._options.doNotLoadControllerMesh||i.motionController._doNotLoadControllerMesh||i.motionController.loadModel().then(function(a){var s;a&&i.motionController&&i.motionController.rootMesh&&(i._options.renderingGroupId&&(i.motionController.rootMesh.renderingGroupId=i._options.renderingGroupId,i.motionController.rootMesh.getChildMeshes(!1).forEach(function(l){return l.renderingGroupId=i._options.renderingGroupId})),i.onMeshLoadedObservable.notifyObservers(i.motionController.rootMesh),i.motionController.rootMesh.parent=i.grip||i.pointer,i.motionController.disableAnimation=!!i._options.disableMotionControllerAnimation),i._disposed&&((s=i.motionController)===null||s===void 0||s.dispose())})},function(){ze.S0.Warn("Could not find a matching motion controller for the registered input source")})}return Object.defineProperty(r.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this.grip&&this.grip.dispose(!0),this.motionController&&this.motionController.dispose(),this.pointer.dispose(!0),this.onMotionControllerInitObservable.clear(),this.onMeshLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._disposed=!0},r.prototype.getWorldPointerRayToRef=function(t,e){e===void 0&&(e=!1);var n=e&&this.grip?this.grip:this.pointer;_.Pq.TransformNormalToRef(this._tmpVector,n.getWorldMatrix(),t.direction),t.direction.normalize(),t.origin.copyFrom(n.absolutePosition),t.length=1e3},r.prototype.updateFromXRFrame=function(t,e,n,i){var o=t.getPose(this.inputSource.targetRaySpace,e);if(this._lastXRPose=o,o){var a=o.transform.position;this.pointer.position.set(a.x,a.y,a.z).scaleInPlace(i.worldScalingFactor);var s=o.transform.orientation;this.pointer.rotationQuaternion.set(s.x,s.y,s.z,s.w),this._scene.useRightHandedSystem||(this.pointer.position.z*=-1,this.pointer.rotationQuaternion.z*=-1,this.pointer.rotationQuaternion.w*=-1),this.pointer.parent=n.parent,this.pointer.scaling.setAll(i.worldScalingFactor)}if(this.inputSource.gripSpace&&this.grip){var l=t.getPose(this.inputSource.gripSpace,e);if(l){a=l.transform.position;var c=l.transform.orientation;this.grip.position.set(a.x,a.y,a.z).scaleInPlace(i.worldScalingFactor),this.grip.rotationQuaternion.set(c.x,c.y,c.z,c.w),this._scene.useRightHandedSystem||(this.grip.position.z*=-1,this.grip.rotationQuaternion.z*=-1,this.grip.rotationQuaternion.w*=-1)}this.grip.parent=n.parent,this.grip.scaling.setAll(i.worldScalingFactor)}this.motionController&&this.motionController.updateFromXRFrame(t)},r}(),rv=function(){function r(t,e,n){n===void 0&&(n={});var i=this;if(this.xrSessionManager=t,this.xrCamera=e,this._options=n,this.controllers=[],this.onControllerAddedObservable=new K.cP,this.onControllerRemovedObservable=new K.cP,this._onInputSourcesChange=function(o){i._addAndRemoveControllers(o.added,o.removed)},this._sessionEndedObserver=this.xrSessionManager.onXRSessionEnded.add(function(){i._addAndRemoveControllers([],i.controllers.map(function(o){return o.inputSource}))}),this._sessionInitObserver=this.xrSessionManager.onXRSessionInit.add(function(o){o.addEventListener("inputsourceschange",i._onInputSourcesChange)}),this._frameObserver=this.xrSessionManager.onXRFrameObservable.add(function(o){i.controllers.forEach(function(a){a.updateFromXRFrame(o,i.xrSessionManager.referenceSpace,i.xrCamera,i.xrSessionManager)})}),this._options.customControllersRepositoryURL&&(Di.BaseRepositoryUrl=this._options.customControllersRepositoryURL),Di.UseOnlineRepository=!this._options.disableOnlineControllerRepository,Di.UseOnlineRepository)try{Di.UpdateProfilesList().catch(function(){Di.UseOnlineRepository=!1})}catch{Di.UseOnlineRepository=!1}}return r.prototype._addAndRemoveControllers=function(t,e){for(var n=this,i=this.controllers.map(function(d){return d.inputSource}),o=0,a=t;o<a.length;o++){var s=a[o];if(i.indexOf(s)===-1){var l=new iv(this.xrSessionManager.scene,s,(0,A.Cl)((0,A.Cl)({},this._options.controllerOptions||{}),{forceControllerProfile:this._options.forceInputProfile,doNotLoadControllerMesh:this._options.doNotLoadControllerMeshes,disableMotionControllerAnimation:this._options.disableControllerAnimation}));this.controllers.push(l),this.onControllerAddedObservable.notifyObservers(l)}}var c=[],u=[];this.controllers.forEach(function(d){e.indexOf(d.inputSource)===-1?c.push(d):u.push(d)}),this.controllers=c,u.forEach(function(d){n.onControllerRemovedObservable.notifyObservers(d),d.dispose()})},r.prototype.dispose=function(){this.controllers.forEach(function(t){t.dispose()}),this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver),this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver),this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver),this.onControllerAddedObservable.clear(),this.onControllerRemovedObservable.clear(),Di.ClearControllerCache()},r}(),qn=function(){function r(t){this._xrSessionManager=t,this._attached=!1,this._removeOnDetach=[],this.isDisposed=!1,this.disableAutoAttach=!1,this._xrNativeFeatureName="",this.onFeatureAttachObservable=new K.cP,this.onFeatureDetachObservable=new K.cP}return Object.defineProperty(r.prototype,"xrNativeFeatureName",{get:function(){return this._xrNativeFeatureName},set:function(t){var e;!this._xrSessionManager.isNative&&t&&this._xrSessionManager.inXRSession&&((e=this._xrSessionManager.enabledFeatures)===null||e===void 0?void 0:e.indexOf(t))===-1&&O.V.Warn("The feature ".concat(t," needs to be enabled before starting the XR session. Note - It is still possible it is not supported.")),this._xrNativeFeatureName=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"attached",{get:function(){return this._attached},enumerable:!1,configurable:!0}),r.prototype.attach=function(t){var e=this;if(this.isDisposed)return!1;if(t)this.attached&&this.detach();else if(this.attached)return!1;if(this._xrSessionManager.enabledFeatures){if(!this._xrSessionManager.isNative&&this.xrNativeFeatureName&&this._xrSessionManager.enabledFeatures.indexOf(this.xrNativeFeatureName)===-1)return!1}else O.V.Warn("session.enabledFeatures is not available on this device. It is possible that this feature is not supported.");return this._attached=!0,this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable,function(n){return e._onXRFrame(n)}),this.onFeatureAttachObservable.notifyObservers(this),!0},r.prototype.detach=function(){return this._attached?(this._attached=!1,this._removeOnDetach.forEach(function(t){t.observable.remove(t.observer)}),this.onFeatureDetachObservable.notifyObservers(this),!0):(this.disableAutoAttach=!0,!1)},r.prototype.dispose=function(){this.detach(),this.isDisposed=!0,this.onFeatureAttachObservable.clear(),this.onFeatureDetachObservable.clear()},r.prototype.isCompatible=function(){return!0},r.prototype._addNewAttachObserver=function(t,e,n){this._removeOnDetach.push({observable:t,observer:t.add(e,void 0,n)})},r}(),Ja=function(r){function t(e,n){var i=r.call(this,e)||this;return i._options=n,i._attachController=function(o){var a;if(!i._controllers[o.uniqueId]){var s=(a=i._generateNewMeshPair(i._options.forceGripIfAvailable&&o.grip?o.grip:o.pointer)).laserPointer,l=a.selectionMesh;switch(i._controllers[o.uniqueId]={xrController:o,laserPointer:s,selectionMesh:l,meshUnderPointer:null,pick:null,tmpRay:new fn(new _.Pq,new _.Pq),disabledByNearInteraction:!1,id:t._IdCounter++},i._attachedController?!i._options.enablePointerSelectionOnAllControllers&&i._options.preferredHandedness&&o.inputSource.handedness===i._options.preferredHandedness&&(i._attachedController=o.uniqueId):i._options.enablePointerSelectionOnAllControllers||(i._attachedController=o.uniqueId),o.inputSource.targetRayMode){case"tracked-pointer":return i._attachTrackedPointerRayMode(o);case"gaze":return i._attachGazeMode(o);case"screen":case"transient-pointer":return i._attachScreenRayMode(o)}}},i._controllers={},i._tmpVectorForPickCompare=new _.Pq,i.disablePointerLighting=!0,i.disableSelectionMeshLighting=!0,i.displayLaserPointer=!0,i.displaySelectionMesh=!0,i.laserPointerPickedColor=new z.v9(.9,.9,.9),i.laserPointerDefaultColor=new z.v9(.7,.7,.7),i.selectionMeshDefaultColor=new z.v9(.8,.8,.8),i.selectionMeshPickedColor=new z.v9(.3,.3,1),i._identityMatrix=_.uq.Identity(),i._screenCoordinatesRef=_.Pq.Zero(),i._viewportRef=new Br.L(0,0,0,0),i._scene=i._xrSessionManager.scene,i._options.lookAndPickMode===void 0&&(i._scene.getEngine()._badDesktopOS||i._scene.getEngine()._badOS)&&(i._options.lookAndPickMode=!0),i._options.lookAndPickMode&&(i._options.enablePointerSelectionOnAllControllers=!0,i.displayLaserPointer=!1),i}return(0,A.C6)(t,r),t.prototype.attach=function(){var e,n=this;if(!r.prototype.attach.call(this))return!1;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController,!0),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(s){n._detachController(s.uniqueId)},!0),this._scene.constantlyUpdateMeshUnderPointer=!0,this._options.gazeCamera){var i=this._options.gazeCamera,o=(e=this._generateNewMeshPair(i)).laserPointer,a=e.selectionMesh;this._controllers.camera={webXRCamera:i,laserPointer:o,selectionMesh:a,meshUnderPointer:null,pick:null,tmpRay:new fn(new _.Pq,new _.Pq),disabledByNearInteraction:!1,id:t._IdCounter++},this._attachGazeMode()}return!0},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach(function(n){e._detachController(n)}),!0)},t.prototype.getMeshUnderPointer=function(e){return this._controllers[e]?this._controllers[e].meshUnderPointer:null},t.prototype.getXRControllerByPointerId=function(e){for(var n=Object.keys(this._controllers),i=0;i<n.length;++i)if(this._controllers[n[i]].id===e)return this._controllers[n[i]].xrController||null;return null},t.prototype._getPointerSelectionDisabledByPointerId=function(e){for(var n=Object.keys(this._controllers),i=0;i<n.length;++i)if(this._controllers[n[i]].id===e)return this._controllers[n[i]].disabledByNearInteraction;return!0},t.prototype._setPointerSelectionDisabledByPointerId=function(e,n){for(var i=Object.keys(this._controllers),o=0;o<i.length;++o)if(this._controllers[i[o]].id===e)return void(this._controllers[i[o]].disabledByNearInteraction=n)},t.prototype._onXRFrame=function(e){var n=this;Object.keys(this._controllers).forEach(function(i){var o,a=n._controllers[i];if(!n._options.lookAndPickMode||((o=a.xrController)===null||o===void 0?void 0:o.inputSource.targetRayMode)==="transient-pointer"){if(!n._options.enablePointerSelectionOnAllControllers&&i!==n._attachedController||a.disabledByNearInteraction)return a.selectionMesh.isVisible=!1,a.laserPointer.isVisible=!1,void(a.pick=null);var s;if(a.laserPointer.isVisible=n.displayLaserPointer,a.xrController)s=n._options.forceGripIfAvailable&&a.xrController.grip?a.xrController.grip.position:a.xrController.pointer.position,a.xrController.getWorldPointerRayToRef(a.tmpRay,n._options.forceGripIfAvailable);else{if(!a.webXRCamera)return;s=a.webXRCamera.position,a.webXRCamera.getForwardRayToRef(a.tmpRay)}if(n._options.maxPointerDistance&&(a.tmpRay.length=n._options.maxPointerDistance),!n._options.disableScenePointerVectorUpdate&&s){var l=n._xrSessionManager.scene,c=n._options.xrInput.xrCamera;c&&(c.viewport.toGlobalToRef(l.getEngine().getRenderWidth()/c.rigCameras.length,l.getEngine().getRenderHeight(),n._viewportRef),_.Pq.ProjectToRef(s,n._identityMatrix,c.getTransformationMatrix(),n._viewportRef,n._screenCoordinatesRef),typeof n._screenCoordinatesRef.x!="number"||typeof n._screenCoordinatesRef.y!="number"||isNaN(n._screenCoordinatesRef.x)||isNaN(n._screenCoordinatesRef.y)||n._screenCoordinatesRef.x===1/0||n._screenCoordinatesRef.y===1/0||(l.pointerX=n._screenCoordinatesRef.x,l.pointerY=n._screenCoordinatesRef.y,a.screenCoordinates={x:n._screenCoordinatesRef.x,y:n._screenCoordinatesRef.y}))}var u=null;n._utilityLayerScene&&(u=n._utilityLayerScene.pickWithRay(a.tmpRay,n._utilityLayerScene.pointerMovePredicate||n.raySelectionPredicate));var d=n._scene.pickWithRay(a.tmpRay,n._scene.pointerMovePredicate||n.raySelectionPredicate);u&&u.hit?d&&d.hit?u.distance<d.distance?a.pick=u:a.pick=d:a.pick=u:a.pick=d,a.pick&&a.xrController&&(a.pick.aimTransform=a.xrController.pointer,a.pick.gripTransform=a.xrController.grip||null,a.pick.originMesh=a.xrController.pointer);var h=a.pick;if(h&&h.pickedPoint&&h.hit){n._updatePointerDistance(a.laserPointer,h.distance),a.selectionMesh.position.copyFrom(h.pickedPoint),a.selectionMesh.scaling.x=Math.sqrt(h.distance),a.selectionMesh.scaling.y=Math.sqrt(h.distance),a.selectionMesh.scaling.z=Math.sqrt(h.distance);var p=n._convertNormalToDirectionOfRay(h.getNormal(!0),a.tmpRay);if(a.selectionMesh.position.copyFrom(h.pickedPoint),p){var m=_.Pq.Cross(Qn._0.Y,p),v=_.Pq.Cross(p,m);_.Pq.RotationFromAxisToRef(v,p,m,a.selectionMesh.rotation),a.selectionMesh.position.addInPlace(p.scale(.001))}a.selectionMesh.isVisible=n.displaySelectionMesh,a.meshUnderPointer=h.pickedMesh}else a.selectionMesh.isVisible=!1,n._updatePointerDistance(a.laserPointer,1),a.meshUnderPointer=null}})},Object.defineProperty(t.prototype,"_utilityLayerScene",{get:function(){return this._options.customUtilityLayerScene||Fn.DefaultUtilityLayer.utilityLayerScene},enumerable:!1,configurable:!0}),t.prototype._attachGazeMode=function(e){var n=this,i=this._controllers[e&&e.uniqueId||"camera"],o=this._options.timeToSelect||3e3,a=this._options.useUtilityLayer?this._utilityLayerScene:this._scene,s=new ri.G,l=Sr("selection",{diameter:.0525,thickness:.015,tessellation:20},a);l.isVisible=!1,l.isPickable=!1,l.parent=i.selectionMesh;var c=0,u=!1,d={pointerId:i.id,pointerType:"xr"};i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(function(){if(i.pick){if(n._augmentPointerInit(d,i.id,i.screenCoordinates),i.laserPointer.material.alpha=0,l.isVisible=!1,i.pick.hit)if(n._pickingMoved(s,i.pick))u&&(n._options.disablePointerUpOnTouchOut||n._scene.simulatePointerUp(i.pick,d)),u=!1,c=0;else if(c>o/10&&(l.isVisible=!0),(c+=n._scene.getEngine().getDeltaTime())>=o)n._scene.simulatePointerDown(i.pick,d),u=!0,n._options.disablePointerUpOnTouchOut&&n._scene.simulatePointerUp(i.pick,d),l.isVisible=!1;else{var h=1-c/o;l.scaling.set(h,h,h)}else u=!1,c=0;n._scene.simulatePointerMove(i.pick,d),s=i.pick}}),this._options.renderingGroupId!==void 0&&(l.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce(function(){i.pick&&!n._options.disablePointerUpOnTouchOut&&u&&(n._scene.simulatePointerUp(i.pick,d),i.finalPointerUpTriggered=!0),l.dispose()})},t.prototype._attachScreenRayMode=function(e){var n=this,i=this._controllers[e.uniqueId],o=!1,a={pointerId:i.id,pointerType:"xr"};i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(function(){n._augmentPointerInit(a,i.id,i.screenCoordinates),!i.pick||n._options.disablePointerUpOnTouchOut&&o||(o?n._scene.simulatePointerMove(i.pick,a):(n._scene.simulatePointerDown(i.pick,a),i.pointerDownTriggered=!0,o=!0,n._options.disablePointerUpOnTouchOut&&n._scene.simulatePointerUp(i.pick,a)))}),e.onDisposeObservable.addOnce(function(){n._augmentPointerInit(a,i.id,i.screenCoordinates),n._xrSessionManager.runInXRFrame(function(){i.pick&&!i.finalPointerUpTriggered&&o&&!n._options.disablePointerUpOnTouchOut&&(n._scene.simulatePointerUp(i.pick,a),i.finalPointerUpTriggered=!0)})})},t.prototype._attachTrackedPointerRayMode=function(e){var n=this,i=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);var o={pointerId:i.id,pointerType:"xr"};if(i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(function(){i.laserPointer.material.disableLighting=n.disablePointerLighting,i.selectionMesh.material.disableLighting=n.disableSelectionMeshLighting,i.pick&&(n._augmentPointerInit(o,i.id,i.screenCoordinates),n._scene.simulatePointerMove(i.pick,o))}),e.inputSource.gamepad){var a=function(c){n._options.overrideButtonId&&(i.selectionComponent=c.getComponent(n._options.overrideButtonId)),i.selectionComponent||(i.selectionComponent=c.getMainComponent()),i.onButtonChangedObserver=i.selectionComponent.onButtonStateChangedObservable.add(function(u){if(u.changes.pressed){var d=u.changes.pressed.current;if(i.pick)(n._options.enablePointerSelectionOnAllControllers||e.uniqueId===n._attachedController)&&(n._augmentPointerInit(o,i.id,i.screenCoordinates),d?(n._scene.simulatePointerDown(i.pick,o),i.pointerDownTriggered=!0,i.selectionMesh.material.emissiveColor=n.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=n.laserPointerPickedColor):(n._scene.simulatePointerUp(i.pick,o),i.selectionMesh.material.emissiveColor=n.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=n.laserPointerDefaultColor));else if(d&&!n._options.enablePointerSelectionOnAllControllers&&!n._options.disableSwitchOnClick){var h=n._controllers[n._attachedController];h&&h.pointerDownTriggered&&!h.finalPointerUpTriggered&&(n._augmentPointerInit(o,h.id,h.screenCoordinates),n._scene.simulatePointerUp(new ri.G,{pointerId:h.id,pointerType:"xr"}),h.finalPointerUpTriggered=!0),n._attachedController=e.uniqueId}}})};e.motionController?a(e.motionController):e.onMotionControllerInitObservable.add(a)}else{var s=function(c){n._xrSessionManager.onXRFrameObservable.addOnce(function(){n._augmentPointerInit(o,i.id,i.screenCoordinates),i.xrController&&c.inputSource===i.xrController.inputSource&&i.pick&&(n._scene.simulatePointerDown(i.pick,o),i.pointerDownTriggered=!0,i.selectionMesh.material.emissiveColor=n.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=n.laserPointerPickedColor)})},l=function(c){n._xrSessionManager.onXRFrameObservable.addOnce(function(){n._augmentPointerInit(o,i.id,i.screenCoordinates),i.xrController&&c.inputSource===i.xrController.inputSource&&i.pick&&(n._scene.simulatePointerUp(i.pick,o),i.selectionMesh.material.emissiveColor=n.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=n.laserPointerDefaultColor)})};i.eventListeners={selectend:l,selectstart:s},this._xrSessionManager.session.addEventListener("selectstart",s),this._xrSessionManager.session.addEventListener("selectend",l)}},t.prototype._convertNormalToDirectionOfRay=function(e,n){return e&&Math.acos(_.Pq.Dot(e,n.direction))<Math.PI/2&&e.scaleInPlace(-1),e},t.prototype._detachController=function(e){var n=this,i=this._controllers[e];if(i){if(i.selectionComponent&&i.onButtonChangedObserver&&i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),i.onFrameObserver&&this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),i.eventListeners&&Object.keys(i.eventListeners).forEach(function(a){var s=i.eventListeners&&i.eventListeners[a];s&&n._xrSessionManager.session.removeEventListener(a,s)}),!i.finalPointerUpTriggered&&i.pointerDownTriggered){var o={pointerId:i.id,pointerType:"xr"};this._xrSessionManager.runInXRFrame(function(){n._augmentPointerInit(o,i.id,i.screenCoordinates),n._scene.simulatePointerUp(i.pick||new ri.G,o),i.finalPointerUpTriggered=!0})}this._xrSessionManager.scene.onBeforeRenderObservable.addOnce(function(){try{if(i.selectionMesh.dispose(),i.laserPointer.dispose(),delete n._controllers[e],n._attachedController===e){var a=Object.keys(n._controllers);a.length?n._attachedController=a[0]:n._attachedController=""}}catch{ze.S0.Warn("controller already detached.")}})}},t.prototype._generateNewMeshPair=function(e){var n=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Fn.DefaultUtilityLayer.utilityLayerScene:this._scene,i=this._options.customLasterPointerMeshGenerator?this._options.customLasterPointerMeshGenerator():_i("laserPointer",{height:1,diameterTop:2e-4,diameterBottom:.004,tessellation:20,subdivisions:1},n);i.parent=e;var o=new qt("laserPointerMat",n);o.emissiveColor=this.laserPointerDefaultColor,o.alpha=.7,i.material=o,i.rotation.x=Math.PI/2,this._updatePointerDistance(i,1),i.isPickable=!1,i.isVisible=!1;var a=this._options.customSelectionMeshGenerator?this._options.customSelectionMeshGenerator():Sr("gazeTracker",{diameter:.0105,thickness:.0075,tessellation:20},n);a.bakeCurrentTransformIntoVertices(),a.isPickable=!1,a.isVisible=!1;var s=new qt("targetMat",n);return s.specularColor=z.v9.Black(),s.emissiveColor=this.selectionMeshDefaultColor,s.backFaceCulling=!1,a.material=s,this._options.renderingGroupId!==void 0&&(i.renderingGroupId=this._options.renderingGroupId,a.renderingGroupId=this._options.renderingGroupId),{laserPointer:i,selectionMesh:a}},t.prototype._pickingMoved=function(e,n){var i;if(!e.hit||!n.hit||!(e.pickedMesh&&e.pickedPoint&&n.pickedMesh&&n.pickedPoint)||e.pickedMesh!==n.pickedMesh)return!0;(i=e.pickedPoint)===null||i===void 0||i.subtractToRef(n.pickedPoint,this._tmpVectorForPickCompare),this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x),Math.abs(this._tmpVectorForPickCompare.y),Math.abs(this._tmpVectorForPickCompare.z));var o=.01*(this._options.gazeModePointerMovedFactor||1)*n.distance;return this._tmpVectorForPickCompare.length()>o},t.prototype._updatePointerDistance=function(e,n){n===void 0&&(n=100),e.scaling.y=n,this._scene.useRightHandedSystem&&(n*=-1),e.position.z=n/2+.05},t.prototype._augmentPointerInit=function(e,n,i){e.pointerId=n,e.pointerType="xr",i&&(e.screenX=i.x,e.screenY=i.y)},Object.defineProperty(t.prototype,"lasterPointerDefaultColor",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._IdCounter=200,t.Name=vn.POINTER_SELECTION,t.Version=1,t}(qn);kn.AddWebXRFeature(Ja.Name,function(r,t){return function(){return new Ja(r,t)}},Ja.Version,!0),function(r){r[r.Float=1]="Float",r[r.Int=2]="Int",r[r.Vector2=4]="Vector2",r[r.Vector3=8]="Vector3",r[r.Vector4=16]="Vector4",r[r.Color3=32]="Color3",r[r.Color4=64]="Color4",r[r.Matrix=128]="Matrix",r[r.Object=256]="Object",r[r.AutoDetect=1024]="AutoDetect",r[r.BasedOnInput=2048]="BasedOnInput",r[r.All=4095]="All"}(G||(G={})),function(r){r[r.Vertex=1]="Vertex",r[r.Fragment=2]="Fragment",r[r.Neutral=4]="Neutral",r[r.VertexAndFragment=3]="VertexAndFragment"}(_e||(_e={}));var Kd,Zd,Nx=function(){function r(){this.supportUniformBuffers=!1,this.attributes=[],this.uniforms=[],this.constants=[],this.samplers=[],this.functions={},this.extensions={},this.prePassOutput={},this.counters={},this._attributeDeclaration="",this._uniformDeclaration="",this._constantDeclaration="",this._samplerDeclaration="",this._varyingTransfer="",this._injectAtEnd="",this._repeatableContentAnchorIndex=0,this._builtCompilationString="",this.compilationString=""}return Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this.sharedData.nodeMaterial.shaderLanguage},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fSuffix",{get:function(){return this.shaderLanguage===1?"f":""},enumerable:!1,configurable:!0}),r.prototype.finalize=function(t){var e=t.sharedData.emitComments,n=this.target===_e.Fragment;this.shaderLanguage===1?this.compilationString=n?`
|
||
`.concat(e?`//Entry point
|
||
`:"",`@fragment
|
||
fn main(input: FragmentInputs) -> FragmentOutputs {
|
||
`).concat(this.compilationString):`
|
||
`.concat(e?`//Entry point
|
||
`:"",`@vertex
|
||
fn main(input: VertexInputs) -> FragmentInputs{
|
||
`).concat(this.compilationString):this.compilationString=`
|
||
`.concat(e?`//Entry point
|
||
`:"",`void main(void) {
|
||
`).concat(this.compilationString),this._constantDeclaration&&(this.compilationString=`
|
||
`.concat(e?`//Constants
|
||
`:"").concat(this._constantDeclaration,`
|
||
`).concat(this.compilationString));var i="";for(var o in this.functions)i+=this.functions[o]+`
|
||
`;if(this.compilationString=`
|
||
`.concat(i,`
|
||
`).concat(this.compilationString),!n&&this._varyingTransfer&&(this.compilationString="".concat(this.compilationString,`
|
||
`).concat(this._varyingTransfer)),this._injectAtEnd&&(this.compilationString="".concat(this.compilationString,`
|
||
`).concat(this._injectAtEnd)),this.compilationString="".concat(this.compilationString,`
|
||
}`),this.sharedData.varyingDeclaration&&(this.compilationString=`
|
||
`.concat(e?`//Varyings
|
||
`:"").concat(this.sharedData.varyingDeclaration,`
|
||
`).concat(this.compilationString)),this._samplerDeclaration&&(this.compilationString=`
|
||
`.concat(e?`//Samplers
|
||
`:"").concat(this._samplerDeclaration,`
|
||
`).concat(this.compilationString)),this._uniformDeclaration&&(this.compilationString=`
|
||
`.concat(e?`//Uniforms
|
||
`:"").concat(this._uniformDeclaration,`
|
||
`).concat(this.compilationString)),this._attributeDeclaration&&!n&&(this.compilationString=`
|
||
`.concat(e?`//Attributes
|
||
`:"").concat(this._attributeDeclaration,`
|
||
`).concat(this.compilationString)),this.shaderLanguage!==1)for(var a in this.compilationString=`precision highp float;
|
||
`+this.compilationString,this.compilationString=`#if defined(WEBGL2) || defined(WEBGPU)
|
||
precision highp sampler2DArray;
|
||
#endif
|
||
`+this.compilationString,n&&(this.compilationString=`#if defined(PREPASS)\r
|
||
#extension GL_EXT_draw_buffers : require\r
|
||
layout(location = 0) out highp vec4 glFragData[SCENE_MRT_COUNT];\r
|
||
highp vec4 gl_FragColor;\r
|
||
#endif\r
|
||
`+this.compilationString),this.extensions){var s=this.extensions[a];this.compilationString=`
|
||
`.concat(s,`
|
||
`).concat(this.compilationString)}this._builtCompilationString=this.compilationString},Object.defineProperty(r.prototype,"_repeatableContentAnchor",{get:function(){return"###___ANCHOR".concat(this._repeatableContentAnchorIndex++,"___###")},enumerable:!1,configurable:!0}),r.prototype._getFreeVariableName=function(t){return t=t.replace(/[^a-zA-Z_]+/g,""),this.sharedData.variableNames[t]===void 0?(this.sharedData.variableNames[t]=0,t==="output"||t==="texture"?t+this.sharedData.variableNames[t]:t):(this.sharedData.variableNames[t]++,t+this.sharedData.variableNames[t])},r.prototype._getFreeDefineName=function(t){return this.sharedData.defineNames[t]===void 0?this.sharedData.defineNames[t]=0:this.sharedData.defineNames[t]++,t+this.sharedData.defineNames[t]},r.prototype._excludeVariableName=function(t){this.sharedData.variableNames[t]=0},r.prototype._emit2DSampler=function(t,e,n){e===void 0&&(e=""),n===void 0&&(n=!1),(this.samplers.indexOf(t)<0||n)&&(e&&(this._samplerDeclaration+="#if ".concat(e,`
|
||
`)),this.shaderLanguage===1?(this._samplerDeclaration+="var ".concat(t+P.Y.AUTOSAMPLERSUFFIX,`: sampler;
|
||
`),this._samplerDeclaration+="var ".concat(t,`: texture_2d<f32>;
|
||
`)):this._samplerDeclaration+="uniform sampler2D ".concat(t,`;
|
||
`),e&&(this._samplerDeclaration+=`#endif
|
||
`),n||this.samplers.push(t))},r.prototype._emitCubeSampler=function(t,e,n){e===void 0&&(e=""),n===void 0&&(n=!1),(this.samplers.indexOf(t)<0||n)&&(e&&(this._samplerDeclaration+="#if ".concat(e,`
|
||
`)),this.shaderLanguage===1?(this._samplerDeclaration+="var ".concat(t+P.Y.AUTOSAMPLERSUFFIX,`: sampler;
|
||
`),this._samplerDeclaration+="var ".concat(t,`: texture_cube<f32>;
|
||
`)):this._samplerDeclaration+="uniform samplerCube ".concat(t,`;
|
||
`),e&&(this._samplerDeclaration+=`#endif
|
||
`),n||this.samplers.push(t))},r.prototype._emit2DArraySampler=function(t){this.samplers.indexOf(t)<0&&(this._samplerDeclaration+="uniform sampler2DArray ".concat(t,`;
|
||
`),this.samplers.push(t))},r.prototype._getGLType=function(t){switch(t){case G.Float:return"float";case G.Int:return"int";case G.Vector2:return"vec2";case G.Color3:case G.Vector3:return"vec3";case G.Color4:case G.Vector4:return"vec4";case G.Matrix:return"mat4"}return""},r.prototype._getShaderType=function(t){var e=this.shaderLanguage===1;switch(t){case G.Float:return e?"f32":"float";case G.Int:return e?"i32":"int";case G.Vector2:return e?"vec2f":"vec2";case G.Color3:case G.Vector3:return e?"vec3f":"vec3";case G.Color4:case G.Vector4:return e?"vec4f":"vec4";case G.Matrix:return e?"mat4x4f":"mat4"}return""},r.prototype._emitExtension=function(t,e,n){n===void 0&&(n=""),this.extensions[t]||(n&&(e="#if ".concat(n,`
|
||
`).concat(e,`
|
||
#endif`)),this.extensions[t]=e)},r.prototype._emitFunction=function(t,e,n){this.functions[t]||(this.sharedData.emitComments&&(e=n+`
|
||
`+e),this.functions[t]=e)},r.prototype._emitCodeFromInclude=function(t,e,n){var i=Gt.l.GetIncludesShadersStore(this.shaderLanguage);if(n&&n.repeatKey)return"#include<".concat(t,">").concat(n.substitutionVars?"("+n.substitutionVars+")":"","[0..").concat(n.repeatKey,`]
|
||
`);var o=i[t]+`
|
||
`;if(this.sharedData.emitComments&&(o=e+`
|
||
`+o),!n)return o;if(n.replaceStrings)for(var a=0;a<n.replaceStrings.length;a++){var s=n.replaceStrings[a];o=o.replace(s.search,s.replace)}return o},r.prototype._emitFunctionFromInclude=function(t,e,n,i){i===void 0&&(i="");var o=t+i;if(!this.functions[o]){var a=Gt.l.GetIncludesShadersStore(this.shaderLanguage);if(!n||!(n.removeAttributes||n.removeUniforms||n.removeVaryings||n.removeIfDef||n.replaceStrings))return n&&n.repeatKey?this.functions[o]="#include<".concat(t,">").concat(n.substitutionVars?"("+n.substitutionVars+")":"","[0..").concat(n.repeatKey,`]
|
||
`):this.functions[o]="#include<".concat(t,">").concat(n?.substitutionVars?"("+n?.substitutionVars+")":"",`
|
||
`),void(this.sharedData.emitComments&&(this.functions[o]=e+`
|
||
`+this.functions[o]));if(this.functions[o]=a[t],this.sharedData.emitComments&&(this.functions[o]=e+`
|
||
`+this.functions[o]),n.removeIfDef&&(this.functions[o]=this.functions[o].replace(/^\s*?#ifdef.+$/gm,""),this.functions[o]=this.functions[o].replace(/^\s*?#endif.*$/gm,""),this.functions[o]=this.functions[o].replace(/^\s*?#else.*$/gm,""),this.functions[o]=this.functions[o].replace(/^\s*?#elif.*$/gm,"")),n.removeAttributes&&(this.functions[o]=this.functions[o].replace(/\s*?attribute .+?;/g,`
|
||
`)),n.removeUniforms&&(this.functions[o]=this.functions[o].replace(/\s*?uniform .*?;/g,`
|
||
`)),n.removeVaryings&&(this.functions[o]=this.functions[o].replace(/\s*?(varying|in) .+?;/g,`
|
||
`)),n.replaceStrings)for(var s=0;s<n.replaceStrings.length;s++){var l=n.replaceStrings[s];this.functions[o]=this.functions[o].replace(l.search,l.replace)}}},r.prototype._registerTempVariable=function(t){return this.sharedData.temps.indexOf(t)===-1&&(this.sharedData.temps.push(t),!0)},r.prototype._emitVaryingFromString=function(t,e,n,i){if(n===void 0&&(n=""),i===void 0&&(i=!1),this.sharedData.varyings.indexOf(t)!==-1)return!1;this.sharedData.varyings.push(t),n&&(n.startsWith("defined(")?this.sharedData.varyingDeclaration+="#if ".concat(n,`
|
||
`):this.sharedData.varyingDeclaration+="".concat(i?"#ifndef":"#ifdef"," ").concat(n,`
|
||
`));var o=this._getShaderType(e);return this.shaderLanguage===1?this.sharedData.varyingDeclaration+="varying ".concat(t,": ").concat(o,`;
|
||
`):this.sharedData.varyingDeclaration+="varying ".concat(o," ").concat(t,`;
|
||
`),n&&(this.sharedData.varyingDeclaration+=`#endif
|
||
`),!0},r.prototype._getVaryingName=function(t){return this.shaderLanguage===1?(this.target!==_e.Fragment?"vertexOutputs.":"fragmentInputs.")+t:t},r.prototype._emitUniformFromString=function(t,e,n,i){if(n===void 0&&(n=""),i===void 0&&(i=!1),this.uniforms.indexOf(t)===-1){this.uniforms.push(t),n&&(n.startsWith("defined(")?this._uniformDeclaration+="#if ".concat(n,`
|
||
`):this._uniformDeclaration+="".concat(i?"#ifndef":"#ifdef"," ").concat(n,`
|
||
`));var o=this._getShaderType(e);this.shaderLanguage===1?this._uniformDeclaration+="uniform ".concat(t,": ").concat(o,`;
|
||
`):this._uniformDeclaration+="uniform ".concat(o," ").concat(t,`;
|
||
`),n&&(this._uniformDeclaration+=`#endif
|
||
`)}},r.prototype._generateTernary=function(t,e,n){return this.shaderLanguage===1?"select(".concat(e,", ").concat(t,", ").concat(n,")"):"(".concat(n,") ? ").concat(t," : ").concat(e)},r.prototype._emitFloat=function(t){return t.toString()===t.toFixed(0)?"".concat(t,".0"):t.toString()},r.prototype._declareOutput=function(t,e){return this._declareLocalVar(t.associatedVariableName,t.type,e)},r.prototype._declareLocalVar=function(t,e,n){return this.shaderLanguage===1?"".concat(n?"const":"var"," ").concat(t,": ").concat(this._getShaderType(e)):"".concat(this._getShaderType(e)," ").concat(t)},r.prototype._samplerCubeFunc=function(){return this.shaderLanguage===1?"textureSample":"textureCube"},r.prototype._samplerFunc=function(){return this.shaderLanguage===1?"textureSample":"texture2D"},r.prototype._samplerLODFunc=function(){return this.shaderLanguage===1?"textureSampleLevel":"texture2DLodEXT"},r.prototype._toLinearSpace=function(t){return this.shaderLanguage!==1||t.type!==G.Color3&&t.type!==G.Vector3?"toLinearSpace(".concat(t.associatedVariableName,")"):"toLinearSpaceVec3(".concat(t.associatedVariableName,")")},r.prototype._generateTextureSample=function(t,e){return this.shaderLanguage===1?"".concat(this._samplerFunc(),"(").concat(e,",").concat(e+P.Y.AUTOSAMPLERSUFFIX,", ").concat(t,")"):"".concat(this._samplerFunc(),"(").concat(e,", ").concat(t,")")},r.prototype._generateTextureSampleLOD=function(t,e,n){return this.shaderLanguage===1?"".concat(this._samplerLODFunc(),"(").concat(e,",").concat(e+P.Y.AUTOSAMPLERSUFFIX,", ").concat(t,", ").concat(n,")"):"".concat(this._samplerLODFunc(),"(").concat(e,", ").concat(t,", ").concat(n,")")},r.prototype._generateTextureSampleCube=function(t,e){return this.shaderLanguage===1?"".concat(this._samplerCubeFunc(),"(").concat(e,",").concat(e+P.Y.AUTOSAMPLERSUFFIX,", ").concat(t,")"):"".concat(this._samplerCubeFunc(),"(").concat(e,", ").concat(t,")")},r.prototype._generateTextureSampleCubeLOD=function(t,e,n){return this.shaderLanguage===1?"".concat(this._samplerCubeFunc(),"(").concat(e,",").concat(e+P.Y.AUTOSAMPLERSUFFIX,", ").concat(t,", ").concat(n,")"):"".concat(this._samplerCubeFunc(),"(").concat(e,", ").concat(t,", ").concat(n,")")},r.prototype._convertVariableDeclarationToWGSL=function(t,e,n){return n.replace(new RegExp("(".concat(t,")\\s+(\\w+)"),"g"),"var $2: ".concat(e))},r.prototype._convertVariableConstructorsToWGSL=function(t,e,n){return n.replace(new RegExp("(".concat(t,")\\("),"g")," ".concat(e,"("))},r.prototype._convertOutParametersToWGSL=function(t){return t.replace(new RegExp("out\\s+var\\s+(\\w+)\\s*:\\s*(\\w+)","g"),"$1: ptr<function, $2>")},r.prototype._convertTernaryOperandsToWGSL=function(t){return t.replace(new RegExp("\\[(.*?)\\?(.*?):(.*)\\]","g"),function(e,n,i,o){return"select(".concat(o,", ").concat(i,", ").concat(n,")")})},r.prototype._convertModOperatorsToWGSL=function(t){return t.replace(new RegExp("mod\\((.+?),\\s*(.+?)\\)","g"),function(e,n,i){return"((".concat(n,")%(").concat(i,"))")})},r.prototype._convertConstToWGSL=function(t){return t.replace(new RegExp("const var","g"),"const")},r.prototype._convertInnerFunctionsToWGSL=function(t){return t.replace(new RegExp("inversesqrt","g"),"inverseSqrt")},r.prototype._convertFunctionsToWGSL=function(t){for(var e,n=/var\s+(\w+)\s*:\s*(\w+)\((.*)\)/g;(e=n.exec(t))!==null;){var i=e[1],o=e[2],a=e[3].replace(/var\s/g,"");t=t.replace(e[0],"fn ".concat(i,"(").concat(a,") -> ").concat(o))}return t},r.prototype._babylonSLtoWGSL=function(t){return t=this._convertVariableDeclarationToWGSL("void","voidnull",t),t=this._convertVariableDeclarationToWGSL("bool","bool",t),t=this._convertVariableDeclarationToWGSL("int","i32",t),t=this._convertVariableDeclarationToWGSL("uint","u32",t),t=this._convertVariableDeclarationToWGSL("float","f32",t),t=this._convertVariableDeclarationToWGSL("vec2","vec2f",t),t=this._convertVariableDeclarationToWGSL("vec3","vec3f",t),t=this._convertVariableDeclarationToWGSL("vec4","vec4f",t),t=this._convertVariableDeclarationToWGSL("mat2","mat2x2f",t),t=this._convertVariableDeclarationToWGSL("mat3","mat3x3f",t),t=this._convertVariableDeclarationToWGSL("mat4","mat4x4f",t),t=this._convertVariableConstructorsToWGSL("float","f32",t),t=this._convertVariableConstructorsToWGSL("vec2","vec2f",t),t=this._convertVariableConstructorsToWGSL("vec3","vec3f",t),t=this._convertVariableConstructorsToWGSL("vec4","vec4f",t),t=this._convertVariableConstructorsToWGSL("mat2","mat2x2f",t),t=this._convertVariableConstructorsToWGSL("mat3","mat3x3f",t),t=this._convertVariableConstructorsToWGSL("mat4","mat4x4f",t),t=this._convertTernaryOperandsToWGSL(t),t=this._convertModOperatorsToWGSL(t),t=this._convertConstToWGSL(t),t=this._convertInnerFunctionsToWGSL(t),t=(t=this._convertOutParametersToWGSL(t)).replace(/\[\*\]/g,"*"),(t=(t=(t=this._convertFunctionsToWGSL(t)).replace(/\s->\svoidnull/g,"")).replace(/dFdx/g,"dpdx")).replace(/dFdy/g,"dpdy")},r.prototype._convertTernaryOperandsToGLSL=function(t){return t.replace(new RegExp("\\[(.+?)\\?(.+?):(.+)\\]","g"),function(e,n,i,o){return"".concat(n," ? ").concat(i," : ").concat(o)})},r.prototype._babylonSLtoGLSL=function(t){return t=t.replace(/\[\*\]/g,""),this._convertTernaryOperandsToGLSL(t)},r}(),nN=function(){function r(){this.temps=[],this.varyings=[],this.varyingDeclaration="",this.inputBlocks=[],this.textureBlocks=[],this.bindableBlocks=[],this.forcedBindableBlocks=[],this.blocksWithFallbacks=[],this.blocksWithDefines=[],this.repeatableContentBlocks=[],this.dynamicUniformBlocks=[],this.blockingBlocks=[],this.animatedInputs=[],this.variableNames={},this.defineNames={},this.hints={needWorldViewMatrix:!1,needWorldViewProjectionMatrix:!1,needAlphaBlending:!1,needAlphaTesting:!1},this.checks={emitVertex:!1,emitFragment:!1,notConnectedNonOptionalInputs:new Array},this.allowEmptyVertexProgram=!1,this.variableNames.position=0,this.variableNames.normal=0,this.variableNames.tangent=0,this.variableNames.uv=0,this.variableNames.uv2=0,this.variableNames.uv3=0,this.variableNames.uv4=0,this.variableNames.uv5=0,this.variableNames.uv6=0,this.variableNames.color=0,this.variableNames.matricesIndices=0,this.variableNames.matricesWeights=0,this.variableNames.matricesIndicesExtra=0,this.variableNames.matricesWeightsExtra=0,this.variableNames.diffuseBase=0,this.variableNames.specularBase=0,this.variableNames.worldPos=0,this.variableNames.shadow=0,this.variableNames.view=0,this.variableNames.vTBN=0,this.defineNames.MAINUV0=0,this.defineNames.MAINUV1=0,this.defineNames.MAINUV2=0,this.defineNames.MAINUV3=0,this.defineNames.MAINUV4=0,this.defineNames.MAINUV5=0,this.defineNames.MAINUV6=0,this.defineNames.MAINUV7=0}return r.prototype.emitErrors=function(t){t===void 0&&(t=null);var e="";this.checks.emitVertex||this.allowEmptyVertexProgram||(e+=`NodeMaterial does not have a vertex output. You need to at least add a block that generates a position value.
|
||
`),this.checks.emitFragment||(e+=`NodeMaterial does not have a fragment output. You need to at least add a block that generates a color value.
|
||
`);for(var n=0,i=this.checks.notConnectedNonOptionalInputs;n<i.length;n++){var o=i[n];e+="input ".concat(o.name," from block ").concat(o.ownerBlock.name,"[").concat(o.ownerBlock.getClassName(),`] is not connected and is not optional.
|
||
`)}return!e||(t&&t.notifyObservers(e),O.V.Error(`Build of NodeMaterial failed:
|
||
`+e),!1)},r}();(function(r){r[r.Compatible=0]="Compatible",r[r.TypeIncompatible=1]="TypeIncompatible",r[r.TargetIncompatible=2]="TargetIncompatible",r[r.HierarchyIssue=3]="HierarchyIssue"})(Kd||(Kd={})),function(r){r[r.Input=0]="Input",r[r.Output=1]="Output"}(Zd||(Zd={}));var pl=function(){function r(t,e,n){this._connectedPointBackingField=null,this._endpoints=new Array,this._typeConnectionSourceBackingField=null,this._defaultConnectionPointTypeBackingField=null,this._linkedConnectionSourceBackingField=null,this._acceptedConnectionPointType=null,this._type=G.Float,this._enforceAssociatedVariableName=!1,this.needDualDirectionValidation=!1,this.acceptedConnectionPointTypes=[],this.excludedConnectionPointTypes=[],this.onConnectionObservable=new K.cP,this.onDisconnectionObservable=new K.cP,this.onTypeChangedObservable=new K.cP,this._isTypeChangeObservableNotifying=!1,this.isExposedOnFrame=!1,this.exposedPortPosition=-1,this._prioritizeVertex=!1,this._target=_e.VertexAndFragment,this._ownerBlock=e,this.name=t,this._direction=n}return r.AreEquivalentTypes=function(t,e){switch(t){case G.Vector3:if(e===G.Color3)return!0;break;case G.Vector4:if(e===G.Color4)return!0;break;case G.Color3:if(e===G.Vector3)return!0;break;case G.Color4:if(e===G.Vector4)return!0}return!1},Object.defineProperty(r.prototype,"_connectedPoint",{get:function(){return this._connectedPointBackingField},set:function(t){var e,n=this;this._connectedPointBackingField!==t&&((e=this._connectedPointTypeChangedObserver)===null||e===void 0||e.remove(),this._updateTypeDependentState(function(){return n._connectedPointBackingField=t}),this._connectedPointBackingField&&(this._connectedPointTypeChangedObserver=this._connectedPointBackingField.onTypeChangedObservable.add(function(){n._notifyTypeChanged()})))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_typeConnectionSource",{get:function(){return this._typeConnectionSourceBackingField},set:function(t){var e,n=this;this._typeConnectionSourceBackingField!==t&&((e=this._typeConnectionSourceTypeChangedObserver)===null||e===void 0||e.remove(),this._updateTypeDependentState(function(){return n._typeConnectionSourceBackingField=t}),this._typeConnectionSourceBackingField&&(this._typeConnectionSourceTypeChangedObserver=this._typeConnectionSourceBackingField.onTypeChangedObservable.add(function(){n._notifyTypeChanged()})))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_defaultConnectionPointType",{get:function(){return this._defaultConnectionPointTypeBackingField},set:function(t){var e=this;this._updateTypeDependentState(function(){return e._defaultConnectionPointTypeBackingField=t})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_linkedConnectionSource",{get:function(){return this._linkedConnectionSourceBackingField},set:function(t){var e,n=this;this._linkedConnectionSourceBackingField!==t&&((e=this._linkedConnectionSourceTypeChangedObserver)===null||e===void 0||e.remove(),this._updateTypeDependentState(function(){return n._linkedConnectionSourceBackingField=t}),this._linkedConnectionSourceBackingField&&(this._linkedConnectionSourceTypeChangedObserver=this._linkedConnectionSourceBackingField.onTypeChangedObservable.add(function(){n._notifyTypeChanged()})))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"declarationVariableName",{get:function(){return this._ownerBlock.isInput?this._ownerBlock.declarationVariableName:this._enforceAssociatedVariableName&&this._associatedVariableName||!this._connectedPoint?this._associatedVariableName:this._connectedPoint.declarationVariableName},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"associatedVariableName",{get:function(){return this._ownerBlock.isInput?this._ownerBlock.associatedVariableName:this._enforceAssociatedVariableName&&this._associatedVariableName||!this._connectedPoint?this._associatedVariableName:this._connectedPoint.associatedVariableName},set:function(t){this._associatedVariableName=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"innerType",{get:function(){return this._linkedConnectionSource&&this._linkedConnectionSource.isConnected?this.type:this._type},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){if(this._type===G.AutoDetect){if(this._ownerBlock.isInput)return this._ownerBlock.type;if(this._connectedPoint)return this._connectedPoint.type;if(this._linkedConnectionSource&&this._linkedConnectionSource.isConnected)return this._linkedConnectionSource.type}if(this._type===G.BasedOnInput){if(this._typeConnectionSource)return!this._typeConnectionSource.isConnected&&this._defaultConnectionPointType?this._defaultConnectionPointType:this._typeConnectionSource.type;if(this._defaultConnectionPointType)return this._defaultConnectionPointType}return this._type},set:function(t){var e=this;this._updateTypeDependentState(function(){return e._type=t})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"target",{get:function(){return this._prioritizeVertex&&this._ownerBlock?this._target!==_e.VertexAndFragment?this._target:this._ownerBlock.target===_e.Fragment?_e.Fragment:_e.Vertex:this._target},set:function(t){this._target=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnected",{get:function(){return this.connectedPoint!==null||this.hasEndpoints},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnectedToInputBlock",{get:function(){return this.connectedPoint!==null&&this.connectedPoint.ownerBlock.isInput},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectInputBlock",{get:function(){return this.isConnectedToInputBlock?this.connectedPoint.ownerBlock:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectedPoint",{get:function(){return this._connectedPoint},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ownerBlock",{get:function(){return this._ownerBlock},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sourceBlock",{get:function(){return this._connectedPoint?this._connectedPoint.ownerBlock:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectedBlocks",{get:function(){return this._endpoints.length===0?[]:this._endpoints.map(function(t){return t.ownerBlock})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"endpoints",{get:function(){return this._endpoints},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasEndpoints",{get:function(){return this._endpoints&&this._endpoints.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isDirectlyConnectedToVertexOutput",{get:function(){if(!this.hasEndpoints)return!1;for(var t=0,e=this._endpoints;t<e.length;t++){var n=e[t];if(n.ownerBlock.target===_e.Vertex||(n.ownerBlock.target===_e.Neutral||n.ownerBlock.target===_e.VertexAndFragment)&&n.ownerBlock.outputs.some(function(i){return i.isDirectlyConnectedToVertexOutput}))return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnectedInVertexShader",{get:function(){if(this.target===_e.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var t=0,e=this._endpoints;t<e.length;t++){var n=e[t];if(n.ownerBlock.target===_e.Vertex||n.target===_e.Vertex||(n.ownerBlock.target===_e.Neutral||n.ownerBlock.target===_e.VertexAndFragment)&&n.ownerBlock.outputs.some(function(i){return i.isConnectedInVertexShader}))return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnectedInFragmentShader",{get:function(){if(this.target===_e.Fragment)return!0;if(!this.hasEndpoints)return!1;for(var t=0,e=this._endpoints;t<e.length;t++){var n=e[t];if(n.ownerBlock.target===_e.Fragment||(n.ownerBlock.target===_e.Neutral||n.ownerBlock.target===_e.VertexAndFragment)&&n.ownerBlock.isConnectedInFragmentShader())return!0}return!1},enumerable:!1,configurable:!0}),r.prototype.createCustomInputBlock=function(){return null},r.prototype.getClassName=function(){return"NodeMaterialConnectionPoint"},r.prototype.canConnectTo=function(t){return this.checkCompatibilityState(t)===0},r.prototype.checkCompatibilityState=function(t){var e=this._ownerBlock,n=t.ownerBlock;if(e.target===_e.Fragment){if(n.target===_e.Vertex)return 2;for(var i=0,o=n.outputs;i<o.length;i++){var a=o[i];if(a.ownerBlock.target!=_e.Neutral&&a.isConnectedInVertexShader)return 2}}if(this.type!==t.type&&t.innerType!==G.AutoDetect)return r.AreEquivalentTypes(this.type,t.type)||t.acceptedConnectionPointTypes&&t.acceptedConnectionPointTypes.indexOf(this.type)!==-1||t._acceptedConnectionPointType&&r.AreEquivalentTypes(t._acceptedConnectionPointType.type,this.type)?0:1;if(t.excludedConnectionPointTypes&&t.excludedConnectionPointTypes.indexOf(this.type)!==-1)return 1;var s=n,l=e;return this.direction===0&&(s=e,l=n),s.isAnAncestorOf(l)?3:0},r.prototype.connectTo=function(t,e){if(e===void 0&&(e=!1),!e&&!this.canConnectTo(t))throw"Cannot connect these two connectors.";return this._endpoints.push(t),t._connectedPoint=this,this._enforceAssociatedVariableName=!1,this.onConnectionObservable.notifyObservers(t),t.onConnectionObservable.notifyObservers(this),this},r.prototype.disconnectFrom=function(t){var e=this._endpoints.indexOf(t);return e===-1||(this._endpoints.splice(e,1),t._connectedPoint=null,this._enforceAssociatedVariableName=!1,t._enforceAssociatedVariableName=!1,this.onDisconnectionObservable.notifyObservers(t),t.onDisconnectionObservable.notifyObservers(this)),this},r.prototype.addExcludedConnectionPointFromAllowedTypes=function(t){for(var e=1;e<G.All;)t&e||this.excludedConnectionPointTypes.push(e),e<<=1},r.prototype.serialize=function(t){t===void 0&&(t=!0);var e={};return e.name=this.name,this.displayName&&(e.displayName=this.displayName),t&&this.connectedPoint&&(e.inputName=this.name,e.targetBlockId=this.connectedPoint.ownerBlock.uniqueId,e.targetConnectionName=this.connectedPoint.name,e.isExposedOnFrame=!0,e.exposedPortPosition=this.exposedPortPosition),(this.isExposedOnFrame||this.exposedPortPosition>=0)&&(e.isExposedOnFrame=!0,e.exposedPortPosition=this.exposedPortPosition),e},r.prototype.dispose=function(){this.onConnectionObservable.clear(),this.onDisconnectionObservable.clear(),this.onTypeChangedObservable.clear(),this._connectedPoint=null,this._typeConnectionSource=null,this._linkedConnectionSource=null},r.prototype._updateTypeDependentState=function(t){var e=this.type;t(),this.type!==e&&this._notifyTypeChanged()},r.prototype._notifyTypeChanged=function(){this._isTypeChangeObservableNotifying||(this._isTypeChangeObservableNotifying=!0,this.onTypeChangedObservable.notifyObservers(this.type),this._isTypeChangeObservableNotifying=!1)},r}(),Lx=L(62273),ut=function(){function r(t,e,n){e===void 0&&(e=_e.Vertex),n===void 0&&(n=!1),this._isFinalMerger=!1,this._isInput=!1,this._isTeleportOut=!1,this._isTeleportIn=!1,this._name="",this._isUnique=!1,this._codeIsReady=!0,this.onCodeIsReadyObservable=new K.cP,this.inputsAreExclusive=!1,this._codeVariableName="",this._inputs=new Array,this._outputs=new Array,this.comments="",this.visibleInInspector=!1,this.visibleOnFrame=!1,this._target=e,this._originalTargetIsNeutral=e===_e.Neutral,this._isFinalMerger=n,this._isInput=this.getClassName()==="InputBlock",this._isTeleportOut=this.getClassName()==="NodeMaterialTeleportOutBlock",this._isTeleportIn=this.getClassName()==="NodeMaterialTeleportInBlock",this._name=t,this.uniqueId=Lx.K.UniqueId}return Object.defineProperty(r.prototype,"name",{get:function(){return this._name},set:function(t){this.validateBlockName(t)&&(this._name=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"codeIsReady",{get:function(){return this._codeIsReady},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isUnique",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isFinalMerger",{get:function(){return this._isFinalMerger},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isTeleportOut",{get:function(){return this._isTeleportOut},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isTeleportIn",{get:function(){return this._isTeleportIn},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"buildId",{get:function(){return this._buildId},set:function(t){this._buildId=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"target",{get:function(){return this._target},set:function(t){this._target&t||(this._target=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"inputs",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"outputs",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),r.prototype.getInputByName=function(t){var e=this._inputs.filter(function(n){return n.name===t});return e.length?e[0]:null},r.prototype.getOutputByName=function(t){var e=this._outputs.filter(function(n){return n.name===t});return e.length?e[0]:null},r.prototype._setInitialTarget=function(t){this._target=t,this._originalTargetIsNeutral=t===_e.Neutral},r.prototype.initialize=function(t){},r.prototype.bind=function(t,e,n,i){},r.prototype._writeVariable=function(t){return t.connectedPoint?"".concat(t.associatedVariableName):"0."},r.prototype._writeFloat=function(t){var e=t.toString();return e.indexOf(".")===-1&&(e+=".0"),"".concat(e)},r.prototype.getClassName=function(){return"NodeMaterialBlock"},r.prototype.isConnectedInFragmentShader=function(){return this.outputs.some(function(t){return t.isConnectedInFragmentShader})},r.prototype.registerInput=function(t,e,n,i,o){return n===void 0&&(n=!1),(o=o??new pl(t,this,0)).type=e,o.isOptional=n,i&&(o.target=i),this._inputs.push(o),this},r.prototype.registerOutput=function(t,e,n,i){return(i=i??new pl(t,this,1)).type=e,n&&(i.target=n),this._outputs.push(i),this},r.prototype.getFirstAvailableInput=function(t){t===void 0&&(t=null);for(var e=0,n=this._inputs;e<n.length;e++){var i=n[e];if(!(i.connectedPoint||t&&t.type!==i.type&&i.type!==G.AutoDetect))return i}return null},r.prototype.getFirstAvailableOutput=function(t){t===void 0&&(t=null);for(var e=0,n=this._outputs;e<n.length;e++){var i=n[e];if(!t||!t.target||t.target===_e.Neutral||t.target&i.target)return i}return null},r.prototype.getSiblingOutput=function(t){var e=this._outputs.indexOf(t);return e===-1||e>=this._outputs.length?null:this._outputs[e+1]},r.prototype.isAnAncestorOf=function(t){for(var e=0,n=this._outputs;e<n.length;e++){var i=n[e];if(i.hasEndpoints)for(var o=0,a=i.endpoints;o<a.length;o++){var s=a[o];if(s.ownerBlock===t||s.ownerBlock.isAnAncestorOf(t))return!0}}return!1},r.prototype.connectTo=function(t,e){if(this._outputs.length!==0){for(var n=e&&e.output?this.getOutputByName(e.output):this.getFirstAvailableOutput(t),i=!0;i;){var o=e&&e.input?t.getInputByName(e.input):t.getFirstAvailableInput(n);if(n&&o&&n.canConnectTo(o))n.connectTo(o),i=!1;else{if(!n)throw"Unable to find a compatible match";n=this.getSiblingOutput(n)}}return this}},r.prototype._buildBlock=function(t){},r.prototype.updateUniformsAndSamples=function(t,e,n,i){},r.prototype.provideFallbacks=function(t,e){},r.prototype.initializeDefines=function(t,e,n,i){},r.prototype.prepareDefines=function(t,e,n,i,o){},r.prototype.autoConfigure=function(t,e){},r.prototype.replaceRepeatableContent=function(t,e,n,i){},Object.defineProperty(r.prototype,"willBeGeneratedIntoVertexShaderFromFragmentShader",{get:function(){return!(this.isInput||this.isFinalMerger||this._outputs.some(function(t){return t.isDirectlyConnectedToVertexOutput})||this.target===_e.Vertex||this.target!==_e.VertexAndFragment&&this.target!==_e.Neutral||!this._outputs.some(function(t){return t.isConnectedInVertexShader}))},enumerable:!1,configurable:!0}),r.prototype.isReady=function(t,e,n,i){return!0},r.prototype._linkConnectionTypes=function(t,e,n){n===void 0&&(n=!1),n?this._inputs[e]._acceptedConnectionPointType=this._inputs[t]:this._inputs[t]._linkedConnectionSource=this._inputs[e],this._inputs[e]._linkedConnectionSource=this._inputs[t]},r.prototype._processBuild=function(t,e,n,i){t.build(e,i);var o=e._vertexState!=null,a=t._buildTarget===_e.Vertex&&t.target!==_e.VertexAndFragment;if(o&&(!(t.target&t._buildTarget)||!(t.target&n.target)||this.target!==_e.VertexAndFragment&&a)&&(!t.isInput&&e.target!==t._buildTarget||t.isInput&&t.isAttribute&&!t._noContextSwitch)){var s=n.connectedPoint;if(e._vertexState._emitVaryingFromString("v_"+s.declarationVariableName,s.type)){var l=e.shaderLanguage===1?"vertexOutputs.":"";e._vertexState.compilationString+="".concat(l).concat("v_"+s.declarationVariableName," = ").concat(s.associatedVariableName,`;
|
||
`)}var c=e.shaderLanguage===1?"fragmentInputs.":"";n.associatedVariableName=c+"v_"+s.declarationVariableName,n._enforceAssociatedVariableName=!0}},r.prototype.validateBlockName=function(t){for(var e=0,n=["position","normal","tangent","particle_positionw","uv","uv2","uv3","uv4","uv5","uv6","position2d","particle_uv","matricesIndices","matricesWeights","world0","world1","world2","world3","particle_color","particle_texturemask"];e<n.length;e++)if(t===n[e])return!1;return!0},r.prototype._customBuildStep=function(t,e){},r.prototype.build=function(t,e){if(this._buildId===t.sharedData.buildId)return!0;if(!this.isInput)for(var n=0,i=this._outputs;n<i.length;n++)(u=i[n]).associatedVariableName||(u.associatedVariableName=t._getFreeVariableName(u.name));for(var o=0,a=this._inputs;o<a.length;o++){var s=a[o];if(s.connectedPoint){if(this.target!==_e.Neutral&&(!(s.target&this.target)||!(s.target&t.target)))continue;(p=s.connectedPoint.ownerBlock)&&p!==this&&this._processBuild(p,t,s,e)}else s.isOptional||t.sharedData.checks.notConnectedNonOptionalInputs.push(s)}if(this._customBuildStep(t,e),this._buildId===t.sharedData.buildId)return!0;if(t.sharedData.verbose&&O.V.Log("".concat(t.target===_e.Vertex?"Vertex shader":"Fragment shader",": Building ").concat(this.name," [").concat(this.getClassName(),"]")),this.isFinalMerger)switch(t.target){case _e.Vertex:t.sharedData.checks.emitVertex=!0;break;case _e.Fragment:t.sharedData.checks.emitFragment=!0}!this.isInput&&t.sharedData.emitComments&&(t.compilationString+=`
|
||
//`.concat(this.name,`
|
||
`)),this._buildBlock(t),this._buildId=t.sharedData.buildId,this._buildTarget=t.target;for(var l=0,c=this._outputs;l<c.length;l++){var u;if((u=c[l]).target&t.target)for(var d=0,h=u.endpoints;d<h.length;d++){var p,m=h[d];(p=m.ownerBlock)&&p.target&t.target&&e.indexOf(p)!==-1&&this._processBuild(p,t,m,e)}}return!1},r.prototype._inputRename=function(t){return t},r.prototype._outputRename=function(t){return t},r.prototype._dumpPropertiesCode=function(){var t=this._codeVariableName;return"".concat(t,".visibleInInspector = ").concat(this.visibleInInspector,`;
|
||
`).concat(t,".visibleOnFrame = ").concat(this.visibleOnFrame,`;
|
||
`).concat(t,".target = ").concat(this.target,`;
|
||
`)},r.prototype._dumpCode=function(t,e){e.push(this);var n=this.name.replace(/[^A-Za-z_]+/g,"");if(this._codeVariableName=n||"".concat(this.getClassName(),"_").concat(this.uniqueId),t.indexOf(this._codeVariableName)!==-1){var i=0;do i++,this._codeVariableName=n+i;while(t.indexOf(this._codeVariableName)!==-1)}t.push(this._codeVariableName);var o=`
|
||
// `.concat(this.getClassName(),`
|
||
`);this.comments&&(o+="// ".concat(this.comments,`
|
||
`)),o+="var ".concat(this._codeVariableName," = new BABYLON.").concat(this.getClassName(),'("').concat(this.name,`");
|
||
`),o+=this._dumpPropertiesCode();for(var a=0,s=this.inputs;a<s.length;a++){var l=s[a];if(l.isConnected){var c=l.connectedPoint.ownerBlock;e.indexOf(c)===-1&&(o+=c._dumpCode(t,e))}}for(var u=0,d=this.outputs;u<d.length;u++){var h=d[u];if(h.hasEndpoints)for(var p=0,m=h.endpoints;p<m.length;p++)(c=m[p].ownerBlock)&&e.indexOf(c)===-1&&(o+=c._dumpCode(t,e))}return o},r.prototype._dumpCodeForOutputConnections=function(t){var e="";if(t.indexOf(this)!==-1)return e;t.push(this);for(var n=0,i=this.inputs;n<i.length;n++){var o=i[n];if(o.isConnected){var a=o.connectedPoint,s=a.ownerBlock;e+=s._dumpCodeForOutputConnections(t),e+="".concat(s._codeVariableName,".").concat(s._outputRename(a.name),".connectTo(").concat(this._codeVariableName,".").concat(this._inputRename(o.name),`);
|
||
`)}}return e},r.prototype.clone=function(t,e){e===void 0&&(e="");var n=this.serialize(),i=(0,j.n9)(n.customType);if(i){var o=new i;return o._deserialize(n,t,e),o}return null},r.prototype.serialize=function(){var t={};t.customType="BABYLON."+this.getClassName(),t.id=this.uniqueId,t.name=this.name,t.comments=this.comments,t.visibleInInspector=this.visibleInInspector,t.visibleOnFrame=this.visibleOnFrame,t.target=this.target,t.inputs=[],t.outputs=[];for(var e=0,n=this.inputs;e<n.length;e++){var i=n[e];t.inputs.push(i.serialize())}for(var o=0,a=this.outputs;o<a.length;o++){var s=a[o];t.outputs.push(s.serialize(!1))}return t},r.prototype._deserialize=function(t,e,n,i){var o;this.name=t.name,this.comments=t.comments,this.visibleInInspector=!!t.visibleInInspector,this.visibleOnFrame=!!t.visibleOnFrame,this._target=(o=t.target)!==null&&o!==void 0?o:this.target,this._deserializePortDisplayNamesAndExposedOnFrame(t)},r.prototype._deserializePortDisplayNamesAndExposedOnFrame=function(t){var e=this,n=t.inputs,i=t.outputs;n&&n.forEach(function(o,a){o.displayName&&(e.inputs[a].displayName=o.displayName),o.isExposedOnFrame&&(e.inputs[a].isExposedOnFrame=o.isExposedOnFrame,e.inputs[a].exposedPortPosition=o.exposedPortPosition)}),i&&i.forEach(function(o,a){o.displayName&&(e.outputs[a].displayName=o.displayName),o.isExposedOnFrame&&(e.outputs[a].isExposedOnFrame=o.isExposedOnFrame,e.outputs[a].exposedPortPosition=o.exposedPortPosition)})},r.prototype.dispose=function(){this.onCodeIsReadyObservable.clear();for(var t=0,e=this.inputs;t<e.length;t++)e[t].dispose();for(var n=0,i=this.outputs;n<i.length;n++)i[n].dispose()},r}(),_l=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.complementW=1,n.complementZ=0,n.target=_e.Vertex,n.registerInput("vector",G.AutoDetect),n.registerInput("transform",G.Matrix),n.registerOutput("output",G.Vector4),n.registerOutput("xyz",G.Vector3),n._inputs[0].onConnectionObservable.add(function(i){if(i.ownerBlock.isInput){var o=i.ownerBlock;o.name!=="normal"&&o.name!=="tangent"||(n.complementW=0)}}),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TransformBlock"},Object.defineProperty(t.prototype,"vector",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.vector,i=this.transform,o=e._getShaderType(G.Vector4),a=e._getShaderType(G.Vector3);if(n.connectedPoint){if(this.complementW===0){var s="//".concat(this.name);e._emitFunctionFromInclude("helperFunctions",s),e.sharedData.blocksWithDefines.push(this);var l=e._getFreeVariableName("".concat(i.associatedVariableName,"_NUS"));switch(e.shaderLanguage===1?e.compilationString+="var ".concat(l,": mat3x3f = mat3x3f(").concat(i.associatedVariableName,"[0].xyz, ").concat(i.associatedVariableName,"[1].xyz, ").concat(i.associatedVariableName,`[2].xyz);
|
||
`):e.compilationString+="mat3 ".concat(l," = mat3(").concat(i.associatedVariableName,`);
|
||
`),e.compilationString+=`#ifdef NONUNIFORMSCALING
|
||
`,e.compilationString+="".concat(l," = transposeMat3(inverseMat3(").concat(l,`));
|
||
`),e.compilationString+=`#endif
|
||
`,n.connectedPoint.type){case G.Vector2:e.compilationString+=e._declareOutput(this.output)+" = ".concat(o,"(").concat(l," * ").concat(a,"(").concat(n.associatedVariableName,", ").concat(this._writeFloat(this.complementZ),"), ").concat(this._writeFloat(this.complementW),`);
|
||
`);break;case G.Vector3:case G.Color3:e.compilationString+=e._declareOutput(this.output)+" = ".concat(o,"(").concat(l," * ").concat(n.associatedVariableName,", ").concat(this._writeFloat(this.complementW),`);
|
||
`);break;default:e.compilationString+=e._declareOutput(this.output)+" = ".concat(o,"(").concat(l," * ").concat(n.associatedVariableName,".xyz, ").concat(this._writeFloat(this.complementW),`);
|
||
`)}}else switch(l=i.associatedVariableName,n.connectedPoint.type){case G.Vector2:e.compilationString+=e._declareOutput(this.output)+" = ".concat(l," * ").concat(o,"(").concat(n.associatedVariableName,", ").concat(this._writeFloat(this.complementZ),", ").concat(this._writeFloat(this.complementW),`);
|
||
`);break;case G.Vector3:case G.Color3:e.compilationString+=e._declareOutput(this.output)+" = ".concat(l," * ").concat(o,"(").concat(n.associatedVariableName,", ").concat(this._writeFloat(this.complementW),`);
|
||
`);break;default:e.compilationString+=e._declareOutput(this.output)+" = ".concat(l," * ").concat(n.associatedVariableName,`;
|
||
`)}this.xyz.hasEndpoints&&(e.compilationString+=e._declareOutput(this.xyz)+" = ".concat(this.output.associatedVariableName,`.xyz;
|
||
`))}return this},t.prototype.prepareDefines=function(e,n,i){e.nonUniformScaling&&i.setValue("NONUNIFORMSCALING",!0)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.complementZ=this.complementZ,e.complementW=this.complementW,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.complementZ=e.complementZ!==void 0?e.complementZ:0,this.complementW=e.complementW!==void 0?e.complementW:1},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".complementZ = ").concat(this.complementZ,`;
|
||
`)+"".concat(this._codeVariableName,".complementW = ").concat(this.complementW,`;
|
||
`)},t}(ut);(0,j.Y5)("BABYLON.TransformBlock",_l);var Qd,$a=function(r){function t(e){var n=r.call(this,e,_e.Vertex,!0)||this;return n.registerInput("vector",G.Vector4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VertexOutputBlock"},Object.defineProperty(t.prototype,"vector",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),t.prototype._isLogarithmicDepthEnabled=function(e,n){if(n)return!0;for(var i=0,o=e;i<o.length;i++)if(o[i].useLogarithmicDepth)return!0;return!1},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.vector,i=e.shaderLanguage===1;if(e.shaderLanguage===1?e.compilationString+="vertexOutputs.position = ".concat(n.associatedVariableName,`;
|
||
`):e.compilationString+="gl_Position = ".concat(n.associatedVariableName,`;
|
||
`),this._isLogarithmicDepthEnabled(e.sharedData.fragmentOutputNodes,e.sharedData.nodeMaterial.useLogarithmicDepth)){e._emitUniformFromString("logarithmicDepthConstant",G.Float),e._emitVaryingFromString("vFragmentDepth",G.Float);var o=i?"vertexOutputs.vFragmentDepth":"vFragmentDepth",a=i?"uniforms.":"",s=i?"vertexOutputs.position":"gl_Position";e.compilationString+="".concat(o," = 1.0 + ").concat(s,`.w;
|
||
`),e.compilationString+="".concat(s,".z = log2(max(0.000001, ").concat(o,")) * ").concat(a,`logarithmicDepthConstant;
|
||
`)}return this},t}(ut);function dt(r,t,e,n){return t===void 0&&(t=0),e===void 0&&(e="PROPERTIES"),function(i,o){var a=i._propStore;a||(a=[],i._propStore=a),a.push({propertyName:o,displayName:r,type:t,groupName:e,options:n??{}})}}(0,j.Y5)("BABYLON.VertexOutputBlock",$a),function(r){r[r.Boolean=0]="Boolean",r[r.Float=1]="Float",r[r.Int=2]="Int",r[r.Vector2=3]="Vector2",r[r.List=4]="List"}(Qd||(Qd={}));var Nt,jr,ca=function(r){function t(e){var n=r.call(this,e,_e.Fragment,!0)||this;return n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n.useLogarithmicDepth=!1,n.registerInput("rgba",G.Color4,!0),n.registerInput("rgb",G.AutoDetect,!0),n.registerInput("a",G.Float,!0),n.rgb.addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FragmentOutputBlock"},t.prototype.initialize=function(e){e._excludeVariableName("logarithmicDepthConstant"),e._excludeVariableName("vFragmentDepth")},Object.defineProperty(t.prototype,"rgba",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,n,i){i.setValue(this._linearDefineName,this.convertToLinearSpace,!0),i.setValue(this._gammaDefineName,this.convertToGammaSpace,!0)},t.prototype.bind=function(e,n,i){(this.useLogarithmicDepth||n.useLogarithmicDepth)&&i&&(0,Re.DL)(void 0,e,i.getScene())},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.rgba,i=this.rgb,o=this.a,a=e.shaderLanguage===1;e.sharedData.hints.needAlphaBlending=n.isConnected||o.isConnected,e.sharedData.blocksWithDefines.push(this),(this.useLogarithmicDepth||e.sharedData.nodeMaterial.useLogarithmicDepth)&&(e._emitUniformFromString("logarithmicDepthConstant",G.Float),e._emitVaryingFromString("vFragmentDepth",G.Float),e.sharedData.bindableBlocks.push(this)),this._linearDefineName=e._getFreeDefineName("CONVERTTOLINEAR"),this._gammaDefineName=e._getFreeDefineName("CONVERTTOGAMMA");var s="//".concat(this.name);e._emitFunctionFromInclude("helperFunctions",s);var l="gl_FragColor";e.shaderLanguage===1&&(e.compilationString+=`var fragmentOutputsColor : vec4<f32>;\r
|
||
`,l="fragmentOutputsColor");var c=e._getShaderType(G.Vector4);if(n.connectedPoint)o.isConnected?e.compilationString+="".concat(l," = ").concat(c,"(").concat(n.associatedVariableName,".rgb, ").concat(o.associatedVariableName,`);
|
||
`):e.compilationString+="".concat(l," = ").concat(n.associatedVariableName,`;
|
||
`);else if(i.connectedPoint){var u="1.0";o.connectedPoint&&(u=o.associatedVariableName),i.connectedPoint.type===G.Float?e.compilationString+="".concat(l," = ").concat(c,"(").concat(i.associatedVariableName,", ").concat(i.associatedVariableName,", ").concat(i.associatedVariableName,", ").concat(u,`);
|
||
`):e.compilationString+="".concat(l," = ").concat(c,"(").concat(i.associatedVariableName,", ").concat(u,`);
|
||
`)}else e.sharedData.checks.notConnectedNonOptionalInputs.push(n);if(e.compilationString+="#ifdef ".concat(this._linearDefineName,`
|
||
`),e.compilationString+="".concat(l," = toLinearSpace(").concat(l,`);
|
||
`),e.compilationString+=`#endif
|
||
`,e.compilationString+="#ifdef ".concat(this._gammaDefineName,`
|
||
`),e.compilationString+="".concat(l," = toGammaSpace(").concat(l,`);
|
||
`),e.compilationString+=`#endif
|
||
`,e.shaderLanguage===1&&(e.compilationString+=`#if !defined(PREPASS)\r
|
||
`,e.compilationString+=`fragmentOutputs.color = fragmentOutputsColor;\r
|
||
`,e.compilationString+=`#endif\r
|
||
`),this.useLogarithmicDepth||e.sharedData.nodeMaterial.useLogarithmicDepth){var d=a?"input.vFragmentDepth":"vFragmentDepth",h=a?"uniforms.":"",p=a?"fragmentOutputs.fragDepth":"gl_FragDepthEXT";e.compilationString+="".concat(p," = log2(").concat(d,") * ").concat(h,`logarithmicDepthConstant * 0.5;
|
||
`)}return e.compilationString+=`#if defined(PREPASS)\r
|
||
`,e.compilationString+="".concat(a?"fragmentOutputs.fragData0":"gl_FragData[0]"," = ").concat(l,`;\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+="".concat(this._codeVariableName,".convertToGammaSpace = ").concat(this.convertToGammaSpace,`;
|
||
`),(e+="".concat(this._codeVariableName,".convertToLinearSpace = ").concat(this.convertToLinearSpace,`;
|
||
`))+"".concat(this._codeVariableName,".useLogarithmicDepth = ").concat(this.useLogarithmicDepth,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,e.useLogarithmicDepth=this.useLogarithmicDepth,e},t.prototype._deserialize=function(e,n,i){var o;r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=!!e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,this.useLogarithmicDepth=(o=e.useLogarithmicDepth)!==null&&o!==void 0&&o},(0,A.Cg)([dt("Convert to gamma space",0,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"convertToGammaSpace",void 0),(0,A.Cg)([dt("Convert to linear space",0,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"convertToLinearSpace",void 0),(0,A.Cg)([dt("Use logarithmic depth",0,"PROPERTIES")],t.prototype,"useLogarithmicDepth",void 0),t}(ut);(0,j.Y5)("BABYLON.FragmentOutputBlock",ca),function(r){r[r.World=1]="World",r[r.View=2]="View",r[r.Projection=3]="Projection",r[r.ViewProjection=4]="ViewProjection",r[r.WorldView=5]="WorldView",r[r.WorldViewProjection=6]="WorldViewProjection",r[r.CameraPosition=7]="CameraPosition",r[r.FogColor=8]="FogColor",r[r.DeltaTime=9]="DeltaTime",r[r.CameraParameters=10]="CameraParameters",r[r.MaterialAlpha=11]="MaterialAlpha"}(Nt||(Nt={})),function(r){r[r.None=0]="None",r[r.Time=1]="Time",r[r.RealTime=2]="RealTime",r[r.MouseInfo=3]="MouseInfo"}(jr||(jr={}));var iN={position2d:"position",particle_uv:"vUV",particle_color:"vColor",particle_texturemask:"textureMask",particle_positionw:"vPositionW"},ov={particle_uv:!0,particle_color:!0,particle_texturemask:!0,particle_positionw:!0},Fx={particle_texturemask:!0},Mt=function(r){function t(e,n,i){n===void 0&&(n=_e.Vertex),i===void 0&&(i=G.AutoDetect);var o=r.call(this,e,n,!1)||this;return o._mode=3,o._animationType=jr.None,o._prefix="",o.min=0,o.max=0,o.isBoolean=!1,o.matrixMode=0,o._systemValue=null,o.isConstant=!1,o.groupInInspector="",o.onValueChangedObservable=new K.cP,o.convertToGammaSpace=!1,o.convertToLinearSpace=!1,o._type=i,o.setDefaultValue(),o.registerOutput("output",i),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"type",{get:function(){if(this._type===G.AutoDetect){if(this.isUniform&&this.value!=null){if(!isNaN(this.value))return this._type=G.Float,this._type;switch(this.value.getClassName()){case"Vector2":return this._type=G.Vector2,this._type;case"Vector3":return this._type=G.Vector3,this._type;case"Vector4":return this._type=G.Vector4,this._type;case"Color3":return this._type=G.Color3,this._type;case"Color4":return this._type=G.Color4,this._type;case"Matrix":return this._type=G.Matrix,this._type}}if(this.isAttribute)switch(this.name){case"position":case"normal":case"particle_positionw":return this._type=G.Vector3,this._type;case"uv":case"uv2":case"uv3":case"uv4":case"uv5":case"uv6":case"position2d":case"particle_uv":return this._type=G.Vector2,this._type;case"matricesIndices":case"matricesWeights":case"matricesIndicesExtra":case"matricesWeightsExtra":case"world0":case"world1":case"world2":case"world3":case"tangent":return this._type=G.Vector4,this._type;case"color":case"instanceColor":case"particle_color":case"particle_texturemask":return this._type=G.Color4,this._type}if(this.isSystemValue)switch(this._systemValue){case Nt.World:case Nt.WorldView:case Nt.WorldViewProjection:case Nt.View:case Nt.ViewProjection:case Nt.Projection:return this._type=G.Matrix,this._type;case Nt.CameraPosition:return this._type=G.Vector3,this._type;case Nt.FogColor:return this._type=G.Color3,this._type;case Nt.DeltaTime:case Nt.MaterialAlpha:return this._type=G.Float,this._type;case Nt.CameraParameters:return this._type=G.Vector4,this._type}}return this._type},enumerable:!1,configurable:!0}),t.prototype.validateBlockName=function(e){return!!this.isAttribute||r.prototype.validateBlockName.call(this,e)},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.setAsAttribute=function(e){return this._mode=1,e&&(this.name=e),this},t.prototype.setAsSystemValue=function(e){return this.systemValue=e,this},Object.defineProperty(t.prototype,"value",{get:function(){return this._storedValue},set:function(e){this.type===G.Float&&(this.isBoolean?e=e?1:0:this.min!==this.max&&(e=Math.max(this.min,e),e=Math.min(this.max,e))),this._storedValue=e,this._mode=0,this.onValueChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"valueCallback",{get:function(){return this._valueCallback},set:function(e){this._valueCallback=e,this._mode=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"declarationVariableName",{get:function(){return this._associatedVariableName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"associatedVariableName",{get:function(){return this._prefix+this._associatedVariableName},set:function(e){this._associatedVariableName=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animationType",{get:function(){return this._animationType},set:function(e){this._animationType=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUndefined",{get:function(){return this._mode===3},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUniform",{get:function(){return this._mode===0},set:function(e){this._mode=e?0:3,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAttribute",{get:function(){return this._mode===1},set:function(e){this._mode=e?1:3,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isVarying",{get:function(){return this._mode===2},set:function(e){this._mode=e?2:3,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSystemValue",{get:function(){return this._systemValue!=null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"systemValue",{get:function(){return this._systemValue},set:function(e){this._mode=0,this.associatedVariableName="",this._systemValue=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"InputBlock"},t.prototype.animate=function(e){switch(this._animationType){case jr.Time:this.type===G.Float&&(this.value+=.01*e.getAnimationRatio());break;case jr.RealTime:this.type===G.Float&&(this.value=(et.j.Now-e.getEngine().startTime)/1e3);break;case jr.MouseInfo:if(this.type===G.Vector4){var n=e._inputManager._originMouseEvent;if(n){var i=n.offsetX,o=n.offsetY,a=1&n.buttons?1:0,s=2&n.buttons?1:0;this.value=new _.IU(i,o,a,s)}else this.value=new _.IU(0,0,0,0)}}},t.prototype._emitDefine=function(e){return e[0]==="!"?"#ifndef ".concat(e.substring(1),`
|
||
`):"#ifdef ".concat(e,`
|
||
`)},t.prototype.initialize=function(){this.associatedVariableName=""},t.prototype.setDefaultValue=function(){switch(this.type){case G.Float:this.value=0;break;case G.Vector2:this.value=_.I9.Zero();break;case G.Vector3:this.value=_.Pq.Zero();break;case G.Vector4:this.value=_.IU.Zero();break;case G.Color3:this.value=Ge.v9.White();break;case G.Color4:this.value=new Ge.ov(1,1,1,1);break;case G.Matrix:this.value=_.uq.Identity()}},t.prototype._emitConstant=function(e){switch(this.type){case G.Float:return"".concat(e._emitFloat(this.value));case G.Vector2:return"vec2(".concat(this.value.x,", ").concat(this.value.y,")");case G.Vector3:return"vec3(".concat(this.value.x,", ").concat(this.value.y,", ").concat(this.value.z,")");case G.Vector4:return"vec4(".concat(this.value.x,", ").concat(this.value.y,", ").concat(this.value.z,", ").concat(this.value.w,")");case G.Color3:return Ge.IG.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&Ge.IG.Color3[0].toGammaSpaceToRef(Ge.IG.Color3[0],e.sharedData.scene.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ge.IG.Color3[0].toLinearSpaceToRef(Ge.IG.Color3[0],e.sharedData.scene.getEngine().useExactSrgbConversions),"vec3(".concat(Ge.IG.Color3[0].r,", ").concat(Ge.IG.Color3[0].g,", ").concat(Ge.IG.Color3[0].b,")");case G.Color4:return Ge.IG.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&Ge.IG.Color4[0].toGammaSpaceToRef(Ge.IG.Color4[0],e.sharedData.scene.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ge.IG.Color4[0].toLinearSpaceToRef(Ge.IG.Color4[0],e.sharedData.scene.getEngine().useExactSrgbConversions),"vec4(".concat(Ge.IG.Color4[0].r,", ").concat(Ge.IG.Color4[0].g,", ").concat(Ge.IG.Color4[0].b,", ").concat(Ge.IG.Color4[0].a,")")}return""},Object.defineProperty(t.prototype,"_noContextSwitch",{get:function(){return ov[this.name]},enumerable:!1,configurable:!0}),t.prototype._emit=function(e,n){var i;if(this.isUniform){if(this._associatedVariableName||(this._associatedVariableName=e._getFreeVariableName("u_"+this.name)),this.isConstant)return e.constants.indexOf(this.associatedVariableName)!==-1?void 0:(e.constants.push(this.associatedVariableName),void(e._constantDeclaration+=e._declareOutput(this.output,!0)+" = ".concat(this._emitConstant(e),`;
|
||
`)));if(e.uniforms.indexOf(this.associatedVariableName)!==-1)return;e.uniforms.push(this.associatedVariableName),n&&(e._uniformDeclaration+=this._emitDefine(n));var o=e._getShaderType(this.type);e.shaderLanguage===1?(e._uniformDeclaration+="uniform ".concat(this._associatedVariableName,": ").concat(o,`;
|
||
`),this._prefix="uniforms."):e._uniformDeclaration+="uniform ".concat(o," ").concat(this.associatedVariableName,`;
|
||
`),n&&(e._uniformDeclaration+=`#endif
|
||
`);var a=e.sharedData.hints;if(this._systemValue!==null&&this._systemValue!==void 0)switch(this._systemValue){case Nt.WorldView:a.needWorldViewMatrix=!0;break;case Nt.WorldViewProjection:a.needWorldViewProjectionMatrix=!0}else this._animationType!==jr.None&&e.sharedData.animatedInputs.push(this)}else if(this.isAttribute){if(this.associatedVariableName=(i=iN[this.name])!==null&&i!==void 0?i:this.name,this.target===_e.Vertex&&e._vertexState)return void(ov[this.name]?Fx[this.name]?(e._emitUniformFromString(this.declarationVariableName,this.type,n),e.shaderLanguage===1&&(this._prefix="vertexInputs.")):e._emitVaryingFromString(this.declarationVariableName,this.type,n):this._emit(e._vertexState,n));if(e.attributes.indexOf(this.declarationVariableName)!==-1)return;e.attributes.push(this.declarationVariableName),ov[this.name]?Fx[this.name]?(e._emitUniformFromString(this.declarationVariableName,this.type,n),e.shaderLanguage===1&&(this._prefix="uniforms.")):(e._emitVaryingFromString(this.declarationVariableName,this.type,n),e.shaderLanguage===1&&(this._prefix="fragmentInputs.")):(n&&(e._attributeDeclaration+=this._emitDefine(n)),e.shaderLanguage===1?(e._attributeDeclaration+="attribute ".concat(this.declarationVariableName,": ").concat(e._getShaderType(this.type),`;
|
||
`),this._prefix="vertexInputs."):e._attributeDeclaration+="attribute ".concat(e._getShaderType(this.type)," ").concat(this.declarationVariableName,`;
|
||
`),n&&(e._attributeDeclaration+=`#endif
|
||
`))}},t.prototype._transmitWorld=function(e,n,i,o){if(this._systemValue){var a=this._associatedVariableName;switch(this._systemValue){case Nt.World:e.setMatrix(a,n);break;case Nt.WorldView:e.setMatrix(a,i);break;case Nt.WorldViewProjection:e.setMatrix(a,o)}}},t.prototype._transmit=function(e,n,i){if(!this.isAttribute){var o=this._associatedVariableName;if(this._systemValue)switch(this._systemValue){case Nt.World:case Nt.WorldView:case Nt.WorldViewProjection:return;case Nt.View:e.setMatrix(o,n.getViewMatrix());break;case Nt.Projection:e.setMatrix(o,n.getProjectionMatrix());break;case Nt.ViewProjection:e.setMatrix(o,n.getTransformMatrix());break;case Nt.CameraPosition:n.bindEyePosition(e,o,!0);break;case Nt.FogColor:e.setColor3(o,n.fogColor);break;case Nt.DeltaTime:e.setFloat(o,n.deltaTime/1e3);break;case Nt.CameraParameters:n.activeCamera&&e.setFloat4(o,n.getEngine().hasOriginBottomLeft?-1:1,n.activeCamera.minZ,n.activeCamera.maxZ,1/n.activeCamera.maxZ);break;case Nt.MaterialAlpha:e.setFloat(o,i.alpha)}else{var a=this._valueCallback?this._valueCallback():this._storedValue;if(a!==null)switch(this.type){case G.Float:e.setFloat(o,a);break;case G.Int:e.setInt(o,a);break;case G.Color3:Ge.IG.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&Ge.IG.Color3[0].toGammaSpaceToRef(Ge.IG.Color3[0],n.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ge.IG.Color3[0].toLinearSpaceToRef(Ge.IG.Color3[0],n.getEngine().useExactSrgbConversions),e.setColor3(o,Ge.IG.Color3[0]);break;case G.Color4:Ge.IG.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&Ge.IG.Color4[0].toGammaSpaceToRef(Ge.IG.Color4[0],n.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ge.IG.Color4[0].toLinearSpaceToRef(Ge.IG.Color4[0],n.getEngine().useExactSrgbConversions),e.setDirectColor4(o,Ge.IG.Color4[0]);break;case G.Vector2:e.setVector2(o,a);break;case G.Vector3:e.setVector3(o,a);break;case G.Vector4:e.setVector4(o,a);break;case G.Matrix:e.setMatrix(o,a)}}}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),(this.isUniform||this.isSystemValue)&&e.sharedData.inputBlocks.push(this),this._emit(e)},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName;if(this.isAttribute)return r.prototype._dumpPropertiesCode.call(this)+"".concat(e,'.setAsAttribute("').concat(this.name,`");
|
||
`);if(this.isSystemValue)return r.prototype._dumpPropertiesCode.call(this)+"".concat(e,".setAsSystemValue(BABYLON.NodeMaterialSystemValues.").concat(Nt[this._systemValue],`);
|
||
`);if(this.isUniform){var n=[],i="";switch(this.type){case G.Float:i="".concat(this.value);break;case G.Vector2:i="new BABYLON.Vector2(".concat(this.value.x,", ").concat(this.value.y,")");break;case G.Vector3:i="new BABYLON.Vector3(".concat(this.value.x,", ").concat(this.value.y,", ").concat(this.value.z,")");break;case G.Vector4:i="new BABYLON.Vector4(".concat(this.value.x,", ").concat(this.value.y,", ").concat(this.value.z,", ").concat(this.value.w,")");break;case G.Color3:i="new BABYLON.Color3(".concat(this.value.r,", ").concat(this.value.g,", ").concat(this.value.b,")"),this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case G.Color4:i="new BABYLON.Color4(".concat(this.value.r,", ").concat(this.value.g,", ").concat(this.value.b,", ").concat(this.value.a,")"),this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case G.Matrix:i="BABYLON.Matrix.FromArray([".concat(this.value.m,"])")}return n.push("".concat(e,".value = ").concat(i)),this.type===G.Float&&n.push("".concat(e,".min = ").concat(this.min),"".concat(e,".max = ").concat(this.max),"".concat(e,".isBoolean = ").concat(this.isBoolean),"".concat(e,".matrixMode = ").concat(this.matrixMode),"".concat(e,".animationType = BABYLON.AnimatedInputBlockTypes.").concat(jr[this.animationType])),n.push("".concat(e,".isConstant = ").concat(this.isConstant)),n.push(""),r.prototype._dumpPropertiesCode.call(this)+n.join(`;
|
||
`)}return r.prototype._dumpPropertiesCode.call(this)},t.prototype.dispose=function(){this.onValueChangedObservable.clear(),r.prototype.dispose.call(this)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.type=this.type,e.mode=this._mode,e.systemValue=this._systemValue,e.animationType=this._animationType,e.min=this.min,e.max=this.max,e.isBoolean=this.isBoolean,e.matrixMode=this.matrixMode,e.isConstant=this.isConstant,e.groupInInspector=this.groupInInspector,e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,this._storedValue!=null&&this._mode===0&&(this._storedValue.asArray?(e.valueType="BABYLON."+this._storedValue.getClassName(),e.value=this._storedValue.asArray()):(e.valueType="number",e.value=this._storedValue)),e},t.prototype._deserialize=function(e,n,i){if(this._mode=e.mode,r.prototype._deserialize.call(this,e,n,i),this._type=e.type,this._systemValue=e.systemValue||e.wellKnownValue,this._animationType=e.animationType,this.min=e.min||0,this.max=e.max||0,this.isBoolean=!!e.isBoolean,this.matrixMode=e.matrixMode||0,this.isConstant=!!e.isConstant,this.groupInInspector=e.groupInInspector||"",this.convertToGammaSpace=!!e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.name==="tangent"&&e.mode===1&&e.type===G.Vector3&&(this._type=G.Vector4),e.valueType)if(e.valueType==="number")this._storedValue=e.value;else{var o=(0,j.n9)(e.valueType);o&&(this._storedValue=o.FromArray(e.value))}},t}(ut);(0,j.Y5)("BABYLON.InputBlock",Mt);var Jd=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment)||this;return n._samplerName="textureSampler",n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n._isUnique=!1,n.registerInput("uv",G.AutoDetect,!1,_e.VertexAndFragment),n.registerOutput("rgba",G.Color4,_e.Neutral),n.registerOutput("rgb",G.Color3,_e.Neutral),n.registerOutput("r",G.Float,_e.Neutral),n.registerOutput("g",G.Float,_e.Neutral),n.registerOutput("b",G.Float,_e.Neutral),n.registerOutput("a",G.Float,_e.Neutral),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Vector2|G.Vector3|G.Vector4),n._inputs[0]._prioritizeVertex=!1,n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"CurrentScreenBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName(this._samplerName)},Object.defineProperty(t.prototype,"target",{get:function(){return this.uv.isConnected?this.uv.sourceBlock.isInput?_e.VertexAndFragment:_e.Fragment:_e.VertexAndFragment},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,n,i){i.setValue(this._linearDefineName,this.convertToGammaSpace,!0),i.setValue(this._gammaDefineName,this.convertToLinearSpace,!0)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype._injectVertexCode=function(e){var n=this.uv;if(n.connectedPoint.ownerBlock.isInput&&(n.connectedPoint.ownerBlock.isAttribute||e._emitUniformFromString(n.associatedVariableName,G.Vector2)),this._mainUVName="vMain"+n.associatedVariableName,e._emitVaryingFromString(this._mainUVName,G.Vector2),e.compilationString+="".concat(this._mainUVName," = ").concat(n.associatedVariableName,`.xy;
|
||
`),this._outputs.some(function(s){return s.isConnectedInVertexShader})){this._writeTextureRead(e,!0);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name,!0)}}},t.prototype._writeTextureRead=function(e,n){n===void 0&&(n=!1);var i=this.uv;if(n){if(e.target===_e.Fragment)return;var o=e.shaderLanguage===0?"texture2D(".concat(this._samplerName,","):"textureSampleLevel(".concat(this._samplerName,", ").concat(this._samplerName+P.Y.AUTOSAMPLERSUFFIX,","),a=e.shaderLanguage===0?"":", 0";e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(o," ").concat(i.associatedVariableName).concat(a,`);
|
||
`)}else{var s=e.shaderLanguage===0?"texture2D(".concat(this._samplerName,","):"textureSample(".concat(this._samplerName,", ").concat(this._samplerName+P.Y.AUTOSAMPLERSUFFIX,",");this.uv.ownerBlock.target!==_e.Fragment?e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(s," ").concat(this._mainUVName,`);
|
||
`):e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(s," ").concat(i.associatedVariableName,`);
|
||
`)}},t.prototype._writeOutput=function(e,n,i,o){if(o===void 0&&(o=!1),o){if(e.target===_e.Fragment)return;e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`)}else this.uv.ownerBlock.target!==_e.Fragment?(e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`),e.compilationString+="#ifdef ".concat(this._linearDefineName,`
|
||
`),e.compilationString+="".concat(n.associatedVariableName," = toGammaSpace(").concat(n.associatedVariableName,`);
|
||
`),e.compilationString+=`#endif
|
||
`,e.compilationString+="#ifdef ".concat(this._gammaDefineName,`
|
||
`),e.compilationString+="".concat(n.associatedVariableName," = toLinearSpace(").concat(n.associatedVariableName,`);
|
||
`),e.compilationString+=`#endif
|
||
`):e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`)},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),e.sharedData.blockingBlocks.indexOf(this)<0&&e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.indexOf(this)<0&&e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.indexOf(this)<0&&e.sharedData.blocksWithDefines.push(this),e.target!==_e.Fragment)return e._emit2DSampler(this._samplerName),void this._injectVertexCode(e);if(this._outputs.some(function(s){return s.isConnectedInFragmentShader})){e._emit2DSampler(this._samplerName),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA");var n="//".concat(this.name);e._emitFunctionFromInclude("helperFunctions",n),this._writeTextureRead(e);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name)}return this}},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,this.texture&&!this.texture.isRenderTarget&&(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.texture&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=Ie.g.Parse(e.texture,n,i))},t}(ut);(0,j.Y5)("BABYLON.CurrentScreenBlock",Jd);var $d=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._samplerName="diffuseSampler",n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n._isUnique=!1,n.registerInput("uv",G.AutoDetect,!1,_e.VertexAndFragment),n.registerOutput("rgba",G.Color4,_e.Neutral),n.registerOutput("rgb",G.Color3,_e.Neutral),n.registerOutput("r",G.Float,_e.Neutral),n.registerOutput("g",G.Float,_e.Neutral),n.registerOutput("b",G.Float,_e.Neutral),n.registerOutput("a",G.Float,_e.Neutral),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Vector2|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ParticleTextureBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("diffuseSampler")},t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.uv.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.isAttribute&&o.name==="particle_uv"&&n(o)});i||(i=new Mt("uv")).setAsAttribute("particle_uv"),i.output.connectTo(this.uv)}},t.prototype.prepareDefines=function(e,n,i){i.setValue(this._linearDefineName,this.convertToGammaSpace,!0),i.setValue(this._gammaDefineName,this.convertToLinearSpace,!0)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype._writeOutput=function(e,n,i){e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`),e.compilationString+="#ifdef ".concat(this._linearDefineName,`
|
||
`),e.compilationString+="".concat(n.associatedVariableName," = toGammaSpace(").concat(n.associatedVariableName,`);
|
||
`),e.compilationString+=`#endif
|
||
`,e.compilationString+="#ifdef ".concat(this._gammaDefineName,`
|
||
`),e.compilationString+="".concat(n.associatedVariableName," = toLinearSpace(").concat(n.associatedVariableName,`);
|
||
`),e.compilationString+=`#endif
|
||
`},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target!==_e.Vertex){this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),e._emit2DSampler(this._samplerName),e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.push(this),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA");var n="//".concat(this.name);e._emitFunctionFromInclude("helperFunctions",n),e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(e._generateTextureSample(this.uv.associatedVariableName,this._samplerName),`;
|
||
`);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,a.name)}return this}},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,this.texture&&!this.texture.isRenderTarget&&(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.texture&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=Ie.g.Parse(e.texture,n,i))},t}(ut);(0,j.Y5)("BABYLON.ParticleTextureBlock",$d);var eh=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._isUnique=!0,n.registerInput("color",G.Color4,!1,_e.Fragment),n.registerOutput("rampColor",G.Color4,_e.Fragment),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ParticleRampGradientBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rampColor",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("remapRanges"),e._excludeVariableName("rampSampler"),e._excludeVariableName("baseColor"),e._excludeVariableName("alpha"),e._excludeVariableName("remappedColorIndex"),e._excludeVariableName("rampColor")},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target!==_e.Vertex)return e._emit2DSampler("rampSampler","RAMPGRADIENT"),e._emitVaryingFromString("remapRanges",G.Vector4,"RAMPGRADIENT"),e.compilationString+=`
|
||
#ifdef RAMPGRADIENT
|
||
`.concat(e._declareLocalVar("baseColor",G.Vector4)," = ").concat(this.color.associatedVariableName,`;
|
||
`).concat(e._declareLocalVar("alpha",G.Float)," = ").concat(this.color.associatedVariableName,`.a;
|
||
|
||
`).concat(e._declareLocalVar("remappedColorIndex",G.Float),` = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);
|
||
|
||
`).concat(e._declareLocalVar("rampColor",G.Vector4)," = ").concat(e._generateTextureSample("vec2(1.0 - remappedColorIndex, 0.)","rampSampler"),`;
|
||
|
||
// Remapped alpha
|
||
`).concat(e._declareOutput(this.rampColor)," = vec4").concat(e.fSuffix,`(baseColor.rgb * rampColor.rgb, clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0));
|
||
#else
|
||
`).concat(e._declareOutput(this.rampColor)," = ").concat(this.color.associatedVariableName,`;
|
||
#endif
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ParticleRampGradientBlock",eh);var th=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._isUnique=!0,n.registerInput("color",G.Color4,!1,_e.Fragment),n.registerInput("alphaTexture",G.Float,!1,_e.Fragment),n.registerInput("alphaColor",G.Float,!1,_e.Fragment),n.registerOutput("blendColor",G.Color4,_e.Fragment),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ParticleBlendMultiplyBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alphaTexture",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alphaColor",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendColor",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("sourceAlpha")},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target!==_e.Vertex)return e.compilationString+=`
|
||
#ifdef BLENDMULTIPLYMODE
|
||
`.concat(e._declareOutput(this.blendColor),`;
|
||
`).concat(e._declareLocalVar("sourceAlpha",G.Float)," = ").concat(this.alphaColor.associatedVariableName," * ").concat(this.alphaTexture.associatedVariableName,`;
|
||
`).concat(this.blendColor.associatedVariableName," = vec4").concat(e.fSuffix,"(").concat(this.color.associatedVariableName,".rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha), ").concat(this.color.associatedVariableName,`.a);
|
||
#else
|
||
`).concat(e._declareOutput(this.blendColor)," = ").concat(this.color.associatedVariableName,`;
|
||
#endif
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ParticleBlendMultiplyBlock",th);var es=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.xSwizzle="x",n.ySwizzle="y",n.zSwizzle="z",n.wSwizzle="w",n.registerInput("xyzw ",G.Vector4,!0),n.registerInput("xyz ",G.Vector3,!0),n.registerInput("xy ",G.Vector2,!0),n.registerInput("zw ",G.Vector2,!0),n.registerInput("x",G.Float,!0),n.registerInput("y",G.Float,!0),n.registerInput("z",G.Float,!0),n.registerInput("w",G.Float,!0),n.registerOutput("xyzw",G.Vector4),n.registerOutput("xyz",G.Vector3),n.registerOutput("xy",G.Vector2),n.registerOutput("zw",G.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VectorMergerBlock"},Object.defineProperty(t.prototype,"xyzwIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwIn",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"w",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwOut",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xy",{get:function(){return this.xyOut},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this.xyzOut},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return e==="xyzw "?"xyzwIn":e==="xyz "?"xyzIn":e==="xy "?"xyIn":e==="zw "?"zwIn":e},t.prototype._buildSwizzle=function(e){return"."+(this.xSwizzle+this.ySwizzle+this.zSwizzle+this.wSwizzle).substring(0,e)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.x,i=this.y,o=this.z,a=this.w,s=this.xyIn,l=this.zwIn,c=this.xyzIn,u=this.xyzwIn,d=this._outputs[0],h=this._outputs[1],p=this._outputs[2],m=this._outputs[3],v=e._getShaderType(G.Vector4),b=e._getShaderType(G.Vector3),E=e._getShaderType(G.Vector2);return u.isConnected?(d.hasEndpoints&&(e.compilationString+=e._declareOutput(d)+" = ".concat(u.associatedVariableName).concat(this._buildSwizzle(4),`;
|
||
`)),h.hasEndpoints&&(e.compilationString+=e._declareOutput(h)+" = ".concat(u.associatedVariableName).concat(this._buildSwizzle(3),`;
|
||
`)),p.hasEndpoints&&(e.compilationString+=e._declareOutput(p)+" = ".concat(u.associatedVariableName).concat(this._buildSwizzle(2),`;
|
||
`))):c.isConnected?(d.hasEndpoints&&(e.compilationString+=e._declareOutput(d)+" = ".concat(v,"(").concat(c.associatedVariableName,", ").concat(a.isConnected?this._writeVariable(a):"0.0",")").concat(this._buildSwizzle(4),`;
|
||
`)),h.hasEndpoints&&(e.compilationString+=e._declareOutput(h)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(3),`;
|
||
`)),p.hasEndpoints&&(e.compilationString+=e._declareOutput(p)+" = ".concat(c.associatedVariableName).concat(this._buildSwizzle(2),`;
|
||
`))):s.isConnected?(d.hasEndpoints&&(l.isConnected?e.compilationString+=e._declareOutput(d)+" = ".concat(v,"(").concat(s.associatedVariableName,", ").concat(l.associatedVariableName,")").concat(this._buildSwizzle(4),`;
|
||
`):e.compilationString+=e._declareOutput(d)+" = ".concat(v,"(").concat(s.associatedVariableName,", ").concat(o.isConnected?this._writeVariable(o):"0.0",", ").concat(a.isConnected?this._writeVariable(a):"0.0",")").concat(this._buildSwizzle(4),`;
|
||
`)),h.hasEndpoints&&(e.compilationString+=e._declareOutput(h)+" = ".concat(b,"(").concat(s.associatedVariableName,", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(3),`;
|
||
`)),p.hasEndpoints&&(e.compilationString+=e._declareOutput(p)+" = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2),`;
|
||
`)),m.hasEndpoints&&(l.isConnected?e.compilationString+=e._declareOutput(m)+" = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2),`;
|
||
`):e.compilationString+=e._declareOutput(m)+" = ".concat(E,"(").concat(o.isConnected?this._writeVariable(o):"0.0",", ").concat(a.isConnected?this._writeVariable(a):"0.0",")").concat(this._buildSwizzle(2),`;
|
||
`))):(d.hasEndpoints&&(l.isConnected?e.compilationString+=e._declareOutput(d)+" = ".concat(v,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(l.associatedVariableName,")").concat(this._buildSwizzle(4),`;
|
||
`):e.compilationString+=e._declareOutput(d)+" = ".concat(v,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",", ").concat(a.isConnected?this._writeVariable(a):"0.0",")").concat(this._buildSwizzle(4),`;
|
||
`)),h.hasEndpoints&&(e.compilationString+=e._declareOutput(h)+" = ".concat(b,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(3),`;
|
||
`)),p.hasEndpoints&&(e.compilationString+=e._declareOutput(p)+" = ".concat(E,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(i.isConnected?this._writeVariable(i):"0.0",")").concat(this._buildSwizzle(2),`;
|
||
`)),m.hasEndpoints&&(l.isConnected?e.compilationString+=e._declareOutput(m)+" = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2),`;
|
||
`):e.compilationString+=e._declareOutput(m)+" = ".concat(E,"(").concat(o.isConnected?this._writeVariable(o):"0.0",", ").concat(a.isConnected?this._writeVariable(a):"0.0",")").concat(this._buildSwizzle(2),`;
|
||
`))),this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.xSwizzle=this.xSwizzle,e.ySwizzle=this.ySwizzle,e.zSwizzle=this.zSwizzle,e.wSwizzle=this.wSwizzle,e},t.prototype._deserialize=function(e,n,i){var o,a,s,l;r.prototype._deserialize.call(this,e,n,i),this.xSwizzle=(o=e.xSwizzle)!==null&&o!==void 0?o:"x",this.ySwizzle=(a=e.ySwizzle)!==null&&a!==void 0?a:"y",this.zSwizzle=(s=e.zSwizzle)!==null&&s!==void 0?s:"z",this.wSwizzle=(l=e.wSwizzle)!==null&&l!==void 0?l:"w"},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+="".concat(this._codeVariableName,'.xSwizzle = "').concat(this.xSwizzle,`";
|
||
`),e+="".concat(this._codeVariableName,'.ySwizzle = "').concat(this.ySwizzle,`";
|
||
`),(e+="".concat(this._codeVariableName,'.zSwizzle = "').concat(this.zSwizzle,`";
|
||
`))+"".concat(this._codeVariableName,'.wSwizzle = "').concat(this.wSwizzle,`";
|
||
`)},t}(ut);(0,j.Y5)("BABYLON.VectorMergerBlock",es);var nh=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.sourceRange=new _.I9(-1,1),n.targetRange=new _.I9(0,1),n.registerInput("input",G.AutoDetect),n.registerInput("sourceMin",G.Float,!0),n.registerInput("sourceMax",G.Float,!0),n.registerInput("targetMin",G.Float,!0),n.registerInput("targetMax",G.Float,!0),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"RemapBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMin",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMax",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMin",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMax",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this.sourceMin.isConnected?this.sourceMin.associatedVariableName:this._writeFloat(this.sourceRange.x),o=this.sourceMax.isConnected?this.sourceMax.associatedVariableName:this._writeFloat(this.sourceRange.y),a=this.targetMin.isConnected?this.targetMin.associatedVariableName:this._writeFloat(this.targetRange.x),s=this.targetMax.isConnected?this.targetMax.associatedVariableName:this._writeFloat(this.targetRange.y);return e.compilationString+=e._declareOutput(n)+" = ".concat(a," + (").concat(this._inputs[0].associatedVariableName," - ").concat(i,") * (").concat(s," - ").concat(a,") / (").concat(o," - ").concat(i,`);
|
||
`),this},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".sourceRange = new BABYLON.Vector2(").concat(this.sourceRange.x,", ").concat(this.sourceRange.y,`);
|
||
`)+"".concat(this._codeVariableName,".targetRange = new BABYLON.Vector2(").concat(this.targetRange.x,", ").concat(this.targetRange.y,`);
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.sourceRange=this.sourceRange.asArray(),e.targetRange=this.targetRange.asArray(),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.sourceRange=_.I9.FromArray(e.sourceRange),this.targetRange=_.I9.FromArray(e.targetRange)},(0,A.Cg)([dt("From",3)],t.prototype,"sourceRange",void 0),(0,A.Cg)([dt("To",3)],t.prototype,"targetRange",void 0),t}(ut);(0,j.Y5)("BABYLON.RemapBlock",nh);var mi,ih=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n.output._typeConnectionSource=n.left,n._linkConnectionTypes(0,1,!0),n.left.acceptedConnectionPointTypes.push(G.Float),n.right.acceptedConnectionPointTypes.push(G.Float),n._connectionObservers=[n.left.onTypeChangedObservable.add(function(){return n._updateInputOutputTypes()}),n.right.onTypeChangedObservable.add(function(){return n._updateInputOutputTypes()})],n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._updateInputOutputTypes=function(){if(this.output._typeConnectionSource=this.left,this.left.isConnected&&this.right.isConnected?(this.left.type===G.Int||this.left.type===G.Float&&this.right.type!==G.Int)&&(this.output._typeConnectionSource=this.right):this.left.isConnected!==this.right.isConnected&&(this.output._typeConnectionSource=this.left.isConnected?this.left:this.right),this.left.isConnected||this.right.isConnected)for(var e=0,n=[[this.left,this.right],[this.right,this.left]];e<n.length;e++){var i=n[e],o=i[0],a=i[1];o.acceptedConnectionPointTypes=[G.Int,G.Float],a.isConnected&&(o.acceptedConnectionPointTypes.push(a.type),a.type!==G.Int&&a.type!==G.Float||o.acceptedConnectionPointTypes.push(G.Vector2,G.Vector3,G.Vector4,G.Color3,G.Color4,G.Matrix))}},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._connectionObservers.forEach(function(e){return e.remove()}),this._connectionObservers.length=0},t}(ut),ml=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MultiplyBlock"},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = ".concat(this.left.associatedVariableName," * ").concat(this.right.associatedVariableName,`;
|
||
`),this},t}(ih);(0,j.Y5)("BABYLON.MultiplyBlock",ml),function(r){r[r.Material=0]="Material",r[r.PostProcess=1]="PostProcess",r[r.Particle=2]="Particle",r[r.ProceduralTexture=3]="ProceduralTexture"}(mi||(mi={}));var rN=function(r){function t(){var e=r.call(this)||this;return e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.DITHER=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.EXPOSURE=!1,e.SKIPFINALCOLORCLAMP=!1,e.rebuild(),e}return(0,A.C6)(t,r),t}(si),Ei=function(){function r(t){this.animations=[],this.renderingGroupId=0,this.emitter=_.Pq.Zero(),this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.applyFog=!1,this._wasDispatched=!1,this._rootUrl="",this.noiseStrength=new _.Pq(10,10,10),this.onAnimationEnd=null,this.blendMode=r.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteCellLoop=!0,this.spriteRandomStartCell=!1,this.translationPivot=new _.I9(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new _.Pq(0,0,0),this._useLogarithmicDepth=!1,this.gravity=_.Pq.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new z.ov(1,1,1,1),this.color2=new z.ov(1,1,1,1),this.colorDead=new z.ov(0,0,0,1),this.textureMask=new z.ov(1,1,1,1),this._isSubEmitter=!1,this._billboardMode=P.Y.PARTICLES_BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new rN,this.id=t,this.name=t}return Object.defineProperty(r.prototype,"noiseTexture",{get:function(){return this._noiseTexture},set:function(t){this._noiseTexture!==t&&(this._noiseTexture=t,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(t){this._isAnimationSheetEnabled!=t&&(this._isAnimationSheetEnabled=t,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(t){this._useLogarithmicDepth=t&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!1,configurable:!0}),r.prototype.getScene=function(){return this._scene},r.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},r.prototype.getDragGradients=function(){return this._dragGradients},r.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},r.prototype.getColorGradients=function(){return this._colorGradients},r.prototype.getSizeGradients=function(){return this._sizeGradients},r.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},r.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},r.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},r.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},r.prototype.getVelocityGradients=function(){return this._velocityGradients},r.prototype.getStartSizeGradients=function(){return this._startSizeGradients},r.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(r.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:_.Pq.Zero()},set:function(t){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:_.Pq.Zero()},set:function(t){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:_.Pq.Zero()},set:function(t){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:_.Pq.Zero()},set:function(t){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(t){this._billboardMode!==t&&(this._billboardMode=t,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(t){this._isBillboardBased!==t&&(this._isBillboardBased=t,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(t){this._attachImageProcessingConfiguration(t)},enumerable:!1,configurable:!0}),r.prototype._attachImageProcessingConfiguration=function(t){t!==this._imageProcessingConfiguration&&(!t&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=t)},r.prototype._reset=function(){},r.prototype._removeGradientAndTexture=function(t,e,n){if(!e)return this;for(var i=0,o=0,a=e;o<a.length;o++){if(a[o].gradient===t){e.splice(i,1);break}i++}return n&&n.dispose(),this},r.prototype.createPointEmitter=function(t,e){throw new Error("Method not implemented.")},r.prototype.createHemisphericEmitter=function(t,e){throw new Error("Method not implemented.")},r.prototype.createSphereEmitter=function(t,e){throw new Error("Method not implemented.")},r.prototype.createDirectedSphereEmitter=function(t,e,n){throw e===void 0&&(e=new _.Pq(0,1,0)),n===void 0&&(n=new _.Pq(0,1,0)),new Error("Method not implemented.")},r.prototype.createCylinderEmitter=function(t,e,n,i){throw new Error("Method not implemented.")},r.prototype.createDirectedCylinderEmitter=function(t,e,n,i,o){throw i===void 0&&(i=new _.Pq(0,1,0)),o===void 0&&(o=new _.Pq(0,1,0)),new Error("Method not implemented.")},r.prototype.createConeEmitter=function(t,e){throw new Error("Method not implemented.")},r.prototype.createDirectedConeEmitter=function(t,e,n,i){throw n===void 0&&(n=new _.Pq(0,1,0)),i===void 0&&(i=new _.Pq(0,1,0)),new Error("Method not implemented.")},r.prototype.createBoxEmitter=function(t,e,n,i){throw new Error("Method not implemented.")},r.BLENDMODE_ONEONE=0,r.BLENDMODE_STANDARD=1,r.BLENDMODE_ADD=2,r.BLENDMODE_MULTIPLY=3,r.BLENDMODE_MULTIPLYADD=4,r}();(0,j.Y5)("BABYLON.BaseParticleSystem",Ei);var rh=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("rgba",G.Color4,!0),n.registerInput("rgb ",G.Color3,!0),n.registerOutput("rgb",G.Color3),n.registerOutput("r",G.Float),n.registerOutput("g",G.Float),n.registerOutput("b",G.Float),n.registerOutput("a",G.Float),n.inputsAreExclusive=!0,n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ColorSplitterBlock"},Object.defineProperty(t.prototype,"rgba",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return e==="rgb "?"rgbIn":e},t.prototype._outputRename=function(e){return e==="rgb"?"rgbOut":e},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.rgba.isConnected?this.rgba:this.rgbIn;if(n.isConnected){var i=this._outputs[0],o=this._outputs[1],a=this._outputs[2],s=this._outputs[3],l=this._outputs[4];return i.hasEndpoints&&(e.compilationString+=e._declareOutput(i)+" = ".concat(n.associatedVariableName,`.rgb;
|
||
`)),o.hasEndpoints&&(e.compilationString+=e._declareOutput(o)+" = ".concat(n.associatedVariableName,`.r;
|
||
`)),a.hasEndpoints&&(e.compilationString+=e._declareOutput(a)+" = ".concat(n.associatedVariableName,`.g;
|
||
`)),s.hasEndpoints&&(e.compilationString+=e._declareOutput(s)+" = ".concat(n.associatedVariableName,`.b;
|
||
`)),l.hasEndpoints&&(e.compilationString+=e._declareOutput(l)+" = ".concat(n.associatedVariableName,`.a;
|
||
`)),this}},t}(ut);(0,j.Y5)("BABYLON.ColorSplitterBlock",rh);var Vn,wx=L(53695),av=function(){function r(t){this.name=lt.v.NAME_PROCEDURALTEXTURE,this.scene=t,this.scene.proceduralTextures=[]}return r.prototype.register=function(){this.scene._beforeClearStage.registerStep(lt.v.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){ze.S0.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var t=0;t<this.scene.proceduralTextures.length;t++){var e=this.scene.proceduralTextures[t];e._shouldRender()&&e.render()}ze.S0.EndPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0)}},r}(),xr=function(r){function t(e,n,i,o,a,s,l,c){a===void 0&&(a=null),s===void 0&&(s=!0),l===void 0&&(l=!1),c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT);var u,d,h=this;(h=r.call(this,null,o,!s)||this).isEnabled=!0,h.autoClear=!0,h.onGeneratedObservable=new K.cP,h.onBeforeGenerationObservable=new K.cP,h.nodeMaterialSource=null,h.defines="",h._textures={},h._currentRefreshId=-1,h._frameId=-1,h._refreshRate=1,h._vertexBuffers={},h._uniforms=new Array,h._samplers=new Array,h._floats={},h._ints={},h._floatsArrays={},h._colors3={},h._colors4={},h._vectors2={},h._vectors3={},h._vectors4={},h._matrices={},h._fallbackTextureUsed=!1,h._cachedDefines=null,h._contentUpdateId=-1,h._rtWrapper=null,a===null||a instanceof Ie.g?(h._options={},h._fallbackTexture=a):(h._options=a,h._fallbackTexture=(u=a.fallbackTexture)!==null&&u!==void 0?u:null),h._shaderLanguage=(d=h._options.shaderLanguage)!==null&&d!==void 0?d:0;var p=(o=h.getScene()||Ve.q.LastCreatedScene)._getComponent(lt.v.NAME_PROCEDURALTEXTURE);p||(p=new av(o),o._addComponent(p)),o.proceduralTextures.push(h),h._fullEngine=o.getEngine(),h.name=e,h.isRenderTarget=!0,h._size=n,h._textureType=c,h._generateMipMaps=s,h._drawWrapper=new jn.E(h._fullEngine),h.setFragment(i);var m=h._createRtWrapper(l,n,s,c);h._texture=m.texture;var v=[];return v.push(1,1),v.push(-1,1),v.push(-1,-1),v.push(1,-1),h._vertexBuffers[Y.R.PositionKind]=new Y.R(h._fullEngine,v,Y.R.PositionKind,!1,!1,2),h._createIndexBuffer(),h}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),t.prototype._createRtWrapper=function(e,n,i,o){return e?(this._rtWrapper=this._fullEngine.createRenderTargetCubeTexture(n,(0,A.Cl)({generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:o},this._options)),this.setFloat("face",0)):(this._rtWrapper=this._fullEngine.createRenderTargetTexture(n,(0,A.Cl)({generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:o},this._options)),this._rtWrapper.is3D&&(this.setFloat("layer",0),this.setInt("layerNum",0))),this._rtWrapper},t.prototype.getEffect=function(){return this._drawWrapper.effect},t.prototype._setEffect=function(e){this._drawWrapper.effect=e},t.prototype.getContent=function(){var e=this;return this._contentData&&this._frameId===this._contentUpdateId||(this._contentData?this._contentData.then(function(n){e._contentData=e.readPixels(0,0,n),e._contentUpdateId=e._frameId}):(this._contentData=this.readPixels(0,0),this._contentUpdateId=this._frameId)),this._contentData},t.prototype._createIndexBuffer=function(){var e=this._fullEngine,n=[];n.push(0),n.push(1),n.push(2),n.push(0),n.push(2),n.push(3),this._indexBuffer=e.createIndexBuffer(n)},t.prototype._rebuild=function(){var e=this._vertexBuffers[Y.R.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===un.$.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=un.$.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){var e;(e=this._drawWrapper.effect)===null||e===void 0||e.dispose(),this._drawWrapper.effect=null,this._cachedDefines=null},t.prototype._getDefines=function(){return this.defines},t.prototype.executeWhenReady=function(e){var n=this;if(this.isReady())e(this);else{var i=this.getEffect();i&&i.executeWhenCompiled(function(){e(n)})}},t.prototype.isReady=function(){var e=this,n=this._fullEngine;if(this.nodeMaterialSource)return this._drawWrapper.effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;if(!this._texture)return!1;var i=this._getDefines();if(this._drawWrapper.effect&&i===this._cachedDefines&&this._drawWrapper.effect.isReady())return!0;var o={vertex:"procedural",fragmentElement:this._fragment.fragmentElement,fragmentSource:this._fragment.fragmentSource,fragment:typeof this._fragment=="string"?this._fragment:void 0};return this._cachedDefines!==i&&(this._cachedDefines=i,this._drawWrapper.effect=n.createEffect(o,[Y.R.PositionKind],this._uniforms,this._samplers,i,void 0,void 0,function(){var a;(a=e._rtWrapper)===null||a===void 0||a.dispose(),e._rtWrapper=e._texture=null,e._fallbackTexture&&(e._texture=e._fallbackTexture._texture,e._texture&&e._texture.incrementReferences()),e._fallbackTextureUsed=!0},void 0,this._shaderLanguage,function(){return(0,A.sH)(e,void 0,void 0,function(){return(0,A.YH)(this,function(a){switch(a.label){case 0:return this._options.extraInitializationsAsync?this.shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,67400)),this._options.extraInitializationsAsync()])]:[3,5];case 1:return a.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,6777)),this._options.extraInitializationsAsync()])];case 3:a.sent(),a.label=4;case 4:return[3,9];case 5:return this.shaderLanguage!==1?[3,7]:[4,Promise.resolve().then(L.bind(L,67400))];case 6:return a.sent(),[3,9];case 7:return[4,Promise.resolve().then(L.bind(L,6777))];case 8:a.sent(),a.label=9;case 9:return[2]}})})})),this._drawWrapper.effect.isReady()},t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},t.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!1,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(this._currentRefreshId===-1||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,this._frameId++,!0):(this._currentRefreshId++,!1)):(this._texture&&(this._texture.isReady=!1),!1)},t.prototype.getRenderSize=function(){return this._size},t.prototype.resize=function(e,n){if(!this._fallbackTextureUsed&&this._rtWrapper&&this._texture){var i=this._texture.isCube;this._rtWrapper.dispose();var o=this._createRtWrapper(i,e,n,this._textureType);this._texture=o.texture,this._size=e,this._generateMipMaps=n}},t.prototype._checkUniform=function(e){this._uniforms.indexOf(e)===-1&&this._uniforms.push(e)},t.prototype.setTexture=function(e,n){return this._samplers.indexOf(e)===-1&&this._samplers.push(e),this._textures[e]=n,this},t.prototype.setFloat=function(e,n){return this._checkUniform(e),this._floats[e]=n,this},t.prototype.setInt=function(e,n){return this._checkUniform(e),this._ints[e]=n,this},t.prototype.setFloats=function(e,n){return this._checkUniform(e),this._floatsArrays[e]=n,this},t.prototype.setColor3=function(e,n){return this._checkUniform(e),this._colors3[e]=n,this},t.prototype.setColor4=function(e,n){return this._checkUniform(e),this._colors4[e]=n,this},t.prototype.setVector2=function(e,n){return this._checkUniform(e),this._vectors2[e]=n,this},t.prototype.setVector3=function(e,n){return this._checkUniform(e),this._vectors3[e]=n,this},t.prototype.setVector4=function(e,n){return this._checkUniform(e),this._vectors4[e]=n,this},t.prototype.setMatrix=function(e,n){return this._checkUniform(e),this._matrices[e]=n,this},t.prototype.render=function(e){var n,i,o,a,s=this.getScene();if(s){var l=this._fullEngine;if(l.enableEffect(this._drawWrapper),this.onBeforeGenerationObservable.notifyObservers(this),l.setState(!1),!this.nodeMaterialSource){for(var c in this._textures)this._drawWrapper.effect.setTexture(c,this._textures[c]);for(var u in this._ints)this._drawWrapper.effect.setInt(u,this._ints[u]);for(var d in this._floats)this._drawWrapper.effect.setFloat(d,this._floats[d]);for(var h in this._floatsArrays)this._drawWrapper.effect.setArray(h,this._floatsArrays[h]);for(var p in this._colors3)this._drawWrapper.effect.setColor3(p,this._colors3[p]);for(var m in this._colors4){var v=this._colors4[m];this._drawWrapper.effect.setFloat4(m,v.r,v.g,v.b,v.a)}for(var b in this._vectors2)this._drawWrapper.effect.setVector2(b,this._vectors2[b]);for(var E in this._vectors3)this._drawWrapper.effect.setVector3(E,this._vectors3[E]);for(var C in this._vectors4)this._drawWrapper.effect.setVector4(C,this._vectors4[C]);for(var T in this._matrices)this._drawWrapper.effect.setMatrix(T,this._matrices[T])}if(this._texture&&this._rtWrapper){(n=l._debugPushGroup)===null||n===void 0||n.call(l,"procedural texture generation for ".concat(this.name),1);var f=l.currentViewport;if(this.isCube)for(var g=0;g<6;g++)l.bindFramebuffer(this._rtWrapper,g,void 0,void 0,!0),l.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._drawWrapper.effect.setFloat("face",g),this.autoClear&&l.clear(s.clearColor,!0,!1,!1),l.drawElementsType(Lt.TriangleFillMode,0,6),l.unBindFramebuffer(this._rtWrapper,!0);else{var S=1;this._rtWrapper.is3D?S=this._rtWrapper.depth:this._rtWrapper.is2DArray&&(S=this._rtWrapper.layers);for(var y=0;y<S;y++){if(l.bindFramebuffer(this._rtWrapper,0,void 0,void 0,!0,0,y),l.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._rtWrapper.is3D||this._rtWrapper.is2DArray)for(var x in(i=this._drawWrapper.effect)===null||i===void 0||i.setFloat("layer",S!==1?y/(S-1):0),(o=this._drawWrapper.effect)===null||o===void 0||o.setInt("layerNum",y),this._textures)this._drawWrapper.effect.setTexture(x,this._textures[x]);this.autoClear&&l.clear(s.clearColor,!0,!1,!1),l.drawElementsType(Lt.TriangleFillMode,0,6),l.unBindFramebuffer(this._rtWrapper,!this._generateMipMaps)}}f&&l.setViewport(f),this.isCube&&l.generateMipMapsForCubemap(this._texture,!0),(a=l._debugPopGroup)===null||a===void 0||a.call(l,1),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),n=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.coordinatesMode=this.coordinatesMode,n},t.prototype.dispose=function(){var e=this.getScene();if(e){var n=e.proceduralTextures.indexOf(this);n>=0&&e.proceduralTextures.splice(n,1);var i=this._vertexBuffers[Y.R.PositionKind];i&&(i.dispose(),this._vertexBuffers[Y.R.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),r.prototype.dispose.call(this)}},(0,A.Cg)([(0,V.lK)()],t.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"autoClear",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_generateMipMaps",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_size",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"refreshRate",null),t}(Ie.g);(0,j.Y5)("BABYLON.ProceduralTexture",xr),function(r){r[r.Cos=0]="Cos",r[r.Sin=1]="Sin",r[r.Abs=2]="Abs",r[r.Exp=3]="Exp",r[r.Exp2=4]="Exp2",r[r.Round=5]="Round",r[r.Floor=6]="Floor",r[r.Ceiling=7]="Ceiling",r[r.Sqrt=8]="Sqrt",r[r.Log=9]="Log",r[r.Tan=10]="Tan",r[r.ArcTan=11]="ArcTan",r[r.ArcCos=12]="ArcCos",r[r.ArcSin=13]="ArcSin",r[r.Fract=14]="Fract",r[r.Sign=15]="Sign",r[r.Radians=16]="Radians",r[r.Degrees=17]="Degrees",r[r.Set=18]="Set"}(Vn||(Vn={}));var oh=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.operation=Vn.Cos,n.registerInput("input",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TrigonometryBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i="";switch(this.operation){case Vn.Cos:i="cos";break;case Vn.Sin:i="sin";break;case Vn.Abs:i="abs";break;case Vn.Exp:i="exp";break;case Vn.Exp2:i="exp2";break;case Vn.Round:i="round";break;case Vn.Floor:i="floor";break;case Vn.Ceiling:i="ceil";break;case Vn.Sqrt:i="sqrt";break;case Vn.Log:i="log";break;case Vn.Tan:i="tan";break;case Vn.ArcTan:i="atan";break;case Vn.ArcCos:i="acos";break;case Vn.ArcSin:i="asin";break;case Vn.Fract:i="fract";break;case Vn.Sign:i="sign";break;case Vn.Radians:i="radians";break;case Vn.Degrees:i="degrees";break;case Vn.Set:i=""}return e.compilationString+=e._declareOutput(n)+" = ".concat(i,"(").concat(this.input.associatedVariableName,`);
|
||
`),this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.operation=this.operation,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.operation=e.operation},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".operation = BABYLON.TrigonometryBlockOperations.").concat(Vn[this.operation],`;
|
||
`)},t}(ut);(0,j.Y5)("BABYLON.TrigonometryBlock",oh);var ar,ah,sv={effect:null,subMesh:null},ts=function(r){function t(){var e=r.call(this)||this;return e.NORMAL=!1,e.TANGENT=!1,e.VERTEXCOLOR_NME=!1,e.UV1=!1,e.UV2=!1,e.UV3=!1,e.UV4=!1,e.UV5=!1,e.UV6=!1,e.PREPASS=!1,e.PREPASS_NORMAL=!1,e.PREPASS_NORMAL_INDEX=-1,e.PREPASS_WORLD_NORMAL=!1,e.PREPASS_WORLD_NORMAL_INDEX=-1,e.PREPASS_POSITION=!1,e.PREPASS_POSITION_INDEX=-1,e.PREPASS_LOCAL_POSITION=!1,e.PREPASS_LOCAL_POSITION_INDEX=-1,e.PREPASS_DEPTH=!1,e.PREPASS_DEPTH_INDEX=-1,e.PREPASS_SCREENSPACE_DEPTH=!1,e.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,e.SCENE_MRT_COUNT=0,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE=!1,e.MORPHTARGETS=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_TANGENT=!1,e.MORPHTARGETS_UV=!1,e.NUM_MORPH_INFLUENCERS=0,e.MORPHTARGETS_TEXTURE=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.DITHER=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.SKIPFINALCOLORCLAMP=!1,e.BUMPDIRECTUV=0,e.CAMERA_ORTHOGRAPHIC=!1,e.CAMERA_PERSPECTIVE=!1,e.rebuild(),e}return(0,A.C6)(t,r),t.prototype.setValue=function(e,n,i){i===void 0&&(i=!1),this[e]===void 0&&this._keys.push(e),i&&this[e]!==n&&this.markAsUnprocessed(),this[e]=n},t}(si),so=function(r){function t(e,n,i){i===void 0&&(i={});var o=r.call(this,e,n||Ve.q.LastCreatedScene)||this;if(o._buildId=t._BuildIdGenerator++,o._buildWasSuccessful=!1,o._cachedWorldViewMatrix=new _.uq,o._cachedWorldViewProjectionMatrix=new _.uq,o._optimizers=new Array,o._animationFrame=-1,o._buildIsInProgress=!1,o.BJSNODEMATERIALEDITOR=o._getGlobalNodeMaterialEditor(),o.editorData=null,o.ignoreAlpha=!1,o.maxSimultaneousLights=4,o.onBuildObservable=new K.cP,o.onBuildErrorObservable=new K.cP,o._vertexOutputNodes=new Array,o._fragmentOutputNodes=new Array,o.attachedBlocks=[],o._mode=mi.Material,o.forceAlphaBlending=!1,i&&i.shaderLanguage===1&&!o.getScene().getEngine().isWebGPU)throw new Error("WebGPU shader language is only supported with WebGPU engine");return o._options=(0,A.Cl)({emitComments:!1,shaderLanguage:t.DefaultShaderLanguage},i),o._attachImageProcessingConfiguration(null),o}return(0,A.C6)(t,r),t._BlockIsTextureBlock=function(e){return e.getClassName()==="TextureBlock"||e.getClassName()==="ReflectionTextureBaseBlock"||e.getClassName()==="ReflectionTextureBlock"||e.getClassName()==="ReflectionBlock"||e.getClassName()==="RefractionBlock"||e.getClassName()==="CurrentScreenBlock"||e.getClassName()==="ParticleTextureBlock"||e.getClassName()==="ImageSourceBlock"||e.getClassName()==="TriPlanarBlock"||e.getClassName()==="BiPlanarBlock"||e.getClassName()==="PrePassTextureBlock"},t.prototype._getGlobalNodeMaterialEditor=function(){return typeof NODEEDITOR<"u"?NODEEDITOR:typeof BABYLON<"u"&&BABYLON.NodeEditor!==void 0?BABYLON:void 0},Object.defineProperty(t.prototype,"shaderLanguage",{get:function(){return this._options.shaderLanguage},set:function(e){this._options.shaderLanguage=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buildId",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"NodeMaterial"},t.prototype._attachImageProcessingConfiguration=function(e){var n=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){n._markAllSubMeshesAsImageProcessingDirty()})))},t.prototype.getBlockByName=function(e){for(var n=null,i=0,o=this.attachedBlocks;i<o.length;i++){var a=o[i];if(a.name===e){if(n)return ze.S0.Warn("More than one block was found with the name `"+e+"`"),n;n=a}}return n},t.prototype.getBlockByPredicate=function(e){for(var n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];if(e(o))return o}return null},t.prototype.getInputBlockByPredicate=function(e){for(var n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];if(o.isInput&&e(o))return o}return null},t.prototype.getInputBlocks=function(){for(var e=[],n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];o.isInput&&e.push(o)}return e},t.prototype.registerOptimizer=function(e){if(!(this._optimizers.indexOf(e)>-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var n=this._optimizers.indexOf(e);if(n!==-1)return this._optimizers.splice(n,1),this},t.prototype.addOutputNode=function(e){if(e.target===null)throw"This node is not meant to be an output node. You may want to explicitly set its target value.";return e.target&_e.Vertex&&this._addVertexOutputNode(e),e.target&_e.Fragment&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return e.target===null||(e.target&_e.Vertex&&this._removeVertexOutputNode(e),e.target&_e.Fragment&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(this._vertexOutputNodes.indexOf(e)===-1)return e.target=_e.Vertex,this._vertexOutputNodes.push(e),this},t.prototype._removeVertexOutputNode=function(e){var n=this._vertexOutputNodes.indexOf(e);if(n!==-1)return this._vertexOutputNodes.splice(n,1),this},t.prototype._addFragmentOutputNode=function(e){if(this._fragmentOutputNodes.indexOf(e)===-1)return e.target=_e.Fragment,this._fragmentOutputNodes.push(e),this},t.prototype._removeFragmentOutputNode=function(e){var n=this._fragmentOutputNodes.indexOf(e);if(n!==-1)return this._fragmentOutputNodes.splice(n,1),this},t.prototype.needAlphaBlending=function(){return!this.ignoreAlpha&&(this.forceAlphaBlending||this.alpha<1||this._sharedData&&this._sharedData.hints.needAlphaBlending)},t.prototype.needAlphaTesting=function(){return this._sharedData&&this._sharedData.hints.needAlphaTesting},t.prototype._processInitializeOnLink=function(e,n,i,o){o===void 0&&(o=!0),(e.target===_e.VertexAndFragment||n.target===_e.Fragment&&e.target===_e.Vertex&&e._preparationId!==this._buildId)&&i.push(e),this._initializeBlock(e,n,i,o)},t.prototype._initializeBlock=function(e,n,i,o){if(o===void 0&&(o=!0),e.initialize(n),o&&e.autoConfigure(this),e._preparationId=this._buildId,this.attachedBlocks.indexOf(e)===-1){if(e.isUnique){for(var a=e.getClassName(),s=0,l=this.attachedBlocks;s<l.length;s++)if(l[s].getClassName()===a)throw"Cannot have multiple blocks of type ".concat(a," in the same NodeMaterial")}this.attachedBlocks.push(e)}for(var c=0,u=e.inputs;c<u.length;c++){var d=u[c];d.associatedVariableName="";var h=d.connectedPoint;if(h){var p=h.ownerBlock;p!==e&&this._processInitializeOnLink(p,n,i,o)}}if(e.isTeleportOut){var m=e;m.entryPoint&&this._processInitializeOnLink(m.entryPoint,n,i,o)}for(var v=0,b=e.outputs;v<b.length;v++)b[v].associatedVariableName=""},t.prototype._resetDualBlocks=function(e,n){e.target===_e.VertexAndFragment&&(e.buildId=n);for(var i=0,o=e.inputs;i<o.length;i++){var a=o[i].connectedPoint;if(a){var s=a.ownerBlock;s!==e&&this._resetDualBlocks(s,n)}}if(e.isTeleportOut){var l=e;l.entryPoint&&this._resetDualBlocks(l.entryPoint,n)}},t.prototype.removeBlock=function(e){var n=this.attachedBlocks.indexOf(e);n>-1&&this.attachedBlocks.splice(n,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e,n,i){var o=this;if(e===void 0&&(e=!1),n===void 0&&(n=!0),i===void 0&&(i=!1),this._buildIsInProgress)O.V.Warn("Build is already in progress, You can use NodeMaterial.onBuildObservable to determine when the build is completed.");else{this._buildIsInProgress=!0,this._vertexCompilationState||i||(i=!0),this._buildWasSuccessful=!1;var a=this.getScene().getEngine(),s=this._mode===mi.Particle;if(this._vertexOutputNodes.length===0&&!s)throw"You must define at least one vertexOutputNode";if(this._fragmentOutputNodes.length===0)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new Nx,this._vertexCompilationState.supportUniformBuffers=a.supportsUniformBuffers,this._vertexCompilationState.target=_e.Vertex,this._fragmentCompilationState=new Nx,this._fragmentCompilationState.supportUniformBuffers=a.supportsUniformBuffers,this._fragmentCompilationState.target=_e.Fragment,this._sharedData=new nN,this._sharedData.nodeMaterial=this,this._sharedData.fragmentOutputNodes=this._fragmentOutputNodes,this._vertexCompilationState.sharedData=this._sharedData,this._fragmentCompilationState.sharedData=this._sharedData,this._sharedData.buildId=this._buildId,this._sharedData.emitComments=this._options.emitComments,this._sharedData.verbose=e,this._sharedData.scene=this.getScene(),this._sharedData.allowEmptyVertexProgram=s;for(var l=[],c=[],u=0,d=this._vertexOutputNodes;u<d.length;u++){var h=d[u];l.push(h),this._initializeBlock(h,this._vertexCompilationState,c,i)}for(var p=0,m=this._fragmentOutputNodes;p<m.length;p++){var v=m[p];c.push(v),this._initializeBlock(v,this._fragmentCompilationState,l,i)}for(var b=0,E=0,C=this.attachedBlocks;E<C.length;E++){var T=C[E];T.codeIsReady||(b++,T.onCodeIsReadyObservable.addOnce(function(){--b==0&&o._finishBuildProcess(e,n,l,c)}))}b===0&&this._finishBuildProcess(e,n,l,c)}},t.prototype._finishBuildProcess=function(e,n,i,o){e===void 0&&(e=!1),n===void 0&&(n=!0),this.optimize();for(var a=0,s=i;a<s.length;a++)s[a].build(this._vertexCompilationState,i);this._fragmentCompilationState.uniforms=this._vertexCompilationState.uniforms.slice(0),this._fragmentCompilationState._uniformDeclaration=this._vertexCompilationState._uniformDeclaration,this._fragmentCompilationState._constantDeclaration=this._vertexCompilationState._constantDeclaration,this._fragmentCompilationState._vertexState=this._vertexCompilationState;for(var l=0,c=o;l<c.length;l++){var u=c[l];this._resetDualBlocks(u,this._buildId-1)}for(var d=0,h=o;d<h.length;d++)(u=h[d]).build(this._fragmentCompilationState,o);this._vertexCompilationState.finalize(this._vertexCompilationState),this._fragmentCompilationState.finalize(this._fragmentCompilationState),n&&(this._buildId=t._BuildIdGenerator++);var p=this._sharedData.emitErrors(this.onBuildErrorObservable);e&&(O.V.Log("Vertex shader:"),O.V.Log(this._vertexCompilationState.compilationString),O.V.Log("Fragment shader:"),O.V.Log(this._fragmentCompilationState.compilationString)),this._buildIsInProgress=!1,this._buildWasSuccessful=!0,p&&this.onBuildObservable.notifyObservers(this);for(var m=0,v=this.getScene().meshes;m<v.length;m++){var b=v[m];if(b.subMeshes)for(var E=0,C=b.subMeshes;E<C.length;E++){var T=C[E];if(T.getMaterial()===this&&T.materialDefines){var f=T.materialDefines;f.markAllAsDirty(),f.reset()}}}this.prePassTextureInputs.length&&this.getScene().enablePrePassRenderer();var g=this.getScene().prePassRenderer;g&&g.markAsDirty()},t.prototype.optimize=function(){for(var e=0,n=this._optimizers;e<n.length;e++)n[e].optimize(this._vertexOutputNodes,this._fragmentOutputNodes)},t.prototype._prepareDefinesForAttributes=function(e,n){var i=n.NORMAL,o=n.TANGENT,a=n.VERTEXCOLOR_NME;n.NORMAL=e.isVerticesDataPresent(Y.R.NormalKind),n.TANGENT=e.isVerticesDataPresent(Y.R.TangentKind);var s=e.useVertexColors&&e.isVerticesDataPresent(Y.R.ColorKind);n.VERTEXCOLOR_NME=s;for(var l=!1,c=1;c<=P.Y.MAX_SUPPORTED_UV_SETS;++c){var u=n["UV"+c];n["UV"+c]=e.isVerticesDataPresent("uv".concat(c===1?"":c)),l=l||n["UV"+c]!==u}var d=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;(0,Re.N4)(this.getScene(),n,!d),(i!==n.NORMAL||o!==n.TANGENT||a!==n.VERTEXCOLOR_NME||l)&&n.markAsAttributesDirty()},Object.defineProperty(t.prototype,"isPrePassCapable",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"prePassTextureOutputs",{get:function(){var e=this.getBlockByPredicate(function(i){return i.getClassName()==="PrePassOutputBlock"}),n=[P.Y.PREPASS_COLOR_TEXTURE_TYPE];return e&&(this.prePassTextureInputs.length||(e.viewDepth.isConnected&&n.push(P.Y.PREPASS_DEPTH_TEXTURE_TYPE),e.screenDepth.isConnected&&n.push(P.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE),e.viewNormal.isConnected&&n.push(P.Y.PREPASS_NORMAL_TEXTURE_TYPE),e.worldNormal.isConnected&&n.push(P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE),e.worldPosition.isConnected&&n.push(P.Y.PREPASS_POSITION_TEXTURE_TYPE))),n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"prePassTextureInputs",{get:function(){for(var e=this.getAllTextureBlocks().filter(function(s){return s.getClassName()==="PrePassTextureBlock"}),n=[],i=0,o=e;i<o.length;i++){var a=o[i];a.position.isConnected&&!n.includes(P.Y.PREPASS_POSITION_TEXTURE_TYPE)&&n.push(P.Y.PREPASS_POSITION_TEXTURE_TYPE),a.localPosition.isConnected&&!n.includes(P.Y.PREPASS_LOCAL_POSITION_TEXTURE_TYPE)&&n.push(P.Y.PREPASS_LOCAL_POSITION_TEXTURE_TYPE),a.depth.isConnected&&!n.includes(P.Y.PREPASS_DEPTH_TEXTURE_TYPE)&&n.push(P.Y.PREPASS_DEPTH_TEXTURE_TYPE),a.screenDepth.isConnected&&!n.includes(P.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE)&&n.push(P.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE),a.normal.isConnected&&!n.includes(P.Y.PREPASS_NORMAL_TEXTURE_TYPE)&&n.push(P.Y.PREPASS_NORMAL_TEXTURE_TYPE),a.worldNormal.isConnected&&!n.includes(P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE)&&n.push(P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE)}return n},enumerable:!1,configurable:!0}),t.prototype.setPrePassRenderer=function(e){var n=this.prePassTextureInputs.concat(this.prePassTextureOutputs);if(e&&n.length>1){var i=e.getEffectConfiguration("nodeMaterial");i||(i=e.addEffectConfiguration({enabled:!0,needsImageProcessing:!1,name:"nodeMaterial",texturesRequired:[]}));for(var o=0,a=n;o<a.length;o++){var s=a[o];i.texturesRequired.includes(s)||i.texturesRequired.push(s)}i.enabled=!0}return n.length>1},t.prototype.createPostProcess=function(e,n,i,o,a,s,l){return n===void 0&&(n=1),i===void 0&&(i=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),s===void 0&&(s=P.Y.TEXTURETYPE_UNSIGNED_INT),l===void 0&&(l=P.Y.TEXTUREFORMAT_RGBA),this.mode!==mi.PostProcess?(O.V.Log("Incompatible material mode"),null):this._createEffectForPostProcess(null,e,n,i,o,a,s,l)},t.prototype.createEffectForPostProcess=function(e){this._createEffectForPostProcess(e)},t.prototype._createEffectForPostProcess=function(e,n,i,o,a,s,l,c){var u=this;i===void 0&&(i=1),o===void 0&&(o=P.Y.TEXTURE_NEAREST_SAMPLINGMODE),l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT),c===void 0&&(c=P.Y.TEXTUREFORMAT_RGBA);var d=this.name+this._buildId,h=new ts,p=new xe(d+"PostProcess",this.getScene()),m=this._buildId;return this._processDefines(p,h),ti.M.RegisterShader(d,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString,this.shaderLanguage),e?e.updateEffect(h.toString(),this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,{maxSimultaneousLights:this.maxSimultaneousLights},void 0,void 0,d,d):e=new _t.w(this.name+"PostProcess",d,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,n,o,a,s,h.toString(),l,d,{maxSimultaneousLights:this.maxSimultaneousLights},!1,c,this.shaderLanguage),e.nodeMaterialSource=this,e.onApplyObservable.add(function(v){m!==u._buildId&&(delete ti.M.ShadersStore[d+"VertexShader"],delete ti.M.ShadersStore[d+"PixelShader"],d=u.name+u._buildId,h.markAllAsDirty(),m=u._buildId),u._processDefines(p,h)&&(ti.M.RegisterShader(d,u._fragmentCompilationState._builtCompilationString,u._vertexCompilationState._builtCompilationString),wx._.SetImmediate(function(){return e.updateEffect(h.toString(),u._fragmentCompilationState.uniforms,u._fragmentCompilationState.samplers,{maxSimultaneousLights:u.maxSimultaneousLights},void 0,void 0,d,d)})),u._checkInternals(v)}),e},t.prototype.createProceduralTexture=function(e,n){var i=this;if(this.mode!==mi.ProceduralTexture)return O.V.Log("Incompatible material mode"),null;var o=this.name+this._buildId,a=new xr(o,e,null,n),s=new xe(o+"Procedural",this.getScene());s.reservedDataStore={hidden:!0};var l=new ts,c=this._processDefines(s,l);ti.M.RegisterShader(o,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString,this.shaderLanguage);var u=this.getScene().getEngine().createEffect({vertexElement:o,fragmentElement:o},[Y.R.PositionKind],this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,l.toString(),c?.fallbacks,void 0,void 0,void 0,this.shaderLanguage);a.nodeMaterialSource=this,a._setEffect(u);var d=this._buildId,h=function(){d!==i._buildId&&(delete ti.M.ShadersStore[o+"VertexShader"],delete ti.M.ShadersStore[o+"PixelShader"],o=i.name+i._buildId,l.markAllAsDirty(),d=i._buildId);var p=i._processDefines(s,l);p&&(ti.M.RegisterShader(o,i._fragmentCompilationState._builtCompilationString,i._vertexCompilationState._builtCompilationString,i.shaderLanguage),wx._.SetImmediate(function(){u=i.getScene().getEngine().createEffect({vertexElement:o,fragmentElement:o},[Y.R.PositionKind],i._fragmentCompilationState.uniforms,i._fragmentCompilationState.samplers,l.toString(),p?.fallbacks,void 0),a._setEffect(u)})),i._checkInternals(u)};return a.onBeforeGenerationObservable.add(function(){h()}),this.onBuildObservable.add(function(){h()}),a},t.prototype._createEffectForParticles=function(e,n,i,o,a,s,l,c){var u=this;c===void 0&&(c="");var d=this.name+this._buildId+"_"+n;s||(s=new ts),l||(l=this.getScene().getMeshByName(this.name+"Particle"))||((l=new xe(this.name+"Particle",this.getScene())).reservedDataStore={hidden:!0});var h=this._buildId,p=[],m=c;if(!a){var v=this._processDefines(l,s);ti.M.RegisterShader(d,this._fragmentCompilationState._builtCompilationString,void 0,this.shaderLanguage),e.fillDefines(p,n,!1),m=p.join(`
|
||
`),a=this.getScene().getEngine().createEffectForParticles(d,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,s.toString()+`
|
||
`+m,v?.fallbacks,i,o,e,this.shaderLanguage),e.setCustomEffect(a,n)}a.onBindObservable.add(function(b){h!==u._buildId&&(delete ti.M.ShadersStore[d+"PixelShader"],d=u.name+u._buildId+"_"+n,s.markAllAsDirty(),h=u._buildId),p.length=0,e.fillDefines(p,n,!1);var E=p.join(`
|
||
`);E!==m&&(s.markAllAsDirty(),m=E);var C=u._processDefines(l,s);if(C)return ti.M.RegisterShader(d,u._fragmentCompilationState._builtCompilationString,void 0,u.shaderLanguage),b=u.getScene().getEngine().createEffectForParticles(d,u._fragmentCompilationState.uniforms,u._fragmentCompilationState.samplers,s.toString()+`
|
||
`+m,C?.fallbacks,i,o,e),e.setCustomEffect(b,n),void u._createEffectForParticles(e,n,i,o,b,s,l,c);u._checkInternals(b)})},t.prototype._checkInternals=function(e){if(this._sharedData.animatedInputs){var n=this.getScene(),i=n.getFrameId();if(this._animationFrame!==i){for(var o=0,a=this._sharedData.animatedInputs;o<a.length;o++)a[o].animate(n);this._animationFrame=i}}for(var s=0,l=this._sharedData.bindableBlocks;s<l.length;s++)l[s].bind(e,this);for(var c=0,u=this._sharedData.inputBlocks;c<u.length;c++)u[c]._transmit(e,this.getScene(),this)},t.prototype.createEffectForParticles=function(e,n,i){this.mode===mi.Particle?(this._createEffectForParticles(e,Ei.BLENDMODE_ONEONE,n,i),this._createEffectForParticles(e,Ei.BLENDMODE_MULTIPLY,n,i)):O.V.Log("Incompatible material mode")},t.prototype.createAsShadowDepthWrapper=function(e){this.mode===mi.Material?e.shadowDepthWrapper=new BABYLON.ShadowDepthWrapper(this,this.getScene()):O.V.Log("Incompatible material mode")},t.prototype._processDefines=function(e,n,i,o){var a=this;i===void 0&&(i=!1);var s=null,l=this.getScene();if((0,Re.Y7)(l,n)&&n.markAsMiscDirty(),this._sharedData.blocksWithDefines.forEach(function(m){m.initializeDefines(e,a,n,i)}),this._sharedData.blocksWithDefines.forEach(function(m){m.prepareDefines(e,a,n,i,o)}),n.isDirty){var c=n._areLightsDisposed;n.markAsProcessed(),this._vertexCompilationState.compilationString=this._vertexCompilationState._builtCompilationString,this._fragmentCompilationState.compilationString=this._fragmentCompilationState._builtCompilationString,this._sharedData.repeatableContentBlocks.forEach(function(m){m.replaceRepeatableContent(a._vertexCompilationState,a._fragmentCompilationState,e,n)});var u=[];this._sharedData.dynamicUniformBlocks.forEach(function(m){m.updateUniformsAndSamples(a._vertexCompilationState,a,n,u)});var d=this._vertexCompilationState.uniforms;this._fragmentCompilationState.uniforms.forEach(function(m){d.indexOf(m)===-1&&d.push(m)});var h=this._vertexCompilationState.samplers;this._fragmentCompilationState.samplers.forEach(function(m){h.indexOf(m)===-1&&h.push(m)});var p=new Tr;this._sharedData.blocksWithFallbacks.forEach(function(m){m.provideFallbacks(e,p)}),s={lightDisposed:c,uniformBuffers:u,mergedUniforms:d,mergedSamplers:h,fallbacks:p}}return s},t.prototype.isReadyForSubMesh=function(e,n,i){var o=this;if(i===void 0&&(i=!1),!this._buildWasSuccessful)return!1;var a=this.getScene();if(this._sharedData.animatedInputs){var s=a.getFrameId();if(this._animationFrame!==s){for(var l=0,c=this._sharedData.animatedInputs;l<c.length;l++)c[l].animate(a);this._animationFrame=s}}var u=n._drawWrapper;if(u.effect&&this.isFrozen&&u._wasPreviouslyReady&&u._wasPreviouslyUsingInstances===i)return!0;n.materialDefines||(n.materialDefines=new ts);var d=n.materialDefines;if(this._isReadyForSubMesh(n))return!0;var h=a.getEngine();if(this._prepareDefinesForAttributes(e,d),this._sharedData.blockingBlocks.some(function(E){return!E.isReady(e,o,d,i)}))return!1;var p=this._processDefines(e,d,i,n);if(p){var m=n.effect,v=d.toString(),b=h.createEffect({vertex:"nodeMaterial"+this._buildId,fragment:"nodeMaterial"+this._buildId,vertexSource:this._vertexCompilationState.compilationString,fragmentSource:this._fragmentCompilationState.compilationString},{attributes:this._vertexCompilationState.attributes,uniformsNames:p.mergedUniforms,uniformBuffersNames:p.uniformBuffers,samplers:p.mergedSamplers,defines:v,fallbacks:p.fallbacks,onCompiled:this.onCompiled,onError:this.onError,multiTarget:d.PREPASS,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights,maxSimultaneousMorphTargets:d.NUM_MORPH_INFLUENCERS},shaderLanguage:this.shaderLanguage},h);if(b)if(this._onEffectCreatedObservable&&(sv.effect=b,sv.subMesh=n,this._onEffectCreatedObservable.notifyObservers(sv)),this.allowShaderHotSwapping&&m&&!b.isReady()){if(b=m,d.markAsUnprocessed(),p.lightDisposed)return d._areLightsDisposed=!0,!1}else a.resetCachedMaterial(),n.setEffect(b,d,this._materialContext)}return!(!n.effect||!n.effect.isReady()||(d._renderId=a.getRenderId(),u._wasPreviouslyReady=!0,u._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),0))},Object.defineProperty(t.prototype,"compiledShaders",{get:function(){return`// Vertex shader
|
||
`.concat(this._vertexCompilationState.compilationString,`
|
||
|
||
// Fragment shader
|
||
`).concat(this._fragmentCompilationState.compilationString)},enumerable:!1,configurable:!0}),t.prototype.bindOnlyWorldMatrix=function(e){var n=this.getScene();if(this._activeEffect){var i=this._sharedData.hints;i.needWorldViewMatrix&&e.multiplyToRef(n.getViewMatrix(),this._cachedWorldViewMatrix),i.needWorldViewProjectionMatrix&&e.multiplyToRef(n.getTransformMatrix(),this._cachedWorldViewProjectionMatrix);for(var o=0,a=this._sharedData.inputBlocks;o<a.length;o++)a[o]._transmitWorld(this._activeEffect,e,this._cachedWorldViewMatrix,this._cachedWorldViewProjectionMatrix)}},t.prototype.bindForSubMesh=function(e,n,i){var o=this.getScene(),a=i.effect;if(a){this._activeEffect=a,this.bindOnlyWorldMatrix(e);var s=this._mustRebind(o,a,i,n.visibility),l=this._sharedData;if(s){for(var c=0,u=l.bindableBlocks;c<u.length;c++)u[c].bind(a,this,n,i);for(var d=0,h=l.forcedBindableBlocks;d<h.length;d++)h[d].bind(a,this,n,i);for(var p=0,m=l.inputBlocks;p<m.length;p++)m[p]._transmit(a,o,this)}else if(!this.isFrozen)for(var v=0,b=l.forcedBindableBlocks;v<b.length;v++)b[v].bind(a,this,n,i);this._afterBind(n,this._activeEffect,i)}},t.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._sharedData&&e.push.apply(e,this._sharedData.textureBlocks.filter(function(n){return n.texture}).map(function(n){return n.texture})),e},t.prototype.getTextureBlocks=function(){return this._sharedData?this._sharedData.textureBlocks:[]},t.prototype.getAllTextureBlocks=function(){for(var e=[],n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];t._BlockIsTextureBlock(o)&&e.push(o)}return e},t.prototype.hasTexture=function(e){if(r.prototype.hasTexture.call(this,e))return!0;if(!this._sharedData)return!1;for(var n=0,i=this._sharedData.textureBlocks;n<i.length;n++)if(i[n].texture===e)return!0;return!1},t.prototype.dispose=function(e,n,i){if(n)for(var o=0,a=this.getTextureBlocks().filter(function(c){return c.texture}).map(function(c){return c.texture});o<a.length;o++)a[o].dispose();for(var s=0,l=this.attachedBlocks;s<l.length;s++)l[s].dispose();this.attachedBlocks.length=0,this._sharedData=null,this._vertexCompilationState=null,this._fragmentCompilationState=null,this.onBuildObservable.clear(),this.onBuildErrorObservable.clear(),this._imageProcessingObserver&&(this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingObserver=null),r.prototype.dispose.call(this,e,n,i)},t.prototype._createNodeEditor=function(e){var n=(0,A.Cl)({nodeMaterial:this},e);this.BJSNODEMATERIALEDITOR.NodeEditor.Show(n)},t.prototype.edit=function(e){var n=this;return new Promise(function(i){if(n.BJSNODEMATERIALEDITOR=n.BJSNODEMATERIALEDITOR||n._getGlobalNodeMaterialEditor(),n.BJSNODEMATERIALEDITOR===void 0){var o=e&&e.editorURL?e.editorURL:t.EditorURL;ze.S0.LoadBabylonScript(o,function(){n.BJSNODEMATERIALEDITOR=n.BJSNODEMATERIALEDITOR||n._getGlobalNodeMaterialEditor(),n._createNodeEditor(e?.nodeEditorConfig),i()})}else n._createNodeEditor(e?.nodeEditorConfig),i()})},t.prototype.clear=function(){this._vertexOutputNodes.length=0,this._fragmentOutputNodes.length=0,this.attachedBlocks.length=0},t.prototype.setToDefault=function(){this.clear(),this.editorData=null;var e=new Mt("Position");e.setAsAttribute("position");var n=new Mt("World");n.setAsSystemValue(Nt.World);var i=new _l("WorldPos");e.connectTo(i),n.connectTo(i);var o=new Mt("ViewProjection");o.setAsSystemValue(Nt.ViewProjection);var a=new _l("WorldPos * ViewProjectionTransform");i.connectTo(a),o.connectTo(a);var s=new $a("VertexOutput");a.connectTo(s);var l=new Mt("color");l.value=new z.ov(.8,.8,.8,1);var c=new ca("FragmentOutput");l.connectTo(c),this.addOutputNode(s),this.addOutputNode(c),this._mode=mi.Material},t.prototype.setToDefaultPostProcess=function(){this.clear(),this.editorData=null;var e=new Mt("Position");e.setAsAttribute("position2d");var n=new Mt("Constant1");n.isConstant=!0,n.value=1;var i=new es("Position3D");e.connectTo(i),n.connectTo(i,{input:"w"});var o=new $a("VertexOutput");i.connectTo(o);var a=new Mt("Scale");a.visibleInInspector=!0,a.value=new _.I9(1,1);var s=new nh("uv0");e.connectTo(s);var l=new ml("UV scale");s.connectTo(l),a.connectTo(l);var c=new Jd("CurrentScreen");l.connectTo(c),c.texture=new Ie.g("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());var u=new ca("FragmentOutput");c.connectTo(u,{output:"rgba"}),this.addOutputNode(o),this.addOutputNode(u),this._mode=mi.PostProcess},t.prototype.setToDefaultProceduralTexture=function(){this.clear(),this.editorData=null;var e=new Mt("Position");e.setAsAttribute("position2d");var n=new Mt("Constant1");n.isConstant=!0,n.value=1;var i=new es("Position3D");e.connectTo(i),n.connectTo(i,{input:"w"});var o=new $a("VertexOutput");i.connectTo(o);var a=new Mt("Time");a.value=0,a.min=0,a.max=0,a.isBoolean=!1,a.matrixMode=0,a.animationType=jr.Time,a.isConstant=!1;var s=new Mt("Color3");s.value=new z.v9(1,1,1),s.isConstant=!1;var l=new ca("FragmentOutput"),c=new es("VectorMerger");c.visibleInInspector=!1;var u=new oh("Cos");u.operation=Vn.Cos,e.connectTo(c),a.output.connectTo(u.input),u.output.connectTo(c.z),c.xyzOut.connectTo(l.rgb),this.addOutputNode(o),this.addOutputNode(l),this._mode=mi.ProceduralTexture},t.prototype.setToDefaultParticle=function(){this.clear(),this.editorData=null;var e=new Mt("uv");e.setAsAttribute("particle_uv");var n=new $d("ParticleTexture");e.connectTo(n);var i=new Mt("Color");i.setAsAttribute("particle_color");var o=new ml("Texture * Color");n.connectTo(o),i.connectTo(o);var a=new eh("ParticleRampGradient");o.connectTo(a);var s=new rh("ColorSplitter");i.connectTo(s);var l=new th("ParticleBlendMultiply");a.connectTo(l),n.connectTo(l,{output:"a"}),s.connectTo(l,{output:"a"});var c=new ca("FragmentOutput");l.connectTo(c),this.addOutputNode(c),this._mode=mi.Particle},t.prototype.loadAsync=function(e,n){return n===void 0&&(n=""),(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(i){return[2,t.ParseFromFileAsync("",e,this.getScene(),n,!0,this)]})})},t.prototype._gatherBlocks=function(e,n){if(n.indexOf(e)===-1){n.push(e);for(var i=0,o=e.inputs;i<o.length;i++){var a=o[i].connectedPoint;a&&(s=a.ownerBlock)!==e&&this._gatherBlocks(s,n)}var s;e.isTeleportOut&&(s=e).entryPoint&&this._gatherBlocks(s.entryPoint,n)}},t.prototype.generateCode=function(){for(var e=[],n=[],i=["const","var","let"],o=0,a=this._vertexOutputNodes;o<a.length;o++){var s=a[o];this._gatherBlocks(s,n)}for(var l=[],c=0,u=this._fragmentOutputNodes;c<u.length;c++)s=u[c],this._gatherBlocks(s,l);var d='var nodeMaterial = new BABYLON.NodeMaterial("'.concat(this.name||"node material",`");
|
||
`);d+="nodeMaterial.mode = BABYLON.NodeMaterialModes.".concat(mi[this.mode],`;
|
||
`);for(var h=0,p=n;h<p.length;h++)(S=p[h]).isInput&&e.indexOf(S)===-1&&(d+=S._dumpCode(i,e));for(var m=0,v=l;m<v.length;m++)(S=v[m]).isInput&&e.indexOf(S)===-1&&(d+=S._dumpCode(i,e));e=[],d+=`
|
||
// Connections
|
||
`;for(var b=0,E=this._vertexOutputNodes;b<E.length;b++)d+=(S=E[b])._dumpCodeForOutputConnections(e);for(var C=0,T=this._fragmentOutputNodes;C<T.length;C++)d+=(S=T[C])._dumpCodeForOutputConnections(e);d+=`
|
||
// Output nodes
|
||
`;for(var f=0,g=this._vertexOutputNodes;f<g.length;f++){var S=g[f];d+="nodeMaterial.addOutputNode(".concat(S._codeVariableName,`);
|
||
`)}for(var y=0,x=this._fragmentOutputNodes;y<x.length;y++)S=x[y],d+="nodeMaterial.addOutputNode(".concat(S._codeVariableName,`);
|
||
`);return d+`nodeMaterial.build();
|
||
`},t.prototype.serialize=function(e){var n=e?{}:tt.p.Serialize(this);n.editorData=JSON.parse(JSON.stringify(this.editorData));var i=[];if(e)i=e;else{n.customType="BABYLON.NodeMaterial",n.outputNodes=[];for(var o=0,a=this._vertexOutputNodes;o<a.length;o++){var s=a[o];this._gatherBlocks(s,i),n.outputNodes.push(s.uniqueId)}for(var l=0,c=this._fragmentOutputNodes;l<c.length;l++)s=c[l],this._gatherBlocks(s,i),n.outputNodes.indexOf(s.uniqueId)===-1&&n.outputNodes.push(s.uniqueId)}n.blocks=[];for(var u=0,d=i;u<d.length;u++){var h=d[u];n.blocks.push(h.serialize())}if(!e)for(var p=0,m=this.attachedBlocks;p<m.length;p++)h=m[p],i.indexOf(h)===-1&&n.blocks.push(h.serialize());return n.uniqueId=this.uniqueId,n},t.prototype._restoreConnections=function(e,n,i){for(var o=0,a=e.outputs;o<a.length;o++)for(var s=a[o],l=0,c=n.blocks;l<c.length;l++){var u=c[l],d=i[u.id];if(d)for(var h=0,p=u.inputs;h<p.length;h++){var m=p[h];if(!(i[m.targetBlockId]!==e||m.targetConnectionName!==s.name)){var v=d.getInputByName(m.inputName);if(!v||v.isConnected)continue;s.connectTo(v,!0),this._restoreConnections(d,n,i)}}}},t.prototype.parseSerializedObject=function(e,n,i,o){var a;n===void 0&&(n=""),i===void 0&&(i=!1),i||this.clear();for(var s={},l=0,c=e.blocks;l<c.length;l++){var u=c[l],d=(0,j.n9)(u.customType);d&&((E=new d)._deserialize(u,this.getScene(),n,o),s[u.id]=E,this.attachedBlocks.push(E))}for(var h=0,p=this.attachedBlocks;h<p.length;h++)if((E=p[h]).isTeleportOut){var m=E,v=m._tempEntryPointUniqueId;v&&s[v].attachToEndpoint(m)}for(var b=0;b<e.blocks.length;b++){var E;(E=s[(u=e.blocks[b]).id])&&(E.inputs.length&&!i||this._restoreConnections(E,e,s))}if(e.outputNodes)for(var C=0,T=e.outputNodes;C<T.length;C++){var f=T[C];this.addOutputNode(s[f])}if(e.locations||e.editorData&&e.editorData.locations){for(var g=e.locations||e.editorData.locations,S=0,y=g;S<y.length;S++){var x=y[S];s[x.blockId]&&(x.blockId=s[x.blockId].uniqueId)}i&&this.editorData&&this.editorData.locations&&g.concat(this.editorData.locations),e.locations?this.editorData={locations:g}:(this.editorData=e.editorData,this.editorData.locations=g);var R=[];for(var I in s)R[I]=s[I].uniqueId;this.editorData.map=R}this.comment=e.comment,e.forceAlphaBlending!==void 0&&(this.forceAlphaBlending=e.forceAlphaBlending),e.alphaMode!==void 0&&(this.alphaMode=e.alphaMode),i||(this._mode=(a=e.mode)!==null&&a!==void 0?a:mi.Material)},t.prototype.loadFromSerialization=function(e,n,i){n===void 0&&(n=""),i===void 0&&(i=!1),this.parseSerializedObject(e,n,i)},t.prototype.clone=function(e,n){var i=this;n===void 0&&(n=!1);var o=this.serialize(),a=tt.p.Clone(function(){return new t(e,i.getScene(),i.options)},this);return a.id=e,a.name=e,a.parseSerializedObject(o),a._buildId=this._buildId,a.build(!1,!n),a},t.prototype.whenTexturesReadyAsync=function(){var e=[];return this.getActiveTextures().forEach(function(n){var i=n.getInternalTexture();i&&!i.isReady&&e.push(new Promise(function(o,a){i.onLoadedObservable.addOnce(function(){o()}),i.onErrorObservable.addOnce(function(s){a(s)})}))}),Promise.all(e)},t.Parse=function(e,n,i,o){i===void 0&&(i=""),o===void 0&&(o=0);var a=tt.p.Parse(function(){return new t(e.name,n,{shaderLanguage:o})},e,n,i);return a.parseSerializedObject(e,i),a.build(),a},t.ParseFromFileAsync=function(e,n,i,o,a,s,l){return o===void 0&&(o=""),a===void 0&&(a=!1),(0,A.sH)(this,void 0,void 0,function(){var c,u,d;return(0,A.YH)(this,function(h){switch(h.label){case 0:return c=s??new t(e,i),[4,i._loadFileAsync(n)];case 1:return u=h.sent(),d=JSON.parse(u),c.parseSerializedObject(d,o,void 0,l),a||c.build(),[2,c]}})})},t.ParseFromSnippetAsync=function(e,n,i,o,a,s,l){var c=this;return n===void 0&&(n=Ve.q.LastCreatedScene),i===void 0&&(i=""),a===void 0&&(a=!1),s===void 0&&(s=!1),e==="_BLANK"?Promise.resolve(t.CreateDefault("blank",n)):new Promise(function(u,d){var h=new We.u;h.addEventListener("readystatechange",function(){if(h.readyState==4)if(h.status==200){var p=JSON.parse(JSON.parse(h.responseText).jsonPayload),m=JSON.parse(p.nodeMaterial);o||((o=tt.p.Parse(function(){return new t(e,n)},m,n,i)).uniqueId=n.getUniqueId()),o.parseSerializedObject(m,void 0,void 0,l),o.snippetId=e,o.sideOrientation=null;try{a||o.build()}catch(v){d(v)}s?o.whenTexturesReadyAsync().then(function(){u(o)}).catch(function(v){d(v)}):u(o)}else d("Unable to load the snippet "+e)}),h.open("GET",c.SnippetUrl+"/"+e.replace(/#/g,"/")),h.send()})},t.CreateDefault=function(e,n){var i=new t(e,n);return i.setToDefault(),i.build(),i},t._BuildIdGenerator=0,t.EditorURL="".concat(ze.S0._DefaultCdnUrl,"/v").concat(Be.$.Version,"/nodeEditor/babylon.nodeEditor.js"),t.SnippetUrl=P.Y.SnippetUrl,t.IgnoreTexturesAtLoadTime=!1,t.DefaultShaderLanguage=0,(0,A.Cg)([(0,V.lK)()],t.prototype,"ignoreAlpha",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"maxSimultaneousLights",void 0),(0,A.Cg)([(0,V.lK)("mode")],t.prototype,"_mode",void 0),(0,A.Cg)([(0,V.lK)("comment")],t.prototype,"comment",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"forceAlphaBlending",void 0),t}(Ro);(0,j.Y5)("BABYLON.NodeMaterial",so),yi.prototype._projectOnTrianglesToRef=function(r,t,e,n,i,o){for(var a=_.AA.Vector3[0],s=_.AA.Vector3[1],l=1/0,c=this.indexStart;c<this.indexStart+this.indexCount-(3-n);c+=n){var u=e[c],d=e[c+1],h=e[c+2];if(i&&h===4294967295)c+=2;else{var p=t[u],m=t[d],v=t[h];if(p&&m&&v){var b=_.Pq.ProjectOnTriangleToRef(r,p,m,v,s);b<l&&(a.copyFrom(s),l=b)}}}return o.copyFrom(a),l},yi.prototype._projectOnUnIndexedTrianglesToRef=function(r,t,e,n){for(var i=_.AA.Vector3[0],o=_.AA.Vector3[1],a=1/0,s=this.verticesStart;s<this.verticesStart+this.verticesCount;s+=3){var l=t[s],c=t[s+1],u=t[s+2],d=_.Pq.ProjectOnTriangleToRef(r,l,c,u,o);d<a&&(i.copyFrom(o),a=d)}return n.copyFrom(i),a},yi.prototype.projectToRef=function(r,t,e,n){var i=this.getMaterial();if(!i)return-1;var o=3,a=!1;switch(i.fillMode){case P.Y.MATERIAL_PointListDrawMode:case P.Y.MATERIAL_LineLoopDrawMode:case P.Y.MATERIAL_LineStripDrawMode:case P.Y.MATERIAL_TriangleFanDrawMode:return-1;case P.Y.MATERIAL_TriangleStripDrawMode:o=1,a=!0}return i.fillMode===P.Y.MATERIAL_LineListDrawMode?-1:!e.length&&this._mesh._unIndexed?this._projectOnUnIndexedTrianglesToRef(r,t,e,n):this._projectOnTrianglesToRef(r,t,e,o,a,n)},function(r){r[r.DEHYDRATED=0]="DEHYDRATED",r[r.HOVER=1]="HOVER",r[r.TOUCH=2]="TOUCH"}(ar||(ar={})),function(r){r[r.DISABLED=0]="DISABLED",r[r.CENTERED_ON_CONTROLLER=1]="CENTERED_ON_CONTROLLER",r[r.CENTERED_IN_FRONT=2]="CENTERED_IN_FRONT"}(ah||(ah={}));var ns=function(r){function t(e,n){var i=r.call(this,e)||this;return i._options=n,i._tmpRay=new fn(new _.Pq,new _.Pq),i._attachController=function(o){var a;if(!i._controllers[o.uniqueId]){var s=(a=i._generateNewTouchPointMesh()).touchCollisionMesh,l=a.touchCollisionMeshFunction,c=a.hydrateCollisionMeshFunction,u=i._generateVisualCue();switch(i._controllers[o.uniqueId]={xrController:o,meshUnderPointer:null,nearInteractionTargetMesh:null,pick:null,stalePick:null,touchCollisionMesh:s,touchCollisionMeshFunction:l,hydrateCollisionMeshFunction:c,currentAnimationState:ar.DEHYDRATED,grabRay:new fn(new _.Pq,new _.Pq),hoverInteraction:!1,nearInteraction:!1,grabInteraction:!1,downTriggered:!1,id:t._IdCounter++,pickedPointVisualCue:u},i._controllers[o.uniqueId]._worldScaleObserver=i._controllers[o.uniqueId]._worldScaleObserver||i._xrSessionManager.onWorldScaleFactorChangedObservable.add(function(d){var h;if(d.newScaleFactor!==d.previousScaleFactor){i._controllers[o.uniqueId].touchCollisionMesh.dispose(),i._controllers[o.uniqueId].pickedPointVisualCue.dispose();var p=(h=i._generateNewTouchPointMesh()).touchCollisionMesh,m=h.touchCollisionMeshFunction,v=h.hydrateCollisionMeshFunction;i._controllers[o.uniqueId].touchCollisionMesh=p,i._controllers[o.uniqueId].touchCollisionMeshFunction=m,i._controllers[o.uniqueId].hydrateCollisionMeshFunction=v,i._controllers[o.uniqueId].pickedPointVisualCue=i._generateVisualCue()}}),i._attachedController?!i._options.enableNearInteractionOnAllControllers&&i._options.preferredHandedness&&o.inputSource.handedness===i._options.preferredHandedness&&(i._attachedController=o.uniqueId):i._options.enableNearInteractionOnAllControllers||(i._attachedController=o.uniqueId),o.inputSource.targetRayMode){case"tracked-pointer":return i._attachNearInteractionMode(o);case"gaze":case"screen":return null}}},i._controllers={},i._farInteractionFeature=null,i.selectionMeshDefaultColor=new z.v9(.8,.8,.8),i.selectionMeshPickedColor=new z.v9(.3,.3,1),i._hoverRadius=.1,i._pickRadius=.02,i._controllerPickRadius=.03,i._nearGrabLengthScale=5,i._scene=i._xrSessionManager.scene,i._options.nearInteractionControllerMode===void 0&&(i._options.nearInteractionControllerMode=2),i._options.farInteractionFeature&&(i._farInteractionFeature=i._options.farInteractionFeature),i}return(0,A.C6)(t,r),t.prototype.attach=function(){var e=this;return!!r.prototype.attach.call(this)&&(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(n){e._detachController(n.uniqueId)}),this._scene.constantlyUpdateMeshUnderPointer=!0,!0)},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach(function(n){e._detachController(n)}),!0)},t.prototype.getMeshUnderPointer=function(e){return this._controllers[e]?this._controllers[e].meshUnderPointer:null},t.prototype.getXRControllerByPointerId=function(e){for(var n=Object.keys(this._controllers),i=0;i<n.length;++i)if(this._controllers[n[i]].id===e)return this._controllers[n[i]].xrController||null;return null},t.prototype.setFarInteractionFeature=function(e){this._farInteractionFeature=e},t.prototype._nearPickPredicate=function(e){return e.isEnabled()&&e.isVisible&&e.isPickable&&e.isNearPickable},t.prototype._nearGrabPredicate=function(e){return e.isEnabled()&&e.isVisible&&e.isPickable&&e.isNearGrabbable},t.prototype._nearInteractionPredicate=function(e){return e.isEnabled()&&e.isVisible&&e.isPickable&&(e.isNearPickable||e.isNearGrabbable)},t.prototype._controllerAvailablePredicate=function(e,n){for(var i=e;i;){if(i.reservedDataStore&&i.reservedDataStore.nearInteraction&&i.reservedDataStore.nearInteraction.excludedControllerId===n)return!1;i=i.parent}return!0},t.prototype._handleTransitionAnimation=function(e,n){var i;if(e.currentAnimationState!==n&&this._options.nearInteractionControllerMode===2&&!(!((i=e.xrController)===null||i===void 0)&&i.inputSource.hand)){if(n>e.currentAnimationState)switch(e.currentAnimationState){case ar.DEHYDRATED:if(e.hydrateCollisionMeshFunction(!0),n===ar.HOVER)break;case ar.HOVER:if(e.touchCollisionMeshFunction(!0),n===ar.TOUCH)break}else switch(e.currentAnimationState){case ar.TOUCH:if(e.touchCollisionMeshFunction(!1),n===ar.HOVER)break;case ar.HOVER:if(e.hydrateCollisionMeshFunction(!1),n===ar.DEHYDRATED)break}e.currentAnimationState=n}},t.prototype._processTouchPoint=function(e,n,i){var o,a=this._controllers[e];a.grabRay.origin.copyFrom(n),i.toEulerAnglesToRef(_.AA.Vector3[0]),a.grabRay.direction.copyFrom(_.AA.Vector3[0]),this._options.nearInteractionControllerMode!==2||!((o=a.xrController)===null||o===void 0)&&o.inputSource.hand||(a.xrController.getWorldPointerRayToRef(this._tmpRay),a.grabRay.origin.addInPlace(this._tmpRay.direction.scale(.05))),a.grabRay.length=this._nearGrabLengthScale*this._hoverRadius*this._xrSessionManager.worldScalingFactor,a.touchCollisionMesh.position.copyFrom(a.grabRay.origin).scaleInPlace(this._xrSessionManager.worldScalingFactor)},t.prototype._onXRFrame=function(e){var n=this;Object.keys(this._controllers).forEach(function(i){var o,a=n._controllers[i],s=(o=a.xrController)===null||o===void 0?void 0:o.inputSource.hand;if((n._options.enableNearInteractionOnAllControllers||i===n._attachedController)&&a.xrController&&(s||n._options.nearInteractionControllerMode&&a.xrController.inputSource.gamepad)){if(a.hoverInteraction=!1,a.nearInteraction=!1,a.xrController){if(s){var l=s.get("index-finger-tip");if(l){var c=e.getJointPose(l,n._xrSessionManager.referenceSpace);if(c&&c.transform){var u=n._scene.useRightHandedSystem?1:-1;_.AA.Vector3[0].set(c.transform.position.x,c.transform.position.y,c.transform.position.z*u),_.AA.Quaternion[0].set(c.transform.orientation.x,c.transform.orientation.y,c.transform.orientation.z*u,c.transform.orientation.w*u),n._processTouchPoint(i,_.AA.Vector3[0],_.AA.Quaternion[0])}}}else if(a.xrController.inputSource.gamepad&&n._options.nearInteractionControllerMode!==0){var d=a.xrController.pointer;a.xrController.grip&&n._options.nearInteractionControllerMode===1&&(d=a.xrController.grip),n._processTouchPoint(i,d.position,d.rotationQuaternion)}var h=function(g,S){return S&&S.hit?g&&g.hit?S.distance<g.distance?S:g:S:g},p=function(g){var S=new ri.G,y=!1,x=g&&g.pickedPoint&&g.hit;return g?.pickedPoint&&(y=g.pickedPoint.x===0&&g.pickedPoint.y===0&&g.pickedPoint.z===0),x&&!y&&(S=g),S};if(!a.grabInteraction){var m=null,v=null;n._options.useUtilityLayer&&n._utilityLayerScene&&(v=n._pickWithSphere(a,n._hoverRadius*n._xrSessionManager.worldScalingFactor,n._utilityLayerScene,function(g){return n._nearInteractionPredicate(g)}));var b=h(n._pickWithSphere(a,n._hoverRadius*n._xrSessionManager.worldScalingFactor,n._scene,function(g){return n._nearInteractionPredicate(g)}),v);if(b&&b.hit&&(m=p(b)).hit&&(a.hoverInteraction=!0),a.hoverInteraction){var E=null,C=(s?n._pickRadius:n._controllerPickRadius)*n._xrSessionManager.worldScalingFactor;n._options.useUtilityLayer&&n._utilityLayerScene&&(E=n._pickWithSphere(a,C,n._utilityLayerScene,function(g){return n._nearPickPredicate(g)}));var T=p(h(n._pickWithSphere(a,C,n._scene,function(g){return n._nearPickPredicate(g)}),E));T.hit&&(m=T,a.nearInteraction=!0)}a.stalePick=a.pick,a.pick=m,a.pick&&a.pick.pickedPoint&&a.pick.hit?(a.meshUnderPointer=a.pick.pickedMesh,a.pickedPointVisualCue.position.copyFrom(a.pick.pickedPoint),a.pickedPointVisualCue.isVisible=!0,n._farInteractionFeature&&n._farInteractionFeature.attached&&n._farInteractionFeature._setPointerSelectionDisabledByPointerId(a.id,!0)):(a.meshUnderPointer=null,a.pickedPointVisualCue.isVisible=!1,n._farInteractionFeature&&n._farInteractionFeature.attached&&n._farInteractionFeature._setPointerSelectionDisabledByPointerId(a.id,!1))}var f=ar.DEHYDRATED;a.grabInteraction||a.nearInteraction?f=ar.TOUCH:a.hoverInteraction&&(f=ar.HOVER),n._handleTransitionAnimation(a,f)}}else a.pick=null})},Object.defineProperty(t.prototype,"_utilityLayerScene",{get:function(){return this._options.customUtilityLayerScene||Fn.DefaultUtilityLayer.utilityLayerScene},enumerable:!1,configurable:!0}),t.prototype._generateVisualCue=function(){var e=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Fn.DefaultUtilityLayer.utilityLayerScene:this._scene,n=li("nearInteraction",{diameter:.0105*this._xrSessionManager.worldScalingFactor},e);n.bakeCurrentTransformIntoVertices(),n.isPickable=!1,n.isVisible=!1,n.rotationQuaternion=_.PT.Identity();var i=new qt("targetMat",e);return i.specularColor=z.v9.Black(),i.emissiveColor=this.selectionMeshDefaultColor,i.backFaceCulling=!1,n.material=i,n},t.prototype._isControllerReadyForNearInteraction=function(e){return!this._farInteractionFeature||this._farInteractionFeature._getPointerSelectionDisabledByPointerId(e)},t.prototype._attachNearInteractionMode=function(e){var n=this,i=this._controllers[e.uniqueId],o={pointerId:i.id,pointerType:"xr-near"};i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(function(){(n._options.enableNearInteractionOnAllControllers||e.uniqueId===n._attachedController)&&i.xrController&&(i.xrController.inputSource.hand||n._options.nearInteractionControllerMode&&i.xrController.inputSource.gamepad)&&(i.pick&&(i.pick.ray=i.grabRay),i.pick&&n._isControllerReadyForNearInteraction(i.id)&&n._scene.simulatePointerMove(i.pick,o),i.nearInteraction&&i.pick&&i.pick.hit?i.nearInteractionTargetMesh||(n._scene.simulatePointerDown(i.pick,o),i.nearInteractionTargetMesh=i.meshUnderPointer,i.downTriggered=!0):i.nearInteractionTargetMesh&&i.stalePick&&(n._scene.simulatePointerUp(i.stalePick,o),i.downTriggered=!1,i.nearInteractionTargetMesh=null))});var a=function(u){n._options.enableNearInteractionOnAllControllers||e.uniqueId===n._attachedController&&n._isControllerReadyForNearInteraction(i.id)?(i.pick&&(i.pick.ray=i.grabRay),u&&i.pick&&i.meshUnderPointer&&n._nearGrabPredicate(i.meshUnderPointer)?(i.grabInteraction=!0,i.pickedPointVisualCue.isVisible=!1,n._scene.simulatePointerDown(i.pick,o),i.downTriggered=!0):!u&&i.pick&&i.grabInteraction&&(n._scene.simulatePointerUp(i.pick,o),i.downTriggered=!1,i.grabInteraction=!1,i.pickedPointVisualCue.isVisible=!0)):!u||n._options.enableNearInteractionOnAllControllers||n._options.disableSwitchOnClick||(n._attachedController=e.uniqueId)};if(e.inputSource.gamepad){var s=function(u){i.squeezeComponent=u.getComponent("grasp"),i.squeezeComponent?i.onSqueezeButtonChangedObserver=i.squeezeComponent.onButtonStateChangedObservable.add(function(d){if(d.changes.pressed){var h=d.changes.pressed.current;a(h)}}):(i.selectionComponent=u.getMainComponent(),i.onButtonChangedObserver=i.selectionComponent.onButtonStateChangedObservable.add(function(d){if(d.changes.pressed){var h=d.changes.pressed.current;a(h)}}))};e.motionController?s(e.motionController):e.onMotionControllerInitObservable.add(s)}else{var l=function(u){i.xrController&&u.inputSource===i.xrController.inputSource&&i.pick&&n._isControllerReadyForNearInteraction(i.id)&&i.meshUnderPointer&&n._nearGrabPredicate(i.meshUnderPointer)&&(i.grabInteraction=!0,i.pickedPointVisualCue.isVisible=!1,n._scene.simulatePointerDown(i.pick,o),i.downTriggered=!0)},c=function(u){i.xrController&&u.inputSource===i.xrController.inputSource&&i.pick&&n._isControllerReadyForNearInteraction(i.id)&&(n._scene.simulatePointerUp(i.pick,o),i.grabInteraction=!1,i.pickedPointVisualCue.isVisible=!0,i.downTriggered=!1)};i.eventListeners={selectend:c,selectstart:l},this._xrSessionManager.session.addEventListener("selectstart",l),this._xrSessionManager.session.addEventListener("selectend",c)}},t.prototype._detachController=function(e){var n=this,i=this._controllers[e];if(i&&(i.squeezeComponent&&i.onSqueezeButtonChangedObserver&&i.squeezeComponent.onButtonStateChangedObservable.remove(i.onSqueezeButtonChangedObserver),i.selectionComponent&&i.onButtonChangedObserver&&i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),i.onFrameObserver&&this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),i.eventListeners&&Object.keys(i.eventListeners).forEach(function(a){var s=i.eventListeners&&i.eventListeners[a];s&&n._xrSessionManager.session.removeEventListener(a,s)}),i.touchCollisionMesh.dispose(),i.pickedPointVisualCue.dispose(),this._xrSessionManager.runInXRFrame(function(){if(i.downTriggered){var a={pointerId:i.id,pointerType:"xr-near"};n._scene.simulatePointerUp(new ri.G,a)}}),i._worldScaleObserver&&this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(i._worldScaleObserver),delete this._controllers[e],this._attachedController===e)){var o=Object.keys(this._controllers);o.length?this._attachedController=o[0]:this._attachedController=""}},t.prototype._generateNewTouchPointMesh=function(){var e=this._xrSessionManager.worldScalingFactor,n=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Fn.DefaultUtilityLayer.utilityLayerScene:this._scene,i=li("PickSphere",{diameter:1*e},n);i.isVisible=!1,this._options.motionControllerOrbMaterial?i.material=this._options.motionControllerOrbMaterial:(this._options.motionControllerTouchMaterialSnippetUrl?so.ParseFromFileAsync("motionControllerTouchMaterial",this._options.motionControllerTouchMaterialSnippetUrl,n):so.ParseFromSnippetAsync("8RUNKL#3",n)).then(function(S){i.material=S}).catch(function(S){O.V.Warn("Error creating touch material in WebXRNearInteraction: ".concat(S))});var o=new Fi;o.setEasingMode(Wt.EASINGMODE_EASEINOUT);var a=new _.Pq(this._controllerPickRadius,this._controllerPickRadius,this._controllerPickRadius).scaleInPlace(e),s=this._controllerPickRadius*(4/3),l=new _.Pq(s,s,s).scaleInPlace(e),c=this._controllerPickRadius*(7/6),u=new _.Pq(c,c,c).scaleInPlace(e),d=.8*this._controllerPickRadius,h=new _.Pq(d,d,d).scaleInPlace(e),p=1.5*this._controllerPickRadius,m=[{frame:0,value:a},{frame:10,value:new _.Pq(p,p,p).scaleInPlace(e)},{frame:18,value:l}],v=[{frame:0,value:l},{frame:10,value:h},{frame:18,value:a}],b=[{frame:0,value:_.Pq.ZeroReadOnly},{frame:12,value:u},{frame:15,value:a}],E=[{frame:0,value:a},{frame:10,value:_.Pq.ZeroReadOnly},{frame:15,value:_.Pq.ZeroReadOnly}],C=new Le("touch","scaling",60,Le.ANIMATIONTYPE_VECTOR3,Le.ANIMATIONLOOPMODE_CONSTANT),T=new Le("release","scaling",60,Le.ANIMATIONTYPE_VECTOR3,Le.ANIMATIONLOOPMODE_CONSTANT),f=new Le("hydrate","scaling",60,Le.ANIMATIONTYPE_VECTOR3,Le.ANIMATIONLOOPMODE_CONSTANT),g=new Le("dehydrate","scaling",60,Le.ANIMATIONTYPE_VECTOR3,Le.ANIMATIONLOOPMODE_CONSTANT);return C.setEasingFunction(o),T.setEasingFunction(o),f.setEasingFunction(o),g.setEasingFunction(o),C.setKeys(m),T.setKeys(v),f.setKeys(b),g.setKeys(E),{touchCollisionMesh:i,touchCollisionMeshFunction:function(S){var y=S?C:T;n.beginDirectAnimation(i,[y],0,18,!1,1)},hydrateCollisionMeshFunction:function(S){var y=S?f:g;S&&(i.isVisible=!0),n.beginDirectAnimation(i,[y],0,15,!1,1,function(){S||(i.isVisible=!1)})}}},t.prototype._pickWithSphere=function(e,n,i,o){var a=new ri.G;if(a.distance=1/0,e.touchCollisionMesh&&e.xrController)for(var s=e.touchCollisionMesh.position,l=Zo.CreateFromCenterAndRadius(s,n),c=0;c<i.meshes.length;c++){var u=i.meshes[c];if(o(u)&&this._controllerAvailablePredicate(u,e.xrController.uniqueId)){var d=t.PickMeshWithSphere(u,l);d&&d.hit&&d.distance<a.distance&&(a.hit=d.hit,a.pickedMesh=u,a.pickedPoint=d.pickedPoint,a.aimTransform=e.xrController.pointer,a.gripTransform=e.xrController.grip||null,a.originMesh=e.touchCollisionMesh,a.distance=d.distance,a.bu=d.bu,a.bv=d.bv,a.faceId=d.faceId,a.subMeshId=d.subMeshId)}}return a},t.PickMeshWithSphere=function(e,n,i){i===void 0&&(i=!1);var o=e.subMeshes,a=new ri.G,s=e.getBoundingInfo();if(!e._generatePointsArray()||!e.subMeshes||!s||!i&&!Zo.Intersects(s.boundingSphere,n))return a;var l,c,u,d,h=_.AA.Vector3[0],p=_.AA.Vector3[1],m=new fn(_.Pq.Zero(),_.Pq.Zero(),1),v=1/0,b=_.AA.Vector3[2],E=_.AA.Matrix[0];E.copyFrom(e.getWorldMatrix()),E.invert(),_.Pq.TransformCoordinatesToRef(n.center,E,b);for(var C=0;C<o.length;C++)o[C].projectToRef(b,e._positions,e.getIndices(),p),_.Pq.TransformCoordinatesToRef(p,e.getWorldMatrix(),p),l=_.Pq.Distance(p,n.center),u=_.Pq.Distance(p,e.getAbsolutePosition()),(c=_.Pq.Distance(n.center,e.getAbsolutePosition()))!==-1&&u!==-1&&u>c&&(l=0,p.copyFrom(n.center)),l!==-1&&l<v&&(v=l,fn.CreateFromToToRef(n.center,p,m),m.length=2*v,d=m.intersectsMesh(e),h.copyFrom(p));return v<n.radius&&(a.hit=!0,a.distance=v,a.pickedMesh=e,a.pickedPoint=h.clone(),d&&d.bu!==null&&d.bv!==null&&(a.faceId=d.faceId,a.subMeshId=d.subMeshId,a.bu=d.bu,a.bv=d.bv)),a},t._IdCounter=200,t.Name=vn.NEAR_INTERACTION,t.Version=1,t}(qn);kn.AddWebXRFeature(ns.Name,function(r,t){return function(){return new ns(r,t)}},ns.Version,!0);var ua,sh,lh,lv=function(){function r(t,e,n){this.element=t,this.sessionMode=e,this.referenceSpaceType=n}return r.prototype.update=function(t){},r}(),Bx=function(){},cv=function(){function r(t,e){var n=this;if(this._scene=t,this.options=e,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new K.cP,this._onSessionGranted=function(u){n._helper&&n._enterXRWithButtonIndex(0)},this.overlay=document.createElement("div"),this.overlay.classList.add("xr-button-overlay"),!e.ignoreSessionGrantedEvent&&navigator.xr&&navigator.xr.addEventListener("sessiongranted",this._onSessionGranted),typeof window<"u"&&window.location&&window.location.protocol==="http:"&&window.location.hostname!=="localhost")throw ze.S0.Warn("WebXR can only be served over HTTPS"),new Error("WebXR can only be served over HTTPS");if(e.customButtons)this._buttons=e.customButtons;else{this.overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;";var i=e.sessionMode||"immersive-vr",o=e.referenceSpaceType||"local-floor",a=".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url("+(typeof SVGSVGElement>"u"?"https://cdn.babylonjs.com/Assets/vrButton.png":"data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";a+='.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';var s=document.createElement("style");s.appendChild(document.createTextNode(a)),document.getElementsByTagName("head")[0].appendChild(s);var l=document.createElement("button");l.className="babylonVRicon",l.title="".concat(i," - ").concat(o),this._buttons.push(new lv(l,i,o)),this._buttons[this._buttons.length-1].update=function(u){this.element.style.display=u===null||u===this?"":"none",l.className="babylonVRicon"+(u===this?" vrdisplaypresenting":"")},this._updateButtons(null)}var c=t.getEngine().getInputElement();c&&c.parentNode&&(c.parentNode.appendChild(this.overlay),t.onDisposeObservable.addOnce(function(){n.dispose()}))}return r.prototype.setHelperAsync=function(t,e){return(0,A.sH)(this,void 0,void 0,function(){var n,i=this;return(0,A.YH)(this,function(o){switch(o.label){case 0:return this._helper=t,this._renderTarget=e,n=this._buttons.map(function(a){return t.sessionManager.isSessionSupportedAsync(a.sessionMode)}),t.onStateChangedObservable.add(function(a){a==3&&i._updateButtons(null)}),[4,Promise.all(n)];case 1:return o.sent().forEach(function(a,s){a?(i.overlay.appendChild(i._buttons[s].element),i._buttons[s].element.onclick=i._enterXRWithButtonIndex.bind(i,s)):ze.S0.Warn('Session mode "'.concat(i._buttons[s].sessionMode,'" not supported in browser'))}),[2]}})})},r.CreateAsync=function(t,e,n){return(0,A.sH)(this,void 0,void 0,function(){var i;return(0,A.YH)(this,function(o){switch(o.label){case 0:return[4,(i=new r(t,n)).setHelperAsync(e,n.renderTarget||void 0)];case 1:return o.sent(),[2,i]}})})},r.prototype._enterXRWithButtonIndex=function(t){return t===void 0&&(t=0),(0,A.sH)(this,void 0,void 0,function(){var e,n,i;return(0,A.YH)(this,function(o){switch(o.label){case 0:return this._helper.state!=2?[3,2]:[4,this._helper.exitXRAsync()];case 1:return o.sent(),this._updateButtons(null),[3,6];case 2:if(this._helper.state!=3)return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),[4,this._helper.enterXRAsync(this._buttons[t].sessionMode,this._buttons[t].referenceSpaceType,this._renderTarget,{optionalFeatures:this.options.optionalFeatures,requiredFeatures:this.options.requiredFeatures})];case 4:return o.sent(),this._updateButtons(this._buttons[t]),[3,6];case 5:return e=o.sent(),this._updateButtons(null),n=this._buttons[t].element,i=n.title,n.title="Error entering XR session : "+i,n.classList.add("xr-error"),this.options.onError&&this.options.onError(e),[3,6];case 6:return[2]}})})},r.prototype.dispose=function(){var t=this._scene.getEngine().getInputElement();t&&t.parentNode&&t.parentNode.contains(this.overlay)&&t.parentNode.removeChild(this.overlay),this.activeButtonChangedObservable.clear(),navigator.xr.removeEventListener("sessiongranted",this._onSessionGranted)},r.prototype._updateButtons=function(t){var e=this;this._activeButton=t,this._buttons.forEach(function(n){n.update(e._activeButton)}),this.activeButtonChangedObservable.notifyObservers(this._activeButton)},r}();(function(r){r.WRIST="wrist",r.THUMB="thumb",r.INDEX="index",r.MIDDLE="middle",r.RING="ring",r.LITTLE="little"})(sh||(sh={})),function(r){r.WRIST="wrist",r.THUMB_METACARPAL="thumb-metacarpal",r.THUMB_PHALANX_PROXIMAL="thumb-phalanx-proximal",r.THUMB_PHALANX_DISTAL="thumb-phalanx-distal",r.THUMB_TIP="thumb-tip",r.INDEX_FINGER_METACARPAL="index-finger-metacarpal",r.INDEX_FINGER_PHALANX_PROXIMAL="index-finger-phalanx-proximal",r.INDEX_FINGER_PHALANX_INTERMEDIATE="index-finger-phalanx-intermediate",r.INDEX_FINGER_PHALANX_DISTAL="index-finger-phalanx-distal",r.INDEX_FINGER_TIP="index-finger-tip",r.MIDDLE_FINGER_METACARPAL="middle-finger-metacarpal",r.MIDDLE_FINGER_PHALANX_PROXIMAL="middle-finger-phalanx-proximal",r.MIDDLE_FINGER_PHALANX_INTERMEDIATE="middle-finger-phalanx-intermediate",r.MIDDLE_FINGER_PHALANX_DISTAL="middle-finger-phalanx-distal",r.MIDDLE_FINGER_TIP="middle-finger-tip",r.RING_FINGER_METACARPAL="ring-finger-metacarpal",r.RING_FINGER_PHALANX_PROXIMAL="ring-finger-phalanx-proximal",r.RING_FINGER_PHALANX_INTERMEDIATE="ring-finger-phalanx-intermediate",r.RING_FINGER_PHALANX_DISTAL="ring-finger-phalanx-distal",r.RING_FINGER_TIP="ring-finger-tip",r.PINKY_FINGER_METACARPAL="pinky-finger-metacarpal",r.PINKY_FINGER_PHALANX_PROXIMAL="pinky-finger-phalanx-proximal",r.PINKY_FINGER_PHALANX_INTERMEDIATE="pinky-finger-phalanx-intermediate",r.PINKY_FINGER_PHALANX_DISTAL="pinky-finger-phalanx-distal",r.PINKY_FINGER_TIP="pinky-finger-tip"}(lh||(lh={}));var ch,qr=["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"],oN=((ua={}).wrist=["wrist"],ua.thumb=["thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip"],ua.index=["index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip"],ua.middle=["middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip"],ua.ring=["ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip"],ua.little=["pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"],ua),uv=function(){function r(t,e,n,i,o,a,s){var l;o===void 0&&(o=!1),a===void 0&&(a=!1),s===void 0&&(s=1),this.xrController=t,this._jointMeshes=e,this._handMesh=n,this.rigMapping=i,this._leftHandedMeshes=o,this._jointsInvisible=a,this._jointScaleFactor=s,this.onHandMeshSetObservable=new K.cP,this._jointTransforms=new Array(qr.length),this._jointTransformMatrices=new Float32Array(16*qr.length),this._tempJointMatrix=new _.uq,this._jointRadii=new Float32Array(qr.length),this._scene=e[0].getScene();for(var c=0;c<this._jointTransforms.length;c++)this._jointTransforms[c]=new jt(qr[c],this._scene),this._jointTransforms[c].rotationQuaternion=new _.PT,e[c].rotationQuaternion?e[c].rotationQuaternion=new _.PT:(l=e[c].rotationQuaternion)===null||l===void 0||l.set(0,0,0,1);n&&this.setHandMesh(n,i),this.xrController.motionController&&this.xrController.motionController.rootMesh&&this.xrController.motionController.rootMesh.dispose(!1,!0),this.xrController.onMotionControllerInitObservable.add(function(u){u._doNotLoadControllerMesh=!0})}return Object.defineProperty(r.prototype,"handMesh",{get:function(){return this._handMesh},enumerable:!1,configurable:!0}),r.prototype.getHandPartMeshes=function(t){var e=this;return oN[t].map(function(n){return e._jointMeshes[qr.indexOf(n)]})},r.prototype.getJointMesh=function(t){return this._jointMeshes[qr.indexOf(t)]},r.prototype.setHandMesh=function(t,e,n){var i=this;if(this._handMesh=t,t.alwaysSelectAsActiveMesh=!0,t.getChildMeshes().forEach(function(a){a.alwaysSelectAsActiveMesh=!0}),this._handMesh.skeleton){var o=this._handMesh.skeleton;qr.forEach(function(a,s){var l=o.getBoneIndexByName(e?e[a]:a);l!==-1&&o.bones[l].linkTransformNode(i._jointTransforms[s])})}this.onHandMeshSetObservable.notifyObservers(this)},r.prototype.updateFromXRFrame=function(t,e){var n=this,i=this.xrController.inputSource.hand;if(i){var o=i,a=qr.map(function(u){return o[u]||i.get(u)}),s=!1;if(t.fillPoses&&t.fillJointRadii)s=t.fillPoses(a,e,this._jointTransformMatrices)&&t.fillJointRadii(a,this._jointRadii);else if(t.getJointPose){s=!0;for(var l=0;l<a.length;l++){var c=t.getJointPose(a[l],e);if(!c){s=!1;break}this._jointTransformMatrices.set(c.transform.matrix,16*l),this._jointRadii[l]=c.radius||.008}}s&&(qr.forEach(function(u,d){var h=n._jointTransforms[d];_.uq.FromArrayToRef(n._jointTransformMatrices,16*d,n._tempJointMatrix),n._tempJointMatrix.decompose(void 0,h.rotationQuaternion,h.position);var p=n._jointRadii[d]*n._jointScaleFactor,m=n._jointMeshes[d];m.isVisible=!n._handMesh&&!n._jointsInvisible,m.position.copyFrom(h.position),m.rotationQuaternion.copyFrom(h.rotationQuaternion),m.scaling.setAll(p),n._scene.useRightHandedSystem||(m.position.z*=-1,m.rotationQuaternion.z*=-1,m.rotationQuaternion.w*=-1,n._leftHandedMeshes&&n._handMesh&&(h.position.z*=-1,h.rotationQuaternion.z*=-1,h.rotationQuaternion.w*=-1))}),this._handMesh&&(this._handMesh.isVisible=!0))}},r.prototype.dispose=function(t){var e;t===void 0&&(t=!1),this._handMesh&&(t?((e=this._handMesh.skeleton)===null||e===void 0||e.dispose(),this._handMesh.dispose(!1,!0)):this._handMesh.isVisible=!1),this._jointTransforms.forEach(function(n){return n.dispose()}),this._jointTransforms.length=0},r}(),is=function(r){function t(e,n){var i=r.call(this,e)||this;i.options=n,i._attachedHands={},i._trackingHands={left:null,right:null},i._handResources={jointMeshes:null,handMeshes:null,rigMappings:null},i._worldScaleObserver=null,i.onHandAddedObservable=new K.cP,i.onHandRemovedObservable=new K.cP,i._attachHand=function(l){var c,u,d;if(l.inputSource.hand&&l.inputSource.handedness!="none"&&i._handResources.jointMeshes){var h=l.inputSource.handedness,p=new uv(l,i._handResources.jointMeshes[h],i._handResources.handMeshes&&i._handResources.handMeshes[h],i._handResources.rigMappings&&i._handResources.rigMappings[h],(c=i.options.handMeshes)===null||c===void 0?void 0:c.meshesUseLeftHandedCoordinates,(u=i.options.jointMeshes)===null||u===void 0?void 0:u.invisible,(d=i.options.jointMeshes)===null||d===void 0?void 0:d.scaleFactor);i._attachedHands[l.uniqueId]=p,i._trackingHands[h]=p,i.onHandAddedObservable.notifyObservers(p)}},i._detachHand=function(l){i._detachHandById(l.uniqueId)},i.xrNativeFeatureName="hand-tracking";var o=n.jointMeshes;if(o&&(o.disableDefaultHandMesh!==void 0&&(n.handMeshes=n.handMeshes||{},n.handMeshes.disableDefaultMeshes=o.disableDefaultHandMesh),o.handMeshes!==void 0&&(n.handMeshes=n.handMeshes||{},n.handMeshes.customMeshes=o.handMeshes),o.leftHandedSystemMeshes!==void 0&&(n.handMeshes=n.handMeshes||{},n.handMeshes.meshesUseLeftHandedCoordinates=o.leftHandedSystemMeshes),o.rigMapping!==void 0)){n.handMeshes=n.handMeshes||{};var a={},s={};[[o.rigMapping.left,a],[o.rigMapping.right,s]].forEach(function(l){var c=l[0],u=l[1];c.forEach(function(d,h){u[qr[h]]=d})}),n.handMeshes.customRigMappings={left:a,right:s}}return i}return(0,A.C6)(t,r),t._GenerateTrackedJointMeshes=function(e,n){n===void 0&&(n=sa("jointParent",t._ICOSPHERE_PARAMS));var i={};return["left","right"].map(function(o){var a,s,l,c,u=[];n.isVisible=!!(!((a=e.jointMeshes)===null||a===void 0)&&a.keepOriginalVisible);for(var d=0;d<qr.length;++d){var h=n.createInstance("".concat(o,"-handJoint-").concat(d));if(!((s=e.jointMeshes)===null||s===void 0)&&s.onHandJointMeshGenerated){var p=e.jointMeshes.onHandJointMeshGenerated(h,d,o);p&&p!==h&&(h.dispose(),h=p)}if(h.isPickable=!1,(l=e.jointMeshes)===null||l===void 0?void 0:l.enablePhysics){var m=((c=e.jointMeshes)===null||c===void 0?void 0:c.physicsProps)||{};h.scaling.setAll(.02);var v=m.impostorType!==void 0?m.impostorType:Dt.SphereImpostor;h.physicsImpostor=new Dt(h,v,(0,A.Cl)({mass:0},m))}h.rotationQuaternion=new _.PT,h.isVisible=!1,u.push(h)}i[o]=u}),{left:i.left,right:i.right}},t._GenerateDefaultHandMeshesAsync=function(e,n,i){var o=this;return new Promise(function(a){return(0,A.sH)(o,void 0,void 0,function(){var s,l,c,u,d,h,p,m,v,b,E,C,T;return(0,A.YH)(this,function(f){switch(f.label){case 0:return s={},!((v=(m=t._RightHandGLB)===null||m===void 0?void 0:m.meshes[1])===null||v===void 0)&&v.isDisposed()&&(t._RightHandGLB=null),!((E=(b=t._LeftHandGLB)===null||b===void 0?void 0:b.meshes[1])===null||E===void 0)&&E.isDisposed()&&(t._LeftHandGLB=null),l=!(!t._RightHandGLB||!t._LeftHandGLB),[4,Promise.all([t._RightHandGLB||yn.ImportMeshAsync("",t.DEFAULT_HAND_MODEL_BASE_URL,t.DEFAULT_HAND_MODEL_RIGHT_FILENAME,e),t._LeftHandGLB||yn.ImportMeshAsync("",t.DEFAULT_HAND_MODEL_BASE_URL,t.DEFAULT_HAND_MODEL_LEFT_FILENAME,e)])];case 1:return c=f.sent(),t._RightHandGLB=c[0],t._LeftHandGLB=c[1],[4,so.ParseFromFileAsync("handShader",t.DEFAULT_HAND_MODEL_SHADER_URL,e,void 0,!0)];case 2:return(u=f.sent()).needDepthPrePass=!0,u.transparencyMode=Lt.MATERIAL_ALPHABLEND,u.alphaMode=P.Y.ALPHA_COMBINE,u.build(!1),d=(0,A.Cl)({base:z.v9.FromInts(116,63,203),fresnel:z.v9.FromInts(149,102,229),fingerColor:z.v9.FromInts(177,130,255),tipFresnel:z.v9.FromInts(220,200,255)},(C=i?.handMeshes)===null||C===void 0?void 0:C.customColors),(h={base:u.getBlockByName("baseColor"),fresnel:u.getBlockByName("fresnelColor"),fingerColor:u.getBlockByName("fingerColor"),tipFresnel:u.getBlockByName("tipFresnelColor")}).base.value=d.base,h.fresnel.value=d.fresnel,h.fingerColor.value=d.fingerColor,h.tipFresnel.value=d.tipFresnel,p=(T=n._getBaseLayerWrapper())===null||T===void 0?void 0:T.isMultiview,["left","right"].forEach(function(g){var S,y=g=="left"?t._LeftHandGLB:t._RightHandGLB;if(!y)throw new Error("Could not load hand model");var x=y.meshes[1];x._internalAbstractMeshDataInfo._computeBonesUsingShaders=!0,p||!((S=i?.handMeshes)===null||S===void 0)&&S.disableHandShader||(x.material=u.clone("".concat(g,"HandShaderClone"),!0)),x.isVisible=!1,s[g]=x,l||e.useRightHandedSystem||y.meshes[1].rotate(Qn._0.Y,Math.PI)}),u.dispose(),a({left:s.left,right:s.right}),[2]}})})})},t._GenerateDefaultHandMeshRigMapping=function(e){var n,i=e=="right"?"R":"L";return(n={}).wrist="wrist_".concat(i),n["thumb-metacarpal"]="thumb_metacarpal_".concat(i),n["thumb-phalanx-proximal"]="thumb_proxPhalanx_".concat(i),n["thumb-phalanx-distal"]="thumb_distPhalanx_".concat(i),n["thumb-tip"]="thumb_tip_".concat(i),n["index-finger-metacarpal"]="index_metacarpal_".concat(i),n["index-finger-phalanx-proximal"]="index_proxPhalanx_".concat(i),n["index-finger-phalanx-intermediate"]="index_intPhalanx_".concat(i),n["index-finger-phalanx-distal"]="index_distPhalanx_".concat(i),n["index-finger-tip"]="index_tip_".concat(i),n["middle-finger-metacarpal"]="middle_metacarpal_".concat(i),n["middle-finger-phalanx-proximal"]="middle_proxPhalanx_".concat(i),n["middle-finger-phalanx-intermediate"]="middle_intPhalanx_".concat(i),n["middle-finger-phalanx-distal"]="middle_distPhalanx_".concat(i),n["middle-finger-tip"]="middle_tip_".concat(i),n["ring-finger-metacarpal"]="ring_metacarpal_".concat(i),n["ring-finger-phalanx-proximal"]="ring_proxPhalanx_".concat(i),n["ring-finger-phalanx-intermediate"]="ring_intPhalanx_".concat(i),n["ring-finger-phalanx-distal"]="ring_distPhalanx_".concat(i),n["ring-finger-tip"]="ring_tip_".concat(i),n["pinky-finger-metacarpal"]="little_metacarpal_".concat(i),n["pinky-finger-phalanx-proximal"]="little_proxPhalanx_".concat(i),n["pinky-finger-phalanx-intermediate"]="little_intPhalanx_".concat(i),n["pinky-finger-phalanx-distal"]="little_distPhalanx_".concat(i),n["pinky-finger-tip"]="little_tip_".concat(i),n},t.prototype.isCompatible=function(){return typeof XRHand<"u"},t.prototype.getHandByControllerId=function(e){return this._attachedHands[e]},t.prototype.getHandByHandedness=function(e){return e=="none"?null:this._trackingHands[e]},t.prototype.attach=function(){var e,n,i,o,a,s=this;return!!r.prototype.attach.call(this)&&(this._handResources.jointMeshes||(this._originalMesh=this._originalMesh||((e=this.options.jointMeshes)===null||e===void 0?void 0:e.sourceMesh)||sa("jointParent",t._ICOSPHERE_PARAMS),this._originalMesh.isVisible=!1,this._handResources.jointMeshes=t._GenerateTrackedJointMeshes(this.options,this._originalMesh)),this._handResources.handMeshes=((n=this.options.handMeshes)===null||n===void 0?void 0:n.customMeshes)||null,this._handResources.rigMappings=((i=this.options.handMeshes)===null||i===void 0?void 0:i.customRigMappings)||null,!((o=this.options.handMeshes)===null||o===void 0)&&o.customMeshes||!((a=this.options.handMeshes)===null||a===void 0)&&a.disableDefaultMeshes||(t._GenerateDefaultHandMeshesAsync(Ve.q.LastCreatedScene,this._xrSessionManager,this.options).then(function(l){var c,u;s._handResources.handMeshes=l,s._handResources.rigMappings={left:t._GenerateDefaultHandMeshRigMapping("left"),right:t._GenerateDefaultHandMeshRigMapping("right")},(c=s._trackingHands.left)===null||c===void 0||c.setHandMesh(s._handResources.handMeshes.left,s._handResources.rigMappings.left,s._xrSessionManager),(u=s._trackingHands.right)===null||u===void 0||u.setHandMesh(s._handResources.handMeshes.right,s._handResources.rigMappings.right,s._xrSessionManager),s._handResources.handMeshes.left.scaling.setAll(s._xrSessionManager.worldScalingFactor),s._handResources.handMeshes.right.scaling.setAll(s._xrSessionManager.worldScalingFactor)}),this._worldScaleObserver=this._xrSessionManager.onWorldScaleFactorChangedObservable.add(function(l){s._handResources.handMeshes&&(s._handResources.handMeshes.left.scaling.scaleInPlace(l.newScaleFactor/l.previousScaleFactor),s._handResources.handMeshes.right.scaling.scaleInPlace(l.newScaleFactor/l.previousScaleFactor))})),this.options.xrInput.controllers.forEach(this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,this._detachHand),!0)},t.prototype._onXRFrame=function(e){var n,i;(n=this._trackingHands.left)===null||n===void 0||n.updateFromXRFrame(e,this._xrSessionManager.referenceSpace),(i=this._trackingHands.right)===null||i===void 0||i.updateFromXRFrame(e,this._xrSessionManager.referenceSpace)},t.prototype._detachHandById=function(e,n){var i,o=this.getHandByControllerId(e);if(o){var a=o.xrController.inputSource.handedness=="left"?"left":"right";((i=this._trackingHands[a])===null||i===void 0?void 0:i.xrController.uniqueId)===e&&(this._trackingHands[a]=null),this.onHandRemovedObservable.notifyObservers(o),o.dispose(n),delete this._attachedHands[e]}},t.prototype.detach=function(){var e,n,i,o,a=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._attachedHands).forEach(function(s){var l;return a._detachHandById(s,(l=a.options.handMeshes)===null||l===void 0?void 0:l.disposeOnSessionEnd)}),!((e=this.options.handMeshes)===null||e===void 0)&&e.disposeOnSessionEnd&&(this._handResources.jointMeshes&&(this._handResources.jointMeshes.left.forEach(function(s){return s.dispose()}),this._handResources.jointMeshes.right.forEach(function(s){return s.dispose()}),this._handResources.jointMeshes=null),this._handResources.handMeshes&&(this._handResources.handMeshes.left.dispose(),this._handResources.handMeshes.right.dispose(),this._handResources.handMeshes=null),(n=t._RightHandGLB)===null||n===void 0||n.meshes.forEach(function(s){return s.dispose()}),(i=t._LeftHandGLB)===null||i===void 0||i.meshes.forEach(function(s){return s.dispose()}),t._RightHandGLB=null,t._LeftHandGLB=null,(o=this._originalMesh)===null||o===void 0||o.dispose(),this._originalMesh=void 0),this._worldScaleObserver&&this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(this._worldScaleObserver),!0)},t.prototype.dispose=function(){var e,n,i;r.prototype.dispose.call(this),this.onHandAddedObservable.clear(),this.onHandRemovedObservable.clear(),this._handResources.handMeshes&&!(!((e=this.options.handMeshes)===null||e===void 0)&&e.customMeshes)&&(this._handResources.handMeshes.left.dispose(),this._handResources.handMeshes.right.dispose(),(n=t._RightHandGLB)===null||n===void 0||n.meshes.forEach(function(o){return o.dispose()}),(i=t._LeftHandGLB)===null||i===void 0||i.meshes.forEach(function(o){return o.dispose()}),t._RightHandGLB=null,t._LeftHandGLB=null),this._handResources.jointMeshes&&(this._handResources.jointMeshes.left.forEach(function(o){return o.dispose()}),this._handResources.jointMeshes.right.forEach(function(o){return o.dispose()}))},t.Name=vn.HAND_TRACKING,t.Version=1,t.DEFAULT_HAND_MODEL_BASE_URL="https://assets.babylonjs.com/meshes/HandMeshes/",t.DEFAULT_HAND_MODEL_RIGHT_FILENAME="r_hand_rhs.glb",t.DEFAULT_HAND_MODEL_LEFT_FILENAME="l_hand_rhs.glb",t.DEFAULT_HAND_MODEL_SHADER_URL="https://assets.babylonjs.com/meshes/HandMeshes/handsShader.json",t._ICOSPHERE_PARAMS={radius:.5,flat:!1,subdivisions:2},t._RightHandGLB=null,t._LeftHandGLB=null,t}(qn);function rs(r){var t,e=0,n=Date.now();r.observableParameters=(t=r.observableParameters)!==null&&t!==void 0?t:{};var i=r.contextObservable.add(function(o){var a=Date.now(),s={startTime:n,currentTime:a,deltaTime:e=a-n,completeRate:e/r.timeout,payload:o};r.onTick&&r.onTick(s),r.breakCondition&&r.breakCondition()&&(r.contextObservable.remove(i),r.onAborted&&r.onAborted(s)),e>=r.timeout&&(r.contextObservable.remove(i),r.onEnded&&r.onEnded(s))},r.observableParameters.mask,r.observableParameters.insertFirst,r.observableParameters.scope);return i}kn.AddWebXRFeature(is.Name,function(r,t){return function(){return new is(r,t)}},is.Version,!1),function(r){r[r.INIT=0]="INIT",r[r.STARTED=1]="STARTED",r[r.ENDED=2]="ENDED"}(ch||(ch={}));var dv=function(){function r(t){var e,n,i=this;this.onEachCountObservable=new K.cP,this.onTimerAbortedObservable=new K.cP,this.onTimerEndedObservable=new K.cP,this.onStateChangedObservable=new K.cP,this._observer=null,this._breakOnNextTick=!1,this._tick=function(o){var a=Date.now();i._timer=a-i._startTime;var s={startTime:i._startTime,currentTime:a,deltaTime:i._timer,completeRate:i._timer/i._timeToEnd,payload:o},l=i._breakOnNextTick||i._breakCondition(s);l||i._timer>=i._timeToEnd?i._stop(s,l):i.onEachCountObservable.notifyObservers(s)},this._setState(0),this._contextObservable=t.contextObservable,this._observableParameters=(e=t.observableParameters)!==null&&e!==void 0?e:{},this._breakCondition=(n=t.breakCondition)!==null&&n!==void 0?n:function(){return!1},this._timeToEnd=t.timeout,t.onEnded&&this.onTimerEndedObservable.add(t.onEnded),t.onTick&&this.onEachCountObservable.add(t.onTick),t.onAborted&&this.onTimerAbortedObservable.add(t.onAborted)}return Object.defineProperty(r.prototype,"breakCondition",{set:function(t){this._breakCondition=t},enumerable:!1,configurable:!0}),r.prototype.clearObservables=function(){this.onEachCountObservable.clear(),this.onTimerAbortedObservable.clear(),this.onTimerEndedObservable.clear(),this.onStateChangedObservable.clear()},r.prototype.start=function(t){if(t===void 0&&(t=this._timeToEnd),this._state===1)throw new Error("Timer already started. Please stop it before starting again");this._timeToEnd=t,this._startTime=Date.now(),this._timer=0,this._observer=this._contextObservable.add(this._tick,this._observableParameters.mask,this._observableParameters.insertFirst,this._observableParameters.scope),this._setState(1)},r.prototype.stop=function(){this._state===1&&(this._breakOnNextTick=!0)},r.prototype.dispose=function(){this._observer&&this._contextObservable.remove(this._observer),this.clearObservables()},r.prototype._setState=function(t){this._state=t,this.onStateChangedObservable.notifyObservers(this._state)},r.prototype._stop=function(t,e){e===void 0&&(e=!1),this._contextObservable.remove(this._observer),this._setState(2),e?this.onTimerAbortedObservable.notifyObservers(t):this.onTimerEndedObservable.notifyObservers(t)},r}(),os=function(r){function t(e,n){var i=r.call(this,e)||this;return i._options=n,i._controllers={},i._snappedToPoint=!1,i._cachedColor4White=new z.ov(1,1,1,1),i._tmpRay=new fn(new _.Pq,new _.Pq),i._tmpVector=new _.Pq,i._tmpQuaternion=new _.PT,i._worldScaleObserver=null,i.skipNextTeleportation=!1,i.backwardsMovementEnabled=!0,i.backwardsTeleportationDistance=.7,i.parabolicCheckRadius=5,i.parabolicRayEnabled=!0,i.straightRayEnabled=!0,i.rotationAngle=Math.PI/8,i.onTargetMeshPositionUpdatedObservable=new K.cP,i.teleportationEnabled=!0,i._rotationEnabled=!0,i.onBeforeCameraTeleportRotation=new K.cP,i.onAfterCameraTeleportRotation=new K.cP,i._attachController=function(o){if(!(i._controllers[o.uniqueId]||i._options.forceHandedness&&o.inputSource.handedness!==i._options.forceHandedness)){i._controllers[o.uniqueId]={xrController:o,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0,blocked:!1,initialHit:!1,mainComponentUsed:!1}};var a=i._controllers[o.uniqueId];if(a.xrController.inputSource.targetRayMode==="tracked-pointer"&&a.xrController.inputSource.gamepad){var s=function(){if(o.motionController){var u=o.motionController.getComponentOfType(Xr.THUMBSTICK_TYPE)||o.motionController.getComponentOfType(Xr.TOUCHPAD_TYPE);if(!u||i._options.useMainComponentOnly){var d=o.motionController.getMainComponent();if(!d)return;a.teleportationState.mainComponentUsed=!0,a.teleportationComponent=d,a.onButtonChangedObserver=d.onButtonStateChangedObservable.add(function(){if(i.teleportationEnabled){var h=function(){a.teleportationState.forward=!0,a.teleportationState.initialHit=!1,i._currentTeleportationControllerId=a.xrController.uniqueId,a.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,a.teleportationState.currentRotation=0,rs({timeout:i._options.timeToTeleport||3e3,contextObservable:i._xrSessionManager.onXRFrameObservable,breakCondition:function(){return!d.pressed},onEnded:function(){i._currentTeleportationControllerId===a.xrController.uniqueId&&a.teleportationState.forward&&i._teleportForward(o.uniqueId)}})};d.changes.pressed&&(d.changes.pressed.current?i._options.timeToTeleportStart?rs({timeout:i._options.timeToTeleportStart,contextObservable:i._xrSessionManager.onXRFrameObservable,onEnded:function(){d.pressed&&h()}}):h():(a.teleportationState.forward=!1,i._currentTeleportationControllerId=""))}})}else a.teleportationComponent=u,a.onAxisChangedObserver=u.onAxisValueChangedObservable.add(function(h){if(h.y<=.7&&a.teleportationState.backwards&&(a.teleportationState.backwards=!1),h.y>.7&&!a.teleportationState.forward&&i.backwardsMovementEnabled&&!i.snapPointsOnly&&!a.teleportationState.backwards){a.teleportationState.backwards=!0,i._tmpQuaternion.copyFrom(i._options.xrInput.xrCamera.rotationQuaternion),i._tmpQuaternion.toEulerAnglesToRef(i._tmpVector),i._tmpVector.x=0,i._tmpVector.z=0,_.PT.FromEulerVectorToRef(i._tmpVector,i._tmpQuaternion),i._tmpVector.set(0,0,i.backwardsTeleportationDistance*(i._xrSessionManager.scene.useRightHandedSystem?1:-1)),i._tmpVector.rotateByQuaternionToRef(i._tmpQuaternion,i._tmpVector),i._tmpVector.addInPlace(i._options.xrInput.xrCamera.position),i._tmpRay.origin.copyFrom(i._tmpVector),i._tmpRay.length=i._options.xrInput.xrCamera.realWorldHeight+.1,i._tmpRay.direction.set(0,-1,0);var p=i._xrSessionManager.scene.pickWithRay(i._tmpRay,function(v){return i._floorMeshes.indexOf(v)!==-1});p&&p.pickedPoint&&(i._options.xrInput.xrCamera.position.x=p.pickedPoint.x,i._options.xrInput.xrCamera.position.z=p.pickedPoint.z)}if(h.y<-.7&&!i._currentTeleportationControllerId&&!a.teleportationState.rotating&&i.teleportationEnabled&&(a.teleportationState.forward=!0,i._currentTeleportationControllerId=a.xrController.uniqueId,a.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),h.x){if(a.teleportationState.forward)i._currentTeleportationControllerId===a.xrController.uniqueId&&(i.rotationEnabled?setTimeout(function(){a.teleportationState.currentRotation=Math.atan2(h.x,h.y*(i._xrSessionManager.scene.useRightHandedSystem?1:-1))}):a.teleportationState.currentRotation=0);else if(!a.teleportationState.rotating&&Math.abs(h.x)>.7){a.teleportationState.rotating=!0;var m=i.rotationAngle*(h.x>0?1:-1)*(i._xrSessionManager.scene.useRightHandedSystem?-1:1);i.onBeforeCameraTeleportRotation.notifyObservers(m),_.PT.FromEulerAngles(0,m,0).multiplyToRef(i._options.xrInput.xrCamera.rotationQuaternion,i._options.xrInput.xrCamera.rotationQuaternion),i.onAfterCameraTeleportRotation.notifyObservers(i._options.xrInput.xrCamera.rotationQuaternion)}}else a.teleportationState.rotating=!1;h.x===0&&h.y===0&&(a.teleportationState.blocked&&(a.teleportationState.blocked=!1,i._setTargetMeshVisibility(!1)),a.teleportationState.forward&&i._teleportForward(o.uniqueId))})}};o.motionController?s():o.onMotionControllerInitObservable.addOnce(function(){s()})}else{a.teleportationState.mainComponentUsed=!0;var l=!1,c=function(){i._currentTeleportationControllerId=a.xrController.uniqueId,a.teleportationState.forward=!0,a.teleportationState.initialHit=!1,a.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,a.teleportationState.currentRotation=0,rs({timeout:i._options.timeToTeleport||3e3,contextObservable:i._xrSessionManager.onXRFrameObservable,onEnded:function(){i._currentTeleportationControllerId===a.xrController.uniqueId&&a.teleportationState.forward&&i._teleportForward(o.uniqueId)}})};i._xrSessionManager.scene.onPointerObservable.add(function(u){u.type===vt.Zp.POINTERDOWN?(l=!1,i._options.timeToTeleportStart?rs({timeout:i._options.timeToTeleportStart,contextObservable:i._xrSessionManager.onXRFrameObservable,onEnded:function(){i._currentTeleportationControllerId===a.xrController.uniqueId&&c()},breakCondition:function(){return!!l&&(l=!1,!0)}}):c()):u.type===vt.Zp.POINTERUP&&(l=!0,a.teleportationState.forward=!1,i._currentTeleportationControllerId="")})}}},i._colorArray=Array(24).fill(i._cachedColor4White),i._options.teleportationTargetMesh||i._createDefaultTargetMesh(),i._floorMeshes=i._options.floorMeshes||[],i._snapToPositions=i._options.snapPositions||[],i._blockedRayColor=i._options.blockedRayColor||new z.ov(1,0,0,.75),i._setTargetMeshVisibility(!1),i.onBeforeCameraTeleport=n.xrInput.xrCamera.onBeforeCameraTeleport,i.onAfterCameraTeleport=n.xrInput.xrCamera.onAfterCameraTeleport,i.parabolicCheckRadius*=i._xrSessionManager.worldScalingFactor,i._worldScaleObserver=e.onWorldScaleFactorChangedObservable.add(function(o){var a;i.parabolicCheckRadius=i.parabolicCheckRadius/o.previousScaleFactor*o.newScaleFactor,(a=i._options.teleportationTargetMesh)===null||a===void 0||a.scaling.scaleInPlace(o.newScaleFactor/o.previousScaleFactor)}),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"rotationEnabled",{get:function(){return this._rotationEnabled},set:function(e){if(this._rotationEnabled=e,this._options.teleportationTargetMesh){var n=this._options.teleportationTargetMesh.getChildMeshes(!1,function(i){return i.name==="rotationCone"});n[0]&&n[0].setEnabled(e)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"teleportationTargetMesh",{get:function(){return this._options.teleportationTargetMesh||null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapPointsOnly",{get:function(){return!!this._options.snapPointsOnly},set:function(e){this._options.snapPointsOnly=e},enumerable:!1,configurable:!0}),t.prototype.addFloorMesh=function(e){this._floorMeshes.push(e)},t.prototype.addBlockerMesh=function(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[],this._options.pickBlockerMeshes.push(e)},t.prototype.addSnapPoint=function(e){this._snapToPositions.push(e)},t.prototype.attach=function(){var e=this;return!!r.prototype.attach.call(this)&&(this._currentTeleportationControllerId="",this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(n){e._detachController(n.uniqueId)}),!0)},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach(function(n){e._detachController(n)}),this._setTargetMeshVisibility(!1),this._currentTeleportationControllerId="",this._controllers={},!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.dispose(!1,!0),this._worldScaleObserver&&this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(this._worldScaleObserver)},t.prototype.removeFloorMesh=function(e){var n=this._floorMeshes.indexOf(e);n!==-1&&this._floorMeshes.splice(n,1)},t.prototype.removeBlockerMesh=function(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[];var n=this._options.pickBlockerMeshes.indexOf(e);n!==-1&&this._options.pickBlockerMeshes.splice(n,1)},t.prototype.removeFloorMeshByName=function(e){var n=this._xrSessionManager.scene.getMeshByName(e);n&&this.removeFloorMesh(n)},t.prototype.removeSnapPoint=function(e){var n=this._snapToPositions.indexOf(e);if(n===-1){for(var i=0;i<this._snapToPositions.length;++i)if(this._snapToPositions[i].equals(e)){n=i;break}}return n!==-1&&(this._snapToPositions.splice(n,1),!0)},t.prototype.setSelectionFeature=function(e){this._selectionFeature=e},t.prototype._onXRFrame=function(e){var n=this,i=this._xrSessionManager.currentFrame,o=this._xrSessionManager.scene;if(this.attach&&i){var a=this._options.teleportationTargetMesh;if(this._currentTeleportationControllerId){if(!a)return;a.rotationQuaternion=a.rotationQuaternion||new _.PT;var s=this._controllers[this._currentTeleportationControllerId];if(s&&s.teleportationState.forward){_.PT.RotationYawPitchRollToRef(s.teleportationState.currentRotation+s.teleportationState.baseRotation,0,0,a.rotationQuaternion);var l=!1,c=s.xrController.inputSource.targetRayMode!=="transient-pointer";if(s.xrController.getWorldPointerRayToRef(this._tmpRay),this.straightRayEnabled){var u=(d=o.pickWithRay(this._tmpRay,function(v){if(n._options.blockerMeshesPredicate&&n._options.blockerMeshesPredicate(v)||n._options.blockAllPickableMeshes&&v.isPickable||n._options.pickBlockerMeshes&&n._options.pickBlockerMeshes.indexOf(v)!==-1)return!0;var b=n._floorMeshes.indexOf(v);return b!==-1&&n._floorMeshes[b].absolutePosition.y<n._options.xrInput.xrCamera.globalPosition.y}))&&d.pickedMesh&&this._floorMeshes.indexOf(d.pickedMesh)!==-1;if(d&&d.pickedMesh&&!u)return s.teleportationState.mainComponentUsed&&!s.teleportationState.initialHit?void(s.teleportationState.forward=!1):(s.teleportationState.blocked=!0,this._setTargetMeshVisibility(!1,!1,c),void this._showParabolicPath(d));d&&d.pickedPoint&&(s.teleportationState.initialHit=!0,s.teleportationState.blocked=!1,l=!0,this._setTargetMeshPosition(d),this._setTargetMeshVisibility(!0,!1,c),this._showParabolicPath(d))}if(this.parabolicRayEnabled&&!l){var d,h=s.xrController.pointer.rotationQuaternion.toEulerAngles().x,p=Math.PI/2-Math.abs(h)+1,m=this.parabolicCheckRadius*p;if(this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2*m),this._tmpVector),this._tmpVector.y=this._tmpRay.origin.y,this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(m)),this._tmpVector.subtractToRef(this._tmpRay.origin,this._tmpRay.direction),this._tmpRay.direction.normalize(),u=(d=o.pickWithRay(this._tmpRay,function(v){return!(!n._options.blockerMeshesPredicate||!n._options.blockerMeshesPredicate(v))||!(!n._options.blockAllPickableMeshes||!v.isPickable)||!(!n._options.pickBlockerMeshes||n._options.pickBlockerMeshes.indexOf(v)===-1)||n._floorMeshes.indexOf(v)!==-1}))&&d.pickedMesh&&this._floorMeshes.indexOf(d.pickedMesh)!==-1,d&&d.pickedMesh&&!u)return s.teleportationState.mainComponentUsed&&!s.teleportationState.initialHit?void(s.teleportationState.forward=!1):(s.teleportationState.blocked=!0,this._setTargetMeshVisibility(!1,!1,c),void this._showParabolicPath(d));d&&d.pickedPoint&&(s.teleportationState.initialHit=!0,s.teleportationState.blocked=!1,l=!0,this._setTargetMeshPosition(d),this._setTargetMeshVisibility(!0,!1,c),this._showParabolicPath(d))}this._setTargetMeshVisibility(l,!1,c)}else this._setTargetMeshVisibility(!1,!1,!0)}else this._disposeBezierCurve(),this._setTargetMeshVisibility(!1,!1,!0)}},t.prototype._createDefaultTargetMesh=function(){this._options.defaultTargetMeshOptions=this._options.defaultTargetMeshOptions||{};var e=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Fn.DefaultUtilityLayer.utilityLayerScene:this._xrSessionManager.scene,n=ta("teleportationTarget",{width:2,height:2,subdivisions:2},e);if(n.isPickable=!1,this._options.defaultTargetMeshOptions.teleportationCircleMaterial)n.material=this._options.defaultTargetMeshOptions.teleportationCircleMaterial;else{var i=new Oo("teleportationPlaneDynamicTexture",512,e,!0);i.hasAlpha=!0;var o=i.getContext();o.beginPath(),o.arc(256,256,200,0,2*Math.PI,!1),o.fillStyle=this._options.defaultTargetMeshOptions.teleportationFillColor||"#444444",o.fill(),o.lineWidth=10,o.strokeStyle=this._options.defaultTargetMeshOptions.teleportationBorderColor||"#FFFFFF",o.stroke(),o.closePath(),i.update();var a=new qt("teleportationPlaneMaterial",e);a.diffuseTexture=i,n.material=a}var s=Sr("torusTeleportation",{diameter:.75,thickness:.1,tessellation:20},e);if(s.isPickable=!1,s.parent=n,!this._options.defaultTargetMeshOptions.disableAnimation){var l=new Le("animationInnerCircle","position.y",30,Le.ANIMATIONTYPE_FLOAT,Le.ANIMATIONLOOPMODE_CYCLE),c=[];c.push({frame:0,value:0}),c.push({frame:30,value:.4}),c.push({frame:60,value:0}),l.setKeys(c);var u=new Ci;u.setEasingMode(Wt.EASINGMODE_EASEINOUT),l.setEasingFunction(u),s.animations=[],s.animations.push(l),e.beginAnimation(s,0,60,!0)}var d=_i("rotationCone",{diameterTop:0,tessellation:4},e);if(d.isPickable=!1,d.scaling.set(.5,.12,.2),d.rotate(Qn._0.X,Math.PI/2),d.position.z=.6,d.parent=s,this._options.defaultTargetMeshOptions.torusArrowMaterial)s.material=this._options.defaultTargetMeshOptions.torusArrowMaterial,d.material=this._options.defaultTargetMeshOptions.torusArrowMaterial;else{var h=new qt("torusConsMat",e);h.disableLighting=!!this._options.defaultTargetMeshOptions.disableLighting,h.disableLighting?h.emissiveColor=new z.v9(.3,.3,1):h.diffuseColor=new z.v9(.3,.3,1),h.alpha=.9,s.material=h,d.material=h,this._teleportationRingMaterial=h}this._options.renderingGroupId!==void 0&&(n.renderingGroupId=this._options.renderingGroupId,s.renderingGroupId=this._options.renderingGroupId,d.renderingGroupId=this._options.renderingGroupId),this._options.teleportationTargetMesh=n,this._options.teleportationTargetMesh.scaling.setAll(this._xrSessionManager.worldScalingFactor),this._setTargetMeshVisibility(!1)},t.prototype._detachController=function(e){var n=this._controllers[e];n&&(n.teleportationComponent&&(n.onAxisChangedObserver&&n.teleportationComponent.onAxisValueChangedObservable.remove(n.onAxisChangedObserver),n.onButtonChangedObserver&&n.teleportationComponent.onButtonStateChangedObservable.remove(n.onButtonChangedObserver)),delete this._controllers[e])},t.prototype._findClosestSnapPointWithRadius=function(e,n){n===void 0&&(n=this._options.snapToPositionRadius||.8);var i=null,o=Number.MAX_VALUE;if(this._snapToPositions.length){var a=n*n;this._snapToPositions.forEach(function(s){var l=_.Pq.DistanceSquared(s,e);l<=a&&l<o&&(o=l,i=s)})}return i},t.prototype._setTargetMeshPosition=function(e){var n=e.pickedPoint;if(this._options.teleportationTargetMesh&&n){var i=this._findClosestSnapPointWithRadius(n);this._snappedToPoint=!!i,this.snapPointsOnly&&!this._snappedToPoint&&this._teleportationRingMaterial?this._teleportationRingMaterial.diffuseColor.set(1,.3,.3):this.snapPointsOnly&&this._snappedToPoint&&this._teleportationRingMaterial&&this._teleportationRingMaterial.diffuseColor.set(.3,.3,1),this._options.teleportationTargetMesh.position.copyFrom(i||n),this._options.teleportationTargetMesh.position.y+=.01,this.onTargetMeshPositionUpdatedObservable.notifyObservers(e)}},t.prototype._setTargetMeshVisibility=function(e,n,i){this._options.teleportationTargetMesh&&(this._options.teleportationTargetMesh.isVisible!==e||n)&&(this._options.teleportationTargetMesh.isVisible=e,this._options.teleportationTargetMesh.getChildren(void 0,!1).forEach(function(o){o.isVisible=e}),e?this._selectionFeature&&i&&this._selectionFeature.detach():(this._quadraticBezierCurve&&(this._quadraticBezierCurve.dispose(),this._quadraticBezierCurve=null),this._selectionFeature&&i&&this._selectionFeature.attach()))},t.prototype._disposeBezierCurve=function(){this._quadraticBezierCurve&&(this._quadraticBezierCurve.dispose(),this._quadraticBezierCurve=null)},t.prototype._showParabolicPath=function(e){if(e.pickedPoint&&this._currentTeleportationControllerId){var n=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Fn.DefaultUtilityLayer.utilityLayerScene:this._xrSessionManager.scene,i=this._controllers[this._currentTeleportationControllerId],o=Bt.jj.CreateQuadraticBezier(i.xrController.pointer.absolutePosition,e.ray.origin,e.pickedPoint,25),a=i.teleportationState.blocked?this._blockedRayColor:void 0,s=this._colorArray.fill(a||this._cachedColor4White),l=o.getPoints();l.shift(),l.shift(),this._options.generateRayPathMesh?this._quadraticBezierCurve=this._options.generateRayPathMesh(o.getPoints(),e):this._quadraticBezierCurve=dn("teleportation path line",{points:l,instance:this._quadraticBezierCurve,updatable:!0,colors:s},n),this._quadraticBezierCurve.isPickable=!1,this._options.renderingGroupId!==void 0&&(this._quadraticBezierCurve.renderingGroupId=this._options.renderingGroupId)}},t.prototype._teleportForward=function(e){var n=this._controllers[e];if(n&&n.teleportationState.forward&&this.teleportationEnabled&&(n.teleportationState.forward=!1,this._currentTeleportationControllerId="",!this.snapPointsOnly||this._snappedToPoint)){if(this.skipNextTeleportation)this.skipNextTeleportation=!1;else if(this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.isVisible){var i=this._options.xrInput.xrCamera.realWorldHeight;this.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position),this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position),this._options.xrInput.xrCamera.position.y+=i,_.PT.FromEulerAngles(0,n.teleportationState.currentRotation-(this._xrSessionManager.scene.useRightHandedSystem?Math.PI:0),0).multiplyToRef(this._options.xrInput.xrCamera.rotationQuaternion,this._options.xrInput.xrCamera.rotationQuaternion),this.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position)}}},t.Name=vn.TELEPORTATION,t.Version=1,t}(qn);kn.AddWebXRFeature(os.Name,function(r,t){return function(){return new os(r,t)}},os.Version,!0);var Vx=function(){},hv=function(){function r(){}return r.CreateAsync=function(t,e){e===void 0&&(e={});var n=new r;if(t.onDisposeObservable.addOnce(function(){n.dispose()}),!e.disableDefaultUI){var i=(0,A.Cl)({renderTarget:n.renderTarget},e.uiOptions||{});e.optionalFeatures&&(typeof e.optionalFeatures=="boolean"?i.optionalFeatures=["hit-test","anchors","plane-detection","hand-tracking"]:i.optionalFeatures=e.optionalFeatures),n.enterExitUI=new cv(t,i)}return Yg.CreateAsync(t).then(function(o){if(n.baseExperience=o,e.ignoreNativeCameraTransformation&&(n.baseExperience.camera.compensateOnFirstFrame=!1),n.input=new rv(o.sessionManager,o.camera,(0,A.Cl)({controllerOptions:{renderingGroupId:e.renderingGroupId}},e.inputOptions||{})),!e.disablePointerSelection){var a=(0,A.Cl)((0,A.Cl)({},e.pointerSelectionOptions),{xrInput:n.input,renderingGroupId:e.renderingGroupId});n.pointerSelection=n.baseExperience.featuresManager.enableFeature(Ja.Name,e.useStablePlugins?"stable":"latest",a),e.disableTeleportation||(n.teleportation=n.baseExperience.featuresManager.enableFeature(os.Name,e.useStablePlugins?"stable":"latest",(0,A.Cl)({floorMeshes:e.floorMeshes,xrInput:n.input,renderingGroupId:e.renderingGroupId},e.teleportationOptions)),n.teleportation.setSelectionFeature(n.pointerSelection))}return e.disableNearInteraction||(n.nearInteraction=n.baseExperience.featuresManager.enableFeature(ns.Name,e.useStablePlugins?"stable":"latest",(0,A.Cl)({xrInput:n.input,farInteractionFeature:n.pointerSelection,renderingGroupId:e.renderingGroupId,useUtilityLayer:!0,enableNearInteractionOnAllControllers:!0},e.nearInteractionOptions))),e.disableHandTracking||n.baseExperience.featuresManager.enableFeature(is.Name,e.useStablePlugins?"stable":"latest",(0,A.Cl)({xrInput:n.input},e.handSupportOptions),void 0,!1),n.renderTarget=n.baseExperience.sessionManager.getWebXRRenderTarget(e.outputCanvasOptions),e.disableDefaultUI?void 0:n.enterExitUI.setHelperAsync(n.baseExperience,n.renderTarget)}).then(function(){return n}).catch(function(o){return O.V.Error("Error initializing XR"),O.V.Error(o),n})},r.prototype.dispose=function(){this.baseExperience&&this.baseExperience.dispose(),this.input&&this.input.dispose(),this.enterExitUI&&this.enterExitUI.dispose(),this.renderTarget&&this.renderTarget.dispose()},r}(),Ux=!0;function Gx(r){for(;r.firstChild;)r.removeChild(r.firstChild);r.srcObject=null,r.src="",r.removeAttribute("src")}ke.Z.prototype.createDefaultLight=function(r){if(r===void 0&&(r=!1),r&&this.lights)for(var t=0;t<this.lights.length;t++)this.lights[t].dispose();this.lights.length===0&&new na("default light",_.Pq.Up(),this)},ke.Z.prototype.createDefaultCamera=function(r,t,e){if(r===void 0&&(r=!1),t===void 0&&(t=!1),e===void 0&&(e=!1),t&&this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),!this.activeCamera){var n=this.getWorldExtends(function(u){return u.isVisible&&u.isEnabled()}),i=n.max.subtract(n.min),o=n.min.add(i.scale(.5)),a=void 0,s=1.5*i.length();if(isFinite(s)||(s=1,o.copyFromFloats(0,0,0)),r){var l=new zr("default camera",-Math.PI/2,Math.PI/2,s,o,this);l.lowerRadiusLimit=.01*s,l.wheelPrecision=100/s,a=l}else{var c=new _r("default camera",new _.Pq(o.x,o.y,-s),this);c.setTarget(o),a=c}a.minZ=.01*s,a.maxZ=1e3*s,a.speed=.2*s,this.activeCamera=a,e&&a.attachControl()}},ke.Z.prototype.createDefaultCameraOrLight=function(r,t,e){r===void 0&&(r=!1),t===void 0&&(t=!1),e===void 0&&(e=!1),this.createDefaultLight(t),this.createDefaultCamera(r,t,e)},ke.Z.prototype.createDefaultSkybox=function(r,t,e,n,i){if(t===void 0&&(t=!1),e===void 0&&(e=1e3),n===void 0&&(n=0),i===void 0&&(i=!0),!r)return O.V.Warn("Can not create default skybox without environment texture."),null;i&&r&&(this.environmentTexture=r);var o=Oi("hdrSkyBox",{size:e},this);if(t){var a=new fl("skyBox",this);a.backFaceCulling=!1,a.reflectionTexture=r.clone(),a.reflectionTexture&&(a.reflectionTexture.coordinatesMode=Ie.g.SKYBOX_MODE),a.microSurface=1-n,a.disableLighting=!0,a.twoSidedLighting=!0,o.material=a}else{var s=new qt("skyBox",this);s.backFaceCulling=!1,s.reflectionTexture=r.clone(),s.reflectionTexture&&(s.reflectionTexture.coordinatesMode=Ie.g.SKYBOX_MODE),s.disableLighting=!0,o.material=s}return o.isPickable=!1,o.infiniteDistance=!0,o.ignoreCameraMaxZ=!0,o},ke.Z.prototype.createDefaultEnvironment=function(r){return kd?new kd(r,this):null},ke.Z.prototype.createDefaultVRExperience=function(r){return r===void 0&&(r={}),new Km(this,r)},ke.Z.prototype.createDefaultXRExperienceAsync=function(r){return r===void 0&&(r={}),hv.CreateAsync(this,r).then(function(t){return t})};var gl=function(r){function t(e,n,i,o,a,s,l,c,u){o===void 0&&(o=!1),a===void 0&&(a=!1),s===void 0&&(s=Ie.g.TRILINEAR_SAMPLINGMODE),l===void 0&&(l={}),u===void 0&&(u=P.Y.TEXTUREFORMAT_RGBA);var d=r.call(this,null,i,!o,a)||this;d._externalTexture=null,d._onUserActionRequestedObservable=null,d._stillImageCaptured=!1,d._displayingPosterTexture=!1,d._frameId=-1,d._currentSrc=null,d._errorFound=!1,d.isVideo=!0,d._resizeInternalTexture=function(){var v;d._texture!=null&&d._texture.dispose(),!d._getEngine().needPOTTextures||ze.S0.IsExponentOfTwo(d.video.videoWidth)&&ze.S0.IsExponentOfTwo(d.video.videoHeight)?(d.wrapU=Ie.g.WRAP_ADDRESSMODE,d.wrapV=Ie.g.WRAP_ADDRESSMODE):(d.wrapU=Ie.g.CLAMP_ADDRESSMODE,d.wrapV=Ie.g.CLAMP_ADDRESSMODE,d._generateMipMaps=!1),d._texture=d._getEngine().createDynamicTexture(d.video.videoWidth,d.video.videoHeight,d._generateMipMaps,d.samplingMode),d._texture.format=(v=d._format)!==null&&v!==void 0?v:P.Y.TEXTUREFORMAT_RGBA,d._frameId=-1,d._updateInternalTexture()},d._createInternalTexture=function(){if(d._texture!=null){if(!d._displayingPosterTexture)return;d._displayingPosterTexture=!1}if(d.video.addEventListener("resize",d._resizeInternalTexture),d._resizeInternalTexture(),d.video.autoplay||d._settings.poster||d._settings.independentVideoSource)d._updateInternalTexture(),d.onLoadObservable.hasObservers()&&d.onLoadObservable.notifyObservers(d);else{var v=d.video.onplaying,b=d.video.muted;d.video.muted=!0,d.video.onplaying=function(){d.video.muted=b,d.video.onplaying=v,d._updateInternalTexture(),d._errorFound||d.video.pause(),d.onLoadObservable.hasObservers()&&d.onLoadObservable.notifyObservers(d)},d._handlePlay()}},d._reset=function(){d._texture!=null&&(d._displayingPosterTexture||(d._texture.dispose(),d._texture=null))},d._updateInternalTexture=function(){if(d._texture!=null&&!(d.video.readyState<d.video.HAVE_CURRENT_DATA||d._displayingPosterTexture)){var v=d.getScene().getFrameId();d._frameId!==v&&(d._frameId=v,d._getEngine().updateVideoTexture(d._texture,d._externalTexture?d._externalTexture:d.video,d._invertY))}},d._settings=(0,A.Cl)({autoPlay:!0,loop:!0,autoUpdateTexture:!0},l),d._onError=c,d._generateMipMaps=o,d._initialSamplingMode=s,d.autoUpdateTexture=d._settings.autoUpdateTexture,d._currentSrc=n,d.name=e||d._getName(n),d.video=d._getVideo(n);var h=d._engine,p=h?.createExternalTexture;p&&(d._externalTexture=p.call(h,d.video)),d._settings.independentVideoSource||(d._settings.poster&&(d.video.poster=d._settings.poster),d._settings.autoPlay!==void 0&&(d.video.autoplay=d._settings.autoPlay),d._settings.loop!==void 0&&(d.video.loop=d._settings.loop),d._settings.muted!==void 0&&(d.video.muted=d._settings.muted),d.video.setAttribute("playsinline",""),d.video.addEventListener("paused",d._updateInternalTexture),d.video.addEventListener("seeked",d._updateInternalTexture),d.video.addEventListener("loadeddata",d._updateInternalTexture),d.video.addEventListener("emptied",d._reset),d._settings.autoPlay&&d._handlePlay()),d._createInternalTextureOnEvent=d._settings.poster&&!d._settings.autoPlay?"play":"canplay",d.video.addEventListener(d._createInternalTextureOnEvent,d._createInternalTexture),d._format=u;var m=d.video.readyState>=d.video.HAVE_CURRENT_DATA;return!d._settings.poster||d._settings.autoPlay&&m?m&&d._createInternalTexture():(d._texture=d._getEngine().createTexture(d._settings.poster,!1,!d.invertY,i),d._displayingPosterTexture=!0),d}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new K.cP),this._onUserActionRequestedObservable},enumerable:!1,configurable:!0}),t.prototype._processError=function(e){this._errorFound=!0,this._onError?this._onError(e?.message):O.V.Error(e?.message)},t.prototype._handlePlay=function(){var e=this;this._errorFound=!1,this.video.play().catch(function(n){if(n?.name==="NotAllowedError"){if(e._onUserActionRequestedObservable&&e._onUserActionRequestedObservable.hasObservers())return void e._onUserActionRequestedObservable.notifyObservers(e);if(!e.video.muted)return O.V.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),e.video.muted=!0,e._errorFound=!1,void e.video.play().catch(function(i){e._processError(i)})}e._processError(n)})},t.prototype.getClassName=function(){return"VideoTexture"},t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:typeof e=="object"?e.toString():e},t.prototype._getVideo=function(e){if(e.isNative)return e;if(e instanceof HTMLVideoElement)return ze.S0.SetCorsBehavior(e.currentSrc,e),e;var n=document.createElement("video");return typeof e=="string"?(ze.S0.SetCorsBehavior(e,n),n.src=e):(ze.S0.SetCorsBehavior(e[0],n),e.forEach(function(i){var o=document.createElement("source");o.src=i,n.appendChild(o)})),this.onDisposeObservable.addOnce(function(){Gx(n)}),n},t.prototype._rebuild=function(){this.update()},t.prototype.update=function(){this.autoUpdateTexture&&this.updateTexture(!0)},t.prototype.updateTexture=function(e){e&&(this.video.paused&&this._stillImageCaptured||(this._stillImageCaptured=!0,this._updateInternalTexture()))},Object.defineProperty(t.prototype,"externalTexture",{get:function(){return this._externalTexture},enumerable:!1,configurable:!0}),t.prototype.updateURL=function(e){this.video.src=e,this._currentSrc=e},t.prototype.clone=function(){return new t(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)},t.prototype.dispose=function(){var e;r.prototype.dispose.call(this),this._currentSrc=null,this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener(this._createInternalTextureOnEvent,this._createInternalTexture),this._settings.independentVideoSource||(this.video.removeEventListener("paused",this._updateInternalTexture),this.video.removeEventListener("seeked",this._updateInternalTexture),this.video.removeEventListener("loadeddata",this._updateInternalTexture),this.video.removeEventListener("emptied",this._reset),this.video.removeEventListener("resize",this._resizeInternalTexture),this.video.pause()),(e=this._externalTexture)===null||e===void 0||e.dispose()},t.CreateFromStreamAsync=function(e,n,i,o){o===void 0&&(o=!0);var a=e.getEngine().createVideoElement(i);return e.getEngine()._badOS&&(document.body.appendChild(a),a.style.transform="scale(0.0001, 0.0001)",a.style.opacity="0",a.style.position="fixed",a.style.bottom="0px",a.style.right="0px"),a.setAttribute("autoplay",""),a.setAttribute("muted","true"),a.setAttribute("playsinline",""),a.muted=!0,a.isNative||(a.mozSrcObject!==void 0?a.mozSrcObject=n:typeof a.srcObject=="object"?a.srcObject=n:a.src=window.URL&&window.URL.createObjectURL(n)),new Promise(function(s){var l=function(){var c=new t("video",a,e,!0,o,void 0,void 0,void 0,P.Y.TEXTUREFORMAT_RGB);e.getEngine()._badOS&&c.onDisposeObservable.addOnce(function(){a.remove()}),c.onDisposeObservable.addOnce(function(){Gx(a)}),s(c),a.removeEventListener("playing",l)};a.addEventListener("playing",l),a.play()})},t.CreateFromWebCamAsync=function(e,n,i,o){return i===void 0&&(i=!1),o===void 0&&(o=!0),(0,A.sH)(this,void 0,void 0,function(){var a,s;return(0,A.YH)(this,function(l){switch(l.label){case 0:return navigator.mediaDevices?[4,navigator.mediaDevices.getUserMedia({video:n,audio:i})]:[3,3];case 1:return a=l.sent(),[4,this.CreateFromStreamAsync(e,a,n,o)];case 2:return(s=l.sent()).onDisposeObservable.addOnce(function(){a.getTracks().forEach(function(c){c.stop()})}),[2,s];case 3:return[2,Promise.reject("No support for userMedia on this device")]}})})},t.CreateFromWebCam=function(e,n,i,o,a){o===void 0&&(o=!1),a===void 0&&(a=!0),this.CreateFromWebCamAsync(e,i,o,a).then(function(s){n&&n(s)}).catch(function(s){O.V.Error(s.name)})},(0,A.Cg)([(0,V.lK)("settings")],t.prototype,"_settings",void 0),(0,A.Cg)([(0,V.lK)("src")],t.prototype,"_currentSrc",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"isVideo",void 0),t}(Ie.g);Ie.g._CreateVideoTexture=function(r,t,e,n,i,o,a,s,l){return n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=Ie.g.TRILINEAR_SAMPLINGMODE),a===void 0&&(a={}),l===void 0&&(l=P.Y.TEXTUREFORMAT_RGBA),new gl(r,t,e,n,i,o,a,s,l)},(0,j.Y5)("BABYLON.VideoTexture",gl);var kx=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"videoMode",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,n,i){var o=this,a={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},s=new gl((this.name||"videoDome")+"_texture",e,n,i.generateMipMaps,this._useDirectMapping,Ie.g.TRILINEAR_SAMPLINGMODE,a);return i.clickToPlay&&(this._pointerObserver=n.onPointerObservable.add(function(l){var c;((c=l.pickInfo)===null||c===void 0?void 0:c.pickedMesh)===o.mesh&&o._texture.video.play()},vt.Zp.POINTERDOWN)),this._textureObserver=s.onLoadObservable.add(function(){o.onLoadObservable.notifyObservers()}),s},t.prototype.dispose=function(e,n){n===void 0&&(n=!1),this._texture.onLoadObservable.remove(this._textureObserver),this._scene.onPointerObservable.remove(this._pointerObserver),r.prototype.dispose.call(this,e,n)},t.MODE_MONOSCOPIC=Fo.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=Fo.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=Fo.MODE_SIDEBYSIDE,t}(Fo),fv=function(){function r(t){this.engine=t,this._captureGPUFrameTime=!1,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new Mi.A,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(r.prototype,"gpuFrameTimeCounter",{get:function(){return this.engine.getGPUFrameTimeCounter()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(t){t!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=t,this.engine.captureGPUFrameTime(t))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(t){var e=this;t!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=t,t?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add(function(){e._shaderCompilationTime.fetchNewFrame(),e._shaderCompilationTime.beginMonitoring()}),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add(function(){e._shaderCompilationTime.endMonitoring()})):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null,this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null,this.engine=null},r}(),pv=function(){function r(t){var e=this;this.scene=t,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new Mi.A,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new Mi.A,this._captureFrameTime=!1,this._frameTime=new Mi.A,this._captureRenderTime=!1,this._renderTime=new Mi.A,this._captureInterFrameTime=!1,this._interFrameTime=new Mi.A,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new Mi.A,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new Mi.A,this._capturePhysicsTime=!1,this._physicsTime=new Mi.A,this._captureAnimationsTime=!1,this._animationsTime=new Mi.A,this._captureCameraRenderTime=!1,this._cameraRenderTime=new Mi.A,this._onBeforeActiveMeshesEvaluationObserver=null,this._onAfterActiveMeshesEvaluationObserver=null,this._onBeforeRenderTargetsRenderObserver=null,this._onAfterRenderTargetsRenderObserver=null,this._onAfterRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterDrawPhaseObserver=null,this._onBeforeAnimationsObserver=null,this._onBeforeParticlesRenderingObserver=null,this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver=null,this._onAfterSpritesRenderingObserver=null,this._onBeforePhysicsObserver=null,this._onAfterPhysicsObserver=null,this._onAfterAnimationsObserver=null,this._onBeforeCameraRenderObserver=null,this._onAfterCameraRenderObserver=null,this._onBeforeAnimationsObserver=t.onBeforeAnimationsObservable.add(function(){e._captureActiveMeshesEvaluationTime&&e._activeMeshesEvaluationTime.fetchNewFrame(),e._captureRenderTargetsRenderTime&&e._renderTargetsRenderTime.fetchNewFrame(),e._captureFrameTime&&(ze.S0.StartPerformanceCounter("Scene rendering"),e._frameTime.beginMonitoring()),e._captureInterFrameTime&&e._interFrameTime.endMonitoring(),e._captureParticlesRenderTime&&e._particlesRenderTime.fetchNewFrame(),e._captureSpritesRenderTime&&e._spritesRenderTime.fetchNewFrame(),e._captureAnimationsTime&&e._animationsTime.beginMonitoring(),e._captureRenderTime&&e._renderTime.fetchNewFrame(),e._captureCameraRenderTime&&e._cameraRenderTime.fetchNewFrame(),e.scene.getEngine()._drawCalls.fetchNewFrame()}),this._onAfterRenderObserver=t.onAfterRenderObservable.add(function(){e._captureFrameTime&&(ze.S0.EndPerformanceCounter("Scene rendering"),e._frameTime.endMonitoring()),e._captureRenderTime&&e._renderTime.endMonitoring(!1),e._captureInterFrameTime&&e._interFrameTime.beginMonitoring(),e._captureActiveMeshesEvaluationTime&&e._activeMeshesEvaluationTime.endFrame(),e._captureRenderTargetsRenderTime&&e._renderTargetsRenderTime.endFrame(),e._captureParticlesRenderTime&&e._particlesRenderTime.endFrame(),e._captureSpritesRenderTime&&e._spritesRenderTime.endFrame(),e._captureRenderTime&&e._renderTime.endFrame(),e._captureCameraRenderTime&&e._cameraRenderTime.endFrame()})}return Object.defineProperty(r.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(t){var e=this;t!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=t,t?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add(function(){ze.S0.StartPerformanceCounter("Active meshes evaluation"),e._activeMeshesEvaluationTime.beginMonitoring()}),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add(function(){ze.S0.EndPerformanceCounter("Active meshes evaluation"),e._activeMeshesEvaluationTime.endMonitoring(!1)})):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(t){var e=this;t!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=t,t?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add(function(){ze.S0.StartPerformanceCounter("Render targets rendering"),e._renderTargetsRenderTime.beginMonitoring()}),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add(function(){ze.S0.EndPerformanceCounter("Render targets rendering"),e._renderTargetsRenderTime.endMonitoring(!1)})):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(t){var e=this;t!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=t,t?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add(function(){ze.S0.StartPerformanceCounter("Particles"),e._particlesRenderTime.beginMonitoring()}),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add(function(){ze.S0.EndPerformanceCounter("Particles"),e._particlesRenderTime.endMonitoring(!1)})):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(t){var e=this;t!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=t,this.scene.spriteManagers&&(t?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add(function(){ze.S0.StartPerformanceCounter("Sprites"),e._spritesRenderTime.beginMonitoring()}),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add(function(){ze.S0.EndPerformanceCounter("Sprites"),e._spritesRenderTime.endMonitoring(!1)})):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(t){var e=this;t!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=t,t?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add(function(){ze.S0.StartPerformanceCounter("Physics"),e._physicsTime.beginMonitoring()}),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add(function(){ze.S0.EndPerformanceCounter("Physics"),e._physicsTime.endMonitoring()})):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(t){var e=this;t!==this._captureAnimationsTime&&(this._captureAnimationsTime=t,t?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add(function(){e._animationsTime.endMonitoring()}):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(t){this._captureFrameTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(t){this._captureInterFrameTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(t){var e=this;t!==this._captureRenderTime&&(this._captureRenderTime=t,t?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add(function(){e._renderTime.beginMonitoring(),ze.S0.StartPerformanceCounter("Main render")}),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add(function(){e._renderTime.endMonitoring(!1),ze.S0.EndPerformanceCounter("Main render")})):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"captureCameraRenderTime",{get:function(){return this._captureCameraRenderTime},set:function(t){var e=this;t!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=t,t?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add(function(n){e._cameraRenderTime.beginMonitoring(),ze.S0.StartPerformanceCounter("Rendering camera ".concat(n.name))}),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add(function(n){e._cameraRenderTime.endMonitoring(!1),ze.S0.EndPerformanceCounter("Rendering camera ".concat(n.name))})):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=null,this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null,this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null,this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver&&(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null),this._onAfterSpritesRenderingObserver&&(this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null),this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null,this._onBeforePhysicsObserver&&(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null),this._onAfterPhysicsObserver&&(this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null),this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null,this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null,this.scene=null},r}(),as=function(){function r(t,e,n){n===void 0&&(n=!1),this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new z.ov},this._effectIntensity={},this.neutralColor=new z.ov,this.isEnabled=!0,this.disableBoundingBoxesFromEffectLayer=!1,this.onDisposeObservable=new K.cP,this.onBeforeRenderMainTextureObservable=new K.cP,this.onBeforeComposeObservable=new K.cP,this.onBeforeRenderMeshToEffect=new K.cP,this.onAfterRenderMeshToEffect=new K.cP,this.onAfterComposeObservable=new K.cP,this.onSizeChangedObservable=new K.cP,this._shaderLanguage=0,this._materialForRendering={},this._shadersLoaded=!1,this.name=t,this._scene=e||Ve.q.LastCreatedScene,r._SceneComponentInitialization(this._scene),!this._scene.getEngine().isWebGPU||n||r.ForceGLSL||(this._shaderLanguage=1),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),this._mergeDrawWrapper=[],this._generateIndexBuffer(),this._generateVertexBuffer()}return Object.defineProperty(r.prototype,"camera",{get:function(){return this._effectLayerOptions.camera},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"renderingGroupId",{get:function(){return this._effectLayerOptions.renderingGroupId},set:function(t){this._effectLayerOptions.renderingGroupId=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"mainTexture",{get:function(){return this._mainTexture},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype.setMaterialForRendering=function(t,e){if(this._mainTexture.setMaterialForRendering(t,e),Array.isArray(t))for(var n=0;n<t.length;++n){var i=t[n];e?this._materialForRendering[i.uniqueId]=[i,e]:delete this._materialForRendering[i.uniqueId]}else e?this._materialForRendering[t.uniqueId]=[t,e]:delete this._materialForRendering[t.uniqueId]},r.prototype.getEffectIntensity=function(t){var e;return(e=this._effectIntensity[t.uniqueId])!==null&&e!==void 0?e:1},r.prototype.setEffectIntensity=function(t,e){this._effectIntensity[t.uniqueId]=e},r.prototype._numInternalDraws=function(){return 1},r.prototype._init=function(t){this._effectLayerOptions=(0,A.Cl)({mainTextureRatio:.5,alphaBlendingMode:P.Y.ALPHA_COMBINE,camera:null,renderingGroupId:-1,mainTextureType:P.Y.TEXTURETYPE_UNSIGNED_INT,generateStencilBuffer:!1},t),this._setMainTextureSize(),this._createMainTexture(),this._createTextureAndPostProcesses()},r.prototype._generateIndexBuffer=function(){var t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=this._engine.createIndexBuffer(t)},r.prototype._generateVertexBuffer=function(){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1);var e=new Y.R(this._engine,t,Y.R.PositionKind,!1,!1,2);this._vertexBuffers[Y.R.PositionKind]=e},r.prototype._setMainTextureSize=function(){this._effectLayerOptions.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._effectLayerOptions.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._effectLayerOptions.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?(0,ir.R)(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?(0,ir.R)(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height),this._mainTextureDesiredSize.width=Math.floor(this._mainTextureDesiredSize.width),this._mainTextureDesiredSize.height=Math.floor(this._mainTextureDesiredSize.height)},r.prototype._createMainTexture=function(){var t,e=this;for(var n in this._mainTexture=new un.$("EffectLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,this._effectLayerOptions.mainTextureType,!1,Ie.g.TRILINEAR_SAMPLINGMODE,!0,this._effectLayerOptions.generateStencilBuffer),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(Ie.g.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._materialForRendering){var i=(t=this._materialForRendering[n])[0],o=t[1];this._mainTexture.setMaterialForRendering(i,o)}if(this._mainTexture.customIsReadyFunction=function(s,l,c){if((c||l===0)&&s.subMeshes)for(var u=0;u<s.subMeshes.length;++u){var d=s.subMeshes[u],h=d.getMaterial(),p=d.getRenderingMesh();if(h){var m=p._getInstancesRenderList(d._id,!!d.getReplacementMesh()).hardwareInstancedRendering[d._id]||p.hasThinInstances;if(e._setEmissiveTextureAndColor(p,d,h),!e._isReady(d,m,e._emissiveTextureAndColor.texture))return!1}}return!0},this._mainTexture.customRenderFunction=function(s,l,c,u){var d;e.onBeforeRenderMainTextureObservable.notifyObservers(e);var h=e._scene.getEngine();if(u.length){for(h.setColorWrite(!1),d=0;d<u.length;d++)e._renderSubMesh(u.data[d]);h.setColorWrite(!0)}for(d=0;d<s.length;d++)e._renderSubMesh(s.data[d]);for(d=0;d<l.length;d++)e._renderSubMesh(l.data[d]);var p=h.getAlphaMode();for(d=0;d<c.length;d++){var m=c.data[d],v=m.getMaterial();if(v&&v.needDepthPrePass){var b=v.getScene().getEngine();b.setColorWrite(!1),e._renderSubMesh(m),b.setColorWrite(!0)}e._renderSubMesh(m,!0)}h.setAlphaMode(p)},this._mainTexture.onClearObservable.add(function(s){s.clear(e.neutralColor,!0,!0,!0)}),this._scene.getBoundingBoxRenderer){var a=this._scene.getBoundingBoxRenderer().enabled;this._mainTexture.onBeforeBindObservable.add(function(){e._scene.getBoundingBoxRenderer().enabled=!e.disableBoundingBoxesFromEffectLayer&&a}),this._mainTexture.onAfterUnbindObservable.add(function(){e._scene.getBoundingBoxRenderer().enabled=a})}},r.prototype._addCustomEffectDefines=function(t){},r.prototype._isReady=function(t,e,n){var i,o=this,a=this._scene.getEngine(),s=t.getMesh(),l=(i=s._internalAbstractMeshDataInfo._materialForRenderPass)===null||i===void 0?void 0:i[a.currentRenderPassId];if(l)return l.isReadyForSubMesh(s,t,e);var c=t.getMaterial();if(!c)return!1;if(this._useMeshMaterial(t.getRenderingMesh()))return c.isReadyForSubMesh(t.getMesh(),t,e);var u=[],d=[Y.R.PositionKind],h=!1,p=!1;if(c){var m=c.needAlphaTesting(),v=c.getAlphaTestTexture(),b=v&&v.hasAlpha&&(c.useAlphaFromDiffuseTexture||c._useAlphaFromAlbedoTexture);v&&(m||b)&&(u.push("#define DIFFUSE"),s.isVerticesDataPresent(Y.R.UV2Kind)&&v.coordinatesIndex===1?(u.push("#define DIFFUSEUV2"),p=!0):s.isVerticesDataPresent(Y.R.UVKind)&&(u.push("#define DIFFUSEUV1"),h=!0),m&&(u.push("#define ALPHATEST"),u.push("#define ALPHATESTVALUE 0.4")),v.gammaSpace||u.push("#define DIFFUSE_ISLINEAR"));var E=c.opacityTexture;E&&(u.push("#define OPACITY"),s.isVerticesDataPresent(Y.R.UV2Kind)&&E.coordinatesIndex===1?(u.push("#define OPACITYUV2"),p=!0):s.isVerticesDataPresent(Y.R.UVKind)&&(u.push("#define OPACITYUV1"),h=!0))}n&&(u.push("#define EMISSIVE"),s.isVerticesDataPresent(Y.R.UV2Kind)&&n.coordinatesIndex===1?(u.push("#define EMISSIVEUV2"),p=!0):s.isVerticesDataPresent(Y.R.UVKind)&&(u.push("#define EMISSIVEUV1"),h=!0),n.gammaSpace||u.push("#define EMISSIVE_ISLINEAR")),s.useVertexColors&&s.isVerticesDataPresent(Y.R.ColorKind)&&s.hasVertexAlpha&&c.transparencyMode!==Lt.MATERIAL_OPAQUE&&(d.push(Y.R.ColorKind),u.push("#define VERTEXALPHA")),h&&(d.push(Y.R.UVKind),u.push("#define UV1")),p&&(d.push(Y.R.UV2Kind),u.push("#define UV2"));var C=new Tr;if(s.useBones&&s.computeBonesUsingShaders){d.push(Y.R.MatricesIndicesKind),d.push(Y.R.MatricesWeightsKind),s.numBoneInfluencers>4&&(d.push(Y.R.MatricesIndicesExtraKind),d.push(Y.R.MatricesWeightsExtraKind)),u.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers);var T=s.skeleton;T&&T.isUsingTextureForMatrices?u.push("#define BONETEXTURE"):u.push("#define BonesPerMesh "+(T?T.bones.length+1:0)),s.numBoneInfluencers>0&&C.addCPUSkinningFallback(0,s)}else u.push("#define NUM_BONE_INFLUENCERS 0");var f=s.morphTargetManager,g=0;f&&(g=f.numMaxInfluencers||f.numInfluencers)>0&&(u.push("#define MORPHTARGETS"),u.push("#define NUM_MORPH_INFLUENCERS "+g),f.isUsingTextureForTargets&&u.push("#define MORPHTARGETS_TEXTURE"),(0,Re.MF)(d,s,g)),e&&(u.push("#define INSTANCES"),(0,Re.te)(d),t.getRenderingMesh().hasThinInstances&&u.push("#define THIN_INSTANCES")),(0,tn.tv)(c,this._scene,u),this._addCustomEffectDefines(u);var S=t._getDrawWrapper(void 0,!0),y=S.defines,x=u.join(`
|
||
`);if(y!==x){var R=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","glowIntensity"];(0,tn.TV)(R),S.setEffect(this._engine.createEffect("glowMapGeneration",d,R,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets"],x,C,void 0,void 0,{maxSimultaneousMorphTargets:g},this._shaderLanguage,this._shadersLoaded?void 0:function(){return(0,A.sH)(o,void 0,void 0,function(){return(0,A.YH)(this,function(I){switch(I.label){case 0:return[4,this._importShadersAsync()];case 1:return I.sent(),this._shadersLoaded=!0,[2]}})})}),x)}return S.effect.isReady()},r.prototype._importShadersAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,97e3)),Promise.resolve().then(L.bind(L,35750))])];case 1:return t.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,47615)),Promise.resolve().then(L.bind(L,75417))])];case 3:t.sent(),t.label=4;case 4:return[2]}})})},r.prototype.render=function(){for(var t=0;t<this._postProcesses.length;t++)if(!this._postProcesses[t].isReady())return;var e=this._scene.getEngine(),n=this._numInternalDraws(),i=!0;for(t=0;t<n;++t)(a=this._mergeDrawWrapper[t])||(a=this._mergeDrawWrapper[t]=new jn.E(this._engine)).setEffect(this._createMergeEffect()),i=i&&a.effect.isReady();if(i){this.onBeforeComposeObservable.notifyObservers(this);var o=e.getAlphaMode();for(t=0;t<n;++t){var a=this._mergeDrawWrapper[t];e.enableEffect(a),e.setState(!1),e.bindBuffers(this._vertexBuffers,this._indexBuffer,a.effect),e.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),this._internalRender(a.effect,t)}e.setAlphaMode(o),this.onAfterComposeObservable.notifyObservers(this);var s=this._mainTexture.getSize();this._setMainTextureSize(),s.width===this._mainTextureDesiredSize.width&&s.height===this._mainTextureDesiredSize.height||this._mainTextureDesiredSize.width===0||this._mainTextureDesiredSize.height===0||(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses())}},r.prototype.hasMesh=function(t){return this.renderingGroupId===-1||t.renderingGroupId===this.renderingGroupId},r.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},r.prototype._shouldRenderMesh=function(t){return!0},r.prototype._canRenderMesh=function(t,e){return!e.needAlphaBlendingForMesh(t)},r.prototype._shouldRenderEmissiveTextureForMesh=function(){return!0},r.prototype._renderSubMesh=function(t,e){var n;if(e===void 0&&(e=!1),this.shouldRender()){var i=t.getMaterial(),o=t.getMesh(),a=t.getReplacementMesh(),s=t.getRenderingMesh(),l=t.getEffectiveMesh(),c=this._scene,u=c.getEngine();if(l._internalAbstractMeshDataInfo._isActiveIntermediate=!1,i&&this._canRenderMesh(s,i)){var d=i._getEffectiveOrientation(s);l._getWorldMatrixDeterminant()<0&&(d=d===Lt.ClockWiseSideOrientation?Lt.CounterClockWiseSideOrientation:Lt.ClockWiseSideOrientation);var h=d===Lt.ClockWiseSideOrientation;u.setState(i.backFaceCulling,i.zOffset,void 0,h,i.cullBackFaces,void 0,i.zOffsetUnits);var p=s._getInstancesRenderList(t._id,!!a);if(!p.mustReturn&&this._shouldRenderMesh(s)){var m=p.hardwareInstancedRendering[t._id]||s.hasThinInstances;if(this._setEmissiveTextureAndColor(s,t,i),this.onBeforeRenderMeshToEffect.notifyObservers(o),this._useMeshMaterial(s))s.render(t,e,a||void 0);else if(this._isReady(t,m,this._emissiveTextureAndColor.texture)){var v=(n=l._internalAbstractMeshDataInfo._materialForRenderPass)===null||n===void 0?void 0:n[u.currentRenderPassId],b=t._getDrawWrapper();if(!b&&v&&(b=v._getDrawWrapper()),!b)return;var E=b.effect;if(u.enableEffect(b),m||s._bind(t,E,i.fillMode),v?v.bindForSubMesh(l.getWorldMatrix(),l,t):(E.setMatrix("viewProjection",c.getTransformMatrix()),E.setMatrix("world",l.getWorldMatrix()),E.setFloat4("glowColor",this._emissiveTextureAndColor.color.r,this._emissiveTextureAndColor.color.g,this._emissiveTextureAndColor.color.b,this._emissiveTextureAndColor.color.a)),!v){var C=i.needAlphaTesting(),T=i.getAlphaTestTexture(),f=T&&T.hasAlpha&&(i.useAlphaFromDiffuseTexture||i._useAlphaFromAlbedoTexture);T&&(C||f)&&(E.setTexture("diffuseSampler",T),(g=T.getTextureMatrix())&&E.setMatrix("diffuseMatrix",g));var g,S=i.opacityTexture;if(S&&(E.setTexture("opacitySampler",S),E.setFloat("opacityIntensity",S.level),(g=S.getTextureMatrix())&&E.setMatrix("opacityMatrix",g)),this._emissiveTextureAndColor.texture&&(E.setTexture("emissiveSampler",this._emissiveTextureAndColor.texture),E.setMatrix("emissiveMatrix",this._emissiveTextureAndColor.texture.getTextureMatrix())),s.useBones&&s.computeBonesUsingShaders&&s.skeleton){var y=s.skeleton;if(y.isUsingTextureForMatrices){var x=y.getTransformMatrixTexture(s);if(!x)return;E.setTexture("boneSampler",x),E.setFloat("boneTextureWidth",4*(y.bones.length+1))}else E.setMatrices("mBones",y.getTransformMatrices(s))}(0,Re.nR)(s,E),s.morphTargetManager&&s.morphTargetManager.isUsingTextureForTargets&&s.morphTargetManager._bind(E),e&&u.setAlphaMode(i.alphaMode),E.setFloat("glowIntensity",this.getEffectIntensity(s)),(0,tn.gS)(E,i,c)}s._processRendering(l,t,E,i.fillMode,p,m,function(R,I){return E.setMatrix("world",I)})}else this._mainTexture.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(o)}}}},r.prototype._useMeshMaterial=function(t){return!1},r.prototype._rebuild=function(){var t=this._vertexBuffers[Y.R.PositionKind];t&&t._rebuild(),this._generateIndexBuffer()},r.prototype._disposeTextureAndPostProcesses=function(){this._mainTexture.dispose();for(var t=0;t<this._postProcesses.length;t++)this._postProcesses[t]&&this._postProcesses[t].dispose();for(this._postProcesses=[],t=0;t<this._textures.length;t++)this._textures[t]&&this._textures[t].dispose();this._textures=[]},r.prototype.dispose=function(){var t=this._vertexBuffers[Y.R.PositionKind];t&&(t.dispose(),this._vertexBuffers[Y.R.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);for(var e=0,n=this._mergeDrawWrapper;e<n.length;e++)n[e].dispose();this._mergeDrawWrapper=[],this._disposeTextureAndPostProcesses();var i=this._scene.effectLayers.indexOf(this,0);i>-1&&this._scene.effectLayers.splice(i,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},r.prototype.getClassName=function(){return"EffectLayer"},r.Parse=function(t,e,n){return ze.S0.Instantiate(t.customType).Parse(t,e,n)},r.ForceGLSL=!1,r._SceneComponentInitialization=function(t){throw(0,gt.n)("EffectLayerSceneComponent")},(0,A.Cg)([(0,V.lK)()],r.prototype,"name",void 0),(0,A.Cg)([(0,V.qK)()],r.prototype,"neutralColor",void 0),(0,A.Cg)([(0,V.lK)()],r.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.fW)()],r.prototype,"camera",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"renderingGroupId",null),(0,A.Cg)([(0,V.lK)()],r.prototype,"disableBoundingBoxesFromEffectLayer",void 0),r}();nt.d.AddParser(lt.v.NAME_EFFECTLAYER,function(r,t,e,n){if(r.effectLayers){e.effectLayers||(e.effectLayers=[]);for(var i=0;i<r.effectLayers.length;i++){var o=as.Parse(r.effectLayers[i],t,n);e.effectLayers.push(o)}}}),nt.d.prototype.removeEffectLayer=function(r){var t=this.effectLayers.indexOf(r);return t!==-1&&this.effectLayers.splice(t,1),t},nt.d.prototype.addEffectLayer=function(r){this.effectLayers.push(r)};var _v=function(){function r(t){this.name=lt.v.NAME_EFFECTLAYER,this._renderEffects=!1,this._needStencil=!1,this._previousStencilState=!1,this.scene=t||Ve.q.LastCreatedScene,this.scene&&(this._engine=this.scene.getEngine(),this.scene.effectLayers=[])}return r.prototype.register=function(){this.scene._isReadyForMeshStage.registerStep(lt.v.STEP_ISREADYFORMESH_EFFECTLAYER,this,this._isReadyForMesh),this.scene._cameraDrawRenderTargetStage.registerStep(lt.v.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER,this,this._renderMainTexture),this.scene._beforeCameraDrawStage.registerStep(lt.v.STEP_BEFORECAMERADRAW_EFFECTLAYER,this,this._setStencil),this.scene._afterRenderingGroupDrawStage.registerStep(lt.v.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW,this,this._drawRenderingGroup),this.scene._afterCameraDrawStage.registerStep(lt.v.STEP_AFTERCAMERADRAW_EFFECTLAYER,this,this._setStencilBack),this.scene._afterCameraDrawStage.registerStep(lt.v.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW,this,this._drawCamera)},r.prototype.rebuild=function(){for(var t=0,e=this.scene.effectLayers;t<e.length;t++)e[t]._rebuild()},r.prototype.serialize=function(t){t.effectLayers=[];for(var e=0,n=this.scene.effectLayers;e<n.length;e++){var i=n[e];i.serialize&&t.effectLayers.push(i.serialize())}},r.prototype.addFromContainer=function(t){var e=this;t.effectLayers&&t.effectLayers.forEach(function(n){e.scene.addEffectLayer(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;t.effectLayers&&t.effectLayers.forEach(function(i){n.scene.removeEffectLayer(i),e&&i.dispose()})},r.prototype.dispose=function(){for(var t=this.scene.effectLayers;t.length;)t[0].dispose()},r.prototype._isReadyForMesh=function(t,e){for(var n=this._engine.currentRenderPassId,i=0,o=this.scene.effectLayers;i<o.length;i++){var a=o[i];if(a.hasMesh(t)){var s=a._mainTexture;this._engine.currentRenderPassId=s.renderPassId;for(var l=0,c=t.subMeshes;l<c.length;l++){var u=c[l];if(!a.isReady(u,e))return this._engine.currentRenderPassId=n,!1}}}return this._engine.currentRenderPassId=n,!0},r.prototype._renderMainTexture=function(t){this._renderEffects=!1,this._needStencil=!1;var e=!1,n=this.scene.effectLayers;if(n&&n.length>0){this._previousStencilState=this._engine.getStencilBuffer();for(var i=0,o=n;i<o.length;i++){var a=o[i];if(a.shouldRender()&&(!a.camera||a.camera.cameraRigMode===Pt.RIG_MODE_NONE&&t===a.camera||a.camera.cameraRigMode!==Pt.RIG_MODE_NONE&&a.camera._rigCameras.indexOf(t)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||a.needStencil();var s=a._mainTexture;s._shouldRender()&&(this.scene.incrementRenderId(),s.render(!1,!1),e=!0)}}this.scene.incrementRenderId()}return e},r.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},r.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},r.prototype._draw=function(t){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var e=this.scene.effectLayers,n=0;n<e.length;n++){var i=e[n];i.renderingGroupId===t&&i.shouldRender()&&i.render()}this._engine.setDepthBuffer(!0)}},r.prototype._drawCamera=function(){this._renderEffects&&this._draw(-1)},r.prototype._drawRenderingGroup=function(t){!this.scene._isInIntermediateRendering()&&this._renderEffects&&this._draw(t)},r}();as._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_EFFECTLAYER);t||(t=new _v(r),r._addComponent(t))},nt.d.prototype.getGlowLayerByName=function(r){for(var t,e=0;e<((t=this.effectLayers)===null||t===void 0?void 0:t.length);e++)if(this.effectLayers[e].name===r&&this.effectLayers[e].getEffectName()===vl.EffectName)return this.effectLayers[e];return null};var vl=function(r){function t(e,n,i){var o=r.call(this,e,n)||this;return o._intensity=1,o._includedOnlyMeshes=[],o._excludedMeshes=[],o._meshesUsingTheirOwnMaterials=[],o.neutralColor=new z.ov(0,0,0,1),o._options=(0,A.Cl)({mainTextureRatio:t.DefaultTextureRatio,blurKernelSize:32,mainTextureFixedSize:void 0,camera:null,mainTextureSamples:1,renderingGroupId:-1,ldrMerge:!1,alphaBlendingMode:P.Y.ALPHA_ADD,mainTextureType:P.Y.TEXTURETYPE_UNSIGNED_INT,generateStencilBuffer:!1},i),o._init({alphaBlendingMode:o._options.alphaBlendingMode,camera:o._options.camera,mainTextureFixedSize:o._options.mainTextureFixedSize,mainTextureRatio:o._options.mainTextureRatio,renderingGroupId:o._options.renderingGroupId,mainTextureType:o._options.mainTextureType,generateStencilBuffer:o._options.generateStencilBuffer}),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"blurKernelSize",{get:function(){return this._options.blurKernelSize},set:function(e){if(e!==this._options.blurKernelSize){this._options.blurKernelSize=e;var n=this._getEffectiveBlurKernelSize();this._horizontalBlurPostprocess1.kernel=n,this._verticalBlurPostprocess1.kernel=n,this._horizontalBlurPostprocess2.kernel=n,this._verticalBlurPostprocess2.kernel=n}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!1,configurable:!0}),t.prototype._importShadersAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,15638)),Promise.resolve().then(L.bind(L,67064)),Promise.resolve().then(L.bind(L,68442))])];case 1:return e.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,62191)),Promise.resolve().then(L.bind(L,99349)),Promise.resolve().then(L.bind(L,67881))])];case 3:e.sent(),e.label=4;case 4:return[4,r.prototype._importShadersAsync.call(this)];case 5:return e.sent(),[2]}})})},t.prototype.getEffectName=function(){return t.EffectName},t.prototype._createMergeEffect=function(){var e=this,n=`#define EMISSIVE
|
||
`;return this._options.ldrMerge&&(n+=`#define LDR
|
||
`),this._engine.createEffect("glowMapMerge",[Y.R.PositionKind],["offset"],["textureSampler","textureSampler2"],n,void 0,void 0,void 0,void 0,this.shaderLanguage,this._shadersLoaded?void 0:function(){return(0,A.sH)(e,void 0,void 0,function(){return(0,A.YH)(this,function(i){switch(i.label){case 0:return[4,this._importShadersAsync()];case 1:return i.sent(),this._shadersLoaded=!0,[2]}})})})},t.prototype._createTextureAndPostProcesses=function(){var e=this,n=this._mainTextureDesiredSize.width,i=this._mainTextureDesiredSize.height;n=this._engine.needPOTTextures?(0,ir.R)(n,this._maxSize):n,i=this._engine.needPOTTextures?(0,ir.R)(i,this._maxSize):i;var o;o=this._engine.getCaps().textureHalfFloatRender?P.Y.TEXTURETYPE_HALF_FLOAT:P.Y.TEXTURETYPE_UNSIGNED_INT,this._blurTexture1=new un.$("GlowLayerBlurRTT",{width:n,height:i},this._scene,!1,!0,o),this._blurTexture1.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(Ie.g.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;var a=Math.floor(n/2),s=Math.floor(i/2);this._blurTexture2=new un.$("GlowLayerBlurRTT2",{width:a,height:s},this._scene,!1,!0,o),this._blurTexture2.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(Ie.g.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2];var l=this._getEffectiveBlurKernelSize();this._horizontalBlurPostprocess1=new ci("GlowLayerHBP1",new _.I9(1,0),l,{width:n,height:i},null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess1.width=n,this._horizontalBlurPostprocess1.height=i,this._horizontalBlurPostprocess1.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess1.onApplyObservable.add(function(c){c.setTexture("textureSampler",e._mainTexture)}),this._verticalBlurPostprocess1=new ci("GlowLayerVBP1",new _.I9(0,1),l,{width:n,height:i},null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess2=new ci("GlowLayerHBP2",new _.I9(1,0),l,{width:a,height:s},null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess2.width=a,this._horizontalBlurPostprocess2.height=s,this._horizontalBlurPostprocess2.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess2.onApplyObservable.add(function(c){c.setTexture("textureSampler",e._blurTexture1)}),this._verticalBlurPostprocess2=new ci("GlowLayerVBP2",new _.I9(0,1),l,{width:a,height:s},null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add(function(){var c=e._blurTexture1.renderTarget;if(c){e._scene.postProcessManager.directRender(e._postProcesses1,c,!0);var u=e._blurTexture2.renderTarget;u&&e._scene.postProcessManager.directRender(e._postProcesses2,u,!0),e._engine.unBindFramebuffer(u??c,!0)}}),this._postProcesses.map(function(c){c.autoClear=!1})},t.prototype._getEffectiveBlurKernelSize=function(){return this._options.blurKernelSize/2},t.prototype.isReady=function(e,n){var i=e.getMaterial(),o=e.getRenderingMesh();if(!i||!o)return!1;var a=i.emissiveTexture;return r.prototype._isReady.call(this,e,n,a)},t.prototype.needStencil=function(){return!1},t.prototype._canRenderMesh=function(e,n){return!0},t.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);var n=this._engine,i=n.getStencilBuffer();n.setStencilBuffer(!1),n.drawElementsType(Lt.TriangleFillMode,0,6),n.setStencilBuffer(i)},t.prototype._setEmissiveTextureAndColor=function(e,n,i){var o,a=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,n,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(a=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector?this.customEmissiveColorSelector(e,n,i,this._emissiveTextureAndColor.color):i.emissiveColor?(a*=(o=i.emissiveIntensity)!==null&&o!==void 0?o:1,this._emissiveTextureAndColor.color.set(i.emissiveColor.r*a,i.emissiveColor.g*a,i.emissiveColor.b*a,i.alpha)):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)},t.prototype._shouldRenderMesh=function(e){return this.hasMesh(e)},t.prototype._addCustomEffectDefines=function(e){e.push("#define GLOW")},t.prototype.addExcludedMesh=function(e){this._excludedMeshes.indexOf(e.uniqueId)===-1&&this._excludedMeshes.push(e.uniqueId)},t.prototype.removeExcludedMesh=function(e){var n=this._excludedMeshes.indexOf(e.uniqueId);n!==-1&&this._excludedMeshes.splice(n,1)},t.prototype.addIncludedOnlyMesh=function(e){this._includedOnlyMeshes.indexOf(e.uniqueId)===-1&&this._includedOnlyMeshes.push(e.uniqueId)},t.prototype.removeIncludedOnlyMesh=function(e){var n=this._includedOnlyMeshes.indexOf(e.uniqueId);n!==-1&&this._includedOnlyMeshes.splice(n,1)},t.prototype.hasMesh=function(e){return!!r.prototype.hasMesh.call(this,e)&&(this._includedOnlyMeshes.length?this._includedOnlyMeshes.indexOf(e.uniqueId)!==-1:!this._excludedMeshes.length||this._excludedMeshes.indexOf(e.uniqueId)===-1)},t.prototype._useMeshMaterial=function(e){return this._meshesUsingTheirOwnMaterials.length!=0&&this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)>-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){var n=this;e.resetDrawCache(this._mainTexture.renderPassId),this._meshesUsingTheirOwnMaterials.push(e.uniqueId),e.onDisposeObservable.add(function(){n._disposeMesh(e)})},t.prototype.unReferenceMeshFromUsingItsOwnMaterial=function(e){for(var n=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);n>=0;)this._meshesUsingTheirOwnMaterials.splice(n,1),n=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);e.resetDrawCache(this._mainTexture.renderPassId)},t.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},t.prototype.getClassName=function(){return"GlowLayer"},t.prototype.serialize=function(){var e,n=tt.p.Serialize(this);if(n.customType="BABYLON.GlowLayer",n.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e<this._includedOnlyMeshes.length;e++)(i=this._scene.getMeshByUniqueId(this._includedOnlyMeshes[e]))&&n.includedMeshes.push(i.id);if(n.excludedMeshes=[],this._excludedMeshes.length)for(e=0;e<this._excludedMeshes.length;e++){var i;(i=this._scene.getMeshByUniqueId(this._excludedMeshes[e]))&&n.excludedMeshes.push(i.id)}return n},t.Parse=function(e,n,i){var o,a=tt.p.Parse(function(){return new t(e.name,n,e.options)},e,n,i);for(o=0;o<e.excludedMeshes.length;o++)(s=n.getMeshById(e.excludedMeshes[o]))&&a.addExcludedMesh(s);for(o=0;o<e.includedMeshes.length;o++){var s;(s=n.getMeshById(e.includedMeshes[o]))&&a.addIncludedOnlyMesh(s)}return a},t.EffectName="GlowLayer",t.DefaultBlurKernelSize=32,t.DefaultTextureRatio=.5,(0,A.Cg)([(0,V.lK)()],t.prototype,"blurKernelSize",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"intensity",null),(0,A.Cg)([(0,V.lK)("options")],t.prototype,"_options",void 0),t}(as);(0,j.Y5)("BABYLON.GlowLayer",vl),nt.d.prototype.getHighlightLayerByName=function(r){for(var t,e=0;e<((t=this.effectLayers)===null||t===void 0?void 0:t.length);e++)if(this.effectLayers[e].name===r&&this.effectLayers[e].getEffectName()===uh.EffectName)return this.effectLayers[e];return null};var zx=function(r){function t(e,n,i,o,a,s,l,c){s===void 0&&(s=Ie.g.BILINEAR_SAMPLINGMODE);var u=r.call(this,e,"glowBlurPostProcess",["screenSize","direction","blurWidth"],null,o,a,s,l,c)||this;return u.direction=n,u.kernel=i,u.onApplyObservable.add(function(d){d.setFloat2("screenSize",u.width,u.height),d.setVector2("direction",u.direction),d.setFloat("blurWidth",u.kernel)}),u}return(0,A.C6)(t,r),t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,68442)))):n.push(Promise.resolve().then(L.bind(L,67881))),r.prototype._gatherImports.call(this,e,n)},t}(_t.w),uh=function(r){function t(e,n,i){var o=r.call(this,e,n,i!==void 0&&!!i.forceGLSL)||this;return o.name=e,o.innerGlow=!0,o.outerGlow=!0,o.onBeforeBlurObservable=new K.cP,o.onAfterBlurObservable=new K.cP,o._instanceGlowingMeshStencilReference=t.GlowingMeshStencilReference++,o._meshes={},o._excludedMeshes={},o.neutralColor=t.NeutralColor,o._engine.isStencilEnable||O.V.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),o._options=(0,A.Cl)({mainTextureRatio:.5,blurTextureSizeRatio:.5,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:P.Y.ALPHA_COMBINE,camera:null,renderingGroupId:-1,mainTextureType:P.Y.TEXTURETYPE_UNSIGNED_INT,forceGLSL:!1},i),o._init({alphaBlendingMode:o._options.alphaBlendingMode,camera:o._options.camera,mainTextureFixedSize:o._options.mainTextureFixedSize,mainTextureRatio:o._options.mainTextureRatio,renderingGroupId:o._options.renderingGroupId,mainTextureType:o._options.mainTextureType}),o._shouldRender=!1,o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"blurHorizontalSize",{get:function(){return this._horizontalBlurPostprocess.kernel},set:function(e){this._horizontalBlurPostprocess.kernel=e,this._options.blurHorizontalSize=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurVerticalSize",{get:function(){return this._verticalBlurPostprocess.kernel},set:function(e){this._verticalBlurPostprocess.kernel=e,this._options.blurVerticalSize=e},enumerable:!1,configurable:!0}),t.prototype._importShadersAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,15638)),Promise.resolve().then(L.bind(L,67064)),Promise.resolve().then(L.bind(L,68442))])];case 1:return e.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,62191)),Promise.resolve().then(L.bind(L,99349)),Promise.resolve().then(L.bind(L,67881))])];case 3:e.sent(),e.label=4;case 4:return[4,r.prototype._importShadersAsync.call(this)];case 5:return e.sent(),[2]}})})},t.prototype.getEffectName=function(){return t.EffectName},t.prototype._numInternalDraws=function(){return 2},t.prototype._createMergeEffect=function(){var e=this;return this._engine.createEffect("glowMapMerge",[Y.R.PositionKind],["offset"],["textureSampler"],this._options.isStroke?`#define STROKE
|
||
`:void 0,void 0,void 0,void 0,void 0,this._shaderLanguage,this._shadersLoaded?void 0:function(){return(0,A.sH)(e,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return[4,this._importShadersAsync()];case 1:return n.sent(),this._shadersLoaded=!0,[2]}})})})},t.prototype._createTextureAndPostProcesses=function(){var e=this,n=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,i=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;n=this._engine.needPOTTextures?(0,ir.R)(n,this._maxSize):n,i=this._engine.needPOTTextures?(0,ir.R)(i,this._maxSize):i;var o;if(o=this._engine.getCaps().textureHalfFloatRender?P.Y.TEXTURETYPE_HALF_FLOAT:P.Y.TEXTURETYPE_UNSIGNED_INT,this._blurTexture=new un.$("HighlightLayerBlurRTT",{width:n,height:i},this._scene,!1,!0,o),this._blurTexture.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(Ie.g.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._options.alphaBlendingMode===P.Y.ALPHA_COMBINE)this._downSamplePostprocess=new ro.v("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._downSamplePostprocess.externalTextureSamplerBinding=!0,this._downSamplePostprocess.onApplyObservable.add(function(s){s.setTexture("textureSampler",e._mainTexture)}),this._horizontalBlurPostprocess=new zx("HighlightLayerHBP",new _.I9(1,0),this._options.blurHorizontalSize,1,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._horizontalBlurPostprocess.onApplyObservable.add(function(s){s.setFloat2("screenSize",n,i)}),this._verticalBlurPostprocess=new zx("HighlightLayerVBP",new _.I9(0,1),this._options.blurVerticalSize,1,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._verticalBlurPostprocess.onApplyObservable.add(function(s){s.setFloat2("screenSize",n,i)}),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess];else{this._horizontalBlurPostprocess=new ci("HighlightLayerHBP",new _.I9(1,0),this._options.blurHorizontalSize/2,{width:n,height:i},null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o);var a=this._horizontalBlurPostprocess;a.width=n,a.height=i,a.externalTextureSamplerBinding=!0,a.onApplyObservable.add(function(s){s.setTexture("textureSampler",e._mainTexture)}),this._verticalBlurPostprocess=new ci("HighlightLayerVBP",new _.I9(0,1),this._options.blurVerticalSize/2,{width:n,height:i},null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]}this._mainTexture.onAfterUnbindObservable.add(function(){e.onBeforeBlurObservable.notifyObservers(e);var s=e._blurTexture.renderTarget;s&&(e._scene.postProcessManager.directRender(e._postProcesses,s,!0),e._engine.unBindFramebuffer(s,!0)),e.onAfterBlurObservable.notifyObservers(e)}),this._postProcesses.map(function(s){s.autoClear=!1})},t.prototype.needStencil=function(){return!0},t.prototype.isReady=function(e,n){var i=e.getMaterial(),o=e.getRenderingMesh();if(!i||!o||!this._meshes)return!1;var a=null,s=this._meshes[o.uniqueId];return s&&s.glowEmissiveOnly&&i&&(a=i.emissiveTexture),r.prototype._isReady.call(this,e,n,a)},t.prototype._internalRender=function(e,n){e.setTexture("textureSampler",this._blurTexture);var i=this._engine;i.cacheStencilState(),i.setStencilOperationPass(P.Y.REPLACE),i.setStencilOperationFail(P.Y.KEEP),i.setStencilOperationDepthFail(P.Y.KEEP),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&n===0&&(e.setFloat("offset",0),i.setStencilFunction(P.Y.NOTEQUAL),i.drawElementsType(Lt.TriangleFillMode,0,6)),this.innerGlow&&n===1&&(e.setFloat("offset",1),i.setStencilFunction(P.Y.EQUAL),i.drawElementsType(Lt.TriangleFillMode,0,6)),i.restoreStencilState()},t.prototype.shouldRender=function(){return!!r.prototype.shouldRender.call(this)&&!!this._meshes},t.prototype._shouldRenderMesh=function(e){return!(this._excludedMeshes&&this._excludedMeshes[e.uniqueId]||!r.prototype.hasMesh.call(this,e))},t.prototype._canRenderMesh=function(e,n){return!0},t.prototype._addCustomEffectDefines=function(e){e.push("#define HIGHLIGHT")},t.prototype._setEmissiveTextureAndColor=function(e,n,i){var o=this._meshes[e.uniqueId];o?this._emissiveTextureAndColor.color.set(o.color.r,o.color.g,o.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),o&&o.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null},t.prototype.addExcludedMesh=function(e){if(this._excludedMeshes&&!this._excludedMeshes[e.uniqueId]){var n={mesh:e,beforeBind:null,afterRender:null,stencilState:!1};n.beforeBind=e.onBeforeBindObservable.add(function(i){n.stencilState=i.getEngine().getStencilBuffer(),i.getEngine().setStencilBuffer(!1)}),n.afterRender=e.onAfterRenderObservable.add(function(i){i.getEngine().setStencilBuffer(n.stencilState)}),this._excludedMeshes[e.uniqueId]=n}},t.prototype.removeExcludedMesh=function(e){if(this._excludedMeshes){var n=this._excludedMeshes[e.uniqueId];n&&(n.beforeBind&&e.onBeforeBindObservable.remove(n.beforeBind),n.afterRender&&e.onAfterRenderObservable.remove(n.afterRender)),this._excludedMeshes[e.uniqueId]=null}},t.prototype.hasMesh=function(e){return!!this._meshes&&!!r.prototype.hasMesh.call(this,e)&&this._meshes[e.uniqueId]!==void 0&&this._meshes[e.uniqueId]!==null},t.prototype.addMesh=function(e,n,i){var o=this;if(i===void 0&&(i=!1),this._meshes){var a=this._meshes[e.uniqueId];a?a.color=n:(this._meshes[e.uniqueId]={mesh:e,color:n,observerHighlight:e.onBeforeBindObservable.add(function(s){o.isEnabled&&(o._excludedMeshes&&o._excludedMeshes[s.uniqueId]?o._defaultStencilReference(s):s.getScene().getEngine().setStencilFunctionReference(o._instanceGlowingMeshStencilReference))}),observerDefault:e.onAfterRenderObservable.add(function(s){o.isEnabled&&o._defaultStencilReference(s)}),glowEmissiveOnly:i},e.onDisposeObservable.add(function(){o._disposeMesh(e)})),this._shouldRender=!0}},t.prototype.removeMesh=function(e){if(this._meshes){var n=this._meshes[e.uniqueId];for(var i in n&&(n.observerHighlight&&e.onBeforeBindObservable.remove(n.observerHighlight),n.observerDefault&&e.onAfterRenderObservable.remove(n.observerDefault),delete this._meshes[e.uniqueId]),this._shouldRender=!1,this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}},t.prototype.removeAllMeshes=function(){if(this._meshes){for(var e in this._meshes)if(Object.prototype.hasOwnProperty.call(this._meshes,e)){var n=this._meshes[e];n&&this.removeMesh(n.mesh)}}},t.prototype._defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference)},t.prototype._disposeMesh=function(e){this.removeMesh(e),this.removeExcludedMesh(e)},t.prototype.dispose=function(){if(this._meshes){for(var e in this._meshes)(n=this._meshes[e])&&n.mesh&&(n.observerHighlight&&n.mesh.onBeforeBindObservable.remove(n.observerHighlight),n.observerDefault&&n.mesh.onAfterRenderObservable.remove(n.observerDefault));this._meshes=null}if(this._excludedMeshes){for(var e in this._excludedMeshes){var n;(n=this._excludedMeshes[e])&&(n.beforeBind&&n.mesh.onBeforeBindObservable.remove(n.beforeBind),n.afterRender&&n.mesh.onAfterRenderObservable.remove(n.afterRender))}this._excludedMeshes=null}r.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"HighlightLayer"},t.prototype.serialize=function(){var e=tt.p.Serialize(this);if(e.customType="BABYLON.HighlightLayer",e.meshes=[],this._meshes)for(var n in this._meshes){var i=this._meshes[n];i&&e.meshes.push({glowEmissiveOnly:i.glowEmissiveOnly,color:i.color.asArray(),meshId:i.mesh.id})}if(e.excludedMeshes=[],this._excludedMeshes)for(var o in this._excludedMeshes){var a=this._excludedMeshes[o];a&&e.excludedMeshes.push(a.mesh.id)}return e},t.Parse=function(e,n,i){var o,a=tt.p.Parse(function(){return new t(e.name,n,e.options)},e,n,i);for(o=0;o<e.excludedMeshes.length;o++)(s=n.getMeshById(e.excludedMeshes[o]))&&a.addExcludedMesh(s);for(o=0;o<e.meshes.length;o++){var s,l=e.meshes[o];(s=n.getMeshById(l.meshId))&&a.addMesh(s,z.v9.FromArray(l.color),l.glowEmissiveOnly)}return a},t.EffectName="HighlightLayer",t.NeutralColor=new z.ov(0,0,0,0),t.GlowingMeshStencilReference=2,t.NormalMeshStencilReference=1,(0,A.Cg)([(0,V.lK)()],t.prototype,"innerGlow",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"outerGlow",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"blurHorizontalSize",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"blurVerticalSize",null),(0,A.Cg)([(0,V.lK)("options")],t.prototype,"_options",void 0),t}(as);(0,j.Y5)("BABYLON.HighlightLayer",uh);var mv=function(){function r(t){this.name=lt.v.NAME_LAYER,this.scene=t||Ve.q.LastCreatedScene,this.scene&&(this._engine=this.scene.getEngine(),this.scene.layers=[])}return r.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(lt.v.STEP_BEFORECAMERADRAW_LAYER,this,this._drawCameraBackground),this.scene._afterCameraDrawStage.registerStep(lt.v.STEP_AFTERCAMERADRAW_LAYER,this,this._drawCameraForegroundWithPostProcessing),this.scene._afterCameraPostProcessStage.registerStep(lt.v.STEP_AFTERCAMERAPOSTPROCESS_LAYER,this,this._drawCameraForegroundWithoutPostProcessing),this.scene._beforeRenderTargetDrawStage.registerStep(lt.v.STEP_BEFORERENDERTARGETDRAW_LAYER,this,this._drawRenderTargetBackground),this.scene._afterRenderTargetDrawStage.registerStep(lt.v.STEP_AFTERRENDERTARGETDRAW_LAYER,this,this._drawRenderTargetForegroundWithPostProcessing),this.scene._afterRenderTargetPostProcessStage.registerStep(lt.v.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER,this,this._drawRenderTargetForegroundWithoutPostProcessing)},r.prototype.rebuild=function(){for(var t=0,e=this.scene.layers;t<e.length;t++)e[t]._rebuild()},r.prototype.dispose=function(){for(var t=this.scene.layers;t.length;)t[0].dispose()},r.prototype._draw=function(t){var e=this.scene.layers;if(e.length){this._engine.setDepthBuffer(!1);for(var n=0,i=e;n<i.length;n++){var o=i[n];t(o)&&o.render()}this._engine.setDepthBuffer(!0)}},r.prototype._drawCameraPredicate=function(t,e,n,i){return!t.renderOnlyInRenderTargetTextures&&t.isBackground===e&&t.applyPostProcess===n&&!!(t.layerMask&i)},r.prototype._drawCameraBackground=function(t){var e=this;this._draw(function(n){return e._drawCameraPredicate(n,!0,!0,t.layerMask)})},r.prototype._drawCameraForegroundWithPostProcessing=function(t){var e=this;this._draw(function(n){return e._drawCameraPredicate(n,!1,!0,t.layerMask)})},r.prototype._drawCameraForegroundWithoutPostProcessing=function(t){var e=this;this._draw(function(n){return e._drawCameraPredicate(n,!1,!1,t.layerMask)})},r.prototype._drawRenderTargetPredicate=function(t,e,n,i,o){return t.renderTargetTextures.length>0&&t.isBackground===e&&t.applyPostProcess===n&&t.renderTargetTextures.indexOf(o)>-1&&!!(t.layerMask&i)},r.prototype._drawRenderTargetBackground=function(t){var e=this;this._draw(function(n){return e._drawRenderTargetPredicate(n,!0,!0,e.scene.activeCamera.layerMask,t)})},r.prototype._drawRenderTargetForegroundWithPostProcessing=function(t){var e=this;this._draw(function(n){return e._drawRenderTargetPredicate(n,!1,!0,e.scene.activeCamera.layerMask,t)})},r.prototype._drawRenderTargetForegroundWithoutPostProcessing=function(t){var e=this;this._draw(function(n){return e._drawRenderTargetPredicate(n,!1,!1,e.scene.activeCamera.layerMask,t)})},r.prototype.addFromContainer=function(t){var e=this;t.layers&&t.layers.forEach(function(n){e.scene.layers.push(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;e===void 0&&(e=!1),t.layers&&t.layers.forEach(function(i){var o=n.scene.layers.indexOf(i);o!==-1&&n.scene.layers.splice(o,1),e&&i.dispose()})},r}(),gv=function(){function r(t,e,n,i,o,a){a===void 0&&(a=!1),this.name=t,this._applyPostProcess=!0,this.scale=new _.I9(1,1),this.offset=new _.I9(0,0),this.alphaBlendingMode=P.Y.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this.isEnabled=!0,this._vertexBuffers={},this.onDisposeObservable=new K.cP,this.onBeforeRenderObservable=new K.cP,this.onAfterRenderObservable=new K.cP,this._shaderLanguage=0,this._shadersLoaded=!1,this.texture=e?new Ie.g(e,n,!0):null,this.isBackground=i===void 0||i,this.color=o===void 0?new z.ov(1,1,1,1):o,this._scene=n||Ve.q.LastCreatedScene;var s=this._scene.getEngine();!s.isWebGPU||a||r.ForceGLSL||(this._shaderLanguage=1);var l=this._scene._getComponent(lt.v.NAME_LAYER);l||(l=new mv(this._scene),this._scene._addComponent(l)),this._scene.layers.push(this),this._drawWrapper=new jn.E(s);var c=[];c.push(1,1),c.push(-1,1),c.push(-1,-1),c.push(1,-1);var u=new Y.R(s,c,Y.R.PositionKind,!1,!1,2);this._vertexBuffers[Y.R.PositionKind]=u,this._createIndexBuffer()}return Object.defineProperty(r.prototype,"applyPostProcess",{get:function(){return this.isBackground||this._applyPostProcess},set:function(t){this._applyPostProcess=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onDispose",{set:function(t){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onBeforeRender",{set:function(t){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onAfterRender",{set:function(t){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._createIndexBuffer=function(){var t=this._scene.getEngine(),e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=t.createIndexBuffer(e)},r.prototype._rebuild=function(){var t=this._vertexBuffers[Y.R.PositionKind];t&&t._rebuild(),this._createIndexBuffer()},r.prototype.isReady=function(){var t=this,e=this._scene.getEngine(),n="";this.alphaTest&&(n="#define ALPHATEST"),this.texture&&!this.texture.gammaSpace&&(n+=`
|
||
#define LINEAR`),this._previousDefines!==n&&(this._previousDefines=n,this._drawWrapper.effect=e.createEffect("layer",[Y.R.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],n,void 0,void 0,void 0,void 0,this._shaderLanguage,this._shadersLoaded?void 0:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(o){switch(o.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,34438)),Promise.resolve().then(L.bind(L,2652))])];case 1:return o.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,79645)),Promise.resolve().then(L.bind(L,94567))])];case 3:o.sent(),o.label=4;case 4:return this._shadersLoaded=!0,[2]}})})}));var i=this._drawWrapper.effect;return i?.isReady()&&(!this.texture||this.texture.isReady())},r.prototype.render=function(){if(this.isEnabled){var t=this._scene.getEngine();if(this.isReady()){var e=this._drawWrapper.effect;this.onBeforeRenderObservable.notifyObservers(this),t.enableEffect(this._drawWrapper),t.setState(!1),this.texture&&(e.setTexture("textureSampler",this.texture),e.setMatrix("textureMatrix",this.texture.getTextureMatrix())),e.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),e.setVector2("offset",this.offset),e.setVector2("scale",this.scale),t.bindBuffers(this._vertexBuffers,this._indexBuffer,e),this.alphaTest?t.drawElementsType(Lt.TriangleFillMode,0,6):(t.setAlphaMode(this.alphaBlendingMode),t.drawElementsType(Lt.TriangleFillMode,0,6),t.setAlphaMode(P.Y.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}}},r.prototype.dispose=function(){var t=this._vertexBuffers[Y.R.PositionKind];t&&(t.dispose(),this._vertexBuffers[Y.R.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var e=this._scene.layers.indexOf(this);this._scene.layers.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},r.ForceGLSL=!1,r}(),Wx=L(75417),Hx=L(47615),Yx=L(35750),Xx=L(97e3),jx=L(62191),qx=L(99349),Kx=L(67881),Zx=L(15638),Qx=L(67064),Jx=L(68442),$x=L(94567),eP=L(79645),tP=L(2652),nP=L(34438),vv=function(){function r(t,e,n,i,o){var a=this;this.size=t,this.position=e,this.alphaMode=P.Y.ALPHA_ONEONE,this.color=n||new z.v9(1,1,1),this.texture=i?new Ie.g(i,o.getScene(),!0):null,this._system=o;var s=o.scene.getEngine();o._onShadersLoaded.addOnce(function(){a._drawWrapper=new jn.E(s),a._drawWrapper.effect=s.createEffect("lensFlare",[Y.R.PositionKind],["color","viewportMatrix"],["textureSampler"],"",void 0,void 0,void 0,void 0,o.shaderLanguage)}),o.lensFlares.push(this)}return r.AddFlare=function(t,e,n,i,o){return new r(t,e,n,i,o)},r.prototype.dispose=function(){this.texture&&this.texture.dispose();var t=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(t,1)},r}(),dh=function(){function r(t,e,n){this.name=t,this.lensFlares=[],this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._shaderLanguage=0,this._vertexBuffers={},this._isEnabled=!0,this._onShadersLoaded=new K.cP(void 0,!0),this._shadersLoaded=!1,this._scene=n||Ve.q.LastCreatedScene,r._SceneComponentInitialization(this._scene),this._emitter=e,this.id=t,n.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(a){return n.activeCamera&&a.material&&a.isVisible&&a.isEnabled()&&a.isBlocker&&!!(a.layerMask&n.activeCamera.layerMask)};var i=n.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[Y.R.PositionKind]=new Y.R(i,o,Y.R.PositionKind,!1,!1,2),this._createIndexBuffer(),this._initShaderSourceAsync()}return Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._initShaderSourceAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:return!this._scene.getEngine().isWebGPU||r.ForceGLSL?[3,2]:(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,89967)),Promise.resolve().then(L.bind(L,51093))])]);case 1:return t.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,25188)),Promise.resolve().then(L.bind(L,51006))])];case 3:t.sent(),t.label=4;case 4:return this._shadersLoaded=!0,this._onShadersLoaded.notifyObservers(),[2]}})})},r.prototype._createIndexBuffer=function(){var t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(t)},Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled=t},enumerable:!1,configurable:!0}),r.prototype.getScene=function(){return this._scene},r.prototype.getEmitter=function(){return this._emitter},r.prototype.setEmitter=function(t){this._emitter=t},r.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},r.prototype.computeEffectivePosition=function(t){var e=this.getEmitterPosition();e=_.Pq.Project(e,_.uq.Identity(),this._scene.getTransformMatrix(),t),this._positionX=e.x,this._positionY=e.y,e=_.Pq.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),this.viewportBorder>0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,e.x+=this.viewportBorder,e.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder);var n=this._scene.useRightHandedSystem;return!!(e.z>0&&!n||e.z<0&&n)&&(this._positionX>t.x&&this._positionX<t.x+t.width&&this._positionY>t.y&&(this._positionY,t.y,t.height),!0)},r.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var t=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),e=t.length();t.normalize();var n=new fn(this._scene.activeCamera.globalPosition,t),i=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!i||!i.hit||i.distance>e},r.prototype.render=function(){if(!this._scene.activeCamera||!this._shadersLoaded)return!1;var t,e,n=this._scene.getEngine(),i=this._scene.activeCamera.viewport.toGlobal(n.getRenderWidth(!0),n.getRenderHeight(!0));if(!this.computeEffectivePosition(i)||!this._isVisible())return!1;var o=(t=this._positionX<this.borderLimit+i.x?this.borderLimit+i.x-this._positionX:this._positionX>i.x+i.width-this.borderLimit?this._positionX-i.x-i.width+this.borderLimit:0)>(e=this._positionY<this.borderLimit+i.y?this.borderLimit+i.y-this._positionY:this._positionY>i.y+i.height-this.borderLimit?this._positionY-i.y-i.height+this.borderLimit:0)?t:e;(o-=this.viewportBorder)>this.borderLimit&&(o=this.borderLimit);var a=1-(0,qe.Clamp)(o/this.borderLimit,0,1);if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(i.x+=this.viewportBorder,i.y+=this.viewportBorder,i.width-=2*this.viewportBorder,i.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var s=i.x+i.width/2,l=i.y+i.height/2,c=s-this._positionX,u=l-this._positionY;n.setState(!1),n.setDepthBuffer(!1);for(var d=0;d<this.lensFlares.length;d++){var h=this.lensFlares[d];if(h._drawWrapper.effect.isReady()&&(!h.texture||h.texture.isReady())){n.enableEffect(h._drawWrapper),n.bindBuffers(this._vertexBuffers,this._indexBuffer,h._drawWrapper.effect),n.setAlphaMode(h.alphaMode);var p=s-c*h.position,m=l-u*h.position,v=h.size,b=h.size*n.getAspectRatio(this._scene.activeCamera,!0),E=(p-i.x)/i.width*2-1,C=1-(m-i.y)/i.height*2,T=_.uq.FromValues(v/2,0,0,0,0,b/2,0,0,0,0,1,0,E,C,0,1);h._drawWrapper.effect.setMatrix("viewportMatrix",T),h._drawWrapper.effect.setTexture("textureSampler",h.texture),h._drawWrapper.effect.setFloat4("color",h.color.r*a,h.color.g*a,h.color.b*a,1),n.drawElementsType(Lt.TriangleFillMode,0,6)}}return n.setDepthBuffer(!0),n.setAlphaMode(P.Y.ALPHA_DISABLE),!0},r.prototype.rebuild=function(){var t;for(var e in this._createIndexBuffer(),this._vertexBuffers)(t=this._vertexBuffers[e])===null||t===void 0||t._rebuild()},r.prototype.dispose=function(){this._onShadersLoaded.clear();var t=this._vertexBuffers[Y.R.PositionKind];for(t&&(t.dispose(),this._vertexBuffers[Y.R.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);this.lensFlares.length;)this.lensFlares[0].dispose();var e=this._scene.lensFlareSystems.indexOf(this);this._scene.lensFlareSystems.splice(e,1)},r.Parse=function(t,e,n){var i=e.getLastEntryById(t.emitterId),o=t.name||"lensFlareSystem#"+t.emitterId,a=new r(o,i,e);a.id=t.id||o,a.borderLimit=t.borderLimit;for(var s=0;s<t.flares.length;s++){var l=t.flares[s];vv.AddFlare(l.size,l.position,z.v9.FromArray(l.color),l.textureName?n+l.textureName:"",a)}return a},r.prototype.serialize=function(){var t={};t.id=this.id,t.name=this.name,t.emitterId=this.getEmitter().id,t.borderLimit=this.borderLimit,t.flares=[];for(var e=0;e<this.lensFlares.length;e++){var n=this.lensFlares[e];t.flares.push({size:n.size,position:n.position,color:n.color.asArray(),textureName:ze.S0.GetFilename(n.texture?n.texture.name:"")})}return t},r.ForceGLSL=!1,r._SceneComponentInitialization=function(t){throw(0,gt.n)("LensFlareSystemSceneComponent")},r}();nt.d.AddParser(lt.v.NAME_LENSFLARESYSTEM,function(r,t,e,n){if(r.lensFlareSystems!==void 0&&r.lensFlareSystems!==null){e.lensFlareSystems||(e.lensFlareSystems=[]);for(var i=0,o=r.lensFlareSystems.length;i<o;i++){var a=r.lensFlareSystems[i],s=dh.Parse(a,t,n);e.lensFlareSystems.push(s)}}}),nt.d.prototype.getLensFlareSystemByName=function(r){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===r)return this.lensFlareSystems[t];return null},nt.d.prototype.getLensFlareSystemById=function(r){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].id===r)return this.lensFlareSystems[t];return null},nt.d.prototype.getLensFlareSystemByID=function(r){return this.getLensFlareSystemById(r)},nt.d.prototype.removeLensFlareSystem=function(r){var t=this.lensFlareSystems.indexOf(r);return t!==-1&&this.lensFlareSystems.splice(t,1),t},nt.d.prototype.addLensFlareSystem=function(r){this.lensFlareSystems.push(r)};var yv=function(){function r(t){this.name=lt.v.NAME_LENSFLARESYSTEM,this.scene=t,t.lensFlareSystems=[]}return r.prototype.register=function(){this.scene._afterCameraDrawStage.registerStep(lt.v.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM,this,this._draw)},r.prototype.rebuild=function(){for(var t=0;t<this.scene.lensFlareSystems.length;t++)this.scene.lensFlareSystems[t].rebuild()},r.prototype.addFromContainer=function(t){var e=this;t.lensFlareSystems&&t.lensFlareSystems.forEach(function(n){e.scene.addLensFlareSystem(n)})},r.prototype.removeFromContainer=function(t,e){var n=this;t.lensFlareSystems&&t.lensFlareSystems.forEach(function(i){n.scene.removeLensFlareSystem(i),e&&i.dispose()})},r.prototype.serialize=function(t){t.lensFlareSystems=[];for(var e=0,n=this.scene.lensFlareSystems;e<n.length;e++){var i=n[e];t.lensFlareSystems.push(i.serialize())}},r.prototype.dispose=function(){for(var t=this.scene.lensFlareSystems;t.length;)t[0].dispose()},r.prototype._draw=function(t){if(this.scene.lensFlaresEnabled){var e=this.scene.lensFlareSystems;ze.S0.StartPerformanceCounter("Lens flares",e.length>0);for(var n=0,i=e;n<i.length;n++){var o=i[n];t.layerMask&o.layerMask&&o.render()}ze.S0.EndPerformanceCounter("Lens flares",e.length>0)}},r}();dh._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_LENSFLARESYSTEM);t||(t=new yv(r),r._addComponent(t))};var iP=L(25188),rP=L(51006),oP=L(89967),aP=L(51093),ss=L(7931),zi=function(){function r(t,e,n,i,o,a){a===void 0&&(a=!1),this.onBeforeShadowMapRenderObservable=new K.cP,this.onAfterShadowMapRenderObservable=new K.cP,this.onBeforeShadowMapRenderMeshObservable=new K.cP,this.onAfterShadowMapRenderMeshObservable=new K.cP,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=r.FILTER_NONE,this._filteringQuality=r.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.useOpacityTextureForTransparentShadow=!1,this.frustumEdgeFalloff=0,this._shaderLanguage=0,this.forceBackFacesOnly=!1,this._lightDirection=_.Pq.Zero(),this._viewMatrix=_.uq.Zero(),this._projectionMatrix=_.uq.Zero(),this._transformMatrix=_.uq.Zero(),this._cachedPosition=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=_.uq.Identity(),this._shadersLoaded=!1,this._mapSize=t,this._light=e,this._scene=e.getScene(),this._camera=i??null,this._useRedTextureType=!!o,this._initShaderSourceAsync(a);var s=e._shadowGenerators;s||(s=e._shadowGenerators=new Map),s.set(this._camera,this),this.id=e.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "'.concat(this._light.name,'")')))),r._SceneComponentInitialization(this._scene);var l=this._scene.getEngine().getCaps();n?l.textureFloatRender&&l.textureFloatLinearFiltering?this._textureType=P.Y.TEXTURETYPE_FLOAT:l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering?this._textureType=P.Y.TEXTURETYPE_HALF_FLOAT:this._textureType=P.Y.TEXTURETYPE_UNSIGNED_INT:l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering?this._textureType=P.Y.TEXTURETYPE_HALF_FLOAT:l.textureFloatRender&&l.textureFloatLinearFiltering?this._textureType=P.Y.TEXTURETYPE_FLOAT:this._textureType=P.Y.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(r.prototype,"bias",{get:function(){return this._bias},set:function(t){this._bias=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"normalBias",{get:function(){return this._normalBias},set:function(t){this._normalBias=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(t){this._blurBoxOffset!==t&&(this._blurBoxOffset=t,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurScale",{get:function(){return this._blurScale},set:function(t){this._blurScale!==t&&(this._blurScale=t,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(t){this._blurKernel!==t&&(this._blurKernel=t,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(t){this._useKernelBlur!==t&&(this._useKernelBlur=t,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"depthScale",{get:function(){return this._depthScale!==void 0?this._depthScale:this._light.getDepthScale()},set:function(t){this._depthScale=t},enumerable:!1,configurable:!0}),r.prototype._validateFilter=function(t){return t},Object.defineProperty(r.prototype,"filter",{get:function(){return this._filter},set:function(t){if(t=this._validateFilter(t),this._light.needCube()){if(t===r.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(t===r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(t===r.FILTER_PCF||t===r.FILTER_PCSS)return void(this.usePoissonSampling=!0)}t!==r.FILTER_PCF&&t!==r.FILTER_PCSS||this._scene.getEngine()._features.supportShadowSamplers?this._filter!==t&&(this._filter=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"usePoissonSampling",{get:function(){return this.filter===r.FILTER_POISSONSAMPLING},set:function(t){var e=this._validateFilter(r.FILTER_POISSONSAMPLING);(t||this.filter===r.FILTER_POISSONSAMPLING)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useExponentialShadowMap",{get:function(){return this.filter===r.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===r.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===r.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var e=this._validateFilter(r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===r.FILTER_PCF},set:function(t){var e=this._validateFilter(r.FILTER_PCF);(t||this.filter===r.FILTER_PCF)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(t){this._filteringQuality!==t&&(this._filteringQuality=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useContactHardeningShadow",{get:function(){return this.filter===r.FILTER_PCSS},set:function(t){var e=this._validateFilter(r.FILTER_PCSS);(t||this.filter===r.FILTER_PCSS)&&(this.filter=t?e:r.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(t){this._contactHardeningLightSizeUVRatio=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"darkness",{get:function(){return this._darkness},set:function(t){this.setDarkness(t)},enumerable:!1,configurable:!0}),r.prototype.getDarkness=function(){return this._darkness},r.prototype.setDarkness=function(t){return this._darkness=t>=1?1:t<=0?0:t,this},Object.defineProperty(r.prototype,"transparencyShadow",{get:function(){return this._transparencyShadow},set:function(t){this.setTransparencyShadow(t)},enumerable:!1,configurable:!0}),r.prototype.setTransparencyShadow=function(t){return this._transparencyShadow=t,this},r.prototype.getShadowMap=function(){return this._shadowMap},r.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},r.prototype.getClassName=function(){return r.CLASSNAME},r.prototype.addShadowCaster=function(t,e){if(e===void 0&&(e=!0),!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.indexOf(t)===-1&&this._shadowMap.renderList.push(t),e)for(var n=0,i=t.getChildMeshes();n<i.length;n++){var o=i[n];this._shadowMap.renderList.indexOf(o)===-1&&this._shadowMap.renderList.push(o)}return this},r.prototype.removeShadowCaster=function(t,e){if(e===void 0&&(e=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var n=this._shadowMap.renderList.indexOf(t);if(n!==-1&&this._shadowMap.renderList.splice(n,1),e)for(var i=0,o=t.getChildren();i<o.length;i++){var a=o[i];this.removeShadowCaster(a)}return this},r.prototype.getLight=function(){return this._light},Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._getCamera=function(){var t;return(t=this._camera)!==null&&t!==void 0?t:this._scene.activeCamera},Object.defineProperty(r.prototype,"mapSize",{get:function(){return this._mapSize},set:function(t){this._mapSize=t,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()},enumerable:!1,configurable:!0}),r.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},r.prototype._createTargetRenderTexture=function(){var t=this._scene.getEngine();t._features.supportDepthStencilTexture?(this._shadowMap=new un.$(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1,void 0,this._useRedTextureType?P.Y.TEXTUREFORMAT_RED:P.Y.TEXTUREFORMAT_RGBA),this._shadowMap.createDepthStencilTexture(t.useReverseDepthBuffer?P.Y.GREATER:P.Y.LESS,!0,void 0,void 0,void 0,"DepthStencilForShadowGenerator-".concat(this._light.name))):this._shadowMap=new un.$(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.noPrePassRenderer=!0},r.prototype._initializeShadowMap=function(){var t=this;if(this._createTargetRenderTexture(),this._shadowMap!==null){this._shadowMap.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Ie.g.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=function(a,s,l,c){return t._renderForShadowMap(a,s,l,c)},this._shadowMap.customIsReadyFunction=function(){return!0};var e=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.add(function(){var a;t._currentSceneUBO=t._scene.getSceneUniformBuffer(),(a=e._debugPushGroup)===null||a===void 0||a.call(e,"shadow map generation for pass id ".concat(e.currentRenderPassId),1)}),this._shadowMap.onBeforeRenderObservable.add(function(a){t._sceneUBOs&&t._scene.setSceneUniformBuffer(t._sceneUBOs[0]),t._currentFaceIndex=a,t._filter===r.FILTER_PCF&&e.setColorWrite(!1),t.getTransformMatrix(),t._scene.setTransformMatrix(t._viewMatrix,t._projectionMatrix),t._useUBO&&(t._scene.getSceneUniformBuffer().unbindEffect(),t._scene.finalizeSceneUbo())}),this._shadowMap.onAfterUnbindObservable.add(function(){var a,s;if(t._sceneUBOs&&t._scene.setSceneUniformBuffer(t._currentSceneUBO),t._scene.updateTransformMatrix(),t._filter===r.FILTER_PCF&&e.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var l=t.getShadowMapForRendering();l&&(t._scene.postProcessManager.directRender(t._blurPostProcesses,l.renderTarget,!0),e.unBindFramebuffer(l.renderTarget,!0),(s=e._debugPopGroup)===null||s===void 0||s.call(e,1))}else(a=e._debugPopGroup)===null||a===void 0||a.call(e,1)});var n=new z.ov(0,0,0,0),i=new z.ov(1,1,1,1);this._shadowMap.onClearObservable.add(function(a){t._filter===r.FILTER_PCF?a.clear(i,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?a.clear(n,!0,!0,!1):a.clear(i,!0,!0,!1)}),this._shadowMap.onResizeObservable.add(function(a){t._storedUniqueId=t._shadowMap.uniqueId,t._mapSize=a.getRenderSize(),t._light._markMeshesAsLightDirty(),t.recreateShadowMap()});for(var o=ss.m.MIN_RENDERINGGROUPS;o<ss.m.MAX_RENDERINGGROUPS;o++)this._shadowMap.setRenderingAutoClearDepthStencil(o,!1)}},r.prototype._initShaderSourceAsync=function(t){return t===void 0&&(t=!1),(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return!this._scene.getEngine().isWebGPU||t||r.ForceGLSL?[3,2]:(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,65465)),Promise.resolve().then(L.bind(L,15455)),Promise.resolve().then(L.bind(L,71666)),Promise.resolve().then(L.bind(L,14654))])]);case 1:return e.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,79908)),Promise.resolve().then(L.bind(L,35004)),Promise.resolve().then(L.bind(L,71859)),Promise.resolve().then(L.bind(L,61195))])];case 3:e.sent(),e.label=4;case 4:return this._shadersLoaded=!0,[2]}})})},r.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,e=this._scene.getEngine(),n=this._mapSize/this.blurScale;this.useKernelBlur&&this.blurScale===1||(this._shadowMap2=new un.$(this._light.name+"_shadowMap2",n,this._scene,!1,!0,this._textureType,void 0,void 0,!1),this._shadowMap2.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(Ie.g.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new ci(this._light.name+"KernelBlurX",new _.I9(1,0),this.blurKernel,1,null,Ie.g.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.width=n,this._kernelBlurXPostprocess.height=n,this._kernelBlurXPostprocess.externalTextureSamplerBinding=!0,this._kernelBlurXPostprocess.onApplyObservable.add(function(i){i.setTexture("textureSampler",t._shadowMap)}),this._kernelBlurYPostprocess=new ci(this._light.name+"KernelBlurY",new _.I9(0,1),this.blurKernel,1,null,Ie.g.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===P.Y.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new _t.w(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,Ie.g.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType,void 0,void 0,void 0,void 0,this._shaderLanguage),this._boxBlurPostprocess.externalTextureSamplerBinding=!0,this._boxBlurPostprocess.onApplyObservable.add(function(i){i.setFloat2("screenSize",n,n),i.setTexture("textureSampler",t._shadowMap)}),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},r.prototype._renderForShadowMap=function(t,e,n,i){var o;if(i.length)for(o=0;o<i.length;o++)this._renderSubMeshForShadowMap(i.data[o]);for(o=0;o<t.length;o++)this._renderSubMeshForShadowMap(t.data[o]);for(o=0;o<e.length;o++)this._renderSubMeshForShadowMap(e.data[o]);if(this._transparencyShadow)for(o=0;o<n.length;o++)this._renderSubMeshForShadowMap(n.data[o],!0);else for(o=0;o<n.length;o++)n.data[o].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1},r.prototype._bindCustomEffectForRenderSubMeshForShadowMap=function(t,e,n){e.setMatrix("viewProjection",this.getTransformMatrix())},r.prototype._renderSubMeshForShadowMap=function(t,e){var n,i;e===void 0&&(e=!1);var o=t.getRenderingMesh(),a=t.getEffectiveMesh(),s=this._scene,l=s.getEngine(),c=t.getMaterial();if(a._internalAbstractMeshDataInfo._isActiveIntermediate=!1,c&&t.verticesCount!==0&&t._renderId!==s.getRenderId()){var u=s.useRightHandedSystem,d=a._getWorldMatrixDeterminant()<0,h=c._getEffectiveOrientation(o);(d&&!u||!d&&u)&&(h=h===P.Y.MATERIAL_ClockWiseSideOrientation?P.Y.MATERIAL_CounterClockWiseSideOrientation:P.Y.MATERIAL_ClockWiseSideOrientation);var p=h===P.Y.MATERIAL_ClockWiseSideOrientation;l.setState(c.backFaceCulling,void 0,void 0,p,c.cullBackFaces);var m=o._getInstancesRenderList(t._id,!!t.getReplacementMesh());if(!m.mustReturn){var v=l.getCaps().instancedArrays&&(m.visibleInstances[t._id]!==null&&m.visibleInstances[t._id]!==void 0||o.hasThinInstances);if(!this.customAllowRendering||this.customAllowRendering(t))if(this.isReady(t,v,e)){t._renderId=s.getRenderId();var b=c.shadowDepthWrapper,E=(n=b?.getEffect(t,this,l.currentRenderPassId))!==null&&n!==void 0?n:t._getDrawWrapper(),C=jn.E.GetEffect(E);l.enableEffect(E),v||o._bind(t,C,c.fillMode),this.getTransformMatrix(),C.setFloat3("biasAndScaleSM",this.bias,this.normalBias,this.depthScale),this.getLight().getTypeID()===hi.LIGHTTYPEID_DIRECTIONALLIGHT?C.setVector3("lightDataSM",this._cachedDirection):C.setVector3("lightDataSM",this._cachedPosition);var T=this._getCamera();if(T&&C.setFloat2("depthValuesSM",this.getLight().getDepthMinZ(T),this.getLight().getDepthMinZ(T)+this.getLight().getDepthMaxZ(T)),e&&this.enableSoftTransparentShadow&&C.setFloat2("softTransparentShadowSM",a.visibility*c.alpha,!((i=this._opacityTexture)===null||i===void 0)&&i.getAlphaFromRGB?1:0),b)t._setMainDrawWrapperOverride(E),b.standalone?b.baseMaterial.bindForSubMesh(a.getWorldMatrix(),o,t):c.bindForSubMesh(a.getWorldMatrix(),o,t),t._setMainDrawWrapperOverride(null);else{if(this._opacityTexture&&(C.setTexture("diffuseSampler",this._opacityTexture),C.setMatrix("diffuseMatrix",this._opacityTexture.getTextureMatrix()||this._defaultTextureMatrix)),o.useBones&&o.computeBonesUsingShaders&&o.skeleton){var f=o.skeleton;if(f.isUsingTextureForMatrices){var g=f.getTransformMatrixTexture(o);if(!g)return;C.setTexture("boneSampler",g),C.setFloat("boneTextureWidth",4*(f.bones.length+1))}else C.setMatrices("mBones",f.getTransformMatrices(o))}(0,Re.nR)(o,C),o.morphTargetManager&&o.morphTargetManager.isUsingTextureForTargets&&o.morphTargetManager._bind(C);var S=t.getMesh().bakedVertexAnimationManager;S&&S.isEnabled&&S.bind(C,v),(0,tn.gS)(C,c,s)}this._useUBO||b||this._bindCustomEffectForRenderSubMeshForShadowMap(t,C,a),(0,Re._8)(C,this._scene.getSceneUniformBuffer()),this._scene.getSceneUniformBuffer().bindUniformBuffer();var y=a.getWorldMatrix();v&&(a.getMeshUniformBuffer().bindToEffect(C,"Mesh"),a.transferToEffect(y)),this.forceBackFacesOnly&&l.setState(!0,0,!1,!0,c.cullBackFaces),this.onBeforeShadowMapRenderMeshObservable.notifyObservers(o),this.onBeforeShadowMapRenderObservable.notifyObservers(C),o._processRendering(a,t,C,c.fillMode,m,v,function(x,R){a===o||x?(a.getMeshUniformBuffer().bindToEffect(C,"Mesh"),a.transferToEffect(x?R:y)):(o.getMeshUniformBuffer().bindToEffect(C,"Mesh"),o.transferToEffect(R))}),this.forceBackFacesOnly&&l.setState(!0,0,!1,!1,c.cullBackFaces),this.onAfterShadowMapRenderObservable.notifyObservers(C),this.onAfterShadowMapRenderMeshObservable.notifyObservers(o)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}}},r.prototype._applyFilterValues=function(){this._shadowMap&&(this.filter===r.FILTER_NONE||this.filter===r.FILTER_PCSS?this._shadowMap.updateSamplingMode(Ie.g.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(Ie.g.BILINEAR_SAMPLINGMODE))},r.prototype.forceCompilation=function(t,e){var n=this,i=(0,A.Cl)({useInstances:!1},e),o=this.getShadowMap();if(o){var a=o.renderList;if(a){for(var s=[],l=0,c=a;l<c.length;l++){var u=c[l];s.push.apply(s,u.subMeshes)}if(s.length!==0){var d=0,h=function(){var p,m;if(n._scene&&n._scene.getEngine()){for(;n.isReady(s[d],i.useInstances,(m=(p=s[d].getMaterial())===null||p===void 0?void 0:p.needAlphaBlendingForMesh(s[d].getMesh()))!==null&&m!==void 0&&m);)if(++d>=s.length)return void(t&&t(n));setTimeout(h,16)}};h()}else t&&t(this)}else t&&t(this)}else t&&t(this)},r.prototype.forceCompilationAsync=function(t){var e=this;return new Promise(function(n){e.forceCompilation(function(){n()},t)})},r.prototype._isReadyCustomDefines=function(t,e,n){},r.prototype._prepareShadowDefines=function(t,e,n,i){n.push("#define SM_LIGHTTYPE_"+this._light.getClassName().toUpperCase()),n.push("#define SM_FLOAT "+(this._textureType!==P.Y.TEXTURETYPE_UNSIGNED_INT?"1":"0")),n.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),n.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));var o=t.getMesh();return n.push("#define SM_NORMALBIAS "+(this.normalBias&&o.isVerticesDataPresent(Y.R.NormalKind)?"1":"0")),n.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===hi.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),n.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),n.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&i?"1":"0")),this._isReadyCustomDefines(n,t,e),n},r.prototype.isReady=function(t,e,n){var i;if(!this._shadersLoaded)return!1;var o=t.getMaterial(),a=o?.shadowDepthWrapper;if(this._opacityTexture=null,!o)return!1;var s=[];if(this._prepareShadowDefines(t,e,s,n),a){if(!a.isReadyForSubMesh(t,s,this,e,this._scene.getEngine().currentRenderPassId))return!1}else{var l=t._getDrawWrapper(void 0,!0),c=l.effect,u=l.defines,d=[Y.R.PositionKind],h=t.getMesh();this.normalBias&&h.isVerticesDataPresent(Y.R.NormalKind)&&(d.push(Y.R.NormalKind),s.push("#define NORMAL"),h.nonUniformScaling&&s.push("#define NONUNIFORMSCALING"));var p=o.needAlphaTesting();if((p||o.needAlphaBlending())&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=o.opacityTexture:this._opacityTexture=o.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;var m=(i=o.alphaCutOff)!==null&&i!==void 0?i:r.DEFAULT_ALPHA_CUTOFF;s.push("#define ALPHATEXTURE"),p&&s.push("#define ALPHATESTVALUE ".concat(m).concat(m%1==0?".":"")),h.isVerticesDataPresent(Y.R.UVKind)&&(d.push(Y.R.UVKind),s.push("#define UV1")),h.isVerticesDataPresent(Y.R.UV2Kind)&&this._opacityTexture.coordinatesIndex===1&&(d.push(Y.R.UV2Kind),s.push("#define UV2"))}var v=new Tr;if(h.useBones&&h.computeBonesUsingShaders&&h.skeleton){d.push(Y.R.MatricesIndicesKind),d.push(Y.R.MatricesWeightsKind),h.numBoneInfluencers>4&&(d.push(Y.R.MatricesIndicesExtraKind),d.push(Y.R.MatricesWeightsExtraKind));var b=h.skeleton;s.push("#define NUM_BONE_INFLUENCERS "+h.numBoneInfluencers),h.numBoneInfluencers>0&&v.addCPUSkinningFallback(0,h),b.isUsingTextureForMatrices?s.push("#define BONETEXTURE"):s.push("#define BonesPerMesh "+(b.bones.length+1))}else s.push("#define NUM_BONE_INFLUENCERS 0");var E=h.morphTargetManager,C=0;if(E&&(C=E.numMaxInfluencers||E.numInfluencers)>0&&(s.push("#define MORPHTARGETS"),s.push("#define NUM_MORPH_INFLUENCERS "+C),E.isUsingTextureForTargets&&s.push("#define MORPHTARGETS_TEXTURE"),(0,Re.MF)(d,h,C)),(0,tn.tv)(o,this._scene,s),e&&(s.push("#define INSTANCES"),(0,Re.te)(d),t.getRenderingMesh().hasThinInstances&&s.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(var T=0,f=this.customShaderOptions.defines;T<f.length;T++){var g=f[T];s.indexOf(g)===-1&&s.push(g)}var S=h.bakedVertexAnimationManager;S&&S.isEnabled&&(s.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),e&&d.push("bakedVertexAnimationSettingsInstanced"));var y=s.join(`
|
||
`);if(u!==y){u=y;var x="shadowMap",R=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","morphTargetCount","boneTextureWidth","softTransparentShadowSM","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],I=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"];if((0,tn.TV)(R),this.customShaderOptions){if(x=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(var M=0,D=this.customShaderOptions.attributes;M<D.length;M++){var B=D[M];d.indexOf(B)===-1&&d.push(B)}if(this.customShaderOptions.uniforms)for(var F=0,X=this.customShaderOptions.uniforms;F<X.length;F++){var $=X[F];R.indexOf($)===-1&&R.push($)}if(this.customShaderOptions.samplers)for(var Q=0,ie=this.customShaderOptions.samplers;Q<ie.length;Q++){var q=ie[Q];I.indexOf(q)===-1&&I.push(q)}}var ee=this._scene.getEngine();c=ee.createEffect(x,{attributes:d,uniformsNames:R,uniformBuffersNames:["Scene","Mesh"],samplers:I,defines:y,fallbacks:v,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:C},shaderLanguage:this._shaderLanguage},ee),l.setEffect(c,u)}if(!c.isReady())return!1}return(this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(this._blurPostProcesses&&this._blurPostProcesses.length||this._initializeBlurRTTAndPostProcesses()),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady()||this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady()||this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())},r.prototype.prepareDefines=function(t,e){var n=this._scene,i=this._light;n.shadowsEnabled&&i.shadowEnabled&&(t["SHADOW"+e]=!0,this.useContactHardeningShadow?(t["SHADOWPCSS"+e]=!0,this._filteringQuality===r.QUALITY_LOW?t["SHADOWLOWQUALITY"+e]=!0:this._filteringQuality===r.QUALITY_MEDIUM&&(t["SHADOWMEDIUMQUALITY"+e]=!0)):this.usePercentageCloserFiltering?(t["SHADOWPCF"+e]=!0,this._filteringQuality===r.QUALITY_LOW?t["SHADOWLOWQUALITY"+e]=!0:this._filteringQuality===r.QUALITY_MEDIUM&&(t["SHADOWMEDIUMQUALITY"+e]=!0)):this.usePoissonSampling?t["SHADOWPOISSON"+e]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?t["SHADOWESM"+e]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(t["SHADOWCLOSEESM"+e]=!0),i.needCube()&&(t["SHADOWCUBE"+e]=!0))},r.prototype.bindShadowLight=function(t,e){var n=this._light;if(this._scene.shadowsEnabled&&n.shadowEnabled){var i=this._getCamera();if(i){var o=this.getShadowMap();if(o){n.needCube()||e.setMatrix("lightMatrix"+t,this.getTransformMatrix());var a=this.getShadowMapForRendering();this._filter===r.FILTER_PCF?(e.setDepthStencilTexture("shadowTexture"+t,a),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),o.getSize().width,1/o.getSize().width,this.frustumEdgeFalloff,t)):this._filter===r.FILTER_PCSS?(e.setDepthStencilTexture("shadowTexture"+t,a),e.setTexture("depthTexture"+t,a),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/o.getSize().width,this._contactHardeningLightSizeUVRatio*o.getSize().width,this.frustumEdgeFalloff,t)):(e.setTexture("shadowTexture"+t,a),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/o.getSize().width,this.depthScale,this.frustumEdgeFalloff,t)),n._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(i),this.getLight().getDepthMinZ(i)+this.getLight().getDepthMaxZ(i),t)}}}},Object.defineProperty(r.prototype,"viewMatrix",{get:function(){return this._viewMatrix},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"projectionMatrix",{get:function(){return this._projectionMatrix},enumerable:!1,configurable:!0}),r.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderId===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderId=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var e=this._light.position;if(this._light.computeTransformedInformation()&&(e=this._light.transformedPosition),_.Pq.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),Math.abs(_.Pq.Dot(this._lightDirection,_.Pq.Up()))===1&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!e.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(e),this._cachedDirection.copyFrom(this._lightDirection),_.uq.LookAtLHToRef(e,e.add(this._lightDirection),_.Pq.Up(),this._viewMatrix);var n=this.getShadowMap();if(n){var i=n.renderList;i&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,i)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix},r.prototype.recreateShadowMap=function(){var t=this._shadowMap;if(t){var e=t.renderList;if(this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this._filter,this._applyFilterValues(),e){this._shadowMap.renderList||(this._shadowMap.renderList=[]);for(var n=0,i=e;n<i.length;n++){var o=i[n];this._shadowMap.renderList.push(o)}}else this._shadowMap.renderList=null}},r.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]},r.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},r.prototype._disposeSceneUBOs=function(){if(this._sceneUBOs){for(var t=0,e=this._sceneUBOs;t<e.length;t++)e[t].dispose();this._sceneUBOs=[]}},r.prototype.dispose=function(){var t;if(this._disposeRTTandPostProcesses(),this._disposeSceneUBOs(),this._light){if(this._light._shadowGenerators){for(var e=this._light._shadowGenerators.entries(),n=e.next();n.done!==!0;n=e.next()){var i=(t=n.value)[0];t[1]===this&&this._light._shadowGenerators.delete(i)}this._light._shadowGenerators.size===0&&(this._light._shadowGenerators=null)}this._light._markMeshesAsLightDirty()}this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear()},r.prototype.serialize=function(){var t,e={},n=this.getShadowMap();if(!n)return e;if(e.className=this.getClassName(),e.lightId=this._light.id,e.cameraId=(t=this._camera)===null||t===void 0?void 0:t.id,e.id=this.id,e.mapSize=n.getRenderSize(),e.forceBackFacesOnly=this.forceBackFacesOnly,e.darkness=this.getDarkness(),e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.filteringQuality=this.filteringQuality,e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.depthScale=this.depthScale,e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.renderList=[],n.renderList)for(var i=0;i<n.renderList.length;i++){var o=n.renderList[i];e.renderList.push(o.id)}return e},r.Parse=function(t,e,n){for(var i=e.getLightById(t.lightId),o=t.cameraId!==void 0?e.getCameraById(t.cameraId):null,a=n?n(t.mapSize,i,o):new r(t.mapSize,i,void 0,o),s=a.getShadowMap(),l=0;l<t.renderList.length;l++)e.getMeshesById(t.renderList[l]).forEach(function(c){s&&(s.renderList||(s.renderList=[]),s.renderList.push(c))});return t.id!==void 0&&(a.id=t.id),a.forceBackFacesOnly=!!t.forceBackFacesOnly,t.darkness!==void 0&&a.setDarkness(t.darkness),t.transparencyShadow&&a.setTransparencyShadow(!0),t.frustumEdgeFalloff!==void 0&&(a.frustumEdgeFalloff=t.frustumEdgeFalloff),t.bias!==void 0&&(a.bias=t.bias),t.normalBias!==void 0&&(a.normalBias=t.normalBias),t.usePercentageCloserFiltering?a.usePercentageCloserFiltering=!0:t.useContactHardeningShadow?a.useContactHardeningShadow=!0:t.usePoissonSampling?a.usePoissonSampling=!0:t.useExponentialShadowMap?a.useExponentialShadowMap=!0:t.useBlurExponentialShadowMap?a.useBlurExponentialShadowMap=!0:t.useCloseExponentialShadowMap?a.useCloseExponentialShadowMap=!0:t.useBlurCloseExponentialShadowMap?a.useBlurCloseExponentialShadowMap=!0:t.useVarianceShadowMap?a.useExponentialShadowMap=!0:t.useBlurVarianceShadowMap&&(a.useBlurExponentialShadowMap=!0),t.contactHardeningLightSizeUVRatio!==void 0&&(a.contactHardeningLightSizeUVRatio=t.contactHardeningLightSizeUVRatio),t.filteringQuality!==void 0&&(a.filteringQuality=t.filteringQuality),t.depthScale&&(a.depthScale=t.depthScale),t.blurScale&&(a.blurScale=t.blurScale),t.blurBoxOffset&&(a.blurBoxOffset=t.blurBoxOffset),t.useKernelBlur&&(a.useKernelBlur=t.useKernelBlur),t.blurKernel&&(a.blurKernel=t.blurKernel),a},r.CLASSNAME="ShadowGenerator",r.ForceGLSL=!1,r.FILTER_NONE=0,r.FILTER_EXPONENTIALSHADOWMAP=1,r.FILTER_POISSONSAMPLING=2,r.FILTER_BLUREXPONENTIALSHADOWMAP=3,r.FILTER_CLOSEEXPONENTIALSHADOWMAP=4,r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5,r.FILTER_PCF=6,r.FILTER_PCSS=7,r.QUALITY_HIGH=0,r.QUALITY_MEDIUM=1,r.QUALITY_LOW=2,r.DEFAULT_ALPHA_CUTOFF=.5,r._SceneComponentInitialization=function(t){throw(0,gt.n)("ShadowGeneratorSceneComponent")},r}(),sP=L(80119),lP=L(36321),ls=function(){function r(t,e,n,i,o,a,s){e===void 0&&(e=P.Y.TEXTURETYPE_FLOAT),n===void 0&&(n=null),i===void 0&&(i=!1),o===void 0&&(o=Ie.g.TRILINEAR_SAMPLINGMODE),a===void 0&&(a=!1);var l=this;this._shaderLanguage=0,this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._shadersLoaded=!1,this._scene=t,this._storeNonLinearDepth=i,this._storeCameraSpaceZ=a,this.isPacked=e===P.Y.TEXTURETYPE_UNSIGNED_BYTE,this.isPacked?this.clearColor=new z.ov(1,1,1,1):this.clearColor=new z.ov(a?1e8:1,0,0,1),this._initShaderSourceAsync(),r._SceneComponentInitialization(this._scene);var c=t.getEngine();this._camera=n,o!==Ie.g.NEAREST_SAMPLINGMODE&&(e!==P.Y.TEXTURETYPE_FLOAT||c._caps.textureFloatLinearFiltering||(o=Ie.g.NEAREST_SAMPLINGMODE),e!==P.Y.TEXTURETYPE_HALF_FLOAT||c._caps.textureHalfFloatLinearFiltering||(o=Ie.g.NEAREST_SAMPLINGMODE));var u=this.isPacked||!c._features.supportExtendedTextureFormats?P.Y.TEXTUREFORMAT_RGBA:P.Y.TEXTUREFORMAT_R;this._depthMap=new un.$(s??"DepthRenderer",{width:c.getRenderWidth(),height:c.getRenderHeight()},this._scene,!1,!0,e,!1,o,void 0,void 0,void 0,u),this._depthMap.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._depthMap.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(function(h){h.clear(l.clearColor,!0,!0,!0)}),this._depthMap.onBeforeBindObservable.add(function(){var h;(h=c._debugPushGroup)===null||h===void 0||h.call(c,"depth renderer",1)}),this._depthMap.onAfterUnbindObservable.add(function(){var h;(h=c._debugPopGroup)===null||h===void 0||h.call(c,1)}),this._depthMap.customIsReadyFunction=function(h,p,m){if((m||p===0)&&h.subMeshes)for(var v=0;v<h.subMeshes.length;++v){var b=h.subMeshes[v],E=b.getRenderingMesh(),C=E._getInstancesRenderList(b._id,!!b.getReplacementMesh()),T=c.getCaps().instancedArrays&&(C.visibleInstances[b._id]!==null&&C.visibleInstances[b._id]!==void 0||E.hasThinInstances);if(!l.isReady(b,T))return!1}return!0};var d=function(h){var p,m=h.getRenderingMesh(),v=h.getEffectiveMesh(),b=l._scene,E=b.getEngine(),C=h.getMaterial();if(v._internalAbstractMeshDataInfo._isActiveIntermediate=!1,C&&!v.infiniteDistance&&!C.disableDepthWrite&&h.verticesCount!==0&&h._renderId!==b.getRenderId()){var T=v._getWorldMatrixDeterminant()<0,f=C._getEffectiveOrientation(m);T&&(f=f===P.Y.MATERIAL_ClockWiseSideOrientation?P.Y.MATERIAL_CounterClockWiseSideOrientation:P.Y.MATERIAL_ClockWiseSideOrientation);var g=f===P.Y.MATERIAL_ClockWiseSideOrientation;E.setState(C.backFaceCulling,0,!1,g,l.reverseCulling?!C.cullBackFaces:C.cullBackFaces);var S=m._getInstancesRenderList(h._id,!!h.getReplacementMesh());if(!S.mustReturn){var y=E.getCaps().instancedArrays&&(S.visibleInstances[h._id]!==null&&S.visibleInstances[h._id]!==void 0||m.hasThinInstances),x=l._camera||b.activeCamera;if(l.isReady(h,y)&&x){h._renderId=b.getRenderId();var R=(p=v._internalAbstractMeshDataInfo._materialForRenderPass)===null||p===void 0?void 0:p[E.currentRenderPassId],I=h._getDrawWrapper();!I&&R&&(I=R._getDrawWrapper());var M=x.mode===Pt.ORTHOGRAPHIC_CAMERA;if(!I)return;var D=I.effect;E.enableEffect(I),y||m._bind(h,D,C.fillMode),R?R.bindForSubMesh(v.getWorldMatrix(),v,h):(D.setMatrix("viewProjection",b.getTransformMatrix()),D.setMatrix("world",v.getWorldMatrix()),l._storeCameraSpaceZ&&D.setMatrix("view",b.getViewMatrix()));var B=void 0,F=void 0;if(M?(B=!E.useReverseDepthBuffer&&E.isNDCHalfZRange?0:1,F=E.useReverseDepthBuffer&&E.isNDCHalfZRange?0:1):(B=E.useReverseDepthBuffer&&E.isNDCHalfZRange?x.minZ:E.isNDCHalfZRange?0:x.minZ,F=E.useReverseDepthBuffer&&E.isNDCHalfZRange?0:x.maxZ),D.setFloat2("depthValues",B,B+F),!R){if(C.needAlphaTesting()){var X=C.getAlphaTestTexture();X&&(D.setTexture("diffuseSampler",X),D.setMatrix("diffuseMatrix",X.getTextureMatrix()))}(0,Re.f$)(m,D),(0,tn.gS)(D,C,b),(0,Re.nR)(m,D),m.morphTargetManager&&m.morphTargetManager.isUsingTextureForTargets&&m.morphTargetManager._bind(D);var $=h.getMesh().bakedVertexAnimationManager;$&&$.isEnabled&&$.bind(D,y),C.pointsCloud&&D.setFloat("pointSize",C.pointSize)}m._processRendering(v,h,D,C.fillMode,S,y,function(Q,ie){return D.setMatrix("world",ie)})}}}};this._depthMap.customRenderFunction=function(h,p,m,v){var b;if(v.length)for(b=0;b<v.length;b++)d(v.data[b]);for(b=0;b<h.length;b++)d(h.data[b]);for(b=0;b<p.length;b++)d(p.data[b]);if(l.forceDepthWriteTransparentMeshes)for(b=0;b<m.length;b++)d(m.data[b]);else for(b=0;b<m.length;b++)m.data[b].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1}}return Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype.setMaterialForRendering=function(t,e){this._depthMap.setMaterialForRendering(t,e)},r.prototype._initShaderSourceAsync=function(t){return t===void 0&&(t=!1),(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return!this._scene.getEngine().isWebGPU||t||r.ForceGLSL?[3,2]:(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,31086)),Promise.resolve().then(L.bind(L,62004))])]);case 1:return e.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,36321)),Promise.resolve().then(L.bind(L,80119))])];case 3:e.sent(),e.label=4;case 4:return this._shadersLoaded=!0,[2]}})})},r.prototype.isReady=function(t,e){var n;if(!this._shadersLoaded)return!1;var i=this._scene.getEngine(),o=t.getMesh(),a=o.getScene(),s=(n=o._internalAbstractMeshDataInfo._materialForRenderPass)===null||n===void 0?void 0:n[i.currentRenderPassId];if(s)return s.isReadyForSubMesh(o,t,e);var l=t.getMaterial();if(!l||l.disableDepthWrite)return!1;var c=[],u=[Y.R.PositionKind];l.needAlphaTesting()&&l.getAlphaTestTexture()&&(c.push("#define ALPHATEST"),o.isVerticesDataPresent(Y.R.UVKind)&&(u.push(Y.R.UVKind),c.push("#define UV1")),o.isVerticesDataPresent(Y.R.UV2Kind)&&(u.push(Y.R.UV2Kind),c.push("#define UV2")));var d=new Tr;if(o.useBones&&o.computeBonesUsingShaders&&o.skeleton){u.push(Y.R.MatricesIndicesKind),u.push(Y.R.MatricesWeightsKind),o.numBoneInfluencers>4&&(u.push(Y.R.MatricesIndicesExtraKind),u.push(Y.R.MatricesWeightsExtraKind)),c.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),o.numBoneInfluencers>0&&d.addCPUSkinningFallback(0,o);var h=o.skeleton;h.isUsingTextureForMatrices?c.push("#define BONETEXTURE"):c.push("#define BonesPerMesh "+(h.bones.length+1))}else c.push("#define NUM_BONE_INFLUENCERS 0");var p=o.morphTargetManager,m=0;p&&(m=p.numMaxInfluencers||p.numInfluencers)>0&&(c.push("#define MORPHTARGETS"),c.push("#define NUM_MORPH_INFLUENCERS "+m),p.isUsingTextureForTargets&&c.push("#define MORPHTARGETS_TEXTURE"),(0,Re.MF)(u,o,m)),l.pointsCloud&&c.push("#define POINTSIZE"),e&&(c.push("#define INSTANCES"),(0,Re.te)(u),t.getRenderingMesh().hasThinInstances&&c.push("#define THIN_INSTANCES"));var v=o.bakedVertexAnimationManager;v&&v.isEnabled&&(c.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),e&&u.push("bakedVertexAnimationSettingsInstanced")),this._storeNonLinearDepth&&c.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&c.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&c.push("#define PACKED"),(0,tn.tv)(l,a,c);var b=t._getDrawWrapper(void 0,!0),E=b.defines,C=c.join(`
|
||
`);if(E!==C){var T=["world","mBones","boneTextureWidth","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"];(0,tn.TV)(T),b.setEffect(i.createEffect("depth",{attributes:u,uniformsNames:T,uniformBuffersNames:[],samplers:["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"],defines:C,fallbacks:d,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:m},shaderLanguage:this._shaderLanguage},i))}return b.effect.isReady()},r.prototype.getDepthMap=function(){return this._depthMap},r.prototype.dispose=function(){var t=[];for(var e in this._scene._depthRenderer)this._scene._depthRenderer[e]===this&&t.push(e);if(t.length>0){this._depthMap.dispose();for(var n=0,i=t;n<i.length;n++)e=i[n],delete this._scene._depthRenderer[e]}},r.ForceGLSL=!1,r._SceneComponentInitialization=function(t){throw(0,gt.n)("DepthRendererSceneComponent")},r}(),bv=L(63639);Gt.l.ShadersStore.minmaxReduxPixelShader=`varying vec2 vUV;uniform sampler2D textureSampler;
|
||
#if defined(INITIAL)
|
||
uniform sampler2D sourceTexture;uniform vec2 texSize;void main(void)
|
||
{ivec2 coord=ivec2(vUV*(texSize-1.0));float f1=texelFetch(sourceTexture,coord,0).r;float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;float minz=min(min(min(f1,f2),f3),f4);
|
||
#ifdef DEPTH_REDUX
|
||
float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);
|
||
#else
|
||
float maxz=max(max(max(f1,f2),f3),f4);
|
||
#endif
|
||
glFragColor=vec4(minz,maxz,0.,0.);}
|
||
#elif defined(MAIN)
|
||
uniform vec2 texSize;void main(void)
|
||
{ivec2 coord=ivec2(vUV*(texSize-1.0));vec2 f1=texelFetch(textureSampler,coord,0).rg;vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);}
|
||
#elif defined(ONEBEFORELAST)
|
||
uniform ivec2 texSize;void main(void)
|
||
{ivec2 coord=ivec2(vUV*vec2(texSize-1));vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;float minz=min(f1.x,f2.x);float maxz=max(f1.y,f2.y);glFragColor=vec4(minz,maxz,0.,0.);}
|
||
#elif defined(LAST)
|
||
void main(void)
|
||
{glFragColor=vec4(0.);if (true) {
|
||
discard;}}
|
||
#endif
|
||
`;var Tv=function(){function r(t){var e=this;this.onAfterReductionPerformed=new K.cP,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=t,this._postProcessManager=new bv.X(t.getScene()),this._onContextRestoredObserver=t.getEngine().onContextRestoredObservable.add(function(){e._postProcessManager._rebuild()})}return Object.defineProperty(r.prototype,"sourceTexture",{get:function(){return this._sourceTexture},enumerable:!1,configurable:!0}),r.prototype.setSourceTexture=function(t,e,n,i){var o=this;if(n===void 0&&(n=P.Y.TEXTURETYPE_HALF_FLOAT),i===void 0&&(i=!0),t!==this._sourceTexture){this.dispose(!1),this._sourceTexture=t,this._reductionSteps=[],this._forceFullscreenViewport=i;var a=this._camera.getScene(),s=new _t.w("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,P.Y.TEXTURE_NEAREST_NEAREST,a.getEngine(),!1,"#define INITIAL"+(e?`
|
||
#define DEPTH_REDUX`:""),n,void 0,void 0,void 0,P.Y.TEXTUREFORMAT_RG);s.autoClear=!1,s.forceFullscreenViewport=i;var l=this._sourceTexture.getRenderWidth(),c=this._sourceTexture.getRenderHeight();s.onApply=function(h,p){return function(m){m.setTexture("sourceTexture",o._sourceTexture),m.setFloat2("texSize",h,p)}}(l,c),this._reductionSteps.push(s);for(var u=1;l>1||c>1;){l=Math.max(Math.round(l/2),1),c=Math.max(Math.round(c/2),1);var d=new _t.w("Reduction phase "+u,"minmaxRedux",["texSize"],null,{width:l,height:c},null,P.Y.TEXTURE_NEAREST_NEAREST,a.getEngine(),!1,"#define "+(l==1&&c==1?"LAST":l==1||c==1?"ONEBEFORELAST":"MAIN"),n,void 0,void 0,void 0,P.Y.TEXTUREFORMAT_RG);d.autoClear=!1,d.forceFullscreenViewport=i,d.onApply=function(h,p){return function(m){h==1||p==1?m.setInt2("texSize",h,p):m.setFloat2("texSize",h,p)}}(l,c),this._reductionSteps.push(d),u++,l==1&&c==1&&d.onAfterRenderObservable.add(function(h,p,m){var v=new Float32Array(4*h*p),b={min:0,max:0};return function(){a.getEngine()._readTexturePixels(m.inputTexture.texture,h,p,-1,0,v,!1),b.min=v[0],b.max=v[1],o.onAfterReductionPerformed.notifyObservers(b)}}(l,c,d))}}},Object.defineProperty(r.prototype,"refreshRate",{get:function(){return this._sourceTexture?this._sourceTexture.refreshRate:-1},set:function(t){this._sourceTexture&&(this._sourceTexture.refreshRate=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activated",{get:function(){return this._activated},enumerable:!1,configurable:!0}),r.prototype.activate=function(){var t=this;!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add(function(){var e,n,i=t._camera.getScene().getEngine();(e=i._debugPushGroup)===null||e===void 0||e.call(i,"min max reduction",1),t._reductionSteps[0].activate(t._camera),t._postProcessManager.directRender(t._reductionSteps,t._reductionSteps[0].inputTexture,t._forceFullscreenViewport),i.unBindFramebuffer(t._reductionSteps[0].inputTexture,!1),(n=i._debugPopGroup)===null||n===void 0||n.call(i,1)}),this._activated=!0)},r.prototype.deactivate=function(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)},r.prototype.dispose=function(t){if(t===void 0&&(t=!0),t&&(this.onAfterReductionPerformed.clear(),this._onContextRestoredObserver&&(this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)),this.deactivate(),this._reductionSteps){for(var e=0;e<this._reductionSteps.length;++e)this._reductionSteps[e].dispose();this._reductionSteps=null}this._postProcessManager&&t&&this._postProcessManager.dispose(),this._sourceTexture=null},r}(),Sv=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"depthRenderer",{get:function(){return this._depthRenderer},enumerable:!1,configurable:!0}),t.prototype.setDepthRenderer=function(e,n,i){e===void 0&&(e=null),n===void 0&&(n=P.Y.TEXTURETYPE_HALF_FLOAT),i===void 0&&(i=!0);var o=this._camera.getScene();this._depthRenderer&&(delete o._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),e===null&&(o._depthRenderer||(o._depthRenderer={}),(e=this._depthRenderer=new ls(o,n,this._camera,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE)).enabled=!1,this._depthRendererId="minmax"+this._camera.id,o._depthRenderer[this._depthRendererId]=e),r.prototype.setSourceTexture.call(this,e.getDepthMap(),!0,n,i)},t.prototype.setSourceTexture=function(e,n,i,o){i===void 0&&(i=P.Y.TEXTURETYPE_HALF_FLOAT),o===void 0&&(o=!0),r.prototype.setSourceTexture.call(this,e,n,i,o)},t.prototype.activate=function(){this._depthRenderer&&(this._depthRenderer.enabled=!0),r.prototype.activate.call(this)},t.prototype.deactivate=function(){r.prototype.deactivate.call(this),this._depthRenderer&&(this._depthRenderer.enabled=!1)},t.prototype.dispose=function(e){if(e===void 0&&(e=!0),r.prototype.dispose.call(this,e),this._depthRenderer&&e){var n=this._depthRenderer.getDepthMap().getScene();n&&delete n._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null}},t}(Tv),cP=_.Pq.Up(),aN=_.Pq.Zero(),$n=new _.Pq,cs=new _.Pq,hh=new _.uq,fh=function(r){function t(e,n,i,o,a){a===void 0&&(a=!0);var s=this;return t.IsSupported?((s=r.call(this,e,n,i,o,a)||this).usePercentageCloserFiltering=!0,s):(O.V.Error("CascadedShadowMap is not supported by the current engine."),s)}return(0,A.C6)(t,r),t.prototype._validateFilter=function(e){return e===zi.FILTER_NONE||e===zi.FILTER_PCF||e===zi.FILTER_PCSS?e:(O.V.Error('Unsupported filter "'+e+'"!'),zi.FILTER_NONE)},Object.defineProperty(t.prototype,"numCascades",{get:function(){return this._numCascades},set:function(e){(e=Math.min(Math.max(e,t.MIN_CASCADES_COUNT),t.MAX_CASCADES_COUNT))!==this._numCascades&&(this._numCascades=e,this.recreateShadowMap(),this._recreateSceneUBOs())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"freezeShadowCastersBoundingInfo",{get:function(){return this._freezeShadowCastersBoundingInfo},set:function(e){var n=this;this._freezeShadowCastersBoundingInfoObservable&&e&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),this._freezeShadowCastersBoundingInfoObservable||e||(this._freezeShadowCastersBoundingInfoObservable=this._scene.onBeforeRenderObservable.add(function(){return n._computeShadowCastersBoundingInfo()})),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()},enumerable:!1,configurable:!0}),t.prototype._computeShadowCastersBoundingInfo=function(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._shadowMap&&this._shadowMap.renderList){for(var e=this._shadowMap.renderList,n=0;n<e.length;n++)if(a=e[n]){var i=a.getBoundingInfo().boundingBox;this._scbiMin.minimizeInPlace(i.minimumWorld),this._scbiMax.maximizeInPlace(i.maximumWorld)}var o=this._scene.meshes;for(n=0;n<o.length;n++){var a;(a=o[n])&&a.isVisible&&a.isEnabled&&a.receiveShadows&&(i=a.getBoundingInfo().boundingBox,this._scbiMin.minimizeInPlace(i.minimumWorld),this._scbiMax.maximizeInPlace(i.maximumWorld))}}this._shadowCastersBoundingInfo.reConstruct(this._scbiMin,this._scbiMax)},Object.defineProperty(t.prototype,"shadowCastersBoundingInfo",{get:function(){return this._shadowCastersBoundingInfo},set:function(e){this._shadowCastersBoundingInfo=e},enumerable:!1,configurable:!0}),t.prototype.setMinMaxDistance=function(e,n){this._minDistance===e&&this._maxDistance===n||(e>n&&(e=0,n=1),e<0&&(e=0),n>1&&(n=1),this._minDistance=e,this._maxDistance=n,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,"minDistance",{get:function(){return this._minDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e<this._numCascades?this._cascadeMinExtents[e]:null},t.prototype.getCascadeMaxExtents=function(e){return e>=0&&e<this._numCascades?this._cascadeMaxExtents[e]:null},Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._getCamera()?this._shadowMaxZ:0},set:function(e){var n=this._getCamera();n?this._shadowMaxZ===e||e<n.minZ||e>n.maxZ&&n.maxZ!==0||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthClamp",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cascadeBlendPercentage",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lambda",{get:function(){return this._lambda},set:function(e){var n=Math.min(Math.max(e,0),1);this._lambda!=n&&(this._lambda=n,this._breaksAreDirty=!0)},enumerable:!1,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e<this._numCascades?this._viewMatrices[e]:null},t.prototype.getCascadeProjectionMatrix=function(e){return e>=0&&e<this._numCascades?this._projectionMatrices[e]:null},t.prototype.getCascadeTransformMatrix=function(e){return e>=0&&e<this._numCascades?this._transformMatrices[e]:null},t.prototype.setDepthRenderer=function(e){this._depthRenderer=e,this._depthReducer&&this._depthReducer.setDepthRenderer(this._depthRenderer)},Object.defineProperty(t.prototype,"autoCalcDepthBounds",{get:function(){return this._autoCalcDepthBounds},set:function(e){var n=this,i=this._getCamera();if(i){if(this._autoCalcDepthBounds=e,!e)return this._depthReducer&&this._depthReducer.deactivate(),void this.setMinMaxDistance(0,1);this._depthReducer||(this._depthReducer=new Sv(i),this._depthReducer.onAfterReductionPerformed.add(function(o){var a=o.min,s=o.max;a>=s&&(a=0,s=1),a==n._minDistance&&s==n._maxDistance||n.setMinMaxDistance(a,s)}),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,n,i;return(i=(n=(e=this._depthReducer)===null||e===void 0?void 0:e.depthRenderer)===null||n===void 0?void 0:n.getDepthMap().refreshRate)!==null&&i!==void 0?i:-1},set:function(e){var n;!((n=this._depthReducer)===null||n===void 0)&&n.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!1,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._getCamera();if(e){for(var n=e.minZ,i=e.maxZ||this._shadowMaxZ,o=i-n,a=this._minDistance,s=n+a*o,l=n+(this._shadowMaxZ<i&&this._shadowMaxZ>=n?Math.min((this._shadowMaxZ-n)/(i-n),this._maxDistance):this._maxDistance)*o,c=l-s,u=l/s,d=0;d<this._cascades.length;++d){var h=(d+1)/this._numCascades,p=s*Math.pow(u,h),m=s+c*h,v=this._lambda*(p-m)+m;this._cascades[d].prevBreakDistance=d===0?a:this._cascades[d-1].breakDistance,this._cascades[d].breakDistance=(v-n)/o,this._viewSpaceFrustumsZ[d]=v,this._frustumLengths[d]=(this._cascades[d].breakDistance-this._cascades[d].prevBreakDistance)*o}this._breaksAreDirty=!1}},t.prototype._computeMatrices=function(){var e=this._scene;if(this._getCamera()){_.Pq.NormalizeToRef(this._light.getShadowDirection(0),this._lightDirection),Math.abs(_.Pq.Dot(this._lightDirection,_.Pq.Up()))===1&&(this._lightDirection.z=1e-13),this._cachedDirection.copyFrom(this._lightDirection);for(var n=e.getEngine().useReverseDepthBuffer,i=0;i<this._numCascades;++i){this._computeFrustumInWorldSpace(i),this._computeCascadeFrustum(i),this._cascadeMaxExtents[i].subtractToRef(this._cascadeMinExtents[i],$n),this._frustumCenter[i].addToRef(this._lightDirection.scale(this._cascadeMinExtents[i].z),this._shadowCameraPos[i]),_.uq.LookAtLHToRef(this._shadowCameraPos[i],this._frustumCenter[i],cP,this._viewMatrices[i]);var o=0,a=$n.z,s=this._shadowCastersBoundingInfo;s.update(this._viewMatrices[i]),a=Math.min(a,s.boundingBox.maximumWorld.z),o=this._depthClamp&&this.filter!==zi.FILTER_PCSS?Math.max(o,s.boundingBox.minimumWorld.z):Math.min(o,s.boundingBox.minimumWorld.z),_.uq.OrthoOffCenterLHToRef(this._cascadeMinExtents[i].x,this._cascadeMaxExtents[i].x,this._cascadeMinExtents[i].y,this._cascadeMaxExtents[i].y,n?a:o,n?o:a,this._projectionMatrices[i],e.getEngine().isNDCHalfZRange),this._cascadeMinExtents[i].z=o,this._cascadeMaxExtents[i].z=a,this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i],this._transformMatrices[i]),_.Pq.TransformCoordinatesToRef(aN,this._transformMatrices[i],$n),$n.scaleInPlace(this._mapSize/2),cs.copyFromFloats(Math.round($n.x),Math.round($n.y),Math.round($n.z)),cs.subtractInPlace($n).scaleInPlace(2/this._mapSize),_.uq.TranslationToRef(cs.x,cs.y,0,hh),this._projectionMatrices[i].multiplyToRef(hh,this._projectionMatrices[i]),this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i],this._transformMatrices[i]),this._transformMatrices[i].copyToArray(this._transformMatricesAsArray,16*i)}}},t.prototype._computeFrustumInWorldSpace=function(e){var n=this._getCamera();if(n){var i=this._cascades[e].prevBreakDistance,o=this._cascades[e].breakDistance,a=this._scene.getEngine().isNDCHalfZRange;n.getViewMatrix();var s=n.maxZ===0,l=n.maxZ;s&&(n.maxZ=this._shadowMaxZ,n.getProjectionMatrix(!0));var c=_.uq.Invert(n.getTransformationMatrix());s&&(n.maxZ=l,n.getProjectionMatrix(!0));for(var u=this._scene.getEngine().useReverseDepthBuffer?4:0,d=0;d<t._FrustumCornersNDCSpace.length;++d)$n.copyFrom(t._FrustumCornersNDCSpace[(d+u)%t._FrustumCornersNDCSpace.length]),a&&$n.z===-1&&($n.z=0),_.Pq.TransformCoordinatesToRef($n,c,this._frustumCornersWorldSpace[e][d]);for(d=0;d<t._FrustumCornersNDCSpace.length/2;++d)$n.copyFrom(this._frustumCornersWorldSpace[e][d+4]).subtractInPlace(this._frustumCornersWorldSpace[e][d]),cs.copyFrom($n).scaleInPlace(i),$n.scaleInPlace(o),$n.addInPlace(this._frustumCornersWorldSpace[e][d]),this._frustumCornersWorldSpace[e][d+4].copyFrom($n),this._frustumCornersWorldSpace[e][d].addInPlace(cs)}},t.prototype._computeCascadeFrustum=function(e){if(this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cascadeMaxExtents[e].copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._frustumCenter[e].copyFromFloats(0,0,0),this._getCamera()){for(var n=0;n<this._frustumCornersWorldSpace[e].length;++n)this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][n]);if(this._frustumCenter[e].scaleInPlace(1/this._frustumCornersWorldSpace[e].length),this.stabilizeCascades){var i=0;for(n=0;n<this._frustumCornersWorldSpace[e].length;++n){var o=this._frustumCornersWorldSpace[e][n].subtractToRef(this._frustumCenter[e],$n).length();i=Math.max(i,o)}i=Math.ceil(16*i)/16,this._cascadeMaxExtents[e].copyFromFloats(i,i,i),this._cascadeMinExtents[e].copyFromFloats(-i,-i,-i)}else{var a=this._frustumCenter[e];for(this._frustumCenter[e].addToRef(this._lightDirection,$n),_.uq.LookAtLHToRef(a,$n,cP,hh),n=0;n<this._frustumCornersWorldSpace[e].length;++n)_.Pq.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][n],hh,$n),this._cascadeMinExtents[e].minimizeInPlace($n),this._cascadeMaxExtents[e].maximizeInPlace($n)}}},t.prototype._recreateSceneUBOs=function(){if(this._disposeSceneUBOs(),this._sceneUBOs)for(var e=0;e<this._numCascades;++e)this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for CSM Shadow Generator (light "'.concat(this._light.name,'" cascade #').concat(e,")")))},Object.defineProperty(t,"IsSupported",{get:function(){var e=Ve.q.LastCreatedEngine;return!!e&&e._features.supportCSM},enumerable:!1,configurable:!0}),t.prototype._initializeGenerator=function(){var e,n,i,o,a,s,l,c,u,d,h,p,m,v,b,E,C,T,f,g;this.penumbraDarkness=(e=this.penumbraDarkness)!==null&&e!==void 0?e:1,this._numCascades=(n=this._numCascades)!==null&&n!==void 0?n:t.DEFAULT_CASCADES_COUNT,this.stabilizeCascades=(i=this.stabilizeCascades)!==null&&i!==void 0&&i,this._freezeShadowCastersBoundingInfoObservable=(o=this._freezeShadowCastersBoundingInfoObservable)!==null&&o!==void 0?o:null,this.freezeShadowCastersBoundingInfo=(a=this.freezeShadowCastersBoundingInfo)!==null&&a!==void 0&&a,this._scbiMin=(s=this._scbiMin)!==null&&s!==void 0?s:new _.Pq(0,0,0),this._scbiMax=(l=this._scbiMax)!==null&&l!==void 0?l:new _.Pq(0,0,0),this._shadowCastersBoundingInfo=(c=this._shadowCastersBoundingInfo)!==null&&c!==void 0?c:new tr(new _.Pq(0,0,0),new _.Pq(0,0,0)),this._breaksAreDirty=(u=this._breaksAreDirty)===null||u===void 0||u,this._minDistance=(d=this._minDistance)!==null&&d!==void 0?d:0,this._maxDistance=(h=this._maxDistance)!==null&&h!==void 0?h:1,this._currentLayer=(p=this._currentLayer)!==null&&p!==void 0?p:0,this._shadowMaxZ=(b=(m=this._shadowMaxZ)!==null&&m!==void 0?m:(v=this._getCamera())===null||v===void 0?void 0:v.maxZ)!==null&&b!==void 0?b:1e4,this._debug=(E=this._debug)!==null&&E!==void 0&&E,this._depthClamp=(C=this._depthClamp)===null||C===void 0||C,this._cascadeBlendPercentage=(T=this._cascadeBlendPercentage)!==null&&T!==void 0?T:.1,this._lambda=(f=this._lambda)!==null&&f!==void 0?f:.5,this._autoCalcDepthBounds=(g=this._autoCalcDepthBounds)!==null&&g!==void 0&&g,this._recreateSceneUBOs(),r.prototype._initializeGenerator.call(this)},t.prototype._createTargetRenderTexture=function(){var e=this._scene.getEngine(),n={width:this._mapSize,height:this._mapSize,layers:this.numCascades};this._shadowMap=new un.$(this._light.name+"_CSMShadowMap",n,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0,this._useRedTextureType?P.Y.TEXTUREFORMAT_RED:P.Y.TEXTUREFORMAT_RGBA),this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer?P.Y.GREATER:P.Y.LESS,!0,void 0,void 0,void 0,"DepthStencilForCSMShadowGenerator-".concat(this._light.name)),this._shadowMap.noPrePassRenderer=!0},t.prototype._initializeShadowMap=function(){var e=this;if(r.prototype._initializeShadowMap.call(this),this._shadowMap!==null){this._transformMatricesAsArray=new Float32Array(16*this._numCascades),this._viewSpaceFrustumsZ=new Array(this._numCascades),this._frustumLengths=new Array(this._numCascades),this._lightSizeUVCorrection=new Array(2*this._numCascades),this._depthCorrection=new Array(this._numCascades),this._cascades=[],this._viewMatrices=[],this._projectionMatrices=[],this._transformMatrices=[],this._cascadeMinExtents=[],this._cascadeMaxExtents=[],this._frustumCenter=[],this._shadowCameraPos=[],this._frustumCornersWorldSpace=[];for(var n=0;n<this._numCascades;++n){this._cascades[n]={prevBreakDistance:0,breakDistance:0},this._viewMatrices[n]=_.uq.Zero(),this._projectionMatrices[n]=_.uq.Zero(),this._transformMatrices[n]=_.uq.Zero(),this._cascadeMinExtents[n]=new _.Pq,this._cascadeMaxExtents[n]=new _.Pq,this._frustumCenter[n]=new _.Pq,this._shadowCameraPos[n]=new _.Pq,this._frustumCornersWorldSpace[n]=new Array(t._FrustumCornersNDCSpace.length);for(var i=0;i<t._FrustumCornersNDCSpace.length;++i)this._frustumCornersWorldSpace[n][i]=new _.Pq}var o=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.clear(),this._shadowMap.onBeforeRenderObservable.clear(),this._shadowMap.onBeforeRenderObservable.add(function(a){e._sceneUBOs&&e._scene.setSceneUniformBuffer(e._sceneUBOs[a]),e._currentLayer=a,e._filter===zi.FILTER_PCF&&o.setColorWrite(!1),e._scene.setTransformMatrix(e.getCascadeViewMatrix(a),e.getCascadeProjectionMatrix(a)),e._useUBO&&(e._scene.getSceneUniformBuffer().unbindEffect(),e._scene.finalizeSceneUbo())}),this._shadowMap.onBeforeBindObservable.add(function(){var a;e._currentSceneUBO=e._scene.getSceneUniformBuffer(),(a=o._debugPushGroup)===null||a===void 0||a.call(o,"cascaded shadow map generation for pass id ".concat(o.currentRenderPassId),1),e._breaksAreDirty&&e._splitFrustum(),e._computeMatrices()}),this._splitFrustum()}},t.prototype._bindCustomEffectForRenderSubMeshForShadowMap=function(e,n){n.setMatrix("viewProjection",this.getCascadeTransformMatrix(this._currentLayer))},t.prototype._isReadyCustomDefines=function(e){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==zi.FILTER_PCSS?"1":"0"))},t.prototype.prepareDefines=function(e,n){r.prototype.prepareDefines.call(this,e,n);var i=this._scene,o=this._light;if(i.shadowsEnabled&&o.shadowEnabled){e["SHADOWCSM"+n]=!0,e["SHADOWCSMDEBUG"+n]=this.debug,e["SHADOWCSMNUM_CASCADES"+n]=this.numCascades,e["SHADOWCSM_RIGHTHANDED"+n]=i.useRightHandedSystem;var a=this._getCamera();a&&this._shadowMaxZ<=(a.maxZ||this._shadowMaxZ)&&(e["SHADOWCSMUSESHADOWMAXZ"+n]=!0),this.cascadeBlendPercentage===0&&(e["SHADOWCSMNOBLEND"+n]=!0)}},t.prototype.bindShadowLight=function(e,n){var i=this._light;if(this._scene.shadowsEnabled&&i.shadowEnabled){var o=this._getCamera();if(o){var a=this.getShadowMap();if(a){var s=a.getSize().width;if(n.setMatrices("lightMatrix"+e,this._transformMatricesAsArray),n.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),n.setFloat("cascadeBlendFactor"+e,this.cascadeBlendPercentage===0?1e4:1/this.cascadeBlendPercentage),n.setArray("frustumLengths"+e,this._frustumLengths),this._filter===zi.FILTER_PCF)n.setDepthStencilTexture("shadowTexture"+e,a),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),s,1/s,this.frustumEdgeFalloff,e);else if(this._filter===zi.FILTER_PCSS){for(var l=0;l<this._numCascades;++l)this._lightSizeUVCorrection[2*l+0]=l===0?1:(this._cascadeMaxExtents[0].x-this._cascadeMinExtents[0].x)/(this._cascadeMaxExtents[l].x-this._cascadeMinExtents[l].x),this._lightSizeUVCorrection[2*l+1]=l===0?1:(this._cascadeMaxExtents[0].y-this._cascadeMinExtents[0].y)/(this._cascadeMaxExtents[l].y-this._cascadeMinExtents[l].y),this._depthCorrection[l]=l===0?1:(this._cascadeMaxExtents[l].z-this._cascadeMinExtents[l].z)/(this._cascadeMaxExtents[0].z-this._cascadeMinExtents[0].z);n.setDepthStencilTexture("shadowTexture"+e,a),n.setTexture("depthTexture"+e,a),n.setArray2("lightSizeUVCorrection"+e,this._lightSizeUVCorrection),n.setArray("depthCorrection"+e,this._depthCorrection),n.setFloat("penumbraDarkness"+e,this.penumbraDarkness),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/s,this._contactHardeningLightSizeUVRatio*s,this.frustumEdgeFalloff,e)}else n.setTexture("shadowTexture"+e,a),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),s,1/s,this.frustumEdgeFalloff,e);i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(o),this.getLight().getDepthMinZ(o)+this.getLight().getDepthMaxZ(o),e)}}}},t.prototype.getTransformMatrix=function(){return this.getCascadeTransformMatrix(0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._freezeShadowCastersBoundingInfoObservable&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),this._depthReducer&&(this._depthReducer.dispose(),this._depthReducer=null)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this),n=this.getShadowMap();if(!n)return e;if(e.numCascades=this._numCascades,e.debug=this._debug,e.stabilizeCascades=this.stabilizeCascades,e.lambda=this._lambda,e.cascadeBlendPercentage=this.cascadeBlendPercentage,e.depthClamp=this._depthClamp,e.autoCalcDepthBounds=this.autoCalcDepthBounds,e.shadowMaxZ=this._shadowMaxZ,e.penumbraDarkness=this.penumbraDarkness,e.freezeShadowCastersBoundingInfo=this._freezeShadowCastersBoundingInfo,e.minDistance=this.minDistance,e.maxDistance=this.maxDistance,e.renderList=[],n.renderList)for(var i=0;i<n.renderList.length;i++){var o=n.renderList[i];e.renderList.push(o.id)}return e},t.Parse=function(e,n){var i=zi.Parse(e,n,function(o,a,s){return new t(o,a,void 0,s)});return e.numCascades!==void 0&&(i.numCascades=e.numCascades),e.debug!==void 0&&(i.debug=e.debug),e.stabilizeCascades!==void 0&&(i.stabilizeCascades=e.stabilizeCascades),e.lambda!==void 0&&(i.lambda=e.lambda),e.cascadeBlendPercentage!==void 0&&(i.cascadeBlendPercentage=e.cascadeBlendPercentage),e.depthClamp!==void 0&&(i.depthClamp=e.depthClamp),e.autoCalcDepthBounds!==void 0&&(i.autoCalcDepthBounds=e.autoCalcDepthBounds),e.shadowMaxZ!==void 0&&(i.shadowMaxZ=e.shadowMaxZ),e.penumbraDarkness!==void 0&&(i.penumbraDarkness=e.penumbraDarkness),e.freezeShadowCastersBoundingInfo!==void 0&&(i.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),e.minDistance!==void 0&&e.maxDistance!==void 0&&i.setMinMaxDistance(e.minDistance,e.maxDistance),i},t._FrustumCornersNDCSpace=[new _.Pq(-1,1,-1),new _.Pq(1,1,-1),new _.Pq(1,-1,-1),new _.Pq(-1,-1,-1),new _.Pq(-1,1,1),new _.Pq(1,1,1),new _.Pq(1,-1,1),new _.Pq(-1,-1,1)],t.CLASSNAME="CascadedShadowGenerator",t.DEFAULT_CASCADES_COUNT=4,t.MIN_CASCADES_COUNT=2,t.MAX_CASCADES_COUNT=4,t._SceneComponentInitialization=function(e){throw(0,gt.n)("ShadowGeneratorSceneComponent")},t}(zi);nt.d.AddParser(lt.v.NAME_SHADOWGENERATOR,function(r,t){if(r.shadowGenerators!==void 0&&r.shadowGenerators!==null)for(var e=0,n=r.shadowGenerators.length;e<n;e++){var i=r.shadowGenerators[e];i.className===fh.CLASSNAME?fh.Parse(i,t):zi.Parse(i,t)}});var Ev=function(){function r(t){this.name=lt.v.NAME_SHADOWGENERATOR,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(lt.v.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR,this,this._gatherRenderTargets)},r.prototype.rebuild=function(){},r.prototype.serialize=function(t){t.shadowGenerators=[];for(var e=0,n=this.scene.lights;e<n.length;e++){var i=n[e].getShadowGenerators();if(i)for(var o=i.values(),a=o.next();a.done!==!0;a=o.next()){var s=a.value;t.shadowGenerators.push(s.serialize())}}},r.prototype.addFromContainer=function(t){},r.prototype.removeFromContainer=function(t,e){},r.prototype.dispose=function(){},r.prototype._gatherRenderTargets=function(t){var e=this.scene;if(this.scene.shadowsEnabled)for(var n=0;n<e.lights.length;n++){var i=e.lights[n],o=i.getShadowGenerators();if(i.isEnabled()&&i.shadowEnabled&&o)for(var a=o.values(),s=a.next();s.done!==!0;s=a.next()){var l=s.value.getShadowMap();e.textures.indexOf(l)!==-1&&t.push(l)}}},r}();zi._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_SHADOWGENERATOR);t||(t=new Ev(r),r._addComponent(t))};var uP=L(65465),dP=L(15455),hP=L(71666),fP=L(14654),pP=L(79908),_P=L(35004),mP=L(71859),gP=L(61195);At.AddNodeConstructor("Light_Type_0",function(r,t){return function(){return new yl(r,_.Pq.Zero(),t)}});var yl=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._shadowAngle=Math.PI/2,o.position=n,o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){var n=this.needCube();if(this._direction=e,this.needCube()!==n&&this._shadowGenerators)for(var i=this._shadowGenerators.values(),o=i.next();o.done!==!0;o=i.next())o.value.recreateShadowMap()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PointLight"},t.prototype.getTypeID=function(){return hi.LIGHTTYPEID_POINTLIGHT},t.prototype.needCube=function(){return!this.direction},t.prototype.getShadowDirection=function(e){if(this.direction)return r.prototype.getShadowDirection.call(this,e);switch(e){case 0:return new _.Pq(1,0,0);case 1:return new _.Pq(-1,0,0);case 2:return new _.Pq(0,-1,0);case 3:return new _.Pq(0,1,0);case 4:return new _.Pq(0,0,1);case 5:return new _.Pq(0,0,-1)}return _.Pq.Zero()},t.prototype._setDefaultShadowProjectionMatrix=function(e,n,i){var o=this.getScene().activeCamera;if(o){var a=this.shadowMinZ!==void 0?this.shadowMinZ:o.minZ,s=this.shadowMaxZ!==void 0?this.shadowMaxZ:o.maxZ,l=this.getScene().getEngine().useReverseDepthBuffer;_.uq.PerspectiveFovLHToRef(this.shadowAngle,1,l?s:a,l?a:s,e,!0,this._scene.getEngine().isNDCHalfZRange,void 0,l)}},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,n){return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,n):this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,n),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,n),this},t.prototype.transferToNodeMaterialEffect=function(e,n){return this.computeTransformedInformation()?e.setFloat3(n,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z):e.setFloat3(n,this.position.x,this.position.y,this.position.z),this},t.prototype.prepareLightSpecificDefines=function(e,n){e["POINTLIGHT"+n]=!0},(0,A.Cg)([(0,V.lK)()],t.prototype,"shadowAngle",null),t}(dl);(0,j.Y5)("BABYLON.PointLight",yl);var xv=function(){function r(t,e,n){e===void 0&&(e=""),n===void 0&&(n="black");var i=this;this._renderingCanvas=t,this._loadingText=e,this._loadingDivBackgroundColor=n,this._resizeLoadingUI=function(){var o=i._renderingCanvas.getBoundingClientRect(),a=window.getComputedStyle(i._renderingCanvas).position;i._loadingDiv&&(i._loadingDiv.style.position=a==="fixed"?"fixed":"absolute",i._loadingDiv.style.left=o.left+"px",i._loadingDiv.style.top=o.top+"px",i._loadingDiv.style.width=o.width+"px",i._loadingDiv.style.height=o.height+"px")}}return r.prototype.displayLoadingUI=function(){if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingDiv.style.pointerEvents="none",this._loadingDiv.style.display="grid",this._loadingDiv.style.gridTemplateRows="100%",this._loadingDiv.style.gridTemplateColumns="100%",this._loadingDiv.style.justifyItems="center",this._loadingDiv.style.alignItems="center",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.style.zIndex="1",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText,this._style=document.createElement("style"),this._style.type="text/css",this._style.innerHTML=`@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}
|
||
100% { -webkit-transform: rotate(360deg);}
|
||
} @keyframes spin1 { 0% { transform: rotate(0deg);}
|
||
100% { transform: rotate(360deg);}
|
||
}`,document.getElementsByTagName("head")[0].appendChild(this._style);var t=!!window.SVGSVGElement,e=new Image;r.DefaultLogoUrl?e.src=r.DefaultLogoUrl:e.src=t?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+":"https://cdn.babylonjs.com/Assets/babylonLogo.png",e.style.width="150px",e.style.gridColumn="1",e.style.gridRow="1",e.style.top="50%",e.style.left="50%",e.style.transform="translate(-50%, -50%)",e.style.position="absolute";var n=document.createElement("div");n.style.width="300px",n.style.gridColumn="1",n.style.gridRow="1",n.style.top="50%",n.style.left="50%",n.style.transform="translate(-50%, -50%)",n.style.position="absolute";var i=new Image;if(r.DefaultSpinnerUrl?i.src=r.DefaultSpinnerUrl:i.src=t?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==":"https://cdn.babylonjs.com/Assets/loadingIcon.png",i.style.animation="spin1 0.75s infinite linear",i.style.webkitAnimation="spin1 0.75s infinite linear",i.style.transformOrigin="50% 50%",i.style.webkitTransformOrigin="50% 50%",!t){var o={w:16,h:18.5},a={w:30,h:30};e.style.width="".concat(o.w,"vh"),e.style.height="".concat(o.h,"vh"),e.style.left="calc(50% - ".concat(o.w/2,"vh)"),e.style.top="calc(50% - ".concat(o.h/2,"vh)"),i.style.width="".concat(a.w,"vh"),i.style.height="".concat(a.h,"vh"),i.style.left="calc(50% - ".concat(a.w/2,"vh)"),i.style.top="calc(50% - ".concat(a.h/2,"vh)")}n.appendChild(i),this._loadingDiv.appendChild(e),this._loadingDiv.appendChild(n),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}},r.prototype.hideLoadingUI=function(){var t=this;this._loadingDiv&&(this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",function(){t._loadingTextDiv&&(t._loadingTextDiv.remove(),t._loadingTextDiv=null),t._loadingDiv&&(t._loadingDiv.remove(),t._loadingDiv=null),t._style&&(t._style.remove(),t._style=null),window.removeEventListener("resize",t._resizeLoadingUI)}))},Object.defineProperty(r.prototype,"loadingUIText",{get:function(){return this._loadingText},set:function(t){this._loadingText=t,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(t){this._loadingDivBackgroundColor=t,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!1,configurable:!0}),r.DefaultLogoUrl="",r.DefaultSpinnerUrl="",r}();Be.$.DefaultLoadingScreenFactory=function(r){return new xv(r)};var Pv=L(51967),Av=L(75768),Ni=L(93540),ph=function(){function r(t,e){e===void 0&&(e={}),this._lodGenerationOffset=0,this._lodGenerationScale=.8,this.quality=P.Y.TEXTURE_FILTERING_QUALITY_OFFLINE,this.hdrScale=1,this._engine=t,this.hdrScale=e.hdrScale||this.hdrScale,this.quality=e.quality||this.quality}return r.prototype._createRenderTarget=function(t){var e=P.Y.TEXTURETYPE_UNSIGNED_BYTE;this._engine.getCaps().textureHalfFloatRender?e=P.Y.TEXTURETYPE_HALF_FLOAT:this._engine.getCaps().textureFloatRender&&(e=P.Y.TEXTURETYPE_FLOAT);var n=this._engine.createRenderTargetCubeTexture(t,{format:P.Y.TEXTUREFORMAT_RGBA,type:e,createMipMaps:!0,generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE});return this._engine.updateTextureWrappingMode(n.texture,P.Y.TEXTURE_CLAMP_ADDRESSMODE,P.Y.TEXTURE_CLAMP_ADDRESSMODE,P.Y.TEXTURE_CLAMP_ADDRESSMODE),this._engine.updateTextureSamplingMode(P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,n.texture,!0),n},r.prototype._prefilterInternal=function(t){var e=t.getSize().width,n=(0,qe.ILog2)(e)+1,i=this._effectWrapper.effect,o=this._createRenderTarget(e);this._effectRenderer.saveStates(),this._effectRenderer.setViewport();var a=t.getInternalTexture();a&&this._engine.updateTextureSamplingMode(P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE,a,!0),this._effectRenderer.applyEffectWrapper(this._effectWrapper);var s=[[new Ge.Pq(0,0,-1),new Ge.Pq(0,-1,0),new Ge.Pq(1,0,0)],[new Ge.Pq(0,0,1),new Ge.Pq(0,-1,0),new Ge.Pq(-1,0,0)],[new Ge.Pq(1,0,0),new Ge.Pq(0,0,1),new Ge.Pq(0,1,0)],[new Ge.Pq(1,0,0),new Ge.Pq(0,0,-1),new Ge.Pq(0,-1,0)],[new Ge.Pq(1,0,0),new Ge.Pq(0,-1,0),new Ge.Pq(0,0,1)],[new Ge.Pq(-1,0,0),new Ge.Pq(0,-1,0),new Ge.Pq(0,0,-1)]];i.setFloat("hdrScale",this.hdrScale),i.setFloat2("vFilteringInfo",t.getSize().width,n),i.setTexture("inputTexture",t);for(var l=0;l<6;l++){i.setVector3("up",s[l][0]),i.setVector3("right",s[l][1]),i.setVector3("front",s[l][2]);for(var c=0;c<n;c++){this._engine.bindFramebuffer(o,l,void 0,void 0,!0,c),this._effectRenderer.applyEffectWrapper(this._effectWrapper);var u=Math.pow(2,(c-this._lodGenerationOffset)/this._lodGenerationScale)/e;c===0&&(u=0),i.setFloat("alphaG",u),this._effectRenderer.draw()}}this._effectRenderer.restoreStates(),this._engine.restoreDefaultFramebuffer(),this._engine._releaseTexture(t._texture);var d=o.texture.type,h=o.texture.format;return o._swapAndDie(t._texture),t._texture.type=d,t._texture.format=h,t.gammaSpace=!1,t.lodGenerationOffset=this._lodGenerationOffset,t.lodGenerationScale=this._lodGenerationScale,t._prefiltered=!0,t},r.prototype._createEffect=function(t,e){var n=this,i=[];t.gammaSpace&&i.push("#define GAMMA_INPUT"),i.push("#define NUM_SAMPLES "+this.quality+"u");var o=this._engine.isWebGPU,a=new Ni.$({engine:this._engine,name:"hdrFiltering",vertexShader:"hdrFiltering",fragmentShader:"hdrFiltering",samplerNames:["inputTexture"],uniformNames:["vSampleDirections","vWeights","up","right","front","vFilteringInfo","hdrScale","alphaG"],useShaderStore:!0,defines:i,onCompiled:e,shaderLanguage:o?1:0,extraInitializationsAsync:function(){return(0,A.sH)(n,void 0,void 0,function(){return(0,A.YH)(this,function(s){switch(s.label){case 0:return o?[4,Promise.all([Promise.resolve().then(L.bind(L,34593)),Promise.resolve().then(L.bind(L,76459))])]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,88724)),Promise.resolve().then(L.bind(L,59586))])];case 3:s.sent(),s.label=4;case 4:return[2]}})})}});return a},r.prototype.isReady=function(t){return t.isReady()&&this._effectWrapper.effect.isReady()},r.prototype.prefilter=function(t,e){var n=this;return e===void 0&&(e=null),this._engine._features.allowTexturePrefiltering?new Promise(function(i){n._effectRenderer=new Ni.J(n._engine),n._effectWrapper=n._createEffect(t),n._effectWrapper.effect.executeWhenCompiled(function(){n._prefilterInternal(t),n._effectRenderer.dispose(),n._effectWrapper.dispose(),i(),e&&e()})}):(O.V.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."),Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."))},r}(),bl=function(r){function t(e,n,i,o,a,s,l,c,u,d){o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=!1),c===void 0&&(c=null),u===void 0&&(u=null),d===void 0&&(d=!1);var h,p=this;return(p=r.call(this,n)||this)._generateHarmonics=!0,p._onError=null,p._isBlocking=!0,p._rotationY=0,p.boundingBoxPosition=_.Pq.Zero(),p.onLoadObservable=new K.cP,e&&(p._coordinatesMode=Ie.g.CUBIC_MODE,p.name=e,p.url=e,p.hasAlpha=!1,p.isCube=!0,p._textureMatrix=_.uq.Identity(),p._prefilterOnLoad=l,p._onLoad=function(){p.onLoadObservable.notifyObservers(p),c&&c()},p._onError=u,p.gammaSpace=s,p._noMipmap=o,p._size=i,p._supersample=d,p._generateHarmonics=a,p._texture=p._getFromCache(e,p._noMipmap,void 0,void 0,void 0,p.isCube),p._texture?p._texture.isReady?ze.S0.SetImmediate(function(){return p._onLoad()}):p._texture.onLoadedObservable.add(p._onLoad):!((h=p.getScene())===null||h===void 0)&&h.useDelayedTextureLoading?p.delayLoadState=P.Y.DELAYLOADSTATE_NOTLOADED:p._loadTexture()),p}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(_.uq.RotationY(this._rotationY))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var n=this.getScene();n&&n.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"HDRCubeTexture"},t.prototype._loadTexture=function(){var e=this,n=this._getEngine(),i=n.getCaps(),o=P.Y.TEXTURETYPE_UNSIGNED_BYTE;if(i.textureFloat&&i.textureFloatLinearFiltering?o=P.Y.TEXTURETYPE_FLOAT:i.textureHalfFloat&&i.textureHalfFloatLinearFiltering&&(o=P.Y.TEXTURETYPE_HALF_FLOAT),n._features.allowTexturePrefiltering&&this._prefilterOnLoad){var a=this._onLoad,s=new ph(n);this._onLoad=function(){s.prefilter(e,a)}}this._texture=n.createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,P.Y.TEXTUREFORMAT_RGB,o,this._noMipmap,function(l){e.lodGenerationOffset=0,e.lodGenerationScale=.8;var c=(0,Pv.VH)(l,e._size,e._supersample);if(e._generateHarmonics){var u=Av.d.ConvertCubeMapToSphericalPolynomial(c);e.sphericalPolynomial=u}for(var d=[],h=null,p=null,m=0;m<6;m++){o===P.Y.TEXTURETYPE_HALF_FLOAT?p=new Uint16Array(e._size*e._size*3):o===P.Y.TEXTURETYPE_UNSIGNED_BYTE&&(h=new Uint8Array(e._size*e._size*3));var v=c[t._FacesMapping[m]];if(e.gammaSpace||p||h){for(var b=0;b<e._size*e._size;b++)if(e.gammaSpace&&(v[3*b+0]=Math.pow(v[3*b+0],pt.rv),v[3*b+1]=Math.pow(v[3*b+1],pt.rv),v[3*b+2]=Math.pow(v[3*b+2],pt.rv)),p&&(p[3*b+0]=(0,Si.LZ)(v[3*b+0]),p[3*b+1]=(0,Si.LZ)(v[3*b+1]),p[3*b+2]=(0,Si.LZ)(v[3*b+2])),h){var E=Math.max(255*v[3*b+0],0),C=Math.max(255*v[3*b+1],0),T=Math.max(255*v[3*b+2],0),f=Math.max(Math.max(E,C),T);if(f>255){var g=255/f;E*=g,C*=g,T*=g}h[3*b+0]=E,h[3*b+1]=C,h[3*b+2]=T}}p?d.push(p):h?d.push(h):d.push(v)}return d},null,this._onLoad,this._onError)},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e},t.prototype.delayLoad=function(){this.delayLoadState===P.Y.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=P.Y.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this._loadTexture())},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var n,i=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&((n=this.getScene())===null||n===void 0||n.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(o){return o.getActiveTextures().indexOf(i)!==-1}))},t.prototype.dispose=function(){this.onLoadObservable.clear(),r.prototype.dispose.call(this)},t.Parse=function(e,n,i){var o=null;return e.name&&!e.isRenderTarget&&((o=new t(i+e.name,n,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,o.hasAlpha=e.hasAlpha,o.level=e.level,o.coordinatesMode=e.coordinatesMode,o.isBlocking=e.isBlocking),o&&(e.boundingBoxPosition&&(o.boundingBoxPosition=_.Pq.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(o.boundingBoxSize=_.Pq.FromArray(e.boundingBoxSize)),e.rotationY&&(o.rotationY=e.rotationY)),o},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this.gammaSpace,e.generateHarmonics=this._generateHarmonics,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e.rotationY=this._rotationY,e},t._FacesMapping=["right","left","up","down","front","back"],t}(Ki.t);(0,j.Y5)("BABYLON.HDRCubeTexture",bl);var Cv=function(){function r(t,e,n){e===void 0&&(e=0),n===void 0&&(n=null),this.name=t,this.animations=[],this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new K.cP,this._onDataLayoutChanged=new K.cP,this._animationPropertiesOverride=null,this._scene=n||Ve.q.LastCreatedScene,this.influence=e,this._scene&&(this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(r.prototype,"influence",{get:function(){return this._influence},set:function(t){if(this._influence!==t){var e=this._influence;this._influence=t,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(e===0||t===0)}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animationPropertiesOverride",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(t){this._animationPropertiesOverride=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasUVs",{get:function(){return!!this._uvs},enumerable:!1,configurable:!0}),r.prototype.setPositions=function(t){var e=this.hasPositions;this._positions=t,e!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},r.prototype.getPositions=function(){return this._positions},r.prototype.setNormals=function(t){var e=this.hasNormals;this._normals=t,e!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},r.prototype.getNormals=function(){return this._normals},r.prototype.setTangents=function(t){var e=this.hasTangents;this._tangents=t,e!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},r.prototype.getTangents=function(){return this._tangents},r.prototype.setUVs=function(t){var e=this.hasUVs;this._uvs=t,e!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)},r.prototype.getUVs=function(){return this._uvs},r.prototype.clone=function(){var t=this,e=tt.p.Clone(function(){return new r(t.name,t.influence,t._scene)},this);return e._positions=this._positions,e._normals=this._normals,e._tangents=this._tangents,e._uvs=this._uvs,e},r.prototype.serialize=function(){var t={};return t.name=this.name,t.influence=this.influence,t.positions=Array.prototype.slice.call(this.getPositions()),this.id!=null&&(t.id=this.id),this.hasNormals&&(t.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(t.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(t.uvs=Array.prototype.slice.call(this.getUVs())),tt.p.AppendSerializedAnimations(this,t),t},r.prototype.getClassName=function(){return"MorphTarget"},r.Parse=function(t,e){var n=new r(t.name,t.influence);if(n.setPositions(t.positions),t.id!=null&&(n.id=t.id),t.normals&&n.setNormals(t.normals),t.tangents&&n.setTangents(t.tangents),t.uvs&&n.setUVs(t.uvs),t.animations){for(var i=0;i<t.animations.length;i++){var o=t.animations[i],a=(0,j.n9)("BABYLON.Animation");a&&n.animations.push(a.Parse(o))}t.autoAnimate&&e&&e.beginAnimation(n,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1)}return n},r.FromMesh=function(t,e,n){e||(e=t.name);var i=new r(e,n,t.getScene());return i.setPositions(t.getVerticesData(Y.R.PositionKind)),t.isVerticesDataPresent(Y.R.NormalKind)&&i.setNormals(t.getVerticesData(Y.R.NormalKind)),t.isVerticesDataPresent(Y.R.TangentKind)&&i.setTangents(t.getVerticesData(Y.R.TangentKind)),t.isVerticesDataPresent(Y.R.UVKind)&&i.setUVs(t.getVerticesData(Y.R.UVKind)),i},(0,A.Cg)([(0,V.lK)()],r.prototype,"id",void 0),r}(),Rv=function(r){function t(e,n,i,o,a,s,l,c,u,d,h){l===void 0&&(l=!0),c===void 0&&(c=!1),u===void 0&&(u=Ie.g.TRILINEAR_SAMPLINGMODE),d===void 0&&(d=P.Y.TEXTURETYPE_UNSIGNED_INT);var p=r.call(this,null,s,!l,c)||this;return p.format=a,p._texture=s.getEngine().createRawTexture2DArray(e,n,i,o,a,l,c,u,null,d,h),p._depth=o,p.is2DArray=!0,p}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"depth",{get:function(){return this._depth},enumerable:!1,configurable:!0}),t.prototype.update=function(e){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t.CreateRGBATexture=function(e,n,i,o,a,s,l,c,u){return s===void 0&&(s=!0),l===void 0&&(l=!1),c===void 0&&(c=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),u===void 0&&(u=P.Y.TEXTURETYPE_UNSIGNED_INT),new t(e,n,i,o,P.Y.TEXTUREFORMAT_RGBA,a,s,l,c,u)},t}(Ie.g),Tl=function(){function r(t){if(t===void 0&&(t=null),this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new er.L(16),this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this._canUseTextureForTargets=!1,this._blockCounter=0,this._textureVertexStride=0,this._textureWidth=0,this._textureHeight=1,this._parentContainer=null,this.optimizeInfluencers=!0,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,this._numMaxInfluencers=0,this._useTextureToStoreTargets=!0,t||(t=Ve.q.LastCreatedScene),this._scene=t,this._scene){this._scene.addMorphTargetManager(this),this._uniqueId=this._scene.getUniqueId();var e=this._scene.getEngine().getCaps();this._canUseTextureForTargets=e.canUseGLVertexID&&e.textureFloat&&e.maxVertexTextureImageUnits>0&&e.texture2DArrayMaxLayerCount>1}}return Object.defineProperty(r.prototype,"areUpdatesFrozen",{get:function(){return this._blockCounter>0},set:function(t){t?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(!0)))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"numMaxInfluencers",{get:function(){return this._numMaxInfluencers},set:function(t){this._numMaxInfluencers!==t&&(this._numMaxInfluencers=t,this._syncActiveTargets(!0))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"vertexCount",{get:function(){return this._vertexCount},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"supportsNormals",{get:function(){return this._supportsNormals&&this.enableNormalMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"supportsTangents",{get:function(){return this._supportsTangents&&this.enableTangentMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"supportsUVs",{get:function(){return this._supportsUVs&&this.enableUVMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"numTargets",{get:function(){return this._targets.length},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"numInfluencers",{get:function(){return this._activeTargets.length},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"influences",{get:function(){return this._influences},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useTextureToStoreTargets",{get:function(){return this._useTextureToStoreTargets},set:function(t){this._useTextureToStoreTargets=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isUsingTextureForTargets",{get:function(){var t;return r.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets&&!(!((t=this._scene)===null||t===void 0)&&t.getEngine().getCaps().disableMorphTargetTexture)},enumerable:!1,configurable:!0}),r.prototype.getActiveTarget=function(t){return this._activeTargets.data[t]},r.prototype.getTarget=function(t){return this._targets[t]},r.prototype.getTargetByName=function(t){for(var e=0,n=this._targets;e<n.length;e++){var i=n[e];if(i.name===t)return i}return null},r.prototype.addTarget=function(t){var e=this;this._targets.push(t),this._targetInfluenceChangedObservers.push(t.onInfluenceChanged.add(function(n){e._syncActiveTargets(n)})),this._targetDataLayoutChangedObservers.push(t._onDataLayoutChanged.add(function(){e._syncActiveTargets(!0)})),this._syncActiveTargets(!0)},r.prototype.removeTarget=function(t){var e=this._targets.indexOf(t);e>=0&&(this._targets.splice(e,1),t.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(e,1)[0]),t._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(e,1)[0]),this._syncActiveTargets(!0)),this._scene&&this._scene.stopAnimation(t)},r.prototype._bind=function(t){t.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),t.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),t.setTexture("morphTargets",this._targetStoreTexture),t.setInt("morphTargetCount",this.numInfluencers)},r.prototype.clone=function(){for(var t=new r(this._scene),e=0,n=this._targets;e<n.length;e++){var i=n[e];t.addTarget(i.clone())}return t.enableNormalMorphing=this.enableNormalMorphing,t.enableTangentMorphing=this.enableTangentMorphing,t.enableUVMorphing=this.enableUVMorphing,t},r.prototype.serialize=function(){var t={};t.id=this.uniqueId,t.targets=[];for(var e=0,n=this._targets;e<n.length;e++){var i=n[e];t.targets.push(i.serialize())}return t},r.prototype._syncActiveTargets=function(t){if(!this.areUpdatesFrozen){var e=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0,this._supportsUVs=!0,this._vertexCount=0,this._scene&&this._targets.length>this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount&&(this.useTextureToStoreTargets=!1),this._morphTargetTextureIndices&&this._morphTargetTextureIndices.length===this._targets.length||(this._morphTargetTextureIndices=new Float32Array(this._targets.length));for(var n=-1,i=0,o=this._targets;i<o.length;i++){var a=o[i];if(n++,a.influence!==0||!this.optimizeInfluencers){if(this._activeTargets.length>=r.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(a),this._morphTargetTextureIndices[e]=n,this._tempInfluences[e++]=a.influence,this._supportsNormals=this._supportsNormals&&a.hasNormals,this._supportsTangents=this._supportsTangents&&a.hasTangents,this._supportsUVs=this._supportsUVs&&a.hasUVs;var s=a.getPositions();if(s){var l=s.length/3;if(this._vertexCount===0)this._vertexCount=l;else if(this._vertexCount!==l)return void O.V.Error("Incompatible target. Targets must all have the same vertices count.")}}}this._morphTargetTextureIndices.length!==e&&(this._morphTargetTextureIndices=this._morphTargetTextureIndices.slice(0,e)),this._influences&&this._influences.length===e||(this._influences=new Float32Array(e));for(var c=0;c<e;c++)this._influences[c]=this._tempInfluences[c];t&&this.synchronize()}},r.prototype.synchronize=function(){if(this._scene&&!this.areUpdatesFrozen){if(this.isUsingTextureForTargets&&(this._vertexCount||this.numMaxInfluencers>0)){this._textureVertexStride=1,this._supportsNormals&&this._textureVertexStride++,this._supportsTangents&&this._textureVertexStride++,this._supportsUVs&&this._textureVertexStride++,this._textureWidth=this._vertexCount*this._textureVertexStride||1,this._textureHeight=1;var t=this._scene.getEngine().getCaps().maxTextureSize;this._textureWidth>t&&(this._textureHeight=Math.ceil(this._textureWidth/t),this._textureWidth=t);var e=!0;if(this._targetStoreTexture){var n=this._targetStoreTexture.getSize();n.width===this._textureWidth&&n.height===this._textureHeight&&this._targetStoreTexture.depth===this._targets.length&&(e=!1)}if(e){this._targetStoreTexture&&this._targetStoreTexture.dispose();for(var i=this._targets.length,o=new Float32Array(i*this._textureWidth*this._textureHeight*4),a=0,s=0;s<i;s++){var l=this._targets[s],c=l.getPositions(),u=l.getNormals(),d=l.getUVs(),h=l.getTangents();if(!c)return void(s===0&&O.V.Error("Invalid morph target. Target must have positions."));a=s*this._textureWidth*this._textureHeight*4;for(var p=0;p<this._vertexCount;p++)o[a]=c[3*p],o[a+1]=c[3*p+1],o[a+2]=c[3*p+2],a+=4,this._supportsNormals&&u&&(o[a]=u[3*p],o[a+1]=u[3*p+1],o[a+2]=u[3*p+2],a+=4),this._supportsUVs&&d&&(o[a]=d[2*p],o[a+1]=d[2*p+1],a+=4),this._supportsTangents&&h&&(o[a]=h[3*p],o[a+1]=h[3*p+1],o[a+2]=h[3*p+2],a+=4)}this._targetStoreTexture=Rv.CreateRGBATexture(o,this._textureWidth,this._textureHeight,i,this._scene,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT)}}for(var m=0,v=this._scene.meshes;m<v.length;m++){var b=v[m];b.morphTargetManager===this&&b._syncGeometryWithMorphTargetManager()}}},r.prototype.dispose=function(){if(this._targetStoreTexture&&this._targetStoreTexture.dispose(),this._targetStoreTexture=null,this._scene){if(this._scene.removeMorphTargetManager(this),this._parentContainer){var t=this._parentContainer.morphTargetManagers.indexOf(this);t>-1&&this._parentContainer.morphTargetManagers.splice(t,1),this._parentContainer=null}for(var e=0,n=this._targets;e<n.length;e++){var i=n[e];this._scene.stopAnimation(i)}}},r.Parse=function(t,e){var n=new r(e);n._uniqueId=t.id;for(var i=0,o=t.targets;i<o.length;i++){var a=o[i];n.addTarget(Cv.Parse(a,e))}return n},r.EnableTextureStorage=!0,r.MaxActiveMorphTargetsInVertexAttributeMode=8,r}(),Iv=function(){function r(){this._hasHit=!1,this._hitNormal=_.Pq.Zero(),this._hitPoint=_.Pq.Zero(),this._triangleIndex=-1}return Object.defineProperty(r.prototype,"hitPoint",{get:function(){return this._hitPoint},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hitNormal",{get:function(){return this._hitNormal},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasHit",{get:function(){return this._hasHit},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"triangleIndex",{get:function(){return this._triangleIndex},enumerable:!1,configurable:!0}),r.prototype.setHitData=function(t,e,n){this._hasHit=!0,this._hitNormal.set(t.x,t.y,t.z),this._hitPoint.set(e.x,e.y,e.z),this._triangleIndex=n??-1},r.prototype.reset=function(){this._hasHit=!1,this._hitNormal.setAll(0),this._hitPoint.setAll(0),this._triangleIndex=-1,this.body=void 0,this.bodyIndex=void 0,this.shape=void 0},r}(),us=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._hitDistance=0,e._rayFromWorld=_.Pq.Zero(),e._rayToWorld=_.Pq.Zero(),e}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hitNormalWorld",{get:function(){return this._hitNormal},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hitPointWorld",{get:function(){return this._hitPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rayFromWorld",{get:function(){return this._rayFromWorld},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rayToWorld",{get:function(){return this._rayToWorld},enumerable:!1,configurable:!0}),t.prototype.setHitDistance=function(e){this._hitDistance=e},t.prototype.calculateHitDistance=function(){this._hitDistance=_.Pq.Distance(this._rayFromWorld,this._hitPoint)},t.prototype.reset=function(e,n){e===void 0&&(e=_.Pq.Zero()),n===void 0&&(n=_.Pq.Zero()),r.prototype.reset.call(this),this._rayFromWorld.copyFrom(e),this._rayToWorld.copyFrom(n),this._hitDistance=0},t}(Iv),_h=function(){function r(t,e){if(e===void 0&&(e=r.DefaultPluginFactory()),this._physicsPlugin=e,this._impostors=[],this._joints=[],this._subTimeStep=0,this._uniqueIdCounter=0,!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new _.Pq(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return r.prototype.getPluginVersion=function(){return this._physicsPlugin.getPluginVersion()},r.DefaultPluginFactory=function(){throw(0,gt.n)("CannonJSPlugin")},r.prototype.setGravity=function(t){this.gravity=t,this._physicsPlugin.setGravity(this.gravity)},r.prototype.setTimeStep=function(t){t===void 0&&(t=1/60),this._physicsPlugin.setTimeStep(t)},r.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},r.prototype.setSubTimeStep=function(t){t===void 0&&(t=0),this._subTimeStep=t},r.prototype.getSubTimeStep=function(){return this._subTimeStep},r.prototype.dispose=function(){this._impostors.forEach(function(t){t.dispose()}),this._physicsPlugin.dispose()},r.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},r.prototype.addImpostor=function(t){this._impostors.push(t),t.uniqueId=this._uniqueIdCounter++,t.parent||this._physicsPlugin.generatePhysicsBody(t)},r.prototype.removeImpostor=function(t){var e=this._impostors.indexOf(t);e>-1&&this._impostors.splice(e,1).length&&this.getPhysicsPlugin().removePhysicsBody(t)},r.prototype.addJoint=function(t,e,n){var i={mainImpostor:t,connectedImpostor:e,joint:n};n.physicsPlugin=this._physicsPlugin,this._joints.push(i),this._physicsPlugin.generateJoint(i)},r.prototype.removeJoint=function(t,e,n){var i=this._joints.filter(function(o){return o.connectedImpostor===e&&o.joint===n&&o.mainImpostor===t});i.length&&this._physicsPlugin.removeJoint(i[0])},r.prototype._step=function(t){var e=this;this._impostors.forEach(function(n){n.isBodyInitRequired()&&e._physicsPlugin.generatePhysicsBody(n)}),t>.1?t=.1:t<=0&&(t=1/60),this._physicsPlugin.executeStep(t,this._impostors)},r.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},r.prototype.getImpostors=function(){return this._impostors},r.prototype.getImpostorForPhysicsObject=function(t){for(var e=0;e<this._impostors.length;++e)if(this._impostors[e].object===t)return this._impostors[e];return null},r.prototype.getImpostorWithPhysicsBody=function(t){for(var e=0;e<this._impostors.length;++e)if(this._impostors[e].physicsBody===t)return this._impostors[e];return null},r.prototype.raycast=function(t,e){return this._physicsPlugin.raycast(t,e)},r.prototype.raycastToRef=function(t,e,n){return this._physicsPlugin.raycastToRef(t,e,n)},r}(),Sl=function(){function r(t,e,n){t===void 0&&(t=!0),e===void 0&&(e=10),n===void 0&&(n=CANNON),this._useDeltaForWorldStep=t,this.name="CannonJSPlugin",this._physicsMaterials=new Array,this._fixedTimeStep=1/60,this._physicsBodiesToRemoveAfterStep=new Array,this._firstFrame=!0,this._tmpQuaternion=new _.PT,this._minus90X=new _.PT(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new _.PT(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=_.Pq.Zero(),this._tmpDeltaPosition=_.Pq.Zero(),this._tmpUnityRotation=new _.PT,this.BJSCANNON=n,this.isSupported()?(this._extendNamespace(),this.world=new this.BJSCANNON.World,this.world.broadphase=new this.BJSCANNON.NaiveBroadphase,this.world.solver.iterations=e,this._cannonRaycastResult=new this.BJSCANNON.RaycastResult,this._raycastResult=new us):O.V.Error("CannonJS is not available. Please make sure you included the js file.")}return r.prototype.getPluginVersion=function(){return 1},r.prototype.setGravity=function(t){var e=t;this.world.gravity.set(e.x,e.y,e.z)},r.prototype.setTimeStep=function(t){this._fixedTimeStep=t},r.prototype.getTimeStep=function(){return this._fixedTimeStep},r.prototype.executeStep=function(t,e){if(this._firstFrame){this._firstFrame=!1;for(var n=0,i=e;n<i.length;n++){var o=i[n];o.type!=Dt.HeightmapImpostor&&o.type!==Dt.PlaneImpostor&&o.beforeStep()}}this.world.step(this._useDeltaForWorldStep?t:this._fixedTimeStep),this._removeMarkedPhysicsBodiesFromWorld()},r.prototype._removeMarkedPhysicsBodiesFromWorld=function(){var t=this;this._physicsBodiesToRemoveAfterStep.length>0&&(this._physicsBodiesToRemoveAfterStep.forEach(function(e){typeof t.world.removeBody=="function"?t.world.removeBody(e):t.world.remove(e)}),this._physicsBodiesToRemoveAfterStep.length=0)},r.prototype.applyImpulse=function(t,e,n){var i=new this.BJSCANNON.Vec3(n.x,n.y,n.z),o=new this.BJSCANNON.Vec3(e.x,e.y,e.z);t.physicsBody.applyImpulse(o,i)},r.prototype.applyForce=function(t,e,n){var i=new this.BJSCANNON.Vec3(n.x,n.y,n.z),o=new this.BJSCANNON.Vec3(e.x,e.y,e.z);t.physicsBody.applyForce(o,i)},r.prototype.generatePhysicsBody=function(t){if(this._removeMarkedPhysicsBodiesFromWorld(),t.parent)t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate());else{if(t.isBodyInitRequired()){var e=this._createShape(t);if(!e)return void O.V.Warn("It was not possible to create a physics body for this object.");var n=t.physicsBody;n&&this.removePhysicsBody(t);var i=this._addMaterial("mat-"+t.uniqueId,t.getParam("friction"),t.getParam("restitution")),o={mass:t.getParam("mass"),material:i},a=t.getParam("nativeOptions");for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(o[s]=a[s]);t.physicsBody=new this.BJSCANNON.Body(o),t.physicsBody.addEventListener("collide",t.onCollide),this.world.addEventListener("preStep",t.beforeStep),this.world.addEventListener("postStep",t.afterStep),t.physicsBody.addShape(e),typeof this.world.addBody=="function"?this.world.addBody(t.physicsBody):this.world.add(t.physicsBody),n&&["force","torque","velocity","angularVelocity"].forEach(function(l){var c=n[l];t.physicsBody[l].set(c.x,c.y,c.z)}),this._processChildMeshes(t)}this._updatePhysicsBodyTransformation(t)}},r.prototype._processChildMeshes=function(t){var e=this,n=t.object.getChildMeshes?t.object.getChildMeshes(!0):[],i=t.object.rotationQuaternion;if(i?i.conjugateToRef(this._tmpQuaternion):this._tmpQuaternion.set(0,0,0,1),n.length){var o=function(a){if(a.rotationQuaternion){var s=a.getPhysicsImpostor();if(s&&s.parent!==t&&a.parent){var l=a.getAbsolutePosition().subtract(a.parent.getAbsolutePosition()),c=a.rotationQuaternion.multiply(e._tmpQuaternion);s.physicsBody&&(e.removePhysicsBody(s),s.physicsBody=null),s.parent=t,s.resetUpdateFlags(),t.physicsBody.addShape(e._createShape(s),new e.BJSCANNON.Vec3(l.x,l.y,l.z),new e.BJSCANNON.Quaternion(c.x,c.y,c.z,c.w)),t.physicsBody.mass+=s.getParam("mass")}a.getChildMeshes(!0).filter(function(u){return!!u.physicsImpostor}).forEach(o)}};n.filter(function(a){return!!a.physicsImpostor}).forEach(o)}},r.prototype.removePhysicsBody=function(t){t.physicsBody.removeEventListener("collide",t.onCollide),this.world.removeEventListener("preStep",t.beforeStep),this.world.removeEventListener("postStep",t.afterStep),this._physicsBodiesToRemoveAfterStep.indexOf(t.physicsBody)===-1&&this._physicsBodiesToRemoveAfterStep.push(t.physicsBody)},r.prototype.generateJoint=function(t){var e=t.mainImpostor.physicsBody,n=t.connectedImpostor.physicsBody;if(e&&n){var i,o=t.joint.jointData,a={pivotA:o.mainPivot?new this.BJSCANNON.Vec3().set(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z):null,pivotB:o.connectedPivot?new this.BJSCANNON.Vec3().set(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z):null,axisA:o.mainAxis?new this.BJSCANNON.Vec3().set(o.mainAxis.x,o.mainAxis.y,o.mainAxis.z):null,axisB:o.connectedAxis?new this.BJSCANNON.Vec3().set(o.connectedAxis.x,o.connectedAxis.y,o.connectedAxis.z):null,maxForce:o.nativeParams.maxForce,collideConnected:!!o.collision};switch(t.joint.type){case In.HingeJoint:case In.Hinge2Joint:i=new this.BJSCANNON.HingeConstraint(e,n,a);break;case In.DistanceJoint:i=new this.BJSCANNON.DistanceConstraint(e,n,o.maxDistance||2);break;case In.SpringJoint:var s=o;i=new this.BJSCANNON.Spring(e,n,{restLength:s.length,stiffness:s.stiffness,damping:s.damping,localAnchorA:a.pivotA,localAnchorB:a.pivotB});break;case In.LockJoint:i=new this.BJSCANNON.LockConstraint(e,n,a);break;case In.PointToPointJoint:case In.BallAndSocketJoint:default:i=new this.BJSCANNON.PointToPointConstraint(e,a.pivotA,n,a.pivotB,a.maxForce)}i.collideConnected=!!o.collision,t.joint.physicsJoint=i,t.joint.type!==In.SpringJoint?this.world.addConstraint(i):(t.joint.jointData.forceApplicationCallback=t.joint.jointData.forceApplicationCallback||function(){i.applyForce()},t.mainImpostor.registerAfterPhysicsStep(t.joint.jointData.forceApplicationCallback))}},r.prototype.removeJoint=function(t){t.joint.type!==In.SpringJoint?this.world.removeConstraint(t.joint.physicsJoint):t.mainImpostor.unregisterAfterPhysicsStep(t.joint.jointData.forceApplicationCallback)},r.prototype._addMaterial=function(t,e,n){var i,o;for(i=0;i<this._physicsMaterials.length;i++)if((o=this._physicsMaterials[i]).friction===e&&o.restitution===n)return o;var a=new this.BJSCANNON.Material(t);return a.friction=e,a.restitution=n,this._physicsMaterials.push(a),a},r.prototype._checkWithEpsilon=function(t){return t<pt.bH?pt.bH:t},r.prototype._createShape=function(t){var e,n=t.object,i=t.getObjectExtents();switch(t.type){case Dt.SphereImpostor:var o=i.x,a=i.y,s=i.z;e=new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(o),this._checkWithEpsilon(a),this._checkWithEpsilon(s))/2);break;case Dt.CylinderImpostor:var l=t.getParam("nativeOptions");l||(l={});var c=l.radiusTop!==void 0?l.radiusTop:this._checkWithEpsilon(i.x)/2,u=l.radiusBottom!==void 0?l.radiusBottom:this._checkWithEpsilon(i.x)/2,d=l.height!==void 0?l.height:this._checkWithEpsilon(i.y),h=l.numSegments!==void 0?l.numSegments:16;e=new this.BJSCANNON.Cylinder(c,u,d,h);var p=new this.BJSCANNON.Quaternion;p.setFromAxisAngle(new this.BJSCANNON.Vec3(1,0,0),-Math.PI/2);var m=new this.BJSCANNON.Vec3(0,0,0);e.transformAllPoints(m,p);break;case Dt.BoxImpostor:var v=i.scale(.5);e=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(v.x),this._checkWithEpsilon(v.y),this._checkWithEpsilon(v.z)));break;case Dt.PlaneImpostor:O.V.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),e=new this.BJSCANNON.Plane;break;case Dt.MeshImpostor:var b=n.getVerticesData?n.getVerticesData(Y.R.PositionKind):[],E=n.getIndices?n.getIndices():[];if(!b)return void O.V.Warn("Tried to create a MeshImpostor for an object without vertices. This will fail.");var C=n.position.clone(),T=n.rotation&&n.rotation.clone(),f=n.rotationQuaternion&&n.rotationQuaternion.clone();n.position.copyFromFloats(0,0,0),n.rotation&&n.rotation.copyFromFloats(0,0,0),n.rotationQuaternion&&n.rotationQuaternion.copyFrom(t.getParentsRotation()),n.rotationQuaternion&&n.parent&&n.rotationQuaternion.conjugateInPlace();var g=n.computeWorldMatrix(!0),S=[],y=void 0;for(y=0;y<b.length;y+=3)_.Pq.TransformCoordinates(_.Pq.FromArray(b,y),g).toArray(S,y);O.V.Warn("MeshImpostor only collides against spheres."),e=new this.BJSCANNON.Trimesh(S,E),n.position.copyFrom(C),T&&n.rotation&&n.rotation.copyFrom(T),f&&n.rotationQuaternion&&n.rotationQuaternion.copyFrom(f);break;case Dt.HeightmapImpostor:var x=n.position.clone(),R=n.rotation&&n.rotation.clone(),I=n.rotationQuaternion&&n.rotationQuaternion.clone();n.position.copyFromFloats(0,0,0),n.rotation&&n.rotation.copyFromFloats(0,0,0),n.rotationQuaternion&&n.rotationQuaternion.copyFrom(t.getParentsRotation()),n.rotationQuaternion&&n.parent&&n.rotationQuaternion.conjugateInPlace(),n.rotationQuaternion&&n.rotationQuaternion.multiplyInPlace(this._minus90X),e=this._createHeightmap(n),n.position.copyFrom(x),R&&n.rotation&&n.rotation.copyFrom(R),I&&n.rotationQuaternion&&n.rotationQuaternion.copyFrom(I),n.computeWorldMatrix(!0);break;case Dt.ParticleImpostor:e=new this.BJSCANNON.Particle;break;case Dt.NoImpostor:e=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0))}return e},r.prototype._createHeightmap=function(t,e){var n,i=t.getVerticesData(Y.R.PositionKind),o=t.computeWorldMatrix(!0),a=[];for(n=0;n<i.length;n+=3)_.Pq.TransformCoordinates(_.Pq.FromArray(i,n),o).toArray(a,n);i=a;for(var s=new Array,l=e||~~(Math.sqrt(i.length/3)-1),c=t.getBoundingInfo(),u=Math.min(c.boundingBox.extendSizeWorld.x,c.boundingBox.extendSizeWorld.y),d=c.boundingBox.extendSizeWorld.z,h=2*u/l,p=0;p<i.length;p+=3){var m=Math.round(i[p+0]/h+l/2),v=Math.round(-1*(i[p+1]/h-l/2)),b=-i[p+2]+d;s[m]||(s[m]=[]),s[m][v]||(s[m][v]=b),s[m][v]=Math.max(b,s[m][v])}for(m=0;m<=l;++m){if(!s[m]){for(var E=1;!s[(m+E)%l];)E++;s[m]=s[(m+E)%l].slice()}for(v=0;v<=l;++v)if(!s[m][v]){E=1;for(var C=void 0;C===void 0;)C=s[m][(v+E++)%l];s[m][v]=C}}var T=new this.BJSCANNON.Heightfield(s,{elementSize:h});return T.minY=d,T},r.prototype._updatePhysicsBodyTransformation=function(t){var e=t.object;if(e.computeWorldMatrix&&e.computeWorldMatrix(!0),e.getBoundingInfo()){var n=t.getObjectCenter();this._tmpDeltaPosition.copyFrom(e.getAbsolutePivotPoint().subtract(n)),this._tmpDeltaPosition.divideInPlace(t.object.scaling),this._tmpPosition.copyFrom(n);var i=e.rotationQuaternion;if(i){if(t.type!==Dt.PlaneImpostor&&t.type!==Dt.HeightmapImpostor||(i=i.multiply(this._minus90X),t.setDeltaRotation(this._plus90X)),t.type===Dt.HeightmapImpostor){var o=e,a=o.getBoundingInfo(),s=o.rotationQuaternion;o.rotationQuaternion=this._tmpUnityRotation,o.computeWorldMatrix(!0);var l=n.clone(),c=o.getPivotMatrix();c=c?c.clone():_.uq.Identity();var u=_.uq.Translation(a.boundingBox.extendSizeWorld.x,0,-a.boundingBox.extendSizeWorld.z);o.setPreTransformMatrix(u),o.computeWorldMatrix(!0);var d=(a=o.getBoundingInfo()).boundingBox.centerWorld.subtract(n).subtract(o.position).negate();this._tmpPosition.copyFromFloats(d.x,d.y-a.boundingBox.extendSizeWorld.y,d.z),this._tmpDeltaPosition.copyFrom(a.boundingBox.centerWorld.subtract(l)),this._tmpDeltaPosition.y+=a.boundingBox.extendSizeWorld.y,o.rotationQuaternion=s,o.setPreTransformMatrix(c),o.computeWorldMatrix(!0)}else t.type===Dt.MeshImpostor&&this._tmpDeltaPosition.copyFromFloats(0,0,0);t.setDeltaPosition(this._tmpDeltaPosition),t.physicsBody.position.set(this._tmpPosition.x,this._tmpPosition.y,this._tmpPosition.z),t.physicsBody.quaternion.set(i.x,i.y,i.z,i.w)}}},r.prototype.setTransformationFromPhysicsBody=function(t){if(t.object.position.set(t.physicsBody.position.x,t.physicsBody.position.y,t.physicsBody.position.z),t.object.rotationQuaternion){var e=t.physicsBody.quaternion;t.object.rotationQuaternion.set(e.x,e.y,e.z,e.w)}},r.prototype.setPhysicsBodyTransformation=function(t,e,n){t.physicsBody.position.set(e.x,e.y,e.z),t.physicsBody.quaternion.set(n.x,n.y,n.z,n.w)},r.prototype.isSupported=function(){return this.BJSCANNON!==void 0},r.prototype.setLinearVelocity=function(t,e){t.physicsBody.velocity.set(e.x,e.y,e.z)},r.prototype.setAngularVelocity=function(t,e){t.physicsBody.angularVelocity.set(e.x,e.y,e.z)},r.prototype.getLinearVelocity=function(t){var e=t.physicsBody.velocity;return e?new _.Pq(e.x,e.y,e.z):null},r.prototype.getAngularVelocity=function(t){var e=t.physicsBody.angularVelocity;return e?new _.Pq(e.x,e.y,e.z):null},r.prototype.setBodyMass=function(t,e){t.physicsBody.mass=e,t.physicsBody.updateMassProperties()},r.prototype.getBodyMass=function(t){return t.physicsBody.mass},r.prototype.getBodyFriction=function(t){return t.physicsBody.material.friction},r.prototype.setBodyFriction=function(t,e){t.physicsBody.material.friction=e},r.prototype.getBodyRestitution=function(t){return t.physicsBody.material.restitution},r.prototype.setBodyRestitution=function(t,e){t.physicsBody.material.restitution=e},r.prototype.sleepBody=function(t){t.physicsBody.sleep()},r.prototype.wakeUpBody=function(t){t.physicsBody.wakeUp()},r.prototype.updateDistanceJoint=function(t,e){t.physicsJoint.distance=e},r.prototype.setMotor=function(t,e,n,i){i||(t.physicsJoint.enableMotor(),t.physicsJoint.setMotorSpeed(e),n&&this.setLimit(t,n))},r.prototype.setLimit=function(t,e,n){t.physicsJoint.motorEquation.maxForce=n,t.physicsJoint.motorEquation.minForce=e===void 0?-e:e},r.prototype.syncMeshWithImpostor=function(t,e){var n=e.physicsBody;t.position.x=n.position.x,t.position.y=n.position.y,t.position.z=n.position.z,t.rotationQuaternion&&(t.rotationQuaternion.x=n.quaternion.x,t.rotationQuaternion.y=n.quaternion.y,t.rotationQuaternion.z=n.quaternion.z,t.rotationQuaternion.w=n.quaternion.w)},r.prototype.getRadius=function(t){return t.physicsBody.shapes[0].boundingSphereRadius},r.prototype.getBoxSizeToRef=function(t,e){var n=t.physicsBody.shapes[0];e.x=2*n.halfExtents.x,e.y=2*n.halfExtents.y,e.z=2*n.halfExtents.z},r.prototype.dispose=function(){},r.prototype._extendNamespace=function(){var t=new this.BJSCANNON.Vec3,e=this.BJSCANNON;this.BJSCANNON.World.prototype.step=function(n,i,o){if(o=o||10,(i=i||0)===0)this.internalStep(n),this.time+=n;else{var a=Math.floor((this.time+i)/n)-Math.floor(this.time/n);a=Math.min(a,o)||1;for(var s=performance.now(),l=0;l!==a&&(this.internalStep(n),!(performance.now()-s>1e3*n));l++);this.time+=i;for(var c=this.time%n/n,u=t,d=this.bodies,h=0;h!==d.length;h++){var p=d[h];p.type!==e.Body.STATIC&&p.sleepState!==e.Body.SLEEPING?(p.position.vsub(p.previousPosition,u),u.scale(c,u),p.position.vadd(u,p.interpolatedPosition)):(p.interpolatedPosition.set(p.position.x,p.position.y,p.position.z),p.interpolatedQuaternion.set(p.quaternion.x,p.quaternion.y,p.quaternion.z,p.quaternion.w))}}}},r.prototype.raycast=function(t,e){return this._raycastResult.reset(t,e),this.raycastToRef(t,e,this._raycastResult),this._raycastResult},r.prototype.raycastToRef=function(t,e,n){this._cannonRaycastResult.reset(),this.world.raycastClosest(t,e,{},this._cannonRaycastResult),n.reset(t,e),this._cannonRaycastResult.hasHit&&(n.setHitData({x:this._cannonRaycastResult.hitNormalWorld.x,y:this._cannonRaycastResult.hitNormalWorld.y,z:this._cannonRaycastResult.hitNormalWorld.z},{x:this._cannonRaycastResult.hitPointWorld.x,y:this._cannonRaycastResult.hitPointWorld.y,z:this._cannonRaycastResult.hitPointWorld.z}),n.setHitDistance(this._cannonRaycastResult.distance))},r}();_h.DefaultPluginFactory=function(){return new Sl};var mh=function(){function r(t,e,n){t===void 0&&(t=!0),n===void 0&&(n=OIMO),this._useDeltaForWorldStep=t,this.name="OimoJSPlugin",this._fixedTimeStep=1/60,this._tmpImpostorsArray=[],this._tmpPositionVector=_.Pq.Zero(),this.BJSOIMO=n,this.world=new this.BJSOIMO.World({iterations:e}),this.world.clear(),this._raycastResult=new us}return r.prototype.getPluginVersion=function(){return 1},r.prototype.setGravity=function(t){this.world.gravity.set(t.x,t.y,t.z)},r.prototype.setTimeStep=function(t){this.world.timeStep=t},r.prototype.getTimeStep=function(){return this.world.timeStep},r.prototype.executeStep=function(t,e){var n=this;e.forEach(function(s){s.beforeStep()}),this.world.timeStep=this._useDeltaForWorldStep?t:this._fixedTimeStep,this.world.step(),e.forEach(function(s){s.afterStep(),n._tmpImpostorsArray[s.uniqueId]=s});for(var i=this.world.contacts;i!==null;)if(!i.touching||i.body1.sleeping||i.body2.sleeping){var o=this._tmpImpostorsArray[+i.body1.name],a=this._tmpImpostorsArray[+i.body2.name];o&&a&&(o.onCollide({body:a.physicsBody,point:null,distance:0,impulse:0,normal:null}),a.onCollide({body:o.physicsBody,point:null,distance:0,impulse:0,normal:null})),i=i.next}else i=i.next},r.prototype.applyImpulse=function(t,e,n){var i=t.physicsBody.mass;t.physicsBody.applyImpulse(n.scale(this.world.invScale),e.scale(this.world.invScale*i))},r.prototype.applyForce=function(t,e,n){O.V.Warn("Oimo doesn't support applying force. Using impulse instead."),this.applyImpulse(t,e,n)},r.prototype.generatePhysicsBody=function(t){var e=this;if(t.parent)t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate());else{if(t.isBodyInitRequired()){var n={name:t.uniqueId,config:[t.getParam("mass")||.001,t.getParam("friction"),t.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:t.getParam("mass")!==0,density:t.getParam("mass"),friction:t.getParam("friction"),restitution:t.getParam("restitution"),world:this.world},i=[t];(s=t.object).getChildMeshes&&s.getChildMeshes().forEach(function(l){l.physicsImpostor&&i.push(l.physicsImpostor)});var o=function(l){return Math.max(l,pt.bH)},a=new _.PT;i.forEach(function(l){if(l.object.rotationQuaternion){var c=l.object.rotationQuaternion;a.copyFrom(c),l.object.rotationQuaternion.set(0,0,0,1),l.object.computeWorldMatrix(!0);var u=a.toEulerAngles(),d=l.getObjectExtents(),h=57.29577951308232;if(l===t){var p=t.getObjectCenter();t.object.getAbsolutePivotPoint().subtractToRef(p,e._tmpPositionVector),e._tmpPositionVector.divideInPlace(t.object.scaling),n.pos.push(p.x),n.pos.push(p.y),n.pos.push(p.z),n.posShape.push(0,0,0),n.rotShape.push(0,0,0)}else{var m=l.object.position.clone();n.posShape.push(m.x),n.posShape.push(m.y),n.posShape.push(m.z),n.rotShape.push(u.x*h,u.y*h,u.z*h)}switch(l.object.rotationQuaternion.copyFrom(a),l.type){case Dt.ParticleImpostor:O.V.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case Dt.SphereImpostor:var v=d.x,b=d.y,E=d.z,C=Math.max(o(v),o(b),o(E))/2;n.type.push("sphere"),n.size.push(C),n.size.push(C),n.size.push(C);break;case Dt.CylinderImpostor:var T=o(d.x)/2,f=o(d.y);n.type.push("cylinder"),n.size.push(T),n.size.push(f),n.size.push(f);break;case Dt.PlaneImpostor:case Dt.BoxImpostor:default:T=o(d.x),f=o(d.y);var g=o(d.z);n.type.push("box"),n.size.push(T),n.size.push(f),n.size.push(g)}l.object.rotationQuaternion=c}}),t.physicsBody=this.world.add(n),t.physicsBody.resetQuaternion(a),t.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var s;t.setDeltaPosition(this._tmpPositionVector)}},r.prototype.removePhysicsBody=function(t){this.world.removeRigidBody(t.physicsBody)},r.prototype.generateJoint=function(t){var e=t.mainImpostor.physicsBody,n=t.connectedImpostor.physicsBody;if(e&&n){var i,o=t.joint.jointData,a=o.nativeParams||{},s={body1:e,body2:n,axe1:a.axe1||(o.mainAxis?o.mainAxis.asArray():null),axe2:a.axe2||(o.connectedAxis?o.connectedAxis.asArray():null),pos1:a.pos1||(o.mainPivot?o.mainPivot.asArray():null),pos2:a.pos2||(o.connectedPivot?o.connectedPivot.asArray():null),min:a.min,max:a.max,collision:a.collision||o.collision,spring:a.spring,world:this.world};switch(t.joint.type){case In.BallAndSocketJoint:i="jointBall";break;case In.SpringJoint:O.V.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var l=o;s.min=l.length||s.min,s.max=Math.max(s.min,s.max);case In.DistanceJoint:i="jointDistance",s.max=o.maxDistance;break;case In.PrismaticJoint:i="jointPrisme";break;case In.SliderJoint:i="jointSlide";break;case In.WheelJoint:i="jointWheel";break;case In.HingeJoint:default:i="jointHinge"}s.type=i,t.joint.physicsJoint=this.world.add(s)}},r.prototype.removeJoint=function(t){try{this.world.removeJoint(t.joint.physicsJoint)}catch(e){O.V.Warn(e)}},r.prototype.isSupported=function(){return this.BJSOIMO!==void 0},r.prototype.setTransformationFromPhysicsBody=function(t){if(!t.physicsBody.sleeping){if(t.physicsBody.shapes.next){for(var e=t.physicsBody.shapes;e.next;)e=e.next;t.object.position.set(e.position.x,e.position.y,e.position.z)}else{var n=t.physicsBody.getPosition();t.object.position.set(n.x,n.y,n.z)}if(t.object.rotationQuaternion){var i=t.physicsBody.getQuaternion();t.object.rotationQuaternion.set(i.x,i.y,i.z,i.w)}}},r.prototype.setPhysicsBodyTransformation=function(t,e,n){var i=t.physicsBody;t.physicsBody.shapes.next||(i.position.set(e.x,e.y,e.z),i.orientation.set(n.x,n.y,n.z,n.w),i.syncShapes(),i.awake())},r.prototype.setLinearVelocity=function(t,e){t.physicsBody.linearVelocity.set(e.x,e.y,e.z)},r.prototype.setAngularVelocity=function(t,e){t.physicsBody.angularVelocity.set(e.x,e.y,e.z)},r.prototype.getLinearVelocity=function(t){var e=t.physicsBody.linearVelocity;return e?new _.Pq(e.x,e.y,e.z):null},r.prototype.getAngularVelocity=function(t){var e=t.physicsBody.angularVelocity;return e?new _.Pq(e.x,e.y,e.z):null},r.prototype.setBodyMass=function(t,e){var n=e===0;t.physicsBody.shapes.density=n?1:e,t.physicsBody.setupMass(n?2:1)},r.prototype.getBodyMass=function(t){return t.physicsBody.shapes.density},r.prototype.getBodyFriction=function(t){return t.physicsBody.shapes.friction},r.prototype.setBodyFriction=function(t,e){t.physicsBody.shapes.friction=e},r.prototype.getBodyRestitution=function(t){return t.physicsBody.shapes.restitution},r.prototype.setBodyRestitution=function(t,e){t.physicsBody.shapes.restitution=e},r.prototype.sleepBody=function(t){t.physicsBody.sleep()},r.prototype.wakeUpBody=function(t){t.physicsBody.awake()},r.prototype.updateDistanceJoint=function(t,e,n){t.physicsJoint.limitMotor.upperLimit=e,n!==void 0&&(t.physicsJoint.limitMotor.lowerLimit=n)},r.prototype.setMotor=function(t,e,n,i){n!==void 0?O.V.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter"):n=1e6,e*=-1;var o=i?t.physicsJoint.rotationalLimitMotor2:t.physicsJoint.rotationalLimitMotor1||t.physicsJoint.rotationalLimitMotor||t.physicsJoint.limitMotor;o&&o.setMotor(e,n)},r.prototype.setLimit=function(t,e,n,i){var o=i?t.physicsJoint.rotationalLimitMotor2:t.physicsJoint.rotationalLimitMotor1||t.physicsJoint.rotationalLimitMotor||t.physicsJoint.limitMotor;o&&o.setLimit(e,n===void 0?-e:n)},r.prototype.syncMeshWithImpostor=function(t,e){var n=e.physicsBody;t.position.x=n.position.x,t.position.y=n.position.y,t.position.z=n.position.z,t.rotationQuaternion&&(t.rotationQuaternion.x=n.orientation.x,t.rotationQuaternion.y=n.orientation.y,t.rotationQuaternion.z=n.orientation.z,t.rotationQuaternion.w=n.orientation.w)},r.prototype.getRadius=function(t){return t.physicsBody.shapes.radius},r.prototype.getBoxSizeToRef=function(t,e){var n=t.physicsBody.shapes;e.x=2*n.halfWidth,e.y=2*n.halfHeight,e.z=2*n.halfDepth},r.prototype.dispose=function(){this.world.clear()},r.prototype.raycast=function(t,e){return O.V.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(t,e),this._raycastResult},r.prototype.raycastToRef=function(t,e,n){O.V.Warn("raycast is not currently supported by the Oimo physics plugin"),n.reset(t,e)},r}(),gh=function(){function r(t,e,n){t===void 0&&(t=!0),e===void 0&&(e=Ammo),n===void 0&&(n=null);var i=this;this._useDeltaForWorldStep=t,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new _.PT,this._tmpContactCallbackResult=!1,this._tmpContactPoint=new _.Pq,this._tmpContactNormal=new _.Pq,this._tmpVec3=new _.Pq,this._tmpMatrix=new _.uq,typeof e!="function"?(this.bjsAMMO=e,this.isSupported()?(this._collisionConfiguration=new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,this._dispatcher=new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),this._overlappingPairCache=n||new this.bjsAMMO.btDbvtBroadphase,this._solver=new this.bjsAMMO.btSequentialImpulseConstraintSolver,this._softBodySolver=new this.bjsAMMO.btDefaultSoftBodySolver,this.world=new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration,this._softBodySolver),this._tmpAmmoConcreteContactResultCallback=new this.bjsAMMO.ConcreteContactResultCallback,this._tmpAmmoConcreteContactResultCallback.addSingleResult=function(o){var a=(o=i.bjsAMMO.wrapPointer(o,i.bjsAMMO.btManifoldPoint)).getPositionWorldOnA(),s=o.m_normalWorldOnB;i._tmpContactPoint.x=a.x(),i._tmpContactPoint.y=a.y(),i._tmpContactPoint.z=a.z(),i._tmpContactNormal.x=s.x(),i._tmpContactNormal.y=s.y(),i._tmpContactNormal.z=s.z(),i._tmpContactImpulse=o.getAppliedImpulse(),i._tmpContactDistance=o.getDistance(),i._tmpContactCallbackResult=!0},this._raycastResult=new us,this._tmpAmmoTransform=new this.bjsAMMO.btTransform,this._tmpAmmoTransform.setIdentity(),this._tmpAmmoQuaternion=new this.bjsAMMO.btQuaternion(0,0,0,1),this._tmpAmmoVectorA=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorB=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorC=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorD=new this.bjsAMMO.btVector3(0,0,0)):O.V.Error("AmmoJS is not available. Please make sure you included the js file.")):O.V.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.")}return r.prototype.getPluginVersion=function(){return 1},r.prototype.setGravity=function(t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),this.world.setGravity(this._tmpAmmoVectorA),this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)},r.prototype.setTimeStep=function(t){this._timeStep=t},r.prototype.setFixedTimeStep=function(t){this._fixedTimeStep=t},r.prototype.setMaxSteps=function(t){this._maxSteps=t},r.prototype.getTimeStep=function(){return this._timeStep},r.prototype._isImpostorInContact=function(t){return this._tmpContactCallbackResult=!1,this.world.contactTest(t.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},r.prototype._isImpostorPairInContact=function(t,e){return this._tmpContactCallbackResult=!1,this.world.contactPairTest(t.physicsBody,e.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},r.prototype._stepSimulation=function(t,e,n){if(t===void 0&&(t=1/60),e===void 0&&(e=10),n===void 0&&(n=1/60),e==0)this.world.stepSimulation(t,0);else for(;e>0&&t>0;)t-n<n?(this.world.stepSimulation(t,0),t=0):(t-=n,this.world.stepSimulation(n,0)),e--},r.prototype.executeStep=function(t,e){for(var n=0,i=e;n<i.length;n++){var o=i[n];o.soft||o.beforeStep()}this._stepSimulation(this._useDeltaForWorldStep?t:this._timeStep,this._maxSteps,this._fixedTimeStep);for(var a=0,s=e;a<s.length;a++){var l=s[a];if(l.soft?this._afterSoftStep(l):l.afterStep(),l._onPhysicsCollideCallbacks.length>0&&this._isImpostorInContact(l))for(var c=0,u=l._onPhysicsCollideCallbacks;c<u.length;c++)for(var d=0,h=u[c].otherImpostors;d<h.length;d++){var p=h[d];(l.physicsBody.isActive()||p.physicsBody.isActive())&&this._isImpostorPairInContact(l,p)&&(l.onCollide({body:p.physicsBody,point:this._tmpContactPoint,distance:this._tmpContactDistance,impulse:this._tmpContactImpulse,normal:this._tmpContactNormal}),p.onCollide({body:l.physicsBody,point:this._tmpContactPoint,distance:this._tmpContactDistance,impulse:this._tmpContactImpulse,normal:this._tmpContactNormal}))}}},r.prototype._afterSoftStep=function(t){t.type===Dt.RopeImpostor?this._ropeStep(t):this._softbodyOrClothStep(t)},r.prototype._ropeStep=function(t){for(var e,n,i,o,a=t.physicsBody.get_m_nodes(),s=a.size(),l=new Array,c=0;c<s;c++)n=(e=a.at(c).get_m_x()).x(),i=e.y(),o=e.z(),l.push(new _.Pq(n,i,o));var u=t.object,d=t.getParam("shape");t._isFromLine?t.object=dn("lines",{points:l,instance:u}):t.object=Va("ext",{shape:d,path:l,instance:u})},r.prototype._softbodyOrClothStep=function(t){var e=t.type===Dt.ClothImpostor?1:-1,n=t.object,i=n.getVerticesData(Y.R.PositionKind);i||(i=[]);var o=n.getVerticesData(Y.R.NormalKind);o||(o=[]);for(var a,s,l,c,u,d,h,p,m=i.length/3,v=t.physicsBody.get_m_nodes(),b=0;b<m;b++){l=(s=(a=v.at(b)).get_m_x()).x(),c=s.y(),u=s.z()*e;var E=a.get_m_n();d=E.x(),h=E.y(),p=E.z()*e,i[3*b]=l,i[3*b+1]=c,i[3*b+2]=u,o[3*b]=d,o[3*b+1]=h,o[3*b+2]=p}var C=new rt;C.positions=i,C.normals=o,C.uvs=n.getVerticesData(Y.R.UVKind),C.colors=n.getVerticesData(Y.R.ColorKind),n&&n.getIndices&&(C.indices=n.getIndices()),C.applyToMesh(n)},r.prototype.applyImpulse=function(t,e,n){if(t.soft)O.V.Warn("Cannot be applied to a soft body");else{t.physicsBody.activate();var i=this._tmpAmmoVectorA,o=this._tmpAmmoVectorB;t.object&&t.object.getWorldMatrix&&n.subtractInPlace(t.object.getWorldMatrix().getTranslation()),i.setValue(n.x,n.y,n.z),o.setValue(e.x,e.y,e.z),t.physicsBody.applyImpulse(o,i)}},r.prototype.applyForce=function(t,e,n){if(t.soft)O.V.Warn("Cannot be applied to a soft body");else{t.physicsBody.activate();var i=this._tmpAmmoVectorA,o=this._tmpAmmoVectorB;if(t.object&&t.object.getWorldMatrix){var a=t.object.getWorldMatrix().getTranslation();i.setValue(n.x-a.x,n.y-a.y,n.z-a.z)}else i.setValue(n.x,n.y,n.z);o.setValue(e.x,e.y,e.z),t.physicsBody.applyForce(o,i)}},r.prototype.generatePhysicsBody=function(t){if(t._pluginData.toDispose=[],t.parent)t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate());else if(t.isBodyInitRequired()){var e=this._createShape(t),n=t.getParam("mass");if(t._pluginData.mass=n,t.soft)e.get_m_cfg().set_collisions(17),e.get_m_cfg().set_kDP(t.getParam("damping")),this.bjsAMMO.castObject(e,this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")),e.setActivationState(r._DISABLE_DEACTIVATION_FLAG),this.world.addSoftBody(e,1,-1),t.physicsBody=e,t._pluginData.toDispose.push(e),this.setBodyPressure(t,0),t.type===Dt.SoftbodyImpostor&&this.setBodyPressure(t,t.getParam("pressure")),this.setBodyStiffness(t,t.getParam("stiffness")),this.setBodyVelocityIterations(t,t.getParam("velocityIterations")),this.setBodyPositionIterations(t,t.getParam("positionIterations"));else{var i=new this.bjsAMMO.btVector3(0,0,0),o=new this.bjsAMMO.btTransform;t.object.computeWorldMatrix(!0),o.setIdentity(),n!==0&&e.calculateLocalInertia(n,i),this._tmpAmmoVectorA.setValue(t.object.position.x,t.object.position.y,t.object.position.z),this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x,t.object.rotationQuaternion.y,t.object.rotationQuaternion.z,t.object.rotationQuaternion.w),o.setOrigin(this._tmpAmmoVectorA),o.setRotation(this._tmpAmmoQuaternion);var a=new this.bjsAMMO.btDefaultMotionState(o),s=new this.bjsAMMO.btRigidBodyConstructionInfo(n,a,e,i),l=new this.bjsAMMO.btRigidBody(s);if(n===0&&(l.setCollisionFlags(l.getCollisionFlags()|r._KINEMATIC_FLAG),l.setActivationState(r._DISABLE_DEACTIVATION_FLAG)),t.type!=Dt.NoImpostor||e.getChildShape||l.setCollisionFlags(l.getCollisionFlags()|r._DISABLE_COLLISION_FLAG),t.type!==Dt.MeshImpostor&&t.type!==Dt.NoImpostor){var c=t.object.getBoundingInfo();this._tmpVec3.copyFrom(t.object.getAbsolutePosition()),this._tmpVec3.subtractInPlace(c.boundingBox.centerWorld),this._tmpVec3.x/=t.object.scaling.x,this._tmpVec3.y/=t.object.scaling.y,this._tmpVec3.z/=t.object.scaling.z,t.setDeltaPosition(this._tmpVec3)}var u=t.getParam("group"),d=t.getParam("mask");u&&d?this.world.addRigidBody(l,u,d):this.world.addRigidBody(l),t.physicsBody=l,t._pluginData.toDispose=t._pluginData.toDispose.concat([l,s,a,o,i,e])}this.setBodyRestitution(t,t.getParam("restitution")),this.setBodyFriction(t,t.getParam("friction"))}},r.prototype.removePhysicsBody=function(t){var e=this;this.world&&(t.soft?this.world.removeSoftBody(t.physicsBody):this.world.removeRigidBody(t.physicsBody),t._pluginData&&(t._pluginData.toDispose.forEach(function(n){e.bjsAMMO.destroy(n)}),t._pluginData.toDispose=[]))},r.prototype.generateJoint=function(t){var e=t.mainImpostor.physicsBody,n=t.connectedImpostor.physicsBody;if(e&&n&&!t.joint.physicsJoint){var i,o=t.joint.jointData;switch(o.mainPivot||(o.mainPivot=new _.Pq(0,0,0)),o.connectedPivot||(o.connectedPivot=new _.Pq(0,0,0)),t.joint.type){case In.DistanceJoint:var a=o.maxDistance;a&&(o.mainPivot=new _.Pq(0,-a/2,0),o.connectedPivot=new _.Pq(0,a/2,0)),(c=this._tmpAmmoVectorA).setValue(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),(u=this._tmpAmmoVectorB).setValue(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z),i=new this.bjsAMMO.btPoint2PointConstraint(e,n,c,u);break;case In.HingeJoint:o.mainAxis||(o.mainAxis=new _.Pq(0,0,0)),o.connectedAxis||(o.connectedAxis=new _.Pq(0,0,0)),(c=this._tmpAmmoVectorA).setValue(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),(u=this._tmpAmmoVectorB).setValue(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z);var s=this._tmpAmmoVectorC;s.setValue(o.mainAxis.x,o.mainAxis.y,o.mainAxis.z);var l=this._tmpAmmoVectorD;l.setValue(o.connectedAxis.x,o.connectedAxis.y,o.connectedAxis.z),i=new this.bjsAMMO.btHingeConstraint(e,n,c,u,s,l);break;case In.BallAndSocketJoint:(c=this._tmpAmmoVectorA).setValue(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),(u=this._tmpAmmoVectorB).setValue(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z),i=new this.bjsAMMO.btPoint2PointConstraint(e,n,c,u);break;default:var c,u;O.V.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),(c=this._tmpAmmoVectorA).setValue(o.mainPivot.x,o.mainPivot.y,o.mainPivot.z),(u=this._tmpAmmoVectorB).setValue(o.connectedPivot.x,o.connectedPivot.y,o.connectedPivot.z),i=new this.bjsAMMO.btPoint2PointConstraint(e,n,c,u)}this.world.addConstraint(i,!t.joint.jointData.collision),t.joint.physicsJoint=i}},r.prototype.removeJoint=function(t){this.world&&this.world.removeConstraint(t.joint.physicsJoint),this.bjsAMMO.destroy(t.joint.physicsJoint)},r.prototype._addMeshVerts=function(t,e,n){var i=this,o=0;if(n&&n.getIndices&&n.getWorldMatrix&&n.getChildMeshes){var a=n.getIndices();a||(a=[]);var s=n.getVerticesData(Y.R.PositionKind);s||(s=[]);var l=void 0;if(e&&e!==n){var c;c=e.rotationQuaternion?e.rotationQuaternion:e.rotation?_.PT.FromEulerAngles(e.rotation.x,e.rotation.y,e.rotation.z):_.PT.Identity(),_.uq.Compose(_.Pq.One(),c,e.position).invertToRef(this._tmpMatrix),l=n.computeWorldMatrix(!1).multiply(this._tmpMatrix)}else _.uq.ScalingToRef(n.scaling.x,n.scaling.y,n.scaling.z,this._tmpMatrix),l=this._tmpMatrix;for(var u=a.length/3,d=0;d<u;d++){for(var h=[],p=0;p<3;p++){var m=new _.Pq(s[3*a[3*d+p]+0],s[3*a[3*d+p]+1],s[3*a[3*d+p]+2]);m=_.Pq.TransformCoordinates(m,l);var v=void 0;(v=p==0?this._tmpAmmoVectorA:p==1?this._tmpAmmoVectorB:this._tmpAmmoVectorC).setValue(m.x,m.y,m.z),h.push(v)}t.addTriangle(h[0],h[1],h[2]),o++}n.getChildMeshes().forEach(function(b){o+=i._addMeshVerts(t,e,b)})}return o},r.prototype._softVertexData=function(t){var e=t.object;if(e&&e.getIndices&&e.getWorldMatrix&&e.getChildMeshes){e.getIndices();var n=e.getVerticesData(Y.R.PositionKind);n||(n=[]);var i=e.getVerticesData(Y.R.NormalKind);i||(i=[]),e.computeWorldMatrix(!1);for(var o=[],a=[],s=0;s<n.length;s+=3){var l=new _.Pq(n[s],n[s+1],n[s+2]),c=new _.Pq(i[s],i[s+1],i[s+2]);l=_.Pq.TransformCoordinates(l,e.getWorldMatrix()),c=_.Pq.TransformNormal(c,e.getWorldMatrix()),o.push(l.x,l.y,l.z),a.push(c.x,c.y,c.z)}var u=new rt;return u.positions=o,u.normals=a,u.uvs=e.getVerticesData(Y.R.UVKind),u.colors=e.getVerticesData(Y.R.ColorKind),e&&e.getIndices&&(u.indices=e.getIndices()),u.applyToMesh(e),e.position=_.Pq.Zero(),e.rotationQuaternion=null,e.rotation=_.Pq.Zero(),e.computeWorldMatrix(!0),u}return rt.ExtractFromMesh(e)},r.prototype._createSoftbody=function(t){var e=t.object;if(e&&e.getIndices){var n=e.getIndices();n||(n=[]);var i=this._softVertexData(t),o=i.positions,a=i.normals;if(o===null||a===null)return new this.bjsAMMO.btCompoundShape;for(var s=[],l=[],c=0;c<o.length;c+=3){var u=new _.Pq(o[c],o[c+1],o[c+2]),d=new _.Pq(a[c],a[c+1],a[c+2]);s.push(u.x,u.y,-u.z),l.push(d.x,d.y,-d.z)}var h=new this.bjsAMMO.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(),s,e.getIndices(),n.length/3,!0),p=o.length/3,m=h.get_m_nodes(),v=void 0;for(c=0;c<p;c++)(v=m.at(c).get_m_n()).setX(l[3*c]),v.setY(l[3*c+1]),v.setZ(l[3*c+2]);return h}},r.prototype._createCloth=function(t){var e=t.object;if(e&&e.getIndices){e.getIndices();var n=this._softVertexData(t),i=n.positions,o=n.normals;if(i===null||o===null)return new this.bjsAMMO.btCompoundShape;var a=i.length,s=Math.sqrt(a/3);t.segments=s;var l=s-1;return this._tmpAmmoVectorA.setValue(i[0],i[1],i[2]),this._tmpAmmoVectorB.setValue(i[3*l],i[3*l+1],i[3*l+2]),this._tmpAmmoVectorD.setValue(i[a-3],i[a-2],i[a-1]),this._tmpAmmoVectorC.setValue(i[a-3-3*l],i[a-2-3*l],i[a-1-3*l]),new this.bjsAMMO.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,this._tmpAmmoVectorC,this._tmpAmmoVectorD,s,s,t.getParam("fixedPoints"),!0)}},r.prototype._createRope=function(t){var e,n,i=this._softVertexData(t),o=i.positions,a=i.normals;if(o===null||a===null)return new this.bjsAMMO.btCompoundShape;if(i.applyToMesh(t.object,!0),t._isFromLine=!0,a.map(function(u){return u*u}).reduce(function(u,d){return u+d})===0)n=(e=o.length)/3-1,this._tmpAmmoVectorA.setValue(o[0],o[1],o[2]),this._tmpAmmoVectorB.setValue(o[e-3],o[e-2],o[e-1]);else{t._isFromLine=!1;var s=t.getParam("path");if(t.getParam("shape")===null)return O.V.Warn("No shape available for extruded mesh"),new this.bjsAMMO.btCompoundShape;n=(e=s.length)-1,this._tmpAmmoVectorA.setValue(s[0].x,s[0].y,s[0].z),this._tmpAmmoVectorB.setValue(s[e-1].x,s[e-1].y,s[e-1].z)}t.segments=n;var l=t.getParam("fixedPoints");l=l>3?3:l;var c=new this.bjsAMMO.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,n-1,l);return c.get_m_cfg().set_collisions(17),c},r.prototype._createCustom=function(t){var e=null;return this.onCreateCustomShape&&(e=this.onCreateCustomShape(t)),e==null&&(e=new this.bjsAMMO.btCompoundShape),e},r.prototype._addHullVerts=function(t,e,n){var i=this,o=0;if(n&&n.getIndices&&n.getWorldMatrix&&n.getChildMeshes){var a=n.getIndices();a||(a=[]);var s=n.getVerticesData(Y.R.PositionKind);s||(s=[]),n.computeWorldMatrix(!1);for(var l=a.length/3,c=0;c<l;c++){for(var u=[],d=0;d<3;d++){var h=new _.Pq(s[3*a[3*c+d]+0],s[3*a[3*c+d]+1],s[3*a[3*c+d]+2]);_.uq.ScalingToRef(n.scaling.x,n.scaling.y,n.scaling.z,this._tmpMatrix),h=_.Pq.TransformCoordinates(h,this._tmpMatrix);var p=void 0;(p=d==0?this._tmpAmmoVectorA:d==1?this._tmpAmmoVectorB:this._tmpAmmoVectorC).setValue(h.x,h.y,h.z),u.push(p)}t.addPoint(u[0],!0),t.addPoint(u[1],!0),t.addPoint(u[2],!0),o++}n.getChildMeshes().forEach(function(m){o+=i._addHullVerts(t,e,m)})}return o},r.prototype._createShape=function(t,e){var n=this;e===void 0&&(e=!1);var i,o=t.object,a=t.getObjectExtents();if(!e){var s=t.object.getChildMeshes?t.object.getChildMeshes(!0):[];i=new this.bjsAMMO.btCompoundShape;var l=0;if(s.forEach(function(v){var b=v.getPhysicsImpostor();if(b){if(b.type==Dt.MeshImpostor)throw"A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";var E=n._createShape(b),C=v.parent.getWorldMatrix().clone(),T=new _.Pq;C.decompose(T),n._tmpAmmoTransform.getOrigin().setValue(v.position.x*T.x,v.position.y*T.y,v.position.z*T.z),n._tmpAmmoQuaternion.setValue(v.rotationQuaternion.x,v.rotationQuaternion.y,v.rotationQuaternion.z,v.rotationQuaternion.w),n._tmpAmmoTransform.setRotation(n._tmpAmmoQuaternion),i.addChildShape(n._tmpAmmoTransform,E),b.dispose(),l++}}),l>0){if(t.type!=Dt.NoImpostor){var c=this._createShape(t,!0);c&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),i.addChildShape(this._tmpAmmoTransform,c))}return i}this.bjsAMMO.destroy(i),i=null}switch(t.type){case Dt.SphereImpostor:if((0,qe.WithinEpsilon)(a.x,a.y,1e-4)&&(0,qe.WithinEpsilon)(a.x,a.z,1e-4))i=new this.bjsAMMO.btSphereShape(a.x/2);else{this._tmpAmmoVectorA.setValue(0,0,0);var u=[this._tmpAmmoVectorA];i=new this.bjsAMMO.btMultiSphereShape(u,[1],1),this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i.setLocalScaling(this._tmpAmmoVectorA)}break;case Dt.CapsuleImpostor:var d=a.x/2;i=new this.bjsAMMO.btCapsuleShape(d,a.y-2*d);break;case Dt.CylinderImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case Dt.PlaneImpostor:case Dt.BoxImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case Dt.MeshImpostor:if(t.getParam("mass")==0){if(this.onCreateCustomMeshImpostor)i=this.onCreateCustomMeshImpostor(t);else{var h=new this.bjsAMMO.btTriangleMesh;t._pluginData.toDispose.push(h);var p=this._addMeshVerts(h,o,o);i=p==0?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(h)}break}case Dt.ConvexHullImpostor:if(this.onCreateCustomConvexHullImpostor)i=this.onCreateCustomConvexHullImpostor(t);else{var m=new this.bjsAMMO.btConvexHullShape;(p=this._addHullVerts(m,o,o))==0?(t._pluginData.toDispose.push(m),i=new this.bjsAMMO.btCompoundShape):i=m}break;case Dt.NoImpostor:i=new this.bjsAMMO.btSphereShape(a.x/2);break;case Dt.CustomImpostor:i=this._createCustom(t);break;case Dt.SoftbodyImpostor:i=this._createSoftbody(t);break;case Dt.ClothImpostor:i=this._createCloth(t);break;case Dt.RopeImpostor:i=this._createRope(t);break;default:O.V.Warn("The impostor type is not currently supported by the ammo plugin.")}return i},r.prototype.setTransformationFromPhysicsBody=function(t){t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),t.object.position.set(this._tmpAmmoTransform.getOrigin().x(),this._tmpAmmoTransform.getOrigin().y(),this._tmpAmmoTransform.getOrigin().z()),t.object.rotationQuaternion?t.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()):t.object.rotation&&(this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()),this._tmpQuaternion.toEulerAnglesToRef(t.object.rotation))},r.prototype.setPhysicsBodyTransformation=function(t,e,n){var i=t.physicsBody.getWorldTransform();if(Math.abs(i.getOrigin().x()-e.x)>pt.bH||Math.abs(i.getOrigin().y()-e.y)>pt.bH||Math.abs(i.getOrigin().z()-e.z)>pt.bH||Math.abs(i.getRotation().x()-n.x)>pt.bH||Math.abs(i.getRotation().y()-n.y)>pt.bH||Math.abs(i.getRotation().z()-n.z)>pt.bH||Math.abs(i.getRotation().w()-n.w)>pt.bH)if(this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),i.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(n.x,n.y,n.z,n.w),i.setRotation(this._tmpAmmoQuaternion),t.physicsBody.setWorldTransform(i),t.mass==0){var o=t.physicsBody.getMotionState();o&&o.setWorldTransform(i)}else t.physicsBody.activate()},r.prototype.isSupported=function(){return this.bjsAMMO!==void 0},r.prototype.setLinearVelocity=function(t,e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),t.soft?t.physicsBody.linearVelocity(this._tmpAmmoVectorA):t.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)},r.prototype.setAngularVelocity=function(t,e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),t.soft?t.physicsBody.angularVelocity(this._tmpAmmoVectorA):t.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)},r.prototype.getLinearVelocity=function(t){var e;if(!(e=t.soft?t.physicsBody.linearVelocity():t.physicsBody.getLinearVelocity()))return null;var n=new _.Pq(e.x(),e.y(),e.z());return this.bjsAMMO.destroy(e),n},r.prototype.getAngularVelocity=function(t){var e;if(!(e=t.soft?t.physicsBody.angularVelocity():t.physicsBody.getAngularVelocity()))return null;var n=new _.Pq(e.x(),e.y(),e.z());return this.bjsAMMO.destroy(e),n},r.prototype.setBodyMass=function(t,e){t.soft?t.physicsBody.setTotalMass(e,!1):t.physicsBody.setMassProps(e),t._pluginData.mass=e},r.prototype.getBodyMass=function(t){return t._pluginData.mass||0},r.prototype.getBodyFriction=function(t){return t._pluginData.friction||0},r.prototype.setBodyFriction=function(t,e){t.soft?t.physicsBody.get_m_cfg().set_kDF(e):t.physicsBody.setFriction(e),t._pluginData.friction=e},r.prototype.getBodyRestitution=function(t){return t._pluginData.restitution||0},r.prototype.setBodyRestitution=function(t,e){t.physicsBody.setRestitution(e),t._pluginData.restitution=e},r.prototype.getBodyPressure=function(t){return t.soft?t._pluginData.pressure||0:(O.V.Warn("Pressure is not a property of a rigid body"),0)},r.prototype.setBodyPressure=function(t,e){t.soft?t.type===Dt.SoftbodyImpostor?(t.physicsBody.get_m_cfg().set_kPR(e),t._pluginData.pressure=e):(t.physicsBody.get_m_cfg().set_kPR(0),t._pluginData.pressure=0):O.V.Warn("Pressure can only be applied to a softbody")},r.prototype.getBodyStiffness=function(t){return t.soft?t._pluginData.stiffness||0:(O.V.Warn("Stiffness is not a property of a rigid body"),0)},r.prototype.setBodyStiffness=function(t,e){t.soft?(e=(e=e<0?0:e)>1?1:e,t.physicsBody.get_m_materials().at(0).set_m_kLST(e),t._pluginData.stiffness=e):O.V.Warn("Stiffness cannot be applied to a rigid body")},r.prototype.getBodyVelocityIterations=function(t){return t.soft?t._pluginData.velocityIterations||0:(O.V.Warn("Velocity iterations is not a property of a rigid body"),0)},r.prototype.setBodyVelocityIterations=function(t,e){t.soft?(e=e<0?0:e,t.physicsBody.get_m_cfg().set_viterations(e),t._pluginData.velocityIterations=e):O.V.Warn("Velocity iterations cannot be applied to a rigid body")},r.prototype.getBodyPositionIterations=function(t){return t.soft?t._pluginData.positionIterations||0:(O.V.Warn("Position iterations is not a property of a rigid body"),0)},r.prototype.setBodyPositionIterations=function(t,e){t.soft?(e=e<0?0:e,t.physicsBody.get_m_cfg().set_piterations(e),t._pluginData.positionIterations=e):O.V.Warn("Position iterations cannot be applied to a rigid body")},r.prototype.appendAnchor=function(t,e,n,i,o,a){o===void 0&&(o=1),a===void 0&&(a=!1);var s=t.segments,l=Math.round((s-1)*n)+s*(s-1-Math.round((s-1)*i));t.physicsBody.appendAnchor(l,e.physicsBody,a,o)},r.prototype.appendHook=function(t,e,n,i,o){i===void 0&&(i=1),o===void 0&&(o=!1);var a=Math.round(t.segments*n);t.physicsBody.appendAnchor(a,e.physicsBody,o,i)},r.prototype.sleepBody=function(t){t.physicsBody.forceActivationState(0)},r.prototype.wakeUpBody=function(t){t.physicsBody.activate()},r.prototype.updateDistanceJoint=function(){O.V.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},r.prototype.setMotor=function(t,e,n){t.physicsJoint.enableAngularMotor(!0,e,n)},r.prototype.setLimit=function(){O.V.Warn("setLimit is not currently supported by the Ammo physics plugin")},r.prototype.syncMeshWithImpostor=function(t,e){e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),t.position.x=this._tmpAmmoTransform.getOrigin().x(),t.position.y=this._tmpAmmoTransform.getOrigin().y(),t.position.z=this._tmpAmmoTransform.getOrigin().z(),t.rotationQuaternion&&(t.rotationQuaternion.x=this._tmpAmmoTransform.getRotation().x(),t.rotationQuaternion.y=this._tmpAmmoTransform.getRotation().y(),t.rotationQuaternion.z=this._tmpAmmoTransform.getRotation().z(),t.rotationQuaternion.w=this._tmpAmmoTransform.getRotation().w())},r.prototype.getRadius=function(t){return t.getObjectExtents().x/2},r.prototype.getBoxSizeToRef=function(t,e){var n=t.getObjectExtents();e.x=n.x,e.y=n.y,e.z=n.z},r.prototype.dispose=function(){this.bjsAMMO.destroy(this.world),this.bjsAMMO.destroy(this._softBodySolver),this.bjsAMMO.destroy(this._solver),this.bjsAMMO.destroy(this._overlappingPairCache),this.bjsAMMO.destroy(this._dispatcher),this.bjsAMMO.destroy(this._collisionConfiguration),this.bjsAMMO.destroy(this._tmpAmmoVectorA),this.bjsAMMO.destroy(this._tmpAmmoVectorB),this.bjsAMMO.destroy(this._tmpAmmoVectorC),this.bjsAMMO.destroy(this._tmpAmmoVectorD),this.bjsAMMO.destroy(this._tmpAmmoTransform),this.bjsAMMO.destroy(this._tmpAmmoQuaternion),this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),this.world=null},r.prototype.raycast=function(t,e){return this.raycastToRef(t,e,this._raycastResult),this._raycastResult},r.prototype.raycastToRef=function(t,e,n){this._tmpAmmoVectorRCA=new this.bjsAMMO.btVector3(t.x,t.y,t.z),this._tmpAmmoVectorRCB=new this.bjsAMMO.btVector3(e.x,e.y,e.z);var i=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,i),n.reset(t,e),i.hasHit()&&(n.setHitData({x:i.get_m_hitNormalWorld().x(),y:i.get_m_hitNormalWorld().y(),z:i.get_m_hitNormalWorld().z()},{x:i.get_m_hitPointWorld().x(),y:i.get_m_hitPointWorld().y(),z:i.get_m_hitPointWorld().z()}),n.calculateHitDistance()),this.bjsAMMO.destroy(i),this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),this.bjsAMMO.destroy(this._tmpAmmoVectorRCB)},r._DISABLE_COLLISION_FLAG=4,r._KINEMATIC_FLAG=2,r._DISABLE_DEACTIVATION_FLAG=4,r}();nt.d.prototype.removeReflectionProbe=function(r){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(r);return t!==-1&&this.reflectionProbes.splice(t,1),t},nt.d.prototype.addReflectionProbe=function(r){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(r)};var vh=function(){function r(t,e,n,i,o,a){i===void 0&&(i=!0),o===void 0&&(o=!1),a===void 0&&(a=!1);var s=this;if(this.name=t,this._viewMatrix=_.uq.Identity(),this._target=_.Pq.Zero(),this._add=_.Pq.Zero(),this._invertYAxis=!1,this.position=_.Pq.Zero(),this.metadata=null,this._parentContainer=null,this._scene=n,n.getEngine().supportsUniformBuffers){this._sceneUBOs=[];for(var l=0;l<6;++l)this._sceneUBOs.push(n.createSceneUniformBuffer('Scene for Reflection Probe (name "'.concat(t,'") face #').concat(l)))}this._scene.reflectionProbes||(this._scene.reflectionProbes=[]),this._scene.reflectionProbes.push(this);var c=P.Y.TEXTURETYPE_UNSIGNED_BYTE;if(o){var u=this._scene.getEngine().getCaps();u.textureHalfFloatRender?c=P.Y.TEXTURETYPE_HALF_FLOAT:u.textureFloatRender&&(c=P.Y.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new un.$(t,e,n,i,!0,c,!0),this._renderTargetTexture.gammaSpace=!a,this._renderTargetTexture.invertZ=n.useRightHandedSystem;var d,h=n.getEngine().useReverseDepthBuffer;this._renderTargetTexture.onBeforeRenderObservable.add(function(p){switch(s._sceneUBOs&&(n.setSceneUniformBuffer(s._sceneUBOs[p]),n.getSceneUniformBuffer().unbindEffect()),p){case 0:s._add.copyFromFloats(1,0,0);break;case 1:s._add.copyFromFloats(-1,0,0);break;case 2:s._add.copyFromFloats(0,s._invertYAxis?1:-1,0);break;case 3:s._add.copyFromFloats(0,s._invertYAxis?-1:1,0);break;case 4:s._add.copyFromFloats(0,0,n.useRightHandedSystem?-1:1);break;case 5:s._add.copyFromFloats(0,0,n.useRightHandedSystem?1:-1)}s._attachedMesh&&s.position.copyFrom(s._attachedMesh.getAbsolutePosition()),s.position.addToRef(s._add,s._target);var m=n.useRightHandedSystem?_.uq.LookAtRHToRef:_.uq.LookAtLHToRef,v=n.useRightHandedSystem?_.uq.PerspectiveFovRH:_.uq.PerspectiveFovLH;m(s.position,s._target,_.Pq.Up(),s._viewMatrix),n.activeCamera&&(s._projectionMatrix=v(Math.PI/2,1,h?n.activeCamera.maxZ:n.activeCamera.minZ,h?n.activeCamera.minZ:n.activeCamera.maxZ,s._scene.getEngine().isNDCHalfZRange),n.setTransformMatrix(s._viewMatrix,s._projectionMatrix),n.activeCamera.isRigCamera&&!s._renderTargetTexture.activeCamera&&(s._renderTargetTexture.activeCamera=n.activeCamera.rigParent||null)),n._forcedViewPosition=s.position}),this._renderTargetTexture.onBeforeBindObservable.add(function(){var p,m;s._currentSceneUBO=n.getSceneUniformBuffer(),(m=(p=n.getEngine())._debugPushGroup)===null||m===void 0||m.call(p,"reflection probe generation for ".concat(t),1),d=s._scene.imageProcessingConfiguration.applyByPostProcess,a&&(n.imageProcessingConfiguration.applyByPostProcess=!0)}),this._renderTargetTexture.onAfterUnbindObservable.add(function(){var p,m;n.imageProcessingConfiguration.applyByPostProcess=d,n._forcedViewPosition=null,s._sceneUBOs&&n.setSceneUniformBuffer(s._currentSceneUBO),n.updateTransformMatrix(!0),(m=(p=n.getEngine())._debugPopGroup)===null||m===void 0||m.call(p,1)})}return Object.defineProperty(r.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(t){this._renderTargetTexture.samples=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(t){this._renderTargetTexture.refreshRate=t},enumerable:!1,configurable:!0}),r.prototype.getScene=function(){return this._scene},Object.defineProperty(r.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},set:function(t){this._renderTargetTexture.renderList=t},enumerable:!1,configurable:!0}),r.prototype.attachToMesh=function(t){this._attachedMesh=t},r.prototype.setRenderingAutoClearDepthStencil=function(t,e){this._renderTargetTexture.setRenderingAutoClearDepthStencil(t,e)},r.prototype.dispose=function(){var t=this._scene.reflectionProbes.indexOf(this);if(t!==-1&&this._scene.reflectionProbes.splice(t,1),this._parentContainer){var e=this._parentContainer.reflectionProbes.indexOf(this);e>-1&&this._parentContainer.reflectionProbes.splice(e,1),this._parentContainer=null}if(this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null),this._sceneUBOs){for(var n=0,i=this._sceneUBOs;n<i.length;n++)i[n].dispose();this._sceneUBOs=[]}},r.prototype.toString=function(t){var e="Name: "+this.name;return t&&(e+=", position: "+this.position.toString(),this._attachedMesh&&(e+=", attached mesh: "+this._attachedMesh.name)),e},r.prototype.getClassName=function(){return"ReflectionProbe"},r.prototype.serialize=function(){var t=tt.p.Serialize(this,this._renderTargetTexture.serialize());return t.isReflectionProbe=!0,t.metadata=this.metadata,t},r.Parse=function(t,e,n){var i=null;if(e.reflectionProbes)for(var o=0;o<e.reflectionProbes.length;o++){var a=e.reflectionProbes[o];if(a.name===t.name){i=a;break}}return(i=tt.p.Parse(function(){return i||new r(t.name,t.renderTargetSize,e,t._generateMipMaps)},t,e,n)).cubeTexture._waitingRenderList=t.renderList,t._attachedMesh&&i.attachToMesh(e.getMeshById(t._attachedMesh)),t.metadata&&(i.metadata=t.metadata),i},(0,A.Cg)([(0,V.xG)()],r.prototype,"_attachedMesh",void 0),(0,A.Cg)([(0,V.P_)()],r.prototype,"position",void 0),r}(),Mv=function(r){function t(e,n){var i=r.call(this)||this;return i.name=e,i.animations=new Array,i.isPickable=!1,i.useAlphaForPicking=!1,i.onDisposeObservable=new K.cP,i._onAnimationEnd=null,i._endAnimation=function(){i._onAnimationEnd&&i._onAnimationEnd(),i.disposeWhenFinishedAnimating&&i.dispose()},i.color=new z.ov(1,1,1,1),i.position=_.Pq.Zero(),i._manager=n,i._manager.sprites.push(i),i.uniqueId=i._manager.scene.getUniqueId(),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manager",{get:function(){return this._manager},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Sprite"},Object.defineProperty(t.prototype,"fromIndex",{get:function(){return this._fromIndex},set:function(e){this.playAnimation(e,this._toIndex,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toIndex",{get:function(){return this._toIndex},set:function(e){this.playAnimation(this._fromIndex,e,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loopAnimation",{get:function(){return this._loopAnimation},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,e,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"delay",{get:function(){return Math.max(this._delay,1)},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,this._loopAnimation,e,this._onAnimationEnd)},enumerable:!1,configurable:!0}),t.prototype.playAnimation=function(e,n,i,o,a){a===void 0&&(a=null),this._onAnimationEnd=a,r.prototype.playAnimation.call(this,e,n,i,o,this._endAnimation)},t.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1);this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.serialize=function(){var e={};return e.name=this.name,e.position=this.position.asArray(),e.color=this.color.asArray(),e.width=this.width,e.height=this.height,e.angle=this.angle,e.cellIndex=this.cellIndex,e.cellRef=this.cellRef,e.invertU=this.invertU,e.invertV=this.invertV,e.disposeWhenFinishedAnimating=this.disposeWhenFinishedAnimating,e.isPickable=this.isPickable,e.isVisible=this.isVisible,e.useAlphaForPicking=this.useAlphaForPicking,e.animationStarted=this.animationStarted,e.fromIndex=this.fromIndex,e.toIndex=this.toIndex,e.loopAnimation=this.loopAnimation,e.delay=this.delay,e},t.Parse=function(e,n){var i=new t(e.name,n);return i.position=_.Pq.FromArray(e.position),i.color=z.ov.FromArray(e.color),i.width=e.width,i.height=e.height,i.angle=e.angle,i.cellIndex=e.cellIndex,i.cellRef=e.cellRef,i.invertU=e.invertU,i.invertV=e.invertV,i.disposeWhenFinishedAnimating=e.disposeWhenFinishedAnimating,i.isPickable=e.isPickable,i.isVisible=e.isVisible,i.useAlphaForPicking=e.useAlphaForPicking,i._fromIndex=e.fromIndex,i._toIndex=e.toIndex,i._loopAnimation=e.loopAnimation,i._delay=e.delay,e.animationStarted&&i.playAnimation(i.fromIndex,i.toIndex,i.loopAnimation,i.delay),i},t}(function(){function r(){this.width=1,this.height=1,this.angle=0,this.invertU=!1,this.invertV=!1,this.isVisible=!0,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._time=0,this._onBaseAnimationEnd=null,this.position={x:1,y:1,z:1},this.color={r:1,g:1,b:1,a:1}}return Object.defineProperty(r.prototype,"animationStarted",{get:function(){return this._animationStarted},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fromIndex",{get:function(){return this._fromIndex},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"toIndex",{get:function(){return this._toIndex},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loopAnimation",{get:function(){return this._loopAnimation},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"delay",{get:function(){return Math.max(this._delay,1)},enumerable:!1,configurable:!0}),r.prototype.playAnimation=function(t,e,n,i,o){this._fromIndex=t,this._toIndex=e,this._loopAnimation=n,this._delay=i||1,this._animationStarted=!0,this._onBaseAnimationEnd=o,t<e?this._direction=1:(this._direction=-1,this._toIndex=t,this._fromIndex=e),this.cellIndex=t,this._time=0},r.prototype.stopAnimation=function(){this._animationStarted=!1},r.prototype._animate=function(t){this._animationStarted&&(this._time+=t,this._time>this._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex<this._fromIndex)&&(this._loopAnimation?this.cellIndex=this._direction>0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},r}());ke.Z.prototype._internalPickSprites=function(r,t,e,n){if(!ri.G)return null;var i=null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers&&this.spriteManagers.length>0)for(var o=0;o<this.spriteManagers.length;o++){var a=this.spriteManagers[o];if(a.isPickable){var s=a.intersects(r,n,t,e);if(s&&s.hit&&(e||i==null||!(s.distance>=i.distance))&&(i=s,e))break}}return i||new ri.G},ke.Z.prototype._internalMultiPickSprites=function(r,t,e){if(!ri.G)return null;var n=[];if(!e){if(!this.activeCamera)return null;e=this.activeCamera}if(this.spriteManagers&&this.spriteManagers.length>0)for(var i=0;i<this.spriteManagers.length;i++){var o=this.spriteManagers[i];if(o.isPickable){var a=o.multiIntersects(r,e,t);a!==null&&(n=n.concat(a))}}return n},ke.Z.prototype.pickSprite=function(r,t,e,n,i){if(!this._tempSpritePickingRay)return null;this.createPickingRayInCameraSpaceToRef(r,t,this._tempSpritePickingRay,i);var o=this._internalPickSprites(this._tempSpritePickingRay,e,n,i);return o&&(o.ray=this.createPickingRayInCameraSpace(r,t,i)),o},ke.Z.prototype.pickSpriteWithRay=function(r,t,e,n){if(!this._tempSpritePickingRay)return null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}fn.TransformToRef(r,n.getViewMatrix(),this._tempSpritePickingRay);var i=this._internalPickSprites(this._tempSpritePickingRay,t,e,n);return i&&(i.ray=r),i},ke.Z.prototype.multiPickSprite=function(r,t,e,n){return this.createPickingRayInCameraSpaceToRef(r,t,this._tempSpritePickingRay,n),this._internalMultiPickSprites(this._tempSpritePickingRay,e,n)},ke.Z.prototype.multiPickSpriteWithRay=function(r,t,e){if(!this._tempSpritePickingRay)return null;if(!e){if(!this.activeCamera)return null;e=this.activeCamera}return fn.TransformToRef(r,e.getViewMatrix(),this._tempSpritePickingRay),this._internalMultiPickSprites(this._tempSpritePickingRay,t,e)},ke.Z.prototype.setPointerOverSprite=function(r){this._pointerOverSprite!==r&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(P.Y.ACTION_OnPointerOutTrigger,Se.X.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=r,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(P.Y.ACTION_OnPointerOverTrigger,Se.X.CreateNewFromSprite(this._pointerOverSprite,this)))},ke.Z.prototype.getPointerOverSprite=function(){return this._pointerOverSprite};var Ov=function(){function r(t){this.name=lt.v.NAME_SPRITE,this.scene=t,this.scene.spriteManagers=[],this.scene._tempSpritePickingRay=fn?fn.Zero():null,this.scene.onBeforeSpritesRenderingObservable=new K.cP,this.scene.onAfterSpritesRenderingObservable=new K.cP,this._spritePredicate=function(e){return!!e.actionManager&&e.isPickable&&e.actionManager.hasPointerTriggers}}return r.prototype.register=function(){this.scene._pointerMoveStage.registerStep(lt.v.STEP_POINTERMOVE_SPRITE,this,this._pointerMove),this.scene._pointerDownStage.registerStep(lt.v.STEP_POINTERDOWN_SPRITE,this,this._pointerDown),this.scene._pointerUpStage.registerStep(lt.v.STEP_POINTERUP_SPRITE,this,this._pointerUp)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){this.scene.onBeforeSpritesRenderingObservable.clear(),this.scene.onAfterSpritesRenderingObservable.clear();var t=this.scene.spriteManagers;if(t)for(;t.length;)t[0].dispose()},r.prototype._pickSpriteButKeepRay=function(t,e,n,i,o){var a=this.scene.pickSprite(e,n,this._spritePredicate,i,o);return a&&(a.ray=t?t.ray:null),a},r.prototype._pointerMove=function(t,e,n,i,o){var a=this.scene;return i?a.setPointerOverSprite(null):(n=this._pickSpriteButKeepRay(n,t,e,!1,a.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite?(a.setPointerOverSprite(n.pickedSprite),!a.doNotHandleCursors&&o&&(a._pointerOverSprite&&a._pointerOverSprite.actionManager&&a._pointerOverSprite.actionManager.hoverCursor?o.style.cursor=a._pointerOverSprite.actionManager.hoverCursor:o.style.cursor=a.hoverCursor)):a.setPointerOverSprite(null),n},r.prototype._pointerDown=function(t,e,n,i){var o=this.scene;if(o._pickedDownSprite=null,o.spriteManagers&&o.spriteManagers.length>0&&(n=o.pickSprite(t,e,this._spritePredicate,!1,o.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(o._pickedDownSprite=n.pickedSprite,i.button){case 0:n.pickedSprite.actionManager.processTrigger(P.Y.ACTION_OnLeftPickTrigger,Se.X.CreateNewFromSprite(n.pickedSprite,o,i));break;case 1:n.pickedSprite.actionManager.processTrigger(P.Y.ACTION_OnCenterPickTrigger,Se.X.CreateNewFromSprite(n.pickedSprite,o,i));break;case 2:n.pickedSprite.actionManager.processTrigger(P.Y.ACTION_OnRightPickTrigger,Se.X.CreateNewFromSprite(n.pickedSprite,o,i))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(P.Y.ACTION_OnPickDownTrigger,Se.X.CreateNewFromSprite(n.pickedSprite,o,i))}return n},r.prototype._pointerUp=function(t,e,n,i,o){var a=this.scene;if(a.spriteManagers&&a.spriteManagers.length>0){var s=a.pickSprite(t,e,this._spritePredicate,!1,a.cameraToUseForPointers||void 0);s&&(s.hit&&s.pickedSprite&&s.pickedSprite.actionManager&&(s.pickedSprite.actionManager.processTrigger(P.Y.ACTION_OnPickUpTrigger,Se.X.CreateNewFromSprite(s.pickedSprite,a,i)),s.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||s.pickedSprite.actionManager.processTrigger(P.Y.ACTION_OnPickTrigger,Se.X.CreateNewFromSprite(s.pickedSprite,a,i)),o&&s.pickedSprite.actionManager.processTrigger(P.Y.ACTION_OnDoublePickTrigger,Se.X.CreateNewFromSprite(s.pickedSprite,a,i)))),a._pickedDownSprite&&a._pickedDownSprite.actionManager&&a._pickedDownSprite!==s.pickedSprite&&a._pickedDownSprite.actionManager.processTrigger(P.Y.ACTION_OnPickOutTrigger,Se.X.CreateNewFromSprite(a._pickedDownSprite,a,i)))}return n},r}(),sN=function(){function r(t,e,n,i){n===void 0&&(n=.01),i===void 0&&(i=null),this.blendMode=P.Y.ALPHA_COMBINE,this.autoResetAlpha=!0,this.disableDepthWrite=!1,this._fogEnabled=!0,this._pixelPerfect=!1,this._shaderLanguage=0,this._useVAO=!1,this._useInstancing=!1,this._vertexBuffers={},this._isDisposed=!1,this._shadersLoaded=!1,this._capacity=e,this._epsilon=n,this._engine=t,this._useInstancing=t.getCaps().instancedArrays&&t._features.supportSpriteInstancing,this._useVAO=t.getCaps().vertexArrayObject&&!t.disableVertexArrayObjects,this._scene=i,this._useInstancing||this._buildIndexBuffer(),this._vertexBufferSize=this._useInstancing?16:18,this._vertexData=new Float32Array(e*this._vertexBufferSize*(this._useInstancing?1:4)),this._buffer=new Y.h(t,this._vertexData,!0,this._vertexBufferSize);var o,a=this._buffer.createVertexBuffer(Y.R.PositionKind,0,4,this._vertexBufferSize,this._useInstancing),s=this._buffer.createVertexBuffer("options",4,2,this._vertexBufferSize,this._useInstancing),l=6;if(this._useInstancing){var c=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new Y.h(t,c,!1,2),o=this._spriteBuffer.createVertexBuffer("offsets",0,2)}else o=this._buffer.createVertexBuffer("offsets",l,2,this._vertexBufferSize,this._useInstancing),l+=2;var u=this._buffer.createVertexBuffer("inverts",l,2,this._vertexBufferSize,this._useInstancing),d=this._buffer.createVertexBuffer("cellInfo",l+2,4,this._vertexBufferSize,this._useInstancing),h=this._buffer.createVertexBuffer(Y.R.ColorKind,l+6,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Y.R.PositionKind]=a,this._vertexBuffers.options=s,this._vertexBuffers.offsets=o,this._vertexBuffers.inverts=u,this._vertexBuffers.cellInfo=d,this._vertexBuffers[Y.R.ColorKind]=h,this._initShaderSourceAsync()}return Object.defineProperty(r.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this._createEffects())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(t){var e,n=!!(!((e=this._scene)===null||e===void 0)&&e.getEngine().getCaps().fragmentDepthSupported);t&&!n&&O.V.Warn("Logarithmic depth has been requested for a sprite renderer on a device that doesn't support it."),this._useLogarithmicDepth=t&&n,this._createEffects()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"capacity",{get:function(){return this._capacity},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pixelPerfect",{get:function(){return this._pixelPerfect},set:function(t){this._pixelPerfect!==t&&(this._pixelPerfect=t,this._createEffects())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._initShaderSourceAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:return!this._engine.isWebGPU||r.ForceGLSL?[3,2]:(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,98179)),Promise.resolve().then(L.bind(L,89493))])]);case 1:return t.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,25792)),Promise.resolve().then(L.bind(L,22088))])];case 3:t.sent(),t.label=4;case 4:return this._shadersLoaded=!0,this._createEffects(),[2]}})})},r.prototype._createEffects=function(){var t,e;if(!this._isDisposed){(t=this._drawWrapperBase)===null||t===void 0||t.dispose(),(e=this._drawWrapperDepth)===null||e===void 0||e.dispose(),this._drawWrapperBase=new jn.E(this._engine),this._drawWrapperDepth=new jn.E(this._engine,!1),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=this._useInstancing),this._drawWrapperDepth.drawContext&&(this._drawWrapperDepth.drawContext.useInstancing=this._useInstancing);var n="";this._pixelPerfect&&(n+=`#define PIXEL_PERFECT
|
||
`),this._scene&&this._scene.fogEnabled&&this._scene.fogMode!==0&&this._fogEnabled&&(n+=`#define FOG
|
||
`),this._useLogarithmicDepth&&(n+=`#define LOGARITHMICDEPTH
|
||
`),this._drawWrapperBase.effect=this._engine.createEffect("sprites",[Y.R.PositionKind,"options","offsets","inverts","cellInfo",Y.R.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor","logarithmicDepthConstant"],["diffuseSampler"],n,void 0,void 0,void 0,void 0,this._shaderLanguage),this._drawWrapperDepth.effect=this._drawWrapperBase.effect,this._drawWrapperDepth.materialContext=this._drawWrapperBase.materialContext}},r.prototype.render=function(t,e,n,i,o){if(o===void 0&&(o=null),this._shadersLoaded&&this.texture&&this.texture.isReady()&&t.length){var a=this._drawWrapperBase,s=this._drawWrapperDepth,l=this.fogEnabled&&this._scene&&this._scene.fogEnabled&&this._scene.fogMode!==0,c=a.effect;if(c.isReady()){for(var u=this._engine,d=!(!this._scene||!this._scene.useRightHandedSystem),h=this.texture.getBaseSize(),p=Math.min(this._capacity,t.length),m=0,v=!0,b=0;b<p;b++){var E=t[b];E&&E.isVisible&&(v=!1,E._animate(e),this._appendSpriteVertex(m++,E,0,0,h,d,o),this._useInstancing||(this._appendSpriteVertex(m++,E,1,0,h,d,o),this._appendSpriteVertex(m++,E,1,1,h,d,o),this._appendSpriteVertex(m++,E,0,1,h,d,o)))}if(!v){this._buffer.update(this._vertexData);var C=!!u.depthCullingState.cull,T=u.depthCullingState.zOffset,f=u.depthCullingState.zOffsetUnits;if(u.setState(C,T,!1,!1,void 0,void 0,f),u.enableEffect(a),c.setTexture("diffuseSampler",this.texture),c.setMatrix("view",n),c.setMatrix("projection",i),l){var g=this._scene;c.setFloat4("vFogInfos",g.fogMode,g.fogStart,g.fogEnd,g.fogDensity),c.setColor3("vFogColor",g.fogColor)}this.useLogarithmicDepth&&this._scene&&(0,Re.DL)(a.defines,c,this._scene),this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=u.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,c)),u.bindVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):u.bindBuffers(this._vertexBuffers,this._indexBuffer,c),u.depthCullingState.depthFunc=u.useReverseDepthBuffer?P.Y.GEQUAL:P.Y.LEQUAL,this.disableDepthWrite||(c.setBool("alphaTest",!0),u.setColorWrite(!1),u.enableEffect(s),this._useInstancing?u.drawArraysType(P.Y.MATERIAL_TriangleStripDrawMode,0,4,m):u.drawElementsType(P.Y.MATERIAL_TriangleFillMode,0,m/4*6),u.enableEffect(a),u.setColorWrite(!0),c.setBool("alphaTest",!1)),u.setAlphaMode(this.blendMode),this._useInstancing?u.drawArraysType(P.Y.MATERIAL_TriangleStripDrawMode,0,4,m):u.drawElementsType(P.Y.MATERIAL_TriangleFillMode,0,m/4*6),this.autoResetAlpha&&u.setAlphaMode(P.Y.ALPHA_DISABLE),d&&this._scene.getEngine().setState(C,T,!1,!0,void 0,void 0,f),u.unbindInstanceAttributes()}}}},r.prototype._appendSpriteVertex=function(t,e,n,i,o,a,s){var l=t*this._vertexBufferSize;if(n===0?n=this._epsilon:n===1&&(n=1-this._epsilon),i===0?i=this._epsilon:i===1&&(i=1-this._epsilon),s)s(e,o);else{e.cellIndex||(e.cellIndex=0);var c=o.width/this.cellWidth,u=e.cellIndex/c|0;e._xOffset=(e.cellIndex-u*c)*this.cellWidth/o.width,e._yOffset=u*this.cellHeight/o.height,e._xSize=this.cellWidth,e._ySize=this.cellHeight}this._vertexData[l]=e.position.x,this._vertexData[l+1]=e.position.y,this._vertexData[l+2]=e.position.z,this._vertexData[l+3]=e.angle,this._vertexData[l+4]=e.width,this._vertexData[l+5]=e.height,this._useInstancing?l-=2:(this._vertexData[l+6]=n,this._vertexData[l+7]=i),this._vertexData[l+8]=a?e.invertU?0:1:e.invertU?1:0,this._vertexData[l+9]=e.invertV?1:0,this._vertexData[l+10]=e._xOffset,this._vertexData[l+11]=e._yOffset,this._vertexData[l+12]=e._xSize/o.width,this._vertexData[l+13]=e._ySize/o.height,this._vertexData[l+14]=e.color.r,this._vertexData[l+15]=e.color.g,this._vertexData[l+16]=e.color.b,this._vertexData[l+17]=e.color.a},r.prototype._buildIndexBuffer=function(){for(var t=[],e=0,n=0;n<this._capacity;n++)t.push(e),t.push(e+1),t.push(e+2),t.push(e),t.push(e+2),t.push(e+3),e+=4;this._indexBuffer=this._engine.createIndexBuffer(t)},r.prototype.rebuild=function(){var t;for(var e in this._indexBuffer&&this._buildIndexBuffer(),this._useVAO&&(this._vertexArrayObject=void 0),this._buffer._rebuild(),this._vertexBuffers)this._vertexBuffers[e]._rebuild();(t=this._spriteBuffer)===null||t===void 0||t._rebuild()},r.prototype.dispose=function(){var t,e;this._buffer&&(this._buffer.dispose(),this._buffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),this.texture&&(this.texture.dispose(),this.texture=null),(t=this._drawWrapperBase)===null||t===void 0||t.dispose(),(e=this._drawWrapperDepth)===null||e===void 0||e.dispose(),this._isDisposed=!0},r.ForceGLSL=!1,r}(),yh=function(){function r(t,e,n,i,o,a,s,l,c){a===void 0&&(a=.01),s===void 0&&(s=Ie.g.TRILINEAR_SAMPLINGMODE),l===void 0&&(l=!1),c===void 0&&(c=null);var u=this;this.name=t,this.sprites=[],this.renderingGroupId=0,this.layerMask=268435455,this.isPickable=!1,this.metadata=null,this._wasDispatched=!1,this.onDisposeObservable=new K.cP,this._disableDepthWrite=!1,this._packedAndReady=!1,this._customUpdate=function(h,p){h.cellRef||(h.cellIndex=0);var m=h.cellIndex;typeof m=="number"&&isFinite(m)&&Math.floor(m)===m&&(h.cellRef=u._spriteMap[h.cellIndex]),h._xOffset=u._cellData[h.cellRef].frame.x/p.width,h._yOffset=u._cellData[h.cellRef].frame.y/p.height,h._xSize=u._cellData[h.cellRef].frame.w,h._ySize=u._cellData[h.cellRef].frame.h},o||(o=Ve.q.LastCreatedScene),o._getComponent(lt.v.NAME_SPRITE)||o._addComponent(new Ov(o)),this._fromPacked=l,this._scene=o;var d=this._scene.getEngine();if(this._spriteRenderer=new sN(d,n,a,o),i.width&&i.height)this.cellWidth=i.width,this.cellHeight=i.height;else{if(i===void 0)return void(this._spriteRenderer=null);this.cellWidth=i,this.cellHeight=i}this._scene.spriteManagers&&this._scene.spriteManagers.push(this),this.uniqueId=this.scene.getUniqueId(),e&&(this.texture=new Ie.g(e,o,!0,!1,s)),this._fromPacked&&this._makePacked(e,c)}return Object.defineProperty(r.prototype,"onDispose",{set:function(t){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"children",{get:function(){return this.sprites},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"capacity",{get:function(){return this._spriteRenderer.capacity},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"texture",{get:function(){return this._spriteRenderer.texture},set:function(t){t.wrapU=Ie.g.CLAMP_ADDRESSMODE,t.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._spriteRenderer.texture=t,this._textureContent=null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cellWidth",{get:function(){return this._spriteRenderer.cellWidth},set:function(t){this._spriteRenderer.cellWidth=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cellHeight",{get:function(){return this._spriteRenderer.cellHeight},set:function(t){this._spriteRenderer.cellHeight=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fogEnabled",{get:function(){return this._spriteRenderer.fogEnabled},set:function(t){this._spriteRenderer.fogEnabled=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._spriteRenderer.useLogarithmicDepth},set:function(t){this._spriteRenderer.useLogarithmicDepth=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blendMode",{get:function(){return this._spriteRenderer.blendMode},set:function(t){this._spriteRenderer.blendMode=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"disableDepthWrite",{get:function(){return this._disableDepthWrite},set:function(t){this._disableDepthWrite=t,this._spriteRenderer.disableDepthWrite=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"pixelPerfect",{get:function(){return this._spriteRenderer.pixelPerfect},set:function(t){this._spriteRenderer.pixelPerfect=t,t&&this.texture.samplingMode!==P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE&&this.texture.updateSamplingMode(P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE)},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"SpriteManager"},r.prototype._makePacked=function(t,e){var n=this;if(e!==null)try{var i=void 0;if((i=typeof e=="string"?JSON.parse(e):e).frames.length){for(var o={},a=0;a<i.frames.length;a++){var s=i.frames[a];if(typeof Object.keys(s)[0]!="string")throw new Error("Invalid JSON Format. Check the frame values and make sure the name is the first parameter.");o[s[Object.keys(s)[0]]]=s}i.frames=o}var l=Reflect.ownKeys(i.frames);this._spriteMap=l,this._packedAndReady=!0,this._cellData=i.frames}catch{throw this._fromPacked=!1,this._packedAndReady=!1,new Error("Invalid JSON from string. Spritesheet managed with constant cell size.")}else{var c=/\./g,u=void 0;do u=c.lastIndex,c.test(t);while(c.lastIndex>0);var d=t.substring(0,u-1)+".json";ze.S0.LoadFile(d,function(h){try{var p=JSON.parse(h),m=Reflect.ownKeys(p.frames);n._spriteMap=m,n._packedAndReady=!0,n._cellData=p.frames}catch{throw n._fromPacked=!1,n._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}},void 0,void 0,!1,function(){O.V.Error("JSON ERROR: Unable to load JSON file."),n._fromPacked=!1,n._packedAndReady=!1})}},r.prototype._checkTextureAlpha=function(t,e,n,i,o){if(!t.useAlphaForPicking||!this.texture)return!0;var a=this.texture.getSize();this._textureContent||(this._textureContent=new Uint8Array(a.width*a.height*4),this.texture.readPixels(0,0,this._textureContent));var s=_.AA.Vector3[0];s.copyFrom(e.direction),s.normalize(),s.scaleInPlace(n),s.addInPlace(e.origin);var l=(s.x-i.x)/(o.x-i.x),c=1-(s.y-i.y)/(o.y-i.y),u=t._xOffset*a.width+l*t._xSize|0,d=t._yOffset*a.height+c*t._ySize|0;return this._textureContent[4*(u+d*a.width)+3]>.5},r.prototype.intersects=function(t,e,n,i){for(var o=Math.min(this.capacity,this.sprites.length),a=_.Pq.Zero(),s=_.Pq.Zero(),l=Number.MAX_VALUE,c=null,u=_.AA.Vector3[0],d=_.AA.Vector3[1],h=e.getViewMatrix(),p=t,m=t,v=0;v<o;v++){var b=this.sprites[v];if(b){if(n){if(!n(b))continue}else if(!b.isPickable)continue;if(_.Pq.TransformCoordinatesToRef(b.position,h,d),b.angle?(_.uq.TranslationToRef(-d.x,-d.y,0,_.AA.Matrix[1]),_.uq.TranslationToRef(d.x,d.y,0,_.AA.Matrix[2]),_.uq.RotationZToRef(-b.angle,_.AA.Matrix[3]),_.AA.Matrix[1].multiplyToRef(_.AA.Matrix[3],_.AA.Matrix[4]),_.AA.Matrix[4].multiplyToRef(_.AA.Matrix[2],_.AA.Matrix[0]),p=t.clone(),_.Pq.TransformCoordinatesToRef(t.origin,_.AA.Matrix[0],p.origin),_.Pq.TransformNormalToRef(t.direction,_.AA.Matrix[0],p.direction)):p=t,a.copyFromFloats(d.x-b.width/2,d.y-b.height/2,d.z),s.copyFromFloats(d.x+b.width/2,d.y+b.height/2,d.z),p.intersectsBoxMinMax(a,s)){var E=_.Pq.Distance(d,p.origin);if(l>E){if(!this._checkTextureAlpha(b,p,E,a,s))continue;if(m=p,l=E,c=b,i)break}}}}if(c){var C=new ri.G;h.invertToRef(_.AA.Matrix[0]),C.hit=!0,C.pickedSprite=c,C.distance=l;var T=_.AA.Vector3[2];return T.copyFrom(m.direction),T.normalize(),T.scaleInPlace(l),m.origin.addToRef(T,u),C.pickedPoint=_.Pq.TransformCoordinates(u,_.AA.Matrix[0]),C}return null},r.prototype.multiIntersects=function(t,e,n){for(var i,o=Math.min(this.capacity,this.sprites.length),a=_.Pq.Zero(),s=_.Pq.Zero(),l=[],c=_.AA.Vector3[0].copyFromFloats(0,0,0),u=_.AA.Vector3[1].copyFromFloats(0,0,0),d=e.getViewMatrix(),h=0;h<o;h++){var p=this.sprites[h];if(p){if(n){if(!n(p))continue}else if(!p.isPickable)continue;if(_.Pq.TransformCoordinatesToRef(p.position,d,u),a.copyFromFloats(u.x-p.width/2,u.y-p.height/2,u.z),s.copyFromFloats(u.x+p.width/2,u.y+p.height/2,u.z),t.intersectsBoxMinMax(a,s)){if(i=_.Pq.Distance(u,t.origin),!this._checkTextureAlpha(p,t,i,a,s))continue;var m=new ri.G;l.push(m),d.invertToRef(_.AA.Matrix[0]),m.hit=!0,m.pickedSprite=p,m.distance=i;var v=_.AA.Vector3[2];v.copyFrom(t.direction),v.normalize(),v.scaleInPlace(i),t.origin.addToRef(v,c),m.pickedPoint=_.Pq.TransformCoordinates(c,_.AA.Matrix[0])}}}return l},r.prototype.render=function(){if(!this._fromPacked||this._packedAndReady&&this._spriteMap&&this._cellData){var t=this._scene.getEngine().getDeltaTime();this._packedAndReady?this._spriteRenderer.render(this.sprites,t,this._scene.getViewMatrix(),this._scene.getProjectionMatrix(),this._customUpdate):this._spriteRenderer.render(this.sprites,t,this._scene.getViewMatrix(),this._scene.getProjectionMatrix())}},r.prototype.rebuild=function(){var t;(t=this._spriteRenderer)===null||t===void 0||t.rebuild()},r.prototype.dispose=function(){if(this._spriteRenderer&&(this._spriteRenderer.dispose(),this._spriteRenderer=null),this._textureContent=null,this._scene.spriteManagers){var t=this._scene.spriteManagers.indexOf(this);this._scene.spriteManagers.splice(t,1)}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null},r.prototype.serialize=function(t){t===void 0&&(t=!1);var e={};e.name=this.name,e.capacity=this.capacity,e.cellWidth=this.cellWidth,e.cellHeight=this.cellHeight,e.fogEnabled=this.fogEnabled,e.blendMode=this.blendMode,e.disableDepthWrite=this.disableDepthWrite,e.pixelPerfect=this.pixelPerfect,e.useLogarithmicDepth=this.useLogarithmicDepth,this.texture&&(t?e.texture=this.texture.serialize():(e.textureUrl=this.texture.name,e.invertY=this.texture._invertY)),e.sprites=[];for(var n=0,i=this.sprites;n<i.length;n++){var o=i[n];e.sprites.push(o.serialize())}return e.metadata=this.metadata,e},r.Parse=function(t,e,n){var i=new r(t.name,"",t.capacity,{width:t.cellWidth,height:t.cellHeight},e);t.fogEnabled!==void 0&&(i.fogEnabled=t.fogEnabled),t.blendMode!==void 0&&(i.blendMode=t.blendMode),t.disableDepthWrite!==void 0&&(i.disableDepthWrite=t.disableDepthWrite),t.pixelPerfect!==void 0&&(i.pixelPerfect=t.pixelPerfect),t.useLogarithmicDepth!==void 0&&(i.useLogarithmicDepth=t.useLogarithmicDepth),t.metadata!==void 0&&(i.metadata=t.metadata),t.texture?i.texture=Ie.g.Parse(t.texture,e,n):t.textureName&&(i.texture=new Ie.g(n+t.textureUrl,e,!1,t.invertY===void 0||t.invertY));for(var o=0,a=t.sprites;o<a.length;o++){var s=a[o];Mv.Parse(s,i)}return i},r.ParseFromFileAsync=function(t,e,n,i){return i===void 0&&(i=""),new Promise(function(o,a){var s=new We.u;s.addEventListener("readystatechange",function(){if(s.readyState==4)if(s.status==200){var l=JSON.parse(s.responseText),c=r.Parse(l,n||Ve.q.LastCreatedScene,i);t&&(c.name=t),o(c)}else a("Unable to load the sprite manager")}),s.open("GET",e),s.send()})},r.ParseFromSnippetAsync=function(t,e,n){var i=this;return n===void 0&&(n=""),t==="_BLANK"?Promise.resolve(new r("Default sprite manager","//playground.babylonjs.com/textures/player.png",500,64,e)):new Promise(function(o,a){var s=new We.u;s.addEventListener("readystatechange",function(){if(s.readyState==4)if(s.status==200){var l=JSON.parse(JSON.parse(s.responseText).jsonPayload),c=JSON.parse(l.spriteManager),u=r.Parse(c,e||Ve.q.LastCreatedScene,n);u.snippetId=t,o(u)}else a("Unable to load the snippet "+t)}),s.open("GET",i.SnippetUrl+"/"+t.replace(/#/g,"/")),s.send()})},r.SnippetUrl=P.Y.SnippetUrl,r.CreateFromSnippetAsync=r.ParseFromSnippetAsync,r}(),vP=!0,El=function(){function r(){}return r.LoaderInjectedPhysicsEngine=void 0,r}(),ds={},Vo={},yP=function(r,t,e,n){if(!t.materials)return null;for(var i=0,o=t.materials.length;i<o;i++){var a=t.materials[i];if(r(a))return{parsedMaterial:a,material:Lt.Parse(a,e,n)}}return null},hs=function(r,t){return r+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")},bP=function(r,t){var e=t;if(t._waitingData.lods){if(t._waitingData.lods.ids&&t._waitingData.lods.ids.length>0){var n=t._waitingData.lods.ids,i=e.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=n.length){var a=o.length>n.length?o[o.length-1]:0;e.setEnabled(!1);for(var s=0;s<n.length;s++){var l=n[s],c=r.getMeshById(l);c!=null&&e.addLODLevel(o[s],c)}a>0&&e.addLODLevel(a,null),i===!0&&e.setEnabled(!0)}else ze.S0.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},bh=function(r,t,e){if(typeof r!="number"){var n=e.getLastEntryById(r);return n&&t!=null?n.instances[parseInt(t)]:n}var i=ds[r];return i&&t!=null?i.instances[parseInt(t)]:i},Th=function(r,t){return typeof r!="number"?t.getLastMaterialById(r,!0):Vo[r]},TP=function(r,t,e,n,i){i===void 0&&(i=!1);var o=new tm(r),a="importScene has failed JSON parse";try{var s=JSON.parse(t);a="";var l=yn.loggingLevel===yn.DETAILED_LOGGING,c=void 0,u=void 0;if(s.environmentTexture!==void 0&&s.environmentTexture!==null){var d=s.isPBR===void 0||s.isPBR;if(s.environmentTextureType&&s.environmentTextureType==="BABYLON.HDRCubeTexture"){var h=s.environmentTextureSize?s.environmentTextureSize:128,p=new bl((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r,h,!0,!d,void 0,s.environmentTexturePrefilterOnLoad);s.environmentTextureRotationY&&(p.rotationY=s.environmentTextureRotationY),r.environmentTexture=p}else if(typeof s.environmentTexture=="object"){var m=mr.Parse(s.environmentTexture,r,e);r.environmentTexture=m}else if(s.environmentTexture.endsWith(".env")){var v=new mr((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r,s.environmentTextureForcedExtension);s.environmentTextureRotationY&&(v.rotationY=s.environmentTextureRotationY),r.environmentTexture=v}else{var b=mr.CreateFromPrefilteredData((s.environmentTexture.match(/https?:\/\//g)?"":e)+s.environmentTexture,r,s.environmentTextureForcedExtension);s.environmentTextureRotationY&&(b.rotationY=s.environmentTextureRotationY),r.environmentTexture=b}if(s.createDefaultSkybox===!0){var E=r.activeCamera!==void 0&&r.activeCamera!==null?(r.activeCamera.maxZ-r.activeCamera.minZ)/2:1e3,C=s.skyboxBlurLevel||0;r.createDefaultSkybox(r.environmentTexture,d,E,C)}o.environmentTexture=r.environmentTexture}if(s.environmentIntensity!==void 0&&s.environmentIntensity!==null&&(r.environmentIntensity=s.environmentIntensity),s.lights!==void 0&&s.lights!==null)for(c=0,u=s.lights.length;c<u;c++){var T=s.lights[c];(Je=hi.Parse(T,r))&&(ds[T.uniqueId]=Je,o.lights.push(Je),Je._parentContainer=o,a+=c===0?`
|
||
Lights:`:"",a+=`
|
||
`+Je.toString(l))}if(s.reflectionProbes!==void 0&&s.reflectionProbes!==null)for(c=0,u=s.reflectionProbes.length;c<u;c++){var f=s.reflectionProbes[c],g=vh.Parse(f,r,e);g&&(o.reflectionProbes.push(g),g._parentContainer=o,a+=c===0?`
|
||
Reflection Probes:`:"",a+=`
|
||
`+g.toString(l))}if(s.animations!==void 0&&s.animations!==null)for(c=0,u=s.animations.length;c<u;c++){var S=s.animations[c],y=(0,j.n9)("BABYLON.Animation");if(y){var x=y.Parse(S);r.animations.push(x),o.animations.push(x),a+=c===0?`
|
||
Animations:`:"",a+=`
|
||
`+x.toString(l)}}if(s.materials!==void 0&&s.materials!==null)for(c=0,u=s.materials.length;c<u;c++){var R=s.materials[c],I=Lt.Parse(R,r,e);I&&(Vo[R.uniqueId||R.id]=I,o.materials.push(I),I._parentContainer=o,a+=c===0?`
|
||
Materials:`:"",a+=`
|
||
`+I.toString(l),I.getActiveTextures().forEach(function(St){o.textures.indexOf(St)==-1&&(o.textures.push(St),St._parentContainer=o)}))}if(s.multiMaterials!==void 0&&s.multiMaterials!==null)for(c=0,u=s.multiMaterials.length;c<u;c++){var M=s.multiMaterials[c],D=Vr.ParseMultiMaterial(M,r);Vo[M.uniqueId||M.id]=D,o.multiMaterials.push(D),D._parentContainer=o,a+=c===0?`
|
||
MultiMaterials:`:"",a+=`
|
||
`+D.toString(l),D.getActiveTextures().forEach(function(St){o.textures.indexOf(St)==-1&&(o.textures.push(St),St._parentContainer=o)})}if(s.morphTargetManagers!==void 0&&s.morphTargetManagers!==null)for(var B=0,F=s.morphTargetManagers;B<F.length;B++){var X=F[B],$=Tl.Parse(X,r);o.morphTargetManagers.push($),$._parentContainer=o}if(s.skeletons!==void 0&&s.skeletons!==null)for(c=0,u=s.skeletons.length;c<u;c++){var Q=s.skeletons[c],ie=xa.Parse(Q,r);o.skeletons.push(ie),ie._parentContainer=o,a+=c===0?`
|
||
Skeletons:`:"",a+=`
|
||
`+ie.toString(l)}var q=s.geometries;if(q!=null){var ee=new Array,te=q.vertexData;if(te!=null)for(c=0,u=te.length;c<u;c++){var ce=te[c];ee.push(Vi.Parse(ce,r,e))}ee.forEach(function(St){St&&(o.geometries.push(St),St._parentContainer=o)})}if(s.transformNodes!==void 0&&s.transformNodes!==null)for(c=0,u=s.transformNodes.length;c<u;c++){var fe=s.transformNodes[c],de=jt.Parse(fe,r,e);ds[fe.uniqueId]=de,o.transformNodes.push(de),de._parentContainer=o}if(s.meshes!==void 0&&s.meshes!==null)for(c=0,u=s.meshes.length;c<u;c++){var Te=s.meshes[c],ue=xe.Parse(Te,r,e);if(ds[Te.uniqueId]=ue,o.meshes.push(ue),ue._parentContainer=o,ue.hasInstances)for(var U=0,N=ue.instances;U<N.length;U++){var w=N[U];o.meshes.push(w),w._parentContainer=o}a+=c===0?`
|
||
Meshes:`:"",a+=`
|
||
`+ue.toString(l)}if(s.cameras!==void 0&&s.cameras!==null)for(c=0,u=s.cameras.length;c<u;c++){var k=s.cameras[c],J=Pt.Parse(k,r);ds[k.uniqueId]=J,o.cameras.push(J),J._parentContainer=o,a+=c===0?`
|
||
Cameras:`:"",a+=`
|
||
`+J.toString(l)}if(s.postProcesses!==void 0&&s.postProcesses!==null)for(c=0,u=s.postProcesses.length;c<u;c++){var le=s.postProcesses[c],be=_t.w.Parse(le,r,e);be&&(o.postProcesses.push(be),be._parentContainer=o,a+=c===0?`
|
||
Postprocesses:`:"",a+=`
|
||
`+be.toString())}if(s.animationGroups!==void 0&&s.animationGroups!==null)for(c=0,u=s.animationGroups.length;c<u;c++){var ve=s.animationGroups[c],ye=wi.Parse(ve,r);o.animationGroups.push(ye),ye._parentContainer=o,a+=c===0?`
|
||
AnimationGroups:`:"",a+=`
|
||
`+ye.toString(l)}if(s.spriteManagers)for(var Me=0,we=s.spriteManagers.length;Me<we;Me++){var He=s.spriteManagers[Me];a+=`
|
||
SpriteManager `+yh.Parse(He,r,e).name}for(c=0,u=r.cameras.length;c<u;c++)(J=r.cameras[c])._waitingParentId!==null&&(J.parent=bh(J._waitingParentId,J._waitingParentInstanceIndex,r),J._waitingParentId=null,J._waitingParentInstanceIndex=null);for(c=0,u=r.lights.length;c<u;c++)(Je=r.lights[c])&&Je._waitingParentId!==null&&(Je.parent=bh(Je._waitingParentId,Je._waitingParentInstanceIndex,r),Je._waitingParentId=null,Je._waitingParentInstanceIndex=null);for(c=0,u=r.transformNodes.length;c<u;c++){var Ke=r.transformNodes[c];Ke._waitingParentId!==null&&(Ke.parent=bh(Ke._waitingParentId,Ke._waitingParentInstanceIndex,r),Ke._waitingParentId=null,Ke._waitingParentInstanceIndex=null)}for(c=0,u=r.meshes.length;c<u;c++)(ue=r.meshes[c])._waitingParentId!==null&&(ue.parent=bh(ue._waitingParentId,ue._waitingParentInstanceIndex,r),ue._waitingParentId=null,ue._waitingParentInstanceIndex=null),ue._waitingData.lods&&bP(r,ue);for(r.multiMaterials.forEach(function(St){St._waitingSubMaterialsUniqueIds.forEach(function(Ot){St.subMaterials.push(Th(Ot,r))}),St._waitingSubMaterialsUniqueIds=[]}),r.meshes.forEach(function(St){St._waitingMaterialId!==null&&(St.material=Th(St._waitingMaterialId,r),St._waitingMaterialId=null)}),c=0,u=r.skeletons.length;c<u;c++)(ie=r.skeletons[c])._hasWaitingData&&(ie.bones!=null&&ie.bones.forEach(function(St){if(St._waitingTransformNodeId){var Ot=r.getLastEntryById(St._waitingTransformNodeId);Ot&&St.linkTransformNode(Ot),St._waitingTransformNodeId=null}}),ie._hasWaitingData=null);for(c=0,u=r.meshes.length;c<u;c++){var Qe=r.meshes[c];Qe._waitingData.freezeWorldMatrix?(Qe.freezeWorldMatrix(),Qe._waitingData.freezeWorldMatrix=null):Qe.computeWorldMatrix(!0)}for(c=0,u=r.lights.length;c<u;c++){var Je;if((Je=r.lights[c])._excludedMeshesIds.length>0){for(var ht=0;ht<Je._excludedMeshesIds.length;ht++){var mt=r.getMeshById(Je._excludedMeshesIds[ht]);mt&&Je.excludedMeshes.push(mt)}Je._excludedMeshesIds=[]}if(Je._includedOnlyMeshesIds.length>0){for(var yt=0;yt<Je._includedOnlyMeshesIds.length;yt++){var zt=r.getMeshById(Je._includedOnlyMeshesIds[yt]);zt&&Je.includedOnlyMeshes.push(zt)}Je._includedOnlyMeshesIds=[]}}for(r.geometries.forEach(function(St){St._loadedUniqueId=""}),nt.d.Parse(s,r,o,e),c=0,u=r.meshes.length;c<u;c++)(ue=r.meshes[c])._waitingData.actions&&(it.Parse(ue._waitingData.actions,ue,r),ue._waitingData.actions=null);s.actions!==void 0&&s.actions!==null&&it.Parse(s.actions,null,r)}catch(St){var $t=hs("loadAssets",s?s.producer:"Unknown")+a;if(!n)throw O.V.Log($t),St;n($t,St)}finally{ds={},Vo={},i||o.removeAllFromScene(),a!==null&&yn.loggingLevel!==yn.NO_LOGGING&&O.V.Log(hs("loadAssets",s?s.producer:"Unknown")+(yn.loggingLevel!==yn.MINIMAL_LOGGING?a:""))}return o};yn.RegisterPlugin({name:"babylon.js",extensions:".babylon",canDirectLoad:function(r){return r.indexOf("babylon")!==-1},importMesh:function(r,t,e,n,i,o,a,s){var l,c="importMesh has failed JSON parse";try{var u=JSON.parse(e);c="";var d=yn.loggingLevel===yn.DETAILED_LOGGING;r?Array.isArray(r)||(r=[r]):r=null;var h=[],p=new Map,m=[];if(u.transformNodes!==void 0&&u.transformNodes!==null)for(var v=0,b=u.transformNodes.length;v<b;v++){var E=u.transformNodes[v],C=jt.Parse(E,t,n);m.push(C),p.set(C._waitingParsedUniqueId,C),C._waitingParsedUniqueId=null}if(u.meshes!==void 0&&u.meshes!==null){var T=[],f=[],g=[],S=[],y=function(ee,te){var ce=u.meshes[ee];if(r===null||function(Je,ht,mt){for(var yt in ht)if(Je.name===ht[yt])return mt.push(Je.id),!0;return Je.parentId!==void 0&&mt.indexOf(Je.parentId)!==-1&&(mt.push(Je.id),!0)}(ce,r,h)){if(r!==null&&delete r[r.indexOf(ce.name)],ce.geometryId!==void 0&&ce.geometryId!==null&&u.geometries!==void 0&&u.geometries!==null){var fe=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach(function(Je){fe!==!0&&u.geometries[Je]&&Array.isArray(u.geometries[Je])&&u.geometries[Je].forEach(function(ht){ht.id===ce.geometryId&&(Je==="vertexData"&&Vi.Parse(ht,t,n),fe=!0)})}),fe===!1&&O.V.Warn("Geometry not found for mesh "+ce.id)}if(ce.materialUniqueId||ce.materialId){var de=ce.materialUniqueId?g:f,Te=de.indexOf(ce.materialUniqueId||ce.materialId)!==-1;if(Te===!1&&u.multiMaterials!==void 0&&u.multiMaterials!==null)for(var ue=function(Je,ht){de.push(Je);var mt=yP(ht,u,t,n);mt&&mt.material&&(Vo[mt.parsedMaterial.uniqueId||mt.parsedMaterial.id]=mt.material,c+=`
|
||
Material `+mt.material.toString(d))},U=0,N=u.multiMaterials.length;U<N;U++){var w=u.multiMaterials[U];if(ce.materialUniqueId&&w.uniqueId===ce.materialUniqueId||w.id===ce.materialId){w.materialsUniqueIds?w.materialsUniqueIds.forEach(function(Je){return ue(Je,function(ht){return ht.uniqueId===Je})}):w.materials.forEach(function(Je){return ue(Je,function(ht){return ht.id===Je})}),de.push(w.uniqueId||w.id);var k=Vr.ParseMultiMaterial(w,t);Vo[w.uniqueId||w.id]=k,k&&(Te=!0,c+=`
|
||
Multi-Material `+k.toString(d));break}}if(Te===!1){de.push(ce.materialUniqueId||ce.materialId);var J=yP(function(Je){return ce.materialUniqueId&&Je.uniqueId===ce.materialUniqueId||Je.id===ce.materialId},u,t,n);J&&J.material?(Vo[J.parsedMaterial.uniqueId||J.parsedMaterial.id]=J.material,c+=`
|
||
Material `+J.material.toString(d)):O.V.Warn("Material not found for mesh "+ce.id)}}if(ce.skeletonId!==null&&ce.skeletonId!==void 0&&u.skeletonId!==-1&&u.skeletons!==void 0&&u.skeletons!==null&&!(T.indexOf(ce.skeletonId)>-1))for(var le=0,be=u.skeletons.length;le<be;le++){var ve=u.skeletons[le];if(ve.id===ce.skeletonId){var ye=xa.Parse(ve,t);a.push(ye),T.push(ve.id),c+=`
|
||
Skeleton `+ye.toString(d)}}if(ce.morphTargetManagerId>-1&&u.morphTargetManagers!==void 0&&u.morphTargetManagers!==null&&!(S.indexOf(ce.morphTargetManagerId)>-1))for(var Me=0,we=u.morphTargetManagers.length;Me<we;Me++){var He=u.morphTargetManagers[Me];if(He.id===ce.morphTargetManagerId){var Ke=Tl.Parse(He,t);S.push(Ke.uniqueId),c+=`
|
||
Morph target `+Ke.toString()}}var Qe=xe.Parse(ce,t,n);i.push(Qe),p.set(Qe._waitingParsedUniqueId,Qe),Qe._waitingParsedUniqueId=null,c+=`
|
||
Mesh `+Qe.toString(d)}};for(v=0,b=u.meshes.length;v<b;v++)y(v);for(t.multiMaterials.forEach(function(ee){ee._waitingSubMaterialsUniqueIds.forEach(function(te){ee.subMaterials.push(Th(te,t))}),ee._waitingSubMaterialsUniqueIds=[]}),t.meshes.forEach(function(ee){ee._waitingMaterialId!==null&&(ee.material=Th(ee._waitingMaterialId,t),ee._waitingMaterialId=null)}),v=0,b=t.transformNodes.length;v<b;v++)if((X=t.transformNodes[v])._waitingParentId!==null){var x=p.get(parseInt(X._waitingParentId))||null;x===null&&(x=t.getLastEntryById(X._waitingParentId));var R=x;X._waitingParentInstanceIndex&&(R=x.instances[parseInt(X._waitingParentInstanceIndex)],X._waitingParentInstanceIndex=null),X.parent=R,X._waitingParentId=null}var I=void 0;for(v=0,b=t.meshes.length;v<b;v++){if((I=t.meshes[v])._waitingParentId){var M=p.get(parseInt(I._waitingParentId))||null;if(M===null&&(M=t.getLastEntryById(I._waitingParentId)),R=M,I._waitingParentInstanceIndex&&(R=M.instances[parseInt(I._waitingParentInstanceIndex)],I._waitingParentInstanceIndex=null),I.parent=R,((l=I.parent)===null||l===void 0?void 0:l.getClassName())==="TransformNode"){var D=m.indexOf(I.parent);D>-1&&m.splice(D,1)}I._waitingParentId=null}I._waitingData.lods&&bP(t,I)}for(var B=0,F=m;B<F.length;B++){var X;(X=F[B]).dispose()}for(v=0,b=t.skeletons.length;v<b;v++){var $=t.skeletons[v];$._hasWaitingData&&($.bones!=null&&$.bones.forEach(function(ee){if(ee._waitingTransformNodeId){var te=t.getLastEntryById(ee._waitingTransformNodeId);te&&ee.linkTransformNode(te),ee._waitingTransformNodeId=null}}),$._hasWaitingData=null)}for(v=0,b=t.meshes.length;v<b;v++)(I=t.meshes[v])._waitingData.freezeWorldMatrix?(I.freezeWorldMatrix(),I._waitingData.freezeWorldMatrix=null):I.computeWorldMatrix(!0)}if(u.particleSystems!==void 0&&u.particleSystems!==null){var Q=nt.d.GetIndividualParser(lt.v.NAME_PARTICLESYSTEM);if(Q)for(v=0,b=u.particleSystems.length;v<b;v++){var ie=u.particleSystems[v];h.indexOf(ie.emitterId)!==-1&&o.push(Q(ie,t,n))}}return t.geometries.forEach(function(ee){ee._loadedUniqueId=""}),!0}catch(ee){var q=hs("importMesh",u?u.producer:"Unknown")+c;if(!s)throw O.V.Log(q),ee;s(q,ee)}finally{c!==null&&yn.loggingLevel!==yn.NO_LOGGING&&O.V.Log(hs("importMesh",u?u.producer:"Unknown")+(yn.loggingLevel!==yn.MINIMAL_LOGGING?c:"")),Vo={}}return!1},load:function(r,t,e,n){var i="importScene has failed JSON parse";try{var o=JSON.parse(t);switch(i="",o.useDelayedTextureLoading!==void 0&&o.useDelayedTextureLoading!==null&&(r.useDelayedTextureLoading=o.useDelayedTextureLoading&&!yn.ForceFullSceneLoadingForIncremental),o.autoClear!==void 0&&o.autoClear!==null&&(r.autoClear=o.autoClear),o.clearColor!==void 0&&o.clearColor!==null&&(r.clearColor=z.ov.FromArray(o.clearColor)),o.ambientColor!==void 0&&o.ambientColor!==null&&(r.ambientColor=z.v9.FromArray(o.ambientColor)),o.gravity!==void 0&&o.gravity!==null&&(r.gravity=_.Pq.FromArray(o.gravity)),o.useRightHandedSystem!==void 0&&(r.useRightHandedSystem=!!o.useRightHandedSystem),o.fogMode!==void 0&&o.fogMode!==null&&(r.fogMode=o.fogMode),o.fogColor!==void 0&&o.fogColor!==null&&(r.fogColor=z.v9.FromArray(o.fogColor)),o.fogStart!==void 0&&o.fogStart!==null&&(r.fogStart=o.fogStart),o.fogEnd!==void 0&&o.fogEnd!==null&&(r.fogEnd=o.fogEnd),o.fogDensity!==void 0&&o.fogDensity!==null&&(r.fogDensity=o.fogDensity),i+=" Fog mode for scene: ",r.fogMode){case 0:i+=`none
|
||
`;break;case 1:i+=`exp
|
||
`;break;case 2:i+=`exp2
|
||
`;break;case 3:i+=`linear
|
||
`}if(o.physicsEnabled){var a=void 0;o.physicsEngine==="cannon"||o.physicsEngine===Sl.name?a=new Sl(void 0,void 0,El.LoaderInjectedPhysicsEngine):o.physicsEngine==="oimo"||o.physicsEngine===mh.name?a=new mh(void 0,El.LoaderInjectedPhysicsEngine):o.physicsEngine!=="ammo"&&o.physicsEngine!==gh.name||(a=new gh(void 0,El.LoaderInjectedPhysicsEngine,void 0)),i=" Physics engine "+(o.physicsEngine?o.physicsEngine:"oimo")+` enabled
|
||
`;var s=o.gravity?_.Pq.FromArray(o.gravity):o.physicsGravity?_.Pq.FromArray(o.physicsGravity):null;r.enablePhysics(s,a)}return o.metadata!==void 0&&o.metadata!==null&&(r.metadata=o.metadata),o.collisionsEnabled!==void 0&&o.collisionsEnabled!==null&&(r.collisionsEnabled=o.collisionsEnabled),!!TP(r,t,e,n,!0)&&(o.autoAnimate&&r.beginAnimation(r,o.autoAnimateFrom,o.autoAnimateTo,o.autoAnimateLoop,o.autoAnimateSpeed||1),o.activeCameraID!==void 0&&o.activeCameraID!==null&&r.setActiveCameraById(o.activeCameraID),!0)}catch(c){var l=hs("importScene",o?o.producer:"Unknown")+i;if(!n)throw O.V.Log(l),c;n(l,c)}finally{i!==null&&yn.loggingLevel!==yn.NO_LOGGING&&O.V.Log(hs("importScene",o?o.producer:"Unknown")+(yn.loggingLevel!==yn.MINIMAL_LOGGING?i:""))}return!1},loadAssetContainer:function(r,t,e,n){return TP(r,t,e,n)}});var SP=L(71433),EP=L(40387),xP=L(57826),PP=L(7590),AP=L(76331),Dv=function(){function r(t){t===void 0&&(t={}),this._isEnabled=!0,this.bias=t.bias===void 0?0:t.bias,this.power=t.power===void 0?1:t.power,this.leftColor=t.leftColor||z.v9.White(),this.rightColor=t.rightColor||z.v9.Black(),t.isEnabled===!1&&(this.isEnabled=!1)}return Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,Be.$.MarkAllMaterialsAsDirty(P.Y.MATERIAL_FresnelDirtyFlag|P.Y.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),r.prototype.clone=function(){var t=new r;return ot.r.DeepCopy(this,t),t},r.prototype.equals=function(t){return t&&this.bias===t.bias&&this.power===t.power&&this.leftColor.equals(t.leftColor)&&this.rightColor.equals(t.rightColor)&&this.isEnabled===t.isEnabled},r.prototype.serialize=function(){return{isEnabled:this.isEnabled,leftColor:this.leftColor.asArray(),rightColor:this.rightColor.asArray(),bias:this.bias,power:this.power}},r.Parse=function(t){return new r({isEnabled:t.isEnabled,leftColor:z.v9.FromArray(t.leftColor),rightColor:z.v9.FromArray(t.rightColor),bias:t.bias,power:t.power||1})},r}();tt.p._FresnelParametersParser=Dv.Parse;var CP=function(){function r(){}return r.BindSceneUniformBuffer=Re._8,r.PrepareDefinesForMergedUV=Re.YT,r.BindTextureMatrix=Re.mA,r.GetFogState=Re.qL,r.PrepareDefinesForMisc=Re.fm,r.PrepareDefinesForCamera=Re.Y7,r.PrepareDefinesForFrameBoundValues=Re.OR,r.PrepareDefinesForBones=Re.IC,r.PrepareDefinesForMorphTargets=Re.Jz,r.PrepareDefinesForBakedVertexAnimation=Re.wu,r.PrepareDefinesForAttributes=Re.qB,r.PrepareDefinesForMultiview=Re.VO,r.PrepareDefinesForOIT=Re.Nc,r.PrepareDefinesForPrePass=Re.N4,r.PrepareDefinesForLight=Re.lo,r.PrepareDefinesForLights=Re.az,r.PrepareUniformsAndSamplersForLight=Re.GD,r.PrepareUniformsAndSamplersList=Re.Bb,r.HandleFallbacksForShadows=Re.c4,r.PrepareAttributesForMorphTargetsInfluencers=Re.MF,r.PrepareAttributesForMorphTargets=Re.IF,r.PrepareAttributesForBakedVertexAnimation=Re.J2,r.PrepareAttributesForBones=Re.ni,r.PrepareAttributesForInstances=Re.ER,r.PushAttributesForInstances=Re.te,r.BindLightProperties=Re.L0,r.BindLight=Re.Kd,r.BindLights=Re.RL,r.BindFogParameters=Re.Yy,r.BindBonesParameters=Re.f$,r.BindMorphTargetParameters=Re.nR,r.BindLogDepth=Re.DL,r}(),RP=L(38589),IP=L(32755),MP=function(r){function t(e,n){var i=r.call(this,e,n,"color",{attributes:["position"],uniforms:["world","viewProjection","color"]})||this;return i.disableColorWrite=!0,i.forceDepthWrite=!0,i.setColor4("color",new z.ov(0,0,0,1)),i}return(0,A.C6)(t,r),t}(pi),Sh=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.maxSimultaneousLights=4,i.disableLighting=!1,i.invertNormalMapX=!1,i.invertNormalMapY=!1,i.emissiveColor=new z.v9(0,0,0),i.occlusionStrength=1,i.useLightmapAsShadowmap=!1,i._useAlphaFromAlbedoTexture=!0,i._useAmbientInGrayScale=!0,i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],t.prototype,"environmentTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],t.prototype,"normalTexture",void 0),(0,A.Cg)([(0,V.jT)("emissive"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],t.prototype,"occlusionStrength",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],t.prototype,"occlusionTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],t.prototype,"alphaCutOff",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"doubleSided",null),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),t}(Tn),Nv=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i._useRoughnessFromMetallicTextureAlpha=!1,i._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i.metallic=1,i.roughness=1,i}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},t.prototype.clone=function(e){var n=this,i=tt.p.Clone(function(){return new t(e,n.getScene())},this);return i.id=e,i.name=e,this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),this.subSurface.copyTo(i.subSurface),i},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.customType="BABYLON.PBRMetallicRoughnessMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e.iridescence=this.iridescence.serialize(),e},t.Parse=function(e,n,i){var o=tt.p.Parse(function(){return new t(e.name,n)},e,n,i);return e.clearCoat&&o.clearCoat.parse(e.clearCoat,n,i),e.anisotropy&&o.anisotropy.parse(e.anisotropy,n,i),e.brdf&&o.brdf.parse(e.brdf,n,i),e.sheen&&o.sheen.parse(e.sheen,n,i),e.subSurface&&o.subSurface.parse(e.subSurface,n,i),e.iridescence&&o.iridescence.parse(e.iridescence,n,i),o},(0,A.Cg)([(0,V.jT)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),t}(Sh);(0,j.Y5)("BABYLON.PBRMetallicRoughnessMaterial",Nv);var Lv=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i._useMicroSurfaceFromReflectivityMapAlpha=!0,i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",{get:function(){return this._useMicroSurfaceFromReflectivityMapAlpha},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},t.prototype.clone=function(e){var n=this,i=tt.p.Clone(function(){return new t(e,n.getScene())},this);return i.id=e,i.name=e,this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),this.subSurface.copyTo(i.subSurface),i},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.customType="BABYLON.PBRSpecularGlossinessMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e.iridescence=this.iridescence.serialize(),e},t.Parse=function(e,n,i){var o=tt.p.Parse(function(){return new t(e.name,n)},e,n,i);return e.clearCoat&&o.clearCoat.parse(e.clearCoat,n,i),e.anisotropy&&o.anisotropy.parse(e.anisotropy,n,i),e.brdf&&o.brdf.parse(e.brdf,n,i),e.sheen&&o.sheen.parse(e.sheen,n,i),e.subSurface&&o.subSurface.parse(e.subSurface,n,i),e.iridescence&&o.iridescence.parse(e.iridescence,n,i),o},(0,A.Cg)([(0,V.jT)("diffuse"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),(0,A.Cg)([(0,V.jT)("specular"),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),(0,A.Cg)([(0,V.uM)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),t}(Sh);(0,j.Y5)("BABYLON.PBRSpecularGlossinessMaterial",Lv);var Eh,OP=L(10721),DP=L(36934),NP=L(17152),LP=L(62338);(function(r){r[r.GLSL=0]="GLSL",r[r.WGSL=1]="WGSL"})(Eh||(Eh={}));var Fv=function(r){function t(e,n,i){i===void 0&&(i=null);var o=r.call(this,n)||this;if(!e)return o;if(o._textureMatrix=_.uq.Identity(),o.name=e,o.url=e,o._onLoad=i,o._texture=o._getFromCache(e,!0),o._texture)o._triggerOnLoad();else{var a=o.getScene();a&&a.useDelayedTextureLoading?o.delayLoadState=P.Y.DELAYLOADSTATE_NOTLOADED:o._loadTexture()}return o}return(0,A.C6)(t,r),t.prototype._triggerOnLoad=function(){this._onLoad&&this._onLoad()},t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype._load3dlTexture=function(){var e,n=this,i=this._getEngine();e=i._features.support3DTextures?i.createRawTexture3D(null,1,1,1,P.Y.TEXTUREFORMAT_RGBA,!1,!1,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,null,P.Y.TEXTURETYPE_UNSIGNED_INT):i.createRawTexture(null,1,1,P.Y.TEXTUREFORMAT_RGBA,!1,!1,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,null,P.Y.TEXTURETYPE_UNSIGNED_INT),this._texture=e,this._texture.isReady=!1,this.isCube=!1,this.is3D=i._features.support3DTextures,this.wrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,this.wrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE,this.wrapR=P.Y.TEXTURE_CLAMP_ADDRESSMODE,this.anisotropicFilteringLevel=1;var o=function(s){if(typeof s=="string"){for(var l,c=null,u=null,d=s.split(`
|
||
`),h=0,p=0,m=0,v=0,b=0,E=0;E<d.length;E++)if(l=d[E],t._NoneEmptyLineRegex.test(l)&&l.indexOf("#")!==0){var C=l.split(" ");if(h!==0){if(h!=0){var T=Math.max(parseInt(C[0]),0),f=Math.max(parseInt(C[1]),0),g=Math.max(parseInt(C[2]),0);b=Math.max(T,b),b=Math.max(f,b),b=Math.max(g,b);var S=4*(p+v*h+m*h*h);u&&(u[S+0]=T,u[S+1]=f,u[S+2]=g),++m%h==0&&(m=0,++v%h==0&&(p++,v=0))}}else h=C.length,c=new Uint8Array(h*h*h*4),u=new Float32Array(h*h*h*4)}if(u&&c)for(E=0;E<u.length;E++)if(E>0&&(E+1)%4==0)c[E]=255;else{var y=u[E];c[E]=y/b*255}e.is3D?(e.updateSize(h,h,h),i.updateRawTexture3D(e,c,P.Y.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(h*h,h),i.updateRawTexture(e,c,P.Y.TEXTUREFORMAT_RGBA,!1)),e.isReady=!0,n._triggerOnLoad()}},a=this.getScene();return a?a._loadFile(this.url,o):i._loadFile(this.url,o),this._texture},t.prototype._loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this._load3dlTexture()},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine());return e.level=this.level,e},t.prototype.delayLoad=function(){this.delayLoadState===P.Y.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=P.Y.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this._loadTexture())},t.Parse=function(e,n){var i=null;return e.name&&!e.isRenderTarget&&((i=new t(e.name,n)).name=e.name,i.level=e.level),i},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},t._NoneEmptyLineRegex=/\S+/,t}(Ki.t);(0,j.Y5)("BABYLON.ColorGradingTexture",Fv);var wv=L(16814),Bv=function(r){function t(e,n,i,o,a,s,l,c){o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=null),l===void 0&&(l=null),c===void 0&&(c=!1);var u=r.call(this,n)||this;if(u._onLoad=null,u._onError=null,!e)throw new Error("Image url is not set");return u._coordinatesMode=Ie.g.CUBIC_MODE,u.name=e,u.url=e,u._size=i,u._supersample=c,u._noMipmap=o,u.gammaSpace=a,u._onLoad=s,u._onError=l,u.hasAlpha=!1,u.isCube=!0,u._texture=u._getFromCache(e,u._noMipmap,void 0,void 0,void 0,u.isCube),u._texture?s&&(u._texture.isReady?ze.S0.SetImmediate(function(){return s()}):u._texture.onLoadedObservable.add(s)):n.useDelayedTextureLoading?u.delayLoadState=P.Y.DELAYLOADSTATE_NOTLOADED:u._loadImage(function(){return u._loadTexture()},u._onError),u}return(0,A.C6)(t,r),t.prototype._loadImage=function(e,n){var i=this,o=this.getScene();if(o){var a=o.getEngine().createRawCubeTexture(null,this._size,P.Y.TEXTUREFORMAT_RGB,o.getEngine().getCaps().textureFloat?P.Y.TEXTURETYPE_FLOAT:P.Y.TEXTURETYPE_UNSIGNED_INTEGER,!this._noMipmap,!1,P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE);a.generateMipMaps=!this._noMipmap,o.addPendingData(a),a.url=this.url,a.isReady=!1,o.getEngine()._internalTexturesCache.push(a),this._texture=a;var s=document.createElement("canvas");(0,hn.W$)(this.url,function(l){i._width=l.width,i._height=l.height,s.width=i._width,s.height=i._height;var c=s.getContext("2d");c.drawImage(l,0,0);var u=c.getImageData(0,0,l.width,l.height);i._buffer=u.data.buffer,s.remove(),e()},function(l,c){o.removePendingData(a),n&&n("".concat(i.getClassName()," could not be loaded"),c)},o?o.offlineProvider:null)}},t.prototype._loadTexture=function(){var e=this,n=this.getScene();if(n){var i=function(){for(var a=e._getFloat32ArrayFromArrayBuffer(e._buffer),s=wv.D.ConvertPanoramaToCubemap(a,e._width,e._height,e._size,e._supersample),l=[],c=0;c<6;c++){var u=s[t._FacesMapping[c]];l.push(u)}return l}(),o=this._texture;n.getEngine().updateRawCubeTexture(o,i,o.format,o.type,o.invertY),o.isReady=!0,n.removePendingData(o),o.onLoadedObservable.notifyObservers(o),o.onLoadedObservable.clear(),this._onLoad&&this._onLoad()}},t.prototype._getFloat32ArrayFromArrayBuffer=function(e){for(var n=new DataView(e),i=new Float32Array(3*e.byteLength/4),o=0,a=0;a<e.byteLength;a++)(a+1)%4!=0&&(i[o++]=n.getUint8(a)/255);return i},t.prototype.getClassName=function(){return"EquiRectangularCubeTexture"},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=new t(this.url,e,this._size,this._noMipmap,this.gammaSpace);return n.level=this.level,n.wrapU=this.wrapU,n.wrapV=this.wrapV,n.coordinatesIndex=this.coordinatesIndex,n.coordinatesMode=this.coordinatesMode,n},t._FacesMapping=["right","left","up","down","front","back"],t}(Ki.t),FP=function(r){function t(e,n,i){var o=r.call(this,i.scene||i.engine)||this;if(o.onLoadObservable=new K.cP,!n||!i.engine&&!i.scene)return o;if(i=(0,A.Cl)((0,A.Cl)({},t._DefaultOptions),i),o._generateMipMaps=i.generateMipMaps,o._samplingMode=i.samplingMode,o._textureMatrix=_.uq.Identity(),o._format=i.format,o.name=e,o.element=n,o._isVideo=!!n.getVideoPlaybackQuality,o._isVideo){var a=o._engine,s=a?.createExternalTexture;s&&(o._externalTexture=s.call(a,n))}return o.anisotropicFilteringLevel=1,o._createInternalTexture(),o}return(0,A.C6)(t,r),t.prototype._createInternalTexture=function(){var e=0,n=0;this._isVideo?(e=this.element.videoWidth,n=this.element.videoHeight):(e=this.element.width,n=this.element.height);var i=this._getEngine();i&&(this._texture=i.createDynamicTexture(e,n,this._generateMipMaps,this._samplingMode),this._texture.format=this._format),this.update()},t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.update=function(e){e===void 0&&(e=null);var n=this._getEngine();if(this._texture!=null&&n!=null){var i=this.isReady();if(this._isVideo){var o=this.element;if(o.readyState<o.HAVE_CURRENT_DATA)return;n.updateVideoTexture(this._texture,this._externalTexture?this._externalTexture:o,e===null||e)}else{var a=this.element;n.updateDynamicTexture(this._texture,a,e===null||e,!1,this._format)}!i&&this.isReady()&&this.onLoadObservable.notifyObservers(this)}},t.prototype.dispose=function(){this.onLoadObservable.clear(),r.prototype.dispose.call(this)},t._DefaultOptions={generateMipMaps:!1,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,format:P.Y.TEXTUREFORMAT_RGBA,engine:null,scene:null},t}(Ki.t),wP=L(5996),BP=L(78750),VP=L(23586),UP=L(93747),lo=L(8102),Uo=L(50919),GP=L(51289),xh=L(54646),Mn=L(45109),Ph=L(99448),kP=L(95487),Kr=function(r){function t(e,n,i,o,a,s){var l=this,c=!(!a||!a.generateMipMaps)&&a.generateMipMaps,u=!(!a||!a.generateDepthTexture)&&a.generateDepthTexture,d=a&&a.depthTextureFormat?a.depthTextureFormat:P.Y.TEXTUREFORMAT_DEPTH16,h=!a||a.doNotChangeAspectRatio===void 0||a.doNotChangeAspectRatio,p=!(!a||!a.drawOnlyOnFirstAttachmentByDefault)&&a.drawOnlyOnFirstAttachmentByDefault;if(!(l=r.call(this,e,n,o,c,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0)||this).isSupported)return l.dispose(),l;l._textureNames=s;var m=[],v=[],b=[],E=[],C=[],T=[],f=[],g=[];l._initTypes(i,m,v,b,E,C,T,f,g,a);var S=!a||a.generateDepthBuffer===void 0||a.generateDepthBuffer,y=!(!a||a.generateStencilBuffer===void 0)&&a.generateStencilBuffer;return l._multiRenderTargetOptions={samplingModes:v,generateMipMaps:c,generateDepthBuffer:S,generateStencilBuffer:y,generateDepthTexture:u,depthTextureFormat:d,types:m,textureCount:i,useSRGBBuffers:b,formats:E,targetTypes:C,faceIndex:T,layerIndex:f,layerCounts:g,labels:s,label:e},l._count=i,l._drawOnlyOnFirstAttachmentByDefault=p,i>0&&(l._createInternalTextures(),l._createTextures(s)),l}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"isSupported",{get:function(){var e,n;return(n=(e=this._engine)===null||e===void 0?void 0:e.getCaps().drawBuffersExtension)!==null&&n!==void 0&&n},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var n=0;n<this._textures.length;n++)this._textures[n].wrapU=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapV",{set:function(e){if(this._textures)for(var n=0;n<this._textures.length;n++)this._textures[n].wrapV=e},enumerable:!1,configurable:!0}),t.prototype._initTypes=function(e,n,i,o,a,s,l,c,u,d){for(var h=0;h<e;h++)d&&d.types&&d.types[h]!==void 0?n.push(d.types[h]):n.push(d&&d.defaultType?d.defaultType:P.Y.TEXTURETYPE_UNSIGNED_INT),d&&d.samplingModes&&d.samplingModes[h]!==void 0?i.push(d.samplingModes[h]):i.push(Ie.g.BILINEAR_SAMPLINGMODE),d&&d.useSRGBBuffers&&d.useSRGBBuffers[h]!==void 0?o.push(d.useSRGBBuffers[h]):o.push(!1),d&&d.formats&&d.formats[h]!==void 0?a.push(d.formats[h]):a.push(P.Y.TEXTUREFORMAT_RGBA),d&&d.targetTypes&&d.targetTypes[h]!==void 0?s.push(d.targetTypes[h]):s.push(P.Y.TEXTURE_2D),d&&d.faceIndex&&d.faceIndex[h]!==void 0?l.push(d.faceIndex[h]):l.push(0),d&&d.layerIndex&&d.layerIndex[h]!==void 0?c.push(d.layerIndex[h]):c.push(0),d&&d.layerCounts&&d.layerCounts[h]!==void 0?u.push(d.layerCounts[h]):u.push(1)},t.prototype._createInternaTextureIndexMapping=function(){var e={},n=[];if(!this._renderTarget)return n;for(var i=this._renderTarget.textures,o=0;o<i.length;o++){var a=i[o];if(a){var s=e[a.uniqueId];s!==void 0?n[o]=s:e[a.uniqueId]=o}}return n},t.prototype._rebuild=function(e,n,i){if(e===void 0&&(e=!1),n===void 0&&(n=!1),!(this._count<1||e)){var o=this._createInternaTextureIndexMapping();this.releaseInternalTextures(),this._createInternalTextures(),n&&(this._releaseTextures(),this._createTextures(i));for(var a=this._renderTarget.textures,s=0;s<a.length;s++){var l=this._textures[s];o[s]!==void 0&&this._renderTarget.setTexture(a[o[s]],s),l._texture=a[s],l._texture&&(l._noMipmap=!l._texture.useMipMaps,l._useSRGBBuffer=l._texture._useSRGBBuffer)}this.samples!==1&&this._renderTarget.setSamples(this.samples,!this._drawOnlyOnFirstAttachmentByDefault,!0)}},t.prototype._createInternalTextures=function(){this._renderTarget=this._getEngine().createMultipleRenderTarget(this._size,this._multiRenderTargetOptions,!this._drawOnlyOnFirstAttachmentByDefault),this._texture=this._renderTarget.texture},t.prototype._releaseTextures=function(){if(this._textures)for(var e=0;e<this._textures.length;e++)this._textures[e]._texture=null,this._textures[e].dispose()},t.prototype._createTextures=function(e){var n=this._renderTarget.textures;this._textures=[];for(var i=0;i<n.length;i++){var o=new Ie.g(null,this.getScene());e?.[i]&&(o.name=e[i]),o._texture=n[i],o._texture&&(o._noMipmap=!o._texture.useMipMaps,o._useSRGBBuffer=o._texture._useSRGBBuffer),this._textures.push(o)}},t.prototype.setInternalTexture=function(e,n,i){var o,a;if(i===void 0&&(i=!0),this.renderTarget&&(n===0&&(this._texture=e),this.renderTarget.setTexture(e,n,i),this.textures[n]||(this.textures[n]=new Ie.g(null,this.getScene()),this.textures[n].name=(a=(o=this._textureNames)===null||o===void 0?void 0:o[n])!==null&&a!==void 0?a:this.textures[n].name),this.textures[n]._texture=e,this.textures[n]._noMipmap=!e.useMipMaps,this.textures[n]._useSRGBBuffer=e._useSRGBBuffer,this._count=this.renderTarget.textures?this.renderTarget.textures.length:0,this._multiRenderTargetOptions.types&&(this._multiRenderTargetOptions.types[n]=e.type),this._multiRenderTargetOptions.samplingModes&&(this._multiRenderTargetOptions.samplingModes[n]=e.samplingMode),this._multiRenderTargetOptions.useSRGBBuffers&&(this._multiRenderTargetOptions.useSRGBBuffers[n]=e._useSRGBBuffer),this._multiRenderTargetOptions.targetTypes&&this._multiRenderTargetOptions.targetTypes[n]!==-1)){var s;s=e.is2DArray?P.Y.TEXTURE_2D_ARRAY:e.isCube?P.Y.TEXTURE_CUBE_MAP:e.is3D?P.Y.TEXTURE_3D:P.Y.TEXTURE_2D,this._multiRenderTargetOptions.targetTypes[n]=s}},t.prototype.setLayerAndFaceIndex=function(e,n,i){n===void 0&&(n=-1),i===void 0&&(i=-1),this.textures[e]&&this.renderTarget&&(this._multiRenderTargetOptions.layerIndex&&(this._multiRenderTargetOptions.layerIndex[e]=n),this._multiRenderTargetOptions.faceIndex&&(this._multiRenderTargetOptions.faceIndex[e]=i),this.renderTarget.setLayerAndFaceIndex(e,n,i))},t.prototype.setLayerAndFaceIndices=function(e,n){this.renderTarget&&(this._multiRenderTargetOptions.layerIndex=e,this._multiRenderTargetOptions.faceIndex=n,this.renderTarget.setLayerAndFaceIndices(e,n))},Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._renderTarget?this._samples=this._renderTarget.setSamples(e):this._samples=e},enumerable:!1,configurable:!0}),t.prototype.resize=function(e){this._processSizeParameter(e,!1),this._rebuild(!1,void 0,this._textureNames)},t.prototype.updateCount=function(e,n,i){this._multiRenderTargetOptions.textureCount=e,this._count=e;var o=[],a=[],s=[],l=[],c=[],u=[],d=[],h=[];this._textureNames=i,this._initTypes(e,o,a,s,l,c,u,d,h,n),this._multiRenderTargetOptions.types=o,this._multiRenderTargetOptions.samplingModes=a,this._multiRenderTargetOptions.useSRGBBuffers=s,this._multiRenderTargetOptions.formats=l,this._multiRenderTargetOptions.targetTypes=c,this._multiRenderTargetOptions.faceIndex=u,this._multiRenderTargetOptions.layerIndex=d,this._multiRenderTargetOptions.layerCounts=h,this._multiRenderTargetOptions.labels=i,this._rebuild(!1,!0,i)},t.prototype._unbindFrameBuffer=function(e,n){var i=this;this._renderTarget&&e.unBindMultiColorAttachmentFramebuffer(this._renderTarget,this.isCube,function(){i.onAfterRenderObservable.notifyObservers(n)})},t.prototype.dispose=function(e){e===void 0&&(e=!1),this._releaseTextures(),e?this._texture=null:this.releaseInternalTextures(),r.prototype.dispose.call(this)},t.prototype.releaseInternalTextures=function(){var e,n,i=(e=this._renderTarget)===null||e===void 0?void 0:e.textures;if(i){for(var o=i.length-1;o>=0;o--)this._textures[o]._texture=null;(n=this._renderTarget)===null||n===void 0||n.dispose(),this._renderTarget=null}},t}(un.$),Ah=function(r,t,e){this.id=r,this.scale=t,this.offset=e},zP=function(){function r(t,e,n,i){var o,a,s,l,c,u,d,h,p,m,v,b,E;return this.name=t,this.meshes=e,this.scene=i,this.options=n,this.options.map=(o=this.options.map)!==null&&o!==void 0?o:["ambientTexture","bumpTexture","diffuseTexture","emissiveTexture","lightmapTexture","opacityTexture","reflectionTexture","refractionTexture","specularTexture"],this.options.uvsIn=(a=this.options.uvsIn)!==null&&a!==void 0?a:Y.R.UVKind,this.options.uvsOut=(s=this.options.uvsOut)!==null&&s!==void 0?s:Y.R.UVKind,this.options.layout=(l=this.options.layout)!==null&&l!==void 0?l:r.LAYOUT_STRIP,this.options.layout===r.LAYOUT_COLNUM&&(this.options.colnum=(c=this.options.colnum)!==null&&c!==void 0?c:8),this.options.updateInputMeshes=(u=this.options.updateInputMeshes)===null||u===void 0||u,this.options.disposeSources=(d=this.options.disposeSources)===null||d===void 0||d,this._expecting=0,this.options.fillBlanks=(h=this.options.fillBlanks)===null||h===void 0||h,this.options.fillBlanks===!0&&(this.options.customFillColor=(p=this.options.customFillColor)!==null&&p!==void 0?p:"black"),this.options.frameSize=(m=this.options.frameSize)!==null&&m!==void 0?m:256,this.options.paddingRatio=(v=this.options.paddingRatio)!==null&&v!==void 0?v:.0115,this._paddingValue=Math.ceil(this.options.frameSize*this.options.paddingRatio),this._paddingValue%2!=0&&this._paddingValue++,this.options.paddingMode=(b=this.options.paddingMode)!==null&&b!==void 0?b:r.SUBUV_WRAP,this.options.paddingMode===r.SUBUV_COLOR&&(this.options.paddingColor=(E=this.options.paddingColor)!==null&&E!==void 0?E:new z.ov(0,0,0,1)),this.sets={},this.frames=[],this}return r.prototype._createFrames=function(t){for(var e=this,n=this._calculateSize(),i=new _.I9(1,1).divide(n),o=0,a=this._expecting,s=this.meshes.length,l=Object.keys(this.sets),c=0;c<l.length;c++){var u=l[c],d=new Oo(this.name+".TexturePack."+u+"Set",{width:n.x,height:n.y},this.scene,!0,Ie.g.TRILINEAR_SAMPLINGMODE,P.Y.TEXTUREFORMAT_RGBA),h=d.getContext();h.fillStyle="rgba(0,0,0,0)",h.fillRect(0,0,n.x,n.y),d.update(!1),this.sets[u]=d}var p=this.options.frameSize||256,m=this._paddingValue,v=p+2*m;for(c=0;c<s;c++)for(var b=this.meshes[c].material,E=function(f){var g=new Oo("temp",v,C.scene,!0),S=g.getContext(),y=C._getFrameOffset(c),x=function(){o++,g.update(!1);var D=S.getImageData(0,0,v,v),B=e.sets[R];if(B.getContext().putImageData(D,n.x*y.x,n.y*y.y),g.dispose(),B.update(!1),o==a)return e._calculateMeshUVFrames(p,m,n,i,e.options.updateInputMeshes||!1),void t()},R=l[f]||"_blank";if(b&&b[R]!==null){var I=b[R],M=new Image;M.src=I instanceof Oo?I.getContext().canvas.toDataURL("image/png"):I.url,ze.S0.SetCorsBehavior(M.src,M),M.onload=function(){S.fillStyle="rgba(0,0,0,0)",S.fillRect(0,0,v,v),g.update(!1),S.setTransform(1,0,0,-1,0,0);var D=[0,0,1,0,1,1,0,1,-1,1,-1,0,-2,0,-1,1,-1];switch(e.options.paddingMode){case 0:for(var B=0;B<9;B++)S.drawImage(M,0,0,M.width,M.height,m+p*D[B],m+p*D[B+1]-v,p,p);break;case 1:for(var F=0;F<m;F++)S.drawImage(M,0,0,M.width,M.height,F+p*D[0],m-v,p,p),S.drawImage(M,0,0,M.width,M.height,2*m-F,m-v,p,p),S.drawImage(M,0,0,M.width,M.height,m,F-v,p,p),S.drawImage(M,0,0,M.width,M.height,m,2*m-F-v,p,p);S.drawImage(M,0,0,M.width,M.height,m+p*D[0],m+p*D[1]-v,p,p);break;case 2:S.fillStyle=(e.options.paddingColor||z.v9.Black()).toHexString(),S.fillRect(0,0,v,-v),S.clearRect(m,m,p,p),S.drawImage(M,0,0,M.width,M.height,m+p*D[0],m+p*D[1]-v,p,p)}S.setTransform(1,0,0,1,0,0),x()}}else S.fillStyle="rgba(0,0,0,0)",C.options.fillBlanks&&(S.fillStyle=C.options.customFillColor),S.fillRect(0,0,v,v),x()},C=this,T=0;T<l.length;T++)E(T)},r.prototype._calculateSize=function(){var t=this.meshes.length||0,e=this.options.frameSize||0,n=this._paddingValue||0;switch(this.options.layout){case 0:return new _.I9(e*t+2*n*t,e+2*n);case 1:var i=Math.max(2,Math.ceil(Math.sqrt(t))),o=e*i+2*n*i;return new _.I9(o,o);case 2:var a=this.options.colnum||1,s=Math.max(1,Math.ceil(t/a));return new _.I9(e*a+2*n*a,e*s+2*n*s)}return _.I9.Zero()},r.prototype._calculateMeshUVFrames=function(t,e,n,i,o){for(var a=this.meshes.length,s=0;s<a;s++){var l=this.meshes[s],c=new _.I9(t/n.x,t/n.y),u=i.clone().scale(e),d=this._getFrameOffset(s).add(u),h=new Ah(s,c,d);this.frames.push(h),o&&(this._updateMeshUV(l,s),this._updateTextureReferences(l))}},r.prototype._getFrameOffset=function(t){var e,n,i,o=this.meshes.length;switch(this.options.layout){case 0:return e=1/o,new _.I9(t*e,0);case 1:var a=Math.max(2,Math.ceil(Math.sqrt(o)));return i=t-(n=Math.floor(t/a))*a,e=1/a,new _.I9(i*e,n*e);case 2:var s=this.options.colnum||1,l=Math.max(1,Math.ceil(o/s));return n=t-(i=Math.floor(t/l))*l,e=new _.I9(1/s,1/l),new _.I9(i*e.x,n*e.y)}return _.I9.Zero()},r.prototype._updateMeshUV=function(t,e){var n=this.frames[e],i=t.getVerticesData(this.options.uvsIn||Y.R.UVKind),o=[],a=0;i.length&&(a=i.length||0);for(var s=0;s<a;s+=2)o.push(i[s]*n.scale.x+n.offset.x,i[s+1]*n.scale.y+n.offset.y);t.setVerticesData(this.options.uvsOut||Y.R.UVKind,o)},r.prototype._updateTextureReferences=function(t,e){e===void 0&&(e=!1);for(var n=t.material,i=Object.keys(this.sets),o=function(l){l.dispose&&l.dispose()},a=0;a<i.length;a++){var s=i[a];if(e)n[s]!==null&&o(n[s]),n[s]=this.sets[s];else{if(!n)return;n[s]!==null&&(o(n[s]),n[s]=this.sets[s])}}},r.prototype.setMeshToFrame=function(t,e,n){n===void 0&&(n=!1),this._updateMeshUV(t,e),n&&this._updateTextureReferences(t,!0)},r.prototype.processAsync=function(){var t=this;return new Promise(function(e,n){try{if(t.meshes.length===0)return void e();for(var i=0,o=function(l){var c=t.meshes[l],u=c.material;if(!u)return++i===t.meshes.length?{value:t._createFrames(e)}:"continue";u.forceCompilationAsync(c).then(function(){(function(d){if(i++,t.options.map){for(var h=0;h<t.options.map.length;h++)d[t.options.map[h]]!==null&&(t.sets[t.options.map[h]]||(t.sets[t.options.map[h]]=!0),t._expecting++);i===t.meshes.length&&t._createFrames(e)}})(u)})},a=0;a<t.meshes.length;a++){var s=o(a);if(typeof s=="object")return s.value}}catch(l){return n(l)}})},r.prototype.dispose=function(){for(var t=Object.keys(this.sets),e=0;e<t.length;e++){var n=t[e];this.sets[n].dispose()}},r.prototype.download=function(t,e){var n=this;t===void 0&&(t="png"),e===void 0&&(e=1),setTimeout(function(){var i={name:n.name,sets:{},options:{},frames:[]},o=Object.keys(n.sets),a=Object.keys(n.options);try{for(var s=0;s<o.length;s++){var l=o[s],c=n.sets[l];i.sets[l]=c.getContext().canvas.toDataURL("image/"+t,e)}for(s=0;s<a.length;s++){var u=a[s];i.options[u]=n.options[u]}for(s=0;s<n.frames.length;s++){var d=n.frames[s];i.frames.push(d.scale.x,d.scale.y,d.offset.x,d.offset.y)}}catch(m){return void O.V.Warn("Unable to download: "+m)}var h="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(i,null,4)),p=document.createElement("a");p.setAttribute("href",h),p.setAttribute("download",n.name+"_texurePackage.json"),document.body.appendChild(p),p.click(),p.remove()},0)},r.prototype.updateFromJSON=function(t){try{var e=JSON.parse(t);this.name=e.name;for(var n=Object.keys(e.options),i=0;i<n.length;i++)this.options[n[i]]=e.options[n[i]];for(i=0;i<e.frames.length;i+=4){var o=new Ah(i/4,new _.I9(e.frames[i],e.frames[i+1]),new _.I9(e.frames[i+2],e.frames[i+3]));this.frames.push(o)}var a=Object.keys(e.sets);for(i=0;i<a.length;i++){var s=new Ie.g(e.sets[a[i]],this.scene,!1,!1);this.sets[a[i]]=s}}catch(l){O.V.Warn("Unable to update from JSON: "+l)}},r.LAYOUT_STRIP=0,r.LAYOUT_POWER2=1,r.LAYOUT_COLNUM=2,r.SUBUV_WRAP=0,r.SUBUV_EXTEND=1,r.SUBUV_COLOR=2,r}(),Vv=function(r){function t(e,n,i,o,a,s,l){var c=r.call(this,e,i,null,o,a,s)||this;return c._animate=!0,c._time=0,c._texturePath=n,!a||a instanceof Ie.g||(l=!!a.skipJson),l?c.setFragment(c._texturePath):c._loadJson(n),c.refreshRate=1,c}return(0,A.C6)(t,r),t.prototype._loadJson=function(e){var n=this,i=function(){try{n.setFragment(n._texturePath)}catch{O.V.Log("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},o=e+"/config.json",a=new We.u;a.open("GET",o),a.addEventListener("load",function(){if(a.status===200||a.responseText&&a.responseText.length>0)try{n._config=JSON.parse(a.response),n.updateShaderUniforms(),n.updateTextures(),n.setFragment(n._texturePath+"/custom"),n._animate=n._config.animate,n.refreshRate=n._config.refreshrate}catch{i()}else i()},!1),a.addEventListener("error",function(){i()},!1);try{a.send()}catch{O.V.Error("CustomProceduralTexture: Error on XHR send request.")}},t.prototype.isReady=function(){if(!r.prototype.isReady.call(this))return!1;for(var e in this._textures)if(!this._textures[e].isReady())return!1;return!0},t.prototype.render=function(e){var n=this.getScene();this._animate&&n&&(this._time+=.03*n.getAnimationRatio(),this.updateShaderUniforms()),r.prototype.render.call(this,e)},t.prototype.updateTextures=function(){for(var e=0;e<this._config.sampler2Ds.length;e++)this.setTexture(this._config.sampler2Ds[e].sample2Dname,new Ie.g(this._texturePath+"/"+this._config.sampler2Ds[e].textureRelativeUrl,this.getScene()))},t.prototype.updateShaderUniforms=function(){if(this._config)for(var e=0;e<this._config.uniforms.length;e++){var n=this._config.uniforms[e];switch(n.type){case"float":this.setFloat(n.name,n.value);break;case"color3":this.setColor3(n.name,new z.v9(n.r,n.g,n.b));break;case"color4":this.setColor4(n.name,new z.ov(n.r,n.g,n.b,n.a));break;case"vector2":this.setVector2(n.name,new _.I9(n.x,n.y));break;case"vector3":this.setVector3(n.name,new _.Pq(n.x,n.y,n.z))}}this.setFloat("time",this._time)},Object.defineProperty(t.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!1,configurable:!0}),t}(xr);Gt.l.ShadersStore.noisePixelShader=`uniform float brightness;uniform float persistence;uniform float timeScale;varying vec2 vUV;vec2 hash22(vec2 p)
|
||
{p=p*mat2(127.1,311.7,269.5,183.3);p=-1.0+2.0*fract(sin(p)*43758.5453123);return sin(p*6.283+timeScale);}
|
||
float interpolationNoise(vec2 p)
|
||
{vec2 pi=floor(p);vec2 pf=p-pi;vec2 w=pf*pf*(3.-2.*pf);float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));float xm1=mix(f00,f10,w.x);float xm2=mix(f01,f11,w.x);float ym=mix(xm1,xm2,w.y);
|
||
return ym;}
|
||
float perlinNoise2D(float x,float y)
|
||
{float sum=0.0;float frequency=0.0;float amplitude=0.0;for(int i=0; i<OCTAVES; i++)
|
||
{frequency=pow(2.0,float(i));amplitude=pow(persistence,float(i));sum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;}
|
||
return sum;}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{float x=abs(vUV.x);float y=abs(vUV.y);float noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);gl_FragColor=vec4(noise,noise,noise,1.0);}
|
||
`;var Uv=function(r){function t(e,n,i,o,a){n===void 0&&(n=256),i===void 0&&(i=Ve.q.LastCreatedScene);var s=r.call(this,e,n,"noise",i,o,a)||this;return s.time=0,s.brightness=.2,s.octaves=3,s.persistence=.8,s.animationSpeedFactor=1,s.autoClear=!1,s._updateShaderUniforms(),s}return(0,A.C6)(t,r),t.prototype._updateShaderUniforms=function(){var e=this.getScene();e&&(this.time+=e.getAnimationRatio()*this.animationSpeedFactor*.01,this.setFloat("brightness",this.brightness),this.setFloat("persistence",this.persistence),this.setFloat("timeScale",this.time))},t.prototype._getDefines=function(){return"#define OCTAVES "+(0|this.octaves)},t.prototype.render=function(e){this._updateShaderUniforms(),r.prototype.render.call(this,e)},t.prototype.serialize=function(){var e={customType:"BABYLON.NoiseProceduralTexture"};return e.brightness=this.brightness,e.octaves=this.octaves,e.persistence=this.persistence,e.animationSpeedFactor=this.animationSpeedFactor,e.size=this.getSize().width,e.generateMipMaps=this._generateMipMaps,e.time=this.time,e},t.prototype.clone=function(){var e=this.getSize(),n=new t(this.name,e.width,this.getScene(),this._fallbackTexture?this._fallbackTexture:void 0,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.coordinatesMode=this.coordinatesMode,n.brightness=this.brightness,n.octaves=this.octaves,n.persistence=this.persistence,n.animationSpeedFactor=this.animationSpeedFactor,n.time=this.time,n},t.Parse=function(e,n){var i,o=new t(e.name,e.size,n,void 0,e.generateMipMaps);return o.brightness=e.brightness,o.octaves=e.octaves,o.persistence=e.persistence,o.animationSpeedFactor=e.animationSpeedFactor,o.time=(i=e.time)!==null&&i!==void 0?i:0,o},t}(xr);(0,j.Y5)("BABYLON.NoiseProceduralTexture",Uv);var Ch,WP=function(r){function t(e,n,i,o,a,s,l,c,u){o===void 0&&(o=P.Y.TEXTUREFORMAT_RGBA),a===void 0&&(a=P.Y.TEXTURETYPE_UNSIGNED_INT),s===void 0&&(s=!1),l===void 0&&(l=!1),c===void 0&&(c=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),u===void 0&&(u=null);var d=r.call(this,"",e)||this;return d._texture=e.getEngine().createRawCubeTexture(n,i,o,a,s,l,c,u),d}return(0,A.C6)(t,r),t.prototype.update=function(e,n,i,o,a){a===void 0&&(a=null),this._texture.getEngine().updateRawCubeTexture(this._texture,e,n,i,o,a)},t.prototype.updateRGBDAsync=function(e,n,i,o){return n===void 0&&(n=null),i===void 0&&(i=.8),o===void 0&&(o=0),(0,ni.gW)(this._texture,e,n,i,o).then(function(){})},t.prototype.clone=function(){var e=this;return tt.p.Clone(function(){var n=e.getScene(),i=e._texture,o=new t(n,i._bufferViewArray,i.width,i.format,i.type,i.generateMipMaps,i.invertY,i.samplingMode,i._compression);return i.source===13&&o.updateRGBDAsync(i._bufferViewArrayArray,i._sphericalPolynomial,i._lodGenerationScale,i._lodGenerationOffset),o},this)},t}(mr),HP=function(r){function t(e,n,i,o,a,s,l,c,u,d,h){l===void 0&&(l=!0),c===void 0&&(c=!1),u===void 0&&(u=Ie.g.TRILINEAR_SAMPLINGMODE),d===void 0&&(d=P.Y.TEXTURETYPE_UNSIGNED_INT);var p=r.call(this,null,s,!l,c)||this;return p.format=a,p._texture=s.getEngine().createRawTexture3D(e,n,i,o,a,l,c,u,null,d,h),p.is3D=!0,p}return(0,A.C6)(t,r),t.prototype.update=function(e){this._texture&&this._getEngine().updateRawTexture3D(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t}(Ie.g),YP=function(r){function t(e,n,i,o){var a=r.call(this,e,n,i,o,!0)||this;return a.refractionPlane=new Qo.Z(0,1,0,1),a.depth=2,a.onBeforeRenderObservable.add(function(){a.getScene().clipPlane=a.refractionPlane}),a.onAfterRenderObservable.add(function(){a.getScene().clipPlane=null}),a}return(0,A.C6)(t,r),t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=this.getSize(),i=new t(this.name,n.width,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.refractionPlane=this.refractionPlane.clone(),this.renderList&&(i.renderList=this.renderList.slice(0)),i.depth=this.depth,i},t.prototype.serialize=function(){if(!this.name)return null;var e=r.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},t}(un.$),XP=L(55204),da=L(63919),jP=function(r){function t(e,n,i){var o=r.call(this,null)||this;return o._renderTarget=null,o._engine=e,o._renderTargetOptions=i,o.resize(n),o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"renderTarget",{get:function(){return this._renderTarget},enumerable:!1,configurable:!0}),t.prototype.resize=function(e){var n;(n=this._renderTarget)===null||n===void 0||n.dispose(),this._renderTarget=null,this._texture=null,this._size=e,this._engine&&(this._renderTarget=this._engine.createRenderTargetTexture(this._size,this._renderTargetOptions)),this._texture=this.renderTarget.texture},t.prototype.getInternalTexture=function(){return this._texture},t.prototype.getClassName=function(){return"ThinRenderTargetTexture"},t.prototype.dispose=function(e){var n;e===void 0&&(e=!1),(n=this._renderTarget)===null||n===void 0||n.dispose(!0),this._renderTarget=null,e||r.prototype.dispose.call(this)},t}(da.D),fs=L(54665),qP=L(67400),KP=L(6777),ZP=L(88724),QP=L(59586),JP=L(34593),$P=L(76459);(function(r){r[r.Uniform=0]="Uniform",r[r.Attribute=1]="Attribute",r[r.Varying=2]="Varying",r[r.Undefined=3]="Undefined"})(Ch||(Ch={}));var bn=function(r){function t(e,n,i,o,a){var s=r.call(this,e,n,i)||this;return s._blockType=o,s._blockName=a,s.needDualDirectionValidation=!0,s}return(0,A.C6)(t,r),t.prototype.checkCompatibilityState=function(e){return e instanceof t&&e._blockName===this._blockName?0:1},t.prototype.createCustomInputBlock=function(){return[new this._blockType(this._blockName),this.name]},t}(pl),Gv=function(r){function t(e){var n=r.call(this,e,_e.Vertex)||this;return n.registerInput("matricesIndices",G.Vector4),n.registerInput("matricesWeights",G.Vector4),n.registerInput("matricesIndicesExtra",G.Vector4,!0),n.registerInput("matricesWeightsExtra",G.Vector4,!0),n.registerInput("world",G.Matrix),n.registerOutput("output",G.Matrix),n}return(0,A.C6)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("boneSampler"),e._excludeVariableName("boneTextureWidth"),e._excludeVariableName("mBones"),e._excludeVariableName("BonesPerMesh"),this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,45699)),Promise.resolve().then(L.bind(L,3641))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,36470)),Promise.resolve().then(L.bind(L,76898))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.getClassName=function(){return"BonesBlock"},Object.defineProperty(t.prototype,"matricesIndices",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesWeights",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesIndicesExtra",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesWeightsExtra",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.matricesIndices.isConnected){var i=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="matricesIndices"&&n(s)});i||(i=new Mt("matricesIndices")).setAsAttribute("matricesIndices"),i.output.connectTo(this.matricesIndices)}if(!this.matricesWeights.isConnected){var o=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="matricesWeights"&&n(s)});o||(o=new Mt("matricesWeights")).setAsAttribute("matricesWeights"),o.output.connectTo(this.matricesWeights)}if(!this.world.isConnected){var a=e.getInputBlockByPredicate(function(s){return s.systemValue===Nt.World&&n(s)});a||(a=new Mt("world")).setAsSystemValue(Nt.World),a.output.connectTo(this.world)}},t.prototype.provideFallbacks=function(e,n){e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton&&n.addCPUSkinningFallback(0,e)},t.prototype.bind=function(e,n,i){(0,Re.f$)(i,e)},t.prototype.prepareDefines=function(e,n,i){i._areAttributesDirty&&(0,Re.IC)(e,i)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),e.sharedData.blocksWithFallbacks.push(this),e.sharedData.forcedBindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this),e.uniforms.push("boneTextureWidth"),e.uniforms.push("mBones"),e.samplers.push("boneSampler");var n="//".concat(this.name);e._emitFunctionFromInclude("bonesDeclaration",n,{removeAttributes:!0,removeUniforms:!1,removeVaryings:!0,removeIfDef:!1});var i=e._getFreeVariableName("influence");e.compilationString+=e._emitCodeFromInclude("bonesVertex",n,{replaceStrings:[{search:/finalWorld=finalWorld\*influence;/,replace:""},{search:/influence/gm,replace:i}]});var o=this._outputs[0],a=this.world;return e.compilationString+=`#if NUM_BONE_INFLUENCERS>0
|
||
`,e.compilationString+=e._declareOutput(o)+" = ".concat(a.associatedVariableName," * ").concat(i,`;
|
||
`),e.compilationString+=`#else
|
||
`,e.compilationString+=e._declareOutput(o)+" = ".concat(a.associatedVariableName,`;
|
||
`),e.compilationString+=`#endif
|
||
`,this},t}(ut);(0,j.Y5)("BABYLON.BonesBlock",Gv);var kv=function(r){function t(e){var n=r.call(this,e,_e.Vertex)||this;return n.registerInput("world0",G.Vector4),n.registerInput("world1",G.Vector4),n.registerInput("world2",G.Vector4),n.registerInput("world3",G.Vector4),n.registerInput("world",G.Matrix,!0),n.registerOutput("output",G.Matrix),n.registerOutput("instanceID",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"InstancesBlock"},Object.defineProperty(t.prototype,"world0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world2",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world3",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instanceID",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.world0.connectedPoint){var i=e.getInputBlockByPredicate(function(c){return c.isAttribute&&c.name==="world0"&&n(c)});i||(i=new Mt("world0")).setAsAttribute("world0"),i.output.connectTo(this.world0)}if(!this.world1.connectedPoint){var o=e.getInputBlockByPredicate(function(c){return c.isAttribute&&c.name==="world1"&&n(c)});o||(o=new Mt("world1")).setAsAttribute("world1"),o.output.connectTo(this.world1)}if(!this.world2.connectedPoint){var a=e.getInputBlockByPredicate(function(c){return c.isAttribute&&c.name==="world2"&&n(c)});a||(a=new Mt("world2")).setAsAttribute("world2"),a.output.connectTo(this.world2)}if(!this.world3.connectedPoint){var s=e.getInputBlockByPredicate(function(c){return c.isAttribute&&c.name==="world3"&&n(c)});s||(s=new Mt("world3")).setAsAttribute("world3"),s.output.connectTo(this.world3)}if(!this.world.connectedPoint){var l=e.getInputBlockByPredicate(function(c){return c.isAttribute&&c.name==="world"&&n(c)});l||(l=new Mt("world")).setAsSystemValue(Nt.World),l.output.connectTo(this.world)}this.world.define="!INSTANCES || THIN_INSTANCES"},t.prototype.prepareDefines=function(e,n,i,o,a){o===void 0&&(o=!1);var s=!1;i.INSTANCES!==o&&(i.setValue("INSTANCES",o),s=!0),a&&i.THIN_INSTANCES!==!!a?.getRenderingMesh().hasThinInstances&&(i.setValue("THIN_INSTANCES",!!a?.getRenderingMesh().hasThinInstances),s=!0),s&&i.markAsUnprocessed()},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=e.sharedData.scene.getEngine();e.sharedData.blocksWithDefines.push(this);var i=this._outputs[0],o=this._outputs[1],a=this.world0,s=this.world1,l=this.world2,c=this.world3,u="mat4",d="gl_InstanceID",h="float";return e.shaderLanguage===1&&(u="mat4x4f",d="vertexInputs.instanceIndex",h="f32"),e.compilationString+=`#ifdef INSTANCES
|
||
`,e.compilationString+=e._declareOutput(i)+" = ".concat(u,"(").concat(a.associatedVariableName,", ").concat(s.associatedVariableName,", ").concat(l.associatedVariableName,", ").concat(c.associatedVariableName,`);
|
||
`),e.compilationString+=`#ifdef THIN_INSTANCES
|
||
`,e.compilationString+="".concat(i.associatedVariableName," = ").concat(this.world.associatedVariableName," * ").concat(i.associatedVariableName,`;
|
||
`),e.compilationString+=`#endif
|
||
`,n._caps.canUseGLInstanceID?e.compilationString+=e._declareOutput(o)+" = ".concat(h,"(").concat(d,`);
|
||
`):e.compilationString+=e._declareOutput(o)+` = 0.0;
|
||
`,e.compilationString+=`#else
|
||
`,e.compilationString+=e._declareOutput(i)+" = ".concat(this.world.associatedVariableName,`;
|
||
`),e.compilationString+=e._declareOutput(o)+` = 0.0;
|
||
`,e.compilationString+=`#endif
|
||
`,this},t}(ut);(0,j.Y5)("BABYLON.InstancesBlock",kv);var Rh=function(r){function t(e){var n=r.call(this,e,_e.Vertex)||this;return n.registerInput("position",G.Vector3),n.registerInput("normal",G.Vector3),n.registerInput("tangent",G.AutoDetect),n.tangent.addExcludedConnectionPointFromAllowedTypes(G.Color4|G.Vector4|G.Vector3),n.registerInput("uv",G.Vector2),n.registerOutput("positionOutput",G.Vector3),n.registerOutput("normalOutput",G.Vector3),n.registerOutput("tangentOutput",G.Vector4),n.registerOutput("uvOutput",G.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MorphTargetsBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangent",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"positionOutput",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalOutput",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangentOutput",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uvOutput",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("morphTargetInfluences"),this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,77320)),Promise.resolve().then(L.bind(L,68478)),Promise.resolve().then(L.bind(L,98819)),Promise.resolve().then(L.bind(L,73683))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,84589)),Promise.resolve().then(L.bind(L,67369)),Promise.resolve().then(L.bind(L,58266)),Promise.resolve().then(L.bind(L,24444))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.position.isConnected){var i=e.getInputBlockByPredicate(function(l){return l.isAttribute&&l.name==="position"&&n(l)});i||(i=new Mt("position")).setAsAttribute(),i.output.connectTo(this.position)}if(!this.normal.isConnected){var o=e.getInputBlockByPredicate(function(l){return l.isAttribute&&l.name==="normal"&&n(l)});o||(o=new Mt("normal")).setAsAttribute("normal"),o.output.connectTo(this.normal)}if(!this.tangent.isConnected){var a=e.getInputBlockByPredicate(function(l){return l.isAttribute&&l.name==="tangent"&&n(l)});a||(a=new Mt("tangent")).setAsAttribute("tangent"),a.output.connectTo(this.tangent)}if(!this.uv.isConnected){var s=e.getInputBlockByPredicate(function(l){return l.isAttribute&&l.name==="uv"&&n(l)});s||(s=new Mt("uv")).setAsAttribute("uv"),s.output.connectTo(this.uv)}},t.prototype.prepareDefines=function(e,n,i){if(e.morphTargetManager){var o=e.morphTargetManager;o?.isUsingTextureForTargets&&(o.numMaxInfluencers||o.numInfluencers)!==i.NUM_MORPH_INFLUENCERS&&i.markAsAttributesDirty()}i._areAttributesDirty&&(0,Re.Jz)(e,i)},t.prototype.bind=function(e,n,i){i&&i.morphTargetManager&&i.morphTargetManager.numInfluencers>0&&((0,Re.nR)(i,e),i.morphTargetManager.isUsingTextureForTargets&&i.morphTargetManager._bind(e))},t.prototype.replaceRepeatableContent=function(e,n,i,o){var a=this.position,s=this.normal,l=this.tangent,c=this.uv,u=this.positionOutput,d=this.normalOutput,h=this.tangentOutput,p=this.uvOutput,m=e,v=o.NUM_MORPH_INFLUENCERS,b=i.morphTargetManager,E=b&&b.supportsNormals&&o.NORMAL,C=b&&b.supportsTangents&&o.TANGENT,T=b&&b.supportsUVs&&o.UV1,f="";b?.isUsingTextureForTargets&&v>0&&(f+="".concat(m._declareLocalVar("vertexID",G.Float),`;
|
||
`)),f+=`#ifdef MORPHTARGETS
|
||
`;var g=m.shaderLanguage===1,S=g?"uniforms.":"";if(b?.isUsingTextureForTargets)f+="for (".concat(g?"var":"int",` i = 0; i < NUM_MORPH_INFLUENCERS; i++) {
|
||
`),f+="if (i >= ".concat(S,`morphTargetCount) { break; }
|
||
`),f+="vertexID = ".concat(g?"f32(vertexInputs.vertexIndex":"float(gl_VertexID",") * ").concat(S,`morphTargetTextureInfo.x;
|
||
`),f+="".concat(u.associatedVariableName," += (readVector3FromRawSampler(i, vertexID) - ").concat(a.associatedVariableName,") * ").concat(S,`morphTargetInfluences[i];
|
||
`),f+=`vertexID += 1.0;
|
||
`,E&&(f+=`#ifdef MORPHTARGETS_NORMAL
|
||
`,f+="".concat(d.associatedVariableName," += (readVector3FromRawSampler(i, vertexID) - ").concat(s.associatedVariableName,") * ").concat(S,`morphTargetInfluences[i];
|
||
`),f+=`vertexID += 1.0;
|
||
`,f+=`#endif
|
||
`),T&&(f+=`#ifdef MORPHTARGETS_UV
|
||
`,f+="".concat(p.associatedVariableName," += (readVector3FromRawSampler(i, vertexID).xy - ").concat(c.associatedVariableName,") * ").concat(S,`morphTargetInfluences[i];
|
||
`),f+=`vertexID += 1.0;
|
||
`,f+=`#endif
|
||
`),C&&(f+=`#ifdef MORPHTARGETS_TANGENT
|
||
`,f+="".concat(h.associatedVariableName,".xyz += (readVector3FromRawSampler(i, vertexID) - ").concat(l.associatedVariableName,".xyz) * ").concat(S,`morphTargetInfluences[i];
|
||
`),l.type===G.Vector4?f+="".concat(h.associatedVariableName,".w = ").concat(l.associatedVariableName,`.w;
|
||
`):f+="".concat(h.associatedVariableName,`.w = 1.;
|
||
`),f+=`#endif
|
||
`),f+=`}
|
||
`;else for(var y=0;y<v;y++)f+="".concat(u.associatedVariableName," += (position").concat(y," - ").concat(a.associatedVariableName,") * ").concat(S,"morphTargetInfluences[").concat(y,`];
|
||
`),E&&(f+=`#ifdef MORPHTARGETS_NORMAL
|
||
`,f+="".concat(d.associatedVariableName," += (normal").concat(y," - ").concat(s.associatedVariableName,") * ").concat(S,"morphTargetInfluences[").concat(y,`];
|
||
`),f+=`#endif
|
||
`),T&&(f+=`#ifdef MORPHTARGETS_UV
|
||
`,f+="".concat(p.associatedVariableName,".xy += (uv_").concat(y," - ").concat(c.associatedVariableName,".xy) * ").concat(S,"morphTargetInfluences[").concat(y,`];
|
||
`),f+=`#endif
|
||
`),C&&(f+=`#ifdef MORPHTARGETS_TANGENT
|
||
`,f+="".concat(h.associatedVariableName,".xyz += (tangent").concat(y," - ").concat(l.associatedVariableName,".xyz) * ").concat(S,"morphTargetInfluences[").concat(y,`];
|
||
`),l.type===G.Vector4?f+="".concat(h.associatedVariableName,".w = ").concat(l.associatedVariableName,`.w;
|
||
`):f+="".concat(h.associatedVariableName,`.w = 1.;
|
||
`),f+=`#endif
|
||
`);if(f+=`#endif
|
||
`,m.compilationString=m.compilationString.replace(this._repeatableContentAnchor,f),v>0)for(y=0;y<v;y++)m.attributes.push(Y.R.PositionKind+y),E&&m.attributes.push(Y.R.NormalKind+y),C&&m.attributes.push(Y.R.TangentKind+y),T&&m.attributes.push(Y.R.UVKind+"_"+y)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),e.sharedData.repeatableContentBlocks.push(this);var n=this.position,i=this.normal,o=this.tangent,a=this.uv,s=this.positionOutput,l=this.normalOutput,c=this.tangentOutput,u=this.uvOutput,d="//".concat(this.name);return e.uniforms.push("morphTargetInfluences"),e.uniforms.push("morphTargetCount"),e.uniforms.push("morphTargetTextureInfo"),e.uniforms.push("morphTargetTextureIndices"),e.samplers.push("morphTargets"),e._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration",d),e._emitFunctionFromInclude("morphTargetsVertexDeclaration",d,{repeatKey:"maxSimultaneousMorphTargets"}),e.compilationString+="".concat(e._declareOutput(s)," = ").concat(n.associatedVariableName,`;
|
||
`),e.compilationString+=`#ifdef NORMAL
|
||
`,e.compilationString+="".concat(e._declareOutput(l)," = ").concat(i.associatedVariableName,`;
|
||
`),e.compilationString+=`#else
|
||
`,e.compilationString+="".concat(e._declareOutput(l),` = vec3(0., 0., 0.);
|
||
`),e.compilationString+=`#endif
|
||
`,e.compilationString+=`#ifdef TANGENT
|
||
`,e.compilationString+="".concat(e._declareOutput(c)," = ").concat(o.associatedVariableName,`;
|
||
`),e.compilationString+=`#else
|
||
`,e.compilationString+="".concat(e._declareOutput(c),` = vec4(0., 0., 0., 0.);
|
||
`),e.compilationString+=`#endif
|
||
`,e.compilationString+=`#ifdef UV1
|
||
`,e.compilationString+="".concat(e._declareOutput(u)," = ").concat(a.associatedVariableName,`;
|
||
`),e.compilationString+=`#else
|
||
`,e.compilationString+="".concat(e._declareOutput(u),` = vec2(0., 0.);
|
||
`),e.compilationString+=`#endif
|
||
`,this._repeatableContentAnchor=e._repeatableContentAnchor,e.compilationString+=this._repeatableContentAnchor,this},t}(ut);(0,j.Y5)("BABYLON.MorphTargetsBlock",Rh);var zv=function(r){function t(e){var n=r.call(this,e,_e.Vertex)||this;return n.registerInput("worldPosition",G.Vector4,!1,_e.Vertex),n.registerOutput("direction",G.Vector3),n.registerOutput("color",G.Color3),n.registerOutput("intensity",G.Float),n.registerOutput("shadowBias",G.Float),n.registerOutput("shadowNormalBias",G.Float),n.registerOutput("shadowDepthScale",G.Float),n.registerOutput("shadowDepthRange",G.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"LightInformationBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensity",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowBias",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowNormalBias",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowDepthScale",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowDepthRange",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),t.prototype.bind=function(e,n,i){if(i){this.light&&this.light.isDisposed()&&(this.light=null);var o=this.light,a=n.getScene();if(!o&&a.lights.length&&(o=this.light=a.lights[0],this._forcePrepareDefines=!0),!o||!o.isEnabled)return e.setFloat3(this._lightDataUniformName,0,0,0),void e.setFloat4(this._lightColorUniformName,0,0,0,0);o.transferToNodeMaterialEffect(e,this._lightDataUniformName),e.setColor4(this._lightColorUniformName,o.diffuse,o.intensity);var s=o.getShadowGenerator();if((this.shadowBias.hasEndpoints||this.shadowNormalBias.hasEndpoints||this.shadowDepthScale.hasEndpoints)&&(s?e.setFloat3(this._lightShadowUniformName,s.bias,s.normalBias,s.depthScale):e.setFloat3(this._lightShadowUniformName,0,0,0)),this.shadowDepthRange)if(s&&a.activeCamera){var l=o;e.setFloat2(this._lightShadowExtraUniformName,l.getDepthMinZ(a.activeCamera),l.getDepthMinZ(a.activeCamera)+l.getDepthMaxZ(a.activeCamera))}else e.setFloat2(this._lightShadowExtraUniformName,0,0)}},t.prototype.prepareDefines=function(e,n,i){if(i._areLightsDirty||this._forcePrepareDefines){this._forcePrepareDefines=!1;var o=this.light;i.setValue(this._lightTypeDefineName,!!(o&&o instanceof yl),!0)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this);var n=this.direction,i=this.color,o=this.intensity,a=this.shadowBias,s=this.shadowNormalBias,l=this.shadowDepthScale,c=this.shadowDepthRange;this._lightDataUniformName=e._getFreeVariableName("lightData"),this._lightColorUniformName=e._getFreeVariableName("lightColor"),this._lightShadowUniformName=e._getFreeVariableName("shadowData"),this._lightShadowExtraUniformName=e._getFreeVariableName("shadowExtraData"),this._lightTypeDefineName=e._getFreeDefineName("LIGHTPOINTTYPE");var u=e.shaderLanguage===1?"uniforms.":"";return e._emitUniformFromString(this._lightDataUniformName,G.Vector3),e._emitUniformFromString(this._lightColorUniformName,G.Vector4),e.compilationString+="#ifdef ".concat(this._lightTypeDefineName,`
|
||
`),e.compilationString+=e._declareOutput(n)+" = normalize(".concat(this.worldPosition.associatedVariableName,".xyz - ").concat(u).concat(this._lightDataUniformName,`);
|
||
`),e.compilationString+=`#else
|
||
`,e.compilationString+=e._declareOutput(n)+" = ".concat(u).concat(this._lightDataUniformName,`;
|
||
`),e.compilationString+=`#endif
|
||
`,e.compilationString+=e._declareOutput(i)+" = ".concat(u).concat(this._lightColorUniformName,`.rgb;
|
||
`),e.compilationString+=e._declareOutput(o)+" = ".concat(u).concat(this._lightColorUniformName,`.a;
|
||
`),(a.hasEndpoints||s.hasEndpoints||l.hasEndpoints)&&(e._emitUniformFromString(this._lightShadowUniformName,G.Vector3),a.hasEndpoints&&(e.compilationString+=e._declareOutput(a)+" = ".concat(u).concat(this._lightShadowUniformName,`.x;
|
||
`)),s.hasEndpoints&&(e.compilationString+=e._declareOutput(s)+" = ".concat(u).concat(this._lightShadowUniformName,`.y;
|
||
`)),l.hasEndpoints&&(e.compilationString+=e._declareOutput(l)+" = ".concat(u).concat(this._lightShadowUniformName,`.z;
|
||
`))),c.hasEndpoints&&(e._emitUniformFromString(this._lightShadowExtraUniformName,G.Vector2),e.compilationString+=e._declareOutput(c)+" = ".concat(this._lightShadowUniformName,`;
|
||
`)),this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.light&&(e.lightId=this.light.id),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),e.lightId&&(this.light=n.getLightById(e.lightId))},t}(ut);(0,j.Y5)("BABYLON.LightInformationBlock",zv);var eA=L(45699),tA=L(3641),nA=L(36470),iA=L(76898),rA=L(77320),oA=L(68478),aA=L(98819),sA=L(73683),lA=L(84589),cA=L(67369),uA=L(58266),dA=L(24444),Wv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.convertInputToLinearSpace=!0,n.registerInput("color",G.AutoDetect),n.registerOutput("output",G.Color4),n.registerOutput("rgb",G.Color3),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Color4|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ImageProcessingBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("exposureLinear"),e._excludeVariableName("contrast"),e._excludeVariableName("vInverseScreenSize"),e._excludeVariableName("vignetteSettings1"),e._excludeVariableName("vignetteSettings2"),e._excludeVariableName("vCameraColorCurveNegative"),e._excludeVariableName("vCameraColorCurveNeutral"),e._excludeVariableName("vCameraColorCurvePositive"),e._excludeVariableName("txColorTransform"),e._excludeVariableName("colorTransformSettings"),e._excludeVariableName("ditherIntensity"),this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,17393)),Promise.resolve().then(L.bind(L,86320)),Promise.resolve().then(L.bind(L,4661))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,75334)),Promise.resolve().then(L.bind(L,59581)),Promise.resolve().then(L.bind(L,40688))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.isReady=function(e,n,i){return!(i._areImageProcessingDirty&&n.imageProcessingConfiguration&&!n.imageProcessingConfiguration.isReady())},t.prototype.prepareDefines=function(e,n,i){i._areImageProcessingDirty&&n.imageProcessingConfiguration&&n.imageProcessingConfiguration.prepareDefines(i)},t.prototype.bind=function(e,n,i){i&&n.imageProcessingConfiguration&&n.imageProcessingConfiguration.bind(e)},t.prototype._buildBlock=function(e){var n;r.prototype._buildBlock.call(this,e),e.sharedData.blocksWithDefines.push(this),e.sharedData.blockingBlocks.push(this),e.sharedData.bindableBlocks.push(this),e.uniforms.push("exposureLinear"),e.uniforms.push("contrast"),e.uniforms.push("vInverseScreenSize"),e.uniforms.push("vignetteSettings1"),e.uniforms.push("vignetteSettings2"),e.uniforms.push("vCameraColorCurveNegative"),e.uniforms.push("vCameraColorCurveNeutral"),e.uniforms.push("vCameraColorCurvePositive"),e.uniforms.push("txColorTransform"),e.uniforms.push("colorTransformSettings"),e.uniforms.push("ditherIntensity");var i=this.color,o=this._outputs[0],a="//".concat(this.name),s=e.shaderLanguage===1?"Vec3":"";return e._emitFunctionFromInclude("helperFunctions",a),e._emitFunctionFromInclude("imageProcessingDeclaration",a),e._emitFunctionFromInclude("imageProcessingFunctions",a),!((n=i.connectedPoint)===null||n===void 0)&&n.isConnected&&(i.connectedPoint.type===G.Color4||i.connectedPoint.type===G.Vector4?e.compilationString+="".concat(e._declareOutput(o)," = ").concat(i.associatedVariableName,`;
|
||
`):e.compilationString+="".concat(e._declareOutput(o)," = vec4").concat(e.fSuffix,"(").concat(i.associatedVariableName,`, 1.0);
|
||
`),e.compilationString+=`#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
`,this.convertInputToLinearSpace&&(e.compilationString+="".concat(o.associatedVariableName," = vec4").concat(e.fSuffix,"(toLinearSpace").concat(s,"(").concat(i.associatedVariableName,".rgb), ").concat(i.associatedVariableName,`.a);
|
||
`)),e.compilationString+=`#else
|
||
`,e.compilationString+=`#ifdef IMAGEPROCESSING
|
||
`,this.convertInputToLinearSpace&&(e.compilationString+="".concat(o.associatedVariableName," = vec4").concat(e.fSuffix,"(toLinearSpace").concat(s,"(").concat(i.associatedVariableName,".rgb), ").concat(i.associatedVariableName,`.a);
|
||
`)),e.compilationString+="".concat(o.associatedVariableName," = applyImageProcessing(").concat(o.associatedVariableName,`);
|
||
`),e.compilationString+=`#endif
|
||
`,e.compilationString+=`#endif
|
||
`,this.rgb.hasEndpoints&&(e.compilationString+=e._declareOutput(this.rgb)+" = ".concat(this.output.associatedVariableName,`.xyz;
|
||
`))),this},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".convertInputToLinearSpace = ").concat(this.convertInputToLinearSpace,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertInputToLinearSpace=this.convertInputToLinearSpace,e},t.prototype._deserialize=function(e,n,i){var o;r.prototype._deserialize.call(this,e,n,i),this.convertInputToLinearSpace=(o=e.convertInputToLinearSpace)===null||o===void 0||o},(0,A.Cg)([dt("Convert input to linear space",0,"ADVANCED")],t.prototype,"convertInputToLinearSpace",void 0),t}(ut);(0,j.Y5)("BABYLON.ImageProcessingBlock",Wv);var ps=function(r){function t(e){var n=r.call(this,e,_e.Fragment,!0)||this;return n.registerInput("normal",G.AutoDetect,!1),n.normal.addExcludedConnectionPointFromAllowedTypes(G.Color4|G.Vector4|G.Vector3),n.registerInput("tangent",G.Vector4,!1),n.registerInput("world",G.Matrix,!1),n.registerOutput("TBN",G.Object,_e.Fragment,new bn("TBN",n,1,t,"TBNBlock")),n.registerOutput("row0",G.Vector3,_e.Fragment),n.registerOutput("row1",G.Vector3,_e.Fragment),n.registerOutput("row2",G.Vector3,_e.Fragment),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TBNBlock"},t.prototype.initialize=function(e){e._excludeVariableName("tbnNormal"),e._excludeVariableName("tbnTangent"),e._excludeVariableName("tbnBitangent"),e._excludeVariableName("TBN")},Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangent",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"TBN",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"row0",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"row1",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"row2",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return _e.Fragment},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.world.isConnected){var i=e.getInputBlockByPredicate(function(s){return s.isSystemValue&&s.systemValue===Nt.World&&n(s)});i||(i=new Mt("world")).setAsSystemValue(Nt.World),i.output.connectTo(this.world)}if(!this.normal.isConnected){var o=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="normal"&&n(s)});o||(o=new Mt("normal")).setAsAttribute("normal"),o.output.connectTo(this.normal)}if(!this.tangent.isConnected){var a=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="tangent"&&s.type===G.Vector4&&n(s)});a||(a=new Mt("tangent")).setAsAttribute("tangent"),a.output.connectTo(this.tangent)}},t.prototype.prepareDefines=function(e,n,i){var o,a,s,l,c=this.normal,u=this.tangent,d=c.isConnected;!((o=c.connectInputBlock)===null||o===void 0)&&o.isAttribute&&!e.isVerticesDataPresent((a=c.connectInputBlock)===null||a===void 0?void 0:a.name)&&(d=!1);var h=u.isConnected;!((s=u.connectInputBlock)===null||s===void 0)&&s.isAttribute&&!e.isVerticesDataPresent((l=u.connectInputBlock)===null||l===void 0?void 0:l.name)&&(h=!1);var p=d&&h;i.setValue("TBNBLOCK",p,!0)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.normal,i=this.tangent,o=this.world,a=this.TBN,s=this.row0,l=this.row1,c=this.row2,u=e.shaderLanguage===1,d=u?"mat3x3f":"mat3",h=u?"f":"";return e.target===_e.Fragment&&(e.compilationString+=`
|
||
// `.concat(this.name,`
|
||
`).concat(e._declareLocalVar("tbnNormal",G.Vector3)," = normalize(").concat(n.associatedVariableName,`).xyz;
|
||
`).concat(e._declareLocalVar("tbnTangent",G.Vector3)," = normalize(").concat(i.associatedVariableName,`.xyz);
|
||
`).concat(e._declareLocalVar("tbnBitangent",G.Vector3)," = cross(tbnNormal, tbnTangent) * ").concat(i.associatedVariableName,`.w;
|
||
`).concat(u?"var":"mat3"," ").concat(a.associatedVariableName," = ").concat(d,"(").concat(o.associatedVariableName,"[0].xyz, ").concat(o.associatedVariableName,"[1].xyz, ").concat(o.associatedVariableName,"[2].xyz) * ").concat(d,`(tbnTangent, tbnBitangent, tbnNormal);
|
||
`),s.hasEndpoints&&(e.compilationString+=e._declareOutput(s)+" = vec3".concat(h,"(").concat(a.associatedVariableName,"[0][0], ").concat(a.associatedVariableName,"[0][1], ").concat(a.associatedVariableName,`[0][2]);
|
||
`)),l.hasEndpoints&&(e.compilationString+=e._declareOutput(l)+" = vec3".concat(h,"(").concat(a.associatedVariableName,"[1[0], ").concat(a.associatedVariableName,"[1][1], ").concat(a.associatedVariableName,`[1][2]);
|
||
`)),c.hasEndpoints&&(e.compilationString+=e._declareOutput(c)+" = vec3".concat(h,"(").concat(a.associatedVariableName,"[2][0], ").concat(a.associatedVariableName,"[2][1], ").concat(a.associatedVariableName,`[2][2]);
|
||
`)),e.sharedData.blocksWithDefines.push(this)),this},t}(ut);(0,j.Y5)("BABYLON.TBNBlock",ps);var Hv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._tangentSpaceParameterName="",n._tangentCorrectionFactorName="",n._worldMatrixName="",n.invertX=!1,n.invertY=!1,n.useParallaxOcclusion=!1,n.useObjectSpaceNormalMap=!1,n._isUnique=!0,n.registerInput("worldPosition",G.Vector4,!1),n.registerInput("worldNormal",G.Vector4,!1),n.registerInput("worldTangent",G.Vector4,!0),n.registerInput("uv",G.Vector2,!1),n.registerInput("normalMapColor",G.Color3,!1),n.registerInput("strength",G.Float,!1),n.registerInput("viewDirection",G.Vector3,!0),n.registerInput("parallaxScale",G.Float,!0),n.registerInput("parallaxHeight",G.Float,!0),n.registerInput("TBN",G.Object,!0,_e.VertexAndFragment,new bn("TBN",n,0,ps,"TBNBlock")),n.registerInput("world",G.Matrix,!0),n.registerOutput("output",G.Vector4),n.registerOutput("uvOffset",G.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"PerturbNormalBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMapColor",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"strength",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewDirection",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parallaxScale",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parallaxHeight",{get:function(){return this._inputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"TBN",{get:function(){return this._inputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[10]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uvOffset",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,20274)),Promise.resolve().then(L.bind(L,96830)),Promise.resolve().then(L.bind(L,66633))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,56159)),Promise.resolve().then(L.bind(L,48661)),Promise.resolve().then(L.bind(L,75394))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.prepareDefines=function(e,n,i){var o=this.normalMapColor.connectedPoint._ownerBlock.samplerName,a=this.viewDirection.isConnected&&(this.useParallaxOcclusion&&o||!this.useParallaxOcclusion&&this.parallaxHeight.isConnected);i.setValue("BUMP",!0),i.setValue("PARALLAX",a,!0),i.setValue("PARALLAX_RHS",n.getScene().useRightHandedSystem,!0),i.setValue("PARALLAXOCCLUSION",this.useParallaxOcclusion,!0),i.setValue("OBJECTSPACE_NORMALMAP",this.useObjectSpaceNormalMap,!0)},t.prototype.bind=function(e,n,i){n.getScene()._mirroredCameraPosition?e.setFloat2(this._tangentSpaceParameterName,this.invertX?1:-1,this.invertY?1:-1):e.setFloat2(this._tangentSpaceParameterName,this.invertX?-1:1,this.invertY?-1:1),i&&(e.setFloat(this._tangentCorrectionFactorName,i.getWorldMatrix().determinant()<0?-1:1),this.useObjectSpaceNormalMap&&!this.world.isConnected&&e.setMatrix(this._worldMatrixName,i.getWorldMatrix()))},t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.uv.isConnected){var i=e.getInputBlockByPredicate(function(a){return a.isAttribute&&a.name==="uv"&&n(a)});i||(i=new Mt("uv")).setAsAttribute(),i.output.connectTo(this.uv)}if(!this.strength.isConnected){var o=new Mt("strength");o.value=1,o.output.connectTo(this.strength)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n="//".concat(this.name),i=this.uv,o=this.worldPosition,a=this.worldNormal,s=this.worldTangent,l=e.shaderLanguage===1,c=l?"mat3x3f":"mat3",u=l?"f":"",d=l?"uniforms.":"";e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),this._tangentSpaceParameterName=e._getFreeDefineName("tangentSpaceParameter"),e._emitUniformFromString(this._tangentSpaceParameterName,G.Vector2),this._tangentCorrectionFactorName=e._getFreeDefineName("tangentCorrectionFactor"),e._emitUniformFromString(this._tangentCorrectionFactorName,G.Float),this._worldMatrixName=e._getFreeDefineName("perturbNormalWorldMatrix"),e._emitUniformFromString(this._worldMatrixName,G.Matrix);var h=null;this.normalMapColor.connectedPoint&&(h=this.normalMapColor.connectedPoint._ownerBlock.samplerName);var p=this.viewDirection.isConnected&&(this.useParallaxOcclusion&&h||!this.useParallaxOcclusion&&this.parallaxHeight.isConnected),m=this.parallaxScale.isConnectedToInputBlock?this.parallaxScale.connectInputBlock.isConstant?e._emitFloat(this.parallaxScale.connectInputBlock.value):this.parallaxScale.associatedVariableName:"0.05",v=this.strength.isConnectedToInputBlock&&this.strength.connectInputBlock.isConstant?`
|
||
#if !defined(NORMALXYSCALE)
|
||
1.0/
|
||
#endif
|
||
`.concat(e._emitFloat(this.strength.connectInputBlock.value)):`
|
||
#if !defined(NORMALXYSCALE)
|
||
1.0/
|
||
#endif
|
||
`.concat(this.strength.associatedVariableName);l||e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var b={search:/defined\(TANGENT\)/g,replace:s.isConnected?"defined(TANGENT)":"defined(IGNORE)"},E=this.TBN;E.isConnected?e.compilationString+=`
|
||
#ifdef TBNBLOCK
|
||
`.concat(l?"var":"mat3"," vTBN = ").concat(E.associatedVariableName,`;
|
||
#endif
|
||
`):s.isConnected&&(e.compilationString+="".concat(e._declareLocalVar("tbnNormal",G.Vector3)," = normalize(").concat(a.associatedVariableName,`.xyz);
|
||
`),e.compilationString+="".concat(e._declareLocalVar("tbnTangent",G.Vector3)," = normalize(").concat(s.associatedVariableName,`.xyz);
|
||
`),e.compilationString+="".concat(e._declareLocalVar("tbnBitangent",G.Vector3)," = cross(tbnNormal, tbnTangent) * ").concat(l?"uniforms.":"").concat(this._tangentCorrectionFactorName,`;
|
||
`),e.compilationString+="".concat(l?"var":"mat3"," vTBN = ").concat(c,`(tbnTangent, tbnBitangent, tbnNormal);
|
||
`));var C=[b,{search:/varying mat3 vTBN;/g,replace:""},{search:/uniform mat4 normalMatrix;/g,replace:""}];l&&(C.push({search:/varying vTBN0: vec3f;/g,replace:""}),C.push({search:/varying vTBN1: vec3f;/g,replace:""}),C.push({search:/varying vTBN2: vec3f;/g,replace:""})),e._emitFunctionFromInclude("bumpFragmentMainFunctions",n,{replaceStrings:C});var T=l?"fn parallaxOcclusion(vViewDirCoT: vec3f, vNormalCoT: vec3f, texCoord: vec2f, parallaxScale:f32, bump: texture_2d<f32>, bumpSampler: sampler)":`#define inline
|
||
vec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)`,f=l?/fn parallaxOcclusion\(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32\)/g:/vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g,g=l?"fn parallaxOffset(viewDir: vec3f, heightScale: f32, height_: f32)":"vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)",S=l?/fn parallaxOffset\(viewDir: vec3f,heightScale: f32\)/g:/vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g;e._emitFunctionFromInclude("bumpFragmentFunctions",n,{replaceStrings:[{search:/#include<samplerFragmentDeclaration>\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g,replace:""},{search:/uniform sampler2D bumpSampler;/g,replace:""},{search:f,replace:T},{search:S,replace:g},{search:/texture.+?bumpSampler,vBumpUV\)\.w/g,replace:"height_"}]});var y=l?"textureSample(".concat(h,", ").concat(h+P.Y.AUTOSAMPLERSUFFIX):"texture2D(".concat(h),x=p&&h?"".concat(y,", ").concat(i.associatedVariableName," + uvOffset).xyz"):this.normalMapColor.associatedVariableName,R=e._getFreeVariableName("tempOutput");return e.compilationString+=e._declareLocalVar(R,G.Vector3)+" = vec3".concat(u,`(0.);
|
||
`),C=[{search:new RegExp("texture.+?bumpSampler".concat(l?"Sampler,fragmentInputs.":",","vBumpUV\\)"),"g"),replace:"".concat(x)},{search:/#define CUSTOM_FRAGMENT_BUMP_FRAGMENT/g,replace:"".concat(e._declareLocalVar("normalMatrix",G.Matrix)," = toNormalMatrix(").concat(this.world.isConnected?this.world.associatedVariableName:this._worldMatrixName,");")},{search:new RegExp("perturbNormal\\(TBN,texture.+?bumpSampler".concat(l?"Sampler,fragmentInputs.":",","vBumpUV\\+uvOffset\\).xyz,").concat(l?"uniforms.":"","vBumpInfos.y\\)"),"g"),replace:"perturbNormal(TBN, ".concat(x,", vBumpInfos.y)")},{search:/parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,replace:"parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, ".concat(l?p&&this.useParallaxOcclusion?"".concat(h,", ").concat(h+P.Y.AUTOSAMPLERSUFFIX):"bump, bumpSampler":p&&this.useParallaxOcclusion?h:"bumpSampler",")")},{search:/parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,replace:"parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, ".concat(p?this.parallaxHeight.associatedVariableName:"0.",")")},{search:/vBumpInfos.y/g,replace:v},{search:/vBumpInfos.z/g,replace:m},{search:/normalW=/g,replace:R+" = "},{search:/mat3\(normalMatrix\)\*normalW/g,replace:"".concat(c,"(normalMatrix) * ")+R},{search:/normalW/g,replace:a.associatedVariableName+".xyz"},{search:/viewDirectionW/g,replace:p?this.viewDirection.associatedVariableName:"vec3".concat(u,"(0.)")},b],l?(C.push({search:/fragmentInputs.vBumpUV/g,replace:i.associatedVariableName}),C.push({search:/input.vPositionW/g,replace:o.associatedVariableName+".xyz"}),C.push({search:/uniforms.vTangentSpaceParams/g,replace:d+this._tangentSpaceParameterName}),C.push({search:/var TBN: mat3x3f=mat3x3<f32>\(input.vTBN0,input.vTBN1,input.vTBN2\);/g,replace:"var TBN = vTBN;"})):(C.push({search:/vBumpUV/g,replace:i.associatedVariableName}),C.push({search:/vPositionW/g,replace:o.associatedVariableName+".xyz"}),C.push({search:/vTangentSpaceParams/g,replace:d+this._tangentSpaceParameterName})),e.compilationString+=e._emitCodeFromInclude("bumpFragment",n,{replaceStrings:C}),e.compilationString+=e._declareOutput(this.output)+" = vec4".concat(u,"(").concat(R,`, 0.);
|
||
`),this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".invertX = ").concat(this.invertX,`;
|
||
`);return e+="".concat(this._codeVariableName,".invertY = ").concat(this.invertY,`;
|
||
`),(e+="".concat(this._codeVariableName,".useParallaxOcclusion = ").concat(this.useParallaxOcclusion,`;
|
||
`))+"".concat(this._codeVariableName,".useObjectSpaceNormalMap = ").concat(this.useObjectSpaceNormalMap,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.invertX=this.invertX,e.invertY=this.invertY,e.useParallaxOcclusion=this.useParallaxOcclusion,e.useObjectSpaceNormalMap=this.useObjectSpaceNormalMap,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.invertX=e.invertX,this.invertY=e.invertY,this.useParallaxOcclusion=!!e.useParallaxOcclusion,this.useObjectSpaceNormalMap=!!e.useObjectSpaceNormalMap},(0,A.Cg)([dt("Invert X axis",0,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertX",void 0),(0,A.Cg)([dt("Invert Y axis",0,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertY",void 0),(0,A.Cg)([dt("Use parallax occlusion",0)],t.prototype,"useParallaxOcclusion",void 0),(0,A.Cg)([dt("Object Space Mode",0,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"useObjectSpaceNormalMap",void 0),t}(ut);(0,j.Y5)("BABYLON.PerturbNormalBlock",Hv);var Yv=function(r){function t(e){var n=r.call(this,e,_e.Fragment,!0)||this;return n.registerInput("value",G.Float,!0),n.registerInput("cutoff",G.Float,!0),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DiscardBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cutoff",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.sharedData.hints.needAlphaTesting=!0,this.cutoff.isConnected&&this.value.isConnected)return e.compilationString+="if (".concat(this.value.associatedVariableName," < ").concat(this.cutoff.associatedVariableName,`) { discard; }
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.DiscardBlock",Yv);var Xv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.registerOutput("output",G.Float,_e.Fragment),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FrontFacingBlock"},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target===_e.Vertex)throw"FrontFacingBlock must only be used in a fragment shader";var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary("1.0","0.0",e.shaderLanguage===0?"gl_FrontFacing":"fragmentInputs.frontFacing"),`;
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.FrontFacingBlock",Xv);var jv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.registerInput("input",G.AutoDetect,!1),n.registerOutput("dx",G.BasedOnInput),n.registerOutput("dy",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._outputs[1]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DerivativeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dx",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dy",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this._outputs[1];e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var o="dFdx",a="dFdy";return e.shaderLanguage===1&&(o="dpdx",a="dpdy"),n.hasEndpoints&&(e.compilationString+=e._declareOutput(n)+" = ".concat(o,"(").concat(this.input.associatedVariableName,`);
|
||
`)),i.hasEndpoints&&(e.compilationString+=e._declareOutput(i)+" = ".concat(a,"(").concat(this.input.associatedVariableName,`);
|
||
`)),this},t}(ut);(0,j.Y5)("BABYLON.DerivativeBlock",jv);var qv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.registerOutput("xy",G.Vector2,_e.Fragment),n.registerOutput("xyz",G.Vector3,_e.Fragment),n.registerOutput("xyzw",G.Vector4,_e.Fragment),n.registerOutput("x",G.Float,_e.Fragment),n.registerOutput("y",G.Float,_e.Fragment),n.registerOutput("z",G.Float,_e.Fragment),n.registerOutput("w",G.Float,_e.Fragment),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FragCoordBlock"},Object.defineProperty(t.prototype,"xy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),t.prototype.writeOutputs=function(e){for(var n="",i=e.shaderLanguage===1?"fragmentInputs.position":"gl_FragCoord",o=0,a=this._outputs;o<a.length;o++){var s=a[o];s.hasEndpoints&&(n+="".concat(e._declareOutput(s)," = ").concat(i,".").concat(s.name,`;
|
||
`))}return n},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target===_e.Vertex)throw"FragCoordBlock must only be used in a fragment shader";return e.compilationString+=this.writeOutputs(e),this},t}(ut);(0,j.Y5)("BABYLON.FragCoordBlock",qv);var Kv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.registerOutput("xy",G.Vector2,_e.Fragment),n.registerOutput("x",G.Float,_e.Fragment),n.registerOutput("y",G.Float,_e.Fragment),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ScreenSizeBlock"},Object.defineProperty(t.prototype,"xy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.bind=function(e){var n=this._scene.getEngine();e.setFloat2(this._varName,n.getRenderWidth(),n.getRenderHeight())},t.prototype.writeOutputs=function(e,n){for(var i="",o=0,a=this._outputs;o<a.length;o++){var s=a[o];s.hasEndpoints&&(i+="".concat(e._declareOutput(s)," = ").concat(n,".").concat(s.name,`;
|
||
`))}return i},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this._scene=e.sharedData.scene,e.target===_e.Vertex)throw"ScreenSizeBlock must only be used in a fragment shader";e.sharedData.bindableBlocks.push(this),this._varName=e._getFreeVariableName("screenSize"),e._emitUniformFromString(this._varName,G.Vector2);var n=e.shaderLanguage===1?"uniforms.":"";return e.compilationString+=this.writeOutputs(e,n+this._varName),this},t}(ut);(0,j.Y5)("BABYLON.ScreenSizeBlock",Kv);var Zv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.registerInput("vector",G.AutoDetect),n.registerInput("worldViewProjection",G.Matrix),n.registerOutput("output",G.Vector2),n.registerOutput("x",G.Float),n.registerOutput("y",G.Float),n.inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ScreenSpaceBlock"},Object.defineProperty(t.prototype,"vector",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldViewProjection",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.worldViewProjection.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.systemValue===Nt.WorldViewProjection&&n(o)});i||(i=new Mt("worldViewProjection")).setAsSystemValue(Nt.WorldViewProjection),i.output.connectTo(this.worldViewProjection)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.vector,i=this.worldViewProjection;if(n.connectedPoint){var o=i.associatedVariableName,a=e._getFreeVariableName("screenSpaceTemp");switch(n.connectedPoint.type){case G.Vector3:e.compilationString+="".concat(e._declareLocalVar(a,G.Vector4)," = ").concat(o," * vec4").concat(e.fSuffix,"(").concat(n.associatedVariableName,`, 1.0);
|
||
`);break;case G.Vector4:e.compilationString+="".concat(e._declareLocalVar(a,G.Vector4)," = ").concat(o," * ").concat(n.associatedVariableName,`;
|
||
`)}return e.compilationString+="".concat(a," = vec4").concat(e.fSuffix,"(").concat(a,".xy / ").concat(a,".w, ").concat(a,".zw);"),e.compilationString+="".concat(a," = vec4").concat(e.fSuffix,"(").concat(a,".xy * 0.5 + vec2").concat(e.fSuffix,"(0.5, 0.5), ").concat(a,".zw);"),this.output.hasEndpoints&&(e.compilationString+=e._declareOutput(this.output)+" = ".concat(a,`.xy;
|
||
`)),this.x.hasEndpoints&&(e.compilationString+=e._declareOutput(this.x)+" = ".concat(a,`.x;
|
||
`)),this.y.hasEndpoints&&(e.compilationString+=e._declareOutput(this.y)+" = ".concat(a,`.y;
|
||
`)),this}},t}(ut);(0,j.Y5)("BABYLON.ScreenSpaceBlock",Zv);var Qv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.registerInput("input",G.Vector2),n.registerInput("strength",G.Float),n.registerInput("center",G.Vector2),n.registerInput("offset",G.Vector2),n.registerOutput("output",G.Vector2),n.registerOutput("x",G.Float),n.registerOutput("y",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TwirlBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"strength",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"center",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offset",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.center.isConnected){var e=new Mt("center");e.value=new _.I9(.5,.5),e.output.connectTo(this.center)}if(!this.strength.isConnected){var n=new Mt("strength");n.value=1,n.output.connectTo(this.strength)}if(!this.offset.isConnected){var i=new Mt("offset");i.value=new _.I9(0,0),i.output.connectTo(this.offset)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=e._getFreeVariableName("delta"),i=e._getFreeVariableName("angle"),o=e._getFreeVariableName("x"),a=e._getFreeVariableName("y"),s=e._getFreeVariableName("result");return e.compilationString+=`
|
||
`.concat(e._declareLocalVar(n,G.Vector2)," = ").concat(this.input.associatedVariableName," - ").concat(this.center.associatedVariableName,`;
|
||
`).concat(e._declareLocalVar(i,G.Float)," = ").concat(this.strength.associatedVariableName," * length(").concat(n,`);
|
||
`).concat(e._declareLocalVar(o,G.Float)," = cos(").concat(i,") * ").concat(n,".x - sin(").concat(i,") * ").concat(n,`.y;
|
||
`).concat(e._declareLocalVar(a,G.Float)," = sin(").concat(i,") * ").concat(n,".x + cos(").concat(i,") * ").concat(n,`.y;
|
||
`).concat(e._declareLocalVar(s,G.Vector2)," = vec2(").concat(o," + ").concat(this.center.associatedVariableName,".x + ").concat(this.offset.associatedVariableName,".x, ").concat(a," + ").concat(this.center.associatedVariableName,".y + ").concat(this.offset.associatedVariableName,`.y);
|
||
`),this.output.hasEndpoints&&(e.compilationString+=e._declareOutput(this.output)+" = ".concat(s,`;
|
||
`)),this.x.hasEndpoints&&(e.compilationString+=e._declareOutput(this.x)+" = ".concat(s,`.x;
|
||
`)),this.y.hasEndpoints&&(e.compilationString+=e._declareOutput(this.y)+" = ".concat(s,`.y;
|
||
`)),this},t}(ut);(0,j.Y5)("BABYLON.TwirlBlock",Qv);var Jv=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.generateInWorldSpace=!1,n.automaticNormalizationNormal=!0,n.automaticNormalizationTangent=!0,n.registerInput("input",G.Float),n.registerInput("worldPosition",G.Vector3),n.registerInput("worldNormal",G.Vector3),n.registerInput("worldTangent",G.AutoDetect,!0),n.registerOutput("output",G.Vector4),n.registerOutput("xyz",G.Vector3),n._inputs[3].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"HeightToNormalBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=e.shaderLanguage===1,o=e.fSuffix;this.generateInWorldSpace||this.worldTangent.isConnected||O.V.Error("You must connect the 'worldTangent' input of the ".concat(this.name," block!"));var a=this.generateInWorldSpace?"":`
|
||
vec3 biTangent = cross(norm, tgt);
|
||
mat3 TBN = mat3(tgt, biTangent, norm);
|
||
`,s=this.generateInWorldSpace?"":`
|
||
result = TBN * result;
|
||
result = result * vec3(0.5) + vec3(0.5);
|
||
`,l=`
|
||
vec4 heightToNormal(float height, vec3 position, vec3 tangent, vec3 normal) {
|
||
vec3 tgt = `.concat(this.automaticNormalizationTangent?"normalize(tangent);":"tangent;",`
|
||
vec3 norm = `).concat(this.automaticNormalizationNormal?"normalize(normal);":"normal;",`
|
||
`).concat(a,`
|
||
vec3 worlddX = dFdx(position);
|
||
vec3 worlddY = dFdy(position);
|
||
vec3 crossX = cross(norm, worlddX);
|
||
vec3 crossY = cross(norm, worlddY);
|
||
float d = abs(dot(crossY, worlddX));
|
||
vec3 inToNormal = vec3(((((height + dFdx(height)) - height) * crossY) + (((height + dFdy(height)) - height) * crossX)) * sign(d));
|
||
inToNormal.y *= -1.0;
|
||
vec3 result = normalize((d * norm) - inToNormal);
|
||
`).concat(s,`
|
||
return vec4(result, 0.);
|
||
}`);return i?l=e._babylonSLtoWGSL(l):e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),e._emitFunction("heightToNormal",l,"// heightToNormal"),e.compilationString+=e._declareOutput(n)+" = heightToNormal(".concat(this.input.associatedVariableName,", ").concat(this.worldPosition.associatedVariableName,", ").concat(this.worldTangent.isConnected?this.worldTangent.associatedVariableName:"vec3".concat(o,"(0.)"),".xyz, ").concat(this.worldNormal.associatedVariableName,`);
|
||
`),this.xyz.hasEndpoints&&(e.compilationString+=e._declareOutput(this.xyz)+" = ".concat(this.output.associatedVariableName,`.xyz;
|
||
`)),this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+="".concat(this._codeVariableName,".generateInWorldSpace = ").concat(this.generateInWorldSpace,`;
|
||
`),(e+="".concat(this._codeVariableName,".automaticNormalizationNormal = ").concat(this.automaticNormalizationNormal,`;
|
||
`))+"".concat(this._codeVariableName,".automaticNormalizationTangent = ").concat(this.automaticNormalizationTangent,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.generateInWorldSpace=this.generateInWorldSpace,e.automaticNormalizationNormal=this.automaticNormalizationNormal,e.automaticNormalizationTangent=this.automaticNormalizationTangent,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.generateInWorldSpace=e.generateInWorldSpace,this.automaticNormalizationNormal=e.automaticNormalizationNormal,this.automaticNormalizationTangent=e.automaticNormalizationTangent},(0,A.Cg)([dt("Generate in world space instead of tangent space",0,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"generateInWorldSpace",void 0),(0,A.Cg)([dt("Force normalization for the worldNormal input",0,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"automaticNormalizationNormal",void 0),(0,A.Cg)([dt("Force normalization for the worldTangent input",0,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"automaticNormalizationTangent",void 0),t}(ut);(0,j.Y5)("BABYLON.HeightToNormalBlock",Jv);var $v=function(r){function t(e){var n=r.call(this,e,_e.Fragment,!0)||this;return n.registerInput("depth",G.Float,!0),n.registerInput("worldPos",G.Vector4,!0),n.registerInput("viewProjection",G.Matrix,!0),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FragDepthBlock"},Object.defineProperty(t.prototype,"depth",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPos",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewProjection",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=e.shaderLanguage===0?"gl_FragDepth":"fragmentOutputs.fragDepth";return this.depth.isConnected?e.compilationString+="".concat(n," = ").concat(this.depth.associatedVariableName,`;
|
||
`):this.worldPos.isConnected&&this.viewProjection.isConnected?e.compilationString+=`
|
||
`.concat(e._declareLocalVar("p",G.Vector4)," = ").concat(this.viewProjection.associatedVariableName," * ").concat(this.worldPos.associatedVariableName,`;
|
||
`).concat(e._declareLocalVar("v",G.Float),` = p.z / p.w;
|
||
#ifndef IS_NDC_HALF_ZRANGE
|
||
v = v * 0.5 + 0.5;
|
||
#endif
|
||
`).concat(n,` = v;
|
||
|
||
`):O.V.Warn("FragDepthBlock: either the depth input or both the worldPos and viewProjection inputs must be connected!"),this},t}(ut);(0,j.Y5)("BABYLON.FragDepthBlock",$v);var ey=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.registerInput("worldPosition",G.Vector4,!1),n.registerInput("viewProjection",G.Matrix,!1),n.registerInput("worldNormal",G.AutoDetect,!0),n.registerOutput("depth",G.Vector3),n.worldNormal.addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ShadowMapBlock"},t.prototype.initialize=function(e){e._excludeVariableName("vPositionWSM"),e._excludeVariableName("lightDataSM"),e._excludeVariableName("biasAndScaleSM"),e._excludeVariableName("depthValuesSM"),e._excludeVariableName("clipPos"),e._excludeVariableName("worldPos"),e._excludeVariableName("zSM"),this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,28924)),Promise.resolve().then(L.bind(L,68298)),Promise.resolve().then(L.bind(L,79574))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,62371)),Promise.resolve().then(L.bind(L,78531)),Promise.resolve().then(L.bind(L,29313))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewProjection",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depth",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n="//".concat(this.name),i=e.shaderLanguage===1;e._emitUniformFromString("biasAndScaleSM",G.Vector3),e._emitUniformFromString("lightDataSM",G.Vector3),e._emitUniformFromString("depthValuesSM",G.Vector2),e._emitFunctionFromInclude("packingFunctions",n),e.compilationString+="".concat(e._declareLocalVar("worldPos",G.Vector4)," = ").concat(this.worldPosition.associatedVariableName,`;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("vPositionWSM",G.Vector3),`;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("vDepthMetricSM",G.Float),` = 0.0;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("zSM",G.Float),`;
|
||
`),this.worldNormal.isConnected&&(e.compilationString+="".concat(e._declareLocalVar("vNormalW",G.Vector3)," = ").concat(this.worldNormal.associatedVariableName,`.xyz;
|
||
`),e.compilationString+=e._emitCodeFromInclude("shadowMapVertexNormalBias",n)),e.compilationString+="".concat(e._declareLocalVar("clipPos",G.Vector4)," = ").concat(this.viewProjection.associatedVariableName,` * worldPos;
|
||
`),e.compilationString+=e._emitCodeFromInclude("shadowMapVertexMetric",n,{replaceStrings:[{search:/gl_Position/g,replace:"clipPos"},{search:/vertexOutputs.position/g,replace:"clipPos"}]}),e.compilationString+=e._emitCodeFromInclude("shadowMapFragment",n,{replaceStrings:[{search:/return;/g,replace:""}]});var o=i?"fragmentOutputs.fragDepth":"gl_FragDepth";return e.compilationString+=`
|
||
#if SM_DEPTHTEXTURE == 1
|
||
#ifdef IS_NDC_HALF_ZRANGE
|
||
`.concat(o,` = (clipPos.z / clipPos.w);
|
||
#else
|
||
`).concat(o,` = (clipPos.z / clipPos.w) * 0.5 + 0.5;
|
||
#endif
|
||
#endif
|
||
`),e.compilationString+="".concat(e._declareOutput(this.depth)," = vec3").concat(e.fSuffix,`(depthSM, 1., 1.);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ShadowMapBlock",ey);var ty=function(r){function t(e){var n=r.call(this,e,_e.Fragment,!0)||this;return n.registerInput("viewDepth",G.Float,!0),n.registerInput("screenDepth",G.Float,!0),n.registerInput("worldPosition",G.AutoDetect,!0),n.registerInput("localPosition",G.AutoDetect,!0),n.registerInput("viewNormal",G.AutoDetect,!0),n.registerInput("worldNormal",G.AutoDetect,!0),n.registerInput("reflectivity",G.AutoDetect,!0),n.inputs[2].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4),n.inputs[3].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4),n.inputs[4].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4),n.inputs[5].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4),n.inputs[6].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4|G.Color3|G.Color4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"PrePassOutputBlock"},Object.defineProperty(t.prototype,"viewDepth",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screenDepth",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localPosition",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewNormal",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectivity",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),t.prototype._getFragData=function(e,n){return e?"fragmentOutputs.fragData".concat(n):"gl_FragData[".concat(n,"]")},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.worldPosition,i=this.localPosition,o=this.viewNormal,a=this.worldNormal,s=this.viewDepth,l=this.reflectivity,c=this.screenDepth;e.sharedData.blocksWithDefines.push(this);var u="//".concat(this.name),d=e._getShaderType(G.Vector4),h=e.shaderLanguage===1;return e._emitFunctionFromInclude("helperFunctions",u),e.compilationString+=`#if defined(PREPASS)\r
|
||
`,e.compilationString+=h?`var fragData: array<vec4<f32>, SCENE_MRT_COUNT>;\r
|
||
`:`vec4 fragData[SCENE_MRT_COUNT];\r
|
||
`,e.compilationString+=`#ifdef PREPASS_DEPTH\r
|
||
`,s.connectedPoint?e.compilationString+=" fragData[PREPASS_DEPTH_INDEX] = ".concat(d,"(").concat(s.associatedVariableName,`, 0.0, 0.0, 1.0);\r
|
||
`):e.compilationString+=" fragData[PREPASS_DEPTH_INDEX] = ".concat(d,`(0.0, 0.0, 0.0, 0.0);\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#ifdef PREPASS_SCREENSPACE_DEPTH\r
|
||
`,c.connectedPoint?e.compilationString+=" gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX] = vec4(".concat(c.associatedVariableName,`, 0.0, 0.0, 1.0);\r
|
||
`):e.compilationString+=` gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r
|
||
`,e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#ifdef PREPASS_POSITION\r
|
||
`,n.connectedPoint?e.compilationString+="fragData[PREPASS_POSITION_INDEX] = ".concat(d,"(").concat(n.associatedVariableName,".rgb, ").concat(n.connectedPoint.type===G.Vector4?n.associatedVariableName+".a":"1.0",`);\r
|
||
`):e.compilationString+=" fragData[PREPASS_POSITION_INDEX] = ".concat(d,`(0.0, 0.0, 0.0, 0.0);\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#ifdef PREPASS_LOCAL_POSITION\r
|
||
`,i.connectedPoint?e.compilationString+=" gl_FragData[PREPASS_LOCAL_POSITION_INDEX] = vec4(".concat(i.associatedVariableName,".rgb, ").concat(i.connectedPoint.type===G.Vector4?i.associatedVariableName+".a":"1.0",`);\r
|
||
`):e.compilationString+=` gl_FragData[PREPASS_LOCAL_POSITION_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r
|
||
`,e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#ifdef PREPASS_NORMAL\r
|
||
`,o.connectedPoint?e.compilationString+=" fragData[PREPASS_NORMAL_INDEX] = ".concat(d,"(").concat(o.associatedVariableName,".rgb, ").concat(o.connectedPoint.type===G.Vector4?o.associatedVariableName+".a":"1.0",`);\r
|
||
`):e.compilationString+=" fragData[PREPASS_NORMAL_INDEX] = ".concat(d,`(0.0, 0.0, 0.0, 0.0);\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#ifdef PREPASS_WORLD_NORMAL\r
|
||
`,a.connectedPoint?e.compilationString+=" gl_FragData[PREPASS_WORLD_NORMAL_INDEX] = vec4(".concat(a.associatedVariableName,".rgb, ").concat(a.connectedPoint.type===G.Vector4?a.associatedVariableName+".a":"1.0",`);\r
|
||
`):e.compilationString+=` gl_FragData[PREPASS_WORLD_NORMAL_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r
|
||
`,e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#ifdef PREPASS_REFLECTIVITY\r
|
||
`,l.connectedPoint?e.compilationString+=" fragData[PREPASS_REFLECTIVITY_INDEX] = ".concat(d,"(").concat(l.associatedVariableName,".rgb, ").concat(l.connectedPoint.type===G.Vector4?l.associatedVariableName+".a":"1.0",`);\r
|
||
`):e.compilationString+=" fragData[PREPASS_REFLECTIVITY_INDEX] = ".concat(d,`(0.0, 0.0, 0.0, 1.0);\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#if SCENE_MRT_COUNT > 1\r
|
||
`,e.compilationString+="".concat(this._getFragData(h,1),` = fragData[1];\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#if SCENE_MRT_COUNT > 2\r
|
||
`,e.compilationString+="".concat(this._getFragData(h,2),` = fragData[2];\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#if SCENE_MRT_COUNT > 3\r
|
||
`,e.compilationString+="".concat(this._getFragData(h,3),` = fragData[3];\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#if SCENE_MRT_COUNT > 4\r
|
||
`,e.compilationString+="".concat(this._getFragData(h,4),` = fragData[4];\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#if SCENE_MRT_COUNT > 5\r
|
||
`,e.compilationString+="".concat(this._getFragData(h,5),` = fragData[5];\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#if SCENE_MRT_COUNT > 6\r
|
||
`,e.compilationString+="".concat(this._getFragData(h,6),` = fragData[6];\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#if SCENE_MRT_COUNT > 7\r
|
||
`,e.compilationString+="".concat(this._getFragData(h,7),` = fragData[7];\r
|
||
`),e.compilationString+=`#endif\r
|
||
`,e.compilationString+=`#endif\r
|
||
`,this},t}(ut);(0,j.Y5)("BABYLON.PrePassOutputBlock",ty);var hA=L(86320),fA=L(4661),pA=L(75334),_A=L(59581),mA=L(40688),gA=L(20274),vA=L(96830),yA=L(66633),bA=L(56159),TA=L(48661),SA=L(75394),EA=L(28924),xA=L(68298),PA=L(79574),AA=L(62371),CA=L(78531),RA=L(29313),ny=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment,!1)||this;return n.registerInput("worldPosition",G.Vector4,!1,_e.Vertex),n.registerInput("view",G.Matrix,!1,_e.Vertex),n.registerInput("input",G.AutoDetect,!1,_e.Fragment),n.registerInput("fogColor",G.AutoDetect,!1,_e.Fragment),n.registerOutput("output",G.Color3,_e.Fragment),n.input.addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Color4),n.fogColor.addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Color4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FogBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fogColor",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,98318))];case 1:return n.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,52767))];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.view.isConnected){var i=e.getInputBlockByPredicate(function(a){return a.systemValue===Nt.View&&n(a)});i||(i=new Mt("view")).setAsSystemValue(Nt.View),i.output.connectTo(this.view)}if(!this.fogColor.isConnected){var o=e.getInputBlockByPredicate(function(a){return a.systemValue===Nt.FogColor&&n(a)});o||(o=new Mt("fogColor",void 0,G.Color3)).setAsSystemValue(Nt.FogColor),o.output.connectTo(this.fogColor)}},t.prototype.prepareDefines=function(e,n,i){var o=e.getScene();i.setValue("FOG",n.fogEnabled&&(0,Re.qL)(e,o))},t.prototype.bind=function(e,n,i){if(i){var o=i.getScene();e.setFloat4(this._fogParameters,o.fogMode,o.fogStart,o.fogEnd,o.fogDensity)}},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target===_e.Fragment){e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this);var n=[],i="",o="";e.shaderLanguage===1?(n=[{search:/fn CalcFogFactor\(\)/,replace:"fn CalcFogFactor(vFogDistance: vec3f, vFogInfos: vec4f)"},{search:/uniforms.vFogInfos/g,replace:"vFogInfos"},{search:/fragmentInputs.vFogDistance/g,replace:"vFogDistance"}],i="fragmentInputs.",o="uniforms."):n=[{search:/float CalcFogFactor\(\)/,replace:"float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"}],e._emitFunctionFromInclude("fogFragmentDeclaration","//".concat(this.name),{removeUniforms:!0,removeVaryings:!0,removeIfDef:!1,replaceStrings:n});var a=e._getFreeVariableName("fog"),s=this.input,l=this.fogColor;this._fogParameters=e._getFreeVariableName("fogParameters");var c=this._outputs[0];e._emitUniformFromString(this._fogParameters,G.Vector4),e.compilationString+=`#ifdef FOG
|
||
`,e.compilationString+="".concat(e._declareLocalVar(a,G.Float)," = CalcFogFactor(").concat(i).concat(this._fogDistanceName,", ").concat(o).concat(this._fogParameters,`);
|
||
`),e.compilationString+=e._declareOutput(c)+" = ".concat(a," * ").concat(s.associatedVariableName,".rgb + (1.0 - ").concat(a,") * ").concat(l.associatedVariableName,`.rgb;
|
||
`),e.compilationString+=`#else
|
||
`.concat(e._declareOutput(c)," = ").concat(s.associatedVariableName,`.rgb;
|
||
`),e.compilationString+=`#endif
|
||
`}else{var u=this.worldPosition,d=this.view;this._fogDistanceName=e._getFreeVariableName("vFogDistance"),e._emitVaryingFromString(this._fogDistanceName,G.Vector3);var h=e.shaderLanguage===1?"vertexOutputs.":"";e.compilationString+="".concat(h).concat(this._fogDistanceName," = (").concat(d.associatedVariableName," * ").concat(u.associatedVariableName,`).xyz;
|
||
`)}return this},t}(ut);(0,j.Y5)("BABYLON.FogBlock",ny);var iy=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment)||this;return n._lightId=0,n.generateOnlyFragmentCode=!1,n._isUnique=!0,n.registerInput("worldPosition",G.Vector4,!1,_e.Vertex),n.registerInput("worldNormal",G.Vector4,!1,_e.Fragment),n.registerInput("cameraPosition",G.Vector3,!1,_e.Fragment),n.registerInput("glossiness",G.Float,!0,_e.Fragment),n.registerInput("glossPower",G.Float,!0,_e.Fragment),n.registerInput("diffuseColor",G.Color3,!0,_e.Fragment),n.registerInput("specularColor",G.Color3,!0,_e.Fragment),n.registerInput("view",G.Matrix,!0),n.registerOutput("diffuseOutput",G.Color3,_e.Fragment),n.registerOutput("specularOutput",G.Color3,_e.Fragment),n.registerOutput("shadow",G.Float,_e.Fragment),n}return(0,A.C6)(t,r),t._OnGenerateOnlyFragmentCodeChanged=function(e,n){var i=e;return i.worldPosition.isConnected?(i.generateOnlyFragmentCode=!i.generateOnlyFragmentCode,O.V.Error("The worldPosition input must not be connected to be able to switch!"),!1):(i._setTarget(),!0)},t.prototype._setTarget=function(){this._setInitialTarget(this.generateOnlyFragmentCode?_e.Fragment:_e.VertexAndFragment),this.getInputByName("worldPosition").target=this.generateOnlyFragmentCode?_e.Fragment:_e.Vertex},t.prototype.getClassName=function(){return"LightBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glossiness",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glossPower",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseColor",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularColor",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseOutput",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularOutput",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadow",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,84192)),Promise.resolve().then(L.bind(L,10896)),Promise.resolve().then(L.bind(L,58902)),Promise.resolve().then(L.bind(L,17393)),Promise.resolve().then(L.bind(L,53378)),Promise.resolve().then(L.bind(L,32532)),Promise.resolve().then(L.bind(L,59115))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,87283)),Promise.resolve().then(L.bind(L,7363)),Promise.resolve().then(L.bind(L,32823)),Promise.resolve().then(L.bind(L,48961)),Promise.resolve().then(L.bind(L,94785)),Promise.resolve().then(L.bind(L,75334)),Promise.resolve().then(L.bind(L,54409)),Promise.resolve().then(L.bind(L,46837)),Promise.resolve().then(L.bind(L,62136))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.cameraPosition.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.systemValue===Nt.CameraPosition&&n(o)});i||(i=new Mt("cameraPosition")).setAsSystemValue(Nt.CameraPosition),i.output.connectTo(this.cameraPosition)}},t.prototype.prepareDefines=function(e,n,i){if(i._areLightsDirty){var o=e.getScene();if(this.light){var a={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};(0,Re.lo)(o,e,this.light,this._lightId,i,!0,a),a.needRebuild&&i.rebuild()}else(0,Re.az)(o,e,i,!0,n.maxSimultaneousLights)}},t.prototype.updateUniformsAndSamples=function(e,n,i,o){for(var a=0;a<n.maxSimultaneousLights&&i["LIGHT"+a];a++){var s=e.uniforms.indexOf("vLightData"+a)>=0;(0,Re.GD)(a,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+a],o,s)}},t.prototype.bind=function(e,n,i){if(i){var o=i.getScene();this.light?(0,Re.Kd)(this.light,this._lightId,o,e,!0):(0,Re.RL)(o,i,e,!0,n.maxSimultaneousLights)}},t.prototype._injectVertexCode=function(e){var n=this.worldPosition,i="//".concat(this.name);this.light?(this._lightId=(e.counters.lightCounter!==void 0?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var o="v_"+n.associatedVariableName;e._emitVaryingFromString(o,G.Vector4)&&(e.compilationString+=(e.shaderLanguage===1?"vertexOutputs.":"")+"".concat(o," = ").concat(n.associatedVariableName,`;
|
||
`)),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:n.associatedVariableName}]}):(e.compilationString+="".concat(e._declareLocalVar("worldPos",G.Vector4)," = ").concat(n.associatedVariableName,`;
|
||
`),this.view.isConnected&&(e.compilationString+="".concat(e._declareLocalVar("view",G.Matrix)," = ").concat(this.view.associatedVariableName,`;
|
||
`)),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{repeatKey:"maxSimultaneousLights"}))},t.prototype._injectUBODeclaration=function(e){var n="//".concat(this.name);this.light?e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",n,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"varying,":void 0})},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=e.shaderLanguage===1,i=n?"f":"",o="//".concat(this.name);if(e.target===_e.Fragment){this.generateOnlyFragmentCode&&e.sharedData.dynamicUniformBlocks.push(this);var a=n?"fragmentInputs.":"";e.sharedData.forcedBindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this);var s=this.worldPosition,l=s.associatedVariableName;this.generateOnlyFragmentCode?(l=e._getFreeVariableName("globalWorldPos"),e._emitFunction("light_globalworldpos","".concat(e._declareLocalVar(l,G.Vector3),`;
|
||
`),o),e.compilationString+="".concat(l," = ").concat(s.associatedVariableName,`.xyz;
|
||
`),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",o,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"worldPos,".concat(s.associatedVariableName):void 0})):l=a+"v_"+l+".xyz",e._emitFunctionFromInclude("helperFunctions",o);var c={search:/vPositionW/g,replace:l};if(n&&(c={search:/fragmentInputs\.vPositionW/g,replace:l}),e._emitFunctionFromInclude("lightsFragmentFunctions",o,{replaceStrings:[c]}),e._emitFunctionFromInclude("shadowsFragmentFunctions",o,{replaceStrings:[c]}),this._injectUBODeclaration(e),this._lightId===0&&(e._registerTempVariable("viewDirectionW")&&(e.compilationString+="".concat(e._declareLocalVar("viewDirectionW",G.Vector3)," = normalize(").concat(this.cameraPosition.associatedVariableName," - ").concat(l,`);
|
||
`)),e.compilationString+=n?`var info: lightingInfo;
|
||
`:`lightingInfo info;
|
||
`,e.compilationString+="".concat(e._declareLocalVar("shadow",G.Float),` = 1.;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("aggShadow",G.Float),` = 0.;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("numLights",G.Float),` = 0.;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("glossiness",G.Float)," = ").concat(this.glossiness.isConnected?this.glossiness.associatedVariableName:"1.0"," * ").concat(this.glossPower.isConnected?this.glossPower.associatedVariableName:"1024.0",`;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("diffuseBase",G.Vector3)," = vec3").concat(i,`(0., 0., 0.);
|
||
`),e.compilationString+="".concat(e._declareLocalVar("specularBase",G.Vector3)," = vec3").concat(i,`(0., 0., 0.);
|
||
`),e.compilationString+="".concat(e._declareLocalVar("normalW",G.Vector3)," = ").concat(this.worldNormal.associatedVariableName,`.xyz;
|
||
`)),this.light){var u={search:/vPositionW/g,replace:l+".xyz"};n&&(u={search:/fragmentInputs\.vPositionW/g,replace:l+".xyz"}),e.compilationString+=e._emitCodeFromInclude("lightFragment",o,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},u]})}else{var d="vPositionW,".concat(l,".xyz");n&&(d="fragmentInputs.vPositionW,".concat(l,".xyz")),e.compilationString+=e._emitCodeFromInclude("lightFragment",o,{repeatKey:"maxSimultaneousLights",substitutionVars:d})}this._lightId===0&&(e.compilationString+=`aggShadow = aggShadow / numLights;
|
||
`);var h=this.diffuseOutput,p=this.specularOutput;return e.compilationString+=e._declareOutput(h)+" = diffuseBase".concat(this.diffuseColor.isConnected?" * "+this.diffuseColor.associatedVariableName:"",`;
|
||
`),p.hasEndpoints&&(e.compilationString+=e._declareOutput(p)+" = specularBase".concat(this.specularColor.isConnected?" * "+this.specularColor.associatedVariableName:"",`;
|
||
`)),this.shadow.hasEndpoints&&(e.compilationString+=e._declareOutput(this.shadow)+` = aggShadow;
|
||
`),this}this._injectVertexCode(e)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.generateOnlyFragmentCode=this.generateOnlyFragmentCode,this.light&&(e.lightId=this.light.id),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),e.lightId&&(this.light=n.getLightById(e.lightId)),this.generateOnlyFragmentCode=e.generateOnlyFragmentCode,this._setTarget()},(0,A.Cg)([dt("Generate only fragment code",0,"ADVANCED",{notifiers:{rebuild:!0,update:!0,onValidation:t._OnGenerateOnlyFragmentCodeChanged}})],t.prototype,"generateOnlyFragmentCode",void 0),t}(ut);(0,j.Y5)("BABYLON.LightBlock",iy);var sr=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment)||this;return n.registerOutput("source",G.Object,_e.VertexAndFragment,new bn("source",n,1,t,"ImageSourceBlock")),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){var n,i=this;if(this._texture!==e){var o=(n=e?.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;!e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i._texture)}),this._texture=e,e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(e)})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerName",{get:function(){return this._samplerName},enumerable:!1,configurable:!0}),t.prototype.bind=function(e){this.texture&&e.setTexture(this._samplerName,this.texture)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.getClassName=function(){return"ImageSourceBlock"},Object.defineProperty(t.prototype,"source",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){return r.prototype._buildBlock.call(this,e),e.target===_e.Vertex&&(this._samplerName=e._getFreeVariableName(this.name+"Texture"),e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),e.sharedData.bindableBlocks.push(this)),e._emit2DSampler(this._samplerName),this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return this.texture?(e+="".concat(this._codeVariableName,'.texture = new BABYLON.Texture("').concat(this.texture.name,'", null, ').concat(this.texture.noMipmap,", ").concat(this.texture.invertY,", ").concat(this.texture.samplingMode,`);
|
||
`),e+="".concat(this._codeVariableName,".texture.wrapU = ").concat(this.texture.wrapU,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.wrapV = ").concat(this.texture.wrapV,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uAng = ").concat(this.texture.uAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vAng = ").concat(this.texture.vAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.wAng = ").concat(this.texture.wAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uOffset = ").concat(this.texture.uOffset,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vOffset = ").concat(this.texture.vOffset,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uScale = ").concat(this.texture.uScale,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vScale = ").concat(this.texture.vScale,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.coordinatesMode = ").concat(this.texture.coordinatesMode,`;
|
||
`)):e},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.texture&&!this.texture.isRenderTarget&&this.texture.getClassName()!=="VideoTexture"&&(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i,o){r.prototype._deserialize.call(this,e,n,i,o),e.texture&&!so.IgnoreTexturesAtLoadTime&&e.texture.url!==void 0&&(e.texture.url.indexOf("data:")===0?i="":o&&(e.texture.url=o(e.texture.url),e.texture.name=e.texture.url),this.texture=Ie.g.Parse(e.texture,n,i))},t}(ut);(0,j.Y5)("BABYLON.ImageSourceBlock",sr);var ry=function(r){function t(e,n){n===void 0&&(n=!1);var i=r.call(this,e,n?_e.Fragment:_e.VertexAndFragment)||this;return i._convertToGammaSpace=!1,i._convertToLinearSpace=!1,i.disableLevelMultiplication=!1,i._fragmentOnly=n,i.registerInput("uv",G.AutoDetect,!1,_e.VertexAndFragment),i.registerInput("source",G.Object,!0,_e.VertexAndFragment,new bn("source",i,0,sr,"ImageSourceBlock")),i.registerInput("layer",G.Float,!0),i.registerInput("lod",G.Float,!0),i.registerOutput("rgba",G.Color4,_e.Neutral),i.registerOutput("rgb",G.Color3,_e.Neutral),i.registerOutput("r",G.Float,_e.Neutral),i.registerOutput("g",G.Float,_e.Neutral),i.registerOutput("b",G.Float,_e.Neutral),i.registerOutput("a",G.Float,_e.Neutral),i.registerOutput("level",G.Float,_e.Neutral),i._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Vector2|G.Vector3|G.Vector4),i._inputs[0]._prioritizeVertex=!n,i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"texture",{get:function(){var e;return this.source.isConnected?((e=this.source.connectedPoint)===null||e===void 0?void 0:e.ownerBlock).texture:this._texture},set:function(e){var n,i=this;if(this._texture!==e){var o=(n=e?.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;!e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i._texture)}),this._texture=e,e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(e)})}},enumerable:!1,configurable:!0}),t._IsPrePassTextureBlock=function(e){return e?.getClassName()==="PrePassTextureBlock"},Object.defineProperty(t.prototype,"_isSourcePrePass",{get:function(){return t._IsPrePassTextureBlock(this._imageSource)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerName",{get:function(){if(this._imageSource){if(!t._IsPrePassTextureBlock(this._imageSource))return this._imageSource.samplerName;if(this.source.connectedPoint)return this._imageSource.getSamplerName(this.source.connectedPoint)}return this._samplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasImageSource",{get:function(){return this.source.isConnected},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToGammaSpace",{get:function(){return this._convertToGammaSpace},set:function(e){var n,i=this;if(e!==this._convertToGammaSpace&&(this._convertToGammaSpace=e,this.texture)){var o=(n=this.texture.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;o?.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i.texture)})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToLinearSpace",{get:function(){return this._convertToLinearSpace},set:function(e){var n,i=this;if(e!==this._convertToLinearSpace&&(this._convertToLinearSpace=e,this.texture)){var o=(n=this.texture.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;o?.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i.texture)})}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TextureBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layer",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lod",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){if(this._fragmentOnly)return _e.Fragment;if(!this.uv.isConnected||this.uv.sourceBlock.isInput)return _e.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===_e.Fragment)return _e.Fragment;if(e.target===_e.Vertex)return _e.VertexAndFragment;if(e.target===_e.Neutral||e.target===_e.VertexAndFragment){var n=e.ownerBlock;if(n.target===_e.Fragment)return _e.Fragment;e=null;for(var i=0,o=n.inputs;i<o.length;i++){var a=o[i];if(a.connectedPoint){e=a.connectedPoint;break}}}}return _e.VertexAndFragment},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.uv.isConnected){if(e.mode===mi.PostProcess)(i=e.getBlockByPredicate(function(a){return a.name==="uv"&&n(a)}))&&i.connectTo(this);else if(e.mode!==mi.ProceduralTexture){var i,o=e.mode===mi.Particle?"particle_uv":"uv";(i=e.getInputBlockByPredicate(function(a){return a.isAttribute&&a.name===o&&n(a)}))||(i=new Mt("uv")).setAsAttribute(o),i.output.connectTo(this.uv)}}},t.prototype.initializeDefines=function(e,n,i){i._areTexturesDirty&&this._mainUVDefineName!==void 0&&i.setValue(this._mainUVDefineName,!1,!0)},t.prototype.prepareDefines=function(e,n,i){if(i._areTexturesDirty)if(this.texture&&this.texture.getTextureMatrix){var o=this.convertToGammaSpace&&this.texture&&!this.texture.gammaSpace,a=this.convertToLinearSpace&&this.texture&&this.texture.gammaSpace;i.setValue(this._linearDefineName,o,!0),i.setValue(this._gammaDefineName,a,!0),this._isMixed&&(this.texture.getTextureMatrix().isIdentityAs3x2()?(i.setValue(this._defineName,!1,!0),i.setValue(this._mainUVDefineName,!0,!0)):(i.setValue(this._defineName,!0),i[this._mainUVDefineName]==null&&i.setValue(this._mainUVDefineName,!1,!0)))}else this._isMixed&&(i.setValue(this._defineName,!1,!0),i.setValue(this._mainUVDefineName,!0,!0))},t.prototype.isReady=function(){return!!this._isSourcePrePass||!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.bind=function(e){this._isSourcePrePass&&e.setFloat(this._textureInfoName,1),this.texture&&(this._isMixed&&(e.setFloat(this._textureInfoName,this.texture.level),e.setMatrix(this._textureTransformName,this.texture.getTextureMatrix())),this._imageSource||e.setTexture(this._samplerName,this.texture))},Object.defineProperty(t.prototype,"_isMixed",{get:function(){return this.target!==_e.Fragment},enumerable:!1,configurable:!0}),t.prototype._injectVertexCode=function(e){var n=this.uv;this._defineName=e._getFreeDefineName("UVTRANSFORM"),this._mainUVDefineName="VMAIN"+n.declarationVariableName.toUpperCase(),this._mainUVName="vMain"+n.declarationVariableName,this._transformedUVName=e._getFreeVariableName("transformedUV"),this._textureTransformName=e._getFreeVariableName("textureTransform"),this._textureInfoName=e._getFreeVariableName("textureInfoName"),this.level.associatedVariableName=this._textureInfoName,e._emitVaryingFromString(this._transformedUVName,G.Vector2,this._defineName),e._emitVaryingFromString(this._mainUVName,G.Vector2,this._mainUVDefineName),e._emitUniformFromString(this._textureTransformName,G.Matrix,this._defineName);var i=e._getShaderType(G.Vector4),o=e._getShaderType(G.Vector2);e.compilationString+="#ifdef ".concat(this._defineName,`
|
||
`),e.compilationString+="".concat(e._getVaryingName(this._transformedUVName)," = ").concat(o,"(").concat(this._textureTransformName," * ").concat(i,"(").concat(n.associatedVariableName,`.xy, 1.0, 0.0));
|
||
`),e.compilationString+="#elif defined(".concat(this._mainUVDefineName,`)
|
||
`);var a="";if(e.shaderLanguage===1&&n.isConnectedToInputBlock&&n.associatedVariableName.indexOf("vertexInputs.")===-1&&(a="vertexInputs."),e.compilationString+="".concat(e._getVaryingName(this._mainUVName)," = ").concat(a).concat(n.associatedVariableName,`.xy;
|
||
`),e.compilationString+=`#endif
|
||
`,this._outputs.some(function(u){return u.isConnectedInVertexShader})){this._writeTextureRead(e,!0);for(var s=0,l=this._outputs;s<l.length;s++){var c=l[s];c.hasEndpoints&&c.name!=="level"&&this._writeOutput(e,c,c.name,!0)}}},t.prototype._getUVW=function(e){var n,i,o,a,s,l,c=e,u=(o=(i=(n=this._texture)===null||n===void 0?void 0:n._texture)===null||i===void 0?void 0:i.is2DArray)!==null&&o!==void 0&&o,d=(l=(s=(a=this._texture)===null||a===void 0?void 0:a._texture)===null||s===void 0?void 0:s.is3D)!==null&&l!==void 0&&l;if(u){var h=this.layer.isConnected?this.layer.associatedVariableName:"0";c="vec3(".concat(e,", ").concat(h,")")}else d&&(h=this.layer.isConnected?this.layer.associatedVariableName:"0",c="vec3(".concat(e,", ").concat(h,")"));return c},t.prototype._samplerFunc=function(e){return e.shaderLanguage===1?e.target===_e.Vertex?"textureSampleLevel":"textureSample":this.lod.isConnected?"texture2DLodEXT":"texture2D"},Object.defineProperty(t.prototype,"_samplerLodSuffix",{get:function(){return this.lod.isConnected?", ".concat(this.lod.associatedVariableName):""},enumerable:!1,configurable:!0}),t.prototype._generateTextureSample=function(e,n){if(n.shaderLanguage===1){var i=n.target===_e.Vertex;return"".concat(this._samplerFunc(n),"(").concat(this.samplerName,",").concat(this.samplerName+P.Y.AUTOSAMPLERSUFFIX,", ").concat(this._getUVW(e)).concat(this._samplerLodSuffix).concat(i?", 0":"",")")}return"".concat(this._samplerFunc(n),"(").concat(this.samplerName,", ").concat(this._getUVW(e)).concat(this._samplerLodSuffix,")")},t.prototype._generateTextureLookup=function(e){e.compilationString+="#ifdef ".concat(this._defineName,`
|
||
`),e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(this._generateTextureSample(e._getVaryingName(this._transformedUVName),e),`;
|
||
`),e.compilationString+="#elif defined(".concat(this._mainUVDefineName,`)
|
||
`),e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(this._generateTextureSample(this._mainUVName?e._getVaryingName(this._mainUVName):this.uv.associatedVariableName,e)).concat(this._samplerLodSuffix,`;
|
||
`),e.compilationString+=`#endif
|
||
`},t.prototype._writeTextureRead=function(e,n){n===void 0&&(n=!1);var i=this.uv;if(n){if(e.target===_e.Fragment)return;this._generateTextureLookup(e)}else this.uv.ownerBlock.target!==_e.Fragment?this._generateTextureLookup(e):e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(this._generateTextureSample(i.associatedVariableName,e)).concat(this._samplerLodSuffix,`;
|
||
`)},t.prototype._generateConversionCode=function(e,n,i){i!=="a"&&(this.texture&&this.texture.gammaSpace||(e.compilationString+="#ifdef ".concat(this._linearDefineName,`
|
||
`).concat(n.associatedVariableName," = toGammaSpace(").concat(n.associatedVariableName,`);
|
||
#endif
|
||
`)),e.compilationString+="#ifdef ".concat(this._gammaDefineName,`
|
||
`).concat(n.associatedVariableName," = ").concat(e._toLinearSpace(n),`;
|
||
#endif
|
||
`))},t.prototype._writeOutput=function(e,n,i,o){if(o===void 0&&(o=!1),o)return e.target===_e.Fragment?void 0:(e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`),void this._generateConversionCode(e,n,i));if(this.uv.ownerBlock.target===_e.Fragment)return e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`),void this._generateConversionCode(e,n,i);var a="";this.disableLevelMultiplication||(a=" * ".concat((e.shaderLanguage===1?"uniforms.":"")+this._textureInfoName)),e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i).concat(a,`;
|
||
`),this._generateConversionCode(e,n,i)},t.prototype._buildBlock=function(e){var n,i,o,a;if(r.prototype._buildBlock.call(this,e),this.source.isConnected?this._imageSource=this.source.connectedPoint.ownerBlock:this._imageSource=null,(e.target===_e.Vertex||this._fragmentOnly||e.target===_e.Fragment)&&(this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA")),!this._isMixed&&e.target===_e.Fragment||this._isMixed&&e.target===_e.Vertex){if(!this._imageSource){var s=e._getFreeVariableName(this.name);this._samplerName=s+"Texture",!((i=(n=this._texture)===null||n===void 0?void 0:n._texture)===null||i===void 0)&&i.is2DArray?e._emit2DArraySampler(this._samplerName):e._emit2DSampler(this._samplerName)}e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this)}if(e.target===_e.Fragment){if(this._outputs.some(function(h){return h.isConnectedInFragmentShader})){this._isMixed&&!this._imageSource&&(!((a=(o=this._texture)===null||o===void 0?void 0:o._texture)===null||a===void 0)&&a.is2DArray?e._emit2DArraySampler(this._samplerName):e._emit2DSampler(this._samplerName));var l="//".concat(this.name);e._emitFunctionFromInclude("helperFunctions",l),this._isMixed&&e._emitUniformFromString(this._textureInfoName,G.Float),this._writeTextureRead(e);for(var c=0,u=this._outputs;c<u.length;c++){var d=u[c];d.hasEndpoints&&d.name!=="level"&&this._writeOutput(e,d,d.name)}return this}}else this._injectVertexCode(e)},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+="".concat(this._codeVariableName,".convertToGammaSpace = ").concat(this.convertToGammaSpace,`;
|
||
`),e+="".concat(this._codeVariableName,".convertToLinearSpace = ").concat(this.convertToLinearSpace,`;
|
||
`),e+="".concat(this._codeVariableName,".disableLevelMultiplication = ").concat(this.disableLevelMultiplication,`;
|
||
`),this.texture?(e+="".concat(this._codeVariableName,'.texture = new BABYLON.Texture("').concat(this.texture.name,'", null, ').concat(this.texture.noMipmap,", ").concat(this.texture.invertY,", ").concat(this.texture.samplingMode,`);
|
||
`),e+="".concat(this._codeVariableName,".texture.wrapU = ").concat(this.texture.wrapU,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.wrapV = ").concat(this.texture.wrapV,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uAng = ").concat(this.texture.uAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vAng = ").concat(this.texture.vAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.wAng = ").concat(this.texture.wAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uOffset = ").concat(this.texture.uOffset,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vOffset = ").concat(this.texture.vOffset,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uScale = ").concat(this.texture.uScale,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vScale = ").concat(this.texture.vScale,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.coordinatesMode = ").concat(this.texture.coordinatesMode,`;
|
||
`)):e},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,e.fragmentOnly=this._fragmentOnly,e.disableLevelMultiplication=this.disableLevelMultiplication,this.hasImageSource||!this.texture||this.texture.isRenderTarget||this.texture.getClassName()==="VideoTexture"||(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i,o){r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,this._fragmentOnly=!!e.fragmentOnly,this.disableLevelMultiplication=!!e.disableLevelMultiplication,e.texture&&!so.IgnoreTexturesAtLoadTime&&e.texture.url!==void 0&&(e.texture.url.indexOf("data:")===0?i="":o&&(e.texture.url=o(e.texture.url),e.texture.name=e.texture.url),this.texture=Ie.g.Parse(e.texture,n,i))},t}(ut);(0,j.Y5)("BABYLON.TextureBlock",ry);var xl=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment)||this;return n.generateOnlyFragmentCode=!1,n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){var n,i=this;if(this._texture!==e){var o=(n=e?.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;!e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i._texture)}),this._texture=e,e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(e)})}},enumerable:!1,configurable:!0}),t._OnGenerateOnlyFragmentCodeChanged=function(e,n){return e._onGenerateOnlyFragmentCodeChanged()},t.prototype._onGenerateOnlyFragmentCodeChanged=function(){return this._setTarget(),!0},t.prototype._setTarget=function(){this._setInitialTarget(this.generateOnlyFragmentCode?_e.Fragment:_e.VertexAndFragment)},t.prototype.getClassName=function(){return"ReflectionTextureBaseBlock"},t.prototype._getTexture=function(){return this.texture},t.prototype.initialize=function(e){this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,61439))];case 1:return n.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,40150))];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.position.isConnected){var i=e.getInputBlockByPredicate(function(s){return s.isAttribute&&s.name==="position"&&n(s)});i||(i=new Mt("position")).setAsAttribute(),i.output.connectTo(this.position)}if(!this.world.isConnected){var o=e.getInputBlockByPredicate(function(s){return s.systemValue===Nt.World&&n(s)});o||(o=new Mt("world")).setAsSystemValue(Nt.World),o.output.connectTo(this.world)}if(this.view&&!this.view.isConnected){var a=e.getInputBlockByPredicate(function(s){return s.systemValue===Nt.View&&n(s)});a||(a=new Mt("view")).setAsSystemValue(Nt.View),a.output.connectTo(this.view)}},t.prototype.prepareDefines=function(e,n,i){if(i._areTexturesDirty){var o=this._getTexture();o&&o.getTextureMatrix&&(i.setValue(this._define3DName,o.isCube,!0),i.setValue(this._defineLocalCubicName,!!o.boundingBoxSize,!0),i.setValue(this._defineExplicitName,o.coordinatesMode===P.Y.TEXTURE_EXPLICIT_MODE,!0),i.setValue(this._defineSkyboxName,o.coordinatesMode===P.Y.TEXTURE_SKYBOX_MODE,!0),i.setValue(this._defineCubicName,o.coordinatesMode===P.Y.TEXTURE_CUBIC_MODE||o.coordinatesMode===P.Y.TEXTURE_INVCUBIC_MODE,!0),i.setValue("INVERTCUBICMAP",o.coordinatesMode===P.Y.TEXTURE_INVCUBIC_MODE,!0),i.setValue(this._defineSphericalName,o.coordinatesMode===P.Y.TEXTURE_SPHERICAL_MODE,!0),i.setValue(this._definePlanarName,o.coordinatesMode===P.Y.TEXTURE_PLANAR_MODE,!0),i.setValue(this._defineProjectionName,o.coordinatesMode===P.Y.TEXTURE_PROJECTION_MODE,!0),i.setValue(this._defineEquirectangularName,o.coordinatesMode===P.Y.TEXTURE_EQUIRECTANGULAR_MODE,!0),i.setValue(this._defineEquirectangularFixedName,o.coordinatesMode===P.Y.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,!0),i.setValue(this._defineMirroredEquirectangularFixedName,o.coordinatesMode===P.Y.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,!0))}},t.prototype.isReady=function(){var e=this._getTexture();return!(e&&!e.isReadyOrNotBlocking())},t.prototype.bind=function(e,n,i,o){var a=this._getTexture();if(i&&a&&(e.setMatrix(this._reflectionMatrixName,a.getReflectionTextureMatrix()),a.isCube?e.setTexture(this._cubeSamplerName,a):e.setTexture(this._2DSamplerName,a),a.boundingBoxSize)){var s=a;e.setVector3(this._reflectionPositionName,s.boundingBoxPosition),e.setVector3(this._reflectionSizeName,s.boundingBoxSize)}},t.prototype.handleVertexSide=function(e){if(this.generateOnlyFragmentCode&&e.target===_e.Vertex)return"";var n=e.shaderLanguage===1;this._define3DName=e._getFreeDefineName("REFLECTIONMAP_3D"),this._defineCubicName=e._getFreeDefineName("REFLECTIONMAP_CUBIC"),this._defineSphericalName=e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),this._definePlanarName=e._getFreeDefineName("REFLECTIONMAP_PLANAR"),this._defineProjectionName=e._getFreeDefineName("REFLECTIONMAP_PROJECTION"),this._defineExplicitName=e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),this._defineEquirectangularName=e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),this._defineLocalCubicName=e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),this._defineMirroredEquirectangularFixedName=e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),this._defineEquirectangularFixedName=e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),this._defineSkyboxName=e._getFreeDefineName("REFLECTIONMAP_SKYBOX"),this._defineOppositeZ=e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),this._reflectionMatrixName=e._getFreeVariableName("reflectionMatrix"),e._emitUniformFromString(this._reflectionMatrixName,G.Matrix);var i="";this._worldPositionNameInFragmentOnlyMode=e._getFreeVariableName("worldPosition");var o=this.generateOnlyFragmentCode?this._worldPositionNameInFragmentOnlyMode:"v_"+this.worldPosition.associatedVariableName;return(this.generateOnlyFragmentCode||e._emitVaryingFromString(o,G.Vector4))&&(this.generateOnlyFragmentCode?i+="".concat(e._declareLocalVar(o,G.Vector4)," = ").concat(this.worldPosition.associatedVariableName,`;
|
||
`):i+="".concat(n?"vertexOutputs.":"").concat(o," = ").concat(this.worldPosition.associatedVariableName,`;
|
||
`)),this._positionUVWName=e._getFreeVariableName("positionUVW"),this._directionWName=e._getFreeVariableName("directionW"),(this.generateOnlyFragmentCode||e._emitVaryingFromString(this._positionUVWName,G.Vector3,this._defineSkyboxName))&&(i+="#ifdef ".concat(this._defineSkyboxName,`
|
||
`),this.generateOnlyFragmentCode?i+="".concat(e._declareLocalVar(this._positionUVWName,G.Vector3)," = ").concat(this.position.associatedVariableName,`.xyz;
|
||
`):i+="".concat(n?"vertexOutputs.":"").concat(this._positionUVWName," = ").concat(this.position.associatedVariableName,`.xyz;
|
||
`),i+=`#endif
|
||
`),(this.generateOnlyFragmentCode||e._emitVaryingFromString(this._directionWName,G.Vector3,"defined(".concat(this._defineEquirectangularFixedName,") || defined(").concat(this._defineMirroredEquirectangularFixedName,")")))&&(i+="#if defined(".concat(this._defineEquirectangularFixedName,") || defined(").concat(this._defineMirroredEquirectangularFixedName,`)
|
||
`),this.generateOnlyFragmentCode?i+="".concat(e._declareLocalVar(this._directionWName,G.Vector3)," = normalize(vec3").concat(e.fSuffix,"(").concat(this.world.associatedVariableName," * vec4").concat(e.fSuffix,"(").concat(this.position.associatedVariableName,`.xyz, 0.0)));
|
||
`):i+="".concat(n?"vertexOutputs.":"").concat(this._directionWName," = normalize(vec3").concat(e.fSuffix,"(").concat(this.world.associatedVariableName," * vec4").concat(e.fSuffix,"(").concat(this.position.associatedVariableName,`.xyz, 0.0)));
|
||
`),i+=`#endif
|
||
`),i},t.prototype.handleFragmentSideInits=function(e){e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),this._cubeSamplerName=e._getFreeVariableName(this.name+"CubeSampler"),e.samplers.push(this._cubeSamplerName),this._2DSamplerName=e._getFreeVariableName(this.name+"2DSampler"),e.samplers.push(this._2DSamplerName),e._samplerDeclaration+="#ifdef ".concat(this._define3DName,`
|
||
`),e._emitCubeSampler(this._cubeSamplerName,"",!0),e._samplerDeclaration+=`#else
|
||
`,e._emit2DSampler(this._2DSamplerName,"",!0),e._samplerDeclaration+=`#endif
|
||
`,e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this);var n="//".concat(this.name);e._emitFunctionFromInclude("helperFunctions",n),e._emitFunctionFromInclude("reflectionFunction",n,{replaceStrings:[{search:/vec3 computeReflectionCoords/g,replace:"void DUMMYFUNC"},{search:/fn computeReflectionCoords\(worldPos: vec4f,worldNormal: vec3f\)->vec3f/g,replace:"fn DUMMYFUNC()"}]}),this._reflectionColorName=e._getFreeVariableName("reflectionColor"),this._reflectionVectorName=e._getFreeVariableName("reflectionUVW"),this._reflectionCoordsName=e._getFreeVariableName("reflectionCoords"),this._reflectionPositionName=e._getFreeVariableName("vReflectionPosition"),e._emitUniformFromString(this._reflectionPositionName,G.Vector3),this._reflectionSizeName=e._getFreeVariableName("vReflectionPosition"),e._emitUniformFromString(this._reflectionSizeName,G.Vector3)},t.prototype.handleFragmentSideCodeReflectionCoords=function(e,n,i,o,a){o===void 0&&(o=!1),a===void 0&&(a=!1),i||(i=this.generateOnlyFragmentCode?this._worldPositionNameInFragmentOnlyMode:"v_".concat(this.worldPosition.associatedVariableName));var s=(e.shaderLanguage===1?"uniforms.":"")+this._reflectionMatrixName,l="normalize(".concat(this._directionWName,")"),c="".concat(this._positionUVWName),u="".concat(this.cameraPosition.associatedVariableName),d="".concat(this.view.associatedVariableName);n+=".xyz";var h=`
|
||
#ifdef `.concat(this._defineMirroredEquirectangularFixedName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeMirroredFixedEquirectangularCoords(").concat(i,", ").concat(n,", ").concat(l,`);
|
||
#endif
|
||
|
||
#ifdef `).concat(this._defineEquirectangularFixedName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeFixedEquirectangularCoords(").concat(i,", ").concat(n,", ").concat(l,`);
|
||
#endif
|
||
|
||
#ifdef `).concat(this._defineEquirectangularName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeEquirectangularCoords(").concat(i,", ").concat(n,", ").concat(u,".xyz, ").concat(s,`);
|
||
#endif
|
||
|
||
#ifdef `).concat(this._defineSphericalName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeSphericalCoords(").concat(i,", ").concat(n,", ").concat(d,", ").concat(s,`);
|
||
#endif
|
||
|
||
#ifdef `).concat(this._definePlanarName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computePlanarCoords(").concat(i,", ").concat(n,", ").concat(u,".xyz, ").concat(s,`);
|
||
#endif
|
||
|
||
#ifdef `).concat(this._defineCubicName,`
|
||
#ifdef `).concat(this._defineLocalCubicName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeCubicLocalCoords(").concat(i,", ").concat(n,", ").concat(u,".xyz, ").concat(s,", ").concat(this._reflectionSizeName,", ").concat(this._reflectionPositionName,`);
|
||
#else
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeCubicCoords(").concat(i,", ").concat(n,", ").concat(u,".xyz, ").concat(s,`);
|
||
#endif
|
||
#endif
|
||
|
||
#ifdef `).concat(this._defineProjectionName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeProjectionCoords(").concat(i,", ").concat(d,", ").concat(s,`);
|
||
#endif
|
||
|
||
#ifdef `).concat(this._defineSkyboxName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3)," = computeSkyBoxCoords(").concat(c,", ").concat(s,`);
|
||
#endif
|
||
|
||
#ifdef `).concat(this._defineExplicitName,`
|
||
`).concat(e._declareLocalVar(this._reflectionVectorName,G.Vector3),` = vec3(0, 0, 0);
|
||
#endif
|
||
`);return a||(h+="#ifdef ".concat(this._defineOppositeZ,`
|
||
`).concat(this._reflectionVectorName,`.z *= -1.0;
|
||
#endif
|
||
`)),o||(h+=`
|
||
#ifdef `.concat(this._define3DName,`
|
||
`).concat(e._declareLocalVar(this._reflectionCoordsName,G.Vector3)," = ").concat(this._reflectionVectorName,`;
|
||
#else
|
||
`).concat(e._declareLocalVar(this._reflectionCoordsName,G.Vector2)," = ").concat(this._reflectionVectorName,`.xy;
|
||
#ifdef `).concat(this._defineProjectionName,`
|
||
`).concat(this._reflectionCoordsName," /= ").concat(this._reflectionVectorName,`.z;
|
||
#endif
|
||
`).concat(this._reflectionCoordsName,".y = 1.0 - ").concat(this._reflectionCoordsName,`.y;
|
||
#endif
|
||
`)),h},t.prototype.handleFragmentSideCodeReflectionColor=function(e,n,i){i===void 0&&(i=".rgb");var o=G.Vector4;i.length===3&&(o=G.Vector3);var a="".concat(e._declareLocalVar(this._reflectionColorName,o),`;
|
||
#ifdef `).concat(this._define3DName,`
|
||
`);return a+=n?"".concat(this._reflectionColorName," = ").concat(e._generateTextureSampleCubeLOD(this._reflectionVectorName,this._cubeSamplerName,n)).concat(i,`;
|
||
`):"".concat(this._reflectionColorName," = ").concat(e._generateTextureSampleCube(this._reflectionVectorName,this._cubeSamplerName)).concat(i,`;
|
||
`),a+=`
|
||
#else
|
||
`,(a+=n?"".concat(this._reflectionColorName," =").concat(e._generateTextureSampleLOD(this._reflectionCoordsName,this._2DSamplerName,n)).concat(i,`;
|
||
`):"".concat(this._reflectionColorName," = ").concat(e._generateTextureSample(this._reflectionCoordsName,this._2DSamplerName)).concat(i,`;
|
||
`))+`#endif
|
||
`},t.prototype.writeOutputs=function(e,n){var i="";if(e.target===_e.Fragment)for(var o=0,a=this._outputs;o<a.length;o++){var s=a[o];s.hasEndpoints&&(i+="".concat(e._declareOutput(s)," = ").concat(n,".").concat(s.name,`;
|
||
`))}return i},t.prototype._buildBlock=function(e){return r.prototype._buildBlock.call(this,e),this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);if(!this.texture)return e;if(this.texture.isCube){var n=this.texture.forcedExtension;e+="".concat(this._codeVariableName,'.texture = new BABYLON.CubeTexture("').concat(this.texture.name,'", undefined, undefined, ').concat(this.texture.noMipmap,", null, undefined, undefined, undefined, ").concat(this.texture._prefiltered,", ").concat(n?'"'+n+'"':"null",`);
|
||
`)}else e+="".concat(this._codeVariableName,'.texture = new BABYLON.Texture("').concat(this.texture.name,`", null);
|
||
`);return e+"".concat(this._codeVariableName,".texture.coordinatesMode = ").concat(this.texture.coordinatesMode,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.texture&&!this.texture.isRenderTarget&&(e.texture=this.texture.serialize()),e.generateOnlyFragmentCode=this.generateOnlyFragmentCode,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),e.texture&&!so.IgnoreTexturesAtLoadTime&&(i=e.texture.url.indexOf("data:")===0?"":i,e.texture.isCube?this.texture=mr.Parse(e.texture,n,i):this.texture=Ie.g.Parse(e.texture,n,i)),this.generateOnlyFragmentCode=e.generateOnlyFragmentCode,this._setTarget()},(0,A.Cg)([dt("Generate only fragment code",0,"ADVANCED",{notifiers:{rebuild:!0,update:!0,onValidation:t._OnGenerateOnlyFragmentCodeChanged}})],t.prototype,"generateOnlyFragmentCode",void 0),t}(ut);(0,j.Y5)("BABYLON.ReflectionTextureBaseBlock",xl);var oy=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("position",G.AutoDetect,!1,_e.Vertex),n.registerInput("worldPosition",G.Vector4,!1,_e.Vertex),n.registerInput("worldNormal",G.Vector4,!1,_e.Fragment),n.registerInput("world",G.Matrix,!1,_e.Vertex),n.registerInput("cameraPosition",G.Vector3,!1,_e.Fragment),n.registerInput("view",G.Matrix,!1,_e.Fragment),n.registerOutput("rgb",G.Color3,_e.Fragment),n.registerOutput("rgba",G.Color4,_e.Fragment),n.registerOutput("r",G.Float,_e.Fragment),n.registerOutput("g",G.Float,_e.Fragment),n.registerOutput("b",G.Float,_e.Fragment),n.registerOutput("a",G.Float,_e.Fragment),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype._onGenerateOnlyFragmentCodeChanged=function(){return this.position.isConnected?(this.generateOnlyFragmentCode=!this.generateOnlyFragmentCode,O.V.Error("The position input must not be connected to be able to switch!"),!1):this.worldPosition.isConnected?(this.generateOnlyFragmentCode=!this.generateOnlyFragmentCode,O.V.Error("The worldPosition input must not be connected to be able to switch!"),!1):(this._setTarget(),!0)},t.prototype._setTarget=function(){r.prototype._setTarget.call(this),this.getInputByName("position").target=this.generateOnlyFragmentCode?_e.Fragment:_e.Vertex,this.getInputByName("worldPosition").target=this.generateOnlyFragmentCode?_e.Fragment:_e.Vertex},t.prototype.getClassName=function(){return"ReflectionTextureBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),r.prototype.autoConfigure.call(this,e),!this.cameraPosition.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.systemValue===Nt.CameraPosition&&n(o)});i||(i=new Mt("cameraPosition")).setAsSystemValue(Nt.CameraPosition),i.output.connectTo(this.cameraPosition)}},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),!this.texture)return e.compilationString+=this.writeOutputs(e,"vec4".concat(e.fSuffix,"(0.)")),this;if(e.target!==_e.Fragment)return e.compilationString+=this.handleVertexSide(e),this;this.generateOnlyFragmentCode&&(e.compilationString+=this.handleVertexSide(e)),this.handleFragmentSideInits(e);var n=e._getFreeVariableName("normalWUnit");return e.compilationString+="".concat(e._declareLocalVar(n,G.Vector4)," = normalize(").concat(this.worldNormal.associatedVariableName,`);
|
||
`),e.compilationString+=this.handleFragmentSideCodeReflectionCoords(e,n),e.compilationString+=this.handleFragmentSideCodeReflectionColor(e,void 0,""),e.compilationString+=this.writeOutputs(e,this._reflectionColorName),this},t}(xl);(0,j.Y5)("BABYLON.ReflectionTextureBlock",oy);var ay=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment)||this;return n.useNonLinearDepth=!1,n.storeCameraSpaceZ=!1,n.force32itsFloat=!1,n._isUnique=!0,n.registerInput("uv",G.AutoDetect,!1,_e.VertexAndFragment),n.registerOutput("depth",G.Float,_e.Neutral),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Vector2|G.Vector3|G.Vector4),n._inputs[0]._prioritizeVertex=!1,n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SceneDepthBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depth",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("textureSampler")},Object.defineProperty(t.prototype,"target",{get:function(){return this.uv.isConnected?this.uv.sourceBlock.isInput?_e.VertexAndFragment:_e.Fragment:_e.VertexAndFragment},enumerable:!1,configurable:!0}),t.prototype._getTexture=function(e){return e.enableDepthRenderer(void 0,this.useNonLinearDepth,this.force32itsFloat,void 0,this.storeCameraSpaceZ).getDepthMap()},t.prototype.bind=function(e,n){var i=this._getTexture(n.getScene());e.setTexture(this._samplerName,i)},t.prototype._injectVertexCode=function(e){var n=this.uv;if(n.connectedPoint.ownerBlock.isInput&&(n.connectedPoint.ownerBlock.isAttribute||e._emitUniformFromString(n.associatedVariableName,n.type===G.Vector3?G.Vector3:n.type===G.Vector4?G.Vector4:G.Vector2)),this._mainUVName="vMain"+n.associatedVariableName,e._emitVaryingFromString(this._mainUVName,G.Vector2),e.compilationString+="".concat(this._mainUVName," = ").concat(n.associatedVariableName,`.xy;
|
||
`),this._outputs.some(function(s){return s.isConnectedInVertexShader})){this._writeTextureRead(e,!0);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&this._writeOutput(e,a,"r",!0)}}},t.prototype._writeTextureRead=function(e,n){n===void 0&&(n=!1);var i=this.uv;if(n){if(e.target===_e.Fragment)return;var o=e.shaderLanguage===0?"texture2D(".concat(this._samplerName,","):"textureSampleLevel(".concat(this._samplerName,", ").concat(this._samplerName+P.Y.AUTOSAMPLERSUFFIX,","),a=e.shaderLanguage===0?"":", 0";e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4),"= ").concat(o," ").concat(i.associatedVariableName,".xy").concat(a,`);
|
||
`)}else{var s=e.shaderLanguage===0?"texture2D(".concat(this._samplerName,","):"textureSample(".concat(this._samplerName,", ").concat(this._samplerName+P.Y.AUTOSAMPLERSUFFIX,",");this.uv.ownerBlock.target!==_e.Fragment?e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(s," ").concat(this._mainUVName,`);
|
||
`):e.compilationString+="".concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = ").concat(s," ").concat(i.associatedVariableName,`.xy);
|
||
`)}},t.prototype._writeOutput=function(e,n,i,o){if(o===void 0&&(o=!1),o){if(e.target===_e.Fragment)return;e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`)}else this.uv.ownerBlock.target,_e.Fragment,e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i,`;
|
||
`)},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this._samplerName=e._getFreeVariableName(this.name+"Sampler"),this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),e.sharedData.bindableBlocks.indexOf(this)<0&&e.sharedData.bindableBlocks.push(this),e.target!==_e.Fragment)return e._emit2DSampler(this._samplerName),void this._injectVertexCode(e);if(this._outputs.some(function(a){return a.isConnectedInFragmentShader})){e._emit2DSampler(this._samplerName),this._writeTextureRead(e);for(var n=0,i=this._outputs;n<i.length;n++){var o=i[n];o.hasEndpoints&&this._writeOutput(e,o,"r")}return this}},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.useNonLinearDepth=this.useNonLinearDepth,e.storeCameraSpaceZ=this.storeCameraSpaceZ,e.force32itsFloat=this.force32itsFloat,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.useNonLinearDepth=e.useNonLinearDepth,this.storeCameraSpaceZ=!!e.storeCameraSpaceZ,this.force32itsFloat=e.force32itsFloat},(0,A.Cg)([dt("Use non linear depth",0,"ADVANCED",{notifiers:{activatePreviewCommand:!0,callback:function(e,n){var i=n,o=!1;return i.useNonLinearDepth&&(i.storeCameraSpaceZ=!1,o=!0),e&&e.disableDepthRenderer(),o}}})],t.prototype,"useNonLinearDepth",void 0),(0,A.Cg)([dt("Store Camera space Z",0,"ADVANCED",{notifiers:{activatePreviewCommand:!0,callback:function(e,n){var i=n,o=!1;return i.storeCameraSpaceZ&&(i.useNonLinearDepth=!1,o=!0),e&&e.disableDepthRenderer(),o}}})],t.prototype,"storeCameraSpaceZ",void 0),(0,A.Cg)([dt("Force 32 bits float",0,"ADVANCED",{notifiers:{activatePreviewCommand:!0,callback:function(e){return e?.disableDepthRenderer()}}})],t.prototype,"force32itsFloat",void 0),t}(ut);(0,j.Y5)("BABYLON.SceneDepthBlock",ay);var sy=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment,!0)||this;return n.registerInput("worldPosition",G.Vector4,!1),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ClipPlanesBlock"},t.prototype.initialize=function(e){e._excludeVariableName("vClipPlane"),e._excludeVariableName("fClipDistance"),e._excludeVariableName("vClipPlane2"),e._excludeVariableName("fClipDistance2"),e._excludeVariableName("vClipPlane3"),e._excludeVariableName("fClipDistance3"),e._excludeVariableName("vClipPlane4"),e._excludeVariableName("fClipDistance4"),e._excludeVariableName("vClipPlane5"),e._excludeVariableName("fClipDistance5"),e._excludeVariableName("vClipPlane6"),e._excludeVariableName("fClipDistance6"),this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,30032)),Promise.resolve().then(L.bind(L,20502)),Promise.resolve().then(L.bind(L,63002)),Promise.resolve().then(L.bind(L,9436))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,39643)),Promise.resolve().then(L.bind(L,27003)),Promise.resolve().then(L.bind(L,83057)),Promise.resolve().then(L.bind(L,85637))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return _e.VertexAndFragment},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,n,i){var o,a,s,l,c,u,d=e.getScene(),h=!!((o=n.clipPlane)!==null&&o!==void 0?o:d.clipPlane),p=!!((a=n.clipPlane2)!==null&&a!==void 0?a:d.clipPlane2),m=!!((s=n.clipPlane3)!==null&&s!==void 0?s:d.clipPlane3),v=!!((l=n.clipPlane4)!==null&&l!==void 0?l:d.clipPlane4),b=!!((c=n.clipPlane5)!==null&&c!==void 0?c:d.clipPlane5),E=!!((u=n.clipPlane6)!==null&&u!==void 0?u:d.clipPlane6);i.setValue("CLIPPLANE",h,!0),i.setValue("CLIPPLANE2",p,!0),i.setValue("CLIPPLANE3",m,!0),i.setValue("CLIPPLANE4",v,!0),i.setValue("CLIPPLANE5",b,!0),i.setValue("CLIPPLANE6",E,!0)},t.prototype.bind=function(e,n,i){if(i){var o=i.getScene();(0,tn.gS)(e,n,o)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n="//".concat(this.name);if(e.target!==_e.Fragment){var i=this.worldPosition;return e._emitFunctionFromInclude("clipPlaneVertexDeclaration",n,{replaceStrings:[{search:/uniform vec4 vClipPlane\d*;/g,replace:""}]}),e.compilationString+=e._emitCodeFromInclude("clipPlaneVertex",n,{replaceStrings:[{search:/worldPos/g,replace:i.associatedVariableName}]}),e._emitUniformFromString("vClipPlane",G.Vector4),e._emitUniformFromString("vClipPlane2",G.Vector4),e._emitUniformFromString("vClipPlane3",G.Vector4),e._emitUniformFromString("vClipPlane4",G.Vector4),e._emitUniformFromString("vClipPlane5",G.Vector4),void e._emitUniformFromString("vClipPlane6",G.Vector4)}return e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this),e._emitFunctionFromInclude("clipPlaneFragmentDeclaration",n),e.compilationString+=e._emitCodeFromInclude("clipPlaneFragment",n),this},t}(ut);(0,j.Y5)("BABYLON.ClipPlanesBlock",sy);var IA=L(30032),MA=L(20502),OA=L(63002),DA=L(9436),NA=L(39643),LA=L(27003),FA=L(83057),wA=L(85637),BA=L(98318),VA=L(52767),UA=L(84192),GA=L(10896),kA=L(58902),zA=L(53378),WA=L(32532),HA=L(59115),YA=L(87283),XA=L(7363),jA=L(32823),qA=L(48961),KA=L(94785),ZA=L(54409),QA=L(46837),JA=L(62136),$A=L(61439),eC=L(40150),ly=function(r){function t(e,n){n===void 0&&(n=_e.VertexAndFragment);var i=r.call(this,e,n,!1)||this;return i.registerOutput("position",G.Object,_e.VertexAndFragment,new bn("position",i,1,sr,"ImageSourceBlock")),i.registerOutput("localPosition",G.Object,_e.VertexAndFragment,new bn("localPosition",i,1,sr,"ImageSourceBlock")),i.registerOutput("depth",G.Object,_e.VertexAndFragment,new bn("depth",i,1,sr,"ImageSourceBlock")),i.registerOutput("screenDepth",G.Object,_e.VertexAndFragment,new bn("screenDepth",i,1,sr,"ImageSourceBlock")),i.registerOutput("normal",G.Object,_e.VertexAndFragment,new bn("normal",i,1,sr,"ImageSourceBlock")),i.registerOutput("worldNormal",G.Object,_e.VertexAndFragment,new bn("worldNormal",i,1,sr,"ImageSourceBlock")),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"texture",{get:function(){return null},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.getSamplerName=function(e){return e===this._outputs[0]?this._positionSamplerName:e===this._outputs[1]?this._localPositionSamplerName:e===this._outputs[2]?this._depthSamplerName:e===this._outputs[3]?this._screenSpaceDepthSamplerName:e===this._outputs[4]?this._normalSamplerName:e===this._outputs[5]?this._worldNormalSamplerName:""},Object.defineProperty(t.prototype,"position",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localPosition",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depth",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screenDepth",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"positionSamplerName",{get:function(){return this._positionSamplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localPositionSamplerName",{get:function(){return this._localPositionSamplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalSamplerName",{get:function(){return this._normalSamplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormalSamplerName",{get:function(){return this._worldNormalSamplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthSamplerName",{get:function(){return this._depthSamplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linearDepthSamplerName",{get:function(){return this._screenSpaceDepthSamplerName},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PrePassTextureBlock"},t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),e.target!==_e.Vertex)return this._positionSamplerName="prepassPositionSampler",this._depthSamplerName="prepassDepthSampler",this._normalSamplerName="prepassNormalSampler",this._worldNormalSamplerName="prepassWorldNormalSampler",this._localPositionSamplerName="prepassLocalPositionSampler",this._screenSpaceDepthSamplerName="prepassScreenSpaceDepthSampler",e.sharedData.variableNames.prepassPositionSampler=0,e.sharedData.variableNames.prepassDepthSampler=0,e.sharedData.variableNames.prepassNormalSampler=0,e.sharedData.variableNames.prepassWorldNormalSampler=0,e.sharedData.variableNames.prepassLocalPositionSampler=0,e.sharedData.variableNames.prepassScreenSpaceDepthSampler=0,e.sharedData.textureBlocks.push(this),e.sharedData.bindableBlocks.push(this),this.position.isConnected&&e._emit2DSampler(this._positionSamplerName),this.depth.isConnected&&e._emit2DSampler(this._depthSamplerName),this.normal.isConnected&&e._emit2DSampler(this._normalSamplerName),this.worldNormal.isConnected&&e._emit2DSampler(this._worldNormalSamplerName),this.localPosition.isConnected&&e._emit2DSampler(this._localPositionSamplerName),this.screenDepth.isConnected&&e._emit2DSampler(this._screenSpaceDepthSamplerName),this},t.prototype.bind=function(e,n){var i=n.getScene().enablePrePassRenderer();if(i){var o=i.defaultRT;o.textures&&(this.position.isConnected&&e.setTexture(this._positionSamplerName,o.textures[i.getIndex(P.Y.PREPASS_POSITION_TEXTURE_TYPE)]),this.localPosition.isConnected&&e.setTexture(this._localPositionSamplerName,o.textures[i.getIndex(P.Y.PREPASS_LOCAL_POSITION_TEXTURE_TYPE)]),this.depth.isConnected&&e.setTexture(this._depthSamplerName,o.textures[i.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE)]),this.screenDepth.isConnected&&e.setTexture(this._screenSpaceDepthSamplerName,o.textures[i.getIndex(P.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE)]),this.normal.isConnected&&e.setTexture(this._normalSamplerName,o.textures[i.getIndex(P.Y.PREPASS_NORMAL_TEXTURE_TYPE)]),this.worldNormal.isConnected&&e.setTexture(this._worldNormalSamplerName,o.textures[i.getIndex(P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE)]))}},t}(ut);(0,j.Y5)("BABYLON.PrePassTextureBlock",ly);var cy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n._endpoints=[],n.registerInput("input",G.AutoDetect),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"endpoints",{get:function(){return this._endpoints},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e=this._inputs[0];if(e.isConnected){var n=e.connectedPoint.ownerBlock;if(n.target!==_e.VertexAndFragment)return n.target;if(e.connectedPoint.target!==_e.VertexAndFragment)return e.connectedPoint.target}return this._target},set:function(e){this._target&e||(this._target=e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"NodeMaterialTeleportInBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),t.prototype.isConnectedInFragmentShader=function(){return this.endpoints.some(function(e){return e.output.isConnectedInFragmentShader})},t.prototype._dumpCode=function(e,n){for(var i=r.prototype._dumpCode.call(this,e,n),o=0,a=this.endpoints;o<a.length;o++){var s=a[o];n.indexOf(s)===-1&&(i+=s._dumpCode(e,n))}return i},t.prototype.isAnAncestorOf=function(e){for(var n=0,i=this.endpoints;n<i.length;n++){var o=i[n];if(o===e||o.isAnAncestorOf(e))return!0}return!1},t.prototype.attachToEndpoint=function(e){e.detach(),this._endpoints.push(e),e._entryPoint=this,e._outputs[0]._typeConnectionSource=this._inputs[0],e._tempEntryPointUniqueId=null,e.name="> "+this.name,this._outputs=this._endpoints.map(function(n){return n.output})},t.prototype.detachFromEndpoint=function(e){var n=this._endpoints.indexOf(e);n!==-1&&(this._endpoints.splice(n,1),e._outputs[0]._typeConnectionSource=null,e._entryPoint=null,this._outputs=this._endpoints.map(function(i){return i.output}))},t.prototype.dispose=function(){r.prototype.dispose.call(this);for(var e=0,n=this._endpoints;e<n.length;e++){var i=n[e];this.detachFromEndpoint(i)}this._endpoints=[]},t}(ut);(0,j.Y5)("BABYLON.NodeMaterialTeleportInBlock",cy);var uy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n._entryPoint=null,n._tempEntryPointUniqueId=null,n.registerOutput("output",G.BasedOnInput),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"entryPoint",{get:function(){return this._entryPoint},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"NodeMaterialTeleportOutBlock"},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return this._entryPoint?this._entryPoint.target:this._target},set:function(e){this._target&e||(this._target=e)},enumerable:!1,configurable:!0}),t.prototype.detach=function(){this._entryPoint&&this._entryPoint.detachFromEndpoint(this)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),this.entryPoint&&(e.compilationString+=e._declareOutput(this.output)+" = ".concat(this.entryPoint.input.associatedVariableName,`;
|
||
`))},t.prototype.clone=function(e,n){n===void 0&&(n="");var i=r.prototype.clone.call(this,e,n);return this.entryPoint&&this.entryPoint.attachToEndpoint(i),i},t.prototype._customBuildStep=function(e,n){this.entryPoint&&this.entryPoint.build(e,n)},t.prototype._dumpCode=function(e,n){var i="";return this.entryPoint&&n.indexOf(this.entryPoint)===-1&&(i+=this.entryPoint._dumpCode(e,n)),i+r.prototype._dumpCode.call(this,e,n)},t.prototype._dumpCodeForOutputConnections=function(e){var n=r.prototype._dumpCodeForOutputConnections.call(this,e);return this.entryPoint&&(n+=this.entryPoint._dumpCodeForOutputConnections(e)),n},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return this.entryPoint&&(e+="".concat(this.entryPoint._codeVariableName,".attachToEndpoint(").concat(this._codeVariableName,`);
|
||
`)),e},t.prototype.serialize=function(){var e,n,i=r.prototype.serialize.call(this);return i.entryPoint=(n=(e=this.entryPoint)===null||e===void 0?void 0:e.uniqueId)!==null&&n!==void 0?n:"",i},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this._tempEntryPointUniqueId=e.entryPoint},t}(ut);(0,j.Y5)("BABYLON.NodeMaterialTeleportOutBlock",uy);var dy=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"AddBlock"},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = ".concat(this.left.associatedVariableName," + ").concat(this.right.associatedVariableName,`;
|
||
`),this},t}(ih);(0,j.Y5)("BABYLON.AddBlock",dy);var hy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.AutoDetect),n.registerInput("factor",G.Float),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ScaleBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"factor",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = ".concat(this.input.associatedVariableName," * ").concat(this.factor.associatedVariableName,`;
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ScaleBlock",hy);var fy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.minimum=0,n.maximum=1,n.registerInput("value",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ClampBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=e.shaderLanguage===1?e._getShaderType(this.value.type):"";return e.compilationString+=e._declareOutput(n)+" = clamp(".concat(this.value.associatedVariableName,", ").concat(i,"(").concat(this._writeFloat(this.minimum),"), ").concat(i,"(").concat(this._writeFloat(this.maximum),`));
|
||
`),this},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".minimum = ").concat(this.minimum,`;
|
||
`)+"".concat(this._codeVariableName,".maximum = ").concat(this.maximum,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.minimum=this.minimum,e.maximum=this.maximum,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.minimum=e.minimum,this.maximum=e.maximum},(0,A.Cg)([dt("Minimum",1)],t.prototype,"minimum",void 0),(0,A.Cg)([dt("Maximum",1)],t.prototype,"maximum",void 0),t}(ut);(0,j.Y5)("BABYLON.ClampBlock",fy);var py=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerOutput("output",G.Vector3),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(G.Float),n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n._inputs[0].excludedConnectionPointTypes.push(G.Vector2),n._inputs[1].excludedConnectionPointTypes.push(G.Float),n._inputs[1].excludedConnectionPointTypes.push(G.Matrix),n._inputs[1].excludedConnectionPointTypes.push(G.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"CrossBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = cross(".concat(this.left.associatedVariableName,".xyz, ").concat(this.right.associatedVariableName,`.xyz);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.CrossBlock",py);var _y=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},set:function(e){this._deserializeOptions(e)},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"CustomBlock"},t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e);var i=this._code,o=this._options.functionName;this._inputs.forEach(function(s){var l=new RegExp("\\{TYPE_"+s.name+"\\}","gm"),c=e._getGLType(s.type);i=i.replace(l,c),o=o.replace(l,c)}),this._outputs.forEach(function(s){var l=new RegExp("\\{TYPE_"+s.name+"\\}","gm"),c=e._getGLType(s.type);i=i.replace(l,c),o=o.replace(l,c)}),e._emitFunction(o,i,""),this._outputs.forEach(function(s){e.compilationString+=e._declareOutput(s)+`;
|
||
`}),e.compilationString+=o+"(";var a=!1;return this._inputs.forEach(function(s,l){var c,u,d;l>0&&(e.compilationString+=", "),n._inputSamplers&&n._inputSamplers.indexOf(s.name)!==-1?e.compilationString+=(d=(u=(c=s.connectedPoint)===null||c===void 0?void 0:c.ownerBlock)===null||u===void 0?void 0:u.samplerName)!==null&&d!==void 0?d:s.associatedVariableName:e.compilationString+=s.associatedVariableName,a=!0}),this._outputs.forEach(function(s,l){(l>0||a)&&(e.compilationString+=", "),e.compilationString+=s.associatedVariableName}),e.compilationString+=`);
|
||
`,this},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".options = ").concat(JSON.stringify(this._options),`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.options=this._options,e},t.prototype._deserialize=function(e,n,i){this._deserializeOptions(e.options),r.prototype._deserialize.call(this,e,n,i)},t.prototype._deserializeOptions=function(e){var n,i,o,a=this;this._options=e,this._code=e.code.join(`
|
||
`)+`
|
||
`,this.name=this.name||e.name,this.target=_e[e.target],(n=e.inParameters)===null||n===void 0||n.forEach(function(s,l){var c=G[s.type];s.type==="sampler2D"||s.type==="samplerCube"?(a._inputSamplers=a._inputSamplers||[],a._inputSamplers.push(s.name),a.registerInput(s.name,G.Object,!0,_e.VertexAndFragment,new bn(s.name,a,0,sr,"ImageSourceBlock"))):a.registerInput(s.name,c),Object.defineProperty(a,s.name,{get:function(){return this._inputs[l]},enumerable:!0,configurable:!0})}),(i=e.outParameters)===null||i===void 0||i.forEach(function(s,l){a.registerOutput(s.name,G[s.type]),Object.defineProperty(a,s.name,{get:function(){return this._outputs[l]},enumerable:!0,configurable:!0}),s.type==="BasedOnInput"&&(a._outputs[l]._typeConnectionSource=a._findInputByName(s.typeFromInput)[0])}),(o=e.inLinkedConnectionTypes)===null||o===void 0||o.forEach(function(s){a._linkConnectionTypes(a._findInputByName(s.input1)[1],a._findInputByName(s.input2)[1])})},t.prototype._findInputByName=function(e){if(!e)return null;for(var n=0;n<this._inputs.length;n++)if(this._inputs[n].name===e)return[this._inputs[n],n];return null},t}(ut);(0,j.Y5)("BABYLON.CustomBlock",_y);var my=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerOutput("output",G.Float),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(G.Float),n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n._inputs[1].excludedConnectionPointTypes.push(G.Float),n._inputs[1].excludedConnectionPointTypes.push(G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DotBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = dot(".concat(this.left.associatedVariableName,", ").concat(this.right.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.DotBlock",my);var gy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(G.Float),n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"NormalizeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this._inputs[0];return e.compilationString+=e._declareOutput(n)+" = normalize(".concat(i.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.NormalizeBlock",gy);var vy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.rSwizzle="r",n.gSwizzle="g",n.bSwizzle="b",n.aSwizzle="a",n.registerInput("rgb ",G.Color3,!0),n.registerInput("r",G.Float,!0),n.registerInput("g",G.Float,!0),n.registerInput("b",G.Float,!0),n.registerInput("a",G.Float,!0),n.registerOutput("rgba",G.Color4),n.registerOutput("rgb",G.Color3),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ColorMergerBlock"},Object.defineProperty(t.prototype,"rgbIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this.rgbOut},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return e==="rgb "?"rgbIn":e},t.prototype._buildSwizzle=function(e){return"."+(this.rSwizzle+this.gSwizzle+this.bSwizzle+this.aSwizzle).substring(0,e)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.r,i=this.g,o=this.b,a=this.a,s=this.rgbIn,l=this._outputs[0],c=this._outputs[1],u=e._getShaderType(G.Vector4),d=e._getShaderType(G.Vector3);return s.isConnected?(l.hasEndpoints&&(e.compilationString+=e._declareOutput(l)+" = ".concat(u,"(").concat(s.associatedVariableName,", ").concat(a.isConnected?this._writeVariable(a):"0.0",")").concat(this._buildSwizzle(4),`;
|
||
`)),c.hasEndpoints&&(e.compilationString+=e._declareOutput(c)+" = ".concat(s.associatedVariableName).concat(this._buildSwizzle(3),`;
|
||
`))):(l.hasEndpoints&&(e.compilationString+=e._declareOutput(l)+" = ".concat(u,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",", ").concat(a.isConnected?this._writeVariable(a):"0.0",")").concat(this._buildSwizzle(4),`;
|
||
`)),c.hasEndpoints&&(e.compilationString+=e._declareOutput(c)+" = ".concat(d,"(").concat(n.isConnected?this._writeVariable(n):"0.0",", ").concat(i.isConnected?this._writeVariable(i):"0.0",", ").concat(o.isConnected?this._writeVariable(o):"0.0",")").concat(this._buildSwizzle(3),`;
|
||
`))),this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.rSwizzle=this.rSwizzle,e.gSwizzle=this.gSwizzle,e.bSwizzle=this.bSwizzle,e.aSwizzle=this.aSwizzle,e},t.prototype._deserialize=function(e,n,i){var o,a,s,l;r.prototype._deserialize.call(this,e,n,i),this.rSwizzle=(o=e.rSwizzle)!==null&&o!==void 0?o:"r",this.gSwizzle=(a=e.gSwizzle)!==null&&a!==void 0?a:"g",this.bSwizzle=(s=e.bSwizzle)!==null&&s!==void 0?s:"b",this.aSwizzle=(l=e.aSwizzle)!==null&&l!==void 0?l:"a"},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+="".concat(this._codeVariableName,'.rSwizzle = "').concat(this.rSwizzle,`";
|
||
`),e+="".concat(this._codeVariableName,'.gSwizzle = "').concat(this.gSwizzle,`";
|
||
`),(e+="".concat(this._codeVariableName,'.bSwizzle = "').concat(this.bSwizzle,`";
|
||
`))+"".concat(this._codeVariableName,'.aSwizzle = "').concat(this.aSwizzle,`";
|
||
`)},t}(ut);(0,j.Y5)("BABYLON.ColorMergerBlock",vy);var yy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("xyzw",G.Vector4,!0),n.registerInput("xyz ",G.Vector3,!0),n.registerInput("xy ",G.Vector2,!0),n.registerOutput("xyz",G.Vector3),n.registerOutput("xy",G.Vector2),n.registerOutput("zw",G.Vector2),n.registerOutput("x",G.Float),n.registerOutput("y",G.Float),n.registerOutput("z",G.Float),n.registerOutput("w",G.Float),n.inputsAreExclusive=!0,n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VectorSplitterBlock"},Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zw",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"w",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){switch(e){case"xy ":return"xyIn";case"xyz ":return"xyzIn";default:return e}},t.prototype._outputRename=function(e){switch(e){case"xy":return"xyOut";case"xyz":return"xyzOut";default:return e}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.xyzw.isConnected?this.xyzw:this.xyzIn.isConnected?this.xyzIn:this.xyIn,i=this._outputs[0],o=this._outputs[1],a=this._outputs[2],s=this._outputs[3],l=this._outputs[4],c=this._outputs[5],u=this._outputs[6],d=e._getShaderType(G.Vector3);return i.hasEndpoints&&(n===this.xyIn?e.compilationString+=e._declareOutput(i)+" = ".concat(d,"(").concat(n.associatedVariableName,`, 0.0);
|
||
`):e.compilationString+=e._declareOutput(i)+" = ".concat(n.associatedVariableName,`.xyz;
|
||
`)),a.hasEndpoints&&this.xyzw.isConnected&&(e.compilationString+=e._declareOutput(a)+" = ".concat(this.xyzw.associatedVariableName,`.zw;
|
||
`)),o.hasEndpoints&&(e.compilationString+=e._declareOutput(o)+" = ".concat(n.associatedVariableName,`.xy;
|
||
`)),s.hasEndpoints&&(e.compilationString+=e._declareOutput(s)+" = ".concat(n.associatedVariableName,`.x;
|
||
`)),l.hasEndpoints&&(e.compilationString+=e._declareOutput(l)+" = ".concat(n.associatedVariableName,`.y;
|
||
`)),c.hasEndpoints&&(e.compilationString+=e._declareOutput(c)+" = ".concat(n.associatedVariableName,`.z;
|
||
`)),u.hasEndpoints&&(e.compilationString+=e._declareOutput(u)+" = ".concat(n.associatedVariableName,`.w;
|
||
`)),this},t}(ut);(0,j.Y5)("BABYLON.VectorSplitterBlock",yy);var by=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerInput("gradient",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._linkConnectionTypes(1,2,!0),n._inputs[2].acceptedConnectionPointTypes.push(G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"LerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = mix(".concat(this.left.associatedVariableName," , ").concat(this.right.associatedVariableName,", ").concat(this.gradient.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.LerpBlock",by);var Ty=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DivideBlock"},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = ".concat(this.left.associatedVariableName," / ").concat(this.right.associatedVariableName,`;
|
||
`),this},t}(ih);(0,j.Y5)("BABYLON.DivideBlock",Ty);var Sy=function(r){function t(e){return r.call(this,e)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SubtractBlock"},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = ".concat(this.left.associatedVariableName," - ").concat(this.right.associatedVariableName,`;
|
||
`),this},t}(ih);(0,j.Y5)("BABYLON.SubtractBlock",Sy);var Ey=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("value",G.Float),n.registerInput("edge",G.Float),n.registerOutput("output",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"StepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = step(".concat(this.edge.associatedVariableName,", ").concat(this.value.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.StepBlock",Ey);var Ih=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._outputs[0].excludedConnectionPointTypes.push(G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"OneMinusBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = 1. - ".concat(this.input.associatedVariableName,`;
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.OneMinusBlock",Ih),(0,j.Y5)("BABYLON.OppositeBlock",Ih);var Mh=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("worldPosition",G.Vector4),n.registerInput("cameraPosition",G.Vector3),n.registerOutput("output",G.Vector3),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ViewDirectionBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.cameraPosition.isConnected){var i=e.getInputBlockByPredicate(function(o){return o.systemValue===Nt.CameraPosition&&n(o)});i||(i=new Mt("cameraPosition")).setAsSystemValue(Nt.CameraPosition),i.output.connectTo(this.cameraPosition)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = normalize(".concat(this.cameraPosition.associatedVariableName," - ").concat(this.worldPosition.associatedVariableName,`.xyz);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ViewDirectionBlock",Mh),L(18644);var xy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("worldNormal",G.Vector4),n.registerInput("viewDirection",G.Vector3),n.registerInput("bias",G.Float),n.registerInput("power",G.Float),n.registerOutput("fresnel",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FresnelBlock"},Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewDirection",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"power",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fresnel",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.viewDirection.isConnected){var n=new Mh("View direction");n.output.connectTo(this.viewDirection),n.autoConfigure(e)}if(!this.bias.isConnected){var i=new Mt("bias");i.value=0,i.output.connectTo(this.bias)}if(!this.power.isConnected){var o=new Mt("power");o.value=1,o.output.connectTo(this.power)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n="//".concat(this.name);return e._emitFunctionFromInclude("fresnelFunction",n,{removeIfDef:!0}),e.compilationString+=e._declareOutput(this.fresnel)+" = computeFresnelTerm(".concat(this.viewDirection.associatedVariableName,".xyz, ").concat(this.worldNormal.associatedVariableName,".xyz, ").concat(this.bias.associatedVariableName,", ").concat(this.power.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.FresnelBlock",xy);var Py=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MaxBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = max(".concat(this.left.associatedVariableName,", ").concat(this.right.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.MaxBlock",Py);var Ay=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MinBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = min(".concat(this.left.associatedVariableName,", ").concat(this.right.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.MinBlock",Ay);var Cy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerOutput("output",G.Float),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(G.Float),n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n._inputs[1].excludedConnectionPointTypes.push(G.Float),n._inputs[1].excludedConnectionPointTypes.push(G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DistanceBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = length(".concat(this.left.associatedVariableName," - ").concat(this.right.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.DistanceBlock",Cy);var Ry=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("value",G.AutoDetect),n.registerOutput("output",G.Float),n._inputs[0].excludedConnectionPointTypes.push(G.Float),n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"LengthBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = length(".concat(this.value.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.LengthBlock",Ry);var Iy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("value",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"NegateBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = -1.0 * ".concat(this.value.associatedVariableName,`;
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.NegateBlock",Iy);var My=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("value",G.AutoDetect),n.registerInput("power",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"PowBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"power",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = pow(max(".concat(this.value.associatedVariableName,", 0.), ").concat(this.power.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.PowBlock",My);var Oy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("seed",G.AutoDetect),n.registerOutput("output",G.Float),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Vector2|G.Vector3|G.Vector4|G.Color3|G.Color4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"RandomNumberBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i="//".concat(this.name);return e._emitFunctionFromInclude("helperFunctions",i),e.compilationString+=e._declareOutput(n)+" = getRand(".concat(this.seed.associatedVariableName,`.xy);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.RandomNumberBlock",Oy);var Dy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("x",G.Float),n.registerInput("y",G.Float),n.registerOutput("output",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ArcTan2Block"},Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=e.shaderLanguage===1?"atan2":"atan";return e.compilationString+=e._declareOutput(n)+" = ".concat(i,"(").concat(this.x.associatedVariableName,", ").concat(this.y.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ArcTan2Block",Dy);var Ny=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("value",G.AutoDetect),n.registerInput("edge0",G.Float),n.registerInput("edge1",G.Float),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SmoothStepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge0",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge1",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=e._getShaderType(this.value.type);return e.compilationString+=e._declareOutput(n)+" = smoothstep(".concat(i,"(").concat(this.edge0.associatedVariableName,"), ").concat(i,"(").concat(this.edge1.associatedVariableName,"), ").concat(this.value.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.SmoothStepBlock",Ny);var Ly=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ReciprocalBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return this.input.type===G.Matrix?e.compilationString+=e._declareOutput(n)+" = inverse(".concat(this.input.associatedVariableName,`);
|
||
`):e.compilationString+=e._declareOutput(n)+" = 1. / ".concat(this.input.associatedVariableName,`;
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ReciprocalBlock",Ly);var Fy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("value",G.AutoDetect),n.registerInput("reference",G.AutoDetect),n.registerInput("distance",G.Float),n.registerInput("replacement",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._linkConnectionTypes(0,3),n._inputs[0].excludedConnectionPointTypes.push(G.Float),n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n._inputs[1].excludedConnectionPointTypes.push(G.Float),n._inputs[1].excludedConnectionPointTypes.push(G.Matrix),n._inputs[3].excludedConnectionPointTypes.push(G.Float),n._inputs[3].excludedConnectionPointTypes.push(G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ReplaceColorBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reference",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"distance",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"replacement",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+`;
|
||
`,e.compilationString+="if (length(".concat(this.value.associatedVariableName," - ").concat(this.reference.associatedVariableName,") < ").concat(this.distance.associatedVariableName,`) {
|
||
`),e.compilationString+="".concat(n.associatedVariableName," = ").concat(this.replacement.associatedVariableName,`;
|
||
`),e.compilationString+=`} else {
|
||
`,e.compilationString+="".concat(n.associatedVariableName," = ").concat(this.value.associatedVariableName,`;
|
||
`),e.compilationString+=`}
|
||
`,this},t}(ut);(0,j.Y5)("BABYLON.ReplaceColorBlock",Fy);var Oh,wy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("value",G.AutoDetect),n.registerInput("steps",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n._inputs[1].excludedConnectionPointTypes.push(G.Matrix),n._inputs[1].acceptedConnectionPointTypes.push(G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"PosterizeBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"steps",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = floor(".concat(this.value.associatedVariableName," / (1.0 / ").concat(this.steps.associatedVariableName,")) * (1.0 / ").concat(this.steps.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.PosterizeBlock",wy),function(r){r[r.SawTooth=0]="SawTooth",r[r.Square=1]="Square",r[r.Triangle=2]="Triangle"}(Oh||(Oh={}));var By=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.kind=0,n.registerInput("input",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"WaveBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];switch(this.kind){case 0:e.compilationString+=e._declareOutput(n)+" = ".concat(this.input.associatedVariableName," - floor(0.5 + ").concat(this.input.associatedVariableName,`);
|
||
`);break;case 1:e.compilationString+=e._declareOutput(n)+" = 1.0 - 2.0 * round(fract(".concat(this.input.associatedVariableName,`));
|
||
`);break;case 2:e.compilationString+=e._declareOutput(n)+" = 2.0 * abs(2.0 * (".concat(this.input.associatedVariableName," - floor(0.5 + ").concat(this.input.associatedVariableName,`))) - 1.0;
|
||
`)}return this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.kind=this.kind,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.kind=e.kind},t}(ut);(0,j.Y5)("BABYLON.WaveBlock",By);var Pl=function(){function r(t,e){this.step=t,this.color=e}return Object.defineProperty(r.prototype,"step",{get:function(){return this._step},set:function(t){this._step=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"color",{get:function(){return this._color},set:function(t){this._color=t},enumerable:!1,configurable:!0}),r}(),Vy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.colorSteps=[new Pl(0,z.v9.Black()),new Pl(1,z.v9.White())],n.onValueChangedObservable=new K.cP,n.registerInput("gradient",G.AutoDetect),n.registerOutput("output",G.Color3),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Float|G.Vector2|G.Vector3|G.Vector4|G.Color3|G.Color4),n}return(0,A.C6)(t,r),t.prototype.colorStepsUpdated=function(){this.onValueChangedObservable.notifyObservers(this)},t.prototype.getClassName=function(){return"GradientBlock"},Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._writeColorConstant=function(e,n){var i=this.colorSteps[e];return"".concat(n,"(").concat(i.color.r,", ").concat(i.color.g,", ").concat(i.color.b,")")},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=e._getShaderType(G.Vector3);if(this.colorSteps.length&&this.gradient.connectedPoint){var o=e._getFreeVariableName("gradientTempColor"),a=e._getFreeVariableName("gradientTempPosition");e.compilationString+="".concat(e._declareLocalVar(o,G.Vector3)," = ").concat(this._writeColorConstant(0,i),`;
|
||
`),e.compilationString+="".concat(e._declareLocalVar(a,G.Float),`;
|
||
`);var s=this.gradient.associatedVariableName;this.gradient.connectedPoint.type!==G.Float&&(s+=".x");for(var l=1;l<this.colorSteps.length;l++){var c=this.colorSteps[l],u=this.colorSteps[l-1];e.compilationString+="".concat(a," = clamp((").concat(s," - ").concat(e._emitFloat(u.step),") / (").concat(e._emitFloat(c.step)," - ").concat(e._emitFloat(u.step),"), 0.0, 1.0) * step(").concat(e._emitFloat(l),", ").concat(e._emitFloat(this.colorSteps.length-1),`);
|
||
`),e.compilationString+="".concat(o," = mix(").concat(o,", ").concat(this._writeColorConstant(l,i),", ").concat(a,`);
|
||
`)}return e.compilationString+=e._declareOutput(n)+" = ".concat(o,`;
|
||
`),this}e.compilationString+=e._declareOutput(n)+" = ".concat(i,`(0., 0., 0.);
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);e.colorSteps=[];for(var n=0,i=this.colorSteps;n<i.length;n++){var o=i[n];e.colorSteps.push({step:o.step,color:{r:o.color.r,g:o.color.g,b:o.color.b}})}return e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.colorSteps.length=0;for(var o=0,a=e.colorSteps;o<a.length;o++){var s=a[o];this.colorSteps.push(new Pl(s.step,new z.v9(s.color.r,s.color.g,s.color.b)))}},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);e+="".concat(this._codeVariableName,`.colorSteps = [];
|
||
`);for(var n=0,i=this.colorSteps;n<i.length;n++){var o=i[n];e+="".concat(this._codeVariableName,".colorSteps.push(new BABYLON.GradientBlockColorStep(").concat(o.step,", new BABYLON.Color3(").concat(o.color.r,", ").concat(o.color.g,", ").concat(o.color.b,`)));
|
||
`)}return e},t}(ut);(0,j.Y5)("BABYLON.GradientBlock",Vy);var Uy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerInput("gradient",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._linkConnectionTypes(1,2,!0),n._inputs[2].acceptedConnectionPointTypes.push(G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"NLerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = normalize(mix(".concat(this.left.associatedVariableName," , ").concat(this.right.associatedVariableName,", ").concat(this.gradient.associatedVariableName,`));
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.NLerpBlock",Uy);var Gy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.manhattanDistance=!1,n.registerInput("seed",G.Vector3),n.registerInput("jitter",G.Float),n.registerOutput("output",G.Vector2),n.registerOutput("x",G.Float),n.registerOutput("y",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"WorleyNoise3DBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this.seed.isConnected&&(this.output.hasEndpoints||this.x.hasEndpoints||this.y.hasEndpoints)){var n=`vec3 permute(vec3 x){
|
||
`;n+=` return mod((34.0 * x + 1.0) * x, 289.0);
|
||
`,n+=`}
|
||
|
||
`,n+=`vec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){
|
||
`,n+=` return [manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z)];
|
||
`,n+=`}
|
||
|
||
`,n+=`vec2 worley(vec3 P, float jitter, bool manhattanDistance){
|
||
`,n+=` float K = 0.142857142857; // 1/7
|
||
`,n+=` float Ko = 0.428571428571; // 1/2-K/2
|
||
`,n+=` float K2 = 0.020408163265306; // 1/(7*7)
|
||
`,n+=` float Kz = 0.166666666667; // 1/6
|
||
`,n+=` float Kzo = 0.416666666667; // 1/2-1/6*2
|
||
`,n+=`
|
||
`,n+=` vec3 Pi = mod(floor(P), 289.0);
|
||
`,n+=` vec3 Pf = fract(P) - 0.5;
|
||
`,n+=`
|
||
`,n+=` vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);
|
||
`,n+=` vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);
|
||
`,n+=` vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);
|
||
`,n+=`
|
||
`,n+=` vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));
|
||
`,n+=` vec3 p1 = permute(p + Pi.y - 1.0);
|
||
`,n+=` vec3 p2 = permute(p + Pi.y);
|
||
`,n+=` vec3 p3 = permute(p + Pi.y + 1.0);
|
||
`,n+=`
|
||
`,n+=` vec3 p11 = permute(p1 + Pi.z - 1.0);
|
||
`,n+=` vec3 p12 = permute(p1 + Pi.z);
|
||
`,n+=` vec3 p13 = permute(p1 + Pi.z + 1.0);
|
||
`,n+=`
|
||
`,n+=` vec3 p21 = permute(p2 + Pi.z - 1.0);
|
||
`,n+=` vec3 p22 = permute(p2 + Pi.z);
|
||
`,n+=` vec3 p23 = permute(p2 + Pi.z + 1.0);
|
||
`,n+=`
|
||
`,n+=` vec3 p31 = permute(p3 + Pi.z - 1.0);
|
||
`,n+=` vec3 p32 = permute(p3 + Pi.z);
|
||
`,n+=` vec3 p33 = permute(p3 + Pi.z + 1.0);
|
||
`,n+=`
|
||
`,n+=` vec3 ox11 = fract(p11*K) - Ko;
|
||
`,n+=` vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed
|
||
`,n+=`
|
||
`,n+=` vec3 ox12 = fract(p12*K) - Ko;
|
||
`,n+=` vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz12 = floor(p12*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 ox13 = fract(p13*K) - Ko;
|
||
`,n+=` vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz13 = floor(p13*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 ox21 = fract(p21*K) - Ko;
|
||
`,n+=` vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz21 = floor(p21*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 ox22 = fract(p22*K) - Ko;
|
||
`,n+=` vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz22 = floor(p22*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 ox23 = fract(p23*K) - Ko;
|
||
`,n+=` vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz23 = floor(p23*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 ox31 = fract(p31*K) - Ko;
|
||
`,n+=` vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz31 = floor(p31*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 ox32 = fract(p32*K) - Ko;
|
||
`,n+=` vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz32 = floor(p32*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 ox33 = fract(p33*K) - Ko;
|
||
`,n+=` vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;
|
||
`,n+=` vec3 oz33 = floor(p33*K2)*Kz - Kzo;
|
||
`,n+=`
|
||
`,n+=` vec3 dx11 = Pfx + jitter*ox11;
|
||
`,n+=` vec3 dy11 = Pfy.x + jitter*oy11;
|
||
`,n+=` vec3 dz11 = Pfz.x + jitter*oz11;
|
||
`,n+=`
|
||
`,n+=` vec3 dx12 = Pfx + jitter*ox12;
|
||
`,n+=` vec3 dy12 = Pfy.x + jitter*oy12;
|
||
`,n+=` vec3 dz12 = Pfz.y + jitter*oz12;
|
||
`,n+=`
|
||
`,n+=` vec3 dx13 = Pfx + jitter*ox13;
|
||
`,n+=` vec3 dy13 = Pfy.x + jitter*oy13;
|
||
`,n+=` vec3 dz13 = Pfz.z + jitter*oz13;
|
||
`,n+=`
|
||
`,n+=` vec3 dx21 = Pfx + jitter*ox21;
|
||
`,n+=` vec3 dy21 = Pfy.y + jitter*oy21;
|
||
`,n+=` vec3 dz21 = Pfz.x + jitter*oz21;
|
||
`,n+=`
|
||
`,n+=` vec3 dx22 = Pfx + jitter*ox22;
|
||
`,n+=` vec3 dy22 = Pfy.y + jitter*oy22;
|
||
`,n+=` vec3 dz22 = Pfz.y + jitter*oz22;
|
||
`,n+=`
|
||
`,n+=` vec3 dx23 = Pfx + jitter*ox23;
|
||
`,n+=` vec3 dy23 = Pfy.y + jitter*oy23;
|
||
`,n+=` vec3 dz23 = Pfz.z + jitter*oz23;
|
||
`,n+=`
|
||
`,n+=` vec3 dx31 = Pfx + jitter*ox31;
|
||
`,n+=` vec3 dy31 = Pfy.z + jitter*oy31;
|
||
`,n+=` vec3 dz31 = Pfz.x + jitter*oz31;
|
||
`,n+=`
|
||
`,n+=` vec3 dx32 = Pfx + jitter*ox32;
|
||
`,n+=` vec3 dy32 = Pfy.z + jitter*oy32;
|
||
`,n+=` vec3 dz32 = Pfz.y + jitter*oz32;
|
||
`,n+=`
|
||
`,n+=` vec3 dx33 = Pfx + jitter*ox33;
|
||
`,n+=` vec3 dy33 = Pfy.z + jitter*oy33;
|
||
`,n+=` vec3 dz33 = Pfz.z + jitter*oz33;
|
||
`,n+=`
|
||
`,n+=` vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);
|
||
`,n+=` vec3 d12 = dist(dx12, dy12, dz12, manhattanDistance);
|
||
`,n+=` vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);
|
||
`,n+=` vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);
|
||
`,n+=` vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);
|
||
`,n+=` vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);
|
||
`,n+=` vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);
|
||
`,n+=` vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);
|
||
`,n+=` vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);
|
||
`,n+=`
|
||
`,n+=` vec3 d1a = min(d11, d12);
|
||
`,n+=` d12 = max(d11, d12);
|
||
`,n+=` d11 = min(d1a, d13); // Smallest now not in d12 or d13
|
||
`,n+=` d13 = max(d1a, d13);
|
||
`,n+=` d12 = min(d12, d13); // 2nd smallest now not in d13
|
||
`,n+=` vec3 d2a = min(d21, d22);
|
||
`,n+=` d22 = max(d21, d22);
|
||
`,n+=` d21 = min(d2a, d23); // Smallest now not in d22 or d23
|
||
`,n+=` d23 = max(d2a, d23);
|
||
`,n+=` d22 = min(d22, d23); // 2nd smallest now not in d23
|
||
`,n+=` vec3 d3a = min(d31, d32);
|
||
`,n+=` d32 = max(d31, d32);
|
||
`,n+=` d31 = min(d3a, d33); // Smallest now not in d32 or d33
|
||
`,n+=` d33 = max(d3a, d33);
|
||
`,n+=` d32 = min(d32, d33); // 2nd smallest now not in d33
|
||
`,n+=` vec3 da = min(d11, d21);
|
||
`,n+=` d21 = max(d11, d21);
|
||
`,n+=` d11 = min(da, d31); // Smallest now in d11
|
||
`,n+=` d31 = max(da, d31); // 2nd smallest now not in d31
|
||
`,n+=` if (d11.x >= d11.y) { vec2 temp = d11.yx; d11.x = temp.x; d11.y = temp.y; }
|
||
`,n+=` if (d11.x >= d11.z) { vec2 temp = d11.zx; d11.x = temp.x; d11.z = temp.y; }
|
||
`,n+=` d12 = min(d12, d21); // 2nd smallest now not in d21
|
||
`,n+=` d12 = min(d12, d22); // nor in d22
|
||
`,n+=` d12 = min(d12, d31); // nor in d31
|
||
`,n+=` d12 = min(d12, d32); // nor in d32
|
||
`,n+=` vec2 temp2 = min(d11.yz, d12.xy); // nor in d12.yz
|
||
`,n+=` d11.y = temp2.x;
|
||
`,n+=` d11.z = temp2.y;
|
||
`,n+=` d11.y = min(d11.y, d12.z); // Only two more to go
|
||
`,n+=` d11.y = min(d11.y, d11.z); // Done! (Phew!)
|
||
`,n+=` return sqrt(d11.xy); // F1, F2
|
||
`,n+=`}
|
||
|
||
`,n=e.shaderLanguage===1?e._babylonSLtoWGSL(n):e._babylonSLtoGLSL(n),e._emitFunction("worley3D",n,"// Worley3D");var i=e._getFreeVariableName("worleyTemp");return e.compilationString+="".concat(e._declareLocalVar(i,G.Vector2)," = worley(").concat(this.seed.associatedVariableName,", ").concat(this.jitter.associatedVariableName,", ").concat(this.manhattanDistance,`);
|
||
`),this.output.hasEndpoints&&(e.compilationString+=e._declareOutput(this.output)+" = ".concat(i,`;
|
||
`)),this.x.hasEndpoints&&(e.compilationString+=e._declareOutput(this.x)+" = ".concat(i,`.x;
|
||
`)),this.y.hasEndpoints&&(e.compilationString+=e._declareOutput(this.y)+" = ".concat(i,`.y;
|
||
`)),this}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".manhattanDistance = ").concat(this.manhattanDistance,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.manhattanDistance=this.manhattanDistance,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.manhattanDistance=e.manhattanDistance},(0,A.Cg)([dt("Use Manhattan Distance",0,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"manhattanDistance",void 0),t}(ut);(0,j.Y5)("BABYLON.WorleyNoise3DBlock",Gy);var ky=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("seed",G.Vector3),n.registerOutput("output",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SimplexPerlin3DBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this.seed.isConnected&&this._outputs[0].hasEndpoints){var n=`const float SKEWFACTOR = 1.0/3.0;
|
||
`;return n+=`const float UNSKEWFACTOR = 1.0/6.0;
|
||
`,n+=`const float SIMPLEX_CORNER_POS = 0.5;
|
||
`,n+=`const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;
|
||
`,n+=`float SimplexPerlin3D( vec3 source ){
|
||
`,n+=` vec3 P = source;
|
||
`,n+=` P.x = [P.x == 0. && P.y == 0. && P.z == 0. ? 0.00001 : P.x];
|
||
`,n+=` P *= SIMPLEX_TETRAHADRON_HEIGHT;
|
||
`,n+=" vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );",n+=` vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );
|
||
`,n+=` vec3 g = step(x0.yzx, x0.xyz);
|
||
`,n+=` vec3 l = 1.0 - g;
|
||
`,n+=` vec3 Pi_1 = min( g.xyz, l.zxy );
|
||
`,n+=` vec3 Pi_2 = max( g.xyz, l.zxy );
|
||
`,n+=` vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;
|
||
`,n+=` vec3 x2 = x0 - Pi_2 + SKEWFACTOR;
|
||
`,n+=` vec3 x3 = x0 - SIMPLEX_CORNER_POS;
|
||
`,n+=` vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );
|
||
`,n+=` vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );
|
||
`,n+=` vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );
|
||
`,n+=` Pi = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;
|
||
`,n+=` vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );
|
||
`,n+=` vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;
|
||
`,n+=` Pt *= Pt;
|
||
`,n+=` vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );
|
||
`,n+=` Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );
|
||
`,n+=` const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );
|
||
`,n+=` const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );
|
||
`,n+=` vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );
|
||
`,n+=` vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );
|
||
`,n+=` Pi_1 = [( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods];
|
||
`,n+=` Pi_2 = [( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods];
|
||
`,n+=` vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;
|
||
`,n+=` vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;
|
||
`,n+=` vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;
|
||
`,n+=` vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );
|
||
`,n+=` const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;
|
||
`,n+=` vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;
|
||
`,n+=` kernel_weights = max(0.5 - kernel_weights, vec4(0.));
|
||
`,n+=` kernel_weights = kernel_weights*kernel_weights*kernel_weights;
|
||
`,n+=` return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;
|
||
`,n+=`}
|
||
`,n=e.shaderLanguage===1?e._babylonSLtoWGSL(n):e._babylonSLtoGLSL(n),e._emitFunction("SimplexPerlin3D",n,"// SimplexPerlin3D"),e.compilationString+=e._declareOutput(this._outputs[0])+" = SimplexPerlin3D(".concat(this.seed.associatedVariableName,`);
|
||
`),this}},t}(ut);(0,j.Y5)("BABYLON.SimplexPerlin3DBlock",ky);var zy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("normalMap0",G.AutoDetect),n.registerInput("normalMap1",G.AutoDetect),n.registerOutput("output",G.Vector3),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Color4|G.Vector3|G.Vector4),n._inputs[1].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Color4|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"NormalBlendBlock"},Object.defineProperty(t.prototype,"normalMap0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMap1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this._inputs[0],o=this._inputs[1],a=e._getFreeVariableName("stepR"),s=e._getFreeVariableName("stepG");return e.compilationString+="".concat(e._declareLocalVar(a,G.Float)," = step(0.5, ").concat(i.associatedVariableName,`.r);
|
||
`),e.compilationString+="".concat(e._declareLocalVar(s,G.Float)," = step(0.5, ").concat(i.associatedVariableName,`.g);
|
||
`),e.compilationString+=e._declareOutput(n)+`;
|
||
`,e.compilationString+="".concat(n.associatedVariableName,".r = (1.0 - ").concat(a,") * ").concat(i.associatedVariableName,".r * ").concat(o.associatedVariableName,".r * 2.0 + ").concat(a," * (1.0 - (1.0 - ").concat(i.associatedVariableName,".r) * (1.0 - ").concat(o.associatedVariableName,`.r) * 2.0);
|
||
`),e.compilationString+="".concat(n.associatedVariableName,".g = (1.0 - ").concat(s,") * ").concat(i.associatedVariableName,".g * ").concat(o.associatedVariableName,".g * 2.0 + ").concat(s," * (1.0 - (1.0 - ").concat(i.associatedVariableName,".g) * (1.0 - ").concat(o.associatedVariableName,`.g) * 2.0);
|
||
`),e.compilationString+="".concat(n.associatedVariableName,".b = ").concat(i.associatedVariableName,".b * ").concat(o.associatedVariableName,`.b;
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.NormalBlendBlock",zy);var Wy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.Vector2),n.registerInput("angle",G.Float),n.registerOutput("output",G.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"Rotate2dBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.angle.isConnected){var e=new Mt("angle");e.value=0,e.output.connectTo(this.angle)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this.angle,o=this.input;return e.compilationString+=e._declareOutput(n)+" = vec2(cos(".concat(i.associatedVariableName,") * ").concat(o.associatedVariableName,".x - sin(").concat(i.associatedVariableName,") * ").concat(o.associatedVariableName,".y, sin(").concat(i.associatedVariableName,") * ").concat(o.associatedVariableName,".x + cos(").concat(i.associatedVariableName,") * ").concat(o.associatedVariableName,`.y);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.Rotate2dBlock",Wy);var Hy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("incident",G.AutoDetect),n.registerInput("normal",G.AutoDetect),n.registerOutput("output",G.Vector3),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4|G.Color3|G.Color4),n._inputs[1].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4|G.Color3|G.Color4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ReflectBlock"},Object.defineProperty(t.prototype,"incident",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = reflect(".concat(this.incident.associatedVariableName,".xyz, ").concat(this.normal.associatedVariableName,`.xyz);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ReflectBlock",Hy);var Yy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("incident",G.AutoDetect),n.registerInput("normal",G.AutoDetect),n.registerInput("ior",G.Float),n.registerOutput("output",G.Vector3),n._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4|G.Color3|G.Color4),n._inputs[1].addExcludedConnectionPointFromAllowedTypes(G.Vector3|G.Vector4|G.Color3|G.Color4),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"RefractBlock"},Object.defineProperty(t.prototype,"incident",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ior",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.compilationString+=e._declareOutput(n)+" = refract(".concat(this.incident.associatedVariableName,".xyz, ").concat(this.normal.associatedVariableName,".xyz, ").concat(this.ior.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.RefractBlock",Yy);var Xy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("color",G.Color3),n.registerInput("level",G.Float),n.registerOutput("output",G.Color3),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DesaturateBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this.color.associatedVariableName,o=e._getFreeVariableName("colorMin"),a=e._getFreeVariableName("colorMax"),s=e._getFreeVariableName("colorMerge");return e.compilationString+="".concat(e._declareLocalVar(o,G.Float)," = min(min(").concat(i,".x, ").concat(i,".y), ").concat(i,`.z);
|
||
`),e.compilationString+="".concat(e._declareLocalVar(a,G.Float)," = max(max(").concat(i,".x, ").concat(i,".y), ").concat(i,`.z);
|
||
`),e.compilationString+="".concat(e._declareLocalVar(s,G.Float)," = 0.5 * (").concat(o," + ").concat(a,`);
|
||
`),e.compilationString+=e._declareOutput(n)+" = mix(".concat(i,", ").concat(e._getShaderType(G.Vector3),"(").concat(s,", ").concat(s,", ").concat(s,"), ").concat(this.level.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.DesaturateBlock",Xy);var Dh=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.albedoScaling=!1,n.linkSheenWithAlbedo=!1,n._isUnique=!0,n.registerInput("intensity",G.Float,!0,_e.Fragment),n.registerInput("color",G.Color3,!0,_e.Fragment),n.registerInput("roughness",G.Float,!0,_e.Fragment),n.registerOutput("sheen",G.Object,_e.Fragment,new bn("sheen",n,1,t,"SheenBlock")),n}return(0,A.C6)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("sheenOut"),e._excludeVariableName("sheenMapData"),e._excludeVariableName("vSheenColor"),e._excludeVariableName("vSheenRoughness")},t.prototype.getClassName=function(){return"SheenBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheen",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,n,i){r.prototype.prepareDefines.call(this,e,n,i),i.setValue("SHEEN",!0),i.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE",!0,!0),i.setValue("SHEEN_LINKWITHALBEDO",this.linkSheenWithAlbedo,!0),i.setValue("SHEEN_ROUGHNESS",this.roughness.isConnected,!0),i.setValue("SHEEN_ALBEDOSCALING",this.albedoScaling,!0)},t.prototype.getCode=function(e,n){var i=this.color.isConnected?this.color.associatedVariableName:"vec3".concat(n.fSuffix,"(1.)"),o=this.intensity.isConnected?this.intensity.associatedVariableName:"1.",a=this.roughness.isConnected?this.roughness.associatedVariableName:"0.",s="vec4".concat(n.fSuffix,"(0.)"),l=n.shaderLanguage===1;return`#ifdef SHEEN
|
||
`.concat(l?"var sheenOut: sheenOutParams":"sheenOutParams sheenOut",`;
|
||
|
||
`).concat(n._declareLocalVar("vSheenColor",G.Vector4)," = vec4").concat(n.fSuffix,"(").concat(i,", ").concat(o,`);
|
||
|
||
sheenOut = sheenBlock(
|
||
vSheenColor
|
||
#ifdef SHEEN_ROUGHNESS
|
||
, `).concat(a,`
|
||
#endif
|
||
, roughness
|
||
#ifdef SHEEN_TEXTURE
|
||
, `).concat(s,`
|
||
`).concat(l?", ".concat(s,"Sampler"):"",`
|
||
, 1.0
|
||
#endif
|
||
, reflectance
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
, baseColor
|
||
, surfaceAlbedo
|
||
#endif
|
||
#ifdef ENVIRONMENTBRDF
|
||
, NdotV
|
||
, environmentBrdf
|
||
#endif
|
||
#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
||
, AARoughnessFactors
|
||
, `).concat(l?"uniforms.":"").concat(e?._vReflectionMicrosurfaceInfosName,`
|
||
, `).concat(e?._vReflectionInfosName,`
|
||
, `).concat(e?.reflectionColor,`
|
||
, `).concat(l?"uniforms.":"",`vLightingIntensity
|
||
#ifdef `).concat(e?._define3DName,`
|
||
, `).concat(e?._cubeSamplerName,`
|
||
`).concat(l?", ".concat(e?._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat(e?._2DSamplerName,`
|
||
`).concat(l?", ".concat(e?._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
, reflectionOut.reflectionCoords
|
||
, NdotVUnclamped
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef `).concat(e?._define3DName,`
|
||
, `).concat(e?._cubeSamplerName,`
|
||
`).concat(l?", ".concat(e?._cubeSamplerName,"Sampler"):"",`
|
||
, `).concat(e?._cubeSamplerName,`
|
||
`).concat(l?", ".concat(e?._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat(e?._2DSamplerName,`
|
||
`).concat(l?", ".concat(e?._2DSamplerName,"Sampler"):"",`
|
||
, `).concat(e?._2DSamplerName,`
|
||
`).concat(l?", ".concat(e?._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
#endif
|
||
#if !defined(`).concat(e?._defineSkyboxName,`) && defined(RADIANCEOCCLUSION)
|
||
, seo
|
||
#endif
|
||
#if !defined(`).concat(e?._defineSkyboxName,") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(").concat(e?._define3DName,`)
|
||
, eho
|
||
#endif
|
||
#endif
|
||
);
|
||
|
||
#ifdef SHEEN_LINKWITHALBEDO
|
||
surfaceAlbedo = sheenOut.surfaceAlbedo;
|
||
#endif
|
||
#endif
|
||
`)},t.prototype._buildBlock=function(e){return e.target===_e.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return(e+="".concat(this._codeVariableName,".albedoScaling = ").concat(this.albedoScaling,`;
|
||
`))+"".concat(this._codeVariableName,".linkSheenWithAlbedo = ").concat(this.linkSheenWithAlbedo,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.albedoScaling=this.albedoScaling,e.linkSheenWithAlbedo=this.linkSheenWithAlbedo,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.albedoScaling=e.albedoScaling,this.linkSheenWithAlbedo=e.linkSheenWithAlbedo},(0,A.Cg)([dt("Albedo scaling",0,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"albedoScaling",void 0),(0,A.Cg)([dt("Link sheen with albedo",0,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"linkSheenWithAlbedo",void 0),t}(ut);(0,j.Y5)("BABYLON.SheenBlock",Dh);var Nh=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._tangentCorrectionFactorName="",n._isUnique=!0,n.registerInput("intensity",G.Float,!0,_e.Fragment),n.registerInput("direction",G.Vector2,!0,_e.Fragment),n.registerInput("uv",G.Vector2,!0),n.registerInput("worldTangent",G.Vector4,!0),n.registerInput("TBN",G.Object,!0,_e.VertexAndFragment,new bn("TBN",n,0,ps,"TBNBlock")),n.registerInput("roughness",G.Float,!0,_e.Fragment),n.registerOutput("anisotropy",G.Object,_e.Fragment,new bn("anisotropy",n,1,t,"AnisotropyBlock")),n}return(0,A.C6)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("anisotropicOut"),e._excludeVariableName("TBN")},t.prototype.getClassName=function(){return"AnisotropyBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"TBN",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anisotropy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._generateTBNSpace=function(e){var n="",i="//".concat(this.name),o=this.uv,a=this.worldPositionConnectionPoint,s=this.worldNormalConnectionPoint,l=this.worldTangent,c=e.shaderLanguage===1;o.isConnected||O.V.Error("You must connect the 'uv' input of the Anisotropy block!"),e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var u={search:/defined\(TANGENT\)/g,replace:l.isConnected?"defined(TANGENT)":"defined(IGNORE)"},d=this.TBN;return d.isConnected?e.compilationString+=`
|
||
#ifdef TBNBLOCK
|
||
`.concat(c?"var TBN":"mat3 TBN"," = ").concat(d.associatedVariableName,`;
|
||
#endif
|
||
`):l.isConnected&&(n+="".concat(e._declareLocalVar("tbnNormal",G.Vector3)," = normalize(").concat(s.associatedVariableName,`.xyz);
|
||
`),n+="".concat(e._declareLocalVar("tbnTangent",G.Vector3)," = normalize(").concat(l.associatedVariableName,`.xyz);
|
||
`),n+="".concat(e._declareLocalVar("tbnBitangent",G.Vector3)," = cross(tbnNormal, tbnTangent) * ").concat(this._tangentCorrectionFactorName,`;
|
||
`),n+="".concat(c?"var vTBN":"mat3 vTBN"," = ").concat(c?"mat3x3f":"mat3",`(tbnTangent, tbnBitangent, tbnNormal);
|
||
`)),n+=`
|
||
#if defined(`.concat(l.isConnected?"TANGENT":"IGNORE",`) && defined(NORMAL)
|
||
`).concat(c?"var TBN":"mat3 TBN",` = vTBN;
|
||
#else
|
||
`).concat(c?"var TBN":"mat3 TBN"," = cotangent_frame(").concat(s.associatedVariableName+".xyz",", ").concat("v_"+a.associatedVariableName+".xyz",", ").concat(o.isConnected?o.associatedVariableName:"vec2(0.)",", vec2").concat(e.fSuffix,`(1., 1.));
|
||
#endif
|
||
`),e._emitFunctionFromInclude("bumpFragmentMainFunctions",i,{replaceStrings:[u]}),n},t.prototype.getCode=function(e,n){n===void 0&&(n=!1);var i="";n&&(i+=this._generateTBNSpace(e));var o=e.shaderLanguage===1,a=this.intensity.isConnected?this.intensity.associatedVariableName:"1.0",s=this.direction.isConnected?this.direction.associatedVariableName:"vec2(1., 0.)",l=this.roughness.isConnected?this.roughness.associatedVariableName:"0.";return i+"".concat(o?"var anisotropicOut: anisotropicOutParams":"anisotropicOutParams anisotropicOut",`;
|
||
anisotropicOut = anisotropicBlock(
|
||
vec3(`).concat(s,", ").concat(a,`),
|
||
`).concat(l,`,
|
||
#ifdef ANISOTROPIC_TEXTURE
|
||
vec3(0.),
|
||
#endif
|
||
TBN,
|
||
normalW,
|
||
viewDirectionW
|
||
);
|
||
`)},t.prototype.prepareDefines=function(e,n,i){r.prototype.prepareDefines.call(this,e,n,i),i.setValue("ANISOTROPIC",!0),i.setValue("ANISOTROPIC_TEXTURE",!1,!0),i.setValue("ANISOTROPIC_LEGACY",!this.roughness.isConnected)},t.prototype.bind=function(e,n,i){r.prototype.bind.call(this,e,n,i),i&&e.setFloat(this._tangentCorrectionFactorName,i.getWorldMatrix().determinant()<0?-1:1)},t.prototype._buildBlock=function(e){return e.target===_e.Fragment&&(e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),this._tangentCorrectionFactorName=e._getFreeDefineName("tangentCorrectionFactor"),e._emitUniformFromString(this._tangentCorrectionFactorName,G.Float)),this},t}(ut);(0,j.Y5)("BABYLON.AnisotropyBlock",Nh);var Lh=function(r){function t(e){var n=r.call(this,e)||this;return n.useSphericalHarmonics=!0,n.forceIrradianceInFragment=!1,n._isUnique=!0,n.registerInput("position",G.AutoDetect,!1,_e.Vertex),n.registerInput("world",G.Matrix,!1,_e.Vertex),n.registerInput("color",G.Color3,!0,_e.Fragment),n.registerOutput("reflection",G.Object,_e.Fragment,new bn("reflection",n,1,t,"ReflectionBlock")),n.position.addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Vector4),n}return(0,A.C6)(t,r),t.prototype._onGenerateOnlyFragmentCodeChanged=function(){return this.position.isConnected?(this.generateOnlyFragmentCode=!this.generateOnlyFragmentCode,O.V.Error("The position input must not be connected to be able to switch!"),!1):(this._setTarget(),!0)},t.prototype._setTarget=function(){r.prototype._setTarget.call(this),this.getInputByName("position").target=this.generateOnlyFragmentCode?_e.Fragment:_e.Vertex,this.generateOnlyFragmentCode&&(this.forceIrradianceInFragment=!0)},t.prototype.getClassName=function(){return"ReflectionBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this.worldPositionConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this.worldNormalConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this.cameraPositionConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this.viewConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflection",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTexture",{get:function(){return!!this._getTexture()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionColor",{get:function(){return this.color.isConnected?this.color.associatedVariableName:"vec3(1., 1., 1.)"},enumerable:!1,configurable:!0}),t.prototype._getTexture=function(){return this.texture?this.texture:this._scene.environmentTexture},t.prototype.prepareDefines=function(e,n,i){r.prototype.prepareDefines.call(this,e,n,i);var o=this._getTexture(),a=o&&o.getTextureMatrix;i.setValue("REFLECTION",a,!0),a&&(i.setValue(this._defineLODReflectionAlpha,o.lodLevelInAlpha,!0),i.setValue(this._defineLinearSpecularReflection,o.linearSpecularLOD,!0),i.setValue(this._defineOppositeZ,this._scene.useRightHandedSystem?!o.invertZ:o.invertZ,!0),i.setValue("SPHERICAL_HARMONICS",this.useSphericalHarmonics,!0),i.setValue("GAMMAREFLECTION",o.gammaSpace,!0),i.setValue("RGBDREFLECTION",o.isRGBD,!0),o&&o.coordinatesMode!==Ie.g.SKYBOX_MODE&&o.isCube&&(i.setValue("USESPHERICALFROMREFLECTIONMAP",!0),i.setValue("USEIRRADIANCEMAP",!1),this.forceIrradianceInFragment||this._scene.getEngine().getCaps().maxVaryingVectors<=8?i.setValue("USESPHERICALINVERTEX",!1):i.setValue("USESPHERICALINVERTEX",!0)))},t.prototype.bind=function(e,n,i,o){r.prototype.bind.call(this,e,n,i);var a=this._getTexture();if(a&&o){a.isCube?e.setTexture(this._cubeSamplerName,a):e.setTexture(this._2DSamplerName,a);var s=a.getSize().width;e.setFloat3(this._vReflectionMicrosurfaceInfosName,s,a.lodGenerationScale,a.lodGenerationOffset),e.setFloat2(this._vReflectionFilteringInfoName,s,Math.log2(s));var l=o.materialDefines,c=a.sphericalPolynomial;if(l.USESPHERICALFROMREFLECTIONMAP&&c)if(l.SPHERICAL_HARMONICS){var u=c.preScaledHarmonics;e.setVector3("vSphericalL00",u.l00),e.setVector3("vSphericalL1_1",u.l1_1),e.setVector3("vSphericalL10",u.l10),e.setVector3("vSphericalL11",u.l11),e.setVector3("vSphericalL2_2",u.l2_2),e.setVector3("vSphericalL2_1",u.l2_1),e.setVector3("vSphericalL20",u.l20),e.setVector3("vSphericalL21",u.l21),e.setVector3("vSphericalL22",u.l22)}else e.setFloat3("vSphericalX",c.x.x,c.x.y,c.x.z),e.setFloat3("vSphericalY",c.y.x,c.y.y,c.y.z),e.setFloat3("vSphericalZ",c.z.x,c.z.y,c.z.z),e.setFloat3("vSphericalXX_ZZ",c.xx.x-c.zz.x,c.xx.y-c.zz.y,c.xx.z-c.zz.z),e.setFloat3("vSphericalYY_ZZ",c.yy.x-c.zz.x,c.yy.y-c.zz.y,c.yy.z-c.zz.z),e.setFloat3("vSphericalZZ",c.zz.x,c.zz.y,c.zz.z),e.setFloat3("vSphericalXY",c.xy.x,c.xy.y,c.xy.z),e.setFloat3("vSphericalYZ",c.yz.x,c.yz.y,c.yz.z),e.setFloat3("vSphericalZX",c.zx.x,c.zx.y,c.zx.z)}},t.prototype.handleVertexSide=function(e){var n=r.prototype.handleVertexSide.call(this,e),i=e.shaderLanguage===1;e._emitFunctionFromInclude("harmonicsFunctions","//".concat(this.name),{replaceStrings:[{search:/uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,replace:""},{search:/uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,replace:""}]});var o=e._getFreeVariableName("reflectionVector");return this._vEnvironmentIrradianceName=e._getFreeVariableName("vEnvironmentIrradiance"),e._emitVaryingFromString(this._vEnvironmentIrradianceName,G.Vector3,"defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"),e._emitUniformFromString("vSphericalL00",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL1_1",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL10",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL11",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL2_2",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL2_1",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL20",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL21",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalL22",G.Vector3,"SPHERICAL_HARMONICS"),e._emitUniformFromString("vSphericalX",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalY",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalZ",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalXX_ZZ",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalYY_ZZ",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalZZ",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalXY",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalYZ",G.Vector3,"SPHERICAL_HARMONICS",!0),e._emitUniformFromString("vSphericalZX",G.Vector3,"SPHERICAL_HARMONICS",!0),n+`#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
|
||
`.concat(e._declareLocalVar(o,G.Vector3)," = (").concat((i?"uniforms.":"")+this._reflectionMatrixName," * vec4").concat(e.fSuffix,"(normalize(").concat(this.worldNormal.associatedVariableName,`).xyz, 0)).xyz;
|
||
#ifdef `).concat(this._defineOppositeZ,`
|
||
`).concat(o,`.z *= -1.0;
|
||
#endif
|
||
`).concat(i?"vertexOutputs.":"").concat(this._vEnvironmentIrradianceName," = computeEnvironmentIrradiance(").concat(o,`);
|
||
#endif
|
||
`)},t.prototype.getCode=function(e,n){var i="";this.handleFragmentSideInits(e);var o=e.shaderLanguage===1;e._emitFunctionFromInclude("harmonicsFunctions","//".concat(this.name),{replaceStrings:[{search:/uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,replace:""},{search:/uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,replace:""}]}),o||(e._emitFunction("sampleReflection",`
|
||
#ifdef `.concat(this._define3DName,`
|
||
#define sampleReflection(s, c) textureCube(s, c)
|
||
#else
|
||
#define sampleReflection(s, c) texture2D(s, c)
|
||
#endif
|
||
`),"//".concat(this.name)),e._emitFunction("sampleReflectionLod",`
|
||
#ifdef `.concat(this._define3DName,`
|
||
#define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
|
||
#else
|
||
#define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
|
||
#endif
|
||
`),"//".concat(this.name)));var a=o?`
|
||
fn computeReflectionCoordsPBR(worldPos: vec4f, worldNormal: vec3f) -> vec3f {
|
||
`.concat(this.handleFragmentSideCodeReflectionCoords(e,"worldNormal","worldPos",!0,!0),`
|
||
return `).concat(this._reflectionVectorName,`;
|
||
}
|
||
`):`
|
||
vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {
|
||
`.concat(this.handleFragmentSideCodeReflectionCoords(e,"worldNormal","worldPos",!0,!0),`
|
||
return `).concat(this._reflectionVectorName,`;
|
||
}
|
||
`);return e._emitFunction("computeReflectionCoordsPBR",a,"//".concat(this.name)),this._vReflectionMicrosurfaceInfosName=e._getFreeVariableName("vReflectionMicrosurfaceInfos"),e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName,G.Vector3),this._vReflectionInfosName=e._getFreeVariableName("vReflectionInfos"),this._vReflectionFilteringInfoName=e._getFreeVariableName("vReflectionFilteringInfo"),e._emitUniformFromString(this._vReflectionFilteringInfoName,G.Vector2),i+`#ifdef REFLECTION
|
||
`.concat(e._declareLocalVar(this._vReflectionInfosName,G.Vector2)," = vec2").concat(e.fSuffix,`(1., 0.);
|
||
|
||
`).concat(o?"var reflectionOut: reflectionOutParams":"reflectionOutParams reflectionOut",`;
|
||
|
||
reflectionOut = reflectionBlock(
|
||
`).concat(this.generateOnlyFragmentCode?this._worldPositionNameInFragmentOnlyMode:(o?"input.":"")+"v_"+this.worldPosition.associatedVariableName,`.xyz
|
||
, `).concat(n,`
|
||
, alphaG
|
||
, `).concat((o?"uniforms.":"")+this._vReflectionMicrosurfaceInfosName,`
|
||
, `).concat(this._vReflectionInfosName,`
|
||
, `).concat(this.reflectionColor,`
|
||
#ifdef ANISOTROPIC
|
||
,anisotropicOut
|
||
#endif
|
||
#if defined(`).concat(this._defineLODReflectionAlpha,") && !defined(").concat(this._defineSkyboxName,`)
|
||
,NdotVUnclamped
|
||
#endif
|
||
#ifdef `).concat(this._defineLinearSpecularReflection,`
|
||
, roughness
|
||
#endif
|
||
#ifdef `).concat(this._define3DName,`
|
||
, `).concat(this._cubeSamplerName,`
|
||
`).concat(o?", ".concat(this._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat(this._2DSamplerName,`
|
||
`).concat(o?", ".concat(this._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
||
, `).concat(o?"input.":"").concat(this._vEnvironmentIrradianceName,`
|
||
#endif
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
, `).concat(this._reflectionMatrixName,`
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
, irradianceSampler // ** not handled **
|
||
`).concat(o?", irradianceSamplerSampler":"",`
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef `).concat(this._define3DName,`
|
||
, `).concat(this._cubeSamplerName,`
|
||
`).concat(o?", ".concat(this._cubeSamplerName,"Sampler"):"",`
|
||
, `).concat(this._cubeSamplerName,`
|
||
`).concat(o?", ".concat(this._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat(this._2DSamplerName,`
|
||
`).concat(o?", ".concat(this._2DSamplerName,"Sampler"):"",`
|
||
, `).concat(this._2DSamplerName,`
|
||
`).concat(o?", ".concat(this._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
, `).concat(this._vReflectionFilteringInfoName,`
|
||
#endif
|
||
);
|
||
#endif
|
||
`)},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,e.target!==_e.Fragment&&(this._defineLODReflectionAlpha=e._getFreeDefineName("LODINREFLECTIONALPHA"),this._defineLinearSpecularReflection=e._getFreeDefineName("LINEARSPECULARREFLECTION")),this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return this.texture&&(e+="".concat(this._codeVariableName,".texture.gammaSpace = ").concat(this.texture.gammaSpace,`;
|
||
`)),(e+="".concat(this._codeVariableName,".useSphericalHarmonics = ").concat(this.useSphericalHarmonics,`;
|
||
`))+"".concat(this._codeVariableName,".forceIrradianceInFragment = ").concat(this.forceIrradianceInFragment,`;
|
||
`)},t.prototype.serialize=function(){var e,n,i=r.prototype.serialize.call(this);return i.useSphericalHarmonics=this.useSphericalHarmonics,i.forceIrradianceInFragment=this.forceIrradianceInFragment,i.gammaSpace=(n=(e=this.texture)===null||e===void 0?void 0:e.gammaSpace)===null||n===void 0||n,i},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.useSphericalHarmonics=e.useSphericalHarmonics,this.forceIrradianceInFragment=e.forceIrradianceInFragment,this.texture&&(this.texture.gammaSpace=e.gammaSpace)},(0,A.Cg)([dt("Spherical Harmonics",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useSphericalHarmonics",void 0),(0,A.Cg)([dt("Force irradiance in fragment",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"forceIrradianceInFragment",void 0),t}(xl);(0,j.Y5)("BABYLON.ReflectionBlock",Lh);var Al=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._tangentCorrectionFactorName="",n.remapF0OnInterfaceChange=!0,n._isUnique=!0,n.registerInput("intensity",G.Float,!1,_e.Fragment),n.registerInput("roughness",G.Float,!0,_e.Fragment),n.registerInput("indexOfRefraction",G.Float,!0,_e.Fragment),n.registerInput("normalMapColor",G.Color3,!0,_e.Fragment),n.registerInput("uv",G.Vector2,!0,_e.Fragment),n.registerInput("tintColor",G.Color3,!0,_e.Fragment),n.registerInput("tintAtDistance",G.Float,!0,_e.Fragment),n.registerInput("tintThickness",G.Float,!0,_e.Fragment),n.registerInput("worldTangent",G.Vector4,!0),n.registerInput("worldNormal",G.AutoDetect,!0),n.worldNormal.addExcludedConnectionPointFromAllowedTypes(G.Color4|G.Vector4|G.Vector3),n.registerInput("TBN",G.Object,!0,_e.VertexAndFragment,new bn("TBN",n,0,ps,"TBNBlock")),n.registerOutput("clearcoat",G.Object,_e.Fragment,new bn("clearcoat",n,1,t,"ClearCoatBlock")),n}return(0,A.C6)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("clearcoatOut"),e._excludeVariableName("vClearCoatParams"),e._excludeVariableName("vClearCoatTintParams"),e._excludeVariableName("vClearCoatRefractionParams"),e._excludeVariableName("vClearCoatTangentSpaceParams"),e._excludeVariableName("vGeometricNormaClearCoatW")},t.prototype.getClassName=function(){return"ClearCoatBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMapColor",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintColor",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintAtDistance",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintThickness",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"TBN",{get:function(){return this._inputs[10]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoat",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.intensity.isConnected){var e=new Mt("ClearCoat intensity",_e.Fragment,G.Float);e.value=1,e.output.connectTo(this.intensity)}},t.prototype.prepareDefines=function(e,n,i){r.prototype.prepareDefines.call(this,e,n,i),i.setValue("CLEARCOAT",!0),i.setValue("CLEARCOAT_TEXTURE",!1,!0),i.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE",!0,!0),i.setValue("CLEARCOAT_TINT",this.tintColor.isConnected||this.tintThickness.isConnected||this.tintAtDistance.isConnected,!0),i.setValue("CLEARCOAT_BUMP",this.normalMapColor.isConnected,!0),i.setValue("CLEARCOAT_DEFAULTIOR",!this.indexOfRefraction.isConnected||this.indexOfRefraction.connectInputBlock.value===Ka._DefaultIndexOfRefraction,!0),i.setValue("CLEARCOAT_REMAP_F0",this.remapF0OnInterfaceChange,!0)},t.prototype.bind=function(e,n,i){var o,a;r.prototype.bind.call(this,e,n,i);var s=(a=(o=this.indexOfRefraction.connectInputBlock)===null||o===void 0?void 0:o.value)!==null&&a!==void 0?a:Ka._DefaultIndexOfRefraction,l=1-s,c=1+s,u=Math.pow(-l/c,2),d=1/s;e.setFloat4("vClearCoatRefractionParams",u,d,l,c);var h=this.clearcoat.hasEndpoints?this.clearcoat.endpoints[0].ownerBlock:null,p=h?.perturbedNormal.isConnected?h.perturbedNormal.connectedPoint.ownerBlock:null;this._scene._mirroredCameraPosition?e.setFloat2("vClearCoatTangentSpaceParams",p?.invertX?1:-1,p?.invertY?1:-1):e.setFloat2("vClearCoatTangentSpaceParams",p?.invertX?-1:1,p?.invertY?-1:1),i&&e.setFloat(this._tangentCorrectionFactorName,i.getWorldMatrix().determinant()<0?-1:1)},t.prototype._generateTBNSpace=function(e,n,i){var o="",a="//".concat(this.name),s=this.worldTangent,l=e.shaderLanguage===1;l||e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var c={search:/defined\(TANGENT\)/g,replace:s.isConnected?"defined(TANGENT)":"defined(IGNORE)"},u=this.TBN;return u.isConnected?e.compilationString+=`
|
||
#ifdef TBNBLOCK
|
||
`.concat(l?"var TBN":"mat3 TBN"," = ").concat(u.associatedVariableName,`;
|
||
#endif
|
||
`):s.isConnected&&(o+="".concat(e._declareLocalVar("tbnNormal",G.Vector3)," = normalize(").concat(i,`.xyz);
|
||
`),o+="".concat(e._declareLocalVar("tbnTangent",G.Vector3)," = normalize(").concat(s.associatedVariableName,`.xyz);
|
||
`),o+="".concat(e._declareLocalVar("tbnBitangent",G.Vector3)," = cross(tbnNormal, tbnTangent) * ").concat(this._tangentCorrectionFactorName,`;
|
||
`),o+="".concat(l?"var vTBN":"mat3 vTBN"," = ").concat(l?"mat3x3f":"mat3",`(tbnTangent, tbnBitangent, tbnNormal);
|
||
`)),e._emitFunctionFromInclude("bumpFragmentMainFunctions",a,{replaceStrings:[c]}),o},t.GetCode=function(e,n,i,o,a,s,l){var c="",u=n?.intensity.isConnected?n.intensity.associatedVariableName:"1.",d=n?.roughness.isConnected?n.roughness.associatedVariableName:"0.",h=n?.normalMapColor.isConnected?n.normalMapColor.associatedVariableName:"vec3".concat(e.fSuffix,"(0.)"),p=n?.uv.isConnected?n.uv.associatedVariableName:"vec2".concat(e.fSuffix,"(0.)"),m=n?.tintColor.isConnected?n.tintColor.associatedVariableName:"vec3".concat(e.fSuffix,"(1.)"),v=n?.tintThickness.isConnected?n.tintThickness.associatedVariableName:"1.",b=n?.tintAtDistance.isConnected?n.tintAtDistance.associatedVariableName:"1.",E="vec4".concat(e.fSuffix,"(0.)");if(n){e._emitUniformFromString("vClearCoatRefractionParams",G.Vector4),e._emitUniformFromString("vClearCoatTangentSpaceParams",G.Vector2);var C=n.worldNormal;c+="".concat(e._declareLocalVar("vGeometricNormaClearCoatW",G.Vector3)," = ").concat(C.isConnected?"normalize("+C.associatedVariableName+".xyz)":"geometricNormalW",`;
|
||
`)}else c+="".concat(e._declareLocalVar("vGeometricNormaClearCoatW",G.Vector3),` = geometricNormalW;
|
||
`);a&&n&&(c+=n._generateTBNSpace(e,o,l),s=n.worldTangent.isConnected);var T=e.shaderLanguage===1;return c+"".concat(T?"var clearcoatOut: clearcoatOutParams":"clearcoatOutParams clearcoatOut",`;
|
||
|
||
#ifdef CLEARCOAT
|
||
`).concat(e._declareLocalVar("vClearCoatParams",G.Vector2)," = vec2").concat(e.fSuffix,"(").concat(u,", ").concat(d,`);
|
||
`).concat(e._declareLocalVar("vClearCoatTintParams",G.Vector4)," = vec4").concat(e.fSuffix,"(").concat(m,", ").concat(v,`);
|
||
|
||
clearcoatOut = clearcoatBlock(
|
||
`).concat(o,`.xyz
|
||
, vGeometricNormaClearCoatW
|
||
, viewDirectionW
|
||
, vClearCoatParams
|
||
, specularEnvironmentR0
|
||
#ifdef CLEARCOAT_TEXTURE
|
||
, vec2`).concat(e.fSuffix,`(0.)
|
||
#endif
|
||
#ifdef CLEARCOAT_TINT
|
||
, vClearCoatTintParams
|
||
, `).concat(b,`
|
||
, `).concat(T?"uniforms.":"",`vClearCoatRefractionParams
|
||
#ifdef CLEARCOAT_TINT_TEXTURE
|
||
, `).concat(E,`
|
||
#endif
|
||
#endif
|
||
#ifdef CLEARCOAT_BUMP
|
||
, vec2`).concat(e.fSuffix,`(0., 1.)
|
||
, vec4`).concat(e.fSuffix,"(").concat(h,`, 0.)
|
||
, `).concat(p,`
|
||
#if defined(`).concat(s?"TANGENT":"IGNORE",`) && defined(NORMAL)
|
||
, vTBN
|
||
#else
|
||
, `).concat(T?"uniforms.":"",`vClearCoatTangentSpaceParams
|
||
#endif
|
||
#ifdef OBJECTSPACE_NORMALMAP
|
||
, normalMatrix
|
||
#endif
|
||
#endif
|
||
#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
||
, faceNormal
|
||
#endif
|
||
#ifdef REFLECTION
|
||
, `).concat(T?"uniforms.":"").concat(i?._vReflectionMicrosurfaceInfosName,`
|
||
, `).concat(i?._vReflectionInfosName,`
|
||
, `).concat(i?.reflectionColor,`
|
||
, `).concat(T?"uniforms.":"",`vLightingIntensity
|
||
#ifdef `).concat(i?._define3DName,`
|
||
, `).concat(i?._cubeSamplerName,`
|
||
`).concat(T?", ".concat(i?._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat(i?._2DSamplerName,`
|
||
`).concat(T?", ".concat(i?._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef `).concat(i?._define3DName,`
|
||
, `).concat(i?._cubeSamplerName,`
|
||
`).concat(T?", ".concat(i?._cubeSamplerName,"Sampler"):"",`
|
||
, `).concat(i?._cubeSamplerName,`
|
||
`).concat(T?", ".concat(i?._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat(i?._2DSamplerName,`
|
||
`).concat(T?", ".concat(i?._2DSamplerName,"Sampler"):"",`
|
||
, `).concat(i?._2DSamplerName,`
|
||
`).concat(T?", ".concat(i?._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
|
||
, (`).concat(e._generateTernary("1.","-1.",T?"fragmentInputs.frontFacing":"gl_FrontFacing"),`)
|
||
#endif
|
||
);
|
||
#else
|
||
clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;
|
||
#endif
|
||
`)},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,e.target===_e.Fragment&&(e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this),this._tangentCorrectionFactorName=e._getFreeDefineName("tangentCorrectionFactor"),e._emitUniformFromString(this._tangentCorrectionFactorName,G.Float)),this},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".remapF0OnInterfaceChange = ").concat(this.remapF0OnInterfaceChange,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.remapF0OnInterfaceChange=this.remapF0OnInterfaceChange,e},t.prototype._deserialize=function(e,n,i){var o;r.prototype._deserialize.call(this,e,n,i),this.remapF0OnInterfaceChange=(o=e.remapF0OnInterfaceChange)===null||o===void 0||o},(0,A.Cg)([dt("Remap F0 on interface change",0,"ADVANCED")],t.prototype,"remapF0OnInterfaceChange",void 0),t}(ut);(0,j.Y5)("BABYLON.ClearCoatBlock",Al);var jy=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._isUnique=!0,n.registerInput("intensity",G.Float,!0,_e.Fragment),n.registerInput("indexOfRefraction",G.Float,!0,_e.Fragment),n.registerInput("thickness",G.Float,!0,_e.Fragment),n.registerOutput("iridescence",G.Object,_e.Fragment,new bn("iridescence",n,1,t,"IridescenceBlock")),n}return(0,A.C6)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("iridescenceOut"),e._excludeVariableName("vIridescenceParams")},t.prototype.getClassName=function(){return"IridescenceBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thickness",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"iridescence",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.intensity.isConnected){var e=new Mt("Iridescence intensity",_e.Fragment,G.Float);e.value=1,e.output.connectTo(this.intensity);var n=new Mt("Iridescence ior",_e.Fragment,G.Float);n.value=1.3,n.output.connectTo(this.indexOfRefraction);var i=new Mt("Iridescence thickness",_e.Fragment,G.Float);i.value=400,i.output.connectTo(this.thickness)}},t.prototype.prepareDefines=function(e,n,i){r.prototype.prepareDefines.call(this,e,n,i),i.setValue("IRIDESCENCE",!0,!0),i.setValue("IRIDESCENCE_TEXTURE",!1,!0),i.setValue("IRIDESCENCE_THICKNESS_TEXTURE",!1,!0)},t.GetCode=function(e,n){var i="",o=e?.intensity.isConnected?e.intensity.associatedVariableName:"1.",a=e?.indexOfRefraction.isConnected?e.indexOfRefraction.associatedVariableName:Za._DefaultIndexOfRefraction,s=e?.thickness.isConnected?e.thickness.associatedVariableName:Za._DefaultMaximumThickness,l=n.shaderLanguage===1;return i+"".concat(l?"var iridescenceOut: iridescenceOutParams":"iridescenceOutParams iridescenceOut",`;
|
||
|
||
#ifdef IRIDESCENCE
|
||
iridescenceOut = iridescenceBlock(
|
||
vec4(`).concat(o,", ").concat(a,", 1., ").concat(s,`)
|
||
, NdotV
|
||
, specularEnvironmentR0
|
||
#ifdef CLEARCOAT
|
||
, NdotVUnclamped
|
||
#endif
|
||
);
|
||
|
||
float iridescenceIntensity = iridescenceOut.iridescenceIntensity;
|
||
specularEnvironmentR0 = iridescenceOut.specularEnvironmentR0;
|
||
#endif
|
||
`)},t.prototype._buildBlock=function(e){return e.target===_e.Fragment&&(e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this)),this},t.prototype.serialize=function(){return r.prototype.serialize.call(this)},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i)},t}(ut);(0,j.Y5)("BABYLON.IridescenceBlock",jy);var Fh=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n.linkRefractionWithTransparency=!1,n.invertRefractionY=!1,n.useThicknessAsDepth=!1,n._isUnique=!0,n.registerInput("intensity",G.Float,!1,_e.Fragment),n.registerInput("tintAtDistance",G.Float,!0,_e.Fragment),n.registerInput("volumeIndexOfRefraction",G.Float,!0,_e.Fragment),n.registerOutput("refraction",G.Object,_e.Fragment,new bn("refraction",n,1,t,"RefractionBlock")),n}return(0,A.C6)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("vRefractionPosition"),e._excludeVariableName("vRefractionSize")},t.prototype.getClassName=function(){return"RefractionBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintAtDistance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"volumeIndexOfRefraction",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this.viewConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refraction",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTexture",{get:function(){return!!this._getTexture()},enumerable:!1,configurable:!0}),t.prototype._getTexture=function(){return this.texture?this.texture:this._scene.environmentTexture},t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.intensity.isConnected){var i=new Mt("Refraction intensity",_e.Fragment,G.Float);i.value=1,i.output.connectTo(this.intensity)}if(this.view&&!this.view.isConnected){var o=e.getInputBlockByPredicate(function(a){return a.systemValue===Nt.View&&n(a)});o||(o=new Mt("view")).setAsSystemValue(Nt.View),o.output.connectTo(this.view)}},t.prototype.prepareDefines=function(e,n,i){r.prototype.prepareDefines.call(this,e,n,i);var o=this._getTexture(),a=o&&o.getTextureMatrix;i.setValue("SS_REFRACTION",a,!0),a&&(i.setValue(this._define3DName,o.isCube,!0),i.setValue(this._defineLODRefractionAlpha,o.lodLevelInAlpha,!0),i.setValue(this._defineLinearSpecularRefraction,o.linearSpecularLOD,!0),i.setValue(this._defineOppositeZ,this._scene.useRightHandedSystem&&o.isCube?!o.invertZ:o.invertZ,!0),i.setValue("SS_LINKREFRACTIONTOTRANSPARENCY",this.linkRefractionWithTransparency,!0),i.setValue("SS_GAMMAREFRACTION",o.gammaSpace,!0),i.setValue("SS_RGBDREFRACTION",o.isRGBD,!0),i.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC",!!o.boundingBoxSize,!0),i.setValue("SS_USE_THICKNESS_AS_DEPTH",this.useThicknessAsDepth,!0))},t.prototype.isReady=function(){var e=this._getTexture();return!(e&&!e.isReadyOrNotBlocking())},t.prototype.bind=function(e,n,i){var o,a,s,l;r.prototype.bind.call(this,e,n,i);var c=this._getTexture();if(c){c.isCube?e.setTexture(this._cubeSamplerName,c):e.setTexture(this._2DSamplerName,c),e.setMatrix(this._refractionMatrixName,c.getRefractionTextureMatrix());var u=1;c.isCube||c.depth&&(u=c.depth);var d=(l=(a=(o=this.volumeIndexOfRefraction.connectInputBlock)===null||o===void 0?void 0:o.value)!==null&&a!==void 0?a:(s=this.indexOfRefractionConnectionPoint.connectInputBlock)===null||s===void 0?void 0:s.value)!==null&&l!==void 0?l:1.5;e.setFloat4(this._vRefractionInfosName,c.level,1/d,u,this.invertRefractionY?-1:1),e.setFloat4(this._vRefractionMicrosurfaceInfosName,c.getSize().width,c.lodGenerationScale,c.lodGenerationOffset,1/d);var h=c.getSize().width;if(e.setFloat2(this._vRefractionFilteringInfoName,h,Math.log2(h)),c.boundingBoxSize){var p=c;e.setVector3("vRefractionPosition",p.boundingBoxPosition),e.setVector3("vRefractionSize",p.boundingBoxSize)}}},t.prototype.getCode=function(e){return e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),this._cubeSamplerName=e._getFreeVariableName(this.name+"CubeSampler"),e.samplers.push(this._cubeSamplerName),this._2DSamplerName=e._getFreeVariableName(this.name+"2DSampler"),e.samplers.push(this._2DSamplerName),this._define3DName=e._getFreeDefineName("SS_REFRACTIONMAP_3D"),this._getTexture()&&(e._samplerDeclaration+="#ifdef ".concat(this._define3DName,`
|
||
`),e._emitCubeSampler(this._cubeSamplerName,void 0,!0),e._samplerDeclaration+=`#else
|
||
`,e._emit2DSampler(this._2DSamplerName,void 0,!0),e._samplerDeclaration+=`#endif
|
||
`),e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),this._defineLODRefractionAlpha=e._getFreeDefineName("SS_LODINREFRACTIONALPHA"),this._defineLinearSpecularRefraction=e._getFreeDefineName("SS_LINEARSPECULARREFRACTION"),this._defineOppositeZ=e._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"),this._refractionMatrixName=e._getFreeVariableName("refractionMatrix"),e._emitUniformFromString(this._refractionMatrixName,G.Matrix),e.shaderLanguage!==1&&(e._emitFunction("sampleRefraction",`
|
||
#ifdef `.concat(this._define3DName,`
|
||
#define sampleRefraction(s, c) textureCube(s, c)
|
||
#else
|
||
#define sampleRefraction(s, c) texture2D(s, c)
|
||
#endif
|
||
`),"//".concat(this.name)),e._emitFunction("sampleRefractionLod",`
|
||
#ifdef `.concat(this._define3DName,`
|
||
#define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)
|
||
#else
|
||
#define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)
|
||
#endif
|
||
`),"//".concat(this.name))),this._vRefractionMicrosurfaceInfosName=e._getFreeVariableName("vRefractionMicrosurfaceInfos"),e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName,G.Vector4),this._vRefractionInfosName=e._getFreeVariableName("vRefractionInfos"),e._emitUniformFromString(this._vRefractionInfosName,G.Vector4),this._vRefractionFilteringInfoName=e._getFreeVariableName("vRefractionFilteringInfo"),e._emitUniformFromString(this._vRefractionFilteringInfoName,G.Vector2),e._emitUniformFromString("vRefractionPosition",G.Vector3),e._emitUniformFromString("vRefractionSize",G.Vector3),""},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return this.texture&&(e=this.texture.isCube?"".concat(this._codeVariableName,'.texture = new BABYLON.CubeTexture("').concat(this.texture.name,`");
|
||
`):"".concat(this._codeVariableName,'.texture = new BABYLON.Texture("').concat(this.texture.name,`");
|
||
`),e+="".concat(this._codeVariableName,".texture.coordinatesMode = ").concat(this.texture.coordinatesMode,`;
|
||
`)),e+="".concat(this._codeVariableName,".linkRefractionWithTransparency = ").concat(this.linkRefractionWithTransparency,`;
|
||
`),(e+="".concat(this._codeVariableName,".invertRefractionY = ").concat(this.invertRefractionY,`;
|
||
`))+"".concat(this._codeVariableName,".useThicknessAsDepth = ").concat(this.useThicknessAsDepth,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.texture&&!this.texture.isRenderTarget&&(e.texture=this.texture.serialize()),e.linkRefractionWithTransparency=this.linkRefractionWithTransparency,e.invertRefractionY=this.invertRefractionY,e.useThicknessAsDepth=this.useThicknessAsDepth,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),e.texture&&(i=e.texture.url.indexOf("data:")===0?"":i,e.texture.isCube?this.texture=mr.Parse(e.texture,n,i):this.texture=Ie.g.Parse(e.texture,n,i)),this.linkRefractionWithTransparency=e.linkRefractionWithTransparency,this.invertRefractionY=e.invertRefractionY,this.useThicknessAsDepth=!!e.useThicknessAsDepth},(0,A.Cg)([dt("Link refraction to transparency",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"linkRefractionWithTransparency",void 0),(0,A.Cg)([dt("Invert refraction Y",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"invertRefractionY",void 0),(0,A.Cg)([dt("Use thickness as depth",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useThicknessAsDepth",void 0),t}(ut);(0,j.Y5)("BABYLON.RefractionBlock",Fh);var Cl=function(r){function t(e){var n=r.call(this,e,_e.Fragment)||this;return n._isUnique=!0,n.registerInput("thickness",G.Float,!1,_e.Fragment),n.registerInput("tintColor",G.Color3,!0,_e.Fragment),n.registerInput("translucencyIntensity",G.Float,!0,_e.Fragment),n.registerInput("translucencyDiffusionDist",G.Color3,!0,_e.Fragment),n.registerInput("refraction",G.Object,!0,_e.Fragment,new bn("refraction",n,0,Fh,"RefractionBlock")),n.registerInput("dispersion",G.Float,!0,_e.Fragment),n.registerOutput("subsurface",G.Object,_e.Fragment,new bn("subsurface",n,1,t,"SubSurfaceBlock")),n}return(0,A.C6)(t,r),t.prototype.initialize=function(e){e._excludeVariableName("subSurfaceOut"),e._excludeVariableName("vThicknessParam"),e._excludeVariableName("vTintColor"),e._excludeVariableName("vTranslucencyColor"),e._excludeVariableName("vSubSurfaceIntensity"),e._excludeVariableName("dispersion")},t.prototype.getClassName=function(){return"SubSurfaceBlock"},Object.defineProperty(t.prototype,"thickness",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintColor",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translucencyIntensity",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translucencyDiffusionDist",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refraction",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dispersion",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subsurface",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.thickness.isConnected){var e=new Mt("SubSurface thickness",_e.Fragment,G.Float);e.value=0,e.output.connectTo(this.thickness)}},t.prototype.prepareDefines=function(e,n,i){r.prototype.prepareDefines.call(this,e,n,i);var o=this.translucencyDiffusionDist.isConnected||this.translucencyIntensity.isConnected;i.setValue("SUBSURFACE",o||this.refraction.isConnected,!0),i.setValue("SS_TRANSLUCENCY",o,!0),i.setValue("SS_THICKNESSANDMASK_TEXTURE",!1,!0),i.setValue("SS_REFRACTIONINTENSITY_TEXTURE",!1,!0),i.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE",!1,!0),i.setValue("SS_USE_GLTF_TEXTURES",!1,!0),i.setValue("SS_DISPERSION",this.dispersion.isConnected,!0)},t.GetCode=function(e,n,i,o){var a,s,l,c,u,d,h,p,m,v,b,E,C,T,f,g,S="",y=n?.thickness.isConnected?n.thickness.associatedVariableName:"0.",x=n?.tintColor.isConnected?n.tintColor.associatedVariableName:"vec3(1.)",R=n?.translucencyIntensity.isConnected?n?.translucencyIntensity.associatedVariableName:"1.",I=n?.translucencyDiffusionDist.isConnected?n?.translucencyDiffusionDist.associatedVariableName:"vec3(1.)",M=n?.refraction.isConnected?(a=n?.refraction.connectedPoint)===null||a===void 0?void 0:a.ownerBlock:null,D=M?.tintAtDistance.isConnected?M.tintAtDistance.associatedVariableName:"1.",B=M?.intensity.isConnected?M.intensity.associatedVariableName:"1.",F=M?.view.isConnected?M.view.associatedVariableName:"",X=n?.dispersion.isConnected?n?.dispersion.associatedVariableName:"0.0",$=e.shaderLanguage===1;return(S+=(s=M?.getCode(e))!==null&&s!==void 0?s:"")+"".concat($?"var subSurfaceOut: subSurfaceOutParams":"subSurfaceOutParams subSurfaceOut",`;
|
||
|
||
#ifdef SUBSURFACE
|
||
`).concat(e._declareLocalVar("vThicknessParam",G.Vector2)," = vec2").concat(e.fSuffix,"(0., ").concat(y,`);
|
||
`).concat(e._declareLocalVar("vTintColor",G.Vector4)," = vec4").concat(e.fSuffix,"(").concat(x,", ").concat(D,`);
|
||
`).concat(e._declareLocalVar("vSubSurfaceIntensity",G.Vector3)," = vec3(").concat(B,", ").concat(R,`, 0.);
|
||
`).concat(e._declareLocalVar("dispersion",G.Float)," = ").concat(X,`;
|
||
subSurfaceOut = subSurfaceBlock(
|
||
vSubSurfaceIntensity
|
||
, vThicknessParam
|
||
, vTintColor
|
||
, normalW
|
||
, specularEnvironmentReflectance
|
||
#ifdef SS_THICKNESSANDMASK_TEXTURE
|
||
, vec4`).concat(e.fSuffix,`(0.)
|
||
#endif
|
||
#ifdef REFLECTION
|
||
#ifdef SS_TRANSLUCENCY
|
||
, `).concat(($?"uniforms.":"")+i?._reflectionMatrixName,`
|
||
#ifdef USESPHERICALFROMREFLECTIONMAP
|
||
#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
|
||
, reflectionOut.irradianceVector
|
||
#endif
|
||
#if defined(REALTIME_FILTERING)
|
||
, `).concat(i?._cubeSamplerName,`
|
||
`).concat($?", ".concat(i?._cubeSamplerName,"Sampler"):"",`
|
||
, `).concat(i?._vReflectionFilteringInfoName,`
|
||
#endif
|
||
#endif
|
||
#ifdef USEIRRADIANCEMAP
|
||
, irradianceSampler
|
||
`).concat($?", irradianceSamplerSampler":"",`
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
|
||
, surfaceAlbedo
|
||
#endif
|
||
#ifdef SS_REFRACTION
|
||
, `).concat(o,`.xyz
|
||
, viewDirectionW
|
||
, `).concat(F,`
|
||
, `).concat((l=($?"uniforms.":"")+M?._vRefractionInfosName)!==null&&l!==void 0?l:"",`
|
||
, `).concat((c=($?"uniforms.":"")+M?._refractionMatrixName)!==null&&c!==void 0?c:"",`
|
||
, `).concat((u=($?"uniforms.":"")+M?._vRefractionMicrosurfaceInfosName)!==null&&u!==void 0?u:"",`
|
||
, `).concat($?"uniforms.":"",`vLightingIntensity
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
, alpha
|
||
#endif
|
||
#ifdef `).concat((d=M?._defineLODRefractionAlpha)!==null&&d!==void 0?d:"IGNORE",`
|
||
, NdotVUnclamped
|
||
#endif
|
||
#ifdef `).concat((h=M?._defineLinearSpecularRefraction)!==null&&h!==void 0?h:"IGNORE",`
|
||
, roughness
|
||
#endif
|
||
, alphaG
|
||
#ifdef `).concat((p=M?._define3DName)!==null&&p!==void 0?p:"IGNORE",`
|
||
, `).concat((m=M?._cubeSamplerName)!==null&&m!==void 0?m:"",`
|
||
`).concat($?", ".concat(M?._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat((v=M?._2DSamplerName)!==null&&v!==void 0?v:"",`
|
||
`).concat($?", ".concat(M?._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
#ifndef LODBASEDMICROSFURACE
|
||
#ifdef `).concat((b=M?._define3DName)!==null&&b!==void 0?b:"IGNORE",`
|
||
, `).concat((E=M?._cubeSamplerName)!==null&&E!==void 0?E:"",`
|
||
`).concat($?", ".concat(M?._cubeSamplerName,"Sampler"):"",`
|
||
, `).concat((C=M?._cubeSamplerName)!==null&&C!==void 0?C:"",`
|
||
`).concat($?", ".concat(M?._cubeSamplerName,"Sampler"):"",`
|
||
#else
|
||
, `).concat((T=M?._2DSamplerName)!==null&&T!==void 0?T:"",`
|
||
`).concat($?", ".concat(M?._2DSamplerName,"Sampler"):"",`
|
||
, `).concat((f=M?._2DSamplerName)!==null&&f!==void 0?f:"",`
|
||
`).concat($?", ".concat(M?._2DSamplerName,"Sampler"):"",`
|
||
#endif
|
||
#endif
|
||
#ifdef ANISOTROPIC
|
||
, anisotropicOut
|
||
#endif
|
||
#ifdef REALTIME_FILTERING
|
||
, `).concat((g=M?._vRefractionFilteringInfoName)!==null&&g!==void 0?g:"",`
|
||
#endif
|
||
#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
|
||
, vRefractionPosition
|
||
, vRefractionSize
|
||
#endif
|
||
#ifdef SS_DISPERSION
|
||
, dispersion
|
||
#endif
|
||
#endif
|
||
#ifdef SS_TRANSLUCENCY
|
||
, `).concat(I,`
|
||
, vTintColor
|
||
#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
|
||
, vec4`).concat(e.fSuffix,`(0.)
|
||
#endif
|
||
#endif
|
||
);
|
||
|
||
#ifdef SS_REFRACTION
|
||
surfaceAlbedo = subSurfaceOut.surfaceAlbedo;
|
||
#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
|
||
alpha = subSurfaceOut.alpha;
|
||
#endif
|
||
#endif
|
||
#else
|
||
subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;
|
||
#endif
|
||
`)},t.prototype._buildBlock=function(e){return e.target===_e.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t}(ut);(0,j.Y5)("BABYLON.SubSurfaceBlock",Cl);var lN={ambientClr:["finalAmbient",""],diffuseDir:["finalDiffuse",""],specularDir:["finalSpecularScaled","!defined(UNLIT) && defined(SPECULARTERM)"],clearcoatDir:["finalClearCoatScaled","!defined(UNLIT) && defined(CLEARCOAT)"],sheenDir:["finalSheenScaled","!defined(UNLIT) && defined(SHEEN)"],diffuseInd:["finalIrradiance","!defined(UNLIT) && defined(REFLECTION)"],specularInd:["finalRadianceScaled","!defined(UNLIT) && defined(REFLECTION)"],clearcoatInd:["clearcoatOut.finalClearCoatRadianceScaled","!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"],sheenInd:["sheenOut.finalSheenRadianceScaled","!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"],refraction:["subSurfaceOut.finalRefraction","!defined(UNLIT) && defined(SS_REFRACTION)"],lighting:["finalColor.rgb",""],shadow:["aggShadow",""],alpha:["alpha",""]},qy=function(r){function t(e){var n=r.call(this,e,_e.VertexAndFragment)||this;return n._environmentBRDFTexture=null,n._metallicReflectanceColor=z.v9.White(),n._metallicF0Factor=1,n.directIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.lightFalloff=0,n.useAlphaTest=!1,n.alphaTestCutoff=.5,n.useAlphaBlending=!1,n.useRadianceOverAlpha=!0,n.useSpecularOverAlpha=!0,n.enableSpecularAntiAliasing=!1,n.realTimeFiltering=!1,n.realTimeFilteringQuality=P.Y.TEXTURE_FILTERING_QUALITY_LOW,n.useEnergyConservation=!0,n.useRadianceOcclusion=!0,n.useHorizonOcclusion=!0,n.unlit=!1,n.forceNormalForward=!1,n.generateOnlyFragmentCode=!1,n.debugMode=0,n.debugLimit=0,n.debugFactor=1,n._isUnique=!0,n.registerInput("worldPosition",G.Vector4,!1,_e.Vertex),n.registerInput("worldNormal",G.Vector4,!1,_e.Vertex),n.registerInput("view",G.Matrix,!1),n.registerInput("cameraPosition",G.Vector3,!1,_e.Fragment),n.registerInput("perturbedNormal",G.Vector4,!0,_e.Fragment),n.registerInput("baseColor",G.Color3,!0,_e.Fragment),n.registerInput("metallic",G.Float,!1,_e.Fragment),n.registerInput("roughness",G.Float,!1,_e.Fragment),n.registerInput("ambientOcc",G.Float,!0,_e.Fragment),n.registerInput("opacity",G.Float,!0,_e.Fragment),n.registerInput("indexOfRefraction",G.Float,!0,_e.Fragment),n.registerInput("ambientColor",G.Color3,!0,_e.Fragment),n.registerInput("reflection",G.Object,!0,_e.Fragment,new bn("reflection",n,0,Lh,"ReflectionBlock")),n.registerInput("clearcoat",G.Object,!0,_e.Fragment,new bn("clearcoat",n,0,Al,"ClearCoatBlock")),n.registerInput("sheen",G.Object,!0,_e.Fragment,new bn("sheen",n,0,Dh,"SheenBlock")),n.registerInput("subsurface",G.Object,!0,_e.Fragment,new bn("subsurface",n,0,Cl,"SubSurfaceBlock")),n.registerInput("anisotropy",G.Object,!0,_e.Fragment,new bn("anisotropy",n,0,Nh,"AnisotropyBlock")),n.registerInput("iridescence",G.Object,!0,_e.Fragment,new bn("iridescence",n,0,jy,"IridescenceBlock")),n.registerOutput("ambientClr",G.Color3,_e.Fragment),n.registerOutput("diffuseDir",G.Color3,_e.Fragment),n.registerOutput("specularDir",G.Color3,_e.Fragment),n.registerOutput("clearcoatDir",G.Color3,_e.Fragment),n.registerOutput("sheenDir",G.Color3,_e.Fragment),n.registerOutput("diffuseInd",G.Color3,_e.Fragment),n.registerOutput("specularInd",G.Color3,_e.Fragment),n.registerOutput("clearcoatInd",G.Color3,_e.Fragment),n.registerOutput("sheenInd",G.Color3,_e.Fragment),n.registerOutput("refraction",G.Color3,_e.Fragment),n.registerOutput("lighting",G.Color3,_e.Fragment),n.registerOutput("shadow",G.Float,_e.Fragment),n.registerOutput("alpha",G.Float,_e.Fragment),n}return(0,A.C6)(t,r),t._OnGenerateOnlyFragmentCodeChanged=function(e,n){var i=e;return i.worldPosition.isConnected?(i.generateOnlyFragmentCode=!i.generateOnlyFragmentCode,O.V.Error("The worldPosition input must not be connected to be able to switch!"),!1):(i._setTarget(),!0)},t.prototype._setTarget=function(){this._setInitialTarget(this.generateOnlyFragmentCode?_e.Fragment:_e.VertexAndFragment),this.getInputByName("worldPosition").target=this.generateOnlyFragmentCode?_e.Fragment:_e.Vertex},t.prototype.initialize=function(e){e._excludeVariableName("vLightingIntensity"),e._excludeVariableName("geometricNormalW"),e._excludeVariableName("normalW"),e._excludeVariableName("faceNormal"),e._excludeVariableName("albedoOpacityOut"),e._excludeVariableName("surfaceAlbedo"),e._excludeVariableName("alpha"),e._excludeVariableName("aoOut"),e._excludeVariableName("baseColor"),e._excludeVariableName("reflectivityOut"),e._excludeVariableName("microSurface"),e._excludeVariableName("roughness"),e._excludeVariableName("NdotVUnclamped"),e._excludeVariableName("NdotV"),e._excludeVariableName("alphaG"),e._excludeVariableName("AARoughnessFactors"),e._excludeVariableName("environmentBrdf"),e._excludeVariableName("ambientMonochrome"),e._excludeVariableName("seo"),e._excludeVariableName("eho"),e._excludeVariableName("environmentRadiance"),e._excludeVariableName("irradianceVector"),e._excludeVariableName("environmentIrradiance"),e._excludeVariableName("diffuseBase"),e._excludeVariableName("specularBase"),e._excludeVariableName("preInfo"),e._excludeVariableName("info"),e._excludeVariableName("shadow"),e._excludeVariableName("finalDiffuse"),e._excludeVariableName("finalAmbient"),e._excludeVariableName("ambientOcclusionForDirectDiffuse"),e._excludeVariableName("finalColor"),e._excludeVariableName("vClipSpacePosition"),e._excludeVariableName("vDebugMode"),this._initShaderSourceAsync(e.shaderLanguage)},t.prototype._initShaderSourceAsync=function(e){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._codeIsReady=!1,e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,10721)),Promise.resolve().then(L.bind(L,36934))])];case 1:return n.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,17152)),Promise.resolve().then(L.bind(L,62338))])];case 3:n.sent(),n.label=4;case 4:return this._codeIsReady=!0,this.onCodeIsReadyObservable.notifyObservers(this),[2]}})})},t.prototype.getClassName=function(){return"PBRMetallicRoughnessBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"perturbedNormal",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColor",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallic",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ambientOcc",{get:function(){return this._inputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"opacity",{get:function(){return this._inputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this._inputs[10]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ambientColor",{get:function(){return this._inputs[11]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflection",{get:function(){return this._inputs[12]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoat",{get:function(){return this._inputs[13]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheen",{get:function(){return this._inputs[14]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subsurface",{get:function(){return this._inputs[15]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anisotropy",{get:function(){return this._inputs[16]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"iridescence",{get:function(){return this._inputs[17]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ambientClr",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseDir",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularDir",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoatDir",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheenDir",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseInd",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularInd",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoatInd",{get:function(){return this._outputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheenInd",{get:function(){return this._outputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refraction",{get:function(){return this._outputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lighting",{get:function(){return this._outputs[10]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadow",{get:function(){return this._outputs[11]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this._outputs[12]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e,n){if(n===void 0&&(n=function(){return!0}),!this.cameraPosition.isConnected){var i=e.getInputBlockByPredicate(function(a){return a.systemValue===Nt.CameraPosition&&n(a)});i||(i=new Mt("cameraPosition")).setAsSystemValue(Nt.CameraPosition),i.output.connectTo(this.cameraPosition)}if(!this.view.isConnected){var o=e.getInputBlockByPredicate(function(a){return a.systemValue===Nt.View&&n(a)});o||(o=new Mt("view")).setAsSystemValue(Nt.View),o.output.connectTo(this.view)}},t.prototype.prepareDefines=function(e,n,i){i.setValue("PBR",!0),i.setValue("METALLICWORKFLOW",!0),i.setValue("DEBUGMODE",this.debugMode,!0),i.setValue("DEBUGMODE_FORCERETURN",!0),i.setValue("NORMALXYSCALE",!0),i.setValue("BUMP",this.perturbedNormal.isConnected,!0),i.setValue("LODBASEDMICROSFURACE",this._scene.getEngine().getCaps().textureLOD),i.setValue("ALBEDO",!1,!0),i.setValue("OPACITY",this.opacity.isConnected,!0),i.setValue("AMBIENT",!0,!0),i.setValue("AMBIENTINGRAYSCALE",!1,!0),i.setValue("REFLECTIVITY",!1,!0),i.setValue("AOSTOREINMETALMAPRED",!1,!0),i.setValue("METALLNESSSTOREINMETALMAPBLUE",!1,!0),i.setValue("ROUGHNESSSTOREINMETALMAPALPHA",!1,!0),i.setValue("ROUGHNESSSTOREINMETALMAPGREEN",!1,!0),this.lightFalloff===Tn.LIGHTFALLOFF_STANDARD?(i.setValue("USEPHYSICALLIGHTFALLOFF",!1),i.setValue("USEGLTFLIGHTFALLOFF",!1)):this.lightFalloff===Tn.LIGHTFALLOFF_GLTF?(i.setValue("USEPHYSICALLIGHTFALLOFF",!1),i.setValue("USEGLTFLIGHTFALLOFF",!0)):(i.setValue("USEPHYSICALLIGHTFALLOFF",!0),i.setValue("USEGLTFLIGHTFALLOFF",!1));var o=this.alphaTestCutoff.toString();i.setValue("ALPHABLEND",this.useAlphaBlending,!0),i.setValue("ALPHAFROMALBEDO",!1,!0),i.setValue("ALPHATEST",this.useAlphaTest,!0),i.setValue("ALPHATESTVALUE",o.indexOf(".")<0?o+".":o,!0),i.setValue("OPACITYRGB",!1,!0),i.setValue("RADIANCEOVERALPHA",this.useRadianceOverAlpha,!0),i.setValue("SPECULAROVERALPHA",this.useSpecularOverAlpha,!0),i.setValue("SPECULARAA",this._scene.getEngine().getCaps().standardDerivatives&&this.enableSpecularAntiAliasing,!0),i.setValue("REALTIME_FILTERING",this.realTimeFiltering,!0);var a=e.getScene();if(a.getEngine()._features.needTypeSuffixInShaderConstants?i.setValue("NUM_SAMPLES",this.realTimeFilteringQuality+"u",!0):i.setValue("NUM_SAMPLES",""+this.realTimeFilteringQuality,!0),i.setValue("BRDF_V_HEIGHT_CORRELATED",!0),i.setValue("MS_BRDF_ENERGY_CONSERVATION",this.useEnergyConservation,!0),i.setValue("RADIANCEOCCLUSION",this.useRadianceOcclusion,!0),i.setValue("HORIZONOCCLUSION",this.useHorizonOcclusion,!0),i.setValue("UNLIT",this.unlit,!0),i.setValue("FORCENORMALFORWARD",this.forceNormalForward,!0),this._environmentBRDFTexture&&$e.ReflectionTextureEnabled?(i.setValue("ENVIRONMENTBRDF",!0),i.setValue("ENVIRONMENTBRDF_RGBD",this._environmentBRDFTexture.isRGBD,!0)):(i.setValue("ENVIRONMENTBRDF",!1),i.setValue("ENVIRONMENTBRDF_RGBD",!1)),i._areImageProcessingDirty&&n.imageProcessingConfiguration&&n.imageProcessingConfiguration.prepareDefines(i),i._areLightsDirty)if(this.light){var s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};(0,Re.lo)(a,e,this.light,this._lightId,i,!0,s),s.needRebuild&&i.rebuild()}else(0,Re.az)(a,e,i,!0,n.maxSimultaneousLights),i._needNormals=!0,(0,Re.VO)(a,i)},t.prototype.updateUniformsAndSamples=function(e,n,i,o){for(var a=0;a<n.maxSimultaneousLights&&i["LIGHT"+a];a++){var s=e.uniforms.indexOf("vLightData"+a)>=0;(0,Re.GD)(a,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+a],o,s)}},t.prototype.isReady=function(e,n,i){return!(this._environmentBRDFTexture&&!this._environmentBRDFTexture.isReady()||i._areImageProcessingDirty&&n.imageProcessingConfiguration&&!n.imageProcessingConfiguration.isReady())},t.prototype.bind=function(e,n,i){var o,a;if(i){var s=i.getScene();this.light?(0,Re.Kd)(this.light,this._lightId,s,e,!0):(0,Re.RL)(s,i,e,!0,n.maxSimultaneousLights),e.setTexture(this._environmentBrdfSamplerName,this._environmentBRDFTexture),e.setFloat2("vDebugMode",this.debugLimit,this.debugFactor);var l=this._scene.ambientColor;l&&e.setColor3("ambientFromScene",l);var c=s.useRightHandedSystem===(s._mirroredCameraPosition!=null);e.setFloat(this._invertNormalName,c?-1:1),e.setFloat4("vLightingIntensity",this.directIntensity,1,this.environmentIntensity*this._scene.environmentIntensity,this.specularIntensity);var u=(a=(o=this.indexOfRefraction.connectInputBlock)===null||o===void 0?void 0:o.value)!==null&&a!==void 0?a:1.5,d=Math.pow((u-1)/(u+1),2);this._metallicReflectanceColor.scaleToRef(d*this._metallicF0Factor,z.IG.Color3[0]);var h=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,z.IG.Color3[0],h),n.imageProcessingConfiguration&&n.imageProcessingConfiguration.bind(e)}},t.prototype._injectVertexCode=function(e){var n,i,o=this.worldPosition,a=this.worldNormal,s="//".concat(this.name),l=e.shaderLanguage===1;this.light?(this._lightId=(e.counters.lightCounter!==void 0?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",s,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",s,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var c="v_"+o.associatedVariableName;e._emitVaryingFromString(c,G.Vector4)&&(e.compilationString+=(l?"vertexOutputs.":"")+"".concat(c," = ").concat(o.associatedVariableName,`;
|
||
`));var u="v_"+a.associatedVariableName;e._emitVaryingFromString(u,G.Vector4)&&(e.compilationString+=(l?"vertexOutputs.":"")+"".concat(u," = ").concat(a.associatedVariableName,`;
|
||
`));var d=this.reflection.isConnected?(n=this.reflection.connectedPoint)===null||n===void 0?void 0:n.ownerBlock:null;d&&(d.viewConnectionPoint=this.view),e.compilationString+=(i=d?.handleVertexSide(e))!==null&&i!==void 0?i:"",e._emitVaryingFromString("vClipSpacePosition",G.Vector4,"defined(IGNORE) || DEBUGMODE > 0")&&(e._injectAtEnd+=`#if DEBUGMODE > 0
|
||
`,e._injectAtEnd+=(l?"vertexOutputs.":"")+"vClipSpacePosition = ".concat(l?"vertexOutputs.position":"gl_Position",`;
|
||
`),e._injectAtEnd+=`#endif
|
||
`),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",s,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:o.associatedVariableName}]}):(e.compilationString+="".concat(e._declareLocalVar("worldPos",G.Vector4)," = ").concat(o.associatedVariableName,`;
|
||
`),this.view.isConnected&&(e.compilationString+="".concat(e._declareLocalVar("view",G.Matrix)," = ").concat(this.view.associatedVariableName,`;
|
||
`)),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",s,{repeatKey:"maxSimultaneousLights"}))},t.prototype._getAlbedoOpacityCode=function(e){var n=e.shaderLanguage===1?`var albedoOpacityOut: albedoOpacityOutParams;
|
||
`:`albedoOpacityOutParams albedoOpacityOut;
|
||
`,i=this.baseColor.isConnected?this.baseColor.associatedVariableName:"vec3(1.)",o=this.opacity.isConnected?this.opacity.associatedVariableName:"1.";return n+`albedoOpacityOut = albedoOpacityBlock(
|
||
vec4`.concat(e.fSuffix,"(").concat(i,`, 1.)
|
||
#ifdef ALBEDO
|
||
,vec4`).concat(e.fSuffix,`(1.)
|
||
,vec2`).concat(e.fSuffix,`(1., 1.)
|
||
#endif
|
||
#ifdef OPACITY
|
||
,vec4`).concat(e.fSuffix,"(").concat(o,`)
|
||
,vec2`).concat(e.fSuffix,`(1., 1.)
|
||
#endif
|
||
);
|
||
|
||
`).concat(e._declareLocalVar("surfaceAlbedo",G.Vector3),` = albedoOpacityOut.surfaceAlbedo;
|
||
`).concat(e._declareLocalVar("alpha",G.Float),` = albedoOpacityOut.alpha;
|
||
`)},t.prototype._getAmbientOcclusionCode=function(e){var n=e.shaderLanguage===1?`var aoOut: ambientOcclusionOutParams;
|
||
`:`ambientOcclusionOutParams aoOut;
|
||
`,i=this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:"1.";return n+`aoOut = ambientOcclusionBlock(
|
||
#ifdef AMBIENT
|
||
vec3`.concat(e.fSuffix,"(").concat(i,`),
|
||
vec4`).concat(e.fSuffix,`(0., 1.0, 1.0, 0.)
|
||
#endif
|
||
);
|
||
`)},t.prototype._getReflectivityCode=function(e){var n=e.shaderLanguage===1,i=n?`var reflectivityOut: reflectivityOutParams;
|
||
`:`reflectivityOutParams reflectivityOut;
|
||
`;return this._vMetallicReflectanceFactorsName=e._getFreeVariableName("vMetallicReflectanceFactors"),e._emitUniformFromString(this._vMetallicReflectanceFactorsName,G.Vector4),i+"".concat(e._declareLocalVar("baseColor",G.Vector3),` = surfaceAlbedo;
|
||
|
||
reflectivityOut = reflectivityBlock(
|
||
vec4`).concat(e.fSuffix,"(").concat(this.metallic.associatedVariableName,", ").concat(this.roughness.associatedVariableName,`, 0., 0.)
|
||
#ifdef METALLICWORKFLOW
|
||
, surfaceAlbedo
|
||
, `).concat((n?"uniforms.":"")+this._vMetallicReflectanceFactorsName,`
|
||
#endif
|
||
#ifdef REFLECTIVITY
|
||
, vec3`).concat(e.fSuffix,"(0., 0., ").concat("1.",`)
|
||
, vec4`).concat(e.fSuffix,`(1.)
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
, aoOut.ambientOcclusionColor
|
||
#endif
|
||
#ifdef MICROSURFACEMAP
|
||
, microSurfaceTexel <== not handled!
|
||
#endif
|
||
);
|
||
|
||
`).concat(e._declareLocalVar("microSurface",G.Float),` = reflectivityOut.microSurface;
|
||
`).concat(e._declareLocalVar("roughness",G.Float),` = reflectivityOut.roughness;
|
||
|
||
#ifdef METALLICWORKFLOW
|
||
surfaceAlbedo = reflectivityOut.surfaceAlbedo;
|
||
#endif
|
||
#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
|
||
aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;
|
||
#endif
|
||
`)},t.prototype._buildBlock=function(e){var n,i,o,a,s,l,c,u,d,h,p,m,v,b,E,C,T,f,g,S,y,x,R,I,M,D,B,F,X,$,Q,ie,q,ee,te,ce,fe,de,Te,ue,U;r.prototype._buildBlock.call(this,e),this._scene=e.sharedData.scene;var N=e.shaderLanguage===1;this._environmentBRDFTexture||(this._environmentBRDFTexture=qa(this._scene));var w=this.reflection.isConnected?(n=this.reflection.connectedPoint)===null||n===void 0?void 0:n.ownerBlock:null;if(w&&(w.worldPositionConnectionPoint=this.worldPosition,w.cameraPositionConnectionPoint=this.cameraPosition,w.worldNormalConnectionPoint=this.worldNormal,w.viewConnectionPoint=this.view),e.target!==_e.Fragment)return this._injectVertexCode(e),this;e.sharedData.forcedBindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this),e.sharedData.blockingBlocks.push(this),this.generateOnlyFragmentCode&&e.sharedData.dynamicUniformBlocks.push(this);var k="//".concat(this.name),J=this.perturbedNormal,le=this.worldPosition.associatedVariableName,be=this.worldNormal.associatedVariableName;this.generateOnlyFragmentCode?(le=e._getFreeVariableName("globalWorldPos"),e.compilationString+="".concat(le," = ").concat(this.worldPosition.associatedVariableName,`.xyz;
|
||
`),be=e._getFreeVariableName("globalWorldNormal"),e.compilationString+="".concat(be," = ").concat(this.worldNormal.associatedVariableName,`.xyz;
|
||
`),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",k,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"worldPos,".concat(this.worldPosition.associatedVariableName):void 0}),e.compilationString+=`#if DEBUGMODE > 0
|
||
`,e.compilationString+="".concat(e._declareLocalVar("vClipSpacePosition",G.Vector4)," = vec4").concat(e.fSuffix,"((vec2").concat(e.fSuffix,"(").concat(N?"fragmentInputs.position":"gl_FragCoord.xy",") / vec2").concat(e.fSuffix,`(1.0)) * 2.0 - 1.0, 0.0, 1.0);
|
||
`),e.compilationString+=`#endif
|
||
`):(le=(N?"input.":"")+"v_"+le,be=(N?"input.":"")+"v_"+be),this._environmentBrdfSamplerName=e._getFreeVariableName("environmentBrdfSampler"),e._emit2DSampler(this._environmentBrdfSamplerName),e.sharedData.hints.needAlphaBlending=e.sharedData.hints.needAlphaBlending||this.useAlphaBlending,e.sharedData.hints.needAlphaTesting=e.sharedData.hints.needAlphaTesting||this.useAlphaTest,e._emitExtension("lod","#extension GL_EXT_shader_texture_lod : enable","defined(LODBASEDMICROSFURACE)"),e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),e._emitUniformFromString("vDebugMode",G.Vector2,"defined(IGNORE) || DEBUGMODE > 0"),e._emitUniformFromString("ambientFromScene",G.Vector3),e.uniforms.push("exposureLinear"),e.uniforms.push("contrast"),e.uniforms.push("vInverseScreenSize"),e.uniforms.push("vignetteSettings1"),e.uniforms.push("vignetteSettings2"),e.uniforms.push("vCameraColorCurveNegative"),e.uniforms.push("vCameraColorCurveNeutral"),e.uniforms.push("vCameraColorCurvePositive"),e.uniforms.push("txColorTransform"),e.uniforms.push("colorTransformSettings"),e.uniforms.push("ditherIntensity"),this.light?e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",k,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",k,{repeatKey:"maxSimultaneousLights",substitutionVars:this.generateOnlyFragmentCode?"varying,":void 0}),e._emitFunctionFromInclude("helperFunctions",k),e._emitFunctionFromInclude("importanceSampling",k),e._emitFunctionFromInclude("pbrHelperFunctions",k),e._emitFunctionFromInclude("imageProcessingDeclaration",k),e._emitFunctionFromInclude("imageProcessingFunctions",k),e._emitFunctionFromInclude("shadowsFragmentFunctions",k),e._emitFunctionFromInclude("pbrDirectLightingSetupFunctions",k),e._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions",k),e._emitFunctionFromInclude("pbrBRDFFunctions",k,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:(i=w?._defineSkyboxName)!==null&&i!==void 0?i:"REFLECTIONMAP_SKYBOX"}]}),e._emitFunctionFromInclude("hdrFilteringFunctions",k),e._emitFunctionFromInclude("pbrDirectLightingFunctions",k),e._emitFunctionFromInclude("pbrIBLFunctions",k),e._emitFunctionFromInclude("pbrBlockAlbedoOpacity",k),e._emitFunctionFromInclude("pbrBlockReflectivity",k),e._emitFunctionFromInclude("pbrBlockAmbientOcclusion",k),e._emitFunctionFromInclude("pbrBlockAlphaFresnel",k),e._emitFunctionFromInclude("pbrBlockAnisotropic",k),e._emitUniformFromString("vLightingIntensity",G.Vector4),w?.generateOnlyFragmentCode&&(e.compilationString+=w.handleVertexSide(e)),this._vNormalWName=e._getFreeVariableName("vNormalW"),e.compilationString+="".concat(e._declareLocalVar(this._vNormalWName,G.Vector4)," = normalize(").concat(be,`);
|
||
`),e._registerTempVariable("viewDirectionW")&&(e.compilationString+="".concat(e._declareLocalVar("viewDirectionW",G.Vector3)," = normalize(").concat(this.cameraPosition.associatedVariableName," - ").concat(le,`.xyz);
|
||
`)),e.compilationString+="".concat(e._declareLocalVar("geometricNormalW",G.Vector3)," = ").concat(this._vNormalWName,`.xyz;
|
||
`),e.compilationString+="".concat(e._declareLocalVar("normalW",G.Vector3)," = ").concat(J.isConnected?"normalize("+J.associatedVariableName+".xyz)":"geometricNormalW",`;
|
||
`),this._invertNormalName=e._getFreeVariableName("invertNormal"),e._emitUniformFromString(this._invertNormalName,G.Float),e.compilationString+=e._emitCodeFromInclude("pbrBlockNormalFinal",k,{replaceStrings:[{search:/vPositionW/g,replace:le+".xyz"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),e.compilationString+=this._getAlbedoOpacityCode(e),e.compilationString+=e._emitCodeFromInclude("depthPrePass",k),e.compilationString+=this._getAmbientOcclusionCode(e),e.compilationString+=e._emitCodeFromInclude("pbrBlockLightmapInit",k),e.compilationString+=`#ifdef UNLIT
|
||
`.concat(e._declareLocalVar("diffuseBase",G.Vector3)," = vec3").concat(e.fSuffix,`(1., 1., 1.);
|
||
#else
|
||
`),e.compilationString+=this._getReflectivityCode(e),e.compilationString+=e._emitCodeFromInclude("pbrBlockGeometryInfo",k,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:(o=w?._defineSkyboxName)!==null&&o!==void 0?o:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:(a=w?._define3DName)!==null&&a!==void 0?a:"REFLECTIONMAP_3D"}]});var ve=this.anisotropy.isConnected?(s=this.anisotropy.connectedPoint)===null||s===void 0?void 0:s.ownerBlock:null;ve&&(ve.worldPositionConnectionPoint=this.worldPosition,ve.worldNormalConnectionPoint=this.worldNormal,e.compilationString+=ve.getCode(e,!this.perturbedNormal.isConnected)),w&&w.hasTexture&&(e.compilationString+=w.getCode(e,ve?"anisotropicOut.anisotropicNormal":"normalW")),e._emitFunctionFromInclude("pbrBlockReflection",k,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:(l=w?._define3DName)!==null&&l!==void 0?l:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(c=w?._defineOppositeZ)!==null&&c!==void 0?c:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:(u=w?._defineProjectionName)!==null&&u!==void 0?u:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:(d=w?._defineSkyboxName)!==null&&d!==void 0?d:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:(h=w?._defineLODReflectionAlpha)!==null&&h!==void 0?h:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:(p=w?._defineLinearSpecularReflection)!==null&&p!==void 0?p:"LINEARSPECULARREFLECTION"},{search:/vReflectionFilteringInfo/g,replace:(m=w?._vReflectionFilteringInfoName)!==null&&m!==void 0?m:"vReflectionFilteringInfo"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockReflectance0",k,{replaceStrings:[{search:/metallicReflectanceFactors/g,replace:(N?"uniforms.":"")+this._vMetallicReflectanceFactorsName}]});var ye=this.sheen.isConnected?(v=this.sheen.connectedPoint)===null||v===void 0?void 0:v.ownerBlock:null;ye&&(e.compilationString+=ye.getCode(w,e)),e._emitFunctionFromInclude("pbrBlockSheen",k,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:(b=w?._define3DName)!==null&&b!==void 0?b:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_SKYBOX/g,replace:(E=w?._defineSkyboxName)!==null&&E!==void 0?E:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:(C=w?._defineLODReflectionAlpha)!==null&&C!==void 0?C:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:(T=w?._defineLinearSpecularReflection)!==null&&T!==void 0?T:"LINEARSPECULARREFLECTION"}]});var Me=this.iridescence.isConnected?(f=this.iridescence.connectedPoint)===null||f===void 0?void 0:f.ownerBlock:null;e.compilationString+=jy.GetCode(Me,e),e._emitFunctionFromInclude("pbrBlockIridescence",k,{replaceStrings:[]});var we=this.clearcoat.isConnected?(g=this.clearcoat.connectedPoint)===null||g===void 0?void 0:g.ownerBlock:null,He=!this.perturbedNormal.isConnected&&!this.anisotropy.isConnected,Ke=this.perturbedNormal.isConnected&&((y=((S=this.perturbedNormal.connectedPoint)===null||S===void 0?void 0:S.ownerBlock).worldTangent)===null||y===void 0?void 0:y.isConnected),Qe=this.anisotropy.isConnected&&((x=this.anisotropy.connectedPoint)===null||x===void 0?void 0:x.ownerBlock).worldTangent.isConnected,Je=Ke||!this.perturbedNormal.isConnected&&Qe;e.compilationString+=Al.GetCode(e,we,w,le,He,Je,be),He&&(Je=(R=we?.worldTangent.isConnected)!==null&&R!==void 0&&R),e._emitFunctionFromInclude("pbrBlockClearcoat",k,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:(I=w?._define3DName)!==null&&I!==void 0?I:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(M=w?._defineOppositeZ)!==null&&M!==void 0?M:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:(D=w?._defineProjectionName)!==null&&D!==void 0?D:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:(B=w?._defineSkyboxName)!==null&&B!==void 0?B:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:(F=w?._defineLODReflectionAlpha)!==null&&F!==void 0?F:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:(X=w?._defineLinearSpecularReflection)!==null&&X!==void 0?X:"LINEARSPECULARREFLECTION"},{search:/defined\(TANGENT\)/g,replace:Je?"defined(TANGENT)":"defined(IGNORE)"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockReflectance",k,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:($=w?._defineSkyboxName)!==null&&$!==void 0?$:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:(Q=w?._define3DName)!==null&&Q!==void 0?Q:"REFLECTIONMAP_3D"}]});var ht=this.subsurface.isConnected?(ie=this.subsurface.connectedPoint)===null||ie===void 0?void 0:ie.ownerBlock:null,mt=this.subsurface.isConnected?(ee=((q=this.subsurface.connectedPoint)===null||q===void 0?void 0:q.ownerBlock).refraction.connectedPoint)===null||ee===void 0?void 0:ee.ownerBlock:null;mt&&(mt.viewConnectionPoint=this.view,mt.indexOfRefractionConnectionPoint=this.indexOfRefraction),e.compilationString+=Cl.GetCode(e,ht,w,le),e._emitFunctionFromInclude("pbrBlockSubSurface",k,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:(te=w?._define3DName)!==null&&te!==void 0?te:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:(ce=w?._defineOppositeZ)!==null&&ce!==void 0?ce:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:(fe=w?._defineProjectionName)!==null&&fe!==void 0?fe:"REFLECTIONMAP_PROJECTION"},{search:/SS_REFRACTIONMAP_3D/g,replace:(de=mt?._define3DName)!==null&&de!==void 0?de:"SS_REFRACTIONMAP_3D"},{search:/SS_LODINREFRACTIONALPHA/g,replace:(Te=mt?._defineLODRefractionAlpha)!==null&&Te!==void 0?Te:"SS_LODINREFRACTIONALPHA"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:(ue=mt?._defineLinearSpecularRefraction)!==null&&ue!==void 0?ue:"SS_LINEARSPECULARREFRACTION"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:(U=mt?._defineOppositeZ)!==null&&U!==void 0?U:"SS_REFRACTIONMAP_OPPOSITEZ"}]}),e.compilationString+=e._emitCodeFromInclude("pbrBlockDirectLighting",k),this.light?e.compilationString+=e._emitCodeFromInclude("lightFragment",k,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:new RegExp("".concat(N?"fragmentInputs.":"","vPositionW"),"g"),replace:le+".xyz"}]}):e.compilationString+=e._emitCodeFromInclude("lightFragment",k,{repeatKey:"maxSimultaneousLights",substitutionVars:"".concat(N?"fragmentInputs.":"","vPositionW,").concat(le,".xyz")}),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalLitComponents",k),e.compilationString+=`#endif
|
||
`;var yt=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:"vec3".concat(e.fSuffix,"(0., 0., 0.)"),zt=Tn.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();zt.indexOf(".")===-1&&(zt+=".");var $t=[{search:/vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,replace:""},{search:new RegExp("".concat(N?"uniforms.":"","vAmbientColor"),"g"),replace:yt+" * ".concat(N?"uniforms.":"","ambientFromScene")},{search:new RegExp("".concat(N?"uniforms.":"","vAmbientInfos.w"),"g"),replace:zt}];N&&($t[0]={search:/var finalEmissive[\s\S]*?finalEmissive\*=uniforms.vLightingIntensity\.y;/g,replace:""}),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalUnlitComponents",k,{replaceStrings:$t}),e.compilationString+=e._emitCodeFromInclude("pbrBlockFinalColorComposition",k,{replaceStrings:[{search:/finalEmissive/g,replace:"vec3".concat(e.fSuffix,"(0.)")}]}),$t=N?[{search:/mesh.visibility/g,replace:"1."}]:[{search:/visibility/g,replace:"1."}],e.compilationString+=e._emitCodeFromInclude("pbrBlockImageProcessing",k,{replaceStrings:$t});var St=N?"fragmentOutputs.color":"gl_FragColor";$t=[{search:new RegExp("".concat(N?"fragmentInputs.":"","vNormalW"),"g"),replace:this._vNormalWName},{search:new RegExp("".concat(N?"fragmentInputs.":"","vPositionW"),"g"),replace:le},{search:/albedoTexture\.rgb;/g,replace:"vec3".concat(e.fSuffix,`(1.);
|
||
`).concat(St,".rgb = toGammaSpace(").concat(St,`.rgb);
|
||
`)}],e.compilationString+=e._emitCodeFromInclude("pbrDebug",k,{replaceStrings:$t});for(var Ot=0,Et=this._outputs;Ot<Et.length;Ot++){var Vt=Et[Ot];if(Vt.hasEndpoints){var ln=lN[Vt.name];if(ln){var Yt=ln[0],Un=ln[1];Un&&(e.compilationString+="#if ".concat(Un,`
|
||
`)),e.compilationString+="".concat(e._declareOutput(Vt)," = ").concat(Yt,`;
|
||
`),Un&&(e.compilationString+=`#else
|
||
`,e.compilationString+="".concat(e._declareOutput(Vt)," = vec3").concat(e.fSuffix,`(0.);
|
||
`),e.compilationString+=`#endif
|
||
`)}else O.V.Error("There's no remapping for the ".concat(Vt.name," end point! No code generated"))}}return this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+="".concat(this._codeVariableName,".lightFalloff = ").concat(this.lightFalloff,`;
|
||
`),e+="".concat(this._codeVariableName,".useAlphaTest = ").concat(this.useAlphaTest,`;
|
||
`),e+="".concat(this._codeVariableName,".alphaTestCutoff = ").concat(this.alphaTestCutoff,`;
|
||
`),e+="".concat(this._codeVariableName,".useAlphaBlending = ").concat(this.useAlphaBlending,`;
|
||
`),e+="".concat(this._codeVariableName,".useRadianceOverAlpha = ").concat(this.useRadianceOverAlpha,`;
|
||
`),e+="".concat(this._codeVariableName,".useSpecularOverAlpha = ").concat(this.useSpecularOverAlpha,`;
|
||
`),e+="".concat(this._codeVariableName,".enableSpecularAntiAliasing = ").concat(this.enableSpecularAntiAliasing,`;
|
||
`),e+="".concat(this._codeVariableName,".realTimeFiltering = ").concat(this.realTimeFiltering,`;
|
||
`),e+="".concat(this._codeVariableName,".realTimeFilteringQuality = ").concat(this.realTimeFilteringQuality,`;
|
||
`),e+="".concat(this._codeVariableName,".useEnergyConservation = ").concat(this.useEnergyConservation,`;
|
||
`),e+="".concat(this._codeVariableName,".useRadianceOcclusion = ").concat(this.useRadianceOcclusion,`;
|
||
`),e+="".concat(this._codeVariableName,".useHorizonOcclusion = ").concat(this.useHorizonOcclusion,`;
|
||
`),e+="".concat(this._codeVariableName,".unlit = ").concat(this.unlit,`;
|
||
`),e+="".concat(this._codeVariableName,".forceNormalForward = ").concat(this.forceNormalForward,`;
|
||
`),e+="".concat(this._codeVariableName,".debugMode = ").concat(this.debugMode,`;
|
||
`),(e+="".concat(this._codeVariableName,".debugLimit = ").concat(this.debugLimit,`;
|
||
`))+"".concat(this._codeVariableName,".debugFactor = ").concat(this.debugFactor,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return this.light&&(e.lightId=this.light.id),e.lightFalloff=this.lightFalloff,e.useAlphaTest=this.useAlphaTest,e.alphaTestCutoff=this.alphaTestCutoff,e.useAlphaBlending=this.useAlphaBlending,e.useRadianceOverAlpha=this.useRadianceOverAlpha,e.useSpecularOverAlpha=this.useSpecularOverAlpha,e.enableSpecularAntiAliasing=this.enableSpecularAntiAliasing,e.realTimeFiltering=this.realTimeFiltering,e.realTimeFilteringQuality=this.realTimeFilteringQuality,e.useEnergyConservation=this.useEnergyConservation,e.useRadianceOcclusion=this.useRadianceOcclusion,e.useHorizonOcclusion=this.useHorizonOcclusion,e.unlit=this.unlit,e.forceNormalForward=this.forceNormalForward,e.debugMode=this.debugMode,e.debugLimit=this.debugLimit,e.debugFactor=this.debugFactor,e.generateOnlyFragmentCode=this.generateOnlyFragmentCode,e},t.prototype._deserialize=function(e,n,i){var o,a;r.prototype._deserialize.call(this,e,n,i),e.lightId&&(this.light=n.getLightById(e.lightId)),this.lightFalloff=(o=e.lightFalloff)!==null&&o!==void 0?o:0,this.useAlphaTest=e.useAlphaTest,this.alphaTestCutoff=e.alphaTestCutoff,this.useAlphaBlending=e.useAlphaBlending,this.useRadianceOverAlpha=e.useRadianceOverAlpha,this.useSpecularOverAlpha=e.useSpecularOverAlpha,this.enableSpecularAntiAliasing=e.enableSpecularAntiAliasing,this.realTimeFiltering=!!e.realTimeFiltering,this.realTimeFilteringQuality=(a=e.realTimeFilteringQuality)!==null&&a!==void 0?a:P.Y.TEXTURE_FILTERING_QUALITY_LOW,this.useEnergyConservation=e.useEnergyConservation,this.useRadianceOcclusion=e.useRadianceOcclusion,this.useHorizonOcclusion=e.useHorizonOcclusion,this.unlit=e.unlit,this.forceNormalForward=!!e.forceNormalForward,this.debugMode=e.debugMode,this.debugLimit=e.debugLimit,this.debugFactor=e.debugFactor,this.generateOnlyFragmentCode=!!e.generateOnlyFragmentCode,this._setTarget()},(0,A.Cg)([dt("Direct lights",1,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"directIntensity",void 0),(0,A.Cg)([dt("Environment lights",1,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"environmentIntensity",void 0),(0,A.Cg)([dt("Specular highlights",1,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"specularIntensity",void 0),(0,A.Cg)([dt("Light falloff",4,"LIGHTING & COLORS",{notifiers:{update:!0},options:[{label:"Physical",value:Tn.LIGHTFALLOFF_PHYSICAL},{label:"GLTF",value:Tn.LIGHTFALLOFF_GLTF},{label:"Standard",value:Tn.LIGHTFALLOFF_STANDARD}]})],t.prototype,"lightFalloff",void 0),(0,A.Cg)([dt("Alpha Testing",0,"OPACITY")],t.prototype,"useAlphaTest",void 0),(0,A.Cg)([dt("Alpha CutOff",1,"OPACITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"alphaTestCutoff",void 0),(0,A.Cg)([dt("Alpha blending",0,"OPACITY")],t.prototype,"useAlphaBlending",void 0),(0,A.Cg)([dt("Radiance over alpha",0,"RENDERING",{notifiers:{update:!0}})],t.prototype,"useRadianceOverAlpha",void 0),(0,A.Cg)([dt("Specular over alpha",0,"RENDERING",{notifiers:{update:!0}})],t.prototype,"useSpecularOverAlpha",void 0),(0,A.Cg)([dt("Specular anti-aliasing",0,"RENDERING",{notifiers:{update:!0}})],t.prototype,"enableSpecularAntiAliasing",void 0),(0,A.Cg)([dt("Realtime filtering",0,"RENDERING",{notifiers:{update:!0}})],t.prototype,"realTimeFiltering",void 0),(0,A.Cg)([dt("Realtime filtering quality",4,"RENDERING",{notifiers:{update:!0},options:[{label:"Low",value:P.Y.TEXTURE_FILTERING_QUALITY_LOW},{label:"Medium",value:P.Y.TEXTURE_FILTERING_QUALITY_MEDIUM},{label:"High",value:P.Y.TEXTURE_FILTERING_QUALITY_HIGH}]})],t.prototype,"realTimeFilteringQuality",void 0),(0,A.Cg)([dt("Energy Conservation",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useEnergyConservation",void 0),(0,A.Cg)([dt("Radiance occlusion",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useRadianceOcclusion",void 0),(0,A.Cg)([dt("Horizon occlusion",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useHorizonOcclusion",void 0),(0,A.Cg)([dt("Unlit",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"unlit",void 0),(0,A.Cg)([dt("Force normal forward",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"forceNormalForward",void 0),(0,A.Cg)([dt("Generate only fragment code",0,"ADVANCED",{notifiers:{rebuild:!0,update:!0,onValidation:t._OnGenerateOnlyFragmentCodeChanged}})],t.prototype,"generateOnlyFragmentCode",void 0),(0,A.Cg)([dt("Debug mode",4,"DEBUG",{notifiers:{update:!0},options:[{label:"None",value:0},{label:"Normalized position",value:1},{label:"Normals",value:2},{label:"Tangents",value:3},{label:"Bitangents",value:4},{label:"Bump Normals",value:5},{label:"ClearCoat Normals",value:8},{label:"ClearCoat Tangents",value:9},{label:"ClearCoat Bitangents",value:10},{label:"Anisotropic Normals",value:11},{label:"Anisotropic Tangents",value:12},{label:"Anisotropic Bitangents",value:13},{label:"Env Refraction",value:40},{label:"Env Reflection",value:41},{label:"Env Clear Coat",value:42},{label:"Direct Diffuse",value:50},{label:"Direct Specular",value:51},{label:"Direct Clear Coat",value:52},{label:"Direct Sheen",value:53},{label:"Env Irradiance",value:54},{label:"Surface Albedo",value:60},{label:"Reflectance 0",value:61},{label:"Metallic",value:62},{label:"Metallic F0",value:71},{label:"Roughness",value:63},{label:"AlphaG",value:64},{label:"NdotV",value:65},{label:"ClearCoat Color",value:66},{label:"ClearCoat Roughness",value:67},{label:"ClearCoat NdotV",value:68},{label:"Transmittance",value:69},{label:"Refraction Transmittance",value:70},{label:"SEO",value:80},{label:"EHO",value:81},{label:"Energy Factor",value:82},{label:"Specular Reflectance",value:83},{label:"Clear Coat Reflectance",value:84},{label:"Sheen Reflectance",value:85},{label:"Luminance Over Alpha",value:86},{label:"Alpha",value:87},{label:"Albedo color",value:88},{label:"Ambient occlusion color",value:89}]})],t.prototype,"debugMode",void 0),(0,A.Cg)([dt("Split position",1,"DEBUG",{min:-1,max:1,notifiers:{update:!0}})],t.prototype,"debugLimit",void 0),(0,A.Cg)([dt("Output factor",1,"DEBUG",{min:0,max:5,notifiers:{update:!0}})],t.prototype,"debugFactor",void 0),t}(ut);(0,j.Y5)("BABYLON.PBRMetallicRoughnessBlock",qy);var Ky=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("left",G.AutoDetect),n.registerInput("right",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[1].acceptedConnectionPointTypes.push(G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ModBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0];return e.shaderLanguage===0?e.compilationString+=e._declareOutput(n)+" = mod(".concat(this.left.associatedVariableName,", ").concat(this.right.associatedVariableName,`);
|
||
`):e.compilationString+=e._declareOutput(n)+" = (".concat(this.left.associatedVariableName," % ").concat(this.right.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ModBlock",Ky);var Zi,Zy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("row0",G.Vector4),n.registerInput("row1",G.Vector4),n.registerInput("row2",G.Vector4),n.registerInput("row3",G.Vector4),n.registerOutput("output",G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MatrixBuilder"},Object.defineProperty(t.prototype,"row0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"row1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"row2",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"row3",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.row0.isConnected){var e=new Mt("row0");e.value=new _.IU(1,0,0,0),e.output.connectTo(this.row0)}if(!this.row1.isConnected){var n=new Mt("row1");n.value=new _.IU(0,1,0,0),n.output.connectTo(this.row1)}if(!this.row2.isConnected){var i=new Mt("row2");i.value=new _.IU(0,0,1,0),i.output.connectTo(this.row2)}if(!this.row3.isConnected){var o=new Mt("row3");o.value=new _.IU(0,0,0,1),o.output.connectTo(this.row3)}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this.row0,o=this.row1,a=this.row2,s=this.row3,l=e.shaderLanguage===1?"mat4x4f":"mat4";return e.compilationString+=e._declareOutput(n)+" = ".concat(l,"(").concat(i.associatedVariableName,", ").concat(o.associatedVariableName,", ").concat(a.associatedVariableName,", ").concat(s.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.MatrixBuilder",Zy),function(r){r[r.Equal=0]="Equal",r[r.NotEqual=1]="NotEqual",r[r.LessThan=2]="LessThan",r[r.GreaterThan=3]="GreaterThan",r[r.LessOrEqual=4]="LessOrEqual",r[r.GreaterOrEqual=5]="GreaterOrEqual",r[r.Xor=6]="Xor",r[r.Or=7]="Or",r[r.And=8]="And"}(Zi||(Zi={}));var Qy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.condition=Zi.LessThan,n.registerInput("a",G.Float),n.registerInput("b",G.Float),n.registerInput("true",G.AutoDetect,!0),n.registerInput("false",G.AutoDetect,!0),n.registerOutput("output",G.BasedOnInput),n._linkConnectionTypes(2,3),n._outputs[0]._typeConnectionSource=n._inputs[2],n._outputs[0]._defaultConnectionPointType=G.Float,n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ConditionalBlock"},Object.defineProperty(t.prototype,"a",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"true",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"false",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this.true.isConnected?this.true.associatedVariableName:"1.0",o=this.false.isConnected?this.false.associatedVariableName:"0.0";switch(this.condition){case Zi.Equal:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"".concat(this.a.associatedVariableName," == ").concat(this.b.associatedVariableName)),`;
|
||
`);break;case Zi.NotEqual:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"".concat(this.a.associatedVariableName," != ").concat(this.b.associatedVariableName)),`;
|
||
`);break;case Zi.LessThan:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"".concat(this.a.associatedVariableName," < ").concat(this.b.associatedVariableName)),`;
|
||
`);break;case Zi.LessOrEqual:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"".concat(this.a.associatedVariableName," <= ").concat(this.b.associatedVariableName)),`;
|
||
`);break;case Zi.GreaterThan:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"".concat(this.a.associatedVariableName," > ").concat(this.b.associatedVariableName)),`;
|
||
`);break;case Zi.GreaterOrEqual:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"".concat(this.a.associatedVariableName," >= ").concat(this.b.associatedVariableName)),`;
|
||
`);break;case Zi.Xor:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"(((".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,") % 2.0) > 0.0)")),`;
|
||
`);break;case Zi.Or:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"(min(".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,", 1.0) > 0.0)")),`;
|
||
`);break;case Zi.And:e.compilationString+=e._declareOutput(n)+" = ".concat(e._generateTernary(i,o,"(".concat(this.a.associatedVariableName," * ").concat(this.b.associatedVariableName," > 0.0)")),`;
|
||
`)}return this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.condition=this.condition,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.condition=e.condition},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".condition = BABYLON.ConditionalBlockConditions.").concat(Zi[this.condition],`;
|
||
`)},t}(ut);(0,j.Y5)("BABYLON.ConditionalBlock",Qy);var Jy=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.octaves=6,n.registerInput("seed",G.AutoDetect),n.registerInput("chaos",G.AutoDetect,!0),n.registerInput("offsetX",G.Float,!0),n.registerInput("offsetY",G.Float,!0),n.registerInput("offsetZ",G.Float,!0),n.registerOutput("output",G.Float),n._inputs[0].acceptedConnectionPointTypes.push(G.Vector2),n._inputs[0].acceptedConnectionPointTypes.push(G.Vector3),n._linkConnectionTypes(0,1),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"CloudBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chaos",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetX",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetY",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetZ",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n,i,o;if(r.prototype._buildBlock.call(this,e),this.seed.isConnected&&this._outputs[0].hasEndpoints){var a=`
|
||
|
||
float cloudRandom(float p) {
|
||
float temp = fract(p * 0.011);
|
||
temp *= temp + 7.5;
|
||
temp *= temp + temp;
|
||
return fract(temp);
|
||
}
|
||
|
||
// Based on Morgan McGuire @morgan3d
|
||
// https://www.shadertoy.com/view/4dS3Wd
|
||
float cloudNoise2(vec2 x, vec2 chaos) {
|
||
vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);
|
||
|
||
vec2 i = floor(x);
|
||
vec2 f = fract(x);
|
||
|
||
float n = dot(i, step);
|
||
|
||
vec2 u = f * f * (3.0 - 2.0 * f);
|
||
return mix(
|
||
mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),
|
||
mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),
|
||
u.y
|
||
);
|
||
}
|
||
|
||
float cloudNoise3(vec3 x, vec3 chaos) {
|
||
vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);
|
||
|
||
vec3 i = floor(x);
|
||
vec3 f = fract(x);
|
||
|
||
float n = dot(i, step);
|
||
|
||
vec3 u = f * f * (3.0 - 2.0 * f);
|
||
return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),
|
||
mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
|
||
mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),
|
||
mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
|
||
}`,s=`
|
||
float fbm2(vec2 st, vec2 chaos) {
|
||
// Initial values
|
||
float value = 0.0;
|
||
float amplitude = .5;
|
||
float frequency = 0.;
|
||
|
||
// Loop of octaves
|
||
vec2 tempST = st;
|
||
for (int i = 0; i < OCTAVES; i++) {
|
||
value += amplitude * cloudNoise2(tempST, chaos);
|
||
tempST *= 2.0;
|
||
amplitude *= 0.5;
|
||
}
|
||
return value;
|
||
}
|
||
|
||
float fbm3(vec3 x, vec3 chaos) {
|
||
// Initial values
|
||
float value = 0.0;
|
||
float amplitude = 0.5;
|
||
vec3 tempX = x;
|
||
for (int i = 0; i < OCTAVES; i++) {
|
||
value += amplitude * cloudNoise3(tempX, chaos);
|
||
tempX = tempX * 2.0;
|
||
amplitude *= 0.5;
|
||
}
|
||
return value;
|
||
}`;e.shaderLanguage===1&&(a=e._babylonSLtoWGSL(a),s=e._babylonSLtoWGSL(s));var l="fbm".concat(this.octaves);e._emitFunction("CloudBlockCode",a,"// CloudBlockCode"),e._emitFunction("CloudBlockCodeFBM"+this.octaves,s.replace(/fbm/gi,l).replace(/OCTAVES/gi,(0|this.octaves).toString()),"// CloudBlockCode FBM");var c=e._getFreeVariableName("st"),u=((n=this.seed.connectedPoint)===null||n===void 0?void 0:n.type)||G.Vector3;e.compilationString+="".concat(e._declareLocalVar(c,u)," = ").concat(this.seed.associatedVariableName,`;
|
||
`),this.offsetX.isConnected&&(e.compilationString+="".concat(c,".x += 0.1 * ").concat(this.offsetX.associatedVariableName,`;
|
||
`)),this.offsetY.isConnected&&(e.compilationString+="".concat(c,".y += 0.1 * ").concat(this.offsetY.associatedVariableName,`;
|
||
`)),this.offsetZ.isConnected&&u===G.Vector3&&(e.compilationString+="".concat(c,".z += 0.1 * ").concat(this.offsetZ.associatedVariableName,`;
|
||
`));var d="";if(this.chaos.isConnected)d=this.chaos.associatedVariableName;else{var h=e.fSuffix;d=((i=this.seed.connectedPoint)===null||i===void 0?void 0:i.type)===G.Vector2?"vec2".concat(h,"(0., 0.)"):"vec3".concat(h,"(0., 0., 0.)")}return e.compilationString+=e._declareOutput(this._outputs[0])+" = ".concat(l).concat(((o=this.seed.connectedPoint)===null||o===void 0?void 0:o.type)===G.Vector2?"2":"3","(").concat(c,", ").concat(d,`);
|
||
`),this}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".octaves = ").concat(this.octaves,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.octaves=this.octaves,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.octaves=e.octaves},(0,A.Cg)([dt("Octaves",2)],t.prototype,"octaves",void 0),t}(ut);(0,j.Y5)("BABYLON.CloudBlock",Jy);var $y=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("seed",G.Vector2),n.registerInput("offset",G.Float),n.registerInput("density",G.Float),n.registerOutput("output",G.Float),n.registerOutput("cells",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VoronoiNoiseBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offset",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"density",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cells",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){if(r.prototype._buildBlock.call(this,e),this.seed.isConnected){var n=`vec2 voronoiRandom(vec2 p){
|
||
p = vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)));
|
||
return fract(sin(p)*18.5453);
|
||
}
|
||
`;e.shaderLanguage===1&&(n=e._babylonSLtoWGSL(n)),e._emitFunction("voronoiRandom",n,"// Voronoi random generator"),n=`void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){
|
||
vec2 n = floor(seed * density);
|
||
vec2 f = fract(seed * density);
|
||
vec3 m = vec3( 8.0 );
|
||
for( int j=-1; j<=1; j++ ){
|
||
for( int i=-1; i<=1; i++ ){
|
||
vec2 g = vec2( float(i), float(j) );
|
||
vec2 o = voronoiRandom( n + g);
|
||
vec2 r = g - f + (0.5+0.5*sin(offset+6.2831*o));
|
||
float d = dot( r, r );
|
||
if( d<m.x ){
|
||
m = vec3( d, o );
|
||
outValue = m.x;
|
||
cells = m.y;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
`,n=e.shaderLanguage===1?e._babylonSLtoWGSL(n):e._babylonSLtoGLSL(n),e._emitFunction("voronoi",n,"// Voronoi");var i=e._getFreeVariableName("tempOutput"),o=e._getFreeVariableName("tempCells"),a=e.shaderLanguage===1?"&":"";return e.compilationString+="".concat(e._declareLocalVar(i,G.Float),` = 0.0;
|
||
`),e.compilationString+="".concat(e._declareLocalVar(o,G.Float),` = 0.0;
|
||
`),e.compilationString+="voronoi(".concat(this.seed.associatedVariableName,", ").concat(this.offset.associatedVariableName,", ").concat(this.density.associatedVariableName,", ").concat(a).concat(i,", ").concat(a).concat(o,`);
|
||
`),this.output.hasEndpoints&&(e.compilationString+=e._declareOutput(this.output)+" = ".concat(i,`;
|
||
`)),this.cells.hasEndpoints&&(e.compilationString+=e._declareOutput(this.cells)+" = ".concat(o,`;
|
||
`)),this}},t}(ut);(0,j.Y5)("BABYLON.VoronoiNoiseBlock",$y);var e0=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ElbowBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e=this._inputs[0];if(e.isConnected){var n=e.connectedPoint.ownerBlock;if(n.target!==_e.VertexAndFragment)return n.target;if(e.connectedPoint.target!==_e.VertexAndFragment)return e.connectedPoint.target}return this._target},set:function(e){this._target&e||(this._target=e)},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this._inputs[0];return e.compilationString+=e._declareOutput(n)+" = ".concat(i.associatedVariableName,`;
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.ElbowBlock",e0);var wh=function(r){function t(e,n){n===void 0&&(n=!1);var i=r.call(this,e,_e.Neutral)||this;return i.projectAsCube=!1,i._convertToGammaSpace=!1,i._convertToLinearSpace=!1,i.disableLevelMultiplication=!1,i.registerInput("position",G.AutoDetect,!1),i.registerInput("normal",G.AutoDetect,!1),i.registerInput("sharpness",G.Float,!0),i.registerInput("source",G.Object,!0,_e.VertexAndFragment,new bn("source",i,0,sr,"ImageSourceBlock")),i.registerInput("sourceY",G.Object,!0,_e.VertexAndFragment,new bn("sourceY",i,0,sr,"ImageSourceBlock")),n||i.registerInput("sourceZ",G.Object,!0,_e.VertexAndFragment,new bn("sourceZ",i,0,sr,"ImageSourceBlock")),i.registerOutput("rgba",G.Color4,_e.Neutral),i.registerOutput("rgb",G.Color3,_e.Neutral),i.registerOutput("r",G.Float,_e.Neutral),i.registerOutput("g",G.Float,_e.Neutral),i.registerOutput("b",G.Float,_e.Neutral),i.registerOutput("a",G.Float,_e.Neutral),i.registerOutput("level",G.Float,_e.Neutral),i._inputs[0].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Vector4),i._inputs[1].addExcludedConnectionPointFromAllowedTypes(G.Color3|G.Vector3|G.Vector4),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"texture",{get:function(){var e;return this.source.isConnected?((e=this.source.connectedPoint)===null||e===void 0?void 0:e.ownerBlock).texture:this._texture},set:function(e){var n,i=this;if(this._texture!==e){var o=(n=e?.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;!e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i._texture)}),this._texture=e,e&&o&&o.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(e)})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureY",{get:function(){var e;return this.sourceY.isConnected?((e=this.sourceY.connectedPoint)===null||e===void 0?void 0:e.ownerBlock).texture:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureZ",{get:function(){var e,n;return!((e=this.sourceZ)===null||e===void 0)&&e.isConnected?((n=this.sourceY.connectedPoint)===null||n===void 0?void 0:n.ownerBlock).texture:null},enumerable:!1,configurable:!0}),t.prototype._getImageSourceBlock=function(e){return e?.isConnected?e.connectedPoint.ownerBlock:null},Object.defineProperty(t.prototype,"samplerName",{get:function(){var e=this._getImageSourceBlock(this.source);return e?e.samplerName:this._samplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerYName",{get:function(){var e,n;return(n=(e=this._getImageSourceBlock(this.sourceY))===null||e===void 0?void 0:e.samplerName)!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerZName",{get:function(){var e,n;return(n=(e=this._getImageSourceBlock(this.sourceZ))===null||e===void 0?void 0:e.samplerName)!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasImageSource",{get:function(){return this.source.isConnected},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToGammaSpace",{get:function(){return this._convertToGammaSpace},set:function(e){var n,i=this;if(e!==this._convertToGammaSpace&&(this._convertToGammaSpace=e,this.texture)){var o=(n=this.texture.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;o?.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i.texture)})}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToLinearSpace",{get:function(){return this._convertToLinearSpace},set:function(e){var n,i=this;if(e!==this._convertToLinearSpace&&(this._convertToLinearSpace=e,this.texture)){var o=(n=this.texture.getScene())!==null&&n!==void 0?n:Ve.q.LastCreatedScene;o?.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag,function(a){return a.hasTexture(i.texture)})}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TriPlanarBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sharpness",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceY",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceZ",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,n,i){if(i._areTexturesDirty){var o=this.convertToGammaSpace&&this.texture&&!this.texture.gammaSpace,a=this.convertToLinearSpace&&this.texture&&this.texture.gammaSpace;i.setValue(this._linearDefineName,o,!0),i.setValue(this._gammaDefineName,a,!0)}},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.bind=function(e){this.texture&&(e.setFloat(this._textureInfoName,this.texture.level),this._imageSource||e.setTexture(this._samplerName,this.texture))},t.prototype._samplerFunc=function(e){return e.shaderLanguage===1?"textureSample":"texture2D"},t.prototype._generateTextureSample=function(e,n,i){return i.shaderLanguage===1?"".concat(this._samplerFunc(i),"(").concat(e,",").concat(e+P.Y.AUTOSAMPLERSUFFIX,", ").concat(n,")"):"".concat(this._samplerFunc(i),"(").concat(e,", ").concat(n,")")},t.prototype._generateTextureLookup=function(e){var n,i,o=this.samplerName,a=(n=this.samplerYName)!==null&&n!==void 0?n:o,s=(i=this.samplerZName)!==null&&i!==void 0?i:o,l=this.sharpness.isConnected?this.sharpness.associatedVariableName:"1.0",c=e._getFreeVariableName("x"),u=e._getFreeVariableName("y"),d=e._getFreeVariableName("z"),h=e._getFreeVariableName("w"),p=e._getFreeVariableName("n"),m=e._getFreeVariableName("uvx"),v=e._getFreeVariableName("uvy"),b=e._getFreeVariableName("uvz");e.compilationString+=`
|
||
`.concat(e._declareLocalVar(p,G.Vector3)," = ").concat(this.normal.associatedVariableName,`.xyz;
|
||
|
||
`).concat(e._declareLocalVar(m,G.Vector2)," = ").concat(this.position.associatedVariableName,`.yz;
|
||
`).concat(e._declareLocalVar(v,G.Vector2)," = ").concat(this.position.associatedVariableName,`.zx;
|
||
`).concat(e._declareLocalVar(b,G.Vector2)," = ").concat(this.position.associatedVariableName,`.xy;
|
||
`),this.projectAsCube&&(e.compilationString+=`
|
||
`.concat(m,".xy = ").concat(m,`.yx;
|
||
|
||
if (`).concat(p,`.x >= 0.0) {
|
||
`).concat(m,".x = -").concat(m,`.x;
|
||
}
|
||
if (`).concat(p,`.y < 0.0) {
|
||
`).concat(v,".y = -").concat(v,`.y;
|
||
}
|
||
if (`).concat(p,`.z < 0.0) {
|
||
`).concat(b,".x = -").concat(b,`.x;
|
||
}
|
||
`));var E=e.fSuffix;e.compilationString+=`
|
||
`.concat(e._declareLocalVar(c,G.Vector4)," = ").concat(this._generateTextureSample(o,m,e),`;
|
||
`).concat(e._declareLocalVar(u,G.Vector4)," = ").concat(this._generateTextureSample(a,v,e),`;
|
||
`).concat(e._declareLocalVar(d,G.Vector4)," = ").concat(this._generateTextureSample(s,b,e),`;
|
||
|
||
// blend weights
|
||
`).concat(e._declareLocalVar(h,G.Vector3)," = pow(abs(").concat(p,"), vec3").concat(E,"(").concat(l,`));
|
||
|
||
// blend and return
|
||
`).concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = (").concat(c,"*").concat(h,".x + ").concat(u,"*").concat(h,".y + ").concat(d,"*").concat(h,".z) / (").concat(h,".x + ").concat(h,".y + ").concat(h,`.z);
|
||
`)},t.prototype._generateConversionCode=function(e,n,i){var o="";e.shaderLanguage!==1||n.type!==G.Vector3&&n.type!==G.Color3||(o="Vec3"),i!=="a"&&(this.texture&&this.texture.gammaSpace||(e.compilationString+="#ifdef ".concat(this._linearDefineName,`
|
||
`).concat(n.associatedVariableName," = toGammaSpace").concat(o,"(").concat(n.associatedVariableName,`);
|
||
#endif
|
||
`)),e.compilationString+="#ifdef ".concat(this._gammaDefineName,`
|
||
`).concat(n.associatedVariableName," = toLinearSpace").concat(o,"(").concat(n.associatedVariableName,`);
|
||
#endif
|
||
`))},t.prototype._writeOutput=function(e,n,i){var o="";this.disableLevelMultiplication||(o=" * ".concat(e.shaderLanguage===1?"uniforms.":"").concat(this._textureInfoName)),e.compilationString+="".concat(e._declareOutput(n)," = ").concat(this._tempTextureRead,".").concat(i).concat(o,`;
|
||
`),this._generateConversionCode(e,n,i)},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e),this.source.isConnected?this._imageSource=this.source.connectedPoint.ownerBlock:this._imageSource=null,this._textureInfoName=e._getFreeVariableName("textureInfoName"),this.level.associatedVariableName=(e.shaderLanguage===1?"uniforms.":"")+this._textureInfoName,this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA"),this._imageSource||(this._samplerName=e._getFreeVariableName(this.name+"Texture"),e._emit2DSampler(this._samplerName)),e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this);var n="//".concat(this.name);e._emitFunctionFromInclude("helperFunctions",n),e._emitUniformFromString(this._textureInfoName,G.Float),this._generateTextureLookup(e);for(var i=0,o=this._outputs;i<o.length;i++){var a=o[i];a.hasEndpoints&&a.name!=="level"&&this._writeOutput(e,a,a.name)}return this},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return e+="".concat(this._codeVariableName,".convertToGammaSpace = ").concat(this.convertToGammaSpace,`;
|
||
`),e+="".concat(this._codeVariableName,".convertToLinearSpace = ").concat(this.convertToLinearSpace,`;
|
||
`),e+="".concat(this._codeVariableName,".disableLevelMultiplication = ").concat(this.disableLevelMultiplication,`;
|
||
`),e+="".concat(this._codeVariableName,".projectAsCube = ").concat(this.projectAsCube,`;
|
||
`),this.texture?(e+="".concat(this._codeVariableName,'.texture = new BABYLON.Texture("').concat(this.texture.name,'", null, ').concat(this.texture.noMipmap,", ").concat(this.texture.invertY,", ").concat(this.texture.samplingMode,`);
|
||
`),e+="".concat(this._codeVariableName,".texture.wrapU = ").concat(this.texture.wrapU,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.wrapV = ").concat(this.texture.wrapV,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uAng = ").concat(this.texture.uAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vAng = ").concat(this.texture.vAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.wAng = ").concat(this.texture.wAng,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uOffset = ").concat(this.texture.uOffset,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vOffset = ").concat(this.texture.vOffset,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.uScale = ").concat(this.texture.uScale,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.vScale = ").concat(this.texture.vScale,`;
|
||
`),e+="".concat(this._codeVariableName,".texture.coordinatesMode = ").concat(this.texture.coordinatesMode,`;
|
||
`)):e},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,e.disableLevelMultiplication=this.disableLevelMultiplication,e.projectAsCube=this.projectAsCube,this.hasImageSource||!this.texture||this.texture.isRenderTarget||this.texture.getClassName()==="VideoTexture"||(e.texture=this.texture.serialize()),e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,this.disableLevelMultiplication=!!e.disableLevelMultiplication,this.projectAsCube=!!e.projectAsCube,e.texture&&!so.IgnoreTexturesAtLoadTime&&e.texture.url!==void 0&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=Ie.g.Parse(e.texture,n,i))},(0,A.Cg)([dt("Project as cube",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"projectAsCube",void 0),t}(ut);(0,j.Y5)("BABYLON.TriPlanarBlock",wh);var t0=function(r){function t(e){return r.call(this,e,!0)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"BiPlanarBlock"},t.prototype._declareLocalVarAsVec3I=function(e,n){return n.shaderLanguage===1?"var ".concat(e,": vec3<i32>"):"ivec3 ".concat(e)},t.prototype._getTextureGrad=function(e,n){return e.shaderLanguage===1?"textureSampleGrad(".concat(n,",").concat(n+P.Y.AUTOSAMPLERSUFFIX):"textureGrad(".concat(n)},t.prototype._generateTextureLookup=function(e){var n,i=this.samplerName,o=(n=this.samplerYName)!==null&&n!==void 0?n:this.samplerName,a=this.sharpness.isConnected?this.sharpness.associatedVariableName:"1.0",s=e._getFreeVariableName("dxValue"),l=e._getFreeVariableName("dyValue"),c=e._getFreeVariableName("n"),u=e._getFreeVariableName("ma"),d=e._getFreeVariableName("mi"),h=e._getFreeVariableName("me"),p=e._getFreeVariableName("x"),m=e._getFreeVariableName("y"),v=e._getFreeVariableName("w"),b="ivec3",E="dFdx",C="dFdy",T=e.fSuffix;e.shaderLanguage===1&&(b="vec3<i32>",E="dpdx",C="dpdy"),e.compilationString+=`
|
||
// grab coord derivatives for texturing
|
||
`.concat(e._declareLocalVar(s,G.Vector3)," = ").concat(E,"(").concat(this.position.associatedVariableName,`.xyz);
|
||
`).concat(e._declareLocalVar(l,G.Vector3)," = ").concat(C,"(").concat(this.position.associatedVariableName,`.xyz);
|
||
`).concat(e._declareLocalVar(c,G.Vector3)," = abs(").concat(this.normal.associatedVariableName,`.xyz);
|
||
|
||
// determine major axis (in x; yz are following axis)
|
||
`).concat(this._declareLocalVarAsVec3I(u,e)," = ").concat(e._generateTernary("".concat(b,"(0,1,2)"),"".concat(e._generateTernary("".concat(b,"(1,2,0)"),"".concat(b,"(2,0,1)"),"(".concat(c,".y>").concat(c,".z)"))),"(".concat(c,".x>").concat(c,".y && ").concat(c,".x>").concat(c,".z)")),`;
|
||
|
||
// determine minor axis (in x; yz are following axis)
|
||
`).concat(this._declareLocalVarAsVec3I(d,e)," = ").concat(e._generateTernary("".concat(b,"(0,1,2)"),"".concat(e._generateTernary("".concat(b,"(1,2,0)"),"".concat(b,"(2,0,1)"),"(".concat(c,".y<").concat(c,".z)"))),"(".concat(c,".x<").concat(c,".y && ").concat(c,".x<").concat(c,".z)")),`;
|
||
|
||
// determine median axis (in x; yz are following axis)
|
||
`).concat(this._declareLocalVarAsVec3I(h,e)," = ").concat(b,"(3) - ").concat(d," - ").concat(u,`;
|
||
|
||
// project+fetch
|
||
`).concat(e._declareLocalVar(p,G.Vector4)," = ").concat(this._getTextureGrad(e,i),", vec2").concat(T,"(").concat(this.position.associatedVariableName,"[").concat(u,".y], ").concat(this.position.associatedVariableName,"[").concat(u,`.z]),
|
||
vec2`).concat(T,"(").concat(s,"[").concat(u,".y],").concat(s,"[").concat(u,`.z]),
|
||
vec2`).concat(T,"(").concat(l,"[").concat(u,".y],").concat(l,"[").concat(u,`.z]));
|
||
`).concat(e._declareLocalVar(m,G.Vector4)," = ").concat(this._getTextureGrad(e,o),", vec2").concat(T,"(").concat(this.position.associatedVariableName,"[").concat(h,".y], ").concat(this.position.associatedVariableName,"[").concat(h,`.z]),
|
||
vec2`).concat(T,"(").concat(s,"[").concat(h,".y],").concat(s,"[").concat(h,`.z]),
|
||
vec2`).concat(T,"(").concat(l,"[").concat(h,".y],").concat(l,"[").concat(h,`.z]));
|
||
|
||
// blend factors
|
||
`).concat(e._declareLocalVar(v,G.Vector2)," = vec2").concat(T,"(").concat(c,"[").concat(u,".x],").concat(c,"[").concat(h,`.x]);
|
||
// make local support
|
||
`).concat(v," = clamp( (").concat(v,"-0.5773)/(1.0-0.5773), vec2").concat(T,"(0.0), vec2").concat(T,`(1.0) );
|
||
// shape transition
|
||
`).concat(v," = pow( ").concat(v,", vec2").concat(T,"(").concat(a,`/8.0) );
|
||
// blend and return
|
||
`).concat(e._declareLocalVar(this._tempTextureRead,G.Vector4)," = (").concat(p,"*").concat(v,".x + ").concat(m,"*").concat(v,".y) / (").concat(v,".x + ").concat(v,`.y);
|
||
`)},t}(wh);(0,j.Y5)("BABYLON.BiPlanarBlock",t0);var n0=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.Matrix),n.registerOutput("output",G.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MatrixDeterminantBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.output,i=this.input;return e.compilationString+=e._declareOutput(n)+" = determinant(".concat(i.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.MatrixDeterminantBlock",n0);var Bh,i0=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.registerInput("input",G.Matrix),n.registerOutput("output",G.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MatrixTransposeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.output,i=this.input;return e.compilationString+=e._declareOutput(n)+" = transpose(".concat(i.associatedVariableName,`);
|
||
`),this},t}(ut);(0,j.Y5)("BABYLON.MatrixTransposeBlock",i0),function(r){r[r.None=0]="None",r[r.Normal=1]="Normal",r[r.Tangent=2]="Tangent",r[r.VertexColor=3]="VertexColor",r[r.UV1=4]="UV1",r[r.UV2=5]="UV2",r[r.UV3=6]="UV3",r[r.UV4=7]="UV4",r[r.UV5=8]="UV5",r[r.UV6=9]="UV6"}(Bh||(Bh={}));var _n,r0=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.attributeType=0,n.registerInput("input",G.AutoDetect),n.registerInput("fallback",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].onConnectionObservable.add(function(i){var o;if(!n.attributeType){var a=i.ownerBlock;if(a instanceof Mt&&a.isAttribute)switch(a.name){case"color":n.attributeType=3;break;case"normal":n.attributeType=1;break;case"tangent":n.attributeType=2;break;case"uv":n.attributeType=4;break;case"uv2":n.attributeType=5;break;case"uv3":n.attributeType=6;break;case"uv4":n.attributeType=7;break;case"uv5":n.attributeType=8;break;case"uv6":n.attributeType=9}else if(a instanceof Rh)switch((o=n.input.connectedPoint)===null||o===void 0?void 0:o.name){case"normalOutput":n.attributeType=1;break;case"tangentOutput":n.attributeType=2;break;case"uvOutput":n.attributeType=4}}}),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MeshAttributeExistsBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fallback",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=null;switch(this.attributeType){case 3:n="VERTEXCOLOR_NME";break;case 1:n="NORMAL";break;case 2:n="TANGENT";break;case 4:n="UV1";break;case 5:n="UV2";break;case 6:n="UV3";break;case 7:n="UV4";break;case 8:n="UV5";break;case 9:n="UV6"}var i=e._declareOutput(this.output);return n&&(e.compilationString+="#ifdef ".concat(n,`
|
||
`)),e.compilationString+="".concat(i," = ").concat(this.input.associatedVariableName,`;
|
||
`),n&&(e.compilationString+=`#else
|
||
`,e.compilationString+="".concat(i," = ").concat(this.fallback.associatedVariableName,`;
|
||
`),e.compilationString+=`#endif
|
||
`),this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.attributeType=this.attributeType,e},t.prototype._deserialize=function(e,n,i){var o;r.prototype._deserialize.call(this,e,n,i),this.attributeType=(o=e.attributeType)!==null&&o!==void 0?o:0},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".attributeType = ").concat(this.attributeType,`;
|
||
`)},(0,A.Cg)([dt("Attribute lookup",4,void 0,{notifiers:{update:!0},options:[{label:"(None)",value:0},{label:"Normal",value:1},{label:"Tangent",value:2},{label:"Vertex Color",value:3},{label:"UV1",value:4},{label:"UV2",value:5},{label:"UV3",value:6},{label:"UV4",value:7},{label:"UV5",value:8},{label:"UV6",value:9}]})],t.prototype,"attributeType",void 0),t}(ut);(0,j.Y5)("BABYLON.MeshAttributeExistsBlock",r0),function(r){r[r.EaseInSine=0]="EaseInSine",r[r.EaseOutSine=1]="EaseOutSine",r[r.EaseInOutSine=2]="EaseInOutSine",r[r.EaseInQuad=3]="EaseInQuad",r[r.EaseOutQuad=4]="EaseOutQuad",r[r.EaseInOutQuad=5]="EaseInOutQuad",r[r.EaseInCubic=6]="EaseInCubic",r[r.EaseOutCubic=7]="EaseOutCubic",r[r.EaseInOutCubic=8]="EaseInOutCubic",r[r.EaseInQuart=9]="EaseInQuart",r[r.EaseOutQuart=10]="EaseOutQuart",r[r.EaseInOutQuart=11]="EaseInOutQuart",r[r.EaseInQuint=12]="EaseInQuint",r[r.EaseOutQuint=13]="EaseOutQuint",r[r.EaseInOutQuint=14]="EaseInOutQuint",r[r.EaseInExpo=15]="EaseInExpo",r[r.EaseOutExpo=16]="EaseOutExpo",r[r.EaseInOutExpo=17]="EaseInOutExpo",r[r.EaseInCirc=18]="EaseInCirc",r[r.EaseOutCirc=19]="EaseOutCirc",r[r.EaseInOutCirc=20]="EaseInOutCirc",r[r.EaseInBack=21]="EaseInBack",r[r.EaseOutBack=22]="EaseOutBack",r[r.EaseInOutBack=23]="EaseInOutBack",r[r.EaseInElastic=24]="EaseInElastic",r[r.EaseOutElastic=25]="EaseOutElastic",r[r.EaseInOutElastic=26]="EaseInOutElastic"}(_n||(_n={}));var o0=function(r){function t(e){var n=r.call(this,e,_e.Neutral)||this;return n.type=_n.EaseInOutSine,n.registerInput("input",G.AutoDetect),n.registerOutput("output",G.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(G.Matrix),n._inputs[0].excludedConnectionPointTypes.push(G.Object),n._inputs[0].excludedConnectionPointTypes.push(G.Int),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"CurveBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._duplicateEntry=function(e,n){return"ret.".concat(n," = ").concat(e.replace(/VAL/g,"v."+n))},t.prototype._duplicateEntryDirect=function(e){return"return ".concat(e.replace(/VAL/g,"v"))},t.prototype._duplicateVector=function(e,n,i){if(n==="float"||n==="f32")return this._duplicateEntryDirect(e);for(var o=parseInt(n.replace("vec","")),a=i?`
|
||
var ret: vec`.concat(o,"f = vec").concat(o,`f(0.0);
|
||
`):`
|
||
vec`.concat(o," ret = vec").concat(o,`(0.0);
|
||
`),s=1;s<=o;s++)a+=this._duplicateEntry(e,s===1?"x":s===2?"y":s===3?"z":"w")+`;
|
||
`;return a+`return ret;
|
||
`},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n,i=this._outputs[0],o="",a=e._getShaderType(this.input.type),s=e.shaderLanguage===1;switch(n=_n[this.type]+"_"+a.replace("<","").replace(">",""),this.type){case _n.EaseInSine:o="return 1.0 - cos((v * 3.1415) / 2.0)";break;case _n.EaseOutSine:o="return sin((v * 3.1415) / 2.0)";break;case _n.EaseInOutSine:o="return -(cos(v * 3.1415) - 1.0) / 2.0";break;case _n.EaseInQuad:o="return v * v";break;case _n.EaseOutQuad:o="return (1.0 - v) * (1.0 - v)";break;case _n.EaseInOutQuad:var l=e._generateTernary("2.0 * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 2.0) / 2.0","VAL < 0.5");o=this._duplicateVector(l,a,s);break;case _n.EaseInCubic:o="return v * v * v";break;case _n.EaseOutCubic:l="1.0 - pow(1.0 - VAL, 3.0)",o=this._duplicateVector(l,a,s);break;case _n.EaseInOutCubic:l=e._generateTernary("4.0 * VAL * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 3.0) / 2.0","VAL < 0.5"),o=this._duplicateVector(l,a,s);break;case _n.EaseInQuart:o="return v * v * v * v";break;case _n.EaseOutQuart:l="1.0 - pow(1.0 - VAL, 4.0)",o=this._duplicateVector(l,a,s);break;case _n.EaseInOutQuart:l=e._generateTernary("8.0 * VAL * VAL * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 4.0) / 2.0","VAL < 0.5"),o=this._duplicateVector(l,a,s);break;case _n.EaseInQuint:o="return v * v * v * v * v";break;case _n.EaseOutQuint:l="1.0 - pow(1.0 - VAL, 5.0)",o=this._duplicateVector(l,a,s);break;case _n.EaseInOutQuint:l=e._generateTernary("16.0 * VAL * VAL * VAL * VAL * VAL","1.0 - pow(-2.0 * VAL + 2.0, 5.0) / 2.0","VAL < 0.5"),o=this._duplicateVector(l,a,s);break;case _n.EaseInExpo:l=e._generateTernary("0.0","pow(2.0, 10.0 * VAL - 10.0)","VAL == 0.0"),o=this._duplicateVector(l,a,s);break;case _n.EaseOutExpo:l=e._generateTernary("1.0","1.0 - pow(2.0, -10.0 * VAL)","VAL == 1.0"),o=this._duplicateVector(l,a,s);break;case _n.EaseInOutExpo:l=e._generateTernary("0.0",e._generateTernary("1.0",e._generateTernary("pow(2.0, 20.0 * VAL - 10.0) / 2.0","(2.0 - pow(2.0, -20.0 * VAL + 10.0)) / 2.0","VAL < 0.5"),"VAL == 1.0"),"VAL == 0.0"),o=this._duplicateVector(l,a,s);break;case _n.EaseInCirc:l="1.0 - sqrt(1.0 - pow(VAL, 2.0))",o=this._duplicateVector(l,a,s);break;case _n.EaseOutCirc:l="sqrt(1.0 - pow(VAL - 1.0, 2.0))",o=this._duplicateVector(l,a,s);break;case _n.EaseInOutCirc:l=e._generateTernary("(1.0 - sqrt(1.0 - pow(2.0 * VAL, 2.0))) / 2.0","(sqrt(1.0 - pow(-2.0 * VAL + 2.0, 2.0)) + 1.0) / 2.0","VAL < 0.5"),o=this._duplicateVector(l,a,s);break;case _n.EaseInBack:o="return 2.70158 * v * v * v - 1.70158 * v * v";break;case _n.EaseOutBack:l="2.70158 * pow(VAL - 1.0, 3.0) + 1.70158 * pow(VAL - 1.0, 2.0)",o=this._duplicateVector(l,a,s);break;case _n.EaseInOutBack:l=e._generateTernary("(pow(2.0 * VAL, 2.0) * ((3.5949095) * 2.0 * VAL - 2.5949095)) / 2.0","(pow(2.0 * VAL - 2.0, 2.0) * (3.5949095 * (VAL * 2.0 - 2.0) + 3.5949095) + 2.0) / 2.0","VAL < 0.5"),o=this._duplicateVector(l,a,s);break;case _n.EaseInElastic:l=e._generateTernary("0.0",e._generateTernary("1.0","-pow(2.0, 10.0 * VAL - 10.0) * sin((VAL * 10.0 - 10.75) * ((2.0 * 3.1415) / 3.0))","VAL == 1.0"),"VAL == 0.0"),o=this._duplicateVector(l,a,s);break;case _n.EaseOutElastic:l=e._generateTernary("0.0",e._generateTernary("1.0","pow(2.0, -10.0 * VAL) * sin((VAL * 10.0 - 0.75) * ((2.0 * 3.1415) / 3.0)) + 1.0","VAL == 1.0"),"VAL == 0.0"),o=this._duplicateVector(l,a,s);break;case _n.EaseInOutElastic:l=e._generateTernary("0.0",e._generateTernary("1.0",e._generateTernary("-(pow(2.0, 20.0 * VAL - 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0","(pow(2.0, -20.0 * VAL + 10.0) * sin((20.0 * VAL - 11.125) * ((2.0 * 3.1415) / 4.5))) / 2.0 + 1.0","VAL < 0.5"),"VAL == 1.0"),"VAL == 0.0"),o=this._duplicateVector(l,a,s)}return s?e._emitFunction(n,"fn ".concat(n,"(v: ").concat(a,") -> ").concat(a," {").concat(o,`;}
|
||
`),""):e._emitFunction(n,"".concat(a," ").concat(n,"(").concat(a," v) {").concat(o,`;}
|
||
`),""),e.compilationString+=e._declareOutput(i)+" = ".concat(n,"(").concat(this.input.associatedVariableName,`);
|
||
`),this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.curveType=this.type,e},t.prototype._deserialize=function(e,n,i){r.prototype._deserialize.call(this,e,n,i),this.type=e.curveType},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".type = BABYLON.CurveBlockTypes.").concat(_n[this.type],`;
|
||
`)},t}(ut);(0,j.Y5)("BABYLON.CurveBlock",o0);var Vh,tC=function(){function r(){}return r.prototype.optimize=function(t,e){},r}(),cN=function(){function r(){this.mm=new Map}return r.prototype.get=function(t,e){var n=this.mm.get(t);if(n!==void 0)return n.get(e)},r.prototype.set=function(t,e,n){var i=this.mm.get(t);i===void 0&&this.mm.set(t,i=new Map),i.set(e,n)},r}(),nC=function(){function r(t,e,n){var i=this;this._baseMaterial=t,this._scene=e??Ve.q.LastCreatedScene,this._options=n,this._subMeshToEffect=new Map,this._subMeshToDepthWrapper=new cN,this._meshes=new Map,this._onEffectCreatedObserver=this._baseMaterial.onEffectCreatedObservable.add(function(o){var a,s,l=(a=o.subMesh)===null||a===void 0?void 0:a.getMesh();l&&!i._meshes.has(l)&&i._meshes.set(l,l.onDisposeObservable.add(function(c){for(var u=i._subMeshToEffect.keys(),d=u.next();d.done!==!0;d=u.next()){var h=d.value;h?.getMesh()===c&&(i._subMeshToEffect.delete(h),i._deleteDepthWrapperEffect(h))}})),((s=i._subMeshToEffect.get(o.subMesh))===null||s===void 0?void 0:s[0])!==o.effect&&(i._subMeshToEffect.set(o.subMesh,[o.effect,i._scene.getEngine().currentRenderPassId]),i._deleteDepthWrapperEffect(o.subMesh))})}return Object.defineProperty(r.prototype,"standalone",{get:function(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.standalone)!==null&&e!==void 0&&e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"baseMaterial",{get:function(){return this._baseMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"doNotInjectCode",{get:function(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.doNotInjectCode)!==null&&e!==void 0&&e},enumerable:!1,configurable:!0}),r.prototype._deleteDepthWrapperEffect=function(t){var e=this._subMeshToDepthWrapper.mm.get(t);e&&(e.forEach(function(n){var i;(i=n.mainDrawWrapper.effect)===null||i===void 0||i.dispose()}),this._subMeshToDepthWrapper.mm.delete(t))},r.prototype.getEffect=function(t,e,n){var i,o=(i=this._subMeshToDepthWrapper.mm.get(t))===null||i===void 0?void 0:i.get(e);if(!o)return null;var a=o.drawWrapper[n];return a||(a=o.drawWrapper[n]=new jn.E(this._scene.getEngine())).setEffect(o.mainDrawWrapper.effect,o.mainDrawWrapper.defines),a},r.prototype.isReadyForSubMesh=function(t,e,n,i,o){var a,s;return!(this.standalone&&!this._baseMaterial.isReadyForSubMesh(t.getMesh(),t,i))&&(s=(a=this._makeEffect(t,e,n,o))===null||a===void 0?void 0:a.isReady())!==null&&s!==void 0&&s},r.prototype.dispose=function(){this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver),this._onEffectCreatedObserver=null;for(var t=this._meshes.entries(),e=t.next();e.done!==!0;e=t.next()){var n=e.value,i=n[0],o=n[1];i.onDisposeObservable.remove(o)}},r.prototype._makeEffect=function(t,e,n,i){var o,a,s,l=this._scene.getEngine(),c=this._subMeshToEffect.get(t);if(!c)return null;var u=c[0],d=c[1],h=this._subMeshToDepthWrapper.get(t,n);if(!h){var p=new jn.E(l);p.defines=(a=(o=t._getDrawWrapper(d))===null||o===void 0?void 0:o.defines)!==null&&a!==void 0?a:null,(h={drawWrapper:[],mainDrawWrapper:p,depthDefines:"",token:(0,Eo.z)()}).drawWrapper[i]=p,this._subMeshToDepthWrapper.set(t,n,h)}var m=e.join(`
|
||
`);if(h.mainDrawWrapper.effect&&m===h.depthDefines)return h.mainDrawWrapper.effect;h.depthDefines=m;var v=u.getUniformNames().slice(),b=u.vertexSourceCodeBeforeMigration,E=u.fragmentSourceCodeBeforeMigration;if(!this.doNotInjectCode){var C=this._options&&this._options.remappedVariables?"#include<shadowMapVertexNormalBias>(".concat(this._options.remappedVariables.join(","),")"):"#include<shadowMapVertexNormalBias>",T=this._options&&this._options.remappedVariables?"#include<shadowMapVertexMetric>(".concat(this._options.remappedVariables.join(","),")"):"#include<shadowMapVertexMetric>",f=this._options&&this._options.remappedVariables?"#include<shadowMapFragmentSoftTransparentShadow>(".concat(this._options.remappedVariables.join(","),")"):"#include<shadowMapFragmentSoftTransparentShadow>",g="#include<shadowMapFragment>",S="#include<shadowMapVertexExtraDeclaration>";b=(b=(b=(b=u.shaderLanguage===0?b.replace(/void\s+?main/g,`
|
||
`.concat(S,`
|
||
void main`)):b.replace(/@vertex/g,`
|
||
`.concat(S,`
|
||
@vertex`))).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,C)).indexOf("#define SHADOWDEPTH_METRIC")!==-1?b.replace(/#define SHADOWDEPTH_METRIC/g,T):b.replace(/}\s*$/g,T+`
|
||
}`)).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var y=E.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||E.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,x=E.indexOf("#define SHADOWDEPTH_FRAGMENT")!==-1,R="";y?E=E.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,f):R=f+`
|
||
`,E=E.replace(/void\s+?main/g,ti.M.IncludesShadersStore.shadowMapFragmentExtraDeclaration+`
|
||
void main`),x?E=E.replace(/#define SHADOWDEPTH_FRAGMENT/g,g):R+=g+`
|
||
`,R&&(E=E.replace(/}\s*$/g,R+"}")),v.push("biasAndScaleSM","depthValuesSM","lightDataSM","softTransparentShadowSM")}h.mainDrawWrapper.effect=l.createEffect({vertexSource:b,fragmentSource:E,vertexToken:h.token,fragmentToken:h.token},{attributes:u.getAttributesNames(),uniformsNames:v,uniformBuffersNames:u.getUniformBuffersNames(),samplers:u.getSamplers(),defines:m+`
|
||
`+u.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:u.getIndexParameters(),shaderLanguage:u.shaderLanguage},l);for(var I=0;I<h.drawWrapper.length;++I)I!==i&&((s=h.drawWrapper[I])===null||s===void 0||s.setEffect(h.mainDrawWrapper.effect,h.mainDrawWrapper.defines));return h.mainDrawWrapper.effect},r}();(function(r){r[r.Created=1]="Created",r[r.Disposed=2]="Disposed",r[r.GetDefineNames=4]="GetDefineNames",r[r.PrepareUniformBuffer=8]="PrepareUniformBuffer",r[r.IsReadyForSubMesh=16]="IsReadyForSubMesh",r[r.PrepareDefines=32]="PrepareDefines",r[r.BindForSubMesh=64]="BindForSubMesh",r[r.PrepareEffect=128]="PrepareEffect",r[r.GetAnimatables=256]="GetAnimatables",r[r.GetActiveTextures=512]="GetActiveTextures",r[r.HasTexture=1024]="HasTexture",r[r.FillRenderTargetTextures=2048]="FillRenderTargetTextures",r[r.HasRenderTargetTextures=4096]="HasRenderTargetTextures",r[r.HardBindForSubMesh=8192]="HardBindForSubMesh"})(Vh||(Vh={}));var a0=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.DECAL=!1,e.DECALDIRECTUV=0,e.DECAL_SMOOTHALPHA=!1,e.GAMMADECAL=!1,e}return(0,A.C6)(t,r),t}(si),Rl=function(r){function t(e,n){n===void 0&&(n=!0);var i=r.call(this,e,"DecalMap",150,new a0,n)||this;return i._isEnabled=!1,i.isEnabled=!1,i._smoothAlpha=!1,i.smoothAlpha=!1,i.registerForExtraEvents=!0,i._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],i}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n,i,o){var a=o.getMesh().decalMap;return!(this._isEnabled&&a?.texture&&$e.DecalMapEnabled&&n.texturesEnabled)||a.isReady()},t.prototype.prepareDefines=function(e,n,i){var o=i.decalMap;this._isEnabled&&o?.texture&&$e.DecalMapEnabled&&n.texturesEnabled?((!e.DECAL||e.GAMMADECAL!==o.texture.gammaSpace)&&e.markAsTexturesDirty(),e.DECAL=!0,e.GAMMADECAL=o.texture.gammaSpace,e.DECAL_SMOOTHALPHA=this._smoothAlpha,(0,Re.YT)(o.texture,e,"DECAL")):(e.DECAL&&e.markAsTexturesDirty(),e.DECAL=!1)},t.prototype.hardBindForSubMesh=function(e,n,i,o){var a=o.getMesh().decalMap;if(this._isEnabled&&a?.texture&&$e.DecalMapEnabled&&n.texturesEnabled){var s=this._material.isFrozen,l=a.texture;e.useUbo&&s&&e.isSync||(e.updateFloat4("vDecalInfos",l.coordinatesIndex,0,0,0),(0,Re.mA)(l,e,"decal")),e.setTexture("decalSampler",l)}},t.prototype.getClassName=function(){return"DecalMapConfiguration"},t.prototype.getSamplers=function(e){e.push("decalSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vDecalInfos",size:4,type:"vec4"},{name:"decalMatrix",size:16,type:"mat4"}]}},(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"smoothAlpha",void 0),t}(qi);function iC(r){return r instanceof Tn?new Wd(r):null}function rC(r){return r instanceof Tn?new gx(r):null}function oC(r){return r instanceof Tn?new Ka(r):null}function aC(r){return r instanceof Tn?new Za(r):null}function sC(r){return r instanceof Tn?new Hd(r):null}function lC(r){return r instanceof Tn?new Yd(r):null}function cC(r){return r instanceof Tn||r instanceof qt?new Bs(r):null}(0,j.Y5)("BABYLON.DecalMapConfiguration",Rl);var ui=function(){function r(){}return r.DEFAULT_COLOR=z.v9.White(),r.DEFAULT_WIDTH_ATTENUATED=1,r.DEFAULT_WIDTH=.1,r}(),On=function(){function r(){}return r.ConvertPoints=function(t){if(t.length&&Array.isArray(t)&&typeof t[0]=="number")return[t];if(t.length&&Array.isArray(t[0])&&typeof t[0][0]=="number")return t;if(t.length&&!Array.isArray(t[0])&&t[0]instanceof _.Pq){for(var e=[],n=0;n<t.length;n++){var i=t[n];e.push(i.x,i.y,i.z)}return[e]}if(t.length>0&&Array.isArray(t[0])&&t[0].length>0&&t[0][0]instanceof _.Pq){var o=[];return t.forEach(function(s){o.push(s.flatMap(function(l){return[l.x,l.y,l.z]}))}),o}if(t instanceof Float32Array)return[Array.from(t)];if(t.length&&t[0]instanceof Float32Array){var a=[];return t.forEach(function(s){a.push(Array.from(s))}),a}return[]},r.OmitZeroLengthPredicate=function(t,e,n){var i=[];return e.subtract(t).lengthSquared()>0&&i.push([t,e]),n.subtract(e).lengthSquared()>0&&i.push([e,n]),t.subtract(n).lengthSquared()>0&&i.push([n,t]),i.length===0?null:i},r.OmitDuplicatesPredicate=function(t,e,n,i){var o=[];return r._SearchInPoints(t,e,i)||o.push([t,e]),r._SearchInPoints(e,n,i)||o.push([e,n]),r._SearchInPoints(n,t,i)||o.push([n,t]),o.length===0?null:o},r._SearchInPoints=function(t,e,n){for(var i,o,a,s=0,l=n;s<l.length;s++)for(var c=l[s],u=0;u<c.length;u++)if(!((i=c[u])===null||i===void 0)&&i.equals(t)&&(!((o=c[u+1])===null||o===void 0)&&o.equals(e)||!((a=c[u-1])===null||a===void 0)&&a.equals(e)))return!0;return!1},r.MeshesToLines=function(t,e){var n=[];return t.forEach(function(i,o){var a=i.getVerticesData(Y.R.PositionKind),s=i.getIndices();if(a&&s)for(var l=0,c=0;l<s.length;l++){var u=3*s[c++],d=3*s[c++],h=3*s[c++],p=new _.Pq(a[u],a[u+1],a[u+2]),m=new _.Pq(a[d],a[d+1],a[d+2]),v=new _.Pq(a[h],a[h+1],a[h+2]);if(e){var b=e(p,m,v,n,l,u,i,o,a,s);if(b)for(var E=0,C=b;E<C.length;E++){var T=C[E];n.push(T)}}else n.push([p,m],[m,v],[v,p])}}),n},r.ToVector3Array=function(t){if(Array.isArray(t[0])){for(var e=[],n=0,i=t;n<i.length;n++){for(var o=i[n],a=[],s=0;s<o.length;s+=3)a.push(new _.Pq(o[s],o[s+1],o[s+2]));e.push(a)}return e}var l=t,c=[];for(s=0;s<l.length;s+=3)c.push(new _.Pq(l[s],l[s+1],l[s+2]));return c},r.ToNumberArray=function(t){return t.flatMap(function(e){return[e.x,e.y,e.z]})},r.GetPointsCountInfo=function(t){for(var e=new Array(t.length),n=0,i=t.length;i--;)e[i]=t[i].length/3,n+=e[i];return{total:n,counts:e}},r.GetLineLength=function(t){if(t.length===0)return 0;var e;e=typeof t[0]=="number"?r.ToVector3Array(t):t;for(var n=_.AA.Vector3[0],i=0,o=0;o<e.length-1;o++){var a=e[o];i+=e[o+1].subtractToRef(a,n).length()}return i},r.GetLineLengthArray=function(t){for(var e=new Float32Array(t.length/3),n=0,i=0,o=t.length/3-1;i<o;i++){var a=t[3*i+0],s=t[3*i+1],l=t[3*i+2];a-=t[3*i+3],s-=t[3*i+4],l-=t[3*i+5],n+=Math.sqrt(a*a+s*s+l*l),e[i+1]=n}return e},r.SegmentizeSegmentByCount=function(t,e,n){var i=[],o=e.subtract(t),a=_.AA.Vector3[0];a.setAll(n);var s=_.AA.Vector3[1];o.divideToRef(a,s);var l=t.clone();i.push(l);for(var c=0;c<n;c++)l=l.clone(),i.push(l.addInPlace(s));return i},r.SegmentizeLineBySegmentLength=function(t,e){var n=t[0]instanceof _.Pq?r.GetLineSegments(t):typeof t[0]=="number"?r.GetLineSegments(r.ToVector3Array(t)):t,i=[];return n.forEach(function(o){o.length>e?r.SegmentizeSegmentByCount(o.point1,o.point2,Math.ceil(o.length/e)).forEach(function(a){i.push(a)}):(i.push(o.point1),i.push(o.point2))}),i},r.SegmentizeLineBySegmentCount=function(t,e){var n=typeof t[0]=="number"?r.ToVector3Array(t):t,i=r.GetLineLength(n)/e;return r.SegmentizeLineBySegmentLength(n,i)},r.GetLineSegments=function(t){for(var e=[],n=0;n<t.length-1;n++){var i=t[n],o=t[n+1],a=o.subtract(i).length();e.push({point1:i,point2:o,length:a})}return e},r.GetMinMaxSegmentLength=function(t){var e=r.GetLineSegments(t).sort(function(n){return n.length});return{min:e[0].length,max:e[e.length-1].length}},r.GetPositionOnLineByVisibility=function(t,e,n,i){i===void 0&&(i=!1);for(var o=e*n,a=0,s=0,l=t.length,c=0;c<l;c++){if(o<=a+t[c].length){s=c;break}a+=t[c].length}var u=(o-a)/t[s].length;return t[s].point2.subtractToRef(t[s].point1,_.AA.Vector3[0]),_.AA.Vector3[1]=_.AA.Vector3[0].multiplyByFloats(u,u,u),i||_.AA.Vector3[1].addInPlace(t[s].point1),_.AA.Vector3[1].clone()},r.GetCircleLinePoints=function(t,e,n,i,o){n===void 0&&(n=0),i===void 0&&(i=t),o===void 0&&(o=2*Math.PI/e);for(var a=[],s=0;s<=e;s++)a.push(new _.Pq(Math.cos(s*o)*t,Math.sin(s*o)*i,n));return a},r.GetBezierLinePoints=function(t,e,n,i){return Bt.jj.CreateQuadraticBezier(t,e,n,i).getPoints().flatMap(function(o){return[o.x,o.y,o.z]})},r.GetArrowCap=function(t,e,n,i,o,a,s){return a===void 0&&(a=0),s===void 0&&(s=0),{points:[t.clone(),t.add(e.multiplyByFloats(n,n,n))],widths:[i,o,a,s]}},r.GetPointsFromText=function(t,e,n,i,o,a){o===void 0&&(o=0),a===void 0&&(a=!0);for(var s=[],l=0,c=zu(t,e,n,i);l<c.length;l++){for(var u=c[l],d=0,h=u.paths;d<h.length;d++){for(var p=[],m=0,v=h[d].getPoints();m<v.length;m++){var b=v[m];p.push(b.x,b.y,o)}s.push(p)}if(a)for(var E=0,C=u.holes;E<C.length;E++){for(var T=[],f=0,g=C[E].getPoints();f<g.length;f++)b=g[f],T.push(b.x,b.y,o);s.push(T)}}return s},r.Color3toRGBAUint8=function(t){for(var e=new Uint8Array(4*t.length),n=0,i=0;n<t.length;n++)e[i++]=255*t[n].r,e[i++]=255*t[n].g,e[i++]=255*t[n].b,e[i++]=255;return e},r.CreateColorsTexture=function(t,e,n,i){var o,a=(o=i.getEngine().getCaps().maxTextureSize)!==null&&o!==void 0?o:1,s=e.length>a?a:e.length,l=Math.ceil(e.length/a);l>1&&(e=(0,A.fX)((0,A.fX)([],e,!0),Array(s*l-e.length).fill(e[0]),!0));var c=r.Color3toRGBAUint8(e),u=new Ln(c,s,l,Zt.TEXTUREFORMAT_RGBA,i,!1,!0,n);return u.name=t,u},r.PrepareEmptyColorsTexture=function(t){if(!ui.EmptyColorsTexture){var e=new Uint8Array(4);ui.EmptyColorsTexture=new Ln(e,1,1,Zt.TEXTUREFORMAT_RGBA,t,!1,!1,Ln.NEAREST_NEAREST),ui.EmptyColorsTexture.name="grlEmptyColorsTexture"}return ui.EmptyColorsTexture},r.DisposeEmptyColorsTexture=function(){var t;(t=ui.EmptyColorsTexture)===null||t===void 0||t.dispose(),ui.EmptyColorsTexture=null},r.BooleanToNumber=function(t){return t?1:0},r}(),s0=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.GREASED_LINE_HAS_COLOR=!1,e.GREASED_LINE_SIZE_ATTENUATION=!1,e.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE=!1,e.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM=!1,e.GREASED_LINE_CAMERA_FACING=!0,e}return(0,A.C6)(t,r),t}(si),ha=function(r){function t(e,n,i){var o,a,s,l,c,u,d,h,p,m,v,b,E,C,T,f,g,S=this;i=i||{color:ui.DEFAULT_COLOR};var y=new s0;return y.GREASED_LINE_HAS_COLOR=!!i.color&&!i.useColors,y.GREASED_LINE_SIZE_ATTENUATION=(o=i.sizeAttenuation)!==null&&o!==void 0&&o,y.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE=i.colorDistributionType===1,y.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM=(n??e.getScene()).useRightHandedSystem,y.GREASED_LINE_CAMERA_FACING=(a=i.cameraFacing)===null||a===void 0||a,(S=r.call(this,e,t.GREASED_LINE_MATERIAL_NAME,200,y)||this).colorsTexture=null,S._scene=n??e.getScene(),S._engine=S._scene.getEngine(),S._cameraFacing=(s=i.cameraFacing)===null||s===void 0||s,S.visibility=(l=i.visibility)!==null&&l!==void 0?l:1,S.useDash=(c=i.useDash)!==null&&c!==void 0&&c,S.dashRatio=(u=i.dashRatio)!==null&&u!==void 0?u:.5,S.dashOffset=(d=i.dashOffset)!==null&&d!==void 0?d:0,S.width=i.width?i.width:i.sizeAttenuation?ui.DEFAULT_WIDTH_ATTENUATED:ui.DEFAULT_WIDTH,S._sizeAttenuation=(h=i.sizeAttenuation)!==null&&h!==void 0&&h,S.colorMode=(p=i.colorMode)!==null&&p!==void 0?p:0,S._color=(m=i.color)!==null&&m!==void 0?m:null,S.useColors=(v=i.useColors)!==null&&v!==void 0&&v,S._colorsDistributionType=(b=i.colorDistributionType)!==null&&b!==void 0?b:0,S.colorsSampling=(E=i.colorsSampling)!==null&&E!==void 0?E:Ln.NEAREST_NEAREST,S._colors=(C=i.colors)!==null&&C!==void 0?C:null,S.dashCount=(T=i.dashCount)!==null&&T!==void 0?T:1,S.resolution=(f=i.resolution)!==null&&f!==void 0?f:new _.I9(S._engine.getRenderWidth(),S._engine.getRenderHeight()),i.colorsTexture?S.colorsTexture=i.colorsTexture:S._colors?S.colorsTexture=On.CreateColorsTexture("".concat(e.name,"-colors-texture"),S._colors,S.colorsSampling,S._scene):(S._color=(g=S._color)!==null&&g!==void 0?g:ui.DEFAULT_COLOR,On.PrepareEmptyColorsTexture(S._scene)),S._engine.onDisposeObservable.add(function(){On.DisposeEmptyColorsTexture()}),S._enable(!0),S}return(0,A.C6)(t,r),t.prototype.getAttributes=function(e){e.push("grl_offsets"),e.push("grl_widths"),e.push("grl_colorPointers"),e.push("grl_counters"),this._cameraFacing?(e.push("grl_previousAndSide"),e.push("grl_nextAndCounters")):e.push("grl_slopes")},t.prototype.getSamplers=function(e){e.push("grl_colors")},t.prototype.getActiveTextures=function(e){this.colorsTexture&&e.push(this.colorsTexture)},t.prototype.getUniforms=function(){var e=[{name:"grl_singleColor",size:3,type:"vec3"},{name:"grl_textureSize",size:2,type:"vec2"},{name:"grl_dashOptions",size:4,type:"vec4"},{name:"grl_colorMode_visibility_colorsWidth_useColors",size:4,type:"vec4"}];return this._cameraFacing&&e.push({name:"grl_projection",size:16,type:"mat4"},{name:"grl_aspect_resolution_lineWidth",size:4,type:"vec4"}),{ubo:e,vertex:this._cameraFacing?`
|
||
uniform vec4 grl_aspect_resolution_lineWidth;
|
||
uniform mat4 grl_projection;
|
||
`:"",fragment:`
|
||
uniform vec4 grl_dashOptions;
|
||
uniform vec2 grl_textureSize;
|
||
uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;
|
||
uniform vec3 grl_singleColor;
|
||
`}},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.bindForSubMesh=function(e){var n,i,o;if(this._cameraFacing){var a=this._scene.activeCamera;if(!a)throw Error("GreasedLinePluginMaterial requires an active camera.");var s=a.getProjectionMatrix();e.updateMatrix("grl_projection",s);var l=_.AA.Vector4[0];l.x=this._aspect,l.y=this._resolution.x,l.z=this._resolution.y,l.w=this.width,e.updateVector4("grl_aspect_resolution_lineWidth",l)}var c=_.AA.Vector4[0];c.x=On.BooleanToNumber(this.useDash),c.y=this._dashArray,c.z=this.dashOffset,c.w=this.dashRatio,e.updateVector4("grl_dashOptions",c);var u=_.AA.Vector4[1];u.x=this.colorMode,u.y=this.visibility,u.z=this.colorsTexture?this.colorsTexture.getSize().width:0,u.w=On.BooleanToNumber(this.useColors),e.updateVector4("grl_colorMode_visibility_colorsWidth_useColors",u),this._color&&e.updateColor3("grl_singleColor",this._color);var d=(n=this.colorsTexture)!==null&&n!==void 0?n:ui.EmptyColorsTexture;e.setTexture("grl_colors",d),e.updateFloat2("grl_textureSize",(i=d?.getSize().width)!==null&&i!==void 0?i:1,(o=d?.getSize().height)!==null&&o!==void 0?o:1)},t.prototype.prepareDefines=function(e,n,i){e.GREASED_LINE_HAS_COLOR=!!this.color&&!this.useColors,e.GREASED_LINE_SIZE_ATTENUATION=this._sizeAttenuation,e.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE=this._colorsDistributionType===1,e.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM=n.useRightHandedSystem,e.GREASED_LINE_CAMERA_FACING=this._cameraFacing},t.prototype.getClassName=function(){return t.GREASED_LINE_MATERIAL_NAME},t.prototype.getCustomCode=function(e){if(e==="vertex"){var n={CUSTOM_VERTEX_DEFINITIONS:`
|
||
attribute float grl_widths;
|
||
attribute vec3 grl_offsets;
|
||
attribute float grl_colorPointers;
|
||
varying float grlCounters;
|
||
varying float grlColorPointer;
|
||
|
||
#ifdef GREASED_LINE_CAMERA_FACING
|
||
attribute vec4 grl_previousAndSide;
|
||
attribute vec4 grl_nextAndCounters;
|
||
|
||
vec2 grlFix( vec4 i, float aspect ) {
|
||
vec2 res = i.xy / i.w;
|
||
res.x *= aspect;
|
||
return res;
|
||
}
|
||
#else
|
||
attribute vec3 grl_slopes;
|
||
attribute float grl_counters;
|
||
#endif
|
||
`,CUSTOM_VERTEX_UPDATE_POSITION:`
|
||
#ifdef GREASED_LINE_CAMERA_FACING
|
||
vec3 grlPositionOffset = grl_offsets;
|
||
positionUpdated += grlPositionOffset;
|
||
#else
|
||
positionUpdated = (positionUpdated + grl_offsets) + (grl_slopes * grl_widths);
|
||
#endif
|
||
`,CUSTOM_VERTEX_MAIN_END:`
|
||
grlColorPointer = grl_colorPointers;
|
||
|
||
#ifdef GREASED_LINE_CAMERA_FACING
|
||
|
||
float grlAspect = grl_aspect_resolution_lineWidth.x;
|
||
float grlBaseWidth = grl_aspect_resolution_lineWidth.w;
|
||
|
||
|
||
vec3 grlPrevious = grl_previousAndSide.xyz;
|
||
float grlSide = grl_previousAndSide.w;
|
||
|
||
vec3 grlNext = grl_nextAndCounters.xyz;
|
||
grlCounters = grl_nextAndCounters.w;
|
||
|
||
mat4 grlMatrix = viewProjection * finalWorld;
|
||
vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );
|
||
vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );
|
||
vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );
|
||
|
||
vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );
|
||
vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );
|
||
vec2 grlNextP = grlFix( grlNextPos, grlAspect );
|
||
|
||
float grlWidth = grlBaseWidth * grl_widths;
|
||
|
||
vec2 grlDir;
|
||
if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );
|
||
else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );
|
||
else {
|
||
vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );
|
||
vec2 grlDir2 = normalize( grlNextP - grlCurrentP );
|
||
grlDir = normalize( grlDir1 + grlDir2 );
|
||
}
|
||
vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );
|
||
#ifdef GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM
|
||
grlNormal.xy *= -.5 * grlWidth;
|
||
#else
|
||
grlNormal.xy *= .5 * grlWidth;
|
||
#endif
|
||
|
||
grlNormal *= grl_projection;
|
||
|
||
#ifdef GREASED_LINE_SIZE_ATTENUATION
|
||
grlNormal.xy *= grlFinalPosition.w;
|
||
grlNormal.xy /= ( vec4( grl_aspect_resolution_lineWidth.yz, 0., 1. ) * grl_projection ).xy;
|
||
#endif
|
||
|
||
grlFinalPosition.xy += grlNormal.xy * grlSide;
|
||
gl_Position = grlFinalPosition;
|
||
|
||
vPositionW = vec3(grlFinalPosition);
|
||
#else
|
||
grlCounters = grl_counters;
|
||
#endif
|
||
`};return this._cameraFacing&&(n["!gl_Position\\=viewProjection\\*worldPos;"]="//"),n}return e==="fragment"?{CUSTOM_FRAGMENT_DEFINITIONS:`
|
||
varying float grlCounters;
|
||
varying float grlColorPointer;
|
||
uniform sampler2D grl_colors;
|
||
`,CUSTOM_FRAGMENT_MAIN_END:`
|
||
float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;
|
||
float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;
|
||
float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;
|
||
float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;
|
||
|
||
float grlUseDash = grl_dashOptions.x;
|
||
float grlDashArray = grl_dashOptions.y;
|
||
float grlDashOffset = grl_dashOptions.z;
|
||
float grlDashRatio = grl_dashOptions.w;
|
||
|
||
gl_FragColor.a *= step(grlCounters, grlVisibility);
|
||
if( gl_FragColor.a == 0. ) discard;
|
||
|
||
if(grlUseDash == 1.){
|
||
gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));
|
||
if (gl_FragColor.a == 0.) discard;
|
||
}
|
||
|
||
#ifdef GREASED_LINE_HAS_COLOR
|
||
if (grlColorMode == `.concat(0,`.) {
|
||
gl_FragColor.rgb = grl_singleColor;
|
||
} else if (grlColorMode == `).concat(1,`.) {
|
||
gl_FragColor.rgb += grl_singleColor;
|
||
} else if (grlColorMode == `).concat(2,`.) {
|
||
gl_FragColor.rgb *= grl_singleColor;
|
||
}
|
||
#else
|
||
if (grlUseColors == 1.) {
|
||
#ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE
|
||
vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);
|
||
#else
|
||
vec2 lookup = vec2(fract(grlColorPointer / grl_textureSize.x), 1.0 - floor(grlColorPointer / grl_textureSize.x) / max(grl_textureSize.y - 1.0, 1.0));
|
||
vec4 grlColor = texture2D(grl_colors, lookup, 0.0);
|
||
#endif
|
||
if (grlColorMode == `).concat(0,`.) {
|
||
gl_FragColor = grlColor;
|
||
} else if (grlColorMode == `).concat(1,`.) {
|
||
gl_FragColor += grlColor;
|
||
} else if (grlColorMode == `).concat(2,`.) {
|
||
gl_FragColor *= grlColor;
|
||
}
|
||
}
|
||
#endif
|
||
|
||
`)}:null},t.prototype.dispose=function(){var e;(e=this.colorsTexture)===null||e===void 0||e.dispose(),r.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"colors",{get:function(){return this._colors},set:function(e){this.setColors(e)},enumerable:!1,configurable:!0}),t.prototype.setColors=function(e,n,i){var o,a,s,l;n===void 0&&(n=!1),i===void 0&&(i=!1);var c=(a=(o=this._colors)===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0;if(this._colors=e,e!==null&&e.length!==0){if(!n||i)if(this.colorsTexture&&c===e.length&&!i){var u=On.Color3toRGBAUint8(e);this.colorsTexture.update(u)}else(l=this.colorsTexture)===null||l===void 0||l.dispose(),this.colorsTexture=On.CreateColorsTexture("".concat(this._material.name,"-colors-texture"),e,this.colorsSampling,this._scene)}else(s=this.colorsTexture)===null||s===void 0||s.dispose()},t.prototype.updateLazy=function(){this._colors&&this.setColors(this._colors,!1,!0)},Object.defineProperty(t.prototype,"dashCount",{get:function(){return this._dashCount},set:function(e){this._dashCount=e,this._dashArray=1/e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeAttenuation",{get:function(){return this._sizeAttenuation},set:function(e){this._sizeAttenuation=e,this.markAllDefinesAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._color},set:function(e){this.setColor(e)},enumerable:!1,configurable:!0}),t.prototype.setColor=function(e,n){n===void 0&&(n=!1),this._color===null&&e!==null||this._color!==null&&e===null?(this._color=e,!n&&this.markAllDefinesAsDirty()):this._color=e},Object.defineProperty(t.prototype,"colorsDistributionType",{get:function(){return this._colorsDistributionType},set:function(e){this._colorsDistributionType=e,this.markAllDefinesAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._aspect=e.x/e.y,this._resolution=e},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e=r.prototype.serialize.call(this),n={colorDistributionType:this._colorsDistributionType,colorsSampling:this.colorsSampling,colorMode:this.colorMode,dashCount:this._dashCount,dashOffset:this.dashOffset,dashRatio:this.dashRatio,resolution:this._resolution,sizeAttenuation:this._sizeAttenuation,useColors:this.useColors,useDash:this.useDash,visibility:this.visibility,width:this.width};return this._colors&&(n.colors=this._colors),this._color&&(n.color=this._color),e.greasedLineMaterialOptions=n,e},t.prototype.parse=function(e,n,i){var o;r.prototype.parse.call(this,e,n,i);var a=e.greasedLineMaterialOptions;(o=this.colorsTexture)===null||o===void 0||o.dispose(),a.color&&this.setColor(a.color,!0),a.colorDistributionType&&(this.colorsDistributionType=a.colorDistributionType),a.colors&&(this.colors=a.colors),a.colorsSampling&&(this.colorsSampling=a.colorsSampling),a.colorMode&&(this.colorMode=a.colorMode),a.useColors&&(this.useColors=a.useColors),a.visibility&&(this.visibility=a.visibility),a.useDash&&(this.useDash=a.useDash),a.dashCount&&(this.dashCount=a.dashCount),a.dashRatio&&(this.dashRatio=a.dashRatio),a.dashOffset&&(this.dashOffset=a.dashOffset),a.width&&(this.width=a.width),a.sizeAttenuation&&(this.sizeAttenuation=a.sizeAttenuation),a.resolution&&(this.resolution=a.resolution),this.colors?this.colorsTexture=On.CreateColorsTexture("".concat(this._material.name,"-colors-texture"),this.colors,this.colorsSampling,n):On.PrepareEmptyColorsTexture(n),this.markAllDefinesAsDirty()},t.prototype.copyTo=function(e){var n,i=e;(n=i.colorsTexture)===null||n===void 0||n.dispose(),this._colors&&(i.colorsTexture=On.CreateColorsTexture("".concat(i._material.name,"-colors-texture"),this._colors,i.colorsSampling,this._scene)),i.setColor(this.color,!0),i.colorsDistributionType=this.colorsDistributionType,i.colorsSampling=this.colorsSampling,i.colorMode=this.colorMode,i.useColors=this.useColors,i.visibility=this.visibility,i.useDash=this.useDash,i.dashCount=this.dashCount,i.dashRatio=this.dashRatio,i.dashOffset=this.dashOffset,i.width=this.width,i.sizeAttenuation=this.sizeAttenuation,i.resolution=this.resolution,i.markAllDefinesAsDirty()},t.GREASED_LINE_MATERIAL_NAME="GreasedLinePluginMaterial",t}(qi);(0,j.Y5)("BABYLON.".concat(ha.GREASED_LINE_MATERIAL_NAME),ha),Gt.l.ShadersStore.greasedLinePixelShader=`precision highp float;uniform sampler2D grlColors;uniform float grlUseColors;uniform float grlUseDash;uniform float grlDashArray;uniform float grlDashOffset;uniform float grlDashRatio;uniform float grlVisibility;uniform float grlColorsWidth;uniform vec2 grl_colorModeAndColorDistributionType;uniform vec3 grlColor;varying float grlCounters;varying float grlColorPointer;void main() {float grlColorMode=grl_colorModeAndColorDistributionType.x;float grlColorDistributionType=grl_colorModeAndColorDistributionType.y;gl_FragColor=vec4(grlColor,1.);gl_FragColor.a=step(grlCounters,grlVisibility);if (gl_FragColor.a==0.) discard;if( grlUseDash==1. ){gl_FragColor.a=ceil(mod(grlCounters+grlDashOffset,grlDashArray)-(grlDashArray*grlDashRatio));if (gl_FragColor.a==0.) discard;}
|
||
if (grlUseColors==1.) {vec4 textureColor;if (grlColorDistributionType==COLOR_DISTRIBUTION_TYPE_LINE) {
|
||
textureColor=texture2D(grlColors,vec2(grlCounters,0.),0.);} else {textureColor=texture2D(grlColors,vec2(grlColorPointer/grlColorsWidth,0.),0.);}
|
||
if (grlColorMode==COLOR_MODE_SET) {gl_FragColor=textureColor;} else if (grlColorMode==COLOR_MODE_ADD) {gl_FragColor+=textureColor;} else if (grlColorMode==COLOR_MODE_MULTIPLY) {gl_FragColor*=textureColor;}}}
|
||
`,L(38615),L(35397),Gt.l.ShadersStore.greasedLineVertexShader=`precision highp float;
|
||
#include<instancesDeclaration>
|
||
attribute float grl_widths;attribute vec3 grl_offsets;attribute float grl_colorPointers;attribute vec3 position;uniform mat4 viewProjection;uniform mat4 projection;varying float grlCounters;varying float grlColorPointer;
|
||
#ifdef GREASED_LINE_CAMERA_FACING
|
||
attribute vec4 grl_nextAndCounters;attribute vec4 grl_previousAndSide;uniform vec2 grlResolution;uniform float grlAspect;uniform float grlWidth;uniform float grlSizeAttenuation;vec2 grlFix( vec4 i,float aspect ) {vec2 res=i.xy/i.w;res.x*=aspect;return res;}
|
||
#else
|
||
attribute vec3 grl_slopes;attribute float grl_counters;
|
||
#endif
|
||
void main() {
|
||
#include<instancesVertex>
|
||
grlColorPointer=grl_colorPointers;mat4 grlMatrix=viewProjection*finalWorld ;
|
||
#ifdef GREASED_LINE_CAMERA_FACING
|
||
float grlBaseWidth=grlWidth;vec3 grlPrevious=grl_previousAndSide.xyz;float grlSide=grl_previousAndSide.w;vec3 grlNext=grl_nextAndCounters.xyz;grlCounters=grl_nextAndCounters.w;vec3 grlPositionOffset=grl_offsets;vec4 grlFinalPosition=grlMatrix*vec4( position+grlPositionOffset ,1.0 );vec4 grlPrevPos=grlMatrix*vec4( grlPrevious+grlPositionOffset,1.0 );vec4 grlNextPos=grlMatrix*vec4( grlNext+grlPositionOffset,1.0 );vec2 grlCurrentP=grlFix( grlFinalPosition,grlAspect );vec2 grlPrevP=grlFix( grlPrevPos,grlAspect );vec2 grlNextP=grlFix( grlNextPos,grlAspect );float grlWidth=grlBaseWidth*grl_widths;vec2 grlDir;if( grlNextP==grlCurrentP ) grlDir=normalize( grlCurrentP-grlPrevP );else if( grlPrevP==grlCurrentP ) grlDir=normalize( grlNextP-grlCurrentP );else {vec2 grlDir1=normalize( grlCurrentP-grlPrevP );vec2 grlDir2=normalize( grlNextP-grlCurrentP );grlDir=normalize( grlDir1+grlDir2 );}
|
||
vec4 grlNormal=vec4( -grlDir.y,grlDir.x,0.,1. );
|
||
#ifdef GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM
|
||
grlNormal.xy*=-.5*grlWidth;
|
||
#else
|
||
grlNormal.xy*=.5*grlWidth;
|
||
#endif
|
||
grlNormal*=projection;if (grlSizeAttenuation==1.) {grlNormal.xy*=grlFinalPosition.w;grlNormal.xy/=( vec4( grlResolution,0.,1. )*projection ).xy;}
|
||
grlFinalPosition.xy+=grlNormal.xy*grlSide;gl_Position=grlFinalPosition;
|
||
#else
|
||
grlCounters=grl_counters;vec4 grlFinalPosition=grlMatrix*vec4( (position+grl_offsets)+grl_slopes*grl_widths ,1.0 ) ;gl_Position=grlFinalPosition;
|
||
#endif
|
||
}
|
||
`;var Uh,Gh,kh,zh=function(r){function t(e,n,i){var o,a,s,l,c,u,d,h,p,m,v,b,E,C,T=this,f=["COLOR_DISTRIBUTION_TYPE_LINE ".concat(1,"."),"COLOR_DISTRIBUTION_TYPE_SEGMENT ".concat(0,"."),"COLOR_MODE_SET ".concat(0,"."),"COLOR_MODE_ADD ".concat(1,"."),"COLOR_MODE_MULTIPLY ".concat(2,".")],g=["position","grl_widths","grl_offsets","grl_colorPointers"];n.useRightHandedSystem&&f.push("GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM"),i.cameraFacing?(f.push("GREASED_LINE_CAMERA_FACING"),g.push("grl_previousAndSide","grl_nextAndCounters")):(g.push("grl_slopes"),g.push("grl_counters")),(T=r.call(this,e,n,{vertex:"greasedLine",fragment:"greasedLine"},{attributes:g,uniforms:["world","viewProjection","view","projection","grlColorsWidth","grlUseColors","grlWidth","grlColor","grl_colorModeAndColorDistributionType","grlResolution","grlAspect","grlAizeAttenuation","grlDashArray","grlDashOffset","grlDashRatio","grlUseDash","grlVisibility"],samplers:["grlColors"],defines:f})||this)._color=z.v9.White(),T._colorsDistributionType=0,T._colorsTexture=null,i=i||{color:ui.DEFAULT_COLOR};var S=n.getEngine();return T.visibility=(o=i.visibility)!==null&&o!==void 0?o:1,T.useDash=(a=i.useDash)!==null&&a!==void 0&&a,T.dashRatio=(s=i.dashRatio)!==null&&s!==void 0?s:.5,T.dashOffset=(l=i.dashOffset)!==null&&l!==void 0?l:0,T.dashCount=(c=i.dashCount)!==null&&c!==void 0?c:1,T.width=i.width?i.width:i.sizeAttenuation&&i.cameraFacing?ui.DEFAULT_WIDTH_ATTENUATED:ui.DEFAULT_WIDTH,T.sizeAttenuation=(u=i.sizeAttenuation)!==null&&u!==void 0&&u,T.color=(d=i.color)!==null&&d!==void 0?d:z.v9.White(),T.useColors=(h=i.useColors)!==null&&h!==void 0&&h,T.colorsDistributionType=(p=i.colorDistributionType)!==null&&p!==void 0?p:0,T.colorsSampling=(m=i.colorsSampling)!==null&&m!==void 0?m:Ln.NEAREST_NEAREST,T.colorMode=(v=i.colorMode)!==null&&v!==void 0?v:0,T._colors=(b=i.colors)!==null&&b!==void 0?b:null,T._cameraFacing=(E=i.cameraFacing)===null||E===void 0||E,T.resolution=(C=i.resolution)!==null&&C!==void 0?C:new _.I9(S.getRenderWidth(),S.getRenderHeight()),i.colorsTexture?T.colorsTexture=i.colorsTexture:T.colorsTexture=On.PrepareEmptyColorsTexture(n),T._colors&&T.useColors&&(T.colorsTexture=On.CreateColorsTexture("".concat(T.name,"-colors-texture"),T._colors,T.colorsSampling,n)),S.onDisposeObservable.add(function(){On.DisposeEmptyColorsTexture()}),T}return(0,A.C6)(t,r),t.prototype.dispose=function(){var e;(e=this._colorsTexture)===null||e===void 0||e.dispose(),r.prototype.dispose.call(this)},t.prototype._setColorModeAndColorDistributionType=function(){this.setVector2("grl_colorModeAndColorDistributionType",new _.I9(this._colorMode,this._colorsDistributionType))},t.prototype.updateLazy=function(){this._colors&&this.setColors(this._colors,!1,!0)},Object.defineProperty(t.prototype,"colors",{get:function(){return this._colors},set:function(e){this.setColors(e)},enumerable:!1,configurable:!0}),t.prototype.setColors=function(e,n,i){var o,a,s,l;n===void 0&&(n=!1),i===void 0&&(i=!1);var c=(a=(o=this._colors)===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0;if(this._colors=e,e!==null&&e.length!==0){if(!n||i)if(this._colorsTexture&&c===e.length&&!i){var u=On.Color3toRGBAUint8(e);this._colorsTexture.update(u)}else(l=this._colorsTexture)===null||l===void 0||l.dispose(),this.colorsTexture=On.CreateColorsTexture("".concat(this.name,"-colors-texture"),e,this.colorsSampling,this.getScene())}else(s=this._colorsTexture)===null||s===void 0||s.dispose()},Object.defineProperty(t.prototype,"colorsTexture",{get:function(){var e;return(e=this._colorsTexture)!==null&&e!==void 0?e:null},set:function(e){this._colorsTexture=e,this.setFloat("grlColorsWidth",this._colorsTexture.getSize().width),this.setTexture("grlColors",this._colorsTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e,this.setFloat("grlWidth",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useColors",{get:function(){return this._useColors},set:function(e){this._useColors=e,this.setFloat("grlUseColors",On.BooleanToNumber(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorsSampling",{get:function(){return this._colorsSampling},set:function(e){this._colorsSampling=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._visibility},set:function(e){this._visibility=e,this.setFloat("grlVisibility",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useDash",{get:function(){return this._useDash},set:function(e){this._useDash=e,this.setFloat("grlUseDash",On.BooleanToNumber(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dashOffset",{get:function(){return this._dashOffset},set:function(e){this._dashOffset=e,this.setFloat("grlDashOffset",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dashRatio",{get:function(){return this._dashRatio},set:function(e){this._dashRatio=e,this.setFloat("grlDashRatio",e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dashCount",{get:function(){return this._dashCount},set:function(e){this._dashCount=e,this._dashArray=1/e,this.setFloat("grlDashArray",this._dashArray)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeAttenuation",{get:function(){return this._sizeAttenuation},set:function(e){this._sizeAttenuation=e,this.setFloat("grlSizeAttenuation",On.BooleanToNumber(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this.color},set:function(e){this.setColor(e)},enumerable:!1,configurable:!0}),t.prototype.setColor=function(e){e=e??ui.DEFAULT_COLOR,this._color=e,this.setColor3("grlColor",e)},Object.defineProperty(t.prototype,"colorsDistributionType",{get:function(){return this._colorsDistributionType},set:function(e){this._colorsDistributionType=e,this._setColorModeAndColorDistributionType()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorMode",{get:function(){return this._colorMode},set:function(e){this._colorMode=e,this._setColorModeAndColorDistributionType()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resolution",{get:function(){return this._resolution},set:function(e){this._resolution=e,this.setVector2("grlResolution",e),this.setFloat("grlAspect",e.x/e.y)},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e=r.prototype.serialize.call(this),n={colorDistributionType:this._colorsDistributionType,colorsSampling:this._colorsSampling,colorMode:this._colorMode,color:this._color,dashCount:this._dashCount,dashOffset:this._dashOffset,dashRatio:this._dashRatio,resolution:this._resolution,sizeAttenuation:this._sizeAttenuation,useColors:this._useColors,useDash:this._useDash,visibility:this._visibility,width:this._width,cameraFacing:this._cameraFacing};return this._colors&&(n.colors=this._colors),e.greasedLineMaterialOptions=n,e},t.prototype.parse=function(e,n,i){var o,a,s=e.greasedLineMaterialOptions;(o=this._colorsTexture)===null||o===void 0||o.dispose(),s.color&&(this.color=s.color),s.colorDistributionType&&(this.colorsDistributionType=s.colorDistributionType),s.colorsSampling&&(this.colorsSampling=s.colorsSampling),s.colorMode&&(this.colorMode=s.colorMode),s.useColors&&(this.useColors=s.useColors),s.visibility&&(this.visibility=s.visibility),s.useDash&&(this.useDash=s.useDash),s.dashCount&&(this.dashCount=s.dashCount),s.dashRatio&&(this.dashRatio=s.dashRatio),s.dashOffset&&(this.dashOffset=s.dashOffset),s.width&&(this.width=s.width),s.sizeAttenuation&&(this.sizeAttenuation=s.sizeAttenuation),s.resolution&&(this.resolution=s.resolution),s.colors?this.colorsTexture=On.CreateColorsTexture("".concat(this.name,"-colors-texture"),s.colors,this.colorsSampling,this.getScene()):this.colorsTexture=On.PrepareEmptyColorsTexture(n),this._cameraFacing=(a=s.cameraFacing)===null||a===void 0||a,this.setDefine("GREASED_LINE_CAMERA_FACING",this._cameraFacing)},t}(pi);(function(r){r[r.MATERIAL_TYPE_STANDARD=0]="MATERIAL_TYPE_STANDARD",r[r.MATERIAL_TYPE_PBR=1]="MATERIAL_TYPE_PBR",r[r.MATERIAL_TYPE_SIMPLE=2]="MATERIAL_TYPE_SIMPLE"})(Uh||(Uh={})),function(r){r[r.COLOR_MODE_SET=0]="COLOR_MODE_SET",r[r.COLOR_MODE_ADD=1]="COLOR_MODE_ADD",r[r.COLOR_MODE_MULTIPLY=2]="COLOR_MODE_MULTIPLY"}(Gh||(Gh={})),function(r){r[r.COLOR_DISTRIBUTION_TYPE_SEGMENT=0]="COLOR_DISTRIBUTION_TYPE_SEGMENT",r[r.COLOR_DISTRIBUTION_TYPE_LINE=1]="COLOR_DISTRIBUTION_TYPE_LINE"}(kh||(kh={}));var Wh,uC=[new Ge.v9(.98,.26,.38),new Ge.v9(.47,.75,.3),new Ge.v9(0,.26,.77),new Ge.v9(.97,.6,.76),new Ge.v9(.19,.63,.78),new Ge.v9(.98,.8,.6),new Ge.v9(.65,.43,.15),new Ge.v9(.15,.47,.22),new Ge.v9(.67,.71,.86),new Ge.v9(.09,.46,.56),new Ge.v9(.8,.98,.02),new Ge.v9(.39,.29,.13),new Ge.v9(.53,.63,.06),new Ge.v9(.95,.96,.41),new Ge.v9(1,.72,.94),new Ge.v9(.63,.08,.31),new Ge.v9(.66,.96,.95),new Ge.v9(.22,.14,.19),new Ge.v9(.14,.65,.59),new Ge.v9(.93,1,.68),new Ge.v9(.93,.14,.44),new Ge.v9(.47,.86,.67),new Ge.v9(.85,.07,.78),new Ge.v9(.53,.64,.98),new Ge.v9(.43,.37,.56),new Ge.v9(.71,.65,.25),new Ge.v9(.66,.19,.01),new Ge.v9(.94,.53,.12),new Ge.v9(.41,.44,.44),new Ge.v9(.24,.71,.96),new Ge.v9(.57,.28,.56),new Ge.v9(.44,.98,.42)];(function(r){r[r.NONE=0]="NONE",r[r.TRIANGLES=1]="TRIANGLES",r[r.VERTICES=2]="VERTICES",r[r.TRIANGLES_VERTICES=3]="TRIANGLES_VERTICES",r[r.UV0=4]="UV0",r[r.UV1=5]="UV1",r[r.VERTEXCOLORS=6]="VERTEXCOLORS",r[r.MATERIALIDS=7]="MATERIALIDS"})(Wh||(Wh={}));var uN=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.DBG_MODE=0,e.DBG_MULTIPLY=!0,e.DBG_ENABLED=!0,e}return(0,A.C6)(t,r),t}(si),l0=function(r){function t(e,n){n===void 0&&(n={});var i,o,a,s,l,c,u,d,h,p,m,v,b,E=this,C=new uN;return C.DBG_MODE=(i=n.mode)!==null&&i!==void 0?i:C.DBG_MODE,C.DBG_MULTIPLY=(o=n.multiply)!==null&&o!==void 0?o:C.DBG_MULTIPLY,(E=r.call(this,e,"MeshDebug",200,C,!0,!0)||this)._mode=C.DBG_MODE,E._multiply=C.DBG_MULTIPLY,E.shadedDiffuseColor=(a=n.shadedDiffuseColor)!==null&&a!==void 0?a:new Ge.v9(1,1,1),E.shadedSpecularColor=(s=n.shadedSpecularColor)!==null&&s!==void 0?s:new Ge.v9(.8,.8,.8),E.shadedSpecularPower=(l=n.shadedSpecularPower)!==null&&l!==void 0?l:10,E.wireframeThickness=(c=n.wireframeThickness)!==null&&c!==void 0?c:.7,E.wireframeTrianglesColor=(u=n.wireframeTrianglesColor)!==null&&u!==void 0?u:new Ge.v9(0,0,0),E.wireframeVerticesColor=(d=n.wireframeVerticesColor)!==null&&d!==void 0?d:new Ge.v9(.8,.8,.8),E.vertexColor=(h=n.vertexColor)!==null&&h!==void 0?h:new Ge.v9(0,0,0),E.vertexRadius=(p=n.vertexRadius)!==null&&p!==void 0?p:1.2,E.uvScale=(m=n.uvScale)!==null&&m!==void 0?m:20,E.uvPrimaryColor=(v=n.uvPrimaryColor)!==null&&v!==void 0?v:new Ge.v9(1,1,1),E.uvSecondaryColor=(b=n.uvSecondaryColor)!==null&&b!==void 0?b:new Ge.v9(.5,.5,.5),E._materialColor=t.MaterialColors[t._PluginCount++%t.MaterialColors.length],E.isEnabled=!0,E}return(0,A.C6)(t,r),t.prototype._markAllDefinesAsDirty=function(){this._enable(this._isEnabled),this.markAllDefinesAsDirty()},t.prototype.isCompatible=function(e){switch(e){case 0:case 1:return!0;default:return!1}},t.prototype.getClassName=function(){return"MeshDebugPluginMaterial"},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){if(this._isEnabled!==e){if(!this._material.getScene().getEngine().isWebGPU&&this._material.getScene().getEngine().version==1)return O.V.Error("MeshDebugPluginMaterial is not supported on WebGL 1.0."),void(this._isEnabled=!1);this._isEnabled=e,this._markAllDefinesAsDirty()}},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,n,i){this._mode!=2&&this._mode!=1&&this._mode!=3||i.isVerticesDataPresent("dbg_initialPass")||O.V.Warn("For best results with TRIANGLES, TRIANGLES_VERTICES, or VERTICES modes, please use MeshDebugPluginMaterial.PrepareMeshForTrianglesAndVerticesMode() on mesh.",1),e.DBG_MODE=this._mode,e.DBG_MULTIPLY=this._multiply,e.DBG_ENABLED=this._isEnabled},t.prototype.getAttributes=function(e){e.push("dbg_initialPass")},t.prototype.getUniforms=function(e){return e===void 0&&(e=0),{ubo:[{name:"dbg_shadedDiffuseColor",size:3,type:"vec3"},{name:"dbg_shadedSpecularColorPower",size:4,type:"vec4"},{name:"dbg_thicknessRadiusScale",size:3,type:"vec3"},{name:"dbg_wireframeTrianglesColor",size:3,type:"vec3"},{name:"dbg_wireframeVerticesColor",size:3,type:"vec3"},{name:"dbg_vertexColor",size:3,type:"vec3"},{name:"dbg_uvPrimaryColor",size:3,type:"vec3"},{name:"dbg_uvSecondaryColor",size:3,type:"vec3"},{name:"dbg_materialColor",size:3,type:"vec3"}],fragment:e===0?`#if defined(DBG_ENABLED)
|
||
uniform vec3 dbg_shadedDiffuseColor;
|
||
uniform vec4 dbg_shadedSpecularColorPower;
|
||
uniform vec3 dbg_thicknessRadiusScale;
|
||
|
||
#if DBG_MODE == 2 || DBG_MODE == 3
|
||
uniform vec3 dbg_vertexColor;
|
||
#endif
|
||
|
||
#if DBG_MODE == 1
|
||
uniform vec3 dbg_wireframeTrianglesColor;
|
||
#elif DBG_MODE == 3
|
||
uniform vec3 dbg_wireframeVerticesColor;
|
||
#elif DBG_MODE == 4 || DBG_MODE == 5
|
||
uniform vec3 dbg_uvPrimaryColor;
|
||
uniform vec3 dbg_uvSecondaryColor;
|
||
#elif DBG_MODE == 7
|
||
uniform vec3 dbg_materialColor;
|
||
#endif
|
||
#endif`:`#if defined(DBG_ENABLED)
|
||
uniform dbg_shadedDiffuseColor: vec3f;
|
||
uniform dbg_shadedSpecularColorPower: vec4f;
|
||
uniform dbg_thicknessRadiusScale: vec3f;
|
||
|
||
#if DBG_MODE == 2 || DBG_MODE == 3
|
||
uniform dbg_vertexColor: vec3f;
|
||
#endif
|
||
|
||
#if DBG_MODE == 1
|
||
uniform dbg_wireframeTrianglesColor: vec3f;
|
||
#elif DBG_MODE == 3
|
||
uniform dbg_wireframeVerticesColor: vec3f;
|
||
#elif DBG_MODE == 4 || DBG_MODE == 5
|
||
uniform dbg_uvPrimaryColor: vec3f;
|
||
uniform dbg_uvSecondaryColor: vec3f;
|
||
#elif DBG_MODE == 7
|
||
uniform dbg_materialColor: vec3f;
|
||
#endif
|
||
#endif`}},t.prototype.bindForSubMesh=function(e){this._isEnabled&&(e.updateFloat3("dbg_shadedDiffuseColor",this.shadedDiffuseColor.r,this.shadedDiffuseColor.g,this.shadedDiffuseColor.b),e.updateFloat4("dbg_shadedSpecularColorPower",this.shadedSpecularColor.r,this.shadedSpecularColor.g,this.shadedSpecularColor.b,this.shadedSpecularPower),e.updateFloat3("dbg_thicknessRadiusScale",this.wireframeThickness,this.vertexRadius,this.uvScale),e.updateColor3("dbg_wireframeTrianglesColor",this.wireframeTrianglesColor),e.updateColor3("dbg_wireframeVerticesColor",this.wireframeVerticesColor),e.updateColor3("dbg_vertexColor",this.vertexColor),e.updateColor3("dbg_uvPrimaryColor",this.uvPrimaryColor),e.updateColor3("dbg_uvSecondaryColor",this.uvSecondaryColor),e.updateColor3("dbg_materialColor",this._materialColor))},t.prototype.getCustomCode=function(e,n){return n===void 0&&(n=0),n===1?e==="vertex"?{CUSTOM_VERTEX_DEFINITIONS:`#if defined(DBG_ENABLED)
|
||
attribute dbg_initialPass: f32;
|
||
varying dbg_vBarycentric: vec3f;
|
||
varying dbg_vVertexWorldPos: vec3f;
|
||
varying dbg_vPass: f32;
|
||
#endif`,CUSTOM_VERTEX_MAIN_END:`#if defined(DBG_ENABLED)
|
||
var dbg_vertexIndex = f32(input.vertexIndex) % 3.;
|
||
if (dbg_vertexIndex == 0.0) {
|
||
vertexOutputs.dbg_vBarycentric = vec3f(1.,0.,0.);
|
||
}
|
||
else if (dbg_vertexIndex == 1.0) {
|
||
vertexOutputs.dbg_vBarycentric = vec3f(0.,1.,0.);
|
||
}
|
||
else {
|
||
vertexOutputs.dbg_vBarycentric = vec3f(0.,0.,1.);
|
||
}
|
||
|
||
vertexOutputs.dbg_vVertexWorldPos = vertexOutputs.vPositionW;
|
||
vertexOutputs.dbg_vPass = input.dbg_initialPass;
|
||
#endif`}:{CUSTOM_FRAGMENT_DEFINITIONS:`#if defined(DBG_ENABLED)
|
||
varying dbg_vBarycentric: vec3f;
|
||
varying dbg_vVertexWorldPos: vec3f;
|
||
varying dbg_vPass: f32;
|
||
|
||
#if !defined(DBG_MULTIPLY)
|
||
fn dbg_applyShading(color: vec3f) -> vec3f {
|
||
var N = fragmentInputs.vNormalW.xyz;
|
||
var L = normalize(scene.vEyePosition.xyz - fragmentInputs.vPositionW.xyz);
|
||
var H = normalize(L + L);
|
||
var LdotN = clamp(dot(L,N), 0., 1.);
|
||
var HdotN = clamp(dot(H,N), 0., 1.);
|
||
var specTerm = pow(HdotN, uniforms.dbg_shadedSpecularColorPower.w);
|
||
var result = color * (LdotN / PI);
|
||
result += uniforms.dbg_shadedSpecularColorPower.rgb * (specTerm / PI);
|
||
return result;
|
||
}
|
||
#endif
|
||
|
||
#if DBG_MODE == 1 || DBG_MODE == 3
|
||
fn dbg_edgeFactor() -> f32 {
|
||
var d = fwidth(fragmentInputs.dbg_vBarycentric);
|
||
var a3 = smoothstep(vec3f(0.), d * uniforms.dbg_thicknessRadiusScale.x, fragmentInputs.dbg_vBarycentric);
|
||
return min(min(a3.x, a3.y), a3.z);
|
||
}
|
||
#endif
|
||
|
||
#if DBG_MODE == 2 || DBG_MODE == 3
|
||
fn dbg_cornerFactor() -> f32 {
|
||
var worldPos = fragmentInputs.vPositionW;
|
||
float dist = length(worldPos - fragmentInputs.dbg_vVertexWorldPos);
|
||
float camDist = length(worldPos - scene.vEyePosition.xyz);
|
||
float d = sqrt(camDist) * .001;
|
||
return smoothstep((uniforms.dbg_thicknessRadiusScale.y * d), ((uniforms.dbg_thicknessRadiusScale.y * 1.01) * d), dist);
|
||
}
|
||
#endif
|
||
|
||
#if (DBG_MODE == 4 && defined(UV1)) || (DBG_MODE == 5 && defined(UV2))
|
||
fn dbg_checkerboardFactor(uv: vec2f) -> f32 {
|
||
var f = fract(uv * uniforms.dbg_thicknessRadiusScale.z);
|
||
f -= .5;
|
||
return (f.x * f.y) > 0. ? 1. : 0.;
|
||
}
|
||
#endif
|
||
#endif`,CUSTOM_FRAGMENT_MAIN_END:`#if defined(DBG_ENABLED)
|
||
var dbg_color = vec3f(1.);
|
||
#if DBG_MODE == 1
|
||
dbg_color = mix(uniforms.dbg_wireframeTrianglesColor, vec3f(1.), dbg_edgeFactor());
|
||
#elif DBG_MODE == 2 || DBG_MODE == 3
|
||
var dbg_cornerFactor = dbg_cornerFactor();
|
||
if (fragmentInputs.dbg_vPass == 0. && dbg_cornerFactor == 1.) discard;
|
||
dbg_color = mix(uniforms.dbg_vertexColor, vec3(1.), dbg_cornerFactor);
|
||
#if DBG_MODE == 3
|
||
dbg_color *= mix(uniforms.dbg_wireframeVerticesColor, vec3f(1.), dbg_edgeFactor());
|
||
#endif
|
||
#elif DBG_MODE == 4 && defined(MAINUV1)
|
||
dbg_color = mix(uniforms.dbg_uvPrimaryColor, uniforms.dbg_uvSecondaryColor, dbg_checkerboardFactor(fragmentInputs.vMainUV1));
|
||
#elif DBG_MODE == 5 && defined(MAINUV2)
|
||
dbg_color = mix(uniforms.dbg_uvPrimaryColor, uniforms.dbg_uvSecondaryColor, dbg_checkerboardFactor(fragmentInputs.vMainUV2));
|
||
#elif DBG_MODE == 6 && defined(VERTEXCOLOR)
|
||
dbg_color = fragmentInputs.vColor.rgb;
|
||
#elif DBG_MODE == 7
|
||
dbg_color = uniforms.dbg_materialColor;
|
||
#endif
|
||
|
||
#if defined(DBG_MULTIPLY)
|
||
fragmentOutputs.color *= vec4f(dbg_color, 1.);
|
||
#else
|
||
#if DBG_MODE != 6
|
||
fragmentOutputs.color = vec4f(dbg_applyShading(dbg_shadedDiffuseColor) * dbg_color, 1.);
|
||
#else
|
||
fragmentOutputs.color = vec4f(dbg_color, 1.);
|
||
#endif
|
||
#endif
|
||
#endif`}:e==="vertex"?{CUSTOM_VERTEX_DEFINITIONS:`#if defined(DBG_ENABLED)
|
||
attribute float dbg_initialPass;
|
||
varying vec3 dbg_vBarycentric;
|
||
flat varying vec3 dbg_vVertexWorldPos;
|
||
flat varying float dbg_vPass;
|
||
#endif`,CUSTOM_VERTEX_MAIN_END:`#if defined(DBG_ENABLED)
|
||
float dbg_vertexIndex = mod(float(gl_VertexID), 3.);
|
||
if (dbg_vertexIndex == 0.0) {
|
||
dbg_vBarycentric = vec3(1.,0.,0.);
|
||
}
|
||
else if (dbg_vertexIndex == 1.0) {
|
||
dbg_vBarycentric = vec3(0.,1.,0.);
|
||
}
|
||
else {
|
||
dbg_vBarycentric = vec3(0.,0.,1.);
|
||
}
|
||
|
||
dbg_vVertexWorldPos = vPositionW;
|
||
dbg_vPass = dbg_initialPass;
|
||
#endif`}:{CUSTOM_FRAGMENT_DEFINITIONS:`#if defined(DBG_ENABLED)
|
||
varying vec3 dbg_vBarycentric;
|
||
flat varying vec3 dbg_vVertexWorldPos;
|
||
flat varying float dbg_vPass;
|
||
|
||
#if !defined(DBG_MULTIPLY)
|
||
vec3 dbg_applyShading(vec3 color) {
|
||
vec3 N = vNormalW.xyz;
|
||
vec3 L = normalize(vEyePosition.xyz - vPositionW.xyz);
|
||
vec3 H = normalize(L + L);
|
||
float LdotN = clamp(dot(L,N), 0., 1.);
|
||
float HdotN = clamp(dot(H,N), 0., 1.);
|
||
float specTerm = pow(HdotN, dbg_shadedSpecularColorPower.w);
|
||
color *= (LdotN / PI);
|
||
color += dbg_shadedSpecularColorPower.rgb * (specTerm / PI);
|
||
return color;
|
||
}
|
||
#endif
|
||
|
||
#if DBG_MODE == 1 || DBG_MODE == 3
|
||
float dbg_edgeFactor() {
|
||
vec3 d = fwidth(dbg_vBarycentric);
|
||
vec3 a3 = smoothstep(vec3(0.), d * dbg_thicknessRadiusScale.x, dbg_vBarycentric);
|
||
return min(min(a3.x, a3.y), a3.z);
|
||
}
|
||
#endif
|
||
|
||
#if DBG_MODE == 2 || DBG_MODE == 3
|
||
float dbg_cornerFactor() {
|
||
vec3 worldPos = vPositionW;
|
||
float dist = length(worldPos - dbg_vVertexWorldPos);
|
||
float camDist = length(worldPos - vEyePosition.xyz);
|
||
float d = sqrt(camDist) * .001;
|
||
return smoothstep((dbg_thicknessRadiusScale.y * d), ((dbg_thicknessRadiusScale.y * 1.01) * d), dist);
|
||
}
|
||
#endif
|
||
|
||
#if (DBG_MODE == 4 && defined(UV1)) || (DBG_MODE == 5 && defined(UV2))
|
||
float dbg_checkerboardFactor(vec2 uv) {
|
||
vec2 f = fract(uv * dbg_thicknessRadiusScale.z);
|
||
f -= .5;
|
||
return (f.x * f.y) > 0. ? 1. : 0.;
|
||
}
|
||
#endif
|
||
#endif`,CUSTOM_FRAGMENT_MAIN_END:`#if defined(DBG_ENABLED)
|
||
vec3 dbg_color = vec3(1.);
|
||
#if DBG_MODE == 1
|
||
dbg_color = mix(dbg_wireframeTrianglesColor, vec3(1.), dbg_edgeFactor());
|
||
#elif DBG_MODE == 2 || DBG_MODE == 3
|
||
float dbg_cornerFactor = dbg_cornerFactor();
|
||
if (dbg_vPass == 0. && dbg_cornerFactor == 1.) discard;
|
||
dbg_color = mix(dbg_vertexColor, vec3(1.), dbg_cornerFactor);
|
||
#if DBG_MODE == 3
|
||
dbg_color *= mix(dbg_wireframeVerticesColor, vec3(1.), dbg_edgeFactor());
|
||
#endif
|
||
#elif DBG_MODE == 4 && defined(MAINUV1)
|
||
dbg_color = mix(dbg_uvPrimaryColor, dbg_uvSecondaryColor, dbg_checkerboardFactor(vMainUV1));
|
||
#elif DBG_MODE == 5 && defined(MAINUV2)
|
||
dbg_color = mix(dbg_uvPrimaryColor, dbg_uvSecondaryColor, dbg_checkerboardFactor(vMainUV2));
|
||
#elif DBG_MODE == 6 && defined(VERTEXCOLOR)
|
||
dbg_color = vColor.rgb;
|
||
#elif DBG_MODE == 7
|
||
dbg_color = dbg_materialColor;
|
||
#endif
|
||
|
||
#if defined(DBG_MULTIPLY)
|
||
gl_FragColor *= vec4(dbg_color, 1.);
|
||
#else
|
||
#if DBG_MODE != 6
|
||
gl_FragColor = vec4(dbg_applyShading(dbg_shadedDiffuseColor) * dbg_color, 1.);
|
||
#else
|
||
gl_FragColor = vec4(dbg_color, 1.);
|
||
#endif
|
||
#endif
|
||
#endif`}},t.Reset=function(){this._PluginCount=0,this.MaterialColors=uC},t.PrepareMeshForTrianglesAndVerticesMode=function(e,n){n===void 0&&(n=!1);var i=function(){};if(e.getTotalIndices()==0)return i;if(n){for(var o=e.getVerticesDataKinds(),a=e.getIndices(),s={},l=0,c=o;l<c.length;l++){var u=c[l];s[u]=e.getVerticesData(u)}i=function(){e.setIndices(a);for(var C=0,T=o;C<T.length;C++){var f=T[C],g=e.getVertexBuffer(f).getStrideSize();e.setVerticesData(f,s[f],void 0,g)}e.removeVerticesData("dbg_initialPass")}}for(var d=Array.from(e.getIndices()),h=[],p=0;p<d.length;p+=3)h.push(d[p+1],d[p+2],d[p+0]);e.setIndices(d.concat(h)),e.convertToUnIndexedMesh(),e.isUnIndexed=!1;var m=[];for(p=(d=Array.from(e.getIndices())).length/2;p<d.length;p+=3)m.push(d[p+1],d[p+2],d[p+0]);e.setIndices(d.concat(m));var v=e.getTotalVertices(),b=v/2,E=new Array(v).fill(1,0,b).fill(0,b,v);return e.setVerticesData("dbg_initialPass",E,!1,1),i},t._PluginCount=0,t.MaterialColors=uC,(0,A.Cg)([(0,V.jT)()],t.prototype,"_materialColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_isEnabled",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllDefinesAsDirty")],t.prototype,"mode",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllDefinesAsDirty")],t.prototype,"multiply",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"shadedDiffuseColor",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"shadedSpecularColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"shadedSpecularPower",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"wireframeThickness",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"wireframeTrianglesColor",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"wireframeVerticesColor",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"vertexColor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"vertexRadius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"uvScale",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"uvPrimaryColor",void 0),(0,A.Cg)([(0,V.jT)()],t.prototype,"uvSecondaryColor",void 0),t}(qi);(0,j.Y5)("BABYLON.MeshDebugPluginMaterial",l0),L(59262),L(13088),L(86343),Gt.l.ShadersStore.gaussianSplattingPixelShader=`#include<clipPlaneFragmentDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<fogFragmentDeclaration>
|
||
varying vec4 vColor;varying vec2 vPosition;void main () {
|
||
#include<clipPlaneFragment>
|
||
float A=-dot(vPosition,vPosition);if (A<-4.0) discard;float B=exp(A)*vColor.a;
|
||
#include<logDepthFragment>
|
||
vec3 color=vColor.rgb;
|
||
#ifdef FOG
|
||
#include<fogFragment>
|
||
#endif
|
||
gl_FragColor=vec4(color,B);}
|
||
`,Gt.l.IncludesShadersStore.gaussianSplattingVertexDeclaration=`uniform mat4 world;uniform mat4 view;uniform mat4 projection;
|
||
`,L(50851),L(56174),Gt.l.IncludesShadersStore.gaussianSplattingUboDeclaration=`#include<sceneUboDeclaration>
|
||
#include<meshUboDeclaration>
|
||
`,L(72153),L(62589),L(56458),Gt.l.ShadersStore.gaussianSplattingVertexShader=`#include<__decl__gaussianSplattingVertex>
|
||
#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
#include<clipPlaneVertexDeclaration>
|
||
#include<fogVertexDeclaration>
|
||
#include<logDepthDeclaration>
|
||
attribute vec2 position;attribute float splatIndex;uniform vec2 invViewport;uniform vec2 dataTextureSize;uniform vec2 focal;uniform sampler2D covariancesATexture;uniform sampler2D covariancesBTexture;uniform sampler2D centersTexture;uniform sampler2D colorsTexture;varying vec4 vColor;varying vec2 vPosition;
|
||
#if !defined(WEBGL2) && !defined(WEBGPU) && !defined(NATIVE)
|
||
mat3 transpose(mat3 matrix) {return mat3(matrix[0][0],matrix[1][0],matrix[2][0],
|
||
matrix[0][1],matrix[1][1],matrix[2][1],
|
||
matrix[0][2],matrix[1][2],matrix[2][2]);}
|
||
#endif
|
||
vec2 getDataUV(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return vec2((x+0.5)/textureSize.x,(y+0.5)/textureSize.y);}
|
||
void main () {vec2 splatUV=getDataUV(splatIndex,dataTextureSize);vec3 center=texture2D(centersTexture,splatUV).xyz;vec4 color=texture2D(colorsTexture,splatUV);vec3 covA=texture2D(covariancesATexture,splatUV).xyz;vec3 covB=texture2D(covariancesBTexture,splatUV).xyz;vec4 worldPos=world*vec4(center,1.0);mat4 modelView=view*world;vec4 camspace=view*worldPos;vec4 pos2d=projection*camspace;float bounds=1.2*pos2d.w;if (pos2d.z<-pos2d.w || pos2d.x<-bounds || pos2d.x>bounds
|
||
|| pos2d.y<-bounds || pos2d.y>bounds) {gl_Position=vec4(0.0,0.0,2.0,1.0);return;}
|
||
mat3 Vrk=mat3(
|
||
covA.x,covA.y,covA.z,
|
||
covA.y,covB.x,covB.y,
|
||
covA.z,covB.y,covB.z
|
||
);mat3 J=mat3(
|
||
focal.x/camspace.z,0.,-(focal.x*camspace.x)/(camspace.z*camspace.z),
|
||
0.,focal.y/camspace.z,-(focal.y*camspace.y)/(camspace.z*camspace.z),
|
||
0.,0.,0.
|
||
);mat3 invy=mat3(1,0,0,0,-1,0,0,0,1);mat3 T=invy*transpose(mat3(modelView))*J;mat3 cov2d=transpose(T)*Vrk*T;float mid=(cov2d[0][0]+cov2d[1][1])/2.0;float radius=length(vec2((cov2d[0][0]-cov2d[1][1])/2.0,cov2d[0][1]));float lambda1=mid+radius,lambda2=mid-radius;if (lambda2<0.0) return;vec2 diagonalVector=normalize(vec2(cov2d[0][1],lambda1-cov2d[0][0]));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);vColor=color;vPosition=position;vec2 vCenter=vec2(pos2d);gl_Position=vec4(
|
||
vCenter
|
||
+ (position.x*majorAxis
|
||
+ position.y*minorAxis)*invViewport*pos2d.w,pos2d.zw);
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<logDepthVertex>
|
||
}
|
||
`;var dN=function(r){function t(){var e=r.call(this)||this;return e.FOG=!1,e.THIN_INSTANCES=!0,e.LOGARITHMICDEPTH=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.CLIPPLANE5=!1,e.CLIPPLANE6=!1,e.rebuild(),e}return(0,A.C6)(t,r),t}(si),Hh=function(r){function t(e,n){var i=r.call(this,e,n)||this;return i.backFaceCulling=!1,i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.needAlphaTesting=function(){return!1},t.prototype.needAlphaBlending=function(){return!0},t.prototype.isReadyForSubMesh=function(e,n){var i=!0,o=n._drawWrapper;if(o.effect&&this.isFrozen&&o._wasPreviouslyReady&&o._wasPreviouslyUsingInstances===i)return!0;n.materialDefines||(n.materialDefines=new dN);var a=this.getScene(),s=n.materialDefines;if(this._isReadyForSubMesh(n))return!0;var l=a.getEngine();if((0,Re.fm)(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,!1,s),(0,Re.OR)(a,l,this,s,i,null,!0),(0,Re.qB)(e,s,!1,!1),s.isDirty){s.markAsProcessed(),a.resetCachedMaterial();var c=[Y.R.PositionKind,"splatIndex"];(0,Re.ER)(c,s);var u=["world","view","projection","vFogInfos","vFogColor","logarithmicDepthConstant","invViewport","dataTextureSize","focal"],d=["covariancesATexture","covariancesBTexture","centersTexture","colorsTexture"],h=["Scene","Mesh"];(0,Re.Bb)({uniformsNames:u,uniformBuffersNames:h,samplers:d,defines:s}),(0,tn.TV)(u);var p=s.toString(),m=a.getEngine().createEffect("gaussianSplatting",{attributes:c,uniformsNames:u,uniformBuffersNames:h,samplers:d,defines:p,onCompiled:this.onCompiled,onError:this.onError},l);n.setEffect(m,s,this._materialContext)}return!(!n.effect||!n.effect.isReady()||(s._renderId=a.getRenderId(),o._wasPreviouslyReady=!0,o._wasPreviouslyUsingInstances=i,0))},t.prototype.bindForSubMesh=function(e,n,i){var o,a=this.getScene(),s=i.materialDefines;if(s){var l=i.effect;if(l){if(this._activeEffect=l,n.getMeshUniformBuffer().bindToEffect(l,"Mesh"),n.transferToEffect(e),this._mustRebind(a,l,i,n.visibility)){this.bindView(l),this.bindViewProjection(l);var c=a.getEngine(),u=this.getScene().activeCamera,d=c.getRenderWidth(),h=c.getRenderHeight(),p=((o=u?.rigParent)===null||o===void 0?void 0:o.rigCameras.length)||1;this._activeEffect.setFloat2("invViewport",1/(d/p),1/h);var m=1e3;if(u){var v=u.getProjectionMatrix().m[5];m=u.fovMode==Pt.FOVMODE_VERTICAL_FIXED?h*v/2:d*v/2}this._activeEffect.setFloat2("focal",m,m);var b=n;if(b.covariancesATexture){var E=b.covariancesATexture.getSize();l.setFloat2("dataTextureSize",E.width,E.height),l.setTexture("covariancesATexture",b.covariancesATexture),l.setTexture("covariancesBTexture",b.covariancesBTexture),l.setTexture("centersTexture",b.centersTexture),l.setTexture("colorsTexture",b.colorsTexture)}(0,tn.gS)(l,this,a)}else a.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(0,Re.Yy)(a,n,l),this.useLogarithmicDepth&&(0,Re.DL)(s,l,a),this._afterBind(n,this._activeEffect,i)}}},t.prototype.clone=function(e){var n=this;return tt.p.Clone(function(){return new t(e,n.getScene())},this)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.customType="BABYLON.GaussianSplattingMaterial",e},t.prototype.getClassName=function(){return"GaussianSplattingMaterial"},t.Parse=function(e,n,i){return tt.p.Parse(function(){return new t(e.name,n)},e,n,i)},t}(Ro);(0,j.Y5)("BABYLON.GaussianSplattingMaterial",Hh),Object.defineProperty(qt.prototype,"decalMap",{get:function(){if(!this._decalMap){if(this._uniformBufferLayoutBuilt)return null;this._decalMap=new Rl(this)}return this._decalMap},enumerable:!0,configurable:!0}),Object.defineProperty(Tn.prototype,"decalMap",{get:function(){if(!this._decalMap){if(this._uniformBufferLayoutBuilt)return null;this._decalMap=new Rl(this)}return this._decalMap},enumerable:!0,configurable:!0}),Object.defineProperty(cn.prototype,"decalMap",{get:function(){return this._decalMap},set:function(r){this._decalMap=r},enumerable:!0,configurable:!0});var dC=L(23667),hC=L(84765),fC=L(85588),pC=L(66904),hN=qe.HighestCommonFactor,_C=(0,A.Cl)((0,A.Cl)({},qe),{TwoPi:2*Math.PI,Sign:Math.sign,Log2:Math.log2,HCF:hN}),mC=function(){function r(t,e){this.radius=t,this.theta=e,this.radius=t,this.theta=e}return r.prototype.getClassName=function(){return"Polar"},r.prototype.toString=function(){return JSON.stringify(this)},r.prototype.asArray=function(){return[this.radius,this.theta]},r.prototype.addToRef=function(t,e){return e.radius=this.radius+t.radius,e.theta=this.theta+t.theta,e},r.prototype.add=function(t){var e=new r(0,0);return this.addToRef(t,e),e},r.prototype.addInPlace=function(t){return this.addToRef(t,this),this},r.prototype.addInPlaceFromFloats=function(t,e){return this.radius+=t,this.theta+=e,this},r.prototype.subtractToRef=function(t,e){return e.radius=this.radius-t.radius,e.theta=this.theta-t.theta,e},r.prototype.subtract=function(t){var e=new r(0,0);return this.subtractToRef(t,e),e},r.prototype.subtractInPlace=function(t){return this.subtractToRef(t,this),this},r.prototype.subtractFromFloatsToRef=function(t,e,n){return n.radius=this.radius-t,n.theta=this.theta-e,n},r.prototype.subtractFromFloats=function(t,e){var n=new r(0,0);return this.subtractFromFloatsToRef(t,e,n),n},r.prototype.multiplyToRef=function(t,e){return e.radius=this.radius*t.radius,e.theta=this.theta*t.theta,e},r.prototype.multiply=function(t){var e=new r(0,0);return this.multiplyToRef(t,e),e},r.prototype.multiplyInPlace=function(t){return this.multiplyToRef(t,this),this},r.prototype.divideToRef=function(t,e){return e.radius=this.radius/t.radius,e.theta=this.theta/t.theta,e},r.prototype.divide=function(t){var e=new r(0,0);return this.divideToRef(t,e),e},r.prototype.divideInPlace=function(t){return this.divideToRef(t,this),this},r.prototype.clone=function(){return new r(this.radius,this.theta)},r.prototype.copyFrom=function(t){return this.radius=t.radius,this.theta=t.theta,this},r.prototype.copyFromFloats=function(t,e){return this.radius=t,this.theta=e,this},r.prototype.scaleToRef=function(t,e){return e.radius=this.radius*t,e.theta=this.theta*t,e},r.prototype.scale=function(t){var e=new r(0,0);return this.scaleToRef(t,e),e},r.prototype.scaleInPlace=function(t){return this.scaleToRef(t,this),this},r.prototype.set=function(t,e){return this.radius=t,this.theta=e,this},r.prototype.setAll=function(t){return this.set(t,t),this},r.prototype.toVector2ToRef=function(t){var e=this.radius*Math.cos(this.theta),n=this.radius*Math.sin(this.theta);return t.set(e,n),t},r.prototype.toVector2=function(){var t=new _.I9(0,0);return this.toVector2ToRef(t)},r.FromVector2ToRef=function(t,e){var n=Math.sign(t.y)*Math.acos(t.x/t.length());return e.radius=t.length(),e.theta=n,e},r.FromVector2=function(t){var e=new r(0,0);return r.FromVector2ToRef(t,e),e},r.FromArray=function(t){return new r(t[0],t[1])},r}(),gC=function(){function r(t,e,n){this.radius=t,this.theta=e,this.phi=n,this.radius=t,this.theta=e,this.phi=n}return r.prototype.getClassName=function(){return"Spherical"},r.prototype.toString=function(){return JSON.stringify(this)},r.prototype.asArray=function(){return[this.radius,this.theta,this.phi]},r.prototype.addToRef=function(t,e){return e.radius=this.radius+t.radius,e.theta=this.theta+t.theta,e.phi=this.phi+t.phi,e},r.prototype.add=function(t){var e=new r(0,0,0);return this.addToRef(t,e),e},r.prototype.addInPlace=function(t){return this.addToRef(t,this),this},r.prototype.addInPlaceFromFloats=function(t,e,n){return this.radius+=t,this.theta+=e,this.phi+=n,this},r.prototype.subtractToRef=function(t,e){return e.radius=this.radius-t.radius,e.theta=this.theta-t.theta,e.phi=this.phi-t.phi,e},r.prototype.subtract=function(t){var e=new r(0,0,0);return this.subtractToRef(t,e),e},r.prototype.subtractInPlace=function(t){return this.subtractToRef(t,this),this},r.prototype.subtractFromFloatsToRef=function(t,e,n,i){return i.radius=this.radius-t,i.theta=this.theta-e,i.phi=this.phi-n,i},r.prototype.subtractFromFloats=function(t,e,n){var i=new r(0,0,0);return this.subtractFromFloatsToRef(t,e,n,i),i},r.prototype.multiplyToRef=function(t,e){return e.radius=this.radius*t.radius,e.theta=this.theta*t.theta,e.phi=this.phi*t.phi,e},r.prototype.multiply=function(t){var e=new r(0,0,0);return this.multiplyToRef(t,e),e},r.prototype.multiplyInPlace=function(t){return this.multiplyToRef(t,this),this},r.prototype.divideToRef=function(t,e){return e.radius=this.radius/t.radius,e.theta=this.theta/t.theta,e.phi=this.phi/t.phi,e},r.prototype.divide=function(t){var e=new r(0,0,0);return this.divideToRef(t,e),e},r.prototype.divideInPlace=function(t){return this.divideToRef(t,this),this},r.prototype.clone=function(){return new r(this.radius,this.theta,this.phi)},r.prototype.copyFrom=function(t){return this.radius=t.radius,this.theta=t.theta,this.phi=t.phi,this},r.prototype.copyFromFloats=function(t,e,n){return this.radius=t,this.theta=e,this.phi=n,this},r.prototype.scaleToRef=function(t,e){return e.radius=this.radius*t,e.theta=this.theta*t,e.phi=this.phi*t,e},r.prototype.scale=function(t){var e=new r(0,0,0);return this.scaleToRef(t,e),e},r.prototype.scaleInPlace=function(t){return this.scaleToRef(t,this),this},r.prototype.set=function(t,e,n){return this.radius=t,this.theta=e,this.phi=n,this},r.prototype.setAll=function(t){return this.set(t,t,t),this},r.prototype.toVector3ToRef=function(t){var e=this.radius*Math.sin(this.theta)*Math.cos(this.phi),n=this.radius*Math.cos(this.theta),i=this.radius*Math.sin(this.theta)*Math.sin(this.phi);return t.set(e,n,i),t},r.prototype.toVector3=function(){var t=new _.Pq(0,0,0);return this.toVector3ToRef(t)},r.FromVector3ToRef=function(t,e){return e.radius=t.length(),e.theta=Math.acos(t.y/e.radius),e.phi=Math.atan2(t.z,t.x),e},r.FromVector3=function(t){var e=new r(0,0,0);return r.FromVector3ToRef(t,e),e},r.FromArray=function(t){return new r(t[0],t[1],t[2])},r}(),c0=function(){function r(t,e,n,i,o){e===void 0&&(e=2),n===void 0&&(n=3),i===void 0&&(i=1),o===void 0&&(o=1),this._curIndex=0,this._sequence=[],this._numSamples=0,this.x=0,this.y=0,this._width=i,this._height=o,this._baseX=e,this._baseY=n,this._generateSequence(t),this.next()}return r.prototype.regenerate=function(t){this._generateSequence(t),this.next()},r.prototype.setDimensions=function(t,e){this._width=t,this._height=e},r.prototype.next=function(){this.x=this._sequence[this._curIndex]/this._width,this.y=this._sequence[this._curIndex+1]/this._height,this._curIndex+=2,this._curIndex>=2*this._numSamples&&(this._curIndex=0)},r.prototype._generateSequence=function(t){this._sequence=[],this._curIndex=0,this._numSamples=t;for(var e=1;e<=t;++e)this._sequence.push(this._halton(e,this._baseX)-.5,this._halton(e,this._baseY)-.5)},r.prototype._halton=function(t,e){for(var n=1,i=0;t>0;)i+=(n/=e)*(t%e),t=~~(t/e);return i},r}();function u0(r,t){return"{X: ".concat(r.x.toFixed(t)," Y: ").concat(r.y.toFixed(t),"}")}function d0(r,t){return"{X: ".concat(r._x.toFixed(t)," Y: ").concat(r._y.toFixed(t)," Z: ").concat(r._z.toFixed(t),"}")}function h0(r,t){return"{X: ".concat(r.x.toFixed(t)," Y: ").concat(r.y.toFixed(t)," Z: ").concat(r.z.toFixed(t)," W: ").concat(r.w.toFixed(t),"}")}var Il=L(80244);function f0(r,t,e,n,i){var o=null,a=null,s=null;try{var l;o=new r.Decoder,(a=new r.DecoderBuffer).Init(t,t.byteLength);var c=o.GetEncodedGeometryType(a);switch(c){case r.TRIANGULAR_MESH:var u=new r.Mesh;if(!(l=o.DecodeBufferToMesh(a,u)).ok()||u.ptr===0)throw new Error(l.error_msg());var d=3*u.num_faces(),h=4*d,p=r._malloc(h);try{o.GetTrianglesUInt32Array(u,h,p);var m=new Uint32Array(d);m.set(new Uint32Array(r.HEAPF32.buffer,p,d)),n(m)}finally{r._free(p)}s=u;break;case r.POINT_CLOUD:var v=new r.PointCloud;if(!(l=o.DecodeBufferToPointCloud(a,v)).ok()||!v.ptr)throw new Error(l.error_msg());s=v;break;default:throw new Error("Invalid geometry type ".concat(c))}var b=s.num_points(),E=function(S,y,x,R){var I,M=R.data_type(),D=R.num_components(),B=R.normalized(),F=R.byte_stride(),X=R.byte_offset(),$=((I={})[r.DT_FLOAT32]={typedArrayConstructor:Float32Array,heap:r.HEAPF32},I[r.DT_INT8]={typedArrayConstructor:Int8Array,heap:r.HEAP8},I[r.DT_INT16]={typedArrayConstructor:Int16Array,heap:r.HEAP16},I[r.DT_INT32]={typedArrayConstructor:Int32Array,heap:r.HEAP32},I[r.DT_UINT8]={typedArrayConstructor:Uint8Array,heap:r.HEAPU8},I[r.DT_UINT16]={typedArrayConstructor:Uint16Array,heap:r.HEAPU16},I[r.DT_UINT32]={typedArrayConstructor:Uint32Array,heap:r.HEAPU32},I)[M];if(!$)throw new Error("Invalid data type ".concat(M));var Q=b*D,ie=Q*$.typedArrayConstructor.BYTES_PER_ELEMENT,q=r._malloc(ie);try{S.GetAttributeDataArrayForAllPoints(y,R,M,ie,q);var ee=new $.typedArrayConstructor($.heap.buffer,q,Q);i(x,ee.slice(),D,X,F,B)}finally{r._free(q)}};if(e)for(var C in e){var T=e[C],f=o.GetAttributeByUniqueId(s,T);E(o,s,C,f)}else{var g={position:r.POSITION,normal:r.NORMAL,color:r.COLOR,uv:r.TEX_COORD};for(var C in g)(T=o.GetAttributeId(s,g[C]))!==-1&&(f=o.GetAttribute(s,T),E(o,s,C,f))}return b}finally{s&&r.destroy(s),a&&r.destroy(a),o&&r.destroy(o)}}function fN(){var r;onmessage=function(t){var e=t.data;switch(e.id){case"init":var n=e.decoder;n.url&&importScripts(n.url);var i=n.wasmBinary?{wasmBinary:n.wasmBinary}:{};r=DracoDecoderModule(i),postMessage({id:"initDone"});break;case"decodeMesh":if(!r)throw new Error("Draco decoder module is not available");r.then(function(o){var a=f0(o,e.dataView,e.attributes,function(s){postMessage({id:"indices",data:s},[s.buffer])},function(s,l,c,u,d,h){postMessage({id:"attribute",kind:s,data:l,size:c,byteOffset:u,byteStride:d,normalized:h},[l.buffer])});postMessage({id:"decodeMeshDone",totalVertices:a})})}}}var vC=function(){function r(t){t===void 0&&(t=r.DefaultNumWorkers);var e=this,n=r.Configuration.decoder;if(n.workerPool||typeof t=="object"&&t.workerPool)this._workerPoolPromise=Promise.resolve(n.workerPool||t.workerPool);else{var i=n.wasmBinary||typeof t=="object"&&t.wasmBinary,o=typeof t=="number"?t:t.numWorkers,a=o&&typeof Worker=="function"&&typeof URL=="function",s=a||!a&&!n.jsModule,l=n.wasmUrl&&n.wasmBinaryUrl&&typeof WebAssembly=="object"?{url:s?ze.S0.GetBabylonScriptURL(n.wasmUrl,!0):"",wasmBinaryPromise:i?Promise.resolve(i):ze.S0.LoadFileAsync(ze.S0.GetBabylonScriptURL(n.wasmBinaryUrl,!0))}:{url:s?ze.S0.GetBabylonScriptURL(n.fallbackUrl):"",wasmBinaryPromise:Promise.resolve(void 0)};a?this._workerPoolPromise=l.wasmBinaryPromise.then(function(c){var u="".concat(f0,"(").concat(fN,")()"),d=URL.createObjectURL(new Blob([u],{type:"application/javascript"}));return new Il.h(o,function(){return function(h,p,m){return new Promise(function(v,b){var E=function(f){h.removeEventListener("error",E),h.removeEventListener("message",C),b(f)},C=function(f){f.data.id==="initDone"&&(h.removeEventListener("error",E),h.removeEventListener("message",C),v(h))};if(h.addEventListener("error",E),h.addEventListener("message",C),p){var T=p.slice(0);h.postMessage({id:"init",decoder:{url:m,wasmBinary:T}},[T])}else h.postMessage({id:"init",decoder:{url:m}})})}(new Worker(d),c,l.url)})}):this._decoderModulePromise=l.wasmBinaryPromise.then(function(c){return(0,A.sH)(e,void 0,void 0,function(){return(0,A.YH)(this,function(u){switch(u.label){case 0:if(typeof DracoDecoderModule<"u")return[3,2];if(n.jsModule)return[3,2];if(!l.url)throw new Error("Draco decoder module is not available");return[4,ze.S0.LoadBabylonScriptAsync(l.url)];case 1:u.sent(),u.label=2;case 2:return[4,(d=c,h=n.jsModule,new Promise(function(p){(h||DracoDecoderModule)({wasmBinary:d}).then(function(m){p({module:m})})}))];case 3:return[2,u.sent()]}var d,h})})})}}return Object.defineProperty(r,"DecoderAvailable",{get:function(){var t=r.Configuration.decoder;return!!(t.wasmUrl&&t.wasmBinaryUrl&&typeof WebAssembly=="object"||t.fallbackUrl)},enumerable:!1,configurable:!0}),r.GetDefaultNumWorkers=function(){return typeof navigator=="object"&&navigator.hardwareConcurrency?Math.min(Math.floor(.5*navigator.hardwareConcurrency),4):1},Object.defineProperty(r,"Default",{get:function(){return r._Default||(r._Default=new r),r._Default},enumerable:!1,configurable:!0}),r.ResetDefault=function(t){r._Default&&(t||r._Default.dispose(),r._Default=null)},r.prototype.dispose=function(){this._workerPoolPromise&&this._workerPoolPromise.then(function(t){t.dispose()}),delete this._workerPoolPromise,delete this._decoderModulePromise},r.prototype.whenReadyAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:return this._workerPoolPromise?[4,this._workerPoolPromise]:[3,2];case 1:case 3:return t.sent(),[2];case 2:return this._decoderModulePromise?[4,this._decoderModulePromise]:[3,4];case 4:return[2]}})})},r.prototype.decodeMeshToMeshDataAsync=function(t,e,n){var i=t instanceof ArrayBuffer?new Int8Array(t):new Int8Array(t.buffer,t.byteOffset,t.byteLength);if(this._workerPoolPromise)return this._workerPoolPromise.then(function(o){return new Promise(function(a,s){o.push(function(l,c){var u=null,d=[],h=function(v){l.removeEventListener("error",h),l.removeEventListener("message",p),s(v),c()},p=function(v){var b,E,C=v.data;switch(C.id){case"decodeMeshDone":l.removeEventListener("error",h),l.removeEventListener("message",p),a({indices:u,attributes:d,totalVertices:C.totalVertices}),c();break;case"indices":u=C.data;break;case"attribute":d.push({kind:C.kind,data:C.data,size:C.size,byteOffset:C.byteOffset,byteStride:C.byteStride,normalized:(b=C.kind,E=C.normalized,n&&n[b]!==void 0?(E!==n[b]&&O.V.Warn("Normalized flag from Draco data (".concat(E,") does not match normalized flag from glTF accessor (").concat(n[b],"). Using flag from glTF accessor.")),n[b]):E)})}};l.addEventListener("error",h),l.addEventListener("message",p);var m=i.slice();l.postMessage({id:"decodeMesh",dataView:m,attributes:e},[m.buffer])})})});if(this._decoderModulePromise)return this._decoderModulePromise.then(function(o){var a=null,s=[],l=f0(o.module,i,e,function(c){a=c},function(c,u,d,h,p,m){s.push({kind:c,data:u,size:d,byteOffset:h,byteStride:p,normalized:m})});return{indices:a,attributes:s,totalVertices:l}});throw new Error("Draco decoder module is not available")},r.prototype.decodeMeshToGeometryAsync=function(t,e,n,i){return(0,A.sH)(this,void 0,void 0,function(){var o,a,s,l,c;return(0,A.YH)(this,function(u){switch(u.label){case 0:return[4,this.decodeMeshToMeshDataAsync(n,i)];case 1:for(o=u.sent(),a=new Vi(t,e),o.indices&&a.setIndices(o.indices),s=0,l=o.attributes;s<l.length;s++)c=l[s],a.setVerticesBuffer(new Y.R(e.getEngine(),c.data,c.kind,!1,void 0,c.byteStride,void 0,c.byteOffset,c.size,void 0,c.normalized,!0),o.totalVertices);return[2,a]}})})},r.prototype._decodeMeshToGeometryForGltfAsync=function(t,e,n,i,o){return(0,A.sH)(this,void 0,void 0,function(){var a,s,l,c,u;return(0,A.YH)(this,function(d){switch(d.label){case 0:return[4,this.decodeMeshToMeshDataAsync(n,i,o)];case 1:for(a=d.sent(),s=new Vi(t,e),a.indices&&s.setIndices(a.indices),l=0,c=a.attributes;l<c.length;l++)u=c[l],s.setVerticesBuffer(new Y.R(e.getEngine(),u.data,u.kind,!1,void 0,u.byteStride,void 0,u.byteOffset,u.size,void 0,u.normalized,!0),a.totalVertices);return[2,s]}})})},r.prototype.decodeMeshAsync=function(t,e){return(0,A.sH)(this,void 0,void 0,function(){var n,i,o,a,s,l;return(0,A.YH)(this,function(c){switch(c.label){case 0:return[4,this.decodeMeshToMeshDataAsync(t,e)];case 1:for(n=c.sent(),i=new rt,n.indices&&(i.indices=n.indices),o=0,a=n.attributes;o<a.length;o++)s=a[o],l=Y.R.GetFloatData(s.data,s.size,Y.R.GetDataType(s.data),s.byteOffset,s.byteStride,s.normalized,n.totalVertices),i.set(l,s.kind);return[2,i]}})})},r.Configuration={decoder:{wasmUrl:"".concat(ze.S0._DefaultCdnUrl,"/draco_wasm_wrapper_gltf.js"),wasmBinaryUrl:"".concat(ze.S0._DefaultCdnUrl,"/draco_decoder_gltf.wasm"),fallbackUrl:"".concat(ze.S0._DefaultCdnUrl,"/draco_decoder_gltf.js")}},r.DefaultNumWorkers=r.GetDefaultNumWorkers(),r._Default=null,r}(),yC=function(){function r(){var t=r.Configuration.decoder;this._decoderModulePromise=ze.S0.LoadBabylonScriptAsync(t.url).then(function(){return MeshoptDecoder.ready})}return Object.defineProperty(r,"Default",{get:function(){return r._Default||(r._Default=new r),r._Default},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){delete this._decoderModulePromise},r.prototype.decodeGltfBufferAsync=function(t,e,n,i,o){var a=this;return this._decoderModulePromise.then(function(){return(0,A.sH)(a,void 0,void 0,function(){var s;return(0,A.YH)(this,function(l){switch(l.label){case 0:return MeshoptDecoder.useWorkers(1),[4,MeshoptDecoder.decodeGltfBufferAsync(e,n,t,i,o)];case 1:return s=l.sent(),MeshoptDecoder.useWorkers(0),[2,s]}})})})},r.Configuration={decoder:{url:"".concat(ze.S0._DefaultCdnUrl,"/meshopt_decoder.js")}},r._Default=null,r}(),Yh=0,bC=function(){function r(t,e,n,i){this.pos=t,this.normal=e,this.uv=n,this.vertColor=i}return r.prototype.clone=function(){var t,e;return new r(this.pos.clone(),this.normal.clone(),(t=this.uv)===null||t===void 0?void 0:t.clone(),(e=this.vertColor)===null||e===void 0?void 0:e.clone())},r.prototype.flip=function(){this.normal=this.normal.scale(-1)},r.prototype.interpolate=function(t,e){return new r(_.Pq.Lerp(this.pos,t.pos,e),_.Pq.Lerp(this.normal,t.normal,e),this.uv&&t.uv?_.I9.Lerp(this.uv,t.uv,e):void 0,this.vertColor&&t.vertColor?z.ov.Lerp(this.vertColor,t.vertColor,e):void 0)},r}(),pN=function(){function r(t,e){this.normal=t,this.w=e}return r.FromPoints=function(t,e,n){var i=n.subtract(t),o=e.subtract(t);if(i.lengthSquared()===0||o.lengthSquared()===0)return null;var a=_.Pq.Normalize(_.Pq.Cross(i,o));return new r(a,_.Pq.Dot(a,t))},r.prototype.clone=function(){return new r(this.normal.clone(),this.w)},r.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},r.prototype.splitPolygon=function(t,e,n,i,o){var a,s,l=0,c=[];for(a=0;a<t.vertices.length;a++){var u=(s=_.Pq.Dot(this.normal,t.vertices[a].pos)-this.w)<-r.EPSILON?2:s>r.EPSILON?1:0;l|=u,c.push(u)}switch(l){case 0:(_.Pq.Dot(this.normal,t.plane.normal)>0?e:n).push(t);break;case 1:i.push(t);break;case 2:o.push(t);break;case 3:var d=[],h=[];for(a=0;a<t.vertices.length;a++){var p=(a+1)%t.vertices.length,m=c[a],v=c[p],b=t.vertices[a],E=t.vertices[p];if(m!==2&&d.push(b),m!==1&&h.push(m!==2?b.clone():b),(m|v)==3){s=(this.w-_.Pq.Dot(this.normal,b.pos))/_.Pq.Dot(this.normal,E.pos.subtract(b.pos));var C=b.interpolate(E,s);d.push(C),h.push(C.clone())}}var T=void 0;d.length>=3&&(T=new Xh(d,t.shared)).plane&&i.push(T),h.length>=3&&(T=new Xh(h,t.shared)).plane&&o.push(T)}},r.EPSILON=1e-5,r}(),Xh=function(){function r(t,e){this.vertices=t,this.shared=e,this.plane=pN.FromPoints(t[0].pos,t[1].pos,t[2].pos)}return r.prototype.clone=function(){return new r(this.vertices.map(function(t){return t.clone()}),this.shared)},r.prototype.flip=function(){this.vertices.reverse().map(function(t){t.flip()}),this.plane.flip()},r}(),Pr=function(){function r(t){this._plane=null,this._front=null,this._back=null,this._polygons=new Array,t&&this.build(t)}return r.prototype.clone=function(){var t=new r;return t._plane=this._plane&&this._plane.clone(),t._front=this._front&&this._front.clone(),t._back=this._back&&this._back.clone(),t._polygons=this._polygons.map(function(e){return e.clone()}),t},r.prototype.invert=function(){for(var t=0;t<this._polygons.length;t++)this._polygons[t].flip();this._plane&&this._plane.flip(),this._front&&this._front.invert(),this._back&&this._back.invert();var e=this._front;this._front=this._back,this._back=e},r.prototype.clipPolygons=function(t){if(!this._plane)return t.slice();for(var e=[],n=[],i=0;i<t.length;i++)this._plane.splitPolygon(t[i],e,n,e,n);return this._front&&(e=this._front.clipPolygons(e)),n=this._back?this._back.clipPolygons(n):[],e.concat(n)},r.prototype.clipTo=function(t){this._polygons=t.clipPolygons(this._polygons),this._front&&this._front.clipTo(t),this._back&&this._back.clipTo(t)},r.prototype.allPolygons=function(){var t=this._polygons.slice();return this._front&&(t=t.concat(this._front.allPolygons())),this._back&&(t=t.concat(this._back.allPolygons())),t},r.prototype.build=function(t){if(t.length){this._plane||(this._plane=t[0].plane.clone());for(var e=[],n=[],i=0;i<t.length;i++)this._plane.splitPolygon(t[i],this._polygons,this._polygons,e,n);e.length&&(this._front||(this._front=new r),this._front.build(e)),n.length&&(this._back||(this._back=new r),this._back.build(n))}},r}(),jh=function(){function r(){this._polygons=new Array}return r.FromVertexData=function(t){var e,n,i,o=[],a=t.indices,s=t.positions,l=t.normals,c=t.uvs,u=t.colors;if(!a||!s)throw"BABYLON.CSG: VertexData must at least contain positions and indices";for(var d=0;d<a.length;d+=3){i=[];for(var h=0;h<3;h++){var p=a[d+h],m=l?_.Pq.FromArray(l,3*p):_.Pq.Zero(),v=c?_.I9.FromArray(c,2*p):void 0,b=u?z.ov.FromArray(u,4*p):void 0,E=_.Pq.FromArray(s,3*p);e=new bC(E,m,v,b),i.push(e)}(n=new Xh(i,{subMeshId:0,meshId:Yh,materialIndex:0})).plane&&o.push(n)}var C=r._FromPolygons(o);return C.matrix=_.uq.Identity(),C.position=_.Pq.Zero(),C.rotation=_.Pq.Zero(),C.scaling=_.Pq.One(),C.rotationQuaternion=_.PT.Identity(),Yh++,C},r.FromMesh=function(t,e){e===void 0&&(e=!1);var n,i,o,a,s,l,c,u,d,h=void 0,p=void 0,m=[],v=null,b=!1;if(!(t instanceof xe))throw"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";t.computeWorldMatrix(!0),l=t.getWorldMatrix(),c=t.position.clone(),u=t.rotation.clone(),t.rotationQuaternion&&(v=t.rotationQuaternion.clone()),d=t.scaling.clone(),t.material&&e&&(b=t.material.sideOrientation===P.Y.MATERIAL_ClockWiseSideOrientation);var E=t.getIndices(),C=t.getVerticesData(Y.R.PositionKind),T=t.getVerticesData(Y.R.NormalKind),f=t.getVerticesData(Y.R.UVKind),g=t.getVerticesData(Y.R.ColorKind);if(E===null)throw"BABYLON.CSG: Mesh has no indices";if(C===null)throw"BABYLON.CSG: Mesh has no positions";if(T===null)throw"BABYLON.CSG: Mesh has no normals";for(var S=t.subMeshes,y=0,x=S.length;y<x;y++)for(var R=S[y].indexStart,I=S[y].indexCount+S[y].indexStart;R<I;R+=3){s=[];for(var M=0;M<3;M++){var D=M===0?R+M:b?R+3-M:R+M,B=new _.Pq(T[3*E[D]],T[3*E[D]+1],T[3*E[D]+2]);f&&(h=new _.I9(f[2*E[D]],f[2*E[D]+1])),g&&(p=new z.ov(g[4*E[D]],g[4*E[D]+1],g[4*E[D]+2],g[4*E[D]+3]));var F=new _.Pq(C[3*E[D]],C[3*E[D]+1],C[3*E[D]+2]);o=_.Pq.TransformCoordinates(F,l),i=_.Pq.TransformNormal(B,l),n=new bC(o,i,h,p),s.push(n)}(a=new Xh(s,{subMeshId:y,meshId:Yh,materialIndex:S[y].materialIndex})).plane&&m.push(a)}var X=r._FromPolygons(m);return X.matrix=e?_.uq.Identity():l,X.position=e?_.Pq.Zero():c,X.rotation=e?_.Pq.Zero():u,X.scaling=e?_.Pq.One():d,X.rotationQuaternion=e&&v?_.PT.Identity():v,Yh++,X},r._FromPolygons=function(t){var e=new r;return e._polygons=t,e},r.prototype.clone=function(){var t=new r;return t._polygons=this._polygons.map(function(e){return e.clone()}),t.copyTransformAttributes(this),t},r.prototype.union=function(t){var e=new Pr(this.clone()._polygons),n=new Pr(t.clone()._polygons);return e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),r._FromPolygons(e.allPolygons()).copyTransformAttributes(this)},r.prototype.unionInPlace=function(t){var e=new Pr(this._polygons),n=new Pr(t._polygons);e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),this._polygons=e.allPolygons()},r.prototype.subtract=function(t){var e=new Pr(this.clone()._polygons),n=new Pr(t.clone()._polygons);return e.invert(),e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),e.invert(),r._FromPolygons(e.allPolygons()).copyTransformAttributes(this)},r.prototype.subtractInPlace=function(t){var e=new Pr(this._polygons),n=new Pr(t._polygons);e.invert(),e.clipTo(n),n.clipTo(e),n.invert(),n.clipTo(e),n.invert(),e.build(n.allPolygons()),e.invert(),this._polygons=e.allPolygons()},r.prototype.intersect=function(t){var e=new Pr(this.clone()._polygons),n=new Pr(t.clone()._polygons);return e.invert(),n.clipTo(e),n.invert(),e.clipTo(n),n.clipTo(e),e.build(n.allPolygons()),e.invert(),r._FromPolygons(e.allPolygons()).copyTransformAttributes(this)},r.prototype.intersectInPlace=function(t){var e=new Pr(this._polygons),n=new Pr(t._polygons);e.invert(),n.clipTo(e),n.invert(),e.clipTo(n),n.clipTo(e),e.build(n.allPolygons()),e.invert(),this._polygons=e.allPolygons()},r.prototype.inverse=function(){var t=this.clone();return t.inverseInPlace(),t},r.prototype.inverseInPlace=function(){this._polygons.map(function(t){t.flip()})},r.prototype.copyTransformAttributes=function(t){return this.matrix=t.matrix,this.position=t.position,this.rotation=t.rotation,this.scaling=t.scaling,this.rotationQuaternion=t.rotationQuaternion,this},r.prototype.toVertexData=function(t,e){t===void 0&&(t=null),e===void 0&&(e=null);var n=this.matrix.clone();n.invert();for(var i,o=this._polygons,a=[],s=[],l=[],c=null,u=null,d=_.Pq.Zero(),h=_.Pq.Zero(),p=_.I9.Zero(),m=new z.ov(0,0,0,0),v=[0,0,0],b={},E=0,C=o.length;E<C;E++){var T=o[E];t&&t(T);for(var f=2,g=T.vertices.length;f<g;f++){v[0]=0,v[1]=f-1,v[2]=f;for(var S=0;S<3;S++){d.copyFrom(T.vertices[v[S]].pos),h.copyFrom(T.vertices[v[S]].normal),T.vertices[v[S]].uv&&(c||(c=[]),p.copyFrom(T.vertices[v[S]].uv)),T.vertices[v[S]].vertColor&&(u||(u=[]),m.copyFrom(T.vertices[v[S]].vertColor));var y=_.Pq.TransformCoordinates(d,n),x=_.Pq.TransformNormal(h,n);i=b[y.x+","+y.y+","+y.z];var R=!1;c&&c[2*i]!==p.x&&c[2*i+1]!==p.y&&(R=!0);var I=!1;u&&u[4*i]!==m.r&&u[4*i+1]!==m.g&&u[4*i+2]!==m.b&&u[4*i+3]!==m.a&&(I=!0),(i===void 0||l[3*i]!==x.x||l[3*i+1]!==x.y||l[3*i+2]!==x.z||R||I)&&(a.push(y.x,y.y,y.z),c&&c.push(p.x,p.y),l.push(h.x,h.y,h.z),u&&u.push(m.r,m.g,m.b,m.a),i=b[y.x+","+y.y+","+y.z]=a.length/3-1),s.push(i),e&&e()}}}var M=new rt;return M.positions=a,M.normals=l,c&&(M.uvs=c),u&&(M.colors=u),M.indices=s,M},r.prototype.buildMeshGeometry=function(t,e,n){var i,o=new xe(t,e),a=this._polygons,s=0,l={};if(n&&a.sort(function(p,m){return p.shared.meshId===m.shared.meshId?p.shared.subMeshId-m.shared.subMeshId:p.shared.meshId-m.shared.meshId}),this.toVertexData(function(p){l[p.shared.meshId]||(l[p.shared.meshId]={}),l[p.shared.meshId][p.shared.subMeshId]||(l[p.shared.meshId][p.shared.subMeshId]={indexStart:1/0,indexEnd:-1/0,materialIndex:p.shared.materialIndex}),i=l[p.shared.meshId][p.shared.subMeshId]},function(){i.indexStart=Math.min(s,i.indexStart),i.indexEnd=Math.max(s,i.indexEnd),s++}).applyToMesh(o),n){var c=0,u=void 0;for(var d in o.subMeshes=[],l){for(var h in u=-1,l[d])i=l[d][h],yi.CreateFromIndices(i.materialIndex+c,i.indexStart,i.indexEnd-i.indexStart+1,o),u=Math.max(i.materialIndex,u);c+=++u}}return o},r.prototype.toMesh=function(t,e,n,i){e===void 0&&(e=null);var o=this.buildMeshGeometry(t,n,i);return o.material=e,o.position.copyFrom(this.position),o.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(o.rotationQuaternion=this.rotationQuaternion.clone()),o.scaling.copyFrom(this.scaling),o.computeWorldMatrix(!0),o},r}(),TC=function(){function r(t,e,n){this._textureCreatedInternally=!1,this._configureUserCreatedTexture=!0,this._maskTexture=null,this._finalPostProcess=null,this._shadersLoaded=!1,this._isDisposed=!1,this.clearColor=new z.ov(0,0,0,0),this.texture=null,this._shaderLanguage=0,this._mesh=t,this._scene=e,this._options=(0,A.Cl)({width:1024,height:1024,textureType:P.Y.TEXTURETYPE_UNSIGNED_BYTE,generateMipMaps:!0,optimizeUVAllocation:!0,uvEdgeBlending:!1},n),this._initShaderSourceAsync()}return r._GetShader=function(t,e){if(!t._meshUVSpaceRendererShader){var n=new pi("meshUVSpaceRendererShader",t,{vertex:"meshUVSpaceRenderer",fragment:"meshUVSpaceRenderer"},{attributes:["position","normal","uv"],uniforms:["world","projMatrix"],samplers:["textureSampler"],needAlphaBlending:!0,shaderLanguage:e});n.backFaceCulling=!1,n.alphaMode=P.Y.ALPHA_COMBINE,t.onDisposeObservable.add(function(){var i;(i=t._meshUVSpaceRendererShader)===null||i===void 0||i.dispose(),t._meshUVSpaceRendererShader=null}),t._meshUVSpaceRendererShader=n}return t._meshUVSpaceRendererShader},r._GetMaskShader=function(t,e){if(!t._meshUVSpaceRendererMaskShader){var n=new pi("meshUVSpaceRendererMaskShader",t,{vertex:"meshUVSpaceRendererMasker",fragment:"meshUVSpaceRendererMasker"},{attributes:["position","uv"],uniforms:["worldViewProjection"],shaderLanguage:e});n.backFaceCulling=!1,n.alphaMode=P.Y.ALPHA_COMBINE,t.onDisposeObservable.add(function(){var i;(i=t._meshUVSpaceRendererMaskShader)===null||i===void 0||i.dispose(),t._meshUVSpaceRendererMaskShader=null}),t._meshUVSpaceRendererMaskShader=n}return t._meshUVSpaceRendererMaskShader},r._IsRenderTargetTexture=function(t){return t.renderList!==void 0},Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._initShaderSourceAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:return this._scene.getEngine().isWebGPU?(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,12436)),Promise.resolve().then(L.bind(L,40002)),Promise.resolve().then(L.bind(L,39721)),Promise.resolve().then(L.bind(L,55139)),Promise.resolve().then(L.bind(L,583)),Promise.resolve().then(L.bind(L,42769))])]):[3,2];case 1:return t.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,34855)),Promise.resolve().then(L.bind(L,69425)),Promise.resolve().then(L.bind(L,86254)),Promise.resolve().then(L.bind(L,30004)),Promise.resolve().then(L.bind(L,7726)),Promise.resolve().then(L.bind(L,79444))])];case 3:t.sent(),t.label=4;case 4:return this._isDisposed||(this._shadersLoaded=!0,this._createDiffuseRTT()),[2]}})})},r.prototype.isReady=function(){var t,e,n,i;if(!this._shadersLoaded)return!1;this.texture||this._createDiffuseRTT();var o=r._IsRenderTargetTexture(this.texture)?this.texture.isReadyForRendering():this.texture.isReady(),a=(e=(t=this._maskTexture)===null||t===void 0?void 0:t.isReadyForRendering())===null||e===void 0||e,s=(i=(n=this._finalPostProcess)===null||n===void 0?void 0:n.isReady())===null||i===void 0||i;return o&&a&&s},r.prototype.renderTexture=function(t,e,n,i,o){if(o===void 0&&(o=0),this.texture?this._configureUserCreatedTexture&&this._configureUserCreatedRTT():this._createDiffuseRTT(),r._IsRenderTargetTexture(this.texture)){var a=this._createProjectionMatrix(e,n,i,o),s=r._GetShader(this._scene,this._shaderLanguage);s.setTexture("textureSampler",t),s.setMatrix("projMatrix",a),this.texture.render()}},r.prototype.clear=function(){var t,e,n,i;this.texture&&r._IsRenderTargetTexture(this.texture)&&this.texture.renderTarget&&((i=this._scene.getEngine()).bindFramebuffer(this.texture.renderTarget),i.clear(this.clearColor,!0,!0,!0),i.unBindFramebuffer(this.texture.renderTarget)),!((t=this._finalPostProcess)===null||t===void 0)&&t.inputTexture&&((i=this._scene.getEngine()).bindFramebuffer((e=this._finalPostProcess)===null||e===void 0?void 0:e.inputTexture),i.clear(this.clearColor,!0,!0,!0),i.unBindFramebuffer((n=this._finalPostProcess)===null||n===void 0?void 0:n.inputTexture))},r.prototype.dispose=function(){var t,e,n;this._textureCreatedInternally&&((t=this.texture)===null||t===void 0||t.dispose(),this._textureCreatedInternally=!1),this._configureUserCreatedTexture=!0,(e=this._maskTexture)===null||e===void 0||e.dispose(),this._maskTexture=null,(n=this._finalPostProcess)===null||n===void 0||n.dispose(),this._finalPostProcess=null,this._isDisposed=!0},r.prototype._configureUserCreatedRTT=function(){this._configureUserCreatedTexture=!1,this.texture&&r._IsRenderTargetTexture(this.texture)&&(this.texture.setMaterialForRendering(this._mesh,r._GetShader(this._scene,this._shaderLanguage)),this.texture.onClearObservable.add(function(){}),this.texture.renderList=[this._mesh],this._options.uvEdgeBlending&&(this._createMaskTexture(),this._createPostProcess(),this.texture.addPostProcess(this._finalPostProcess)))},r.prototype._createDiffuseRTT=function(){this._textureCreatedInternally=!0;var t=this._createRenderTargetTexture(this._options.width,this._options.height);t.setMaterialForRendering(this._mesh,r._GetShader(this._scene,this._shaderLanguage)),this.texture=t,this._configureUserCreatedTexture=!1,this._options.uvEdgeBlending&&(this._createMaskTexture(),this._createPostProcess(),t.addPostProcess(this._finalPostProcess))},r.prototype._createMaskTexture=function(){this._maskTexture||(this._maskTexture=new un.$(this._mesh.name+"_maskTexture",{width:this._options.width,height:this._options.height},this._scene,!1,!0,P.Y.TEXTURETYPE_UNSIGNED_BYTE,!1,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,void 0,void 0,void 0,P.Y.TEXTUREFORMAT_R),this._maskTexture.clearColor=new z.ov(0,0,0,0),this._maskTexture.renderList.push(this._mesh),this._maskTexture.setMaterialForRendering(this._mesh,r._GetMaskShader(this._scene,this._shaderLanguage)),this._maskTexture.refreshRate=un.$.REFRESHRATE_RENDER_ONCE,this._scene.customRenderTargets.push(this._maskTexture))},r.prototype._createPostProcess=function(){var t=this;this._finalPostProcess||(this._finalPostProcess=new _t.w(this._mesh.name+"_fixSeamsPostProcess","meshUVSpaceRendererFinaliser",["textureSize"],["textureSampler","maskTextureSampler"],1,null,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,this._scene.getEngine(),!1,null,this._options.textureType,void 0,void 0,void 0,void 0,this._shaderLanguage),this._finalPostProcess.onApplyObservable.add(function(e){e.setTexture("maskTextureSampler",t._maskTexture),e.setFloat2("textureSize",t._options.width,t._options.height)}))},r.prototype._createRenderTargetTexture=function(t,e){var n=this,i=new un.$(this._mesh.name+"_uvspaceTexture",{width:t,height:e},this._scene,this._options.generateMipMaps,!0,this._options.textureType,!1,this._options.generateMipMaps?P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,!1,!1,!1,P.Y.TEXTUREFORMAT_RGBA);return i.renderParticles=!1,i.optimizeUVAllocation=!!this._options.optimizeUVAllocation,i.onClearObservable.addOnce(function(){n._scene.getEngine().clear(n.clearColor,!0,!0,!0),i.onClearObservable.add(function(){})}),i.renderList=[this._mesh],i},r.prototype._createProjectionMatrix=function(t,e,n,i){i===void 0&&(i=0);var o=-Math.atan2(e.z,e.x)-Math.PI/2,a=Math.sqrt(e.x*e.x+e.z*e.z),s=Math.atan2(e.y,a),l=t.add(e.scale(.5*n.z)),c=_.uq.RotationYawPitchRoll(o,s,i).multiply(_.uq.Translation(l.x,l.y,l.z)),u=_.uq.Invert(c),d=_.uq.FromArray([2/n.x,0,0,0,0,2/n.y,0,0,0,0,1/n.z,0,0,0,0,1]),h=_.uq.FromArray([.5,0,0,0,0,.5,0,0,0,0,1,0,.5,.5,0,1]);return u.multiply(d).multiply(h)},r}();xe._TrailMeshParser=function(r,t){return p0.Parse(r,t)};var qh,p0=function(r){function t(e,n,i,o,a,s){a===void 0&&(a=60),s===void 0&&(s=!0);var l=r.call(this,e,i)||this;l._sectionPolygonPointsCount=4,l._running=!1,l._generator=n,typeof o=="object"&&o!==null?(l.diameter=o.diameter||1,l._length=o.length||60,l._segments=o.segments?o.segments>l._length?l._length:o.segments:l._length,l._sectionPolygonPointsCount=o.sections||4,l._doNotTaper=o.doNotTaper||!1,l._autoStart=o.autoStart||!0):(l.diameter=o||1,l._length=a,l._segments=l._length,l._doNotTaper=!1,l._autoStart=s),l._sectionVectors=[],l._sectionNormalVectors=[];for(var c=0;c<=l._sectionPolygonPointsCount;c++)l._sectionVectors[c]=_.Pq.Zero(),l._sectionNormalVectors[c]=_.Pq.Zero();return l._createMesh(),l}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TrailMesh"},t.prototype._createMesh=function(){var e=new rt,n=[],i=[],o=[],a=[],s=_.Pq.Zero();s=this._generator instanceof cn&&this._generator.hasBoundingInfo?this._generator.getBoundingInfo().boundingBox.centerWorld:this._generator.absolutePosition;for(var l=2*Math.PI/this._sectionPolygonPointsCount,c=0;c<=this._sectionPolygonPointsCount;c++){var u=c!==this._sectionPolygonPointsCount?c*l:0;n.push(s.x+Math.cos(u)*this.diameter,s.y+Math.sin(u)*this.diameter,s.z),a.push(c/this._sectionPolygonPointsCount,0)}for(c=1;c<=this._segments;c++){for(var d=0;d<=this._sectionPolygonPointsCount;d++)u=d!==this._sectionPolygonPointsCount?d*l:0,n.push(s.x+Math.cos(u)*this.diameter,s.y+Math.sin(u)*this.diameter,s.z),a.push(d/this._sectionPolygonPointsCount,c/this._segments);var h=n.length/3-2*(this._sectionPolygonPointsCount+1);for(d=0;d<=this._sectionPolygonPointsCount;d++)o.push(h+d,h+d+this._sectionPolygonPointsCount,h+d+this._sectionPolygonPointsCount+1),o.push(h+d,h+d+this._sectionPolygonPointsCount+1,h+d+1)}rt.ComputeNormals(n,o,i),e.positions=n,e.normals=i,e.indices=o,e.uvs=a,e.applyToMesh(this,!0),this._autoStart&&this.start()},t.prototype._updateSectionVectors=function(){for(var e=this._generator.getWorldMatrix(),n=2*Math.PI/this._sectionPolygonPointsCount,i=0;i<=this._sectionPolygonPointsCount;i++){var o=i!==this._sectionPolygonPointsCount?i*n:0;this._sectionVectors[i].copyFromFloats(Math.cos(o)*this.diameter,Math.sin(o)*this.diameter,0),this._sectionNormalVectors[i].copyFromFloats(Math.cos(o),Math.sin(o),0),_.Pq.TransformCoordinatesToRef(this._sectionVectors[i],e,this._sectionVectors[i]),_.Pq.TransformNormalToRef(this._sectionNormalVectors[i],e,this._sectionNormalVectors[i])}},t.prototype.start=function(){var e=this;this._running||(this._running=!0,this._beforeRenderObserver=this.getScene().onBeforeRenderObservable.add(function(){e.update()}))},t.prototype.stop=function(){this._beforeRenderObserver&&this._running&&(this._running=!1,this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver))},t.prototype.update=function(){var e=this.getVerticesData(Y.R.PositionKind),n=this.getVerticesData(Y.R.NormalKind),i=3*(this._sectionPolygonPointsCount+1);if(e&&n){if(this._doNotTaper)for(var o=i;o<e.length;o++)e[o-i]=(0,qe.Lerp)(e[o-i],e[o],this._segments/this._length);else for(o=i;o<e.length;o++)e[o-i]=(0,qe.Lerp)(e[o-i],e[o],this._segments/this._length)-n[o]/this._length*this.diameter;for(o=i;o<n.length;o++)n[o-i]=(0,qe.Lerp)(n[o-i],n[o],this._segments/this._length);this._updateSectionVectors();var a=e.length-3*(this._sectionPolygonPointsCount+1);for(o=0;o<=this._sectionPolygonPointsCount;o++)e[a+3*o]=this._sectionVectors[o].x,e[a+3*o+1]=this._sectionVectors[o].y,e[a+3*o+2]=this._sectionVectors[o].z,n[a+3*o]=this._sectionNormalVectors[o].x,n[a+3*o+1]=this._sectionNormalVectors[o].y,n[a+3*o+2]=this._sectionNormalVectors[o].z;this.updateVerticesData(Y.R.PositionKind,e,!0,!1),this.updateVerticesData(Y.R.NormalKind,n,!0,!1)}},t.prototype.reset=function(){var e=this.getVerticesData(Y.R.PositionKind),n=this.getVerticesData(Y.R.NormalKind);if(e&&n){this._updateSectionVectors();for(var i=0;i<=this._segments;i++)for(var o=3*i*(this._sectionPolygonPointsCount+1),a=0;a<=this._sectionPolygonPointsCount;a++)e[o+3*a]=this._sectionVectors[a].x,e[o+3*a+1]=this._sectionVectors[a].y,e[o+3*a+2]=this._sectionVectors[a].z,n[o+3*a]=this._sectionNormalVectors[a].x,n[o+3*a+1]=this._sectionNormalVectors[a].y,n[o+3*a+2]=this._sectionNormalVectors[a].z;this.updateVerticesData(Y.R.PositionKind,e,!0,!1),this.updateVerticesData(Y.R.NormalKind,n,!0,!1)}},t.prototype.clone=function(e,n){e===void 0&&(e="");var i={diameter:this.diameter,length:this._length,segments:this._segments,sections:this._sectionPolygonPointsCount,doNotTaper:this._doNotTaper,autoStart:this._autoStart};return new t(e,n??this._generator,this.getScene(),i)},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.generatorId=this._generator.id},t.Parse=function(e,n){var i,o,a=(i=n.getLastMeshById(e.generatorId))!==null&&i!==void 0?i:n.getLastTransformNodeById(e.generatorId);if(!a)throw new Error("TrailMesh: generator not found with ID "+e.generatorId);var s={diameter:(o=e.diameter)!==null&&o!==void 0?o:e._diameter,length:e._length,segments:e._segments,sections:e._sectionPolygonPointsCount,doNotTaper:e._doNotTaper,autoStart:e._autoStart};return new t(e.name,a,n,s)},t}(xe),SC=function(r,t,e){this.quality=r,this.distance=t,this.optimizeMesh=e},_0=function(){function r(){this.running=!1,this._simplificationArray=[]}return r.prototype.addTask=function(t){this._simplificationArray.push(t)},r.prototype.executeNext=function(){var t=this._simplificationArray.pop();t?(this.running=!0,this.runSimplification(t)):this.running=!1},r.prototype.runSimplification=function(t){var e=this;if(t.parallelProcessing)t.settings.forEach(function(i){e._getSimplifier(t).simplify(i,function(o){i.distance!==void 0&&t.mesh.addLODLevel(i.distance,o),o.isVisible=!0,i.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),e.executeNext()})});else{var n=this._getSimplifier(t);ze.LV.Run(t.settings.length,function(i){var o,a;o=t.settings[i.index],a=function(){i.executeNext()},n.simplify(o,function(s){o.distance!==void 0&&t.mesh.addLODLevel(o.distance,s),s.isVisible=!0,a()})},function(){t.successCallback&&t.successCallback(),e.executeNext()})}},r.prototype._getSimplifier=function(t){return t.simplificationType,new m0(t.mesh)},r}();(function(r){r[r.QUADRATIC=0]="QUADRATIC"})(qh||(qh={}));var _N=function(r){this._vertices=r,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0},mN=function(){function r(t,e){this.position=t,this.id=e,this.isBorder=!0,this.q=new EC,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return r.prototype.updatePosition=function(t){this.position.copyFrom(t)},r}(),EC=function(){function r(t){this.data=new Array(10);for(var e=0;e<10;++e)t&&t[e]?this.data[e]=t[e]:this.data[e]=0}return r.prototype.det=function(t,e,n,i,o,a,s,l,c){return this.data[t]*this.data[o]*this.data[c]+this.data[n]*this.data[i]*this.data[l]+this.data[e]*this.data[a]*this.data[s]-this.data[n]*this.data[o]*this.data[s]-this.data[t]*this.data[a]*this.data[l]-this.data[e]*this.data[i]*this.data[c]},r.prototype.addInPlace=function(t){for(var e=0;e<10;++e)this.data[e]+=t.data[e]},r.prototype.addArrayInPlace=function(t){for(var e=0;e<10;++e)this.data[e]+=t[e]},r.prototype.add=function(t){for(var e=new r,n=0;n<10;++n)e.data[n]=this.data[n]+t.data[n];return e},r.FromData=function(t,e,n,i){return new r(r.DataFromNumbers(t,e,n,i))},r.DataFromNumbers=function(t,e,n,i){return[t*t,t*e,t*n,t*i,e*e,e*n,e*i,n*n,n*i,i*i]},r}(),gN=function(r,t){this.vertexId=r,this.triangleId=t},m0=function(){function r(t){this._mesh=t,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=pt.bH}return r.prototype.simplify=function(t,e){var n=this;this._initDecimatedMesh(),ze.LV.Run(this._mesh.subMeshes.length,function(i){n._initWithMesh(i.index,function(){n._runDecimation(t,i.index,function(){i.executeNext()})},t.optimizeMesh)},function(){setTimeout(function(){e(n._reconstructedMesh)},0)})},r.prototype._runDecimation=function(t,e,n){var i=this,o=~~(this._triangles.length*t.quality),a=0,s=this._triangles.length;ze.LV.Run(this.decimationIterations,function(l){var c,u;s-a<=o?l.breakLoop():(c=l.index,u=function(){l.executeNext()},setTimeout(function(){c%5==0&&i._updateMesh(c===0);for(var d=0;d<i._triangles.length;++d)i._triangles[d].isDirty=!1;var h=1e-9*Math.pow(c+3,i.aggressiveness);ze.LV.SyncAsyncForLoop(i._triangles.length,i.syncIterations,function(p){var m=~~((i._triangles.length/2+p)%i._triangles.length),v=i._triangles[m];if(v&&!(v.error[3]>h||v.deleted||v.isDirty))for(var b=function(C){if(v.error[C]<h){var T=[],f=[],g=v._vertices[C],S=v._vertices[(C+1)%3];if(g.isBorder||S.isBorder)return"continue";var y=_.Pq.Zero();i._calculateError(g,S,y);var x=[];if(i._isFlipped(g,S,y,T,x)||i._isFlipped(S,g,y,f,x)||T.indexOf(!0)<0||f.indexOf(!0)<0)return"continue";var R=[];if(x.forEach(function(B){R.indexOf(B)===-1&&(B.deletePending=!0,R.push(B))}),R.length%2!=0)return"continue";g.q=S.q.add(g.q),g.updatePosition(y);var I=i._references.length;a=i._updateTriangles(g,g,T,a),a=i._updateTriangles(g,S,f,a);var M=i._references.length-I;if(M<=g.triangleCount){if(M)for(var D=0;D<M;D++)i._references[g.triangleStart+D]=i._references[I+D]}else g.triangleStart=I;return g.triangleCount=M,"break"}},E=0;E<3&&b(E)!=="break";++E);},u,function(){return s-a<=o})},0))},function(){setTimeout(function(){i._reconstructMesh(e),n()},0)})},r.prototype._initWithMesh=function(t,e,n){var i=this;this._vertices=[],this._triangles=[];var o=this._mesh.getVerticesData(Y.R.PositionKind),a=this._mesh.getIndices(),s=this._mesh.subMeshes[t],l=[],c=s.verticesCount;ze.LV.SyncAsyncForLoop(c,this.syncIterations/4|0,function(u){if(o){var d=u+s.verticesStart,h=_.Pq.FromArray(o,3*d),p=function(m){if(n){for(var v=0;v<i._vertices.length;++v)if(i._vertices[v].position.equalsWithEpsilon(m,1e-4))return i._vertices[v]}return null}(h)||new mN(h,i._vertices.length);p.originalOffsets.push(d),p.id===i._vertices.length&&i._vertices.push(p),l.push(p.id)}},function(){ze.LV.SyncAsyncForLoop(s.indexCount/3,i.syncIterations,function(u){if(a){var d=3*(s.indexStart/3+u),h=a[d+0],p=a[d+1],m=a[d+2],v=i._vertices[l[h-s.verticesStart]],b=i._vertices[l[p-s.verticesStart]],E=i._vertices[l[m-s.verticesStart]],C=new _N([v,b,E]);C.originalOffset=d,i._triangles.push(C)}},function(){i._init(e)})})},r.prototype._init=function(t){var e=this;ze.LV.SyncAsyncForLoop(this._triangles.length,this.syncIterations,function(n){var i=e._triangles[n];i.normal=_.Pq.Cross(i._vertices[1].position.subtract(i._vertices[0].position),i._vertices[2].position.subtract(i._vertices[0].position)).normalize();for(var o=0;o<3;o++)i._vertices[o].q.addArrayInPlace(EC.DataFromNumbers(i.normal.x,i.normal.y,i.normal.z,-_.Pq.Dot(i.normal,i._vertices[0].position)))},function(){ze.LV.SyncAsyncForLoop(e._triangles.length,e.syncIterations,function(n){for(var i=e._triangles[n],o=0;o<3;++o)i.error[o]=e._calculateError(i._vertices[o],i._vertices[(o+1)%3]);i.error[3]=Math.min(i.error[0],i.error[1],i.error[2])},function(){t()})})},r.prototype._reconstructMesh=function(t){var e,n,i,o=[];for(e=0;e<this._vertices.length;++e)this._vertices[e].triangleCount=0;for(e=0;e<this._triangles.length;++e)if(!this._triangles[e].deleted){for(n=this._triangles[e],i=0;i<3;++i)n._vertices[i].triangleCount=1;o.push(n)}var a=this._reconstructedMesh.getVerticesData(Y.R.PositionKind)||[],s=this._reconstructedMesh.getVerticesData(Y.R.NormalKind)||[],l=this._reconstructedMesh.getVerticesData(Y.R.UVKind)||[],c=this._reconstructedMesh.getVerticesData(Y.R.ColorKind)||[],u=this._mesh.getVerticesData(Y.R.NormalKind),d=this._mesh.getVerticesData(Y.R.UVKind),h=this._mesh.getVerticesData(Y.R.ColorKind),p=0,m=function(){var S=v._vertices[e];S.id=p,S.triangleCount&&S.originalOffsets.forEach(function(y){a.push(S.position.x),a.push(S.position.y),a.push(S.position.z),u&&u.length&&(s.push(u[3*y]),s.push(u[3*y+1]),s.push(u[3*y+2])),d&&d.length&&(l.push(d[2*y]),l.push(d[2*y+1])),h&&h.length&&(c.push(h[4*y]),c.push(h[4*y+1]),c.push(h[4*y+2]),c.push(h[4*y+3])),++p})},v=this;for(e=0;e<this._vertices.length;++e)m();var b=this._reconstructedMesh.getTotalIndices(),E=this._reconstructedMesh.getTotalVertices(),C=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var T=this._reconstructedMesh.getIndices(),f=this._mesh.getIndices();for(e=0;e<o.length;++e)n=o[e],[0,1,2].forEach(function(S){var y=f[n.originalOffset+S],x=n._vertices[S].originalOffsets.indexOf(y);x<0&&(x=0),T.push(n._vertices[S].id+x+E)});this._reconstructedMesh.setIndices(T),this._reconstructedMesh.setVerticesData(Y.R.PositionKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(Y.R.NormalKind,s),l.length>0&&this._reconstructedMesh.setVerticesData(Y.R.UVKind,l),c.length>0&&this._reconstructedMesh.setVerticesData(Y.R.ColorKind,c);var g=this._mesh.subMeshes[t];t>0&&(this._reconstructedMesh.subMeshes=[],C.forEach(function(S){yi.AddToMesh(S.materialIndex,S.verticesStart,S.verticesCount,S.indexStart,S.indexCount,S.getMesh())}),yi.AddToMesh(g.materialIndex,E,p,b,3*o.length,this._reconstructedMesh))},r.prototype._initDecimatedMesh=function(){this._reconstructedMesh=new xe(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},r.prototype._isFlipped=function(t,e,n,i,o){for(var a=0;a<t.triangleCount;++a){var s=this._triangles[this._references[t.triangleStart+a].triangleId];if(!s.deleted){var l=this._references[t.triangleStart+a].vertexId,c=s._vertices[(l+1)%3],u=s._vertices[(l+2)%3];if(c!==e&&u!==e){var d=c.position.subtract(n);d=d.normalize();var h=u.position.subtract(n);if(h=h.normalize(),Math.abs(_.Pq.Dot(d,h))>.999)return!0;var p=_.Pq.Cross(d,h).normalize();if(i[a]=!1,_.Pq.Dot(p,s.normal)<.2)return!0}else i[a]=!0,o.push(s)}}return!1},r.prototype._updateTriangles=function(t,e,n,i){for(var o=i,a=0;a<e.triangleCount;++a){var s=this._references[e.triangleStart+a],l=this._triangles[s.triangleId];l.deleted||(n[a]&&l.deletePending?(l.deleted=!0,o++):(l._vertices[s.vertexId]=t,l.isDirty=!0,l.error[0]=this._calculateError(l._vertices[0],l._vertices[1])+l.borderFactor/2,l.error[1]=this._calculateError(l._vertices[1],l._vertices[2])+l.borderFactor/2,l.error[2]=this._calculateError(l._vertices[2],l._vertices[0])+l.borderFactor/2,l.error[3]=Math.min(l.error[0],l.error[1],l.error[2]),this._references.push(s)))}return o},r.prototype._identifyBorder=function(){for(var t=0;t<this._vertices.length;++t){var e=[],n=[],i=this._vertices[t],o=void 0;for(o=0;o<i.triangleCount;++o)for(var a=this._triangles[this._references[i.triangleStart+o].triangleId],s=0;s<3;s++){for(var l=0,c=a._vertices[s];l<e.length&&n[l]!==c.id;)++l;l===e.length?(e.push(1),n.push(c.id)):e[l]++}for(o=0;o<e.length;++o)e[o]===1?this._vertices[n[o]].isBorder=!0:this._vertices[n[o]].isBorder=!1}},r.prototype._updateMesh=function(t){var e,n,i,o;if(t===void 0&&(t=!1),!t){var a=[];for(e=0;e<this._triangles.length;++e)this._triangles[e].deleted||a.push(this._triangles[e]);this._triangles=a}for(e=0;e<this._vertices.length;++e)this._vertices[e].triangleCount=0,this._vertices[e].triangleStart=0;for(e=0;e<this._triangles.length;++e)for(n=this._triangles[e],i=0;i<3;++i)(o=n._vertices[i]).triangleCount++;var s=0;for(e=0;e<this._vertices.length;++e)this._vertices[e].triangleStart=s,s+=this._vertices[e].triangleCount,this._vertices[e].triangleCount=0;var l=new Array(3*this._triangles.length);for(e=0;e<this._triangles.length;++e)for(n=this._triangles[e],i=0;i<3;++i)l[(o=n._vertices[i]).triangleStart+o.triangleCount]=new gN(i,e),o.triangleCount++;this._references=l,t&&this._identifyBorder()},r.prototype._vertexError=function(t,e){var n=e.x,i=e.y,o=e.z;return t.data[0]*n*n+2*t.data[1]*n*i+2*t.data[2]*n*o+2*t.data[3]*n+t.data[4]*i*i+2*t.data[5]*i*o+2*t.data[6]*i+t.data[7]*o*o+2*t.data[8]*o+t.data[9]},r.prototype._calculateError=function(t,e,n){var i=t.q.add(e.q),o=t.isBorder&&e.isBorder,a=0,s=i.det(0,1,2,1,4,5,2,5,7);if(s===0||o){var l=t.position.add(e.position).divide(new _.Pq(2,2,2)),c=this._vertexError(i,t.position),u=this._vertexError(i,e.position),d=this._vertexError(i,l);(a=Math.min(c,u,d))===c?n&&n.copyFrom(t.position):a===u?n&&n.copyFrom(e.position):n&&n.copyFrom(l)}else n||(n=_.Pq.Zero()),n.x=-1/s*i.det(1,2,3,4,5,6,5,7,8),n.y=1/s*i.det(0,2,3,1,5,6,2,7,8),n.z=-1/s*i.det(0,1,3,1,4,6,2,5,8),a=this._vertexError(i,n);return a},r}();Object.defineProperty(ke.Z.prototype,"simplificationQueue",{get:function(){if(!this._simplificationQueue){this._simplificationQueue=new _0;var r=this._getComponent(lt.v.NAME_SIMPLIFICATIONQUEUE);r||(r=new g0(this),this._addComponent(r))}return this._simplificationQueue},set:function(r){this._simplificationQueue=r},enumerable:!0,configurable:!0}),xe.prototype.simplify=function(r,t,e,n){return t===void 0&&(t=!0),e===void 0&&(e=0),this.getScene().simplificationQueue.addTask({settings:r,parallelProcessing:t,mesh:this,simplificationType:e,successCallback:n}),this};var Kh,Zh,Qh,g0=function(){function r(t){this.name=lt.v.NAME_SIMPLIFICATIONQUEUE,this.scene=t}return r.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(lt.v.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE,this,this._beforeCameraUpdate)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r.prototype._beforeCameraUpdate=function(){this.scene._simplificationQueue&&!this.scene._simplificationQueue.running&&this.scene._simplificationQueue.executeNext()},r}();function xC(r){var t=r.minimum.x,e=r.minimum.y,n=r.minimum.z,i=r.maximum.x,o=r.maximum.y,a=r.maximum.z;return[new _.Pq(t,e,n),new _.Pq(i,o,a),new _.Pq(i,e,n),new _.Pq(t,o,n),new _.Pq(t,e,a),new _.Pq(i,o,n),new _.Pq(t,o,a),new _.Pq(i,e,a)]}function PC(r,t,e){t===void 0&&(t=null),e===void 0&&(e=1/6);for(var n=_.AA.Vector3[0],i=new Map,o=new Map,a=r.reduce(function(g,S){return Math.max(g,S.getTotalVertices())},0),s=Array.from({length:a},function(){return new _.Pq}),l=Array.from({length:a},function(){return new _.Pq}),c=function(g){var S=g.getVerticesData(Y.R.PositionKind);if(!S)return"continue";var y=g.getTotalVertices();s.length=Math.max(s.length,y),l.length=Math.max(s.length,y);for(var x=0,R=0;x<y;x++,R+=3)n.set(S[R],S[R+1],S[R+2]),s[x].copyFrom(n),l[x].copyFrom(n);var I=g.morphTargetManager;if(I)for(var M=0;M<I.numTargets;++M){var D=I.getTarget(M).getPositions();if(D)for(x=0,R=0;x<y;x++,R+=3)n.set(D[R],D[R+1],D[R+2]),s[x].minimizeInPlace(n),l[x].maximizeInPlace(n)}var B=g.skeleton,F=B?g.getVerticesData(Y.R.MatricesWeightsKind):null,X=B?g.getVerticesData(Y.R.MatricesIndicesKind):null;if(F&&X){var $=g.numBoneInfluencers>4,Q=$?g.getVerticesData(Y.R.MatricesWeightsExtraKind):null,ie=$?g.getVerticesData(Y.R.MatricesIndicesExtraKind):null,q=o.get(g.uniqueId)||new Map;o.set(g.uniqueId,q);var ee=function(ce,fe,de,Te){for(var ue=fe;ue<fe+4;ue++)if(de[ue]>0){var U=Te[ue],N=q.get(U);N?(N.minimum.minimizeInPlace(s[ce]),N.maximum.maximizeInPlace(l[ce])):q.set(U,{minimum:s[ce].clone(),maximum:l[ce].clone()})}};for(x=0,R=0;x<y;x++,R+=4)ee(x,R,F,X),Q&&ie&&ee(x,R,Q,ie)}else{var te=i.get(g.uniqueId)||{minimum:new _.Pq().setAll(Number.POSITIVE_INFINITY),maximum:new _.Pq().setAll(Number.NEGATIVE_INFINITY)};for(i.set(g.uniqueId,te),x=0;x<y;x++)te.minimum.minimizeInPlace(s[x]),te.maximum.maximizeInPlace(l[x])}},u=0,d=r;u<d.length;u++)c(d[u]);for(var h=new Map,p=new Map,m=function(g){var S=i.get(g.uniqueId);if(S)h.set(g.uniqueId,xC(S));else{var y=o.get(g.uniqueId);if(y){var x=g.skeleton.bones,R=new Map;p.set(g.uniqueId,R),y.forEach(function(I,M){for(var D=xC(I),B=x[M].getAbsoluteInverseBindMatrix(),F=0,X=D;F<X.length;F++){var $=X[F];_.Pq.TransformCoordinatesToRef($,B,$)}R.set(M,D)})}}},v=0,b=r;v<b.length;v++)m(b[v]);var E=Array.from({length:r.length},function(){return{minimum:new _.Pq().setAll(Number.POSITIVE_INFINITY),maximum:new _.Pq().setAll(Number.NEGATIVE_INFINITY)}}),C=function(){for(var g=function(y){var x=r[y],R=x.computeWorldMatrix(!0),I=x.skeleton;if(I){I.prepare(!0);var M=I.bones;p.get(x.uniqueId).forEach(function(X,$){for(var Q=0,ie=X;Q<ie.length;Q++){var q=ie[Q],ee=M[$].getFinalMatrix().multiplyToRef(R,_.AA.Matrix[0]);_.Pq.TransformCoordinatesToRef(q,ee,n),E[y].minimum.minimizeInPlace(n),E[y].maximum.maximizeInPlace(n)}})}else for(var D=0,B=h.get(x.uniqueId);D<B.length;D++){var F=B[D];_.Pq.TransformCoordinatesToRef(F,R,n),E[y].minimum.minimizeInPlace(n),E[y].maximum.maximizeInPlace(n)}},S=0;S<r.length;S++)g(S)};if(t&&t.isStarted)for(var T=e/t.getLength(0,1),f=t.from;f<=t.to;f+=T)t.goToFrame(f),C();else C();return E}(function(r){r[r.POINTS_MODE_POINTS=0]="POINTS_MODE_POINTS",r[r.POINTS_MODE_PATHS=1]="POINTS_MODE_PATHS"})(Kh||(Kh={})),function(r){r[r.FACES_MODE_SINGLE_SIDED=0]="FACES_MODE_SINGLE_SIDED",r[r.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING=1]="FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING",r[r.FACES_MODE_DOUBLE_SIDED=2]="FACES_MODE_DOUBLE_SIDED"}(Zh||(Zh={})),function(r){r[r.AUTO_DIRECTIONS_FROM_FIRST_SEGMENT=0]="AUTO_DIRECTIONS_FROM_FIRST_SEGMENT",r[r.AUTO_DIRECTIONS_FROM_ALL_SEGMENTS=1]="AUTO_DIRECTIONS_FROM_ALL_SEGMENTS",r[r.AUTO_DIRECTIONS_ENHANCED=2]="AUTO_DIRECTIONS_ENHANCED",r[r.AUTO_DIRECTIONS_FACE_TO=3]="AUTO_DIRECTIONS_FACE_TO",r[r.AUTO_DIRECTIONS_NONE=99]="AUTO_DIRECTIONS_NONE"}(Qh||(Qh={}));var Jh=function(r){function t(e,n,i){var o,a,s,l,c=this;return(c=r.call(this,e,n,null,null,!1,!1)||this).name=e,c._options=i,c._lazy=!1,c._updatable=!1,c._engine=n.getEngine(),c._lazy=(o=i.lazy)!==null&&o!==void 0&&o,c._updatable=(a=i.updatable)!==null&&a!==void 0&&a,c._vertexPositions=[],c._indices=[],c._uvs=[],c._points=[],c._colorPointers=(s=i.colorPointers)!==null&&s!==void 0?s:[],c._widths=(l=i.widths)!==null&&l!==void 0?l:new Array(i.points.length).fill(1),c}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GreasedLineMesh"},t.prototype._updateWidthsWithValue=function(e){for(var n=0,i=0,o=this._points;i<o.length;i++)n+=o[i].length;for(var a=n/3*2-this._widths.length,s=0;s<a;s++)this._widths.push(e)},t.prototype.updateLazy=function(){var e,n;this._setPoints(this._points),this._options.colorPointers||this._updateColorPointers(),this._createVertexBuffers((e=this._options.ribbonOptions)===null||e===void 0?void 0:e.smoothShading),this.refreshBoundingInfo(),(n=this.greasedLineMaterial)===null||n===void 0||n.updateLazy()},t.prototype.addPoints=function(e,n){for(var i=0,o=e;i<o.length;i++){var a=o[i];this._points.push(a)}this._lazy||this.setPoints(this._points,n)},t.prototype.dispose=function(e,n){n===void 0&&(n=!1),r.prototype.dispose.call(this,e,n)},t.prototype.isLazy=function(){return this._lazy},Object.defineProperty(t.prototype,"uvs",{get:function(){return this._uvs},set:function(e){this._uvs=e instanceof Float32Array?e:new Float32Array(e),this._createVertexBuffers()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsets",{get:function(){return this._offsets},set:function(e){this._offsets=e,this._offsetsBuffer?this._offsetsBuffer.update(e):this._createOffsetsBuffer(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"widths",{get:function(){return this._widths},set:function(e){this._widths=e,this._lazy||this._widthsBuffer&&this._widthsBuffer.update(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorPointers",{get:function(){return this._colorPointers},set:function(e){this._colorPointers=e,this._lazy||this._colorPointersBuffer&&this._colorPointersBuffer.update(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"greasedLineMaterial",{get:function(){var e,n;return this.material&&this.material instanceof zh?this.material:((n=(e=this.material)===null||e===void 0?void 0:e.pluginManager)===null||n===void 0?void 0:n.getPlugin(ha.GREASED_LINE_MATERIAL_NAME))||void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"points",{get:function(){var e=[];return ot.r.DeepCopy(this._points,e),e},enumerable:!1,configurable:!0}),t.prototype.setPoints=function(e,n){this._points=e,this._updateWidths(),n?.colorPointers||this._updateColorPointers(),this._setPoints(e,n)},t.prototype._initGreasedLine=function(){this._vertexPositions=[],this._indices=[],this._uvs=[]},t.prototype._createLineOptions=function(){return{points:this._points,colorPointers:this._colorPointers,lazy:this._lazy,updatable:this._updatable,uvs:this._uvs,widths:this._widths,ribbonOptions:this._options.ribbonOptions}},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.type=this.getClassName(),e.lineOptions=this._createLineOptions()},t.prototype._createVertexBuffers=function(e){e===void 0&&(e=!1);var n=new rt;return n.positions=this._vertexPositions,n.indices=this._indices,n.uvs=this._uvs,e&&(n.normals=[],rt.ComputeNormals(this._vertexPositions,this._indices,n.normals)),n.applyToMesh(this,this._options.updatable),n},t.prototype._createOffsetsBuffer=function(e){var n=this._scene.getEngine(),i=new Y.h(n,e,this._updatable,3);this.setVerticesBuffer(i.createVertexBuffer("grl_offsets",0,3)),this._offsetsBuffer=i},t}(xe);xe._GreasedLineMeshParser=function(r,t){return $h.Parse(r,t)};var $h=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.name=e,o.intersectionThreshold=.1,o._previousAndSide=[],o._nextAndCounters=[],i.points&&o.addPoints(On.ConvertPoints(i.points)),o}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GreasedLineMesh"},t.prototype._updateColorPointers=function(){var e=this;if(!this._options.colorPointers){var n=0;this._colorPointers=[],this._points.forEach(function(i){for(var o=0;o<i.length;o+=3)e._colorPointers.push(n),e._colorPointers.push(n++)})}},t.prototype._updateWidths=function(){},t.prototype._setPoints=function(e){var n=this;this._points=e,this._options.points=e,this._initGreasedLine();var i=0,o=0,a=0,s=0,l=0;e.forEach(function(T){o+=2*T.length,a+=2*(T.length-3),s+=4*T.length/3,l+=8*T.length/3});var c=new Float32Array(o),u=o>65535?new Uint32Array(a):new Uint16Array(a),d=new Float32Array(s),h=new Float32Array(l),p=new Float32Array(l),m=0,v=0,b=0,E=0,C=0;e.forEach(function(T){for(var f=On.GetLineLengthArray(T),g=f[f.length-1],S=0,y=0;y<T.length;S++,y+=3){var x=m+2*y;if(c[x+0]=T[y+0],c[x+1]=T[y+1],c[x+2]=T[y+2],c[x+3]=T[y+0],c[x+4]=T[y+1],c[x+5]=T[y+2],y<T.length-3){var R=2*S+i,I=v+2*y;u[I+0]=R,u[I+1]=R+1,u[I+2]=R+2,u[I+3]=R+2,u[I+4]=R+1,u[I+5]=R+3}}i+=T.length/3*2;var M=2*T.length,D=c.subarray(m,m+M);m+=M,v+=2*(T.length-3);var B,F=new Float32Array(D.length),X=new Float32Array(D.length),$=D.length/6;B=t._CompareV3(0,$-1,D)?D.subarray(6*($-2),6*($-1)):D.subarray(0,6),F.set(B),F.set(D.subarray(0,D.length-6),6),X.set(D.subarray(6)),B=t._CompareV3($-1,0,D)?D.subarray(6,12):D.subarray(6*($-1),6*$),X.set(B,X.length-6);for(var Q=0,ie=D.length/3;Q<ie;Q++)h[E++]=F[3*Q],h[E++]=F[3*Q+1],h[E++]=F[3*Q+2],h[E++]=1-((1&Q)<<1),p[C++]=X[3*Q],p[C++]=X[3*Q+1],p[C++]=X[3*Q+2],p[C++]=f[Q>>1]/g;if(n._options.uvs)for(Q=0;Q<n._options.uvs.length;Q++)d[b++]=n._options.uvs[Q];else for(S=0;S<$;S++){var q=f[S]/g,ee=b+4*S;d[ee+0]=q,d[ee+1]=0,d[ee+2]=q,d[ee+3]=1}}),this._vertexPositions=c,this._indices=u,this._uvs=d,this._previousAndSide=h,this._nextAndCounters=p,this._lazy||(this._options.colorPointers||this._updateColorPointers(),this._createVertexBuffers(),this.refreshBoundingInfo())},t.prototype.clone=function(e,n){e===void 0&&(e="".concat(this.name,"-cloned"));var i=this._createLineOptions(),o={};ot.r.DeepCopy(i,o,["instance"],void 0,!0);var a=new t(e,this._scene,o);return n&&(a.parent=n),a.material=this.material,a},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.type=this.getClassName(),e.lineOptions=this._createLineOptions()},t.Parse=function(e,n){var i=e.lineOptions;return new t(e.name,n,i)},t.prototype._initGreasedLine=function(){r.prototype._initGreasedLine.call(this),this._previousAndSide=[],this._nextAndCounters=[]},t.prototype.intersects=function(e,n,i,o,a,s){o===void 0&&(o=!1),s===void 0&&(s=!1);var l=new ri.G,c=this.findAllIntersections(e,n,i,o,a,s,!0);if(c?.length===1){var u=c[0];l.hit=!0,l.distance=u.distance,l.ray=e,l.pickedMesh=this,l.pickedPoint=u.point}return l},t.prototype.findAllIntersections=function(e,n,i,o,a,s,l){var c,u;if(o===void 0&&(o=!1),s===void 0&&(s=!1),l===void 0&&(l=!1),!o||s||e.intersectsSphere(this._boundingSphere,this.intersectionThreshold)!==!1){var d=this.getIndices(),h=this.getVerticesData(Y.R.PositionKind),p=this._widths,m=(u=(c=this.greasedLineMaterial)===null||c===void 0?void 0:c.width)!==null&&u!==void 0?u:1,v=[];if(d&&h&&p){var b,E=0;for(E=0,b=d.length-1;E<b;E+=3){var C=d[E],T=d[E+1];t._V_START.fromArray(h,3*C),t._V_END.fromArray(h,3*T),this._offsets&&(t._V_OFFSET_START.fromArray(this._offsets,3*C),t._V_OFFSET_END.fromArray(this._offsets,3*T),t._V_START.addInPlace(t._V_OFFSET_START),t._V_END.addInPlace(t._V_OFFSET_END));var f=Math.floor(E/3),g=p[f]!==void 0?p[f]:1,S=this.intersectionThreshold*(m*g)/2,y=e.intersectionSegment(t._V_START,t._V_END,S);if(y!==-1&&(v.push({distance:y,point:e.direction.normalize().multiplyByFloats(y,y,y).add(e.origin)}),l))return v}E=b}return v}},Object.defineProperty(t.prototype,"_boundingSphere",{get:function(){return this.getBoundingInfo().boundingSphere},enumerable:!1,configurable:!0}),t._CompareV3=function(e,n,i){var o=6*e,a=6*n;return i[o]===i[a]&&i[o+1]===i[a+1]&&i[o+2]===i[a+2]},t.prototype._createVertexBuffers=function(){var e=r.prototype._createVertexBuffers.call(this),n=this._scene.getEngine(),i=new Y.h(n,this._previousAndSide,!1,4);this.setVerticesBuffer(i.createVertexBuffer("grl_previousAndSide",0,4));var o=new Y.h(n,this._nextAndCounters,!1,4);this.setVerticesBuffer(o.createVertexBuffer("grl_nextAndCounters",0,4));var a=new Y.h(n,this._widths,this._updatable,1);this.setVerticesBuffer(a.createVertexBuffer("grl_widths",0,1)),this._widthsBuffer=a;var s=new Y.h(n,this._colorPointers,this._updatable,1);return this.setVerticesBuffer(s.createVertexBuffer("grl_colorPointers",0,1)),this._colorPointersBuffer=s,e},t._V_START=new _.Pq,t._V_END=new _.Pq,t._V_OFFSET_START=new _.Pq,t._V_OFFSET_END=new _.Pq,t}(Jh);xe._GreasedLineRibbonMeshParser=function(r,t){return Ml.Parse(r,t)};var ef,tf,se,nf,rf,Ml=function(r){function t(e,n,i,o){var a,s=this;if((s=r.call(this,e,n,i)||this).name=e,!i.ribbonOptions)throw"'GreasedLineMeshOptions.ribbonOptions' is not set.";return s._paths=[],s._counters=[],s._slopes=[],s._widths=(a=i.widths)!==null&&a!==void 0?a:[],s._ribbonWidths=[],s._pathsOptions=o??[],i.points&&s.addPoints(On.ConvertPoints(i.points),i,!!o),s}return(0,A.C6)(t,r),t.prototype.addPoints=function(e,n,i){if(i===void 0&&(i=!1),!n.ribbonOptions)throw"addPoints() on GreasedLineRibbonMesh instance requires 'GreasedLineMeshOptions.ribbonOptions'.";i||this._pathsOptions.push({options:n,pathCount:e.length}),r.prototype.addPoints.call(this,e,n)},t.prototype.getClassName=function(){return"GreasedLineRibbonMesh"},Object.defineProperty(t.prototype,"isFlatLine",{get:function(){return this._paths.length<3},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"slopes",{get:function(){return this._slopes},set:function(e){this._slopes=e},enumerable:!1,configurable:!0}),t.prototype._updateColorPointers=function(){var e;if(!this._options.colorPointers){var n=0;this._colorPointers=[];for(var i=0;i<this._pathsOptions.length;i++){var o=(e=this._pathsOptions[i]).options,a=e.pathCount,s=this._points[i];if(o.ribbonOptions.pointsMode===0)for(var l=0;l<a;l++)for(var c=0;c<s.length;c+=3)this._colorPointers.push(n),this._colorPointers.push(n++);else for(c=0;c<s.length;c+=3){for(l=0;l<a;l++)this._colorPointers.push(n);n++}}}},t.prototype._updateWidths=function(){r.prototype._updateWidthsWithValue.call(this,1)},t.prototype._setPoints=function(e,n){var i,o,a=this;if(!this._options.ribbonOptions)throw"No 'GreasedLineMeshOptions.ribbonOptions' provided.";this._points=e,this._options.points=e,this._initGreasedLine();for(var s,l,c=0,u=function(m,v){var b,E=(b=d._pathsOptions[m]).options,C=b.pathCount,T=e.slice(v,v+C);if(v+=C,((i=E.ribbonOptions)===null||i===void 0?void 0:i.pointsMode)===1)c=d._preprocess(On.ToVector3Array(T),c,E);else{if(((o=E.ribbonOptions)===null||o===void 0?void 0:o.directionsAutoMode)===99){if(!E.ribbonOptions.directions)throw"In GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_NONE 'GreasedLineMeshOptions.ribbonOptions.directions' must be defined.";s=t._GetDirectionPlanesFromDirectionsOption(T.length,E.ribbonOptions.directions)}T.forEach(function(f,g){var S=t._ConvertToRibbonPath(f,E.ribbonOptions,a._scene.useRightHandedSystem,s&&s[g]);c=a._preprocess(S,c,E)})}l=v},d=this,h=0,p=0;h<this._pathsOptions.length;h++)u(h,p),p=l;this._lazy||(this._createVertexBuffers(),this.refreshBoundingInfo())},t._GetDirectionPlanesFromDirectionsOption=function(e,n){return Array.isArray(n)?n:new Array(e).fill(n)},t._CreateRibbonVertexData=function(e,n){var i,o,a,s=e.length;if(s<2)throw"Minimum of two paths are required to create a GreasedLineRibbonMesh.";for(var l=[],c=[],u=e[0],d=0;d<u.length;d++)for(var h=0;h<e.length;h++){var p=e[h][d];l.push(p.x,p.y,p.z)}var m=[1,0,s],v=(o=((i=n.ribbonOptions)===null||i===void 0?void 0:i.facesMode)===2)!==null&&o!==void 0&&o,b=((a=n.ribbonOptions)===null||a===void 0?void 0:a.pointsMode)===1&&n.ribbonOptions.closePath;if(s>2)for(d=0;d<u.length-1;d++)for(m[0]=1+s*d,m[1]=s*d,m[2]=(d+1)*s,h=0;h<2*(s-1);h++)h%2!=0&&(m[2]+=1),h%2==0&&h>0&&(m[0]+=1,m[1]+=1),c.push(m[1]+(h%2!=0?s:0),m[0],m[2]),v&&c.push(m[0],m[1]+(h%2!=0?s:0),m[2]);else for(d=0;d<l.length/3-3;d+=2)c.push(d,d+1,d+2),c.push(d+2,d+1,d+3),v&&(c.push(d+1,d,d+2),c.push(d+1,d+2,d+3));if(b){var E=s*(u.length-1);for(h=0;h<s-1;h++)c.push(E,h+1,h),c.push(E+1,h+1,E),v&&(c.push(h,h+1,E),c.push(E,h+1,E+1)),E++}return{positions:l,indices:c}},t.prototype._preprocess=function(e,n,i){var o,a,s,l;this._paths=e;var c=t._CreateRibbonVertexData(e,i),u=c.positions;if(!this._options.widths)throw"No 'GreasedLineMeshOptions.widths' table is specified.";var d=Array.isArray(this._vertexPositions)?this._vertexPositions:Array.from(this._vertexPositions);this._vertexPositions=d;var h=Array.isArray(this._uvs)?this._uvs:Array.from(this._uvs);this._uvs=h;var p=Array.isArray(this._indices)?this._indices:Array.from(this._indices);this._indices=p;for(var m=0,v=u;m<v.length;m++){var b=v[m];d.push(b)}var E=e;if(((o=i.ribbonOptions)===null||o===void 0?void 0:o.pointsMode)===1&&i.ribbonOptions.closePath){E=[];for(var C=0;C<e.length;C++){var T=e[C].slice();T.push(e[C][0].clone()),E.push(T)}}this._calculateSegmentLengths(E);var f=E.length,g=new Array(f).fill(0);for(C=0;C<E[0].length;C++)for(var S=0,y=0;y<f;y++){var x=g[y]+this._vSegmentLengths[y][C]/this._vTotalLengths[y];this._counters.push(x),h.push(x,S),g[y]=x,S+=this._uSegmentLengths[C][y]/this._uTotalLengths[C]}C=0;for(var R=0;C<E[0].length;C++){var I=this._uSegmentLengths[C][0]/2,M=this._uSegmentLengths[C][f-1]/2;for(this._ribbonWidths.push((((a=this._widths[R++])!==null&&a!==void 0?a:1)-1)*I),y=0;y<f-2;y++)this._ribbonWidths.push(0);this._ribbonWidths.push((((s=this._widths[R++])!==null&&s!==void 0?s:1)-1)*M)}for(var D=0,B=((l=i.ribbonOptions)===null||l===void 0?void 0:l.pointsMode)===1?new Array(E[0].length*E.length*6).fill(0):t._CalculateSlopes(E);D<B.length;D++){var F=B[D];this._slopes.push(F)}if(c.indices)for(C=0;C<c.indices.length;C++)p.push(c.indices[C]+n);return n+u.length/3},t._ConvertToRibbonPath=function(e,n,i,o){if(n.pointsMode===0&&!n.width)throw"'GreasedLineMeshOptions.ribbonOptiosn.width' must be specified in GreasedLineRibbonPointsMode.POINTS_MODE_POINTS.";var a=[],s=[];if(n.pointsMode===0){var l=n.width/2,c=On.ToVector3Array(e),u=null,d=null;if(n.directionsAutoMode===0&&(o=t._GetDirectionFromPoints(c[0],c[1],null)),n.directionsAutoMode===3&&!(n.directions instanceof _.Pq))throw"In GreasedLineRibbonAutoDirectionMode.AUTO_DIRECTIONS_FACE_TO 'GreasedLineMeshOptions.ribbonOptions.directions' must be a Vector3.";_.AA.Vector3[1]=n.directions instanceof _.Pq?n.directions:t.DIRECTION_XZ;for(var h=0;h<c.length-(o?0:1);h++){var p=c[h],m=c[h+1];if(o)u=o;else if(n.directionsAutoMode===3)m.subtractToRef(p,_.AA.Vector3[0]),u=_.Pq.CrossToRef(_.AA.Vector3[0],_.AA.Vector3[1],_.AA.Vector3[2]).normalize();else if(n.directionsAutoMode===1)u=t._GetDirectionFromPoints(p,m,u);else{var v=m.subtract(p);v.applyRotationQuaternionInPlace(v.x>v.y&&v.x>v.z?i?t._RightHandedForwardReadOnlyQuaternion:t._LeftHandedForwardReadOnlyQuaternion:t._LeftReadOnlyQuaternion),u=v.normalize()}d=u.multiplyByFloats(l,l,l),a.push(p.add(d)),s.push(p.subtract(d))}o||(a.push(c[c.length-1].add(d)),s.push(c[c.length-1].subtract(d)))}return[a,s]},t._GetDirectionFromPoints=function(e,n,i){return e.x!==n.x||i&&i?.x!==1?e.y===n.y?t.DIRECTION_XZ:e.z===n.z?t.DIRECTION_XY:t.DIRECTION_XZ:t.DIRECTION_YZ},t.prototype.clone=function(e,n){e===void 0&&(e="".concat(this.name,"-cloned"));var i=this._createLineOptions(),o={},a=[];ot.r.DeepCopy(this._pathsOptions,a,void 0,void 0,!0),ot.r.DeepCopy(i,o,["instance"],void 0,!0);var s=new t(e,this._scene,o,a);return n&&(s.parent=n),s.material=this.material,s},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.type=this.getClassName(),e.lineOptions=this._createLineOptions(),e.pathsOptions=this._pathsOptions},t.Parse=function(e,n){var i=e.lineOptions;return new t(e.name,n,i,e.pathOptions)},t.prototype._initGreasedLine=function(){r.prototype._initGreasedLine.call(this),this._paths=[],this._counters=[],this._slopes=[],this._ribbonWidths=[]},t.prototype._calculateSegmentLengths=function(e){var n=e.length;this._vSegmentLengths=new Array(n),this._vTotalLengths=new Array(n);for(var i=0,o=0;o<n;o++){var a=e[o];this._vSegmentLengths[o]=[0],i=0;for(var s=0;s<a.length-1;s++)i+=u=Math.abs(a[s].subtract(a[s+1]).lengthSquared()),this._vSegmentLengths[o].push(u);this._vTotalLengths[o]=i}var l=e[0].length;this._uSegmentLengths=new Array(l).fill([]),this._uTotalLengths=new Array(l).fill([]);var c=new _.Pq;for(s=0;s<l;s++){for(i=0,o=1;o<n;o++){var u;e[o][s].subtractToRef(e[o-1][s],c),i+=u=c.length(),this._uSegmentLengths[s].push(u)}this._uTotalLengths[s]=i}},t._CalculateSlopes=function(e){for(var n=e[0],i=e.length===2?e[1]:e[e.length-1],o=[],a=new _.Pq,s=0;s<n.length;s++)for(var l=0;l<e.length;l++)l===0||l===e.length-1?(n[s].subtract(i[s]).normalizeToRef(a),o.push(a.x,a.y,a.z),o.push(-a.x,-a.y,-a.z)):o.push(0,0,0,0,0,0);return o},t.prototype._createVertexBuffers=function(){var e,n;this._uvs=(e=this._options.uvs)!==null&&e!==void 0?e:this._uvs;var i=r.prototype._createVertexBuffers.call(this,(n=this._options.ribbonOptions)===null||n===void 0?void 0:n.smoothShading),o=new Y.h(this._engine,this._counters,this._updatable,1);this.setVerticesBuffer(o.createVertexBuffer("grl_counters",0,1));var a=new Y.h(this._engine,this._colorPointers,this._updatable,1);this.setVerticesBuffer(a.createVertexBuffer("grl_colorPointers",0,1));var s=new Y.h(this._engine,this._slopes,this._updatable,3);this.setVerticesBuffer(s.createVertexBuffer("grl_slopes",0,3));var l=new Y.h(this._engine,this._ribbonWidths,this._updatable,1);return this.setVerticesBuffer(l.createVertexBuffer("grl_widths",0,1)),this._widthsBuffer=l,i},t.DEFAULT_WIDTH=.1,t._RightHandedForwardReadOnlyQuaternion=_.PT.RotationAxis(_.Pq.RightHandedForwardReadOnly,Math.PI/2),t._LeftHandedForwardReadOnlyQuaternion=_.PT.RotationAxis(_.Pq.LeftHandedForwardReadOnly,Math.PI/2),t._LeftReadOnlyQuaternion=_.PT.RotationAxis(_.Pq.LeftReadOnly,Math.PI/2),t.DIRECTION_XY=_.Pq.LeftHandedForwardReadOnly,t.DIRECTION_XZ=_.Pq.UpReadOnly,t.DIRECTION_YZ=_.Pq.LeftReadOnly,t}(Jh);function v0(r,t,e){var n;switch(e=e??Ve.q.LastCreatedScene,t.materialType){case 1:n=new fl(r,e,!0),new ha(n,e,t);break;case 2:n=new zh(r,e,t);break;default:n=new qt(r,e,!0),new ha(n,e,t)}return n}function AC(r,t,e,n){var i,o,a,s,l,c,u,d,h,p,m,v,b;n=n??Ve.q.LastCreatedScene;var E=On.ConvertPoints(t.points);t.widthDistribution=(i=t.widthDistribution)!==null&&i!==void 0?i:3,t.ribbonOptions&&(t.ribbonOptions.facesMode=(o=t.ribbonOptions.facesMode)!==null&&o!==void 0?o:1,t.ribbonOptions.pointsMode=(a=t.ribbonOptions.pointsMode)!==null&&a!==void 0?a:0,t.ribbonOptions.directionsAutoMode=(s=t.ribbonOptions.directionsAutoMode)!==null&&s!==void 0?s:t.ribbonOptions.directions?99:0),(e=e??{color:ui.DEFAULT_COLOR}).createAndAssignMaterial=(l=e.createAndAssignMaterial)===null||l===void 0||l,e.colorDistribution=(c=e?.colorDistribution)!==null&&c!==void 0?c:3,e.materialType=(u=e.materialType)!==null&&u!==void 0?u:0;var C=y0(E),T=b0(C,(d=t.widths)!==null&&d!==void 0?d:[],t.widthDistribution),f=e?.colors?T0(C,e.colors,e.colorDistribution,(h=e.color)!==null&&h!==void 0?h:ui.DEFAULT_COLOR):void 0,g={points:E,updatable:t.updatable,widths:T,lazy:t.lazy,ribbonOptions:t.ribbonOptions,uvs:t.uvs,colorPointers:t.colorPointers};if(g.ribbonOptions&&g.ribbonOptions.pointsMode===0&&(g.ribbonOptions.width=(m=(p=e.width)!==null&&p!==void 0?p:g.ribbonOptions.width)!==null&&m!==void 0?m:ui.DEFAULT_WIDTH),t.instance)if((b=t.instance)instanceof Ml)b.addPoints(E,g);else{var S=b.widths;if(S){for(var y=S.slice(),x=0,R=T;x<R.length;x++){var I=R[x];y.push(I)}b.widths=y}else b.widths=T;if(b.addPoints(E),t.uvs){var M=b.uvs;if(M){var D=new Float32Array(M.length+t.uvs.length);D.set(M,0),D.set(t.uvs,M.length),b.uvs=D}else b.uvs=t.uvs}}else if(b=g.ribbonOptions?new Ml(r,n,g):new $h(r,n,g),e){var B={materialType:e.materialType,dashCount:e.dashCount,dashOffset:e.dashOffset,dashRatio:e.dashRatio,resolution:e.resolution,sizeAttenuation:e.sizeAttenuation,useColors:e.useColors,useDash:e.useDash,visibility:e.visibility,width:e.width,color:e.color,colorMode:e.colorMode,colorsSampling:e.colorsSampling,colorDistributionType:e.colorDistributionType,colors:f,cameraFacing:!t.ribbonOptions,colorsTexture:e.colorsTexture};if(e.createAndAssignMaterial){var F=v0(r,B,n);b.material=F,((v=t.ribbonOptions)===null||v===void 0?void 0:v.facesMode)===1&&(F.backFaceCulling=!1)}}if(f&&t.instance&&t.instance.greasedLineMaterial){var X=t.instance.greasedLineMaterial.colors;if(X){var $=X.concat(f);t.instance.greasedLineMaterial.setColors($,b.isLazy())}}return b}function y0(r){for(var t=0,e=0,n=r;e<n.length;e++)t+=n[e].length/3;return t}function b0(r,t,e,n,i){n===void 0&&(n=1),i===void 0&&(i=1);var o=r-t.length/2,a=[];if(o<0)return t.slice(0,2*r);if(o>0){if(t.length%2!=0&&t.push(n),e===5){for(var s=Math.floor(t.length/2),l=0,c=0;l<s-1;l++)a.push(t[c++]),a.push(t[c++]);var u=t[s/2],d=t[s/2+1];for(l=0;l<o;l++)a.push(d),a.push(u);for(l=s;l<t.length;l+=2)a.push(t[l]),a.push(t[l+1])}else if(e===3){for(l=0;l<t.length;l+=2)a.push(t[l]),a.push(t[l+1]);for(l=0;l<o;l++)a.push(n),a.push(i)}else if(e===4){for(l=0;l<o;l++)a.push(n),a.push(i);for(l=0;l<t.length;l+=2)a.push(t[l]),a.push(t[l+1])}else if(e===1){l=0;for(var h=0;h<r;h++)a.push(t[l++]),a.push(t[l++]),l===t.length&&(l=0)}else if(e===2){c=0;var p=t.length/(2*(r-1));for(h=0;h<r;h++)l=Math.floor(c),a.push(t[l]),a.push(t[l+1]),c+=p}}else for(l=0;l<t.length;l++)a.push(t[l]);return a}function T0(r,t,e,n){var i=(r=Math.max(t.length,r))-t.length;if(i<0)return t.slice(0,r);var o=[];if(i>0){if(e===5){for(var a=Math.floor(t.length/2),s=0;s<a;s++)o.push(t[s]);for(s=0;s<i-1;s++)o.push(n);for(s=a;s<t.length;s++)o.push(t[s])}else if(e===3){for(s=0;s<t.length;s++)o.push(t[s]);for(s=0;s<i;s++)o.push(n)}else if(e===4){for(s=0;s<i-1;s++)o.push(n);for(s=0;s<t.length;s++)o.push(t[s])}else if(e===1){s=0;for(var l=0;l<r;l++)o.push(t[s]),++s===t.length&&(s=0)}else if(e===2){var c=0,u=t.length/(r-1);for(l=0;l<r-1;l++)s=Math.floor(c),o.push(t[s]),c+=u}else if(e===0)for(s=0;s<t.length;s++)o.push(t[s])}else for(s=0;s<r;s++)o.push(t[s]);return o}(function(r){r[r.COLOR_DISTRIBUTION_NONE=0]="COLOR_DISTRIBUTION_NONE",r[r.COLOR_DISTRIBUTION_REPEAT=1]="COLOR_DISTRIBUTION_REPEAT",r[r.COLOR_DISTRIBUTION_EVEN=2]="COLOR_DISTRIBUTION_EVEN",r[r.COLOR_DISTRIBUTION_START=3]="COLOR_DISTRIBUTION_START",r[r.COLOR_DISTRIBUTION_END=4]="COLOR_DISTRIBUTION_END",r[r.COLOR_DISTRIBUTION_START_END=5]="COLOR_DISTRIBUTION_START_END"})(ef||(ef={})),function(r){r[r.WIDTH_DISTRIBUTION_NONE=0]="WIDTH_DISTRIBUTION_NONE",r[r.WIDTH_DISTRIBUTION_REPEAT=1]="WIDTH_DISTRIBUTION_REPEAT",r[r.WIDTH_DISTRIBUTION_EVEN=2]="WIDTH_DISTRIBUTION_EVEN",r[r.WIDTH_DISTRIBUTION_START=3]="WIDTH_DISTRIBUTION_START",r[r.WIDTH_DISTRIBUTION_END=4]="WIDTH_DISTRIBUTION_END",r[r.WIDTH_DISTRIBUTION_START_END=5]="WIDTH_DISTRIBUTION_START_END"}(tf||(tf={})),xe.prototype.thinInstanceAdd=function(r,t){if(t===void 0&&(t=!0),!this.getScene().getEngine().getCaps().instancedArrays)return O.V.Error("Thin Instances are not supported on this device as Instanced Array extension not supported"),-1;this._thinInstanceUpdateBufferSize("matrix",Array.isArray(r)?r.length:1);var e=this._thinInstanceDataStorage.instancesCount;if(Array.isArray(r))for(var n=0;n<r.length;++n)this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,r[n],n===r.length-1&&t);else this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,r,t);return e},xe.prototype.thinInstanceAddSelf=function(r){return r===void 0&&(r=!0),this.thinInstanceAdd(_.uq.IdentityReadOnly,r)},xe.prototype.thinInstanceRegisterAttribute=function(r,t){r===Y.R.ColorKind&&(r=Y.R.ColorInstanceKind),this.removeVerticesData(r),this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.strides[r]=t,this._userThinInstanceBuffersStorage.sizes[r]=t*Math.max(32,this._thinInstanceDataStorage.instancesCount),this._userThinInstanceBuffersStorage.data[r]=new Float32Array(this._userThinInstanceBuffersStorage.sizes[r]),this._userThinInstanceBuffersStorage.vertexBuffers[r]=new Y.R(this.getEngine(),this._userThinInstanceBuffersStorage.data[r],r,!0,!1,t,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r])},xe.prototype.thinInstanceSetMatrixAt=function(r,t,e){if(e===void 0&&(e=!0),!this._thinInstanceDataStorage.matrixData||r>=this._thinInstanceDataStorage.instancesCount)return!1;var n=this._thinInstanceDataStorage.matrixData;return t.copyToArray(n,16*r),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[r]=t),e&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},xe.prototype.thinInstanceSetAttributeAt=function(r,t,e,n){return n===void 0&&(n=!0),r===Y.R.ColorKind&&(r=Y.R.ColorInstanceKind),!(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[r]||t>=this._thinInstanceDataStorage.instancesCount||(this._thinInstanceUpdateBufferSize(r,0),this._userThinInstanceBuffersStorage.data[r].set(e,t*this._userThinInstanceBuffersStorage.strides[r]),n&&this.thinInstanceBufferUpdated(r),0))},Object.defineProperty(xe.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(r){var t,e,n=(t=this._thinInstanceDataStorage.matrixData)!==null&&t!==void 0?t:(e=this.source)===null||e===void 0?void 0:e._thinInstanceDataStorage.matrixData;r<=(n?n.length/16:0)&&(this._thinInstanceDataStorage.instancesCount=r)},enumerable:!0,configurable:!0}),xe.prototype._thinInstanceCreateMatrixBuffer=function(r,t,e){e===void 0&&(e=!0);for(var n=new Y.h(this.getEngine(),t,!e,16,!1,!0),i=0;i<4;i++)this.setVerticesBuffer(n.createVertexBuffer(r+i,4*i,4));return n},xe.prototype.thinInstanceSetBuffer=function(r,t,e,n){var i,o,a;e===void 0&&(e=0),n===void 0&&(n=!0),e=e||16,r==="matrix"?((i=this._thinInstanceDataStorage.matrixBuffer)===null||i===void 0||i.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=t?t.length:32*e,this._thinInstanceDataStorage.matrixData=t,this._thinInstanceDataStorage.worldMatrices=null,t!==null?(this._thinInstanceDataStorage.instancesCount=t.length/e,this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",t,n),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)):(this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo())):r==="previousMatrix"?((o=this._thinInstanceDataStorage.previousMatrixBuffer)===null||o===void 0||o.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=null,this._thinInstanceDataStorage.previousMatrixData=t,t!==null&&(this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",t,n))):(r===Y.R.ColorKind&&(r=Y.R.ColorInstanceKind),t===null?!((a=this._userThinInstanceBuffersStorage)===null||a===void 0)&&a.data[r]&&(this.removeVerticesData(r),delete this._userThinInstanceBuffersStorage.data[r],delete this._userThinInstanceBuffersStorage.strides[r],delete this._userThinInstanceBuffersStorage.sizes[r],delete this._userThinInstanceBuffersStorage.vertexBuffers[r]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[r]=t,this._userThinInstanceBuffersStorage.strides[r]=e,this._userThinInstanceBuffersStorage.sizes[r]=t.length,this._userThinInstanceBuffersStorage.vertexBuffers[r]=new Y.R(this.getEngine(),t,r,!n,!1,e,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r])))},xe.prototype.thinInstanceBufferUpdated=function(r){var t,e,n;r==="matrix"?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.matrixBuffer&&!this._thinInstanceDataStorage.matrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(r),(t=this._thinInstanceDataStorage.matrixBuffer)===null||t===void 0||t.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount)):r==="previousMatrix"?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.previousMatrixBuffer&&!this._thinInstanceDataStorage.previousMatrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(r),(e=this._thinInstanceDataStorage.previousMatrixBuffer)===null||e===void 0||e.updateDirectly(this._thinInstanceDataStorage.previousMatrixData,0,this._thinInstanceDataStorage.instancesCount)):(r===Y.R.ColorKind&&(r=Y.R.ColorInstanceKind),!((n=this._userThinInstanceBuffersStorage)===null||n===void 0)&&n.vertexBuffers[r]&&(this.thinInstanceAllowAutomaticStaticBufferRecreation&&!this._userThinInstanceBuffersStorage.vertexBuffers[r].isUpdatable()&&this._thinInstanceRecreateBuffer(r),this._userThinInstanceBuffersStorage.vertexBuffers[r].updateDirectly(this._userThinInstanceBuffersStorage.data[r],0)))},xe.prototype.thinInstancePartialBufferUpdate=function(r,t,e){var n;r==="matrix"?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,e):(r===Y.R.ColorKind&&(r=Y.R.ColorInstanceKind),!((n=this._userThinInstanceBuffersStorage)===null||n===void 0)&&n.vertexBuffers[r]&&this._userThinInstanceBuffersStorage.vertexBuffers[r].updateDirectly(t,e))},xe.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];var r=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=[];for(var t=0;t<this._thinInstanceDataStorage.instancesCount;++t)this._thinInstanceDataStorage.worldMatrices[t]=_.uq.FromArray(r,16*t)}return this._thinInstanceDataStorage.worldMatrices},xe.prototype.thinInstanceRefreshBoundingInfo=function(r,t,e){if(r===void 0&&(r=!1),t===void 0&&(t=!1),e===void 0&&(e=!1),this._thinInstanceDataStorage.matrixData&&this._thinInstanceDataStorage.matrixBuffer){var n=this._thinInstanceDataStorage.boundingVectors;if(r||!this.rawBoundingInfo){n.length=0,this.refreshBoundingInfo(t,e);var i=this.getBoundingInfo();this.rawBoundingInfo=new tr(i.minimum,i.maximum)}var o=this.getBoundingInfo(),a=this._thinInstanceDataStorage.matrixData;if(n.length===0)for(var s=0;s<o.boundingBox.vectors.length;++s)n.push(o.boundingBox.vectors[s].clone());_.AA.Vector3[0].setAll(Number.POSITIVE_INFINITY),_.AA.Vector3[1].setAll(Number.NEGATIVE_INFINITY);for(var l=0;l<this._thinInstanceDataStorage.instancesCount;++l)for(_.uq.FromArrayToRef(a,16*l,_.AA.Matrix[0]),s=0;s<n.length;++s)_.Pq.TransformCoordinatesToRef(n[s],_.AA.Matrix[0],_.AA.Vector3[2]),_.AA.Vector3[0].minimizeInPlace(_.AA.Vector3[2]),_.AA.Vector3[1].maximizeInPlace(_.AA.Vector3[2]);o.reConstruct(_.AA.Vector3[0],_.AA.Vector3[1]),this._updateBoundingInfo()}},xe.prototype._thinInstanceRecreateBuffer=function(r,t){var e,n,i,o;t===void 0&&(t=!0),r==="matrix"?((e=this._thinInstanceDataStorage.matrixBuffer)===null||e===void 0||e.dispose(),this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",this._thinInstanceDataStorage.matrixData,t)):r==="previousMatrix"?this._scene.needsPreviousWorldMatrices&&((n=this._thinInstanceDataStorage.previousMatrixBuffer)===null||n===void 0||n.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",(i=this._thinInstanceDataStorage.previousMatrixData)!==null&&i!==void 0?i:this._thinInstanceDataStorage.matrixData,t)):(r===Y.R.ColorKind&&(r=Y.R.ColorInstanceKind),(o=this._userThinInstanceBuffersStorage.vertexBuffers[r])===null||o===void 0||o.dispose(),this._userThinInstanceBuffersStorage.vertexBuffers[r]=new Y.R(this.getEngine(),this._userThinInstanceBuffersStorage.data[r],r,!t,!1,this._userThinInstanceBuffersStorage.strides[r],!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r]))},xe.prototype._thinInstanceUpdateBufferSize=function(r,t){var e,n,i;t===void 0&&(t=1),r===Y.R.ColorKind&&(r=Y.R.ColorInstanceKind);var o=r==="matrix";if(o||this._userThinInstanceBuffersStorage&&this._userThinInstanceBuffersStorage.strides[r]){for(var a=o?16:this._userThinInstanceBuffersStorage.strides[r],s=o?this._thinInstanceDataStorage.matrixBufferSize:this._userThinInstanceBuffersStorage.sizes[r],l=o?this._thinInstanceDataStorage.matrixData:this._userThinInstanceBuffersStorage.data[r],c=(this._thinInstanceDataStorage.instancesCount+t)*a,u=s;u<c;)u*=2;if(!l||s!=u){if(l){var d=new Float32Array(u);d.set(l,0),l=d}else l=new Float32Array(u);o?((e=this._thinInstanceDataStorage.matrixBuffer)===null||e===void 0||e.dispose(),this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",l,!1),this._thinInstanceDataStorage.matrixData=l,this._thinInstanceDataStorage.matrixBufferSize=u,this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&((n=this._thinInstanceDataStorage.previousMatrixBuffer)===null||n===void 0||n.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",l,!1))):((i=this._userThinInstanceBuffersStorage.vertexBuffers[r])===null||i===void 0||i.dispose(),this._userThinInstanceBuffersStorage.data[r]=l,this._userThinInstanceBuffersStorage.sizes[r]=u,this._userThinInstanceBuffersStorage.vertexBuffers[r]=new Y.R(this.getEngine(),l,r,!0,!1,a,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r]))}}},xe.prototype._thinInstanceInitializeUserStorage=function(){this._userThinInstanceBuffersStorage||(this._userThinInstanceBuffersStorage={data:{},sizes:{},vertexBuffers:{},strides:{}})},xe.prototype._disposeThinInstanceSpecificData=function(){var r;!((r=this._thinInstanceDataStorage)===null||r===void 0)&&r.matrixBuffer&&(this._thinInstanceDataStorage.matrixBuffer.dispose(),this._thinInstanceDataStorage.matrixBuffer=null)},function(r){r[r.Int=1]="Int",r[r.Float=2]="Float",r[r.Vector2=4]="Vector2",r[r.Vector3=8]="Vector3",r[r.Vector4=16]="Vector4",r[r.Matrix=32]="Matrix",r[r.Geometry=64]="Geometry",r[r.Texture=128]="Texture",r[r.AutoDetect=1024]="AutoDetect",r[r.BasedOnInput=2048]="BasedOnInput",r[r.Undefined=4096]="Undefined",r[r.All=4095]="All"}(se||(se={})),function(r){r[r.Compatible=0]="Compatible",r[r.TypeIncompatible=1]="TypeIncompatible",r[r.HierarchyIssue=2]="HierarchyIssue"}(nf||(nf={})),function(r){r[r.Input=0]="Input",r[r.Output=1]="Output"}(rf||(rf={}));var Qt,of=function(){function r(t,e,n){this._connectedPoint=null,this._storedValue=null,this._storedFunction=null,this._acceptedConnectionPointType=null,this._endpoints=new Array,this._type=se.Geometry,this._linkedConnectionSource=null,this._typeConnectionSource=null,this._defaultConnectionPointType=null,this.acceptedConnectionPointTypes=[],this.excludedConnectionPointTypes=[],this.onConnectionObservable=new K.cP,this.onDisconnectionObservable=new K.cP,this.isExposedOnFrame=!1,this.exposedPortPosition=-1,this.defaultValue=null,this.value=null,this.valueMin=null,this.valueMax=null,this._callCount=0,this._executionCount=0,this._ownerBlock=e,this.name=t,this._direction=n}return Object.defineProperty(r.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){if(this._type===se.AutoDetect){if(this._ownerBlock.isInput)return this._ownerBlock.type;if(this._connectedPoint)return this._connectedPoint.type;if(this._linkedConnectionSource&&this._linkedConnectionSource.isConnected)return this._linkedConnectionSource.type}if(this._type===se.BasedOnInput){if(this._typeConnectionSource)return!this._typeConnectionSource.isConnected&&this._defaultConnectionPointType?this._defaultConnectionPointType:this._typeConnectionSource.type;if(this._defaultConnectionPointType)return this._defaultConnectionPointType}return this._type},set:function(t){this._type=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isConnected",{get:function(){return this.connectedPoint!==null||this.hasEndpoints},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectedPoint",{get:function(){return this._connectedPoint},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ownerBlock",{get:function(){return this._ownerBlock},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sourceBlock",{get:function(){return this._connectedPoint?this._connectedPoint.ownerBlock:null},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"connectedBlocks",{get:function(){return this._endpoints.length===0?[]:this._endpoints.map(function(t){return t.ownerBlock})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"endpoints",{get:function(){return this._endpoints},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasEndpoints",{get:function(){return this._endpoints&&this._endpoints.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"innerType",{get:function(){return this._linkedConnectionSource&&this._linkedConnectionSource.isConnected?this.type:this._type},enumerable:!1,configurable:!0}),r.prototype._resetCounters=function(){this._callCount=0,this._executionCount=0},Object.defineProperty(r.prototype,"callCount",{get:function(){return this._callCount},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"executionCount",{get:function(){return this._executionCount},enumerable:!1,configurable:!0}),r.prototype.getConnectedValue=function(t){var e;return this.isConnected?!((e=this._connectedPoint)===null||e===void 0)&&e._storedFunction?(this._connectedPoint._callCount++,this._connectedPoint._executionCount++,this._connectedPoint._storedFunction(t)):(this._connectedPoint._callCount++,this._connectedPoint._executionCount=1,this._connectedPoint._storedValue):(this._callCount++,this._executionCount=1,this.value)},r.prototype.getClassName=function(){return"NodeGeometryConnectionPoint"},r.prototype.canConnectTo=function(t){return this.checkCompatibilityState(t)===0},r.prototype.checkCompatibilityState=function(t){var e=this._ownerBlock,n=t.ownerBlock;if(this.type!==t.type&&t.innerType!==se.AutoDetect)return t.acceptedConnectionPointTypes&&t.acceptedConnectionPointTypes.indexOf(this.type)!==-1?0:1;if(t.excludedConnectionPointTypes&&t.excludedConnectionPointTypes.indexOf(this.type)!==-1)return 1;var i=n,o=e;return this.direction===0&&(i=e,o=n),i.isAnAncestorOf(o)?2:0},r.prototype.connectTo=function(t,e){if(e===void 0&&(e=!1),!e&&!this.canConnectTo(t))throw"Cannot connect these two connectors.";return this._endpoints.push(t),t._connectedPoint=this,this.onConnectionObservable.notifyObservers(t),t.onConnectionObservable.notifyObservers(this),this},r.prototype.disconnectFrom=function(t){var e=this._endpoints.indexOf(t);return e===-1||(this._endpoints.splice(e,1),t._connectedPoint=null,this.onDisconnectionObservable.notifyObservers(t),t.onDisconnectionObservable.notifyObservers(this)),this},r.prototype.addExcludedConnectionPointFromAllowedTypes=function(t){for(var e=1;e<se.All;)t&e||this.excludedConnectionPointTypes.push(e),e<<=1},r.prototype.serialize=function(t){t===void 0&&(t=!0);var e={};return e.name=this.name,e.displayName=this.displayName,this.value!==void 0&&this.value!==null&&(this.value.asArray?(e.valueType="BABYLON."+this.value.getClassName(),e.value=this.value.asArray()):(e.valueType="number",e.value=this.value)),t&&this.connectedPoint&&(e.inputName=this.name,e.targetBlockId=this.connectedPoint.ownerBlock.uniqueId,e.targetConnectionName=this.connectedPoint.name,e.isExposedOnFrame=!0,e.exposedPortPosition=this.exposedPortPosition),(this.isExposedOnFrame||this.exposedPortPosition>=0)&&(e.isExposedOnFrame=!0,e.exposedPortPosition=this.exposedPortPosition),e},r.prototype.dispose=function(){this.onConnectionObservable.clear(),this.onDisconnectionObservable.clear()},r}(),Tt=function(){function r(t){this._name="",this._isInput=!1,this._isTeleportOut=!1,this._isTeleportIn=!1,this._isDebug=!1,this._isUnique=!1,this._buildExecutionTime=0,this.onBuildObservable=new K.cP,this._inputs=new Array,this._outputs=new Array,this._codeVariableName="",this.visibleOnFrame=!1,this._name=t,this.uniqueId=Lx.K.UniqueId}return Object.defineProperty(r.prototype,"buildExecutionTime",{get:function(){return this._buildExecutionTime},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"inputs",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"outputs",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},set:function(t){this._name=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isTeleportOut",{get:function(){return this._isTeleportOut},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isTeleportIn",{get:function(){return this._isTeleportIn},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isDebug",{get:function(){return this._isDebug},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isUnique",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"NodeGeometryBlock"},r.prototype._inputRename=function(t){return t},r.prototype._outputRename=function(t){return t},r.prototype.isAnAncestorOf=function(t){for(var e=0,n=this._outputs;e<n.length;e++){var i=n[e];if(i.hasEndpoints)for(var o=0,a=i.endpoints;o<a.length;o++){var s=a[o];if(s.ownerBlock===t||s.ownerBlock.isAnAncestorOf(t))return!0}}return!1},r.prototype.isAnAncestorOfType=function(t){if(this.getClassName()===t)return!0;for(var e=0,n=this._outputs;e<n.length;e++){var i=n[e];if(i.hasEndpoints){for(var o=0,a=i.endpoints;o<a.length;o++)if(a[o].ownerBlock.isAnAncestorOfType(t))return!0}}return!1},r.prototype.getDescendantOfPredicate=function(t){if(t(this))return this;for(var e=0,n=this._outputs;e<n.length;e++){var i=n[e];if(i.hasEndpoints)for(var o=0,a=i.endpoints;o<a.length;o++){var s=a[o].ownerBlock.getDescendantOfPredicate(t);if(s)return s}}return null},r.prototype.registerInput=function(t,e,n,i,o,a){n===void 0&&(n=!1);var s=new of(t,this,0);return s.type=e,s.isOptional=n,s.defaultValue=i,s.value=i,s.valueMin=o,s.valueMax=a,this._inputs.push(s),this},r.prototype.registerOutput=function(t,e,n){return(n=n??new of(t,this,1)).type=e,this._outputs.push(n),this},r.prototype._buildBlock=function(t){},r.prototype._customBuildStep=function(t){},r.prototype.build=function(t){if(this._buildId===t.buildId)return!0;if(this._outputs.length>0){if(!this._outputs.some(function(d){return d.hasEndpoints})&&!this.isDebug)return!1;this.outputs.forEach(function(d){return d._resetCounters()})}this._buildId=t.buildId;for(var e=0,n=this._inputs;e<n.length;e++){var i=n[e];i.connectedPoint?(u=i.connectedPoint.ownerBlock)&&u!==this&&u.build(t):i.isOptional||t.notConnectedNonOptionalInputs.push(i)}this._customBuildStep(t),t.verbose&&O.V.Log("Building ".concat(this.name," [").concat(this.getClassName(),"]"));var o=et.j.Now;this._buildBlock(t),this._buildExecutionTime=et.j.Now-o;for(var a=0,s=this._outputs;a<s.length;a++)for(var l=0,c=s[a].endpoints;l<c.length;l++){var u;(u=c[l].ownerBlock)&&u.build(t)}return this.onBuildObservable.notifyObservers(this),!1},r.prototype._linkConnectionTypes=function(t,e,n){n===void 0&&(n=!1),n?this._inputs[e]._acceptedConnectionPointType=this._inputs[t]:this._inputs[t]._linkedConnectionSource=this._inputs[e],this._inputs[e]._linkedConnectionSource=this._inputs[t]},r.prototype.initialize=function(){},r.prototype.autoConfigure=function(){},r.prototype.getInputByName=function(t){var e=this._inputs.filter(function(n){return n.name===t});return e.length?e[0]:null},r.prototype.getOutputByName=function(t){var e=this._outputs.filter(function(n){return n.name===t});return e.length?e[0]:null},r.prototype.serialize=function(){var t={};t.customType="BABYLON."+this.getClassName(),t.id=this.uniqueId,t.name=this.name,t.visibleOnFrame=this.visibleOnFrame,t.inputs=[],t.outputs=[];for(var e=0,n=this.inputs;e<n.length;e++){var i=n[e];t.inputs.push(i.serialize())}for(var o=0,a=this.outputs;o<a.length;o++){var s=a[o];t.outputs.push(s.serialize(!1))}return t},r.prototype._deserialize=function(t){this._name=t.name,this.comments=t.comments,this.visibleOnFrame=!!t.visibleOnFrame,this._deserializePortDisplayNamesAndExposedOnFrame(t)},r.prototype._deserializePortDisplayNamesAndExposedOnFrame=function(t){var e=this,n=t.inputs,i=t.outputs;n&&n.forEach(function(o){var a=e.inputs.find(function(l){return l.name===o.name});if(a&&(o.displayName&&(a.displayName=o.displayName),o.isExposedOnFrame&&(a.isExposedOnFrame=o.isExposedOnFrame,a.exposedPortPosition=o.exposedPortPosition),o.value!==void 0&&o.value!==null))if(o.valueType==="number")a.value=o.value;else{var s=(0,j.n9)(o.valueType);s&&(a.value=s.FromArray(o.value))}}),i&&i.forEach(function(o,a){o.displayName&&(e.outputs[a].displayName=o.displayName),o.isExposedOnFrame&&(e.outputs[a].isExposedOnFrame=o.isExposedOnFrame,e.outputs[a].exposedPortPosition=o.exposedPortPosition)})},r.prototype._dumpPropertiesCode=function(){var t=this._codeVariableName;return"".concat(t,".visibleOnFrame = ").concat(this.visibleOnFrame,`;
|
||
`)},r.prototype._dumpCodeForOutputConnections=function(t){var e="";if(t.indexOf(this)!==-1)return e;t.push(this);for(var n=0,i=this.inputs;n<i.length;n++){var o=i[n];if(o.isConnected){var a=o.connectedPoint,s=a.ownerBlock;e+=s._dumpCodeForOutputConnections(t),e+="".concat(s._codeVariableName,".").concat(s._outputRename(a.name),".connectTo(").concat(this._codeVariableName,".").concat(this._inputRename(o.name),`);
|
||
`)}}return e},r.prototype._dumpCode=function(t,e){e.push(this);var n=this.name.replace(/[^A-Za-z_]+/g,"");if(this._codeVariableName=n||"".concat(this.getClassName(),"_").concat(this.uniqueId),t.indexOf(this._codeVariableName)!==-1){var i=0;do i++,this._codeVariableName=n+i;while(t.indexOf(this._codeVariableName)!==-1)}t.push(this._codeVariableName);var o=`
|
||
// `.concat(this.getClassName(),`
|
||
`);this.comments&&(o+="// ".concat(this.comments,`
|
||
`));var a=this.getClassName();if(a==="GeometryInputBlock"){var s=this.type;o+="var ".concat(this._codeVariableName,' = new BABYLON.GeometryInputBlock("').concat(this.name,'", ').concat(s,`);
|
||
`)}else o+="var ".concat(this._codeVariableName," = new BABYLON.").concat(a,'("').concat(this.name,`");
|
||
`);o+=this._dumpPropertiesCode();for(var l=0,c=this.inputs;l<c.length;l++){var u=c[l];if(u.isConnected){var d=u.connectedPoint.ownerBlock;e.indexOf(d)===-1&&(o+=d._dumpCode(t,e))}}for(var h=0,p=this.outputs;h<p.length;h++){var m=p[h];if(m.hasEndpoints)for(var v=0,b=m.endpoints;v<b.length;v++)(d=b[v].ownerBlock)&&e.indexOf(d)===-1&&(o+=d._dumpCode(t,e))}return o},r.prototype.clone=function(){var t=this.serialize(),e=(0,j.n9)(t.customType);if(e){var n=new e;return n._deserialize(t),n}return null},r.prototype.dispose=function(){for(var t=0,e=this.inputs;t<e.length;t++)e[t].dispose();for(var n=0,i=this.outputs;n<i.length;n++)i[n].dispose();this.onBuildObservable.clear()},(0,A.Cg)([(0,V.lK)("comment")],r.prototype,"comments",void 0),r}(),af=function(r){function t(e){var n=r.call(this,e)||this;return n._vertexData=null,n._isUnique=!0,n.registerInput("geometry",se.Geometry),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"currentVertexData",{get:function(){return this._vertexData},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"GeometryOutputBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){e.vertexData=this.geometry.getConnectedValue(e),this._vertexData=e.vertexData},t}(Tt);(0,j.Y5)("BABYLON.GeometryOutputBlock",af),function(r){r[r.None=0]="None",r[r.Positions=1]="Positions",r[r.Normals=2]="Normals",r[r.Tangents=3]="Tangents",r[r.UV=4]="UV",r[r.UV2=5]="UV2",r[r.UV3=6]="UV3",r[r.UV4=7]="UV4",r[r.UV5=8]="UV5",r[r.UV6=9]="UV6",r[r.Colors=10]="Colors",r[r.VertexID=11]="VertexID",r[r.FaceID=12]="FaceID",r[r.GeometryID=13]="GeometryID",r[r.CollectionID=14]="CollectionID",r[r.LoopID=15]="LoopID",r[r.InstanceID=16]="InstanceID"}(Qt||(Qt={}));var S0=function(){function r(){this._rotationMatrix=new _.uq,this._scalingMatrix=new _.uq,this._positionMatrix=new _.uq,this._scalingRotationMatrix=new _.uq,this._transformMatrix=new _.uq,this._tempVector3=new _.Pq,this.notConnectedNonOptionalInputs=[],this.noContextualData=[],this.vertexData=null,this._geometryContext=null,this._executionContext=null,this._instancingContext=null,this._geometryContextStack=[],this._executionContextStack=[],this._instancingContextStack=[]}return Object.defineProperty(r.prototype,"geometryContext",{get:function(){return this._geometryContext},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"executionContext",{get:function(){return this._executionContext},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"instancingContext",{get:function(){return this._instancingContext},enumerable:!1,configurable:!0}),r.prototype.pushGeometryContext=function(t){this._geometryContext=t,this._geometryContextStack.push(this._geometryContext)},r.prototype.pushExecutionContext=function(t){this._executionContext=t,this._executionContextStack.push(this._executionContext)},r.prototype.pushInstancingContext=function(t){this._instancingContext=t,this._instancingContextStack.push(this._instancingContext)},r.prototype.restoreGeometryContext=function(){this._geometryContextStack.pop(),this._geometryContext=this._geometryContextStack.length>0?this._geometryContextStack[this._geometryContextStack.length-1]:null},r.prototype.restoreExecutionContext=function(){this._executionContextStack.pop(),this._executionContext=this._executionContextStack.length>0?this._executionContextStack[this._executionContextStack.length-1]:null},r.prototype.restoreInstancingContext=function(){this._instancingContextStack.pop(),this._instancingContext=this._instancingContextStack.length>0?this._instancingContextStack[this._instancingContextStack.length-1]:null},r.prototype.getContextualValue=function(t,e){if(e===void 0&&(e=!1),!this.executionContext)return e||this.noContextualData.push(t),null;var n=this.executionContext.getExecutionIndex();switch(t){case Qt.Positions:return this.executionContext.getOverridePositionsContextualValue?this.executionContext.getOverridePositionsContextualValue():this.geometryContext&&this.geometryContext.positions?_.Pq.FromArray(this.geometryContext.positions,3*n):_.Pq.Zero();case Qt.Normals:return this.executionContext.getOverrideNormalsContextualValue?this.executionContext.getOverrideNormalsContextualValue():this.geometryContext&&this.geometryContext.normals?_.Pq.FromArray(this.geometryContext.normals,3*n):_.Pq.Zero();case Qt.Colors:return this.geometryContext&&this.geometryContext.colors?_.IU.FromArray(this.geometryContext.colors,4*n):_.IU.Zero();case Qt.Tangents:return this.geometryContext&&this.geometryContext.tangents?_.IU.FromArray(this.geometryContext.tangents,4*n):_.IU.Zero();case Qt.UV:return this.executionContext.getOverrideUVs1ContextualValue?this.executionContext.getOverrideUVs1ContextualValue():this.geometryContext&&this.geometryContext.uvs?_.I9.FromArray(this.geometryContext.uvs,2*n):_.I9.Zero();case Qt.UV2:return this.geometryContext&&this.geometryContext.uvs2?_.I9.FromArray(this.geometryContext.uvs2,2*n):_.I9.Zero();case Qt.UV3:return this.geometryContext&&this.geometryContext.uvs3?_.I9.FromArray(this.geometryContext.uvs3,2*n):_.I9.Zero();case Qt.UV4:return this.geometryContext&&this.geometryContext.uvs4?_.I9.FromArray(this.geometryContext.uvs4,2*n):_.I9.Zero();case Qt.UV5:return this.geometryContext&&this.geometryContext.uvs5?_.I9.FromArray(this.geometryContext.uvs5,2*n):_.I9.Zero();case Qt.UV6:return this.geometryContext&&this.geometryContext.uvs6?_.I9.FromArray(this.geometryContext.uvs6,2*n):_.I9.Zero();case Qt.VertexID:return n;case Qt.FaceID:return this.executionContext.getExecutionFaceIndex();case Qt.LoopID:return this.executionContext.getExecutionLoopIndex();case Qt.InstanceID:return this.instancingContext?this.instancingContext.getInstanceIndex():0;case Qt.GeometryID:return this.geometryContext?this.geometryContext.uniqueId:0;case Qt.CollectionID:return this.geometryContext&&this.geometryContext.metadata&&this.geometryContext.metadata.collectionId||0}return null},r.prototype.adapt=function(t,e){var n=t.getConnectedValue(this)||0;if(t.type===e)return n;switch(e){case se.Vector2:return new _.I9(n,n);case se.Vector3:return new _.Pq(n,n,n);case se.Vector4:return new _.IU(n,n,n,n)}return null},r.prototype.adaptInput=function(t,e,n){var i;if(!t.isConnected)return t.value||n;var o=t.getConnectedValue(this);if(((i=t._connectedPoint)===null||i===void 0?void 0:i.type)===e)return o;switch(e){case se.Vector2:return new _.I9(o,o);case se.Vector3:return new _.Pq(o,o,o);case se.Vector4:return new _.IU(o,o,o,o)}return null},r.prototype.emitErrors=function(){for(var t="",e=0,n=this.notConnectedNonOptionalInputs;e<n.length;e++){var i=n[e];t+="input ".concat(i.name," from block ").concat(i.ownerBlock.name,"[").concat(i.ownerBlock.getClassName(),`] is not connected and is not optional.
|
||
`)}for(var o=0,a=this.noContextualData;o<a.length;o++){var s=a[o];t+="Contextual input ".concat(Qt[s],` has no context to pull data from (must be connected to a setXXX block or a instantiateXXX block).
|
||
`)}if(t)throw`Build of NodeGeometry failed:
|
||
`+t},r.prototype._instantiate=function(t,e,n,i,o){_.uq.ScalingToRef(i.x,i.y,i.z,this._scalingMatrix),_.uq.RotationYawPitchRollToRef(n.y,n.x,n.z,this._rotationMatrix),_.uq.TranslationToRef(e.x,e.y,e.z,this._positionMatrix),this._scalingMatrix.multiplyToRef(this._rotationMatrix,this._scalingRotationMatrix),this._scalingRotationMatrix.multiplyToRef(this._positionMatrix,this._transformMatrix);for(var a=0;a<t.positions.length;a+=3)this._tempVector3.fromArray(t.positions,a),_.Pq.TransformCoordinatesToRef(this._tempVector3,this._transformMatrix,this._tempVector3),this._tempVector3.toArray(t.positions,a),t.normals&&(this._tempVector3.fromArray(t.normals,a),_.Pq.TransformNormalToRef(this._tempVector3,this._scalingRotationMatrix,this._tempVector3),this._tempVector3.toArray(t.normals,a));o.push(t)},r.prototype._instantiateWithMatrix=function(t,e,n){for(var i=0;i<t.positions.length;i+=3)this._tempVector3.fromArray(t.positions,i),_.Pq.TransformCoordinatesToRef(this._tempVector3,e,this._tempVector3),this._tempVector3.toArray(t.positions,i),t.normals&&(this._tempVector3.fromArray(t.normals,i),_.Pq.TransformNormalToRef(this._tempVector3,e,this._tempVector3),this._tempVector3.toArray(t.normals,i));n.push(t)},r.prototype._instantiateWithPositionAndMatrix=function(t,e,n,i){_.uq.TranslationToRef(e.x,e.y,e.z,this._positionMatrix),n.multiplyToRef(this._positionMatrix,this._transformMatrix);for(var o=0;o<t.positions.length;o+=3)this._tempVector3.fromArray(t.positions,o),_.Pq.TransformCoordinatesToRef(this._tempVector3,this._transformMatrix,this._tempVector3),this._tempVector3.toArray(t.positions,o),t.normals&&(this._tempVector3.fromArray(t.normals,o),_.Pq.TransformNormalToRef(this._tempVector3,this._transformMatrix,this._tempVector3),this._tempVector3.toArray(t.normals,o));i.push(t)},r}(),Nn=function(r){function t(e,n){n===void 0&&(n=se.AutoDetect);var i=r.call(this,e)||this;return i._type=se.Undefined,i._contextualSource=Qt.None,i.min=0,i.max=0,i.groupInInspector="",i.onValueChangedObservable=new K.cP,i._type=n,i._isInput=!0,i.setDefaultValue(),i.registerOutput("output",n),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"type",{get:function(){if(this._type===se.AutoDetect&&this.value!=null){if(!isNaN(this.value))return this._type=se.Float,this._type;switch(this.value.getClassName()){case"Vector2":return this._type=se.Vector2,this._type;case"Vector3":return this._type=se.Vector3,this._type;case"Vector4":return this._type=se.Vector4,this._type;case"Matrix":return this._type=se.Matrix,this._type}}return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isContextual",{get:function(){return this._contextualSource!==Qt.None},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"contextualValue",{get:function(){return this._contextualSource},set:function(e){switch(this._contextualSource=e,e){case Qt.Positions:case Qt.Normals:this._type=se.Vector3;break;case Qt.Colors:case Qt.Tangents:this._type=se.Vector4;break;case Qt.UV:case Qt.UV2:case Qt.UV3:case Qt.UV4:case Qt.UV5:case Qt.UV6:this._type=se.Vector2;break;case Qt.VertexID:case Qt.GeometryID:case Qt.CollectionID:case Qt.FaceID:case Qt.LoopID:case Qt.InstanceID:this._type=se.Int}this.output&&(this.output.type=this._type)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._storedValue},set:function(e){this.type===se.Float&&this.min!==this.max&&(e=Math.max(this.min,e),e=Math.min(this.max,e)),this._storedValue=e,this.onValueChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"valueCallback",{get:function(){return this._valueCallback},set:function(e){this._valueCallback=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"GeometryInputBlock"},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.setDefaultValue=function(){switch(this.contextualValue=Qt.None,this.type){case se.Int:case se.Float:this.value=0;break;case se.Vector2:this.value=_.I9.Zero();break;case se.Vector3:this.value=_.Pq.Zero();break;case se.Vector4:this.value=_.IU.Zero();break;case se.Matrix:this.value=_.uq.Identity()}},t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.isContextual?(this.output._storedValue=null,this.output._storedFunction=function(i){return i.getContextualValue(n._contextualSource)}):(this.output._storedFunction=null,this.output._storedValue=this.value)},t.prototype.dispose=function(){this.onValueChangedObservable.clear(),r.prototype.dispose.call(this)},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName;if(this.isContextual)return r.prototype._dumpPropertiesCode.call(this)+"".concat(e,".contextualValue = BABYLON.NodeGeometryContextualSources.").concat(Qt[this._contextualSource],`;
|
||
`);var n=[],i="";switch(this.type){case se.Float:case se.Int:i="".concat(this.value);break;case se.Vector2:i="new BABYLON.Vector2(".concat(this.value.x,", ").concat(this.value.y,")");break;case se.Vector3:i="new BABYLON.Vector3(".concat(this.value.x,", ").concat(this.value.y,", ").concat(this.value.z,")");break;case se.Vector4:i="new BABYLON.Vector4(".concat(this.value.x,", ").concat(this.value.y,", ").concat(this.value.z,", ").concat(this.value.w,")")}return n.push("".concat(e,".value = ").concat(i)),this.type!==se.Float&&this.type!==se.Int||n.push("".concat(e,".min = ").concat(this.min),"".concat(e,".max = ").concat(this.max)),n.push(""),r.prototype._dumpPropertiesCode.call(this)+n.join(`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.type=this.type,e.contextualValue=this.contextualValue,e.min=this.min,e.max=this.max,e.groupInInspector=this.groupInInspector,this._storedValue===null||this.isContextual||(this._storedValue.asArray?(e.valueType="BABYLON."+this._storedValue.getClassName(),e.value=this._storedValue.asArray()):(e.valueType="number",e.value=this._storedValue)),e},t.prototype._deserialize=function(e){if(r.prototype._deserialize.call(this,e),this._type=e.type,this.contextualValue=e.contextualValue,this.min=e.min||0,this.max=e.max||0,this.groupInInspector=e.groupInInspector||"",e.valueType)if(e.valueType==="number")this._storedValue=e.value;else{var n=(0,j.n9)(e.valueType);n&&(this._storedValue=n.FromArray(e.value))}},t}(Tt);(0,j.Y5)("BABYLON.GeometryInputBlock",Nn);var sf=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("size",se.Float,!0,1),n.registerInput("width",se.Float,!0,0),n.registerInput("height",se.Float,!0,0),n.registerInput("depth",se.Float,!0,0),n.registerInput("subdivisions",se.Int,!0,1),n.registerInput("subdivisionsX",se.Int,!0,0),n.registerInput("subdivisionsY",se.Int,!0,0),n.registerInput("subdivisionsZ",se.Int,!0,0),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"BoxBlock"},Object.defineProperty(t.prototype,"size",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depth",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisions",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsZ",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.size.isConnected){if(!this.width.isConnected&&!this.height.isConnected&&!this.depth.isConnected){var e=new Nn("Size");return e.value=1,void e.output.connectTo(this.size)}if(!this.width.isConnected){var n=new Nn("Width");n.value=1,n.output.connectTo(this.width)}if(!this.height.isConnected){var i=new Nn("Height");i.value=1,i.output.connectTo(this.height)}if(!this.depth.isConnected){var o=new Nn("Depth");o.value=1,o.output.connectTo(this.depth)}}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){i.size=n.size.getConnectedValue(s),i.width=n.width.getConnectedValue(s),i.height=n.height.getConnectedValue(s),i.depth=n.depth.getConnectedValue(s);var l=n.subdivisions.getConnectedValue(s),c=n.subdivisionsX.getConnectedValue(s),u=n.subdivisionsY.getConnectedValue(s),d=n.subdivisionsZ.getConnectedValue(s);return l&&(i.segments=l),c&&(i.widthSegments=c),u&&(i.heightSegments=u),d&&(i.depthSegments=d),ng(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.BoxBlock",sf);var CC=function(){function r(t){this._buildId=r._BuildIdGenerator++,this._buildWasSuccessful=!1,this._vertexData=null,this._buildExecutionTime=0,this.BJSNODEGEOMETRYEDITOR=this._getGlobalNodeGeometryEditor(),this.editorData=null,this.attachedBlocks=[],this.onBuildObservable=new K.cP,this.outputBlock=null,this.name=t}return r.prototype._getGlobalNodeGeometryEditor=function(){return typeof NODEGEOMETRYEDITOR<"u"?NODEGEOMETRYEDITOR:typeof BABYLON<"u"&&BABYLON.NodeGeometryEditor!==void 0?BABYLON:void 0},Object.defineProperty(r.prototype,"buildExecutionTime",{get:function(){return this._buildExecutionTime},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"NodeGeometry"},Object.defineProperty(r.prototype,"vertexData",{get:function(){return this._vertexData},enumerable:!1,configurable:!0}),r.prototype.getBlockByName=function(t){for(var e=null,n=0,i=this.attachedBlocks;n<i.length;n++){var o=i[n];if(o.name===t){if(e)return ze.S0.Warn("More than one block was found with the name `"+t+"`"),e;e=o}}return e},r.prototype.getBlockByPredicate=function(t){for(var e=0,n=this.attachedBlocks;e<n.length;e++){var i=n[e];if(t(i))return i}return null},r.prototype.getInputBlocks=function(){for(var t=[],e=0,n=this.attachedBlocks;e<n.length;e++){var i=n[e];i.isInput&&t.push(i)}return t},r.prototype.edit=function(t){var e=this;return new Promise(function(n){if(e.BJSNODEGEOMETRYEDITOR=e.BJSNODEGEOMETRYEDITOR||e._getGlobalNodeGeometryEditor(),e.BJSNODEGEOMETRYEDITOR===void 0){var i=t&&t.editorURL?t.editorURL:r.EditorURL;ze.S0.LoadBabylonScript(i,function(){e.BJSNODEGEOMETRYEDITOR=e.BJSNODEGEOMETRYEDITOR||e._getGlobalNodeGeometryEditor(),e._createNodeEditor(t?.nodeGeometryEditorConfig),n()})}else e._createNodeEditor(t?.nodeGeometryEditorConfig),n()})},r.prototype._createNodeEditor=function(t){var e=(0,A.Cl)({nodeGeometry:this},t);this.BJSNODEGEOMETRYEDITOR.NodeGeometryEditor.Show(e)},r.prototype.build=function(t,e,n){if(t===void 0&&(t=!1),e===void 0&&(e=!0),n===void 0&&(n=!1),this._buildWasSuccessful=!1,!this.outputBlock)throw"You must define the outputBlock property before building the geometry";var i=et.j.Now;this._initializeBlock(this.outputBlock,n);var o=new S0;o.buildId=this._buildId,o.verbose=t,this.outputBlock.build(o),e&&(this._buildId=r._BuildIdGenerator++),this._buildExecutionTime=et.j.Now-i,o.emitErrors(),this._buildWasSuccessful=!0,this._vertexData=o.vertexData,this.onBuildObservable.notifyObservers(this)},r.prototype.createMesh=function(t,e){if(e===void 0&&(e=null),this._buildWasSuccessful||this.build(),!this._vertexData)return null;var n=new xe(t,e);return this._vertexData.applyToMesh(n),n._internalMetadata=n._internalMetadata||{},n._internalMetadata.nodeGeometry=this,n},r.prototype.updateMesh=function(t){return this._buildWasSuccessful||this.build(),!!this._vertexData&&(this._vertexData.applyToMesh(t),t._internalMetadata=t._internalMetadata||{},t._internalMetadata.nodeGeometry=this,t)},r.prototype._initializeBlock=function(t,e){e===void 0&&(e=!0),t.initialize(),e&&t.autoConfigure(),t._preparationId=this._buildId,this.attachedBlocks.indexOf(t)===-1&&this.attachedBlocks.push(t);for(var n=0,i=t.inputs;n<i.length;n++){var o=i[n].connectedPoint;if(o){var a=o.ownerBlock;a!==t&&this._initializeBlock(a,e)}}},r.prototype.clear=function(){this.outputBlock=null,this.attachedBlocks.length=0},r.prototype.removeBlock=function(t){var e=this.attachedBlocks.indexOf(t);e>-1&&this.attachedBlocks.splice(e,1),t===this.outputBlock&&(this.outputBlock=null)},r.prototype.parseSerializedObject=function(t,e){e===void 0&&(e=!1),e||this.clear();for(var n={},i=0,o=t.blocks;i<o.length;i++){var a=o[i],s=(0,j.n9)(a.customType);s&&((m=new s)._deserialize(a),n[a.id]=m,this.attachedBlocks.push(m))}for(var l=0,c=this.attachedBlocks;l<c.length;l++)if((m=c[l]).isTeleportOut){var u=m,d=u._tempEntryPointUniqueId;if(d){var h=n[d];h&&h.attachToEndpoint(u)}}for(var p=0;p<t.blocks.length;p++){var m;(m=n[(a=t.blocks[p]).id])&&(m.inputs.length&&a.inputs.some(function(g){return g.targetConnectionName})&&!e||this._restoreConnections(m,t,n))}if(t.outputNodeId&&(this.outputBlock=n[t.outputNodeId]),t.locations||t.editorData&&t.editorData.locations){for(var v=t.locations||t.editorData.locations,b=0,E=v;b<E.length;b++){var C=E[b];n[C.blockId]&&(C.blockId=n[C.blockId].uniqueId)}e&&this.editorData&&this.editorData.locations&&v.concat(this.editorData.locations),t.locations?this.editorData={locations:v}:(this.editorData=t.editorData,this.editorData.locations=v);var T=[];for(var f in n)T[f]=n[f].uniqueId;this.editorData.map=T}this.comment=t.comment},r.prototype._restoreConnections=function(t,e,n){for(var i=0,o=t.outputs;i<o.length;i++)for(var a=o[i],s=0,l=e.blocks;s<l.length;s++){var c=l[s],u=n[c.id];if(u)for(var d=0,h=c.inputs;d<h.length;d++){var p=h[d];if(!(n[p.targetBlockId]!==t||p.targetConnectionName!==a.name)){var m=u.getInputByName(p.inputName);if(!m||m.isConnected)continue;a.connectTo(m,!0),this._restoreConnections(u,e,n)}}}},r.prototype.generateCode=function(){var t=[],e=[],n=["const","var","let"];this.outputBlock&&this._gatherBlocks(this.outputBlock,e);for(var i='let nodeGeometry = new BABYLON.NodeGeometry("'.concat(this.name||"node geometry",`");
|
||
`),o=0,a=e;o<a.length;o++){var s=a[o];s.isInput&&t.indexOf(s)===-1&&(i+=s._dumpCode(n,t))}return this.outputBlock&&(t=[],i+=`// Connections
|
||
`,i+=this.outputBlock._dumpCodeForOutputConnections(t),i+=`// Output nodes
|
||
`,i+="nodeGeometry.outputBlock = ".concat(this.outputBlock._codeVariableName,`;
|
||
`),i+=`nodeGeometry.build();
|
||
`),i},r.prototype._gatherBlocks=function(t,e){if(e.indexOf(t)===-1){e.push(t);for(var n=0,i=t.inputs;n<i.length;n++){var o=i[n].connectedPoint;o&&(a=o.ownerBlock)!==t&&this._gatherBlocks(a,e)}var a;t.isTeleportOut&&(a=t).entryPoint&&this._gatherBlocks(a.entryPoint,e)}},r.prototype.setToDefault=function(){this.clear(),this.editorData=null;var t=new sf("Box");t.autoConfigure();var e=new af("Geometry Output");t.geometry.connectTo(e.geometry),this.outputBlock=e},r.prototype.clone=function(t){var e=this.serialize(),n=tt.p.Clone(function(){return new r(t)},this);return n.name=t,n.parseSerializedObject(e),n._buildId=this._buildId,n.build(!1),n},r.prototype.serialize=function(t){var e=t?{}:tt.p.Serialize(this);e.editorData=JSON.parse(JSON.stringify(this.editorData));var n=[];t?n=t:(e.customType="BABYLON.NodeGeometry",this.outputBlock&&(e.outputNodeId=this.outputBlock.uniqueId)),e.blocks=[];for(var i=0,o=n;i<o.length;i++){var a=o[i];e.blocks.push(a.serialize())}if(!t)for(var s=0,l=this.attachedBlocks;s<l.length;s++)a=l[s],n.indexOf(a)===-1&&e.blocks.push(a.serialize());return e},r.prototype.dispose=function(){for(var t=0,e=this.attachedBlocks;t<e.length;t++)e[t].dispose();this.attachedBlocks.length=0,this.onBuildObservable.clear()},r.CreateDefault=function(t){var e=new r(t);return e.setToDefault(),e.build(),e},r.Parse=function(t){var e=tt.p.Parse(function(){return new r(t.name)},t,null);return e.parseSerializedObject(t),e.build(),e},r.ParseFromSnippetAsync=function(t,e,n){var i=this;return n===void 0&&(n=!1),t==="_BLANK"?Promise.resolve(r.CreateDefault("blank")):new Promise(function(o,a){var s=new We.u;s.addEventListener("readystatechange",function(){if(s.readyState==4)if(s.status==200){var l=JSON.parse(JSON.parse(s.responseText).jsonPayload),c=JSON.parse(l.nodeGeometry);e||(e=tt.p.Parse(function(){return new r(t)},c,null)),e.parseSerializedObject(c),e.snippetId=t;try{n||e.build(),o(e)}catch(u){a(u)}}else a("Unable to load the snippet "+t)}),s.open("GET",i.SnippetUrl+"/"+t.replace(/#/g,"/")),s.send()})},r._BuildIdGenerator=0,r.EditorURL="".concat(ze.S0._DefaultCdnUrl,"/v").concat(Be.$.Version,"/nodeGeometryEditor/babylon.nodeGeometryEditor.js"),r.SnippetUrl=P.Y.SnippetUrl,(0,A.Cg)([(0,V.lK)()],r.prototype,"name",void 0),(0,A.Cg)([(0,V.lK)("comment")],r.prototype,"comment",void 0),r}(),E0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.epsilon=pt.bH,n.registerInput("geometry",se.Geometry),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryOptimizeBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){if(!n.geometry.isConnected)return null;for(var a=n.geometry.getConnectedValue(o),s=[],l={},c=0;c<a.positions.length;c+=3){for(var u=a.positions[c],d=a.positions[c+1],h=a.positions[c+2],p=!1,m=0;m<s.length;m+=3)(0,qe.WithinEpsilon)(u,s[m],n.epsilon)&&(0,qe.WithinEpsilon)(d,s[m+1],n.epsilon)&&(0,qe.WithinEpsilon)(h,s[m+2],n.epsilon)&&(l[c/3]=m/3,p=!0);p||(l[c/3]=s.length/3,s.push(u,d,h))}var v=new rt;return v.positions=s,v.indices=a.indices.map(function(b){return l[b]}),v};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)+"".concat(this._codeVariableName,".epsilon = ").concat(this.epsilon,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e.epsilon=this.epsilon,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext,this.epsilon=e.epsilon},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),(0,A.Cg)([dt("Epsilon",1,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"epsilon",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryOptimizeBlock",E0);var x0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("size",se.Float,!0,1),n.registerInput("width",se.Float,!0,0),n.registerInput("height",se.Float,!0,0),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"PlaneBlock"},Object.defineProperty(t.prototype,"size",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.size.isConnected){if(!this.width.isConnected&&!this.height.isConnected){var e=new Nn("Size");return e.value=1,void e.output.connectTo(this.size)}if(!this.width.isConnected){var n=new Nn("Width");n.value=1,n.output.connectTo(this.width)}if(!this.height.isConnected){var i=new Nn("Height");i.value=1,i.output.connectTo(this.height)}}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.size=n.size.getConnectedValue(s),i.width=n.width.getConnectedValue(s),i.height=n.height.getConnectedValue(s),Is(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.PlaneBlock",x0);var P0=function(r){function t(e){var n=r.call(this,e)||this;return n._cachedVertexData=null,n.reverseWindingOrder=!1,n.serializedCachedData=!1,n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this._mesh=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"MeshBlock"},Object.defineProperty(t.prototype,"isUsingCachedData",{get:function(){return!this.mesh&&!!this._cachedVertexData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.cleanData=function(){this._mesh=null,this._cachedVertexData=null},t.prototype._buildBlock=function(){if(this._mesh){var e=rt.ExtractFromMesh(this._mesh,!1,!0);if(this._cachedVertexData=null,this.reverseWindingOrder&&e.indices)for(var n=0;n<e.indices.length;n+=3){var i=e.indices[n];e.indices[n]=e.indices[n+2],e.indices[n+2]=i}this.geometry._storedFunction=function(){return e.clone()}}else this._cachedVertexData?this.geometry._storedValue=this._cachedVertexData.clone():this.geometry._storedValue=null},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.serializedCachedData=this.serializedCachedData,this.serializedCachedData&&(this._mesh?e.cachedVertexData=rt.ExtractFromMesh(this._mesh,!1,!0).serialize():this._cachedVertexData&&(e.cachedVertexData=this._cachedVertexData.serialize())),e.reverseWindingOrder=this.reverseWindingOrder,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.cachedVertexData&&(this._cachedVertexData=rt.Parse(e.cachedVertexData)),this.serializedCachedData=!!e.serializedCachedData,this.reverseWindingOrder=e.reverseWindingOrder},(0,A.Cg)([dt("Serialize cached data",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"serializedCachedData",void 0),t}(Tt);(0,j.Y5)("BABYLON.MeshBlock",P0);var A0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("radius",se.Float,!0,1),n.registerInput("radiusX",se.Float,!0,0),n.registerInput("radiusY",se.Float,!0,0),n.registerInput("radiusZ",se.Float,!0,0),n.registerInput("subdivisions",se.Int,!0,4),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"IcoSphereBlock"},Object.defineProperty(t.prototype,"radius",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radiusX",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radiusY",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radiusZ",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisions",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.radius.isConnected){var e=new Nn("Radius");e.value=.2,e.output.connectTo(this.radius)}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.radius=n.radius.getConnectedValue(s),i.subdivisions=n.subdivisions.getConnectedValue(s),i.radiusX=n.radiusX.getConnectedValue(s),i.radiusY=n.radiusY.getConnectedValue(s),i.radiusZ=n.radiusZ.getConnectedValue(s),$s(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.IcoSphereBlock",A0);var C0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("segments",se.Int,!0,32),n.registerInput("diameter",se.Float,!0,1),n.registerInput("diameterX",se.Float,!0,0),n.registerInput("diameterY",se.Float,!0,0),n.registerInput("diameterZ",se.Float,!0,0),n.registerInput("arc",se.Float,!0,1),n.registerInput("slice",se.Float,!0,1),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SphereBlock"},Object.defineProperty(t.prototype,"segments",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diameter",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diameterX",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diameterY",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diameterZ",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"arc",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"slice",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.diameter.isConnected){var e=new Nn("Diameter");e.value=1,e.output.connectTo(this.diameter)}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.segments=n.segments.getConnectedValue(s),i.diameter=n.diameter.getConnectedValue(s),i.diameterX=n.diameterX.getConnectedValue(s),i.diameterY=n.diameterY.getConnectedValue(s),i.diameterZ=n.diameterZ.getConnectedValue(s),i.arc=n.arc.getConnectedValue(s),i.slice=n.slice.getConnectedValue(s),Xs(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.SphereBlock",C0);var R0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("width",se.Float,!0,1),n.registerInput("height",se.Float,!0,1),n.registerInput("subdivisions",se.Int,!0,1),n.registerInput("subdivisionsX",se.Int,!0,0),n.registerInput("subdivisionsY",se.Int,!0,0),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GridBlock"},Object.defineProperty(t.prototype,"width",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisions",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.width.isConnected){var e=new Nn("Width");e.value=1,e.output.connectTo(this.width)}if(!this.height.isConnected){var n=new Nn("Height");n.value=1,n.output.connectTo(this.height)}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.width=n.width.getConnectedValue(s),i.height=n.height.getConnectedValue(s),i.subdivisions=n.subdivisions.getConnectedValue(s),i.subdivisionsX=n.subdivisionsX.getConnectedValue(s),i.subdivisionsY=n.subdivisionsY.getConnectedValue(s),Wr(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.GridBlock",R0);var I0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("diameter",se.Float,!0,1),n.registerInput("thickness",se.Float,!0,.5),n.registerInput("tessellation",se.Int,!0,16),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TorusBlock"},Object.defineProperty(t.prototype,"diameter",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"thickness",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tessellation",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.diameter.isConnected){var e=new Nn("Diameter");e.value=1,e.output.connectTo(this.diameter)}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.thickness=n.thickness.getConnectedValue(s),i.diameter=n.diameter.getConnectedValue(s),i.tessellation=n.tessellation.getConnectedValue(s),zs(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.TorusBlock",I0);var M0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("height",se.Float,!0,25),n.registerInput("diameter",se.Float,!0,1),n.registerInput("diameterTop",se.Float,!0,-1),n.registerInput("diameterBottom",se.Float,!0,-1),n.registerInput("subdivisions",se.Int,!0,1),n.registerInput("tessellation",se.Int,!0,24),n.registerInput("arc",se.Float,!0,1),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"CylinderBlock"},Object.defineProperty(t.prototype,"height",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diameter",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diameterTop",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diameterBottom",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisions",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tessellation",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"arc",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.diameter.isConnected){var e=new Nn("Diameter");e.value=1,e.output.connectTo(this.diameter)}if(!this.height.isConnected){var n=new Nn("Height");n.value=1,n.output.connectTo(this.height)}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.height=n.height.getConnectedValue(s),i.diameter=n.diameter.getConnectedValue(s),i.diameterTop=n.diameterTop.getConnectedValue(s),i.diameterBottom=n.diameterBottom.getConnectedValue(s),i.diameterTop===-1&&(i.diameterTop=i.diameter),i.diameterBottom===-1&&(i.diameterBottom=i.diameter),i.tessellation=n.tessellation.getConnectedValue(s),i.subdivisions=n.subdivisions.getConnectedValue(s),i.arc=n.arc.getConnectedValue(s),Ws(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.CylinderBlock",M0);var O0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("height",se.Float,!0,1),n.registerInput("radius",se.Float,!0,.25),n.registerInput("tessellation",se.Int,!0,16),n.registerInput("subdivisions",se.Int,!0,2),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"CapsuleBlock"},Object.defineProperty(t.prototype,"height",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tessellation",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisions",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.height.isConnected){var e=new Nn("Height");e.value=1,e.output.connectTo(this.height)}if(!this.radius.isConnected){var n=new Nn("Radius");n.value=.2,n.output.connectTo(this.radius)}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.height=n.height.getConnectedValue(s),i.radius=n.radius.getConnectedValue(s),i.tessellation=n.tessellation.getConnectedValue(s),i.subdivisions=n.subdivisions.getConnectedValue(s),js(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.CapsuleBlock",O0);var D0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("radius",se.Float,!0,.5),n.registerInput("tessellation",se.Int,!0,64),n.registerInput("arc",se.Float,!0,1),n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DiscBlock"},Object.defineProperty(t.prototype,"radius",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tessellation",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"arc",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.radius.isConnected){var e=new Nn("Radius");e.value=.2,e.output.connectTo(this.radius)}},t.prototype._buildBlock=function(e){var n=this,i={},o=function(s){return i.radius=n.radius.getConnectedValue(s),i.tessellation=n.tessellation.getConnectedValue(s),i.arc=n.arc.getConnectedValue(s),qs(i)};if(this.evaluateContext)this.geometry._storedFunction=o;else{var a=o(e);this.geometry._storedFunction=function(){return n.geometry._executionCount=1,a.clone()}}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.DiscBlock",D0);var N0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerOutput("geometry",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"NullBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){this.geometry._storedValue=null},t}(Tt);(0,j.Y5)("BABYLON.NullBlock",N0);var L0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.registerInput("geometry",se.Geometry),n.registerInput("positions",se.Vector3),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"SetPositionsBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"positions",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){if(o.pushExecutionContext(n),n._vertexData=n.geometry.getConnectedValue(o),n._vertexData&&(n._vertexData=n._vertexData.clone()),o.pushGeometryContext(n._vertexData),!n._vertexData||!n._vertexData.positions||!n.positions.isConnected)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=null);var a=n._vertexData.positions.length/3;for(n._currentIndex=0;n._currentIndex<a;n._currentIndex++){var s=n.positions.getConnectedValue(o);s&&s.toArray(n._vertexData.positions,3*n._currentIndex)}return o.restoreGeometryContext(),o.restoreExecutionContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.SetPositionsBlock",L0);var F0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.registerInput("geometry",se.Geometry),n.registerInput("normals",se.Vector3),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"SetNormalsBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normals",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){if(o.pushExecutionContext(n),n._vertexData=n.geometry.getConnectedValue(o),n._vertexData&&(n._vertexData=n._vertexData.clone()),o.pushGeometryContext(n._vertexData),!n._vertexData||!n._vertexData.positions)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=null);if(!n.normals.isConnected)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=n._vertexData);n._vertexData.normals||(n._vertexData.normals=[]);var a=n._vertexData.positions.length/3;for(n._currentIndex=0;n._currentIndex<a;n._currentIndex++){var s=n.normals.getConnectedValue(o);s&&s.toArray(n._vertexData.normals,3*n._currentIndex)}return o.restoreGeometryContext(),o.restoreExecutionContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.SetNormalsBlock",F0);var w0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.textureCoordinateIndex=0,n.registerInput("geometry",se.Geometry),n.registerInput("uvs",se.Vector2),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"SetUVsBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uvs",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){if(o.pushExecutionContext(n),n._vertexData=n.geometry.getConnectedValue(o),n._vertexData&&(n._vertexData=n._vertexData.clone()),o.pushGeometryContext(n._vertexData),!n._vertexData||!n._vertexData.positions)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=null);if(!n.uvs.isConnected)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=n._vertexData);var a=[],s=n._vertexData.positions.length/3;for(n._currentIndex=0;n._currentIndex<s;n._currentIndex++){var l=n.uvs.getConnectedValue(o);l&&l.toArray(a,2*n._currentIndex)}switch(n.textureCoordinateIndex){case 0:n._vertexData.uvs=a;break;case 1:n._vertexData.uvs2=a;break;case 2:n._vertexData.uvs3=a;break;case 3:n._vertexData.uvs4=a;break;case 4:n._vertexData.uvs5=a;break;case 5:n._vertexData.uvs6=a}return o.restoreGeometryContext(),o.restoreExecutionContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,`.textureCoordinateIndex};
|
||
`)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e.textureCoordinateIndex=this.textureCoordinateIndex,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.textureCoordinateIndex=e.textureCoordinateIndex,e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),(0,A.Cg)([dt("Texture coordinates index",4,"ADVANCED",{notifiers:{update:!0},options:[{label:"UV1",value:0},{label:"UV2",value:1},{label:"UV3",value:2},{label:"UV4",value:3},{label:"UV5",value:4},{label:"UV6",value:5}]})],t.prototype,"textureCoordinateIndex",void 0),t}(Tt);(0,j.Y5)("BABYLON.SetUVsBlock",w0);var B0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.registerInput("geometry",se.Geometry),n.registerInput("colors",se.AutoDetect),n.registerOutput("output",se.Geometry),n._inputs[1].excludedConnectionPointTypes.push(se.Int),n._inputs[1].excludedConnectionPointTypes.push(se.Float),n._inputs[1].excludedConnectionPointTypes.push(se.Vector2),n._inputs[1].excludedConnectionPointTypes.push(se.Texture),n._inputs[1].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"SetColorsBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colors",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){var a;if(o.pushExecutionContext(n),n._vertexData=n.geometry.getConnectedValue(o),n._vertexData&&(n._vertexData=n._vertexData.clone()),o.pushGeometryContext(n._vertexData),!n._vertexData||!n._vertexData.positions)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=null);if(!n.colors.isConnected)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=n._vertexData);n._vertexData.colors||(n._vertexData.colors=[]);var s=n._vertexData.positions.length/3;for(n._currentIndex=0;n._currentIndex<s;n._currentIndex++)if(((a=n.colors.connectedPoint)===null||a===void 0?void 0:a.type)===se.Vector3){var l=n.colors.getConnectedValue(o);l&&(l.toArray(n._vertexData.colors,4*n._currentIndex),n._vertexData.colors[4*n._currentIndex+3]=1,n._vertexData.hasVertexAlpha=!1)}else{var c=n.colors.getConnectedValue(o);c&&(c.toArray(n._vertexData.colors,4*n._currentIndex),n._vertexData.hasVertexAlpha=!0)}return o.restoreGeometryContext(),o.restoreExecutionContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.SetColorsBlock",B0);var xi,V0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.registerInput("geometry",se.Geometry),n.registerInput("tangents",se.Vector4),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"SetTangentsBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangents",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){if(o.pushExecutionContext(n),n._vertexData=n.geometry.getConnectedValue(o),n._vertexData&&(n._vertexData=n._vertexData.clone()),o.pushGeometryContext(n._vertexData),!n._vertexData||!n._vertexData.positions)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=null);if(!n.tangents.isConnected)return o.restoreGeometryContext(),o.restoreExecutionContext(),void(n.output._storedValue=n._vertexData);n._vertexData.tangents||(n._vertexData.tangents=[]);var a=n._vertexData.positions.length/3;for(n._currentIndex=0;n._currentIndex<a;n._currentIndex++){var s=n.tangents.getConnectedValue(o);s&&s.toArray(n._vertexData.tangents,4*n._currentIndex)}return o.restoreGeometryContext(),o.restoreExecutionContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.SetTangentsBlock",V0),function(r){r[r.Add=0]="Add",r[r.Subtract=1]="Subtract",r[r.Multiply=2]="Multiply",r[r.Divide=3]="Divide",r[r.Max=4]="Max",r[r.Min=5]="Min"}(xi||(xi={}));var U0=function(r){function t(e){var n,i,o=r.call(this,e)||this;o.operation=xi.Add,o.registerInput("left",se.AutoDetect),o.registerInput("right",se.AutoDetect),o.registerOutput("output",se.BasedOnInput),o.output._typeConnectionSource=o.left;var a=[se.Matrix,se.Geometry,se.Texture];return(n=o.left.excludedConnectionPointTypes).push.apply(n,a),(i=o.right.excludedConnectionPointTypes).push.apply(i,a),o._linkConnectionTypes(0,1),o._connectionObservers=[o.left.onConnectionObservable.add(function(){return o._updateInputOutputTypes()}),o.left.onDisconnectionObservable.add(function(){return o._updateInputOutputTypes()}),o.right.onConnectionObservable.add(function(){return o._updateInputOutputTypes()}),o.right.onDisconnectionObservable.add(function(){return o._updateInputOutputTypes()})],o}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MathBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e,n,i,o=this.left,a=this.right;if(!o.isConnected||!a.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var s=o.type===se.Float||o.type===se.Int,l=a.type===se.Float||a.type===se.Int,c=s&&l;switch(this.operation){case xi.Add:i=c?function(m){return o.getConnectedValue(m)+a.getConnectedValue(m)}:s?function(m){return m.adapt(o,a.type).add(a.getConnectedValue(m))}:function(m){return o.getConnectedValue(m).add(m.adapt(a,o.type))};break;case xi.Subtract:i=c?function(m){return o.getConnectedValue(m)-a.getConnectedValue(m)}:s?function(m){return m.adapt(o,a.type).subtract(a.getConnectedValue(m))}:function(m){return o.getConnectedValue(m).subtract(m.adapt(a,o.type))};break;case xi.Multiply:i=c?function(m){return o.getConnectedValue(m)*a.getConnectedValue(m)}:s?function(m){return m.adapt(o,a.type).multiply(a.getConnectedValue(m))}:function(m){return o.getConnectedValue(m).multiply(m.adapt(a,o.type))};break;case xi.Divide:i=c?function(m){return o.getConnectedValue(m)/a.getConnectedValue(m)}:s?function(m){return m.adapt(o,a.type).divide(a.getConnectedValue(m))}:function(m){return o.getConnectedValue(m).divide(m.adapt(a,o.type))};break;case xi.Min:if(c)i=function(m){return Math.min(o.getConnectedValue(m),a.getConnectedValue(m))};else{var u=(e=s?[a,o]:[o,a])[0],d=e[1];switch(u.type){case se.Vector2:i=function(m){return _.I9.Minimize(u.getConnectedValue(m),m.adapt(d,u.type))};break;case se.Vector3:i=function(m){return _.Pq.Minimize(u.getConnectedValue(m),m.adapt(d,u.type))};break;case se.Vector4:i=function(m){return _.IU.Minimize(u.getConnectedValue(m),m.adapt(d,u.type))}}}break;case xi.Max:if(!c){var h=(n=s?[a,o]:[o,a])[0],p=n[1];switch(h.type){case se.Vector2:i=function(m){return _.I9.Maximize(h.getConnectedValue(m),m.adapt(p,h.type))};break;case se.Vector3:i=function(m){return _.Pq.Maximize(h.getConnectedValue(m),m.adapt(p,h.type))};break;case se.Vector4:i=function(m){return _.IU.Maximize(h.getConnectedValue(m),m.adapt(p,h.type))}}break}i=function(m){return Math.max(o.getConnectedValue(m),a.getConnectedValue(m))}}this.output._storedFunction=function(m){return o.type===se.Int?0|i(m):i(m)}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".operation = BABYLON.MathBlockOperations.").concat(xi[this.operation],`;
|
||
`)},t.prototype._updateInputOutputTypes=function(){if(this.output._typeConnectionSource=this.left,this.left.isConnected&&this.right.isConnected?(this.left.type===se.Int||this.left.type===se.Float&&this.right.type!==se.Int)&&(this.output._typeConnectionSource=this.right):this.left.isConnected!==this.right.isConnected&&(this.output._typeConnectionSource=this.left.isConnected?this.left:this.right),this.left.isConnected||this.right.isConnected)for(var e=0,n=[[this.left,this.right],[this.right,this.left]];e<n.length;e++){var i=n[e],o=i[0],a=i[1];o.acceptedConnectionPointTypes=[se.Int,se.Float],a.isConnected&&(o.acceptedConnectionPointTypes.push(a.type),a.type!==se.Int&&a.type!==se.Float||o.acceptedConnectionPointTypes.push(se.Vector2,se.Vector3,se.Vector4))}},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._connectionObservers.forEach(function(e){return e.remove()}),this._connectionObservers.length=0},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.operation=this.operation,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.operation=e.operation},(0,A.Cg)([dt("Operation",4,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Add",value:xi.Add},{label:"Subtract",value:xi.Subtract},{label:"Multiply",value:xi.Multiply},{label:"Divide",value:xi.Divide},{label:"Max",value:xi.Max},{label:"Min",value:xi.Min}]})],t.prototype,"operation",void 0),t}(Tt);(0,j.Y5)("BABYLON.MathBlock",U0);var Kn,G0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("value",se.AutoDetect),n.registerInput("fromMin",se.Float,!0,0),n.registerInput("fromMax",se.Float,!0,1),n.registerInput("toMin",se.Float,!0,0),n.registerInput("toMax",se.Float,!0,1),n.registerOutput("output",se.BasedOnInput),n._inputs[0].excludedConnectionPointTypes.push(se.Vector2),n._inputs[0].excludedConnectionPointTypes.push(se.Vector3),n._inputs[0].excludedConnectionPointTypes.push(se.Vector4),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MapRangeBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fromMin",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fromMax",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toMin",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toMax",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.value.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);this.output._storedFunction=function(n){var i=e.value.getConnectedValue(n),o=e.fromMin.getConnectedValue(n),a=e.fromMax.getConnectedValue(n),s=e.toMin.getConnectedValue(n),l=(i-o)/(a-o)*(e.toMax.getConnectedValue(n)-s)+s;return e.output.type===se.Int?Math.floor(l):l}},t}(Tt);(0,j.Y5)("BABYLON.MapRangeBlock",G0),function(r){r[r.Equal=0]="Equal",r[r.NotEqual=1]="NotEqual",r[r.LessThan=2]="LessThan",r[r.GreaterThan=3]="GreaterThan",r[r.LessOrEqual=4]="LessOrEqual",r[r.GreaterOrEqual=5]="GreaterOrEqual",r[r.Xor=6]="Xor",r[r.Or=7]="Or",r[r.And=8]="And"}(Kn||(Kn={}));var Qi,k0=function(r){function t(e){var n=r.call(this,e)||this;return n.test=Kn.Equal,n.registerInput("left",se.Float),n.registerInput("right",se.Float,!0,0),n.registerInput("ifTrue",se.AutoDetect,!0,1),n.registerInput("ifFalse",se.AutoDetect,!0,0),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[2],n._outputs[0]._defaultConnectionPointType=se.Float,n._inputs[0].acceptedConnectionPointTypes.push(se.Int),n._inputs[1].acceptedConnectionPointTypes.push(se.Int),n._linkConnectionTypes(2,3),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ConditionBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ifTrue",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ifFalse",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.left.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);this.output._storedFunction=function(n){return function(i){var o=e.left.getConnectedValue(i),a=e.right.getConnectedValue(i),s=!1;switch(e.test){case Kn.Equal:s=(0,qe.WithinEpsilon)(o,a,pt.bH);break;case Kn.NotEqual:s=o!==a;break;case Kn.LessThan:s=o<a;break;case Kn.GreaterThan:s=o>a;break;case Kn.LessOrEqual:s=o<=a;break;case Kn.GreaterOrEqual:s=o>=a;break;case Kn.Xor:s=!!o&&!a||!o&&!!a;break;case Kn.Or:s=!!o||!!a;break;case Kn.And:s=!!o&&!!a}return s}(n)?e.ifTrue.getConnectedValue(n):e.ifFalse.getConnectedValue(n)}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".test = BABYLON.ConditionBlockTests.").concat(Kn[this.test],`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.test=this.test,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.test=e.test},(0,A.Cg)([dt("Test",4,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Equal",value:Kn.Equal},{label:"NotEqual",value:Kn.NotEqual},{label:"LessThan",value:Kn.LessThan},{label:"GreaterThan",value:Kn.GreaterThan},{label:"LessOrEqual",value:Kn.LessOrEqual},{label:"GreaterOrEqual",value:Kn.GreaterOrEqual},{label:"Xor",value:Kn.Xor},{label:"Or",value:Kn.Or},{label:"And",value:Kn.And}]})],t.prototype,"test",void 0),t}(Tt);(0,j.Y5)("BABYLON.ConditionBlock",k0),function(r){r[r.None=0]="None",r[r.LoopID=1]="LoopID",r[r.InstanceID=2]="InstanceID",r[r.Once=3]="Once"}(Qi||(Qi={}));var z0=function(r){function t(e){var n=r.call(this,e)||this;return n._currentLockId=-1,n.lockMode=Qi.None,n.registerInput("min",se.AutoDetect),n.registerInput("max",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n._inputs[1].excludedConnectionPointTypes.push(se.Matrix),n._inputs[1].excludedConnectionPointTypes.push(se.Geometry),n._inputs[1].excludedConnectionPointTypes.push(se.Texture),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"RandomBlock"},Object.defineProperty(t.prototype,"min",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"max",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.min.isConnected){var e=new Nn("Min");e.value=0,e.output.connectTo(this.min)}if(!this.max.isConnected){var n=new Nn("Max");n.value=1,n.output.connectTo(this.max)}},t.prototype._buildBlock=function(){var e=this,n=null;switch(this._currentLockId=-1,this.min.type){case se.Int:case se.Float:n=function(i){var o=e.min.getConnectedValue(i)||0,a=e.max.getConnectedValue(i)||0;return o+Math.random()*(a-o)};break;case se.Vector2:n=function(i){var o=e.min.getConnectedValue(i)||_.I9.Zero(),a=e.max.getConnectedValue(i)||_.I9.Zero();return new _.I9(o.x+Math.random()*(a.x-o.x),o.y+Math.random()*(a.y-o.y))};break;case se.Vector3:n=function(i){var o=e.min.getConnectedValue(i)||_.Pq.Zero(),a=e.max.getConnectedValue(i)||_.Pq.Zero();return new _.Pq(o.x+Math.random()*(a.x-o.x),o.y+Math.random()*(a.y-o.y),o.z+Math.random()*(a.z-o.z))};break;case se.Vector4:n=function(i){var o=e.min.getConnectedValue(i)||_.IU.Zero(),a=e.max.getConnectedValue(i)||_.IU.Zero();return new _.IU(o.x+Math.random()*(a.x-o.x),o.y+Math.random()*(a.y-o.y),o.z+Math.random()*(a.z-o.z),o.w+Math.random()*(a.w-o.w))}}this.lockMode!==Qi.None&&n?this.output._storedFunction=function(i){var o=0;switch(e.lockMode){case Qi.InstanceID:o=i.getContextualValue(Qt.InstanceID,!0)||0;break;case Qi.LoopID:o=i.getContextualValue(Qt.LoopID,!0)||0;break;case Qi.Once:o=i.buildId||0}return e._currentLockId===o&&e.lockMode!==Qi.None||(e._currentLockId=o,e.output._storedValue=n(i)),e.output._storedValue}:this.output._storedFunction=n},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".lockMode = BABYLON.RandomBlockLocks.").concat(Qi[this.lockMode],`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.lockMode=this.lockMode,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.lockMode=e.lockMode},(0,A.Cg)([dt("LockMode",4,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"None",value:Qi.None},{label:"LoopID",value:Qi.LoopID},{label:"InstanceID",value:Qi.InstanceID},{label:"Once",value:Qi.Once}]})],t.prototype,"lockMode",void 0),t}(Tt);(0,j.Y5)("BABYLON.RandomBlock",z0);var W0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("offset",se.Vector3,!0,_.Pq.Zero()),n.registerInput("scale",se.Float,!0,1),n.registerInput("octaves",se.Float,!0,2,0,16),n.registerInput("roughness",se.Float,!0,.5,0,1),n.registerOutput("output",se.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"NoiseBlock"},Object.defineProperty(t.prototype,"offset",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"octaves",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._negateIf=function(e,n){return n!==0?-e:e},t.prototype._noiseGrad=function(e,n,i,o){var a=15&e,s=a<8?n:i,l=a<4?i:a===12||a==14?n:o;return this._negateIf(s,a&s)+this._negateIf(l,2&a)},t.prototype._fade=function(e){return e*e*e*(e*(6*e-15)+10)},t.prototype._hashBitRotate=function(e,n){return e<<n|e>>32-n},t.prototype._hash=function(e,n,i){var o,a,s;return o=a=s=3735928584,s+=i,o+=e,s^=a+=n,o^=s-=this._hashBitRotate(a,14),a^=o-=this._hashBitRotate(s,11),s^=a-=this._hashBitRotate(o,25),o^=s-=this._hashBitRotate(a,16),a^=o-=this._hashBitRotate(s,4),(s^=a-=this._hashBitRotate(o,14))-this._hashBitRotate(a,24)},t.prototype._mix=function(e,n,i,o,a,s,l,c,u,d,h){var p=1-u,m=1-d;return(1-h)*(m*(e*p+n*u)+d*(i*p+o*u))+h*(m*(a*p+s*u)+d*(l*p+c*u))},t.prototype._perlinNoise=function(e){var n=(0|e.x)-(e.x<0?1:0),i=(0|e.y)-(e.y<0?1:0),o=(0|e.z)-(e.z<0?1:0),a=e.x-n,s=e.y-i,l=e.z-o,c=this._fade(a),u=this._fade(s),d=this._fade(l);return this._mix(this._noiseGrad(this._hash(n,i,o),a,s,l),this._noiseGrad(this._hash(n+1,i,o),a-1,s,l),this._noiseGrad(this._hash(n,i+1,o),a,s-1,l),this._noiseGrad(this._hash(n+1,i+1,o),a-1,s-1,l),this._noiseGrad(this._hash(n,i,o+1),a,s,l-1),this._noiseGrad(this._hash(n+1,i,o+1),a-1,s,l-1),this._noiseGrad(this._hash(n,i+1,o+1),a,s-1,l-1),this._noiseGrad(this._hash(n+1,i+1,o+1),a-1,s-1,l-1),c,u,d)},t.prototype._perlinSigned=function(e){return .982*this._perlinNoise(e)},t.prototype._perlin=function(e){return this._perlinSigned(e)/2+.5},t.prototype.noise=function(e,n,i,o,a){for(var s=new _.Pq(i.x*a+o.x,i.y*a+o.y,i.z*a+o.z),l=1,c=1,u=0,d=0,h=0|(e=(0,qe.Clamp)(e,0,15)),p=0;p<=h;p++)d+=this._perlin(s.scale(l))*c,u+=c,c*=(0,qe.Clamp)(n,0,1),l*=2;var m=e-Math.floor(e);if(m==0)return d/u;var v=d+this._perlin(s.scale(l))*c;return(1-m)*(d/=u)+m*(v/(u+c))},t.prototype._buildBlock=function(){var e=this;this.output._storedFunction=function(n){var i=n.getContextualValue(Qt.Positions),o=e.octaves.getConnectedValue(n),a=e.roughness.getConnectedValue(n),s=e.offset.getConnectedValue(n),l=e.scale.getConnectedValue(n);return e.noise(o,a,i,s,l)}},t}(Tt);(0,j.Y5)("BABYLON.NoiseBlock",W0);var H0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.registerInput("geometry0",se.Geometry),n.registerInput("geometry1",se.Geometry,!0),n.registerInput("geometry2",se.Geometry,!0),n.registerInput("geometry3",se.Geometry,!0),n.registerInput("geometry4",se.Geometry,!0),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MergeGeometryBlock"},Object.defineProperty(t.prototype,"geometry0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry2",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry3",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry4",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){var a,s=[];if(n.geometry0.isConnected&&(a=n.geometry0.getConnectedValue(o))&&s.push(a),n.geometry1.isConnected&&(a=n.geometry1.getConnectedValue(o))&&s.push(a),n.geometry2.isConnected&&(a=n.geometry2.getConnectedValue(o))&&s.push(a),n.geometry3.isConnected&&(a=n.geometry3.getConnectedValue(o))&&s.push(a),n.geometry4.isConnected&&(a=n.geometry4.getConnectedValue(o))&&s.push(a),s.length===0)return null;var l=s[0].clone(),c=s.slice(1);return c.length&&l&&(l=l.merge(c,!0,!1,!0,!0)),l};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.MergeGeometryBlock",H0);var Y0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.registerInput("geometry0",se.Geometry,!0),n.registerInput("geometry1",se.Geometry,!0),n.registerInput("geometry2",se.Geometry,!0),n.registerInput("geometry3",se.Geometry,!0),n.registerInput("geometry4",se.Geometry,!0),n.registerInput("geometry5",se.Geometry,!0),n.registerInput("geometry6",se.Geometry,!0),n.registerInput("geometry7",se.Geometry,!0),n.registerInput("geometry8",se.Geometry,!0),n.registerInput("geometry9",se.Geometry,!0),n.registerOutput("output",se.Geometry),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryCollectionBlock"},Object.defineProperty(t.prototype,"geometry0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry2",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry3",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry4",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry5",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry6",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry7",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry8",{get:function(){return this._inputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry9",{get:function(){return this._inputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._storeGeometry=function(e,n,i,o){if(e.isConnected){var a=e.getConnectedValue(n);if(!a)return;a.metadata=a.metadata||{},a.metadata.collectionId=i,o.push(a)}},t.prototype._buildBlock=function(e){var n=this,i=function(o){var a=[];return n._storeGeometry(n.geometry0,o,0,a),n._storeGeometry(n.geometry1,o,1,a),n._storeGeometry(n.geometry2,o,2,a),n._storeGeometry(n.geometry3,o,3,a),n._storeGeometry(n.geometry4,o,4,a),n._storeGeometry(n.geometry5,o,5,a),n._storeGeometry(n.geometry6,o,6,a),n._storeGeometry(n.geometry7,o,7,a),n._storeGeometry(n.geometry8,o,8,a),n._storeGeometry(n.geometry9,o,9,a),a.length?a[Math.round(Math.random()*(a.length-1))]:null};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryCollectionBlock",Y0);var X0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("input",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"buildExecutionTime",{get:function(){return 0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"GeometryElbowBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this._outputs[0],i=this._inputs[0];n._storedFunction=function(o){return i.getConnectedValue(o)}},t}(Tt);(0,j.Y5)("BABYLON.GeometryElbowBlock",X0);var j0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("geometry",se.Geometry),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ComputeNormalsBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;this.output._storedFunction=function(n){if(!e.geometry.isConnected)return null;var i=e.geometry.getConnectedValue(n);return i.normals||(i.normals=[]),rt.ComputeNormals(i.positions,i.indices,i.normals),i}},t}(Tt);(0,j.Y5)("BABYLON.ComputeNormalsBlock",j0);var q0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("xyzw ",se.Vector4,!0),n.registerInput("xyz ",se.Vector3,!0),n.registerInput("xy ",se.Vector2,!0),n.registerInput("zw ",se.Vector2,!0),n.registerInput("x ",se.Float,!0),n.registerInput("y ",se.Float,!0),n.registerInput("z ",se.Float,!0),n.registerInput("w ",se.Float,!0),n.registerOutput("xyzw",se.Vector4),n.registerOutput("xyz",se.Vector3),n.registerOutput("xy",se.Vector2),n.registerOutput("zw",se.Vector2),n.registerOutput("x",se.Float),n.registerOutput("y",se.Float),n.registerOutput("z",se.Float),n.registerOutput("w",se.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"VectorConverterBlock"},Object.defineProperty(t.prototype,"xyzwIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwIn",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xIn",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yIn",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zIn",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wIn",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzwOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zwOut",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xOut",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"yOut",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zOut",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wOut",{get:function(){return this._outputs[7]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return e==="xyzw "?"xyzwIn":e==="xyz "?"xyzIn":e==="xy "?"xyIn":e==="zw "?"zwIn":e==="x "?"xIn":e==="y "?"yIn":e==="z "?"zIn":e==="w "?"wIn":e},t.prototype._outputRename=function(e){switch(e){case"x":return"xOut";case"y":return"yOut";case"z":return"zOut";case"w":return"wOut";case"xy":return"xyOut";case"zw":return"zwOut";case"xyz":return"xyzOut";case"xyzw":return"xyzwOut";default:return e}},t.prototype._buildBlock=function(e){r.prototype._buildBlock.call(this,e);var n=this.xIn,i=this.yIn,o=this.zIn,a=this.wIn,s=this.xyIn,l=this.zwIn,c=this.xyzIn,u=this.xyzwIn,d=this.xyzwOut,h=this.xyzOut,p=this.xyOut,m=this.zwOut,v=this.xOut,b=this.yOut,E=this.zOut,C=this.wOut,T=function(f){if(u.isConnected)return u.getConnectedValue(f);var g,S=0,y=0,x=0,R=0;return n.isConnected&&(S=n.getConnectedValue(f)),i.isConnected&&(y=i.getConnectedValue(f)),o.isConnected&&(x=o.getConnectedValue(f)),a.isConnected&&(R=a.getConnectedValue(f)),s.isConnected&&(g=s.getConnectedValue(f))&&(S=g.x,y=g.y),l.isConnected&&(g=l.getConnectedValue(f))&&(x=g.x,R=g.y),c.isConnected&&(g=c.getConnectedValue(f))&&(S=g.x,y=g.y,x=g.z),new _.IU(S,y,x,R)};d._storedFunction=function(f){return T(f)},h._storedFunction=function(f){var g=T(f);return new _.Pq(g.x,g.y,g.z)},p._storedFunction=function(f){var g=T(f);return new _.I9(g.x,g.y)},m._storedFunction=function(f){var g=T(f);return new _.I9(g.z,g.w)},v._storedFunction=function(f){return T(f).x},b._storedFunction=function(f){return T(f).y},E._storedFunction=function(f){return T(f).z},C._storedFunction=function(f){return T(f).w}},t}(Tt);(0,j.Y5)("BABYLON.VectorConverterBlock",q0);var K0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("input",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._inputs[0].excludedConnectionPointTypes.push(se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"NormalizeVectorBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.output._storedFunction=null,this.input.isConnected?this.output._storedFunction=function(i){return n.input.getConnectedValue(i).normalize()}:this.output._storedValue=null},t}(Tt);(0,j.Y5)("BABYLON.NormalizeVectorBlock",K0);var Ht,Z0=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.registerInput("geometry",se.Geometry),n.registerInput("id",se.Int,!0,0),n.registerOutput("output",se.Geometry),n.id.acceptedConnectionPointTypes.push(se.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SetMaterialIDBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this;if(!this.geometry.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var i=function(o){var a=n.geometry.getConnectedValue(o);if(!a||!a.indices||!a.positions)return a;var s=new Ea;return s.materialIndex=0|n.id.getConnectedValue(o),s.indexStart=0,s.indexCount=a.indices.length,s.verticesStart=0,s.verticesCount=a.positions.length/3,a.materialInfos=[s],a};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.SetMaterialIDBlock",Z0),function(r){r[r.Cos=0]="Cos",r[r.Sin=1]="Sin",r[r.Abs=2]="Abs",r[r.Exp=3]="Exp",r[r.Round=4]="Round",r[r.Floor=5]="Floor",r[r.Ceiling=6]="Ceiling",r[r.Sqrt=7]="Sqrt",r[r.Log=8]="Log",r[r.Tan=9]="Tan",r[r.ArcTan=10]="ArcTan",r[r.ArcCos=11]="ArcCos",r[r.ArcSin=12]="ArcSin",r[r.Sign=13]="Sign",r[r.Negate=14]="Negate",r[r.OneMinus=15]="OneMinus",r[r.Reciprocal=16]="Reciprocal",r[r.ToDegrees=17]="ToDegrees",r[r.ToRadians=18]="ToRadians",r[r.Fract=19]="Fract",r[r.Exp2=20]="Exp2"}(Ht||(Ht={}));var Q0=function(r){function t(e){var n=r.call(this,e)||this;return n.operation=Ht.Cos,n.registerInput("input",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryTrigonometryBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e);var i=null;switch(this.operation){case Ht.Cos:i=function(o){return Math.cos(o)};break;case Ht.Sin:i=function(o){return Math.sin(o)};break;case Ht.Abs:i=function(o){return Math.abs(o)};break;case Ht.Exp:i=function(o){return Math.exp(o)};break;case Ht.Exp2:i=function(o){return Math.pow(2,o)};break;case Ht.Round:i=function(o){return Math.round(o)};break;case Ht.Floor:i=function(o){return Math.floor(o)};break;case Ht.Ceiling:i=function(o){return Math.ceil(o)};break;case Ht.Sqrt:i=function(o){return Math.sqrt(o)};break;case Ht.Log:i=function(o){return Math.log(o)};break;case Ht.Tan:i=function(o){return Math.tan(o)};break;case Ht.ArcTan:i=function(o){return Math.atan(o)};break;case Ht.ArcCos:i=function(o){return Math.acos(o)};break;case Ht.ArcSin:i=function(o){return Math.asin(o)};break;case Ht.Sign:i=function(o){return Math.sign(o)};break;case Ht.Negate:i=function(o){return-o};break;case Ht.OneMinus:i=function(o){return 1-o};break;case Ht.Reciprocal:i=function(o){return 1/o};break;case Ht.ToRadians:i=function(o){return o*Math.PI/180};break;case Ht.ToDegrees:i=function(o){return 180*o/Math.PI};break;case Ht.Fract:i=function(o){return o>=0?o-Math.floor(o):o-Math.ceil(o)}}if(!i)return this.output._storedFunction=null,void(this.output._storedValue=null);switch(this.input.type){case se.Int:case se.Float:this.output._storedFunction=function(o){var a=n.input.getConnectedValue(o);return i(a)};break;case se.Vector2:this.output._storedFunction=function(o){var a=n.input.getConnectedValue(o);return new _.I9(i(a.x),i(a.y))};break;case se.Vector3:this.output._storedFunction=function(o){var a=n.input.getConnectedValue(o);return new _.Pq(i(a.x),i(a.y),i(a.z))};break;case se.Vector4:this.output._storedFunction=function(o){var a=n.input.getConnectedValue(o);return new _.IU(i(a.x),i(a.y),i(a.z),i(a.w))}}return this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.operation=this.operation,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.operation=e.operation},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".operation = BABYLON.GeometryTrigonometryBlockOperations.").concat(Ht[this.operation],`;
|
||
`)},(0,A.Cg)([dt("Operation",4,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Cos",value:Ht.Cos},{label:"Sin",value:Ht.Sin},{label:"Abs",value:Ht.Abs},{label:"Exp",value:Ht.Exp},{label:"Exp2",value:Ht.Exp2},{label:"Round",value:Ht.Round},{label:"Floor",value:Ht.Floor},{label:"Ceiling",value:Ht.Ceiling},{label:"Sqrt",value:Ht.Sqrt},{label:"Log",value:Ht.Log},{label:"Tan",value:Ht.Tan},{label:"ArcTan",value:Ht.ArcTan},{label:"ArcCos",value:Ht.ArcCos},{label:"ArcSin",value:Ht.ArcSin},{label:"Sign",value:Ht.Sign},{label:"Negate",value:Ht.Negate},{label:"OneMinus",value:Ht.OneMinus},{label:"Reciprocal",value:Ht.Reciprocal},{label:"ToDegrees",value:Ht.ToDegrees},{label:"ToRadians",value:Ht.ToRadians},{label:"Fract",value:Ht.Fract}]})],t.prototype,"operation",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryTrigonometryBlock",Q0);var J0=function(r){function t(e){var n=r.call(this,e)||this;return n._rotationMatrix=new _.uq,n._scalingMatrix=new _.uq,n._translationMatrix=new _.uq,n._scalingRotationMatrix=new _.uq,n._transformMatrix=new _.uq,n.evaluateContext=!0,n.registerInput("value",se.AutoDetect),n.registerInput("matrix",se.Matrix,!0),n.registerInput("translation",se.Vector3,!0,_.Pq.Zero()),n.registerInput("rotation",se.Vector3,!0,_.Pq.Zero()),n.registerInput("scaling",se.Vector3,!0,_.Pq.One()),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryTransformBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translation",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this;if(!this.value.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var i=function(o){var a,s=n.value.getConnectedValue(o);if(!s)return null;if(n.matrix.isConnected)a=n.matrix.getConnectedValue(o);else{var l=n.scaling.getConnectedValue(o),c=n.rotation.getConnectedValue(o),u=n.translation.getConnectedValue(o);_.uq.ScalingToRef(l.x,l.y,l.z,n._scalingMatrix),_.uq.RotationYawPitchRollToRef(c.y,c.x,c.z,n._rotationMatrix),_.uq.TranslationToRef(u.x,u.y,u.z,n._translationMatrix),n._scalingMatrix.multiplyToRef(n._rotationMatrix,n._scalingRotationMatrix),n._scalingRotationMatrix.multiplyToRef(n._translationMatrix,n._transformMatrix),a=n._transformMatrix}switch(n.value.type){case se.Geometry:var d=s.clone();return d.transform(a),d;case se.Vector2:return _.I9.Transform(s,a);case se.Vector3:return _.Pq.TransformCoordinates(s,a);case se.Vector4:return _.IU.TransformCoordinates(s,a)}return null};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryTransformBlock",J0);var $0=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("angle",se.Float,!1,0),n.registerOutput("matrix",se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"RotationXBlock"},Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.angle.isConnected){var e=new Nn("Angle");e.value=0,e.output.connectTo(this.angle)}},t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.matrix._storedFunction=function(i){return _.uq.RotationX(n.angle.getConnectedValue(i))}},t}(Tt);(0,j.Y5)("BABYLON.RotationXBlock",$0);var eb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("angle",se.Float,!1,0),n.registerOutput("matrix",se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"RotationYBlock"},Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.angle.isConnected){var e=new Nn("Angle");e.value=0,e.output.connectTo(this.angle)}},t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.matrix._storedFunction=function(i){return _.uq.RotationY(n.angle.getConnectedValue(i))}},t}(Tt);(0,j.Y5)("BABYLON.RotationYBlock",eb);var tb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("angle",se.Float,!1,0),n.registerOutput("matrix",se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"RotationZBlock"},Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.angle.isConnected){var e=new Nn("Angle");e.value=0,e.output.connectTo(this.angle)}},t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.matrix._storedFunction=function(i){return _.uq.RotationZ(n.angle.getConnectedValue(i))}},t}(Tt);(0,j.Y5)("BABYLON.RotationZBlock",tb);var nb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("scale",se.Vector3,!1,_.Pq.One()),n.registerOutput("matrix",se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ScalingBlock"},Object.defineProperty(t.prototype,"scale",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.scale.isConnected){var e=new Nn("Scale");e.value=new _.Pq(1,1,1),e.output.connectTo(this.scale)}},t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.matrix._storedFunction=function(i){var o=n.scale.getConnectedValue(i);return _.uq.Scaling(o.x,o.y,o.z)}},t}(Tt);(0,j.Y5)("BABYLON.ScalingBlock",nb);var ib=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("source",se.Vector3,!0,_.Pq.Up()),n.registerInput("target",se.Vector3,!0,_.Pq.Left()),n.registerOutput("matrix",se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"AlignBlock"},Object.defineProperty(t.prototype,"source",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.matrix._storedFunction=function(i){var o=n.source.getConnectedValue(i).clone(),a=n.target.getConnectedValue(i).clone(),s=new _.uq;return o.normalize(),a.normalize(),_.uq.RotationAlignToRef(o,a,s,!0),s}},t}(Tt);(0,j.Y5)("BABYLON.AlignBlock",ib);var rb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("translation",se.Vector3,!1,_.Pq.Zero()),n.registerOutput("matrix",se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TranslationBlock"},Object.defineProperty(t.prototype,"translation",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(){if(!this.translation.isConnected){var e=new Nn("Translation");e.value=new _.Pq(0,0,0),e.output.connectTo(this.translation)}},t.prototype._buildBlock=function(e){var n=this;r.prototype._buildBlock.call(this,e),this.matrix._storedFunction=function(i){var o=n.translation.getConnectedValue(i);return _.uq.Translation(o.x,o.y,o.z)}},t}(Tt);(0,j.Y5)("BABYLON.TranslationBlock",rb);var ob=function(r){function t(e){var n=r.call(this,e)||this;return n._indexTranslation=null,n.evaluateContext=!0,n.removeDuplicatedPositions=!0,n.registerInput("geometry",se.Geometry),n.registerInput("instance",se.Geometry,!0),n.registerInput("density",se.Float,!0,1,0,1),n.registerInput("matrix",se.Matrix,!0),n.registerInput("rotation",se.Vector3,!0,_.Pq.Zero()),n.registerInput("scaling",se.Vector3,!0,_.Pq.One()),n.scaling.acceptedConnectionPointTypes.push(se.Float),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getInstanceIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionIndex=function(){return this._indexTranslation?this._indexTranslation[this._currentIndex]:this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"InstantiateOnVerticesBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"density",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){if(o.pushExecutionContext(n),o.pushInstancingContext(n),n._vertexData=n.geometry.getConnectedValue(o),o.pushGeometryContext(n._vertexData),!n._vertexData||!n._vertexData.positions||!n.instance.isConnected)return o.restoreExecutionContext(),o.restoreInstancingContext(),o.restoreGeometryContext(),void(n.output._storedValue=null);var a=n._vertexData.positions.length/3,s=[],l=new _.Pq,c=[],u=n._vertexData.positions;if(n._currentLoopIndex=0,n.removeDuplicatedPositions){for(n._indexTranslation={},n._currentIndex=0;n._currentIndex<a;n._currentIndex++){for(var d=u[3*n._currentIndex],h=u[3*n._currentIndex+1],p=u[3*n._currentIndex+2],m=!1,v=0;v<c.length;v+=3)if(Math.abs(c[v]-d)<pt.bH&&Math.abs(c[v+1]-h)<pt.bH&&Math.abs(c[v+2]-p)<pt.bH){m=!0;break}m||(n._indexTranslation[c.length/3]=n._currentIndex,c.push(d,h,p))}a=(u=c).length/3}else n._indexTranslation=null;for(n._currentIndex=0;n._currentIndex<a;n._currentIndex++){var b=n.instance.getConnectedValue(o);if(b&&b.positions&&b.positions.length!==0){var E=n.density.getConnectedValue(o);if(!(E<1&&Math.random()>E)){l.fromArray(u,3*n._currentIndex);var C=b.clone();if(n.matrix.isConnected){var T=n.matrix.getConnectedValue(o);o._instantiateWithPositionAndMatrix(C,l,T,s)}else{var f=o.adaptInput(n.scaling,se.Vector3,_.Pq.OneReadOnly),g=n.rotation.getConnectedValue(o)||_.Pq.ZeroReadOnly;o._instantiate(C,l,g,f,s)}n._currentLoopIndex++}}}if(o.restoreGeometryContext(),o.restoreExecutionContext(),o.restoreInstancingContext(),!s.length)return null;if(s.length===1)n._vertexData=s[0];else{var S=s.splice(0,1)[0];n._vertexData=S.merge(s,!0,!1,!0,!0)}return n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".removeDuplicatedPositions = ").concat(this.removeDuplicatedPositions?"true":"false",`;
|
||
`)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.removeDuplicatedPositions=this.removeDuplicatedPositions,e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.removeDuplicatedPositions=e.removeDuplicatedPositions,e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),(0,A.Cg)([dt("Remove duplicated positions",0,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"removeDuplicatedPositions",void 0),t}(Tt);(0,j.Y5)("BABYLON.InstantiateOnVerticesBlock",ob);var ab=function(r){function t(e){var n=r.call(this,e)||this;return n._currentPosition=new _.Pq,n._currentUV=new _.I9,n._vertex0=new _.Pq,n._vertex1=new _.Pq,n._vertex2=new _.Pq,n._tempVector0=new _.Pq,n._tempVector1=new _.Pq,n._uv0=new _.I9,n._uv1=new _.I9,n._uv2=new _.I9,n.evaluateContext=!0,n.registerInput("geometry",se.Geometry),n.registerInput("instance",se.Geometry,!0),n.registerInput("count",se.Int,!0,256),n.registerInput("matrix",se.Matrix,!0),n.registerInput("rotation",se.Vector3,!0,_.Pq.Zero()),n.registerInput("scaling",se.Vector3,!0,_.Pq.One()),n.scaling.acceptedConnectionPointTypes.push(se.Float),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getInstanceIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionIndex=function(){return 0},t.prototype.getExecutionFaceIndex=function(){return this._currentFaceIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentLoopIndex},t.prototype.getOverridePositionsContextualValue=function(){return this._currentPosition},t.prototype.getOverrideNormalsContextualValue=function(){return this._vertex1.subtractToRef(this._vertex0,this._tempVector0),this._vertex2.subtractToRef(this._vertex1,this._tempVector1),this._tempVector0.normalize(),this._tempVector1.normalize(),_.Pq.Cross(this._tempVector1,this._tempVector0)},t.prototype.getOverrideUVs1ContextualValue=function(){return this._currentUV},t.prototype.getClassName=function(){return"InstantiateOnFacesBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){if(o.pushExecutionContext(n),o.pushInstancingContext(n),n._vertexData=n.geometry.getConnectedValue(o),o.pushGeometryContext(n._vertexData),!(n._vertexData&&n._vertexData.positions&&n._vertexData.indices&&n.instance.isConnected))return o.restoreExecutionContext(),o.restoreInstancingContext(),o.restoreGeometryContext(),void(n.output._storedValue=null);var a=null,s=n.count.getConnectedValue(o),l=n._vertexData.indices.length/3,c=s/l,u=0,d=[],h=0;for(n._currentLoopIndex=0,n._currentFaceIndex=0;n._currentFaceIndex<l;n._currentFaceIndex++){var p=(0|(u+=c))-h;if(!(p<1)){var m=n._vertexData.indices[3*n._currentFaceIndex],v=n._vertexData.indices[3*n._currentFaceIndex+1],b=n._vertexData.indices[3*n._currentFaceIndex+2];n._vertex0.fromArray(n._vertexData.positions,3*m),n._vertex1.fromArray(n._vertexData.positions,3*v),n._vertex2.fromArray(n._vertexData.positions,3*b),n._vertexData.uvs&&(n._uv0.fromArray(n._vertexData.uvs,2*m),n._uv1.fromArray(n._vertexData.uvs,2*v),n._uv2.fromArray(n._vertexData.uvs,2*b));for(var E=0;E<p&&!(h>=s);E++){var C=Math.random(),T=Math.random();if(C>T){var f=C;C=T,T=f}var g=C,S=T-C,y=1-g-S;if(n._currentPosition.set(g*n._vertex0.x+S*n._vertex1.x+y*n._vertex2.x,g*n._vertex0.y+S*n._vertex1.y+y*n._vertex2.y,g*n._vertex0.z+S*n._vertex1.z+y*n._vertex2.z),n._vertexData.uvs&&n._currentUV.set(g*n._uv0.x+S*n._uv1.x+y*n._uv2.x,g*n._uv0.y+S*n._uv1.y+y*n._uv2.y),(a=n.instance.getConnectedValue(o))&&a.positions&&a.positions.length!==0){var x=a.clone();if(n.matrix.isConnected){var R=n.matrix.getConnectedValue(o);o._instantiateWithPositionAndMatrix(x,n._currentPosition,R,d)}else{var I=o.adaptInput(n.scaling,se.Vector3,_.Pq.OneReadOnly),M=n.rotation.getConnectedValue(o)||_.Pq.ZeroReadOnly;o._instantiate(x,n._currentPosition,M,I,d)}h++,n._currentLoopIndex++}else u-=c}}}if(d.length)if(d.length===1)n._vertexData=d[0];else{var D=d.splice(0,1)[0];n._vertexData=D.merge(d,!0,!1,!0,!0)}return o.restoreExecutionContext(),o.restoreInstancingContext(),o.restoreGeometryContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt);(0,j.Y5)("BABYLON.InstantiateOnFacesBlock",ab);var sb=function(r){function t(e){var n=r.call(this,e)||this;return n._currentPosition=new _.Pq,n._vertex0=new _.Pq,n._vertex1=new _.Pq,n._vertex2=new _.Pq,n.evaluateContext=!0,n.gridMode=!1,n.registerInput("geometry",se.Geometry),n.registerInput("instance",se.Geometry,!0),n.registerInput("count",se.Int,!0,256),n.registerInput("matrix",se.Matrix,!0),n.registerInput("rotation",se.Vector3,!0,_.Pq.Zero()),n.registerInput("scaling",se.Vector3,!0,_.Pq.One()),n.registerInput("gridSize",se.Int,!0,10),n.scaling.acceptedConnectionPointTypes.push(se.Float),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getInstanceIndex=function(){return this._currentLoopIndex},t.prototype.getExecutionIndex=function(){return 0},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getExecutionLoopIndex=function(){return this._currentLoopIndex},t.prototype.getOverridePositionsContextualValue=function(){return this._currentPosition},t.prototype.getClassName=function(){return"InstantiateOnVolumeBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gridSize",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._getValueOnGrid=function(e,n,i,o){var a=(o-i)/n;return i+a/2+e*a},t.prototype._getIndexinGrid=function(e,n,i,o){return e+n*o+i*o*o},t.prototype._buildBlock=function(e){var n=this,i=function(o){if(o.pushExecutionContext(n),o.pushInstancingContext(n),n._vertexData=n.geometry.getConnectedValue(o),o.pushGeometryContext(n._vertexData),!(n._vertexData&&n._vertexData.positions&&n._vertexData.indices&&n.instance.isConnected))return o.restoreExecutionContext(),o.restoreInstancingContext(),o.restoreGeometryContext(),void(n.output._storedValue=null);var a,s=null,l=n.count.getConnectedValue(o),c=[],u=(0,no.b)(n._vertexData.positions,0,n._vertexData.positions.length/3),d=u.minimum,h=u.maximum,p=new _.Pq(.5,.8,.2),m=n._vertexData.indices.length/3,v=n.gridSize.getConnectedValue(o);if(n._currentLoopIndex=0,n.gridMode){a=[];for(var b=0;b<v*v*v;b++)a[b]=!1}for(b=0;b<l;b++){if(n.gridMode){var E=Math.floor(Math.random()*v),C=Math.floor(Math.random()*v),T=Math.floor(Math.random()*v),f=n._getIndexinGrid(E,C,T,v);if(a[f]){for(var g=!1,S=0;S<v*v*v;S++)if(!a[S]){E=S-(T=Math.floor(S/(v*v)))*v*v-(C=Math.floor((S-T*v*v)/v))*v,f=n._getIndexinGrid(E,C,T,v),g=!0;break}if(!g)break}if(!a[f]){var y=n._getValueOnGrid(E,v,d.x,h.x),x=n._getValueOnGrid(C,v,d.y,h.y),R=n._getValueOnGrid(T,v,d.z,h.z);n._currentPosition.set(y,x,R),a[f]=!0}}else n._currentPosition.set(Math.random()*(h.x-d.x)+d.x,Math.random()*(h.y-d.y)+d.y,Math.random()*(h.z-d.z)+d.z);for(var I=new fn(n._currentPosition,p),M=0,D=0;D<m;D++){n._vertex0.fromArray(n._vertexData.positions,3*n._vertexData.indices[3*D]),n._vertex1.fromArray(n._vertexData.positions,3*n._vertexData.indices[3*D+1]),n._vertex2.fromArray(n._vertexData.positions,3*n._vertexData.indices[3*D+2]);var B=I.intersectsTriangle(n._vertex0,n._vertex1,n._vertex2);B&&B.distance>0&&M++}if(M%2!=0){if((s=n.instance.getConnectedValue(o))&&s.positions&&s.positions.length!==0){var F=s.clone();if(n.matrix.isConnected){var X=n.matrix.getConnectedValue(o);o._instantiateWithPositionAndMatrix(F,n._currentPosition,X,c)}else{var $=o.adaptInput(n.scaling,se.Vector3,_.Pq.OneReadOnly),Q=n.rotation.getConnectedValue(o)||_.Pq.ZeroReadOnly;o._instantiate(F,n._currentPosition,Q,$,c)}n._currentLoopIndex++}}else b--}if(c.length)if(c.length===1)n._vertexData=c[0];else{var ie=c.splice(0,1)[0];n._vertexData=ie.merge(c,!0,!1,!0,!0)}return o.restoreGeometryContext(),o.restoreExecutionContext(),o.restoreInstancingContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)+"".concat(this._codeVariableName,".gridMode = ").concat(this.gridMode?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e.gridMode=this.gridMode,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext),e.gridMode!==void 0&&(this.gridMode=e.gridMode)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),(0,A.Cg)([dt("Grid mode",0,"MODES",{notifiers:{rebuild:!0}})],t.prototype,"gridMode",void 0),t}(Tt);(0,j.Y5)("BABYLON.InstantiateOnVolumeBlock",sb);var lb=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!0,n.registerInput("instance",se.Geometry,!0),n.registerInput("count",se.Int,!0,1),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getInstanceIndex=function(){return this._currentIndex},t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"InstantiateBaseBlock"},Object.defineProperty(t.prototype,"instance",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),e.evaluateContext!==void 0&&(this.evaluateContext=e.evaluateContext)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),t}(Tt),cb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("matrix",se.Matrix,!0),n.registerInput("position",se.Vector3,!0,_.Pq.Zero()),n.registerInput("rotation",se.Vector3,!0,_.Pq.Zero()),n.registerInput("scaling",se.Vector3,!0,_.Pq.One()),n.scaling.acceptedConnectionPointTypes.push(se.Float),n}return(0,A.C6)(t,r),t.prototype.getInstanceIndex=function(){return this._currentIndex},t.prototype.getExecutionIndex=function(){return this._currentIndex},t.prototype.getExecutionLoopIndex=function(){return this._currentIndex},t.prototype.getExecutionFaceIndex=function(){return 0},t.prototype.getClassName=function(){return"InstantiateBlock"},Object.defineProperty(t.prototype,"matrix",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){o.pushExecutionContext(n),o.pushInstancingContext(n);var a=n.count.getConnectedValue(o),s=[];for(n._currentIndex=0;n._currentIndex<a;n._currentIndex++){var l=n.instance.getConnectedValue(o);if(l&&l.positions&&l.positions.length!==0){var c=l.clone();if(n.matrix.isConnected){var u=n.matrix.getConnectedValue(o);o._instantiateWithMatrix(c,u,s)}else{var d=n.position.getConnectedValue(o)||_.Pq.ZeroReadOnly,h=o.adaptInput(n.scaling,se.Vector3,_.Pq.OneReadOnly),p=n.rotation.getConnectedValue(o)||_.Pq.ZeroReadOnly;o._instantiate(c,d,p,h,s)}}}if(s.length)if(s.length===1)n._vertexData=s[0];else{var m=s.splice(0,1)[0];n._vertexData=m.merge(s,!0,!1,!0,!0)}return o.restoreExecutionContext(),o.restoreInstancingContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t}(lb);(0,j.Y5)("BABYLON.InstantiateBlock",cb);var ub=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("direction",se.Vector3,!0,new _.Pq(1,0,0)),n.registerInput("rotation",se.Vector3,!0,new _.Pq(0,0,0)),n.registerInput("scaling",se.Vector3,!0,new _.Pq(0,0,0)),n.scaling.acceptedConnectionPointTypes.push(se.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"InstantiateLinearBlock"},Object.defineProperty(t.prototype,"direction",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){o.pushExecutionContext(n),o.pushInstancingContext(n);var a=n.count.getConnectedValue(o),s=[],l=_.uq.Identity(),c=_.Pq.Zero(),u=_.Pq.Zero(),d=_.Pq.Zero();for(n._currentIndex=0;n._currentIndex<a;n._currentIndex++){var h=n.instance.getConnectedValue(o);if(h&&h.positions&&h.positions.length!==0){var p=h.clone(),m=n.direction.getConnectedValue(o),v=n.rotation.getConnectedValue(o),b=o.adaptInput(n.scaling,se.Vector3,_.Pq.OneReadOnly);c.copyFrom(m.clone().scale(n._currentIndex)),u.copyFrom(v.clone().scale(n._currentIndex)),d.copyFrom(b.clone().scale(n._currentIndex)),d.addInPlaceFromFloats(1,1,1),_.uq.ComposeToRef(d,_.PT.FromEulerAngles(u.x,u.y,u.z),c,l),o._instantiateWithMatrix(p,l,s)}}if(s.length)if(s.length===1)n._vertexData=s[0];else{var E=s.splice(0,1)[0];n._vertexData=E.merge(s,!0,!1,!0,!0)}return o.restoreExecutionContext(),o.restoreInstancingContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t}(lb);(0,j.Y5)("BABYLON.InstantiateLinearBlock",ub);var db=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("radius",se.Int,!0,0,0),n.registerInput("angleStart",se.Float,!0,0),n.registerInput("angleEnd",se.Float,!0,2*Math.PI),n.registerInput("transform",se.Vector3,!0,new _.Pq(0,0,0)),n.registerInput("rotation",se.Vector3,!0,new _.Pq(0,0,0)),n.registerInput("scaling",se.Vector3,!0,new _.Pq(0,0,0)),n.scaling.acceptedConnectionPointTypes.push(se.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"InstantiateRadialBlock"},Object.defineProperty(t.prototype,"radius",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angleStart",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angleEnd",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){o.pushExecutionContext(n),o.pushInstancingContext(n);var a=n.count.getConnectedValue(o),s=[],l=_.uq.Identity(),c=_.uq.Identity(),u=_.uq.Identity(),d=_.Pq.Zero(),h=_.Pq.Zero(),p=_.Pq.Zero();for(n._currentIndex=0;n._currentIndex<a;n._currentIndex++){var m=n.instance.getConnectedValue(o);if(m&&m.positions&&m.positions.length!==0){var v=m.clone(),b=n.radius.getConnectedValue(o),E=n.angleStart.getConnectedValue(o),C=n.angleEnd.getConnectedValue(o),T=n.transform.getConnectedValue(o),f=n.rotation.getConnectedValue(o),g=o.adaptInput(n.scaling,se.Vector3,_.Pq.OneReadOnly),S=E+(C-E)/a*n._currentIndex,y=_.PT.FromEulerAngles(0,S,0);d.copyFrom(T.clone().scale(n._currentIndex)),h.copyFrom(f.clone().scale(n._currentIndex)),p.copyFrom(g.clone().scale(n._currentIndex)),p.addInPlaceFromFloats(1,1,1),_.uq.RotationYawPitchRollToRef(h.y,h.x,h.z,l),c.setTranslationFromFloats(0,0,b),_.uq.ComposeToRef(p,y,d,u),l.multiplyToRef(c,c),c.multiplyToRef(u,u),o._instantiateWithMatrix(v,u,s)}}if(s.length)if(s.length===1)n._vertexData=s[0];else{var x=s.splice(0,1)[0];n._vertexData=x.merge(s,!0,!1,!0,!0)}return o.restoreExecutionContext(),o.restoreInstancingContext(),n._vertexData};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t}(lb);(0,j.Y5)("BABYLON.InstantiateRadialBlock",db);var hb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("float ",se.Float,!0),n.registerInput("int ",se.Int,!0),n.registerOutput("float",se.Float),n.registerOutput("int",se.Int),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"IntFloatConverterBlock"},Object.defineProperty(t.prototype,"floatIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"floatOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return e==="float "?"floatIn":e==="int "?"intIn":e},t.prototype._buildBlock=function(){var e=this;this.floatOut._storedFunction=function(n){return e.floatIn.isConnected?e.floatIn.getConnectedValue(n):e.intIn.isConnected?e.intIn.getConnectedValue(n):0},this.intOut._storedFunction=function(n){return e.floatIn.isConnected?Math.floor(e.floatIn.getConnectedValue(n)):e.intIn.isConnected?Math.floor(e.intIn.getConnectedValue(n)):0}},t}(Tt);(0,j.Y5)("BABYLON.IntFloatConverterBlock",hb);var fb=function(r){function t(e){var n=r.call(this,e)||this;return n.log=[],n._isDebug=!0,n.registerInput("input",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"buildExecutionTime",{get:function(){return 0},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DebugBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this;if(!this.input.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);this.log=[];var i=function(o){var a=n.input.getConnectedValue(o);if(a==null)return n.log.push(["null",""]),a;switch(n.input.type){case se.Vector2:n.log.push([u0(a,4),a.toString()]);break;case se.Vector3:n.log.push([d0(a,4),a.toString()]);break;case se.Vector4:n.log.push([h0(a,4),a.toString()]);break;default:n.log.push([a.toString(),a.toString()])}return a};this.output.isConnected?this.output._storedFunction=i:this.output._storedValue=i(e)},t}(Tt);(0,j.Y5)("BABYLON.DebugBlock",fb);var Ar,pb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("geometry",se.Geometry),n.registerOutput("output",se.Geometry),n.registerOutput("id",se.Int),n.registerOutput("collectionId",se.Int),n.registerOutput("verticesCount",se.Int),n.registerOutput("facesCount",se.Int),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryInfoBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collectionId",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticesCount",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facesCount",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.geometry.isConnected)return this.id._storedValue=0,this.collectionId._storedValue=0,this.verticesCount._storedValue=0,this.facesCount._storedValue=0,this.output._storedValue=0,this.id._storedFunction=null,this.collectionId._storedFunction=null,this.verticesCount._storedFunction=null,this.facesCount._storedFunction=null,void(this.output._storedFunction=null);this.output._storedFunction=function(n){return e._currentVertexData=e.geometry.getConnectedValue(n),e._currentVertexData},this.id._storedFunction=function(n){return e._currentVertexData=e._currentVertexData||e.geometry.getConnectedValue(n),e._currentVertexData.uniqueId},this.collectionId._storedFunction=function(n){return e._currentVertexData=e._currentVertexData||e.geometry.getConnectedValue(n),e._currentVertexData.metadata?e._currentVertexData.metadata.collectionId:0},this.verticesCount._storedFunction=function(n){return e._currentVertexData=e._currentVertexData||e.geometry.getConnectedValue(n),e._currentVertexData.positions?e._currentVertexData.positions.length/3:0},this.facesCount._storedFunction=function(n){return e._currentVertexData=e._currentVertexData||e.geometry.getConnectedValue(n),e._currentVertexData.indices?e._currentVertexData.indices.length/3:0}},t}(Tt);(0,j.Y5)("BABYLON.GeometryInfoBlock",pb),function(r){r[r.Spherical=0]="Spherical",r[r.Cylindrical=1]="Cylindrical",r[r.Cubic=2]="Cubic"}(Ar||(Ar={}));var _b=function(r){function t(e){var n=r.call(this,e)||this;return n.mapping=Ar.Spherical,n.registerInput("position",se.Vector3),n.registerInput("normal",se.Vector3),n.registerInput("center",se.Vector3,!0,_.Pq.Zero()),n.registerOutput("uv",se.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MappingBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"center",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.position.isConnected)return this.uv._storedFunction=null,void(this.uv._storedValue=null);var n=_.Pq.Zero();this.uv._storedFunction=function(i){return function(o){var a=e.position.getConnectedValue(o)||_.Pq.Zero(),s=e.normal.getConnectedValue(o)||_.Pq.Zero(),l=e.center.getConnectedValue(o),c=_.I9.Zero();switch(e.mapping){case Ar.Spherical:a.subtractToRef(l,n),(u=n.length())>0&&(c.x=Math.acos(n.y/u)/Math.PI,n.x===0&&n.z===0||(c.y=Math.atan2(n.x,n.z)/(2*Math.PI)));break;case Ar.Cylindrical:var u;a.subtractToRef(l,n),(u=n.length())>0&&(c.x=Math.atan2(n.x/u,n.z/u)/(2*Math.PI),c.y=(n.y+1)/2);break;case Ar.Cubic:var d=Math.abs(s.x),h=Math.abs(s.y),p=Math.abs(s.z),m=Math.max(Math.abs(a.x),Math.abs(a.y),Math.abs(a.z)),v=0,b=0;d>=h&&d>=p?(v=a.y/m-l.y,b=a.z/m-l.z):h>=d&&h>=p?(v=a.x/m-l.x,b=a.z/m-l.z):(v=a.x/m-l.x,b=a.y/m-l.y),c.x=(v+1)/2,c.y=(b+1)/2}return c}(i)}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".mapping = BABYLON.MappingTypes.").concat(Ar[this.mapping],`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.mapping=this.mapping,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.mapping=e.mapping},(0,A.Cg)([dt("Mapping",4,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Spherical",value:Ar.Spherical},{label:"Cylindrical",value:Ar.Cylindrical},{label:"Cubic",value:Ar.Cubic}]})],t.prototype,"mapping",void 0),t}(Tt);(0,j.Y5)("BABYLON.MappingBlock",_b);var mb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("matrix0",se.Matrix),n.registerInput("matrix1",se.Matrix),n.registerOutput("output",se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"MatrixComposeBlock"},Object.defineProperty(t.prototype,"matrix0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;this.output._storedFunction=function(n){if(!e.matrix0.isConnected||!e.matrix1.isConnected)return null;var i=e.matrix0.getConnectedValue(n),o=e.matrix1.getConnectedValue(n);return i&&o?i.multiply(o):null}},t}(Tt);(0,j.Y5)("BABYLON.MatrixComposeBlock",mb);var gb=function(r){function t(e){var n=r.call(this,e)||this;return n._endpoints=[],n._isTeleportIn=!0,n.registerInput("input",se.AutoDetect),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"endpoints",{get:function(){return this._endpoints},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TeleportInBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),t.prototype._dumpCode=function(e,n){for(var i=r.prototype._dumpCode.call(this,e,n),o=0,a=this.endpoints;o<a.length;o++){var s=a[o];n.indexOf(s)===-1&&(i+=s._dumpCode(e,n))}return i},t.prototype.isAnAncestorOfType=function(e){if(this.getClassName()===e)return!0;for(var n=0,i=this.endpoints;n<i.length;n++)if(i[n].isAnAncestorOfType(e))return!0;return!1},t.prototype.isAnAncestorOf=function(e){for(var n=0,i=this.endpoints;n<i.length;n++){var o=i[n];if(o===e||o.isAnAncestorOf(e))return!0}return!1},t.prototype.getDescendantOfPredicate=function(e){if(e(this))return this;for(var n=0,i=this.endpoints;n<i.length;n++){var o=i[n].getDescendantOfPredicate(e);if(o)return o}return null},t.prototype.attachToEndpoint=function(e){e.detach(),this._endpoints.push(e),e._entryPoint=this,e._outputs[0]._typeConnectionSource=this._inputs[0],e._tempEntryPointUniqueId=null,e.name="> "+this.name},t.prototype.detachFromEndpoint=function(e){var n=this._endpoints.indexOf(e);n!==-1&&(this._endpoints.splice(n,1),e._outputs[0]._typeConnectionSource=null,e._entryPoint=null)},t.prototype._buildBlock=function(){for(var e=this,n=0,i=this._endpoints;n<i.length;n++)i[n].output._storedFunction=function(o){return e.input.getConnectedValue(o)}},t}(Tt);(0,j.Y5)("BABYLON.TeleportInBlock",gb);var vb=function(r){function t(e){var n=r.call(this,e)||this;return n._entryPoint=null,n._tempEntryPointUniqueId=null,n._isTeleportOut=!0,n.registerOutput("output",se.BasedOnInput),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"entryPoint",{get:function(){return this._entryPoint},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TeleportOutBlock"},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.detach=function(){this._entryPoint&&this._entryPoint.detachFromEndpoint(this)},t.prototype._buildBlock=function(){},t.prototype._customBuildStep=function(e){this.entryPoint&&this.entryPoint.build(e)},t.prototype._dumpCode=function(e,n){var i="";return this.entryPoint&&n.indexOf(this.entryPoint)===-1&&(i+=this.entryPoint._dumpCode(e,n)),i+r.prototype._dumpCode.call(this,e,n)},t.prototype._dumpCodeForOutputConnections=function(e){var n=r.prototype._dumpCodeForOutputConnections.call(this,e);return this.entryPoint&&(n+=this.entryPoint._dumpCodeForOutputConnections(e)),n},t.prototype.clone=function(){var e=r.prototype.clone.call(this);return this.entryPoint&&this.entryPoint.attachToEndpoint(e),e},t.prototype._dumpPropertiesCode=function(){var e=r.prototype._dumpPropertiesCode.call(this);return this.entryPoint&&(e+="".concat(this.entryPoint._codeVariableName,".attachToEndpoint(").concat(this._codeVariableName,`);
|
||
`)),e},t.prototype.serialize=function(){var e,n,i=r.prototype.serialize.call(this);return i.entryPoint=(n=(e=this.entryPoint)===null||e===void 0?void 0:e.uniqueId)!==null&&n!==void 0?n:"",i},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this._tempEntryPointUniqueId=e.entryPoint},t}(Tt);(0,j.Y5)("BABYLON.TeleportOutBlock",vb);var yb=function(r){function t(e){var n=r.call(this,e)||this;return n._data=null,n.serializedCachedData=!1,n.registerOutput("texture",se.Texture),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"textureData",{get:function(){return this._data},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureWidth",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureHeight",{get:function(){return this._height},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"GeometryTextureBlock"},Object.defineProperty(t.prototype,"texture",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._prepareImgToLoadAsync=function(e){var n=this;return new Promise(function(i,o){var a=new Image,s=document.createElement("canvas"),l=s.getContext("2d");a.onload=function(){s.width=a.width,s.height=a.height,l.drawImage(a,0,0);for(var c=l.getImageData(0,0,a.width,a.height).data,u=new Float32Array(c.length),d=0;d<c.length;d++)u[d]=c[d]/255;n._data=u,n._width=a.width,n._height=a.height,i()},a.onerror=function(){n._data=null,o()},a.src=e})},t.prototype.cleanData=function(){this._data=null},t.prototype.loadTextureFromFileAsync=function(e){return this._prepareImgToLoadAsync(URL.createObjectURL(e))},t.prototype.loadTextureFromUrlAsync=function(e){return this._prepareImgToLoadAsync(e)},t.prototype.extractFromTextureAsync=function(e){var n=this;return new Promise(function(i,o){if(e.isReady()){var a=e.getSize();Si.LO.GetTextureDataAsync(e,a.width,a.height).then(function(s){return(0,A.sH)(n,void 0,void 0,function(){var l,c;return(0,A.YH)(this,function(u){for(l=new Float32Array(s.length),c=0;c<s.length;c++)l[c]=s[c]/255;return this._data=l,this._width=a.width,this._height=a.height,i(),[2]})})}).catch(o)}else e.onLoadObservable.addOnce(function(){return n.extractFromTextureAsync(e).then(i).catch(o)})})},t.prototype._buildBlock=function(){if(this._data){var e={data:this._data,width:this._width,height:this._height};this.texture._storedValue=e}else this.texture._storedValue=null},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.width=this._width,e.height=this._height,e.serializedCachedData=this.serializedCachedData,this._data&&this.serializedCachedData&&(e.data=Array.from(this._data)),e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this._width=e.width,this._height=e.height,e.data?(this._data=new Float32Array(e.data),this.serializedCachedData=!0):this.serializedCachedData=!!e.serializedCachedData},(0,A.Cg)([dt("Serialize cached data",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"serializedCachedData",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryTextureBlock",yb);var bb=function(r){function t(e){var n=r.call(this,e)||this;return n.clampCoordinates=!0,n.registerInput("texture",se.Texture),n.registerInput("coordinates",se.Vector2),n.registerOutput("rgba",se.Vector4),n.registerOutput("rgb",se.Vector3),n.registerOutput("r",se.Float),n.registerOutput("g",se.Float),n.registerOutput("b",se.Float),n.registerOutput("a",se.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryTextureFetchBlock"},Object.defineProperty(t.prototype,"texture",{get:function(){return this.inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinates",{get:function(){return this.inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype._repeatClamp=function(e){return e>=0?e%1:1-Math.abs(e)%1},t.prototype._buildBlock=function(){var e=this,n=function(i){var o=e.texture.getConnectedValue(i);if(!o||!o.data)return null;var a=e.coordinates.getConnectedValue(i);if(!a)return null;var s=e.clampCoordinates?Math.max(0,Math.min(a.x,1)):e._repeatClamp(a.x),l=e.clampCoordinates?Math.max(0,Math.min(a.y,1)):e._repeatClamp(a.y),c=Math.floor(s*(o.width-1)),u=Math.floor(l*(o.height-1)),d=c+o.width*u;return _.IU.FromArray(o.data,4*d)};this.rgba._storedFunction=function(i){return n(i)},this.rgb._storedFunction=function(i){var o=n(i);return o?o.toVector3():null},this.r._storedFunction=function(i){var o=n(i);return o?o.x:null},this.g._storedFunction=function(i){var o=n(i);return o?o.y:null},this.b._storedFunction=function(i){var o=n(i);return o?o.z:null},this.a._storedFunction=function(i){var o=n(i);return o?o.w:null}},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".clampCoordinates = ").concat(this.clampCoordinates,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.clampCoordinates=this.clampCoordinates,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.clampCoordinates=e.clampCoordinates},(0,A.Cg)([dt("Clamp Coordinates",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"clampCoordinates",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryTextureFetchBlock",bb);var Cr,Tb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("geometry",se.Geometry),n.registerOutput("min",se.Vector3),n.registerOutput("max",se.Vector3),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"BoundingBlock"},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"min",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"max",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;this.min._storedFunction=function(n){var i=e.geometry.getConnectedValue(n);return i?(0,no.b)(i.positions,0,i.positions.length/3).minimum:null},this.max._storedFunction=function(n){var i=e.geometry.getConnectedValue(n);return i?(0,no.b)(i.positions,0,i.positions.length/3).maximum:null}},t}(Tt);(0,j.Y5)("BABYLON.BoundingBlock",Tb),function(r){r[r.Intersect=0]="Intersect",r[r.Subtract=1]="Subtract",r[r.Union=2]="Union"}(Cr||(Cr={}));var Sb=function(r){function t(e){var n=r.call(this,e)||this;return n.evaluateContext=!1,n.operation=Cr.Intersect,n.registerInput("geometry0",se.Geometry),n.registerInput("geometry1",se.Geometry),n.registerOutput("output",se.Geometry),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"BooleanGeometryBlock"},Object.defineProperty(t.prototype,"geometry0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(e){var n=this,i=function(o){var a=n.geometry0.getConnectedValue(o),s=n.geometry1.getConnectedValue(o);if(!a||!s)return null;var l=a.positions.length/3;!a.normals&&s.normals&&(a.normals=new Array(a.positions.length)),!s.normals&&a.normals&&(s.normals=new Array(s.positions.length)),!a.uvs&&s.uvs&&(a.uvs=new Array(2*l)),!s.uvs&&a.uvs&&(s.uvs=new Array(2*l)),!a.colors&&s.colors&&(a.colors=new Array(4*l)),!s.colors&&a.colors&&(s.colors=new Array(4*l));var c,u=jh.FromVertexData(a),d=jh.FromVertexData(s);switch(n.operation){case Cr.Intersect:c=u.intersect(d);break;case Cr.Subtract:c=u.subtract(d);break;case Cr.Union:c=u.union(d)}return c.toVertexData()};this.evaluateContext?this.output._storedFunction=i:(this.output._storedFunction=null,this.output._storedValue=i(e))},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".evaluateContext = ").concat(this.evaluateContext?"true":"false",`;
|
||
`)+"".concat(this._codeVariableName,".operation = BABYLON.BooleanGeometryOperations.").concat(Cr[this.operation],`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.evaluateContext=this.evaluateContext,e.operation=this.operation,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.evaluateContext=e.evaluateContext,e.operation&&(this.operation=e.operation)},(0,A.Cg)([dt("Evaluate context",0,"ADVANCED",{notifiers:{rebuild:!0}})],t.prototype,"evaluateContext",void 0),(0,A.Cg)([dt("Operation",4,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"Intersect",value:Cr.Intersect},{label:"Subtract",value:Cr.Subtract},{label:"Union",value:Cr.Union}]})],t.prototype,"operation",void 0),t}(Tt);(0,j.Y5)("BABYLON.BooleanGeometryBlock",Sb);var Eb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("x",se.AutoDetect),n.registerInput("y",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryArcTan2Block"},Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.x.isConnected||!this.y.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i,o){return Math.atan2(i,o)};this.output._storedFunction=function(i){var o=e.x.getConnectedValue(i),a=e.y.getConnectedValue(i);switch(e.x.type){case se.Int:case se.Float:return n(o,a);case se.Vector2:return new _.I9(n(o.x,a.x),n(o.y,a.y));case se.Vector3:return new _.Pq(n(o.x,a.x),n(o.y,a.y),n(o.z,a.z));case se.Vector4:return new _.IU(n(o.x,a.x),n(o.y,a.y),n(o.z,a.z),n(o.w,a.w))}return 0}},t}(Tt);(0,j.Y5)("BABYLON.GeometryArcTan2Block",Eb);var xb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("left",se.AutoDetect),n.registerInput("right",se.AutoDetect),n.registerInput("gradient",se.Float),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryLerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.left.isConnected||!this.right.isConnected||!this.gradient.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i,o,a){return(1-i)*o+i*a};return this.output._storedFunction=function(i){var o=e.left.getConnectedValue(i),a=e.right.getConnectedValue(i),s=e.gradient.getConnectedValue(i);switch(e.left.type){case se.Int:case se.Float:return n(s,o,a);case se.Vector2:return new _.I9(n(s,o.x,a.x),n(s,o.y,a.y));case se.Vector3:return new _.Pq(n(s,o.x,a.x),n(s,o.y,a.y),n(s,o.z,a.z));case se.Vector4:return new _.IU(n(s,o.x,a.x),n(s,o.y,a.y),n(s,o.z,a.z),n(s,o.w,a.w))}return 0},this},t}(Tt);(0,j.Y5)("BABYLON.GeometryLerpBlock",xb);var Pb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("left",se.AutoDetect),n.registerInput("right",se.AutoDetect),n.registerInput("gradient",se.Float),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryNLerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.left.isConnected||!this.right.isConnected||!this.gradient.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i,o,a){return(1-i)*o+i*a};return this.output._storedFunction=function(i){var o=e.left.getConnectedValue(i),a=e.right.getConnectedValue(i),s=e.gradient.getConnectedValue(i);switch(e.left.type){case se.Int:case se.Float:return n(s,o,a);case se.Vector2:return(l=new _.I9(n(s,o.x,a.x),n(s,o.y,a.y))).normalize(),l;case se.Vector3:return(l=new _.Pq(n(s,o.x,a.x),n(s,o.y,a.y),n(s,o.z,a.z))).normalize(),l;case se.Vector4:var l;return(l=new _.IU(n(s,o.x,a.x),n(s,o.y,a.y),n(s,o.z,a.z),n(s,o.w,a.w))).normalize(),l}return 0},this},t}(Tt);(0,j.Y5)("BABYLON.GeometryNLerpBlock",Pb);var Ab=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("value",se.AutoDetect),n.registerInput("edge",se.Float),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryStepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.value.isConnected||!this.edge.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i,o){return i<o?0:1};return this.output._storedFunction=function(i){var o=e.value.getConnectedValue(i),a=e.edge.getConnectedValue(i);switch(e.value.type){case se.Int:case se.Float:return n(o,a);case se.Vector2:return new _.I9(n(o.x,a),n(o.y,a));case se.Vector3:return new _.Pq(n(o.x,a),n(o.y,a),n(o.z,a));case se.Vector4:return new _.IU(n(o.x,a),n(o.y,a),n(o.z,a),n(o.w,a))}return 0},this},t}(Tt);(0,j.Y5)("BABYLON.GeometryStepBlock",Ab);var Cb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("value",se.AutoDetect),n.registerInput("edge0",se.Float),n.registerInput("edge1",se.Float),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometrySmoothStepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge0",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge1",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.value.isConnected||!this.edge0.isConnected||!this.edge1.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i,o,a){var s=Math.max(0,Math.min((i-o)/(a-o),1));return s*s*(3-2*s)};return this.output._storedFunction=function(i){var o=e.value.getConnectedValue(i),a=e.edge0.getConnectedValue(i),s=e.edge1.getConnectedValue(i);switch(e.value.type){case se.Int:case se.Float:return n(o,a,s);case se.Vector2:return new _.I9(n(o.x,a,s),n(o.y,a,s));case se.Vector3:return new _.Pq(n(o.x,a,s),n(o.y,a,s),n(o.z,a,s));case se.Vector4:return new _.IU(n(o.x,a,s),n(o.y,a,s),n(o.z,a,s),n(o.w,a,s))}return 0},this},t}(Tt);(0,j.Y5)("BABYLON.GeometrySmoothStepBlock",Cb);var Rb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("left",se.AutoDetect),n.registerInput("right",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryModBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.left.isConnected||!this.right.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i,o){return i-Math.floor(i/o)*o};return this.output._storedFunction=function(i){var o=e.left.getConnectedValue(i),a=e.right.getConnectedValue(i);switch(e.left.type){case se.Int:case se.Float:return n(o,a);case se.Vector2:return new _.I9(n(o.x,a.x),n(o.y,a.y));case se.Vector3:return new _.Pq(n(o.x,a.x),n(o.y,a.y),n(o.z,a.z));case se.Vector4:return new _.IU(n(o.x,a.x),n(o.y,a.y),n(o.z,a.z),n(o.w,a.w))}return 0},this},t}(Tt);(0,j.Y5)("BABYLON.GeometryModBlock",Rb);var Ib=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("value",se.AutoDetect),n.registerInput("power",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryPowBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"power",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.value.isConnected||!this.power.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i,o){return Math.pow(i,o)};return this.output._storedFunction=function(i){var o=e.value.getConnectedValue(i),a=e.power.getConnectedValue(i);switch(e.value.type){case se.Int:case se.Float:return n(o,a);case se.Vector2:return new _.I9(n(o.x,a),n(o.y,a));case se.Vector3:return new _.Pq(n(o.x,a),n(o.y,a),n(o.z,a));case se.Vector4:return new _.IU(n(o.x,a),n(o.y,a),n(o.z,a),n(o.w,a))}return 0},this},t}(Tt);(0,j.Y5)("BABYLON.GeometryPowBlock",Ib);var Mb=function(r){function t(e){var n=r.call(this,e)||this;return n.minimum=0,n.maximum=1,n.registerInput("value",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Geometry),n._inputs[0].excludedConnectionPointTypes.push(se.Texture),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryClampBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;if(!this.value.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);var n=function(i){return Math.max(e.minimum,Math.min(i,e.maximum))};return this.output._storedFunction=function(i){var o=e.value.getConnectedValue(i);switch(e.value.type){case se.Int:case se.Float:return n(o);case se.Vector2:return new _.I9(n(o.x),n(o.y));case se.Vector3:return new _.Pq(n(o.x),n(o.y),n(o.z));case se.Vector4:return new _.IU(n(o.x),n(o.y),n(o.z),n(o.w))}return 0},this},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".minimum = ").concat(this.minimum,`;
|
||
`)+"".concat(this._codeVariableName,".maximum = ").concat(this.maximum,`;
|
||
`)},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.minimum=this.minimum,e.maximum=this.maximum,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.minimum=e.minimum,this.maximum=e.maximum},(0,A.Cg)([dt("Minimum",1)],t.prototype,"minimum",void 0),(0,A.Cg)([dt("Maximum",1)],t.prototype,"maximum",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryClampBlock",Mb);var Ft,Ob=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("left",se.AutoDetect),n.registerInput("right",se.AutoDetect),n.registerOutput("output",se.Vector3),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Int),n._inputs[0].excludedConnectionPointTypes.push(se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Vector2),n._inputs[1].excludedConnectionPointTypes.push(se.Int),n._inputs[1].excludedConnectionPointTypes.push(se.Float),n._inputs[1].excludedConnectionPointTypes.push(se.Matrix),n._inputs[1].excludedConnectionPointTypes.push(se.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryCrossBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.left.isConnected&&this.right.isConnected?(this.output._storedFunction=function(n){var i=e.left.getConnectedValue(n),o=e.right.getConnectedValue(n);switch(e.left.type){case se.Vector3:return _.Pq.Cross(i,o);case se.Vector4:return _.Pq.Cross(i.toVector3(),o.toVector3())}return 0},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryCrossBlock",Ob),function(r){r[r.EaseInSine=0]="EaseInSine",r[r.EaseOutSine=1]="EaseOutSine",r[r.EaseInOutSine=2]="EaseInOutSine",r[r.EaseInQuad=3]="EaseInQuad",r[r.EaseOutQuad=4]="EaseOutQuad",r[r.EaseInOutQuad=5]="EaseInOutQuad",r[r.EaseInCubic=6]="EaseInCubic",r[r.EaseOutCubic=7]="EaseOutCubic",r[r.EaseInOutCubic=8]="EaseInOutCubic",r[r.EaseInQuart=9]="EaseInQuart",r[r.EaseOutQuart=10]="EaseOutQuart",r[r.EaseInOutQuart=11]="EaseInOutQuart",r[r.EaseInQuint=12]="EaseInQuint",r[r.EaseOutQuint=13]="EaseOutQuint",r[r.EaseInOutQuint=14]="EaseInOutQuint",r[r.EaseInExpo=15]="EaseInExpo",r[r.EaseOutExpo=16]="EaseOutExpo",r[r.EaseInOutExpo=17]="EaseInOutExpo",r[r.EaseInCirc=18]="EaseInCirc",r[r.EaseOutCirc=19]="EaseOutCirc",r[r.EaseInOutCirc=20]="EaseInOutCirc",r[r.EaseInBack=21]="EaseInBack",r[r.EaseOutBack=22]="EaseOutBack",r[r.EaseInOutBack=23]="EaseInOutBack",r[r.EaseInElastic=24]="EaseInElastic",r[r.EaseOutElastic=25]="EaseOutElastic",r[r.EaseInOutElastic=26]="EaseInOutElastic"}(Ft||(Ft={}));var Db=function(r){function t(e){var n=r.call(this,e)||this;return n.type=Ft.EaseInOutSine,n.registerInput("input",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[0].excludedConnectionPointTypes.push(se.Int),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryCurveBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e,n=this;if(!this.input.isConnected)return this.output._storedFunction=null,void(this.output._storedValue=null);switch(this.type){case Ft.EaseInSine:e=function(i){return 1-Math.cos(3.1415*i/2)};break;case Ft.EaseOutSine:e=function(i){return Math.sin(3.1415*i/2)};break;case Ft.EaseInOutSine:e=function(i){return-(Math.cos(3.1415*i)-1)/2};break;case Ft.EaseInQuad:e=function(i){return i*i};break;case Ft.EaseOutQuad:e=function(i){return(1-i)*(1-i)};break;case Ft.EaseInOutQuad:e=function(i){return i<.5?2*i*i:1-Math.pow(-2*i+2,2)/2};break;case Ft.EaseInCubic:e=function(i){return i*i*i};break;case Ft.EaseOutCubic:e=function(i){return 1-Math.pow(1-i,3)};break;case Ft.EaseInOutCubic:e=function(i){return i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2};break;case Ft.EaseInQuart:e=function(i){return i*i*i*i};break;case Ft.EaseOutQuart:e=function(i){return 1-Math.pow(1-i,4)};break;case Ft.EaseInOutQuart:e=function(i){return i<.5?8*i*i*i*i:1-Math.pow(-2*i+2,4)/2};break;case Ft.EaseInQuint:e=function(i){return i*i*i*i*i};break;case Ft.EaseOutQuint:e=function(i){return 1-Math.pow(1-i,5)};break;case Ft.EaseInOutQuint:e=function(i){return i<.5?16*i*i*i*i*i:1-Math.pow(-2*i+2,5)/2};break;case Ft.EaseInExpo:e=function(i){return i===0?0:Math.pow(2,10*i-10)};break;case Ft.EaseOutExpo:e=function(i){return i===1?1:1-Math.pow(2,-10*i)};break;case Ft.EaseInOutExpo:e=function(i){return i===0?0:i===1?1:i<.5?Math.pow(2,20*i-10)/2:(2-Math.pow(2,-20*i+10))/2};break;case Ft.EaseInCirc:e=function(i){return 1-Math.sqrt(1-Math.pow(i,2))};break;case Ft.EaseOutCirc:e=function(i){return Math.sqrt(1-Math.pow(i-1,2))};break;case Ft.EaseInOutCirc:e=function(i){return i<.5?(1-Math.sqrt(1-Math.pow(2*i,2)))/2:(Math.sqrt(1-Math.pow(-2*i+2,2))+1)/2};break;case Ft.EaseInBack:e=function(i){return 2.70158*i*i*i-1.70158*i*i};break;case Ft.EaseOutBack:e=function(i){return 2.70158*Math.pow(i-1,3)+1.70158*Math.pow(i-1,2)};break;case Ft.EaseInOutBack:e=function(i){return i<.5?Math.pow(2*i,2)*(7.189819*i-2.5949095)/2:(Math.pow(2*i-2,2)*(3.5949095*(2*i-2)+3.5949095)+2)/2};break;case Ft.EaseInElastic:e=function(i){return i===0?0:i===1?1:-Math.pow(2,10*i-10)*Math.sin(6.283/3*(10*i-10.75))};break;case Ft.EaseOutElastic:e=function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin(6.283/3*(10*i-.75))+1};break;case Ft.EaseInOutElastic:e=function(i){return i===0?0:i==1?1:i<.5?-Math.pow(2,20*i-10)*Math.sin(6.283/4.5*(20*i-11.125))/2:Math.pow(2,-20*i+10)*Math.sin(6.283/4.5*(20*i-11.125))/2+1}}return this.output._storedFunction=function(i){var o=n.input.getConnectedValue(i);switch(n.input.type){case se.Float:return e(o);case se.Vector2:return new _.I9(e(o.x),e(o.y));case se.Vector3:return new _.Pq(e(o.x),e(o.y),e(o.z));case se.Vector4:return new _.IU(e(o.x),e(o.y),e(o.z),e(o.w))}return 0},this},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.curveType=this.type,e},t.prototype._deserialize=function(e){r.prototype._deserialize.call(this,e),this.type=e.curveType},t.prototype._dumpPropertiesCode=function(){return r.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".type = BABYLON.GeometryCurveBlockTypes.").concat(Ft[this.type],`;
|
||
`)},(0,A.Cg)([dt("Type",4,"ADVANCED",{notifiers:{rebuild:!0},options:[{label:"EaseInSine",value:Ft.EaseInSine},{label:"EaseOutSine",value:Ft.EaseOutSine},{label:"EaseInOutSine",value:Ft.EaseInOutSine},{label:"EaseInQuad",value:Ft.EaseInQuad},{label:"EaseOutQuad",value:Ft.EaseOutQuad},{label:"EaseInOutQuad",value:Ft.EaseInOutQuad},{label:"EaseInCubic",value:Ft.EaseInCubic},{label:"EaseOutCubic",value:Ft.EaseOutCubic},{label:"EaseInOutCubic",value:Ft.EaseInOutCubic},{label:"EaseInQuart",value:Ft.EaseInQuart},{label:"EaseOutQuart",value:Ft.EaseOutQuart},{label:"EaseInOutQuart",value:Ft.EaseInOutQuart},{label:"EaseInQuint",value:Ft.EaseInQuint},{label:"EaseOutQuint",value:Ft.EaseOutQuint},{label:"EaseInOutQuint",value:Ft.EaseInOutQuint},{label:"EaseInExpo",value:Ft.EaseInExpo},{label:"EaseOutExpo",value:Ft.EaseOutExpo},{label:"EaseInOutExpo",value:Ft.EaseInOutExpo},{label:"EaseInCirc",value:Ft.EaseInCirc},{label:"EaseOutCirc",value:Ft.EaseOutCirc},{label:"EaseInOutCirc",value:Ft.EaseInOutCirc},{label:"EaseInBack",value:Ft.EaseInBack},{label:"EaseOutBack",value:Ft.EaseOutBack},{label:"EaseInOutBack",value:Ft.EaseInOutBack},{label:"EaseInElastic",value:Ft.EaseInElastic},{label:"EaseOutElastic",value:Ft.EaseOutElastic},{label:"EaseInOutElastic",value:Ft.EaseInOutElastic}]})],t.prototype,"type",void 0),t}(Tt);(0,j.Y5)("BABYLON.GeometryCurveBlock",Db);var Nb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("color",se.Vector3),n.registerInput("level",se.Float,!0,0),n.registerOutput("output",se.Vector3),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryDesaturateBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.color.isConnected?(this.output._storedFunction=function(n){var i=e.color.getConnectedValue(n),o=e.level.getConnectedValue(n),a=.5*(Math.min(i.x,i.y,i.z)+Math.max(i.x,i.y,i.z));return new _.Pq(i.x*(1-o)+a*o,i.y*(1-o)+a*o,i.z*(1-o)+a*o)},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryDesaturateBlock",Nb);var Lb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("value",se.AutoDetect),n.registerInput("steps",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[1].excludedConnectionPointTypes.push(se.Matrix),n._inputs[1].acceptedConnectionPointTypes.push(se.Float),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryPosterizeBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"steps",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.value.isConnected&&this.steps.isConnected?(this.output._storedFunction=function(n){var i=e.value.getConnectedValue(n),o=e.steps.getConnectedValue(n),a=o;if(e.steps.type===se.Float)switch(e.value.type){case se.Vector2:a=new _.I9(o,o);break;case se.Vector3:a=new _.Pq(o,o,o);break;case se.Vector4:a=new _.IU(o,o,o,o)}switch(e.value.type){case se.Vector2:return new _.I9(i.x/(1/a.x)*(1/a.x),i.y/(1/a.y)*(1/a.y));case se.Vector3:return new _.Pq(i.x/(1/a.x)*(1/a.x),i.y/(1/a.y)*(1/a.y),i.z/(1/a.z)*(1/a.z));case se.Vector4:return new _.IU(i.x/(1/a.x)*(1/a.x),i.y/(1/a.y)*(1/a.y),i.z/(1/a.z)*(1/a.z),i.w/(1/a.w)*(1/a.w));default:return Math.floor(i/(1/o)*(1/o))}},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryPosterizeBlock",Lb);var Fb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("value",se.AutoDetect),n.registerInput("reference",se.AutoDetect),n.registerInput("distance",se.Float),n.registerInput("replacement",se.AutoDetect),n.registerOutput("output",se.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._linkConnectionTypes(0,1),n._linkConnectionTypes(0,3),n._inputs[0].excludedConnectionPointTypes.push(se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[1].excludedConnectionPointTypes.push(se.Float),n._inputs[1].excludedConnectionPointTypes.push(se.Matrix),n._inputs[3].excludedConnectionPointTypes.push(se.Float),n._inputs[3].excludedConnectionPointTypes.push(se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryReplaceColorBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reference",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"distance",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"replacement",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.value.isConnected&&this.reference.isConnected&&this.distance.isConnected&&this.replacement.isConnected?(this.output._storedFunction=function(n){var i=e.value.getConnectedValue(n),o=e.reference.getConnectedValue(n),a=e.distance.getConnectedValue(n),s=e.replacement.getConnectedValue(n);return i.subtract(o).length()<a?s:i},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryReplaceColorBlock",Fb);var wb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("left",se.AutoDetect),n.registerInput("right",se.AutoDetect),n.registerOutput("output",se.Float),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Int),n._inputs[0].excludedConnectionPointTypes.push(se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[1].excludedConnectionPointTypes.push(se.Float),n._inputs[1].excludedConnectionPointTypes.push(se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryDistanceBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.left.isConnected&&this.right.isConnected?(this.output._storedFunction=function(n){var i=e.left.getConnectedValue(n),o=e.right.getConnectedValue(n);return i.subtract(o).length()},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryDistanceBlock",wb);var Bb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("left",se.AutoDetect),n.registerInput("right",se.AutoDetect),n.registerOutput("output",se.Float),n._linkConnectionTypes(0,1),n._inputs[0].excludedConnectionPointTypes.push(se.Int),n._inputs[0].excludedConnectionPointTypes.push(se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n._inputs[1].excludedConnectionPointTypes.push(se.Float),n._inputs[1].excludedConnectionPointTypes.push(se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryDotBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.left.isConnected&&this.right.isConnected?(this.output._storedFunction=function(n){var i=e.left.getConnectedValue(n),o=e.right.getConnectedValue(n);return i.dot(o)},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryDotBlock",Bb);var Vb=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("value",se.AutoDetect),n.registerOutput("output",se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Int),n._inputs[0].excludedConnectionPointTypes.push(se.Float),n._inputs[0].excludedConnectionPointTypes.push(se.Matrix),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryLengthBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.value.isConnected?(this.output._storedFunction=function(n){return e.value.getConnectedValue(n).length()},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryLengthBlock",Vb);var Ub=function(r){function t(e){var n=r.call(this,e)||this;return n.registerInput("input",se.Vector2),n.registerInput("angle",se.Float),n.registerOutput("output",se.Vector2),n}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GeometryRotate2dBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(){var e=this;return this.angle.isConnected&&this.input.isConnected?(this.output._storedFunction=function(n){var i=e.input.getConnectedValue(n),o=e.angle.getConnectedValue(n);return new _.I9(Math.cos(o)*i.x-Math.sin(o)*i.y,Math.sin(o)*i.x+Math.cos(o)*i.y)},this):(this.output._storedFunction=null,void(this.output._storedValue=null))},t}(Tt);(0,j.Y5)("BABYLON.GeometryRotate2dBlock",Ub);var RC=function(r){function t(e,n,i,o){n===void 0&&(n=null),i===void 0&&(i=null),o===void 0&&(o=!1);var a=r.call(this,e,i)||this;a._vertexCount=0,a._worker=null,a._frameIdLastUpdate=-1,a._modelViewMatrix=_.uq.Identity(),a._canPostToWorker=!0,a._readyToDisplay=!1,a._covariancesATexture=null,a._covariancesBTexture=null,a._centersTexture=null,a._colorsTexture=null,a._splatPositions=null,a._covariancesA=null,a._covariancesB=null,a._colors=null,a._keepInRam=!1;var s=new rt;return s.positions=[-2,-2,0,2,-2,0,2,2,0,-2,2,0],s.indices=[0,1,2,0,2,3],s.applyToMesh(a),a.subMeshes=[],new yi(0,0,4,0,6,a),a.setEnabled(!1),a._lastModelViewMatrix=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a._keepInRam=o,n&&a.loadFileAsync(n),a.material=new Hh(a.name+"_material",a._scene),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"covariancesATexture",{get:function(){return this._covariancesATexture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"covariancesBTexture",{get:function(){return this._covariancesBTexture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"centersTexture",{get:function(){return this._centersTexture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorsTexture",{get:function(){return this._colorsTexture},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"GaussianSplattingMesh"},t.prototype.getTotalVertices=function(){return this._vertexCount},t.prototype.isReady=function(e){return e===void 0&&(e=!1),!(!r.prototype.isReady.call(this,e,!0)||!this._readyToDisplay&&(this._postToWorker(),1))},t.prototype._postToWorker=function(){var e=this.getScene().getFrameId();if(e!==this._frameIdLastUpdate&&this._worker&&this._scene.activeCamera&&this._canPostToWorker){this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(),this._modelViewMatrix),_.AA.Vector3[0].set(this._lastModelViewMatrix[8],this._lastModelViewMatrix[9],this._lastModelViewMatrix[10]),_.AA.Vector3[1].set(this._modelViewMatrix.m[8],this._modelViewMatrix.m[9],this._modelViewMatrix.m[10]),_.AA.Vector3[0].normalize(),_.AA.Vector3[1].normalize();var n=_.Pq.Dot(_.AA.Vector3[0],_.AA.Vector3[1]);Math.abs(n-1)>=.01&&(this._frameIdLastUpdate=e,this._canPostToWorker=!1,this._lastModelViewMatrix=this._modelViewMatrix.m.slice(0),this._worker.postMessage({view:this._modelViewMatrix.m,depthMix:this._depthMix,useRightHandedSystem:this._scene.useRightHandedSystem},[this._depthMix.buffer]))}},t.prototype.render=function(e,n,i){return this._postToWorker(),r.prototype.render.call(this,e,n,i)},t.ConvertPLYToSplat=function(e){var n,i=new Uint8Array(e),o=new TextDecoder().decode(i.slice(0,10240)),a=o.indexOf(`end_header
|
||
`);if(a<0||!o)return e;for(var s=parseInt(/element vertex (\d+)\n/.exec(o)[1]),l=0,c={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1},u=[],d=0,h=o.slice(0,a).split(`
|
||
`).filter(function(X){return X.startsWith("property ")});d<h.length;d++){var p=(n=h[d].split(" "))[1],m=n[2];if(u.push({name:m,type:p,offset:l}),!c[p])return O.V.Error("Unsupported property type: ".concat(p,". Are you sure it's a valid Gaussian Splatting file?")),new ArrayBuffer(0);l+=c[p]}for(var v=.28209479177387814,b=new DataView(e,a+11),E=new ArrayBuffer(32*s),C=new _.PT,T=0;T<s;T++){for(var f=new Float32Array(E,32*T,3),g=new Float32Array(E,32*T+12,3),S=new Uint8ClampedArray(E,32*T+24,4),y=new Uint8ClampedArray(E,32*T+28,4),x=255,R=0,I=0,M=0,D=0;D<u.length;D++){var B=u[D],F=void 0;switch(B.type){case"float":F=b.getFloat32(B.offset+T*l,!0);break;case"int":F=b.getInt32(B.offset+T*l,!0);break;default:throw new Error("Unsupported property type: ".concat(B.type))}switch(B.name){case"x":f[0]=F;break;case"y":f[1]=F;break;case"z":f[2]=F;break;case"scale_0":g[0]=Math.exp(F);break;case"scale_1":g[1]=Math.exp(F);break;case"scale_2":g[2]=Math.exp(F);break;case"red":S[0]=F;break;case"green":S[1]=F;break;case"blue":S[2]=F;break;case"f_dc_0":S[0]=255*(.5+v*F);break;case"f_dc_1":S[1]=255*(.5+v*F);break;case"f_dc_2":S[2]=255*(.5+v*F);break;case"f_dc_3":S[3]=255*(.5+v*F);break;case"opacity":S[3]=1/(1+Math.exp(-F))*255;break;case"rot_0":x=F;break;case"rot_1":R=F;break;case"rot_2":I=F;break;case"rot_3":M=F}}C.set(R,I,M,x),C.normalize(),y[0]=128*C.w+128,y[1]=128*C.x+128,y[2]=128*C.y+128,y[3]=128*C.z+128}return E},t.prototype.loadDataAsync=function(e){return Promise.resolve(this._loadData(e))},t.prototype.loadFileAsync=function(e){var n=this;return ze.S0.LoadFileAsync(e,!0).then(function(i){n._loadData(t.ConvertPLYToSplat(i))})},t.prototype.dispose=function(e){var n,i,o,a,s;(n=this._covariancesATexture)===null||n===void 0||n.dispose(),(i=this._covariancesBTexture)===null||i===void 0||i.dispose(),(o=this._centersTexture)===null||o===void 0||o.dispose(),(a=this._colorsTexture)===null||a===void 0||a.dispose(),this._covariancesATexture=null,this._covariancesBTexture=null,this._centersTexture=null,this._colorsTexture=null,(s=this._worker)===null||s===void 0||s.terminate(),this._worker=null,r.prototype.dispose.call(this,e,!0)},t.prototype._copyTextures=function(e){var n,i,o,a;this._covariancesATexture=(n=e.covariancesATexture)===null||n===void 0?void 0:n.clone(),this._covariancesBTexture=(i=e.covariancesBTexture)===null||i===void 0?void 0:i.clone(),this._centersTexture=(o=e.centersTexture)===null||o===void 0?void 0:o.clone(),this._colorsTexture=(a=e.colorsTexture)===null||a===void 0?void 0:a.clone()},t.prototype.clone=function(e){e===void 0&&(e="");var n=new t(e,void 0,this.getScene());n._copySource(this),n.makeGeometryUnique(),n._vertexCount=this._vertexCount,n._copyTextures(this),n._modelViewMatrix=_.uq.Identity(),n._splatPositions=this._splatPositions,n._readyToDisplay=!1,n._instanciateWorker();var i=this.getBoundingInfo();return n.getBoundingInfo().reConstruct(i.minimum,i.maximum,this.getWorldMatrix()),n.forcedInstanceCount=n._vertexCount,n.setEnabled(!0),n},t.prototype.updateData=function(e){var n=this;if(e.byteLength){this._covariancesATexture||(this._readyToDisplay=!1);var i=new Uint8Array(e),o=new Float32Array(i.buffer),a=i.length/32;this._vertexCount=a;var s=this._getTextureSize(a),l=s.x*s.y;this._splatPositions=new Float32Array(3*l);for(var c=new Float32Array(3*l),u=new Float32Array(3*l),d=_.AA.Matrix[0],h=_.AA.Matrix[1],p=_.AA.Quaternion[0],m=new _.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),v=new _.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),b=0;b<a;b++){var E=o[8*b+0],C=-o[8*b+1],T=o[8*b+2];this._splatPositions[3*b+0]=E,this._splatPositions[3*b+1]=C,this._splatPositions[3*b+2]=T,m.minimizeInPlaceFromFloats(E,C,T),v.maximizeInPlaceFromFloats(E,C,T),p.set((i[32*b+28+1]-128)/128,(i[32*b+28+2]-128)/128,(i[32*b+28+3]-128)/128,-(i[32*b+28+0]-128)/128),p.toRotationMatrix(d),_.uq.ScalingToRef(2*o[8*b+3+0],2*o[8*b+3+1],2*o[8*b+3+2],h);var f=d.multiplyToRef(h,_.AA.Matrix[0]).m;c[3*b+0]=f[0]*f[0]+f[1]*f[1]+f[2]*f[2],c[3*b+1]=f[0]*f[4]+f[1]*f[5]+f[2]*f[6],c[3*b+2]=f[0]*f[8]+f[1]*f[9]+f[2]*f[10],u[3*b+0]=f[4]*f[4]+f[5]*f[5]+f[6]*f[6],u[3*b+1]=f[4]*f[8]+f[5]*f[9]+f[6]*f[10],u[3*b+2]=f[8]*f[8]+f[9]*f[9]+f[10]*f[10]}this.getBoundingInfo().reConstruct(m,v,this.getWorldMatrix()),this.forcedInstanceCount=this._vertexCount,this.setEnabled(!0);var g=function(R,I,M,D){return new Ln(R,I,M,D,n._scene,!1,!1,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT)},S=function(R,I,M,D){n.getEngine().updateTextureData(R.getInternalTexture(),I,0,0,M,D,0,0,!1)},y=function(R){for(var I=R.length/3,M=new Float32Array(4*I),D=0;D<I;++D)M[4*D+0]=R[3*D+0],M[4*D+1]=R[3*D+1],M[4*D+2]=R[3*D+2],M[4*D+3]=1;return M},x=new Float32Array(s.x*s.y*4);for(b=0;b<this._vertexCount;++b)x[4*b+0]=i[32*b+24+0]/255,x[4*b+1]=i[32*b+24+1]/255,x[4*b+2]=i[32*b+24+2]/255,x[4*b+3]=i[32*b+24+3]/255;this._keepInRam&&(this._covariancesA=c,this._covariancesB=u,this._colors=x),this._covariancesATexture?(S(this._covariancesATexture,y(c),s.x,s.y),S(this._covariancesBTexture,y(u),s.x,s.y),S(this._centersTexture,y(this._splatPositions),s.x,s.y),S(this._colorsTexture,x,s.x,s.y)):(this._covariancesATexture=g(y(c),s.x,s.y,P.Y.TEXTUREFORMAT_RGBA),this._covariancesBTexture=g(y(u),s.x,s.y,P.Y.TEXTUREFORMAT_RGBA),this._centersTexture=g(y(this._splatPositions),s.x,s.y,P.Y.TEXTUREFORMAT_RGBA),this._colorsTexture=g(x,s.x,s.y,P.Y.TEXTUREFORMAT_RGBA),this._instanciateWorker())}},t.prototype._loadData=function(e){e.byteLength&&this.updateData(e)},t.prototype._instanciateWorker=function(){var e,n=this;if(this._vertexCount){var i=new Float32Array(this._vertexCount);this.thinInstanceSetBuffer("splatIndex",i,1,!1),(e=this._worker)===null||e===void 0||e.terminate(),this._worker=new Worker(URL.createObjectURL(new Blob(["(",t._CreateWorker.toString(),")(self)"],{type:"application/javascript"}))),this._depthMix=new BigInt64Array(this._vertexCount);var o=Float32Array.from(this._splatPositions),a=this._vertexCount;this._worker.postMessage({positions:o,vertexCount:a},[o.buffer]),this._worker.onmessage=function(s){n._depthMix=s.data.depthMix;for(var l=new Uint32Array(s.data.depthMix.buffer),c=0;c<n._vertexCount;c++)i[c]=l[2*c];n.thinInstanceBufferUpdated("splatIndex"),n._canPostToWorker=!0,n._readyToDisplay=!0}}},t.prototype._getTextureSize=function(e){var n=this._scene.getEngine(),i=n.getCaps().maxTextureSize,o=1;if(n.version!==1||n.isWebGPU)o=Math.ceil(e/i);else for(;i*o<e;)o*=2;return o>i&&(O.V.Error("GaussianSplatting texture size: ("+i+", "+o+"), maxTextureSize: "+i),o=i),new _.I9(i,o)},t._CreateWorker=function(e){var n,i,o,a,s=0;e.onmessage=function(l){if(l.data.positions)n=l.data.positions,s=l.data.vertexCount;else{var c=l.data.view;if(!n||!c)throw new Error("positions or view is not defined!");i=l.data.depthMix,o=new Uint32Array(i.buffer),a=new Float32Array(i.buffer);for(var u=0;u<s;u++)o[2*u]=u;var d=-1;for(l.data.useRightHandedSystem&&(d=1),u=0;u<s;u++)a[2*u+1]=1e4+(c[2]*n[3*u+0]+c[6]*n[3*u+1]+c[10]*n[3*u+2])*d;i.sort(),e.postMessage({depthMix:i},[i.buffer])}}},t}(xe),IC=L(47590),MC=L(69512),OC=L(34855),DC=L(69425),NC=L(86254),LC=L(30004),FC=L(79444),wC=L(7726),BC=L(12436),VC=L(40002),UC=L(39721),GC=L(55139),kC=L(42769),zC=L(583),WC=function(){function r(t){t===void 0&&(t=Recast),this.bjsRECAST={},this.name="RecastJSPlugin",this._maximumSubStepCount=10,this._timeStep=1/60,this._timeFactor=1,this._worker=null,typeof t=="function"?O.V.Error("RecastJS is not ready. Please make sure you await Recast() before using the plugin."):this.bjsRECAST=t,this.isSupported()?(this.setTimeStep(),this._tempVec1=new this.bjsRECAST.Vec3,this._tempVec2=new this.bjsRECAST.Vec3):O.V.Error("RecastJS is not available. Please make sure you included the js file.")}return r.prototype.setWorkerURL=function(t){return!(!window||!window.Worker||(this._worker=new Worker(t),0))},r.prototype.setTimeStep=function(t){t===void 0&&(t=1/60),this._timeStep=t},r.prototype.getTimeStep=function(){return this._timeStep},r.prototype.setMaximumSubStepCount=function(t){t===void 0&&(t=10),this._maximumSubStepCount=t},r.prototype.getMaximumSubStepCount=function(){return this._maximumSubStepCount},Object.defineProperty(r.prototype,"timeFactor",{get:function(){return this._timeFactor},set:function(t){this._timeFactor=Math.max(t,0)},enumerable:!1,configurable:!0}),r.prototype.createNavMesh=function(t,e,n){var i,o,a;this._worker&&!n?O.V.Warn("A worker is avaible but no completion callback. Defaulting to blocking navmesh creation"):!this._worker&&n&&O.V.Warn("A completion callback is avaible but no worker. Defaulting to blocking navmesh creation"),this.navMesh=new this.bjsRECAST.NavMesh;var s=[],l=[],c=0;for(i=0;i<t.length;i++)if(t[i]){var u=t[i],d=u.getIndices();if(!d)continue;var h=u.getVerticesData(Y.R.PositionKind,!1,!1);if(!h)continue;var p=[],m=u.computeWorldMatrix(!0);if(u.hasThinInstances)for(var v=u.thinInstanceGetWorldMatrices(),b=0;b<v.length;b++){var E=new Ge.uq;v[b].multiplyToRef(m,E),p.push(E)}else p.push(m);for(var C=0;C<p.length;C++){var T=p[C];for(o=0;o<d.length;o++)s.push(d[o]+c);var f=Ge.Pq.Zero(),g=Ge.Pq.Zero();for(a=0;a<h.length;a+=3)Ge.Pq.FromArrayToRef(h,a,g),Ge.Pq.TransformCoordinatesToRef(g,T,f),l.push(f.x,f.y,f.z);c+=h.length/3}}if(this._worker&&n)this._worker.postMessage([l,c,s,s.length,e]),this._worker.onmessage=function(y){n(y.data)};else{var S=new this.bjsRECAST.rcConfig;S.cs=e.cs,S.ch=e.ch,S.borderSize=e.borderSize?e.borderSize:0,S.tileSize=e.tileSize?e.tileSize:0,S.walkableSlopeAngle=e.walkableSlopeAngle,S.walkableHeight=e.walkableHeight,S.walkableClimb=e.walkableClimb,S.walkableRadius=e.walkableRadius,S.maxEdgeLen=e.maxEdgeLen,S.maxSimplificationError=e.maxSimplificationError,S.minRegionArea=e.minRegionArea,S.mergeRegionArea=e.mergeRegionArea,S.maxVertsPerPoly=e.maxVertsPerPoly,S.detailSampleDist=e.detailSampleDist,S.detailSampleMaxError=e.detailSampleMaxError,this.navMesh.build(l,c,s,s.length,S)}},r.prototype.createDebugNavMesh=function(t){var e,n,i=this.navMesh.getDebugNavMesh(),o=i.getTriangleCount(),a=[],s=[];for(e=0;e<3*o;e++)a.push(e);for(e=0;e<o;e++)for(n=0;n<3;n++){var l=i.getTriangle(e).getPoint(n);s.push(l.x,l.y,l.z)}var c=new xe("NavMeshDebug",t),u=new rt;return u.indices=a,u.positions=s,u.applyToMesh(c,!1),c},r.prototype.getClosestPoint=function(t){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z;var e=this.navMesh.getClosestPoint(this._tempVec1);return new Ge.Pq(e.x,e.y,e.z)},r.prototype.getClosestPointToRef=function(t,e){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z;var n=this.navMesh.getClosestPoint(this._tempVec1);e.set(n.x,n.y,n.z)},r.prototype.getRandomPointAround=function(t,e){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z;var n=this.navMesh.getRandomPointAround(this._tempVec1,e);return new Ge.Pq(n.x,n.y,n.z)},r.prototype.getRandomPointAroundToRef=function(t,e,n){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z;var i=this.navMesh.getRandomPointAround(this._tempVec1,e);n.set(i.x,i.y,i.z)},r.prototype.moveAlong=function(t,e){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z,this._tempVec2.x=e.x,this._tempVec2.y=e.y,this._tempVec2.z=e.z;var n=this.navMesh.moveAlong(this._tempVec1,this._tempVec2);return new Ge.Pq(n.x,n.y,n.z)},r.prototype.moveAlongToRef=function(t,e,n){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z,this._tempVec2.x=e.x,this._tempVec2.y=e.y,this._tempVec2.z=e.z;var i=this.navMesh.moveAlong(this._tempVec1,this._tempVec2);n.set(i.x,i.y,i.z)},r.prototype._convertNavPathPoints=function(t){var e,n=t.getPointCount(),i=[];for(e=0;e<n;e++){var o=t.getPoint(e);i.push(new Ge.Pq(o.x,o.y,o.z))}return i},r.prototype.computePath=function(t,e){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z,this._tempVec2.x=e.x,this._tempVec2.y=e.y,this._tempVec2.z=e.z;var n=this.navMesh.computePath(this._tempVec1,this._tempVec2);return this._convertNavPathPoints(n)},r.prototype.computePathSmooth=function(t,e){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z,this._tempVec2.x=e.x,this._tempVec2.y=e.y,this._tempVec2.z=e.z;var n=this.navMesh.computePathSmooth(this._tempVec1,this._tempVec2);return this._convertNavPathPoints(n)},r.prototype.createCrowd=function(t,e,n){return new Gb(this,t,e,n)},r.prototype.setDefaultQueryExtent=function(t){this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z,this.navMesh.setDefaultQueryExtent(this._tempVec1)},r.prototype.getDefaultQueryExtent=function(){var t=this.navMesh.getDefaultQueryExtent();return new Ge.Pq(t.x,t.y,t.z)},r.prototype.buildFromNavmeshData=function(t){var e=t.length*t.BYTES_PER_ELEMENT,n=this.bjsRECAST._malloc(e),i=new Uint8Array(this.bjsRECAST.HEAPU8.buffer,n,e);i.set(t);var o=new this.bjsRECAST.NavmeshData;o.dataPointer=i.byteOffset,o.size=t.length,this.navMesh=new this.bjsRECAST.NavMesh,this.navMesh.buildFromNavmeshData(o),this.bjsRECAST._free(i.byteOffset)},r.prototype.getNavmeshData=function(){var t=this.navMesh.getNavmeshData(),e=new Uint8Array(this.bjsRECAST.HEAPU8.buffer,t.dataPointer,t.size),n=new Uint8Array(t.size);return n.set(e),this.navMesh.freeNavmeshData(t),n},r.prototype.getDefaultQueryExtentToRef=function(t){var e=this.navMesh.getDefaultQueryExtent();t.set(e.x,e.y,e.z)},r.prototype.dispose=function(){},r.prototype.addCylinderObstacle=function(t,e,n){return this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z,this.navMesh.addCylinderObstacle(this._tempVec1,e,n)},r.prototype.addBoxObstacle=function(t,e,n){return this._tempVec1.x=t.x,this._tempVec1.y=t.y,this._tempVec1.z=t.z,this._tempVec2.x=e.x,this._tempVec2.y=e.y,this._tempVec2.z=e.z,this.navMesh.addBoxObstacle(this._tempVec1,this._tempVec2,n)},r.prototype.removeObstacle=function(t){this.navMesh.removeObstacle(t)},r.prototype.isSupported=function(){return this.bjsRECAST!==void 0},r.prototype.getRandomSeed=function(){return this.bjsRECAST._getRandomSeed()},r.prototype.setRandomSeed=function(t){this.bjsRECAST._setRandomSeed(t)},r}(),Gb=function(){function r(t,e,n,i){var o=this;this.recastCrowd={},this.transforms=new Array,this.agents=new Array,this.reachRadii=new Array,this._agentDestinationArmed=new Array,this._agentDestination=new Array,this._onBeforeAnimationsObserver=null,this.onReachTargetObservable=new K.cP,this.bjsRECASTPlugin=t,this.recastCrowd=new this.bjsRECASTPlugin.bjsRECAST.Crowd(e,n,this.bjsRECASTPlugin.navMesh.getNavMesh()),this._scene=i,this._onBeforeAnimationsObserver=i.onBeforeAnimationsObservable.add(function(){o.update(.001*i.getEngine().getDeltaTime()*t.timeFactor)})}return r.prototype.addAgent=function(t,e,n){var i=new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams;i.radius=e.radius,i.height=e.height,i.maxAcceleration=e.maxAcceleration,i.maxSpeed=e.maxSpeed,i.collisionQueryRange=e.collisionQueryRange,i.pathOptimizationRange=e.pathOptimizationRange,i.separationWeight=e.separationWeight,i.updateFlags=7,i.obstacleAvoidanceType=0,i.queryFilterType=0,i.userData=0;var o=this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z),i);return this.transforms.push(n),this.agents.push(o),this.reachRadii.push(e.reachRadius?e.reachRadius:e.radius),this._agentDestinationArmed.push(!1),this._agentDestination.push(new Ge.Pq(0,0,0)),o},r.prototype.getAgentPosition=function(t){var e=this.recastCrowd.getAgentPosition(t);return new Ge.Pq(e.x,e.y,e.z)},r.prototype.getAgentPositionToRef=function(t,e){var n=this.recastCrowd.getAgentPosition(t);e.set(n.x,n.y,n.z)},r.prototype.getAgentVelocity=function(t){var e=this.recastCrowd.getAgentVelocity(t);return new Ge.Pq(e.x,e.y,e.z)},r.prototype.getAgentVelocityToRef=function(t,e){var n=this.recastCrowd.getAgentVelocity(t);e.set(n.x,n.y,n.z)},r.prototype.getAgentNextTargetPath=function(t){var e=this.recastCrowd.getAgentNextTargetPath(t);return new Ge.Pq(e.x,e.y,e.z)},r.prototype.getAgentNextTargetPathToRef=function(t,e){var n=this.recastCrowd.getAgentNextTargetPath(t);e.set(n.x,n.y,n.z)},r.prototype.getAgentState=function(t){return this.recastCrowd.getAgentState(t)},r.prototype.overOffmeshConnection=function(t){return this.recastCrowd.overOffmeshConnection(t)},r.prototype.agentGoto=function(t,e){this.recastCrowd.agentGoto(t,new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z));var n=this.agents.indexOf(t);n>-1&&(this._agentDestinationArmed[n]=!0,this._agentDestination[n].set(e.x,e.y,e.z))},r.prototype.agentTeleport=function(t,e){this.recastCrowd.agentTeleport(t,new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z))},r.prototype.updateAgentParameters=function(t,e){var n=this.recastCrowd.getAgentParameters(t);e.radius!==void 0&&(n.radius=e.radius),e.height!==void 0&&(n.height=e.height),e.maxAcceleration!==void 0&&(n.maxAcceleration=e.maxAcceleration),e.maxSpeed!==void 0&&(n.maxSpeed=e.maxSpeed),e.collisionQueryRange!==void 0&&(n.collisionQueryRange=e.collisionQueryRange),e.pathOptimizationRange!==void 0&&(n.pathOptimizationRange=e.pathOptimizationRange),e.separationWeight!==void 0&&(n.separationWeight=e.separationWeight),this.recastCrowd.setAgentParameters(t,n)},r.prototype.removeAgent=function(t){this.recastCrowd.removeAgent(t);var e=this.agents.indexOf(t);e>-1&&(this.agents.splice(e,1),this.transforms.splice(e,1),this.reachRadii.splice(e,1),this._agentDestinationArmed.splice(e,1),this._agentDestination.splice(e,1))},r.prototype.getAgents=function(){return this.agents},r.prototype.update=function(t){if(this.bjsRECASTPlugin.navMesh.update(),!(t<=Ge.bH)){var e=this.bjsRECASTPlugin.getTimeStep(),n=this.bjsRECASTPlugin.getMaximumSubStepCount();if(e<=Ge.bH)this.recastCrowd.update(t);else{var i=Math.floor(t/e);n&&i>n&&(i=n),i<1&&(i=1);for(var o=t/i,a=0;a<i;a++)this.recastCrowd.update(o)}for(var s=0;s<this.agents.length;s++){var l=this.agents[s],c=this.getAgentPosition(l);if(this.transforms[s].position=c,this._agentDestinationArmed[s]){var u=c.x-this._agentDestination[s].x,d=c.z-this._agentDestination[s].z,h=this.reachRadii[s],p=this._agentDestination[s].y-this.reachRadii[s],m=this._agentDestination[s].y+this.reachRadii[s],v=u*u+d*d;c.y>p&&c.y<m&&v<h*h&&(this._agentDestinationArmed[s]=!1,this.onReachTargetObservable.notifyObservers({agentIndex:l,destination:this._agentDestination[s]}))}}}},r.prototype.setDefaultQueryExtent=function(t){var e=new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z);this.recastCrowd.setDefaultQueryExtent(e)},r.prototype.getDefaultQueryExtent=function(){var t=this.recastCrowd.getDefaultQueryExtent();return new Ge.Pq(t.x,t.y,t.z)},r.prototype.getDefaultQueryExtentToRef=function(t){var e=this.recastCrowd.getDefaultQueryExtent();t.set(e.x,e.y,e.z)},r.prototype.getCorners=function(t){var e,n=this.recastCrowd.getCorners(t),i=n.getPointCount(),o=[];for(e=0;e<i;e++){var a=n.getPoint(e);o.push(new Ge.Pq(a.x,a.y,a.z))}return o},r.prototype.dispose=function(){this.recastCrowd.destroy(),this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.onReachTargetObservable.clear()},r}(),fa=L(65054);Be.$.OfflineProviderFactory=function(r,t,e){return e===void 0&&(e=!1),new kb(r,t,e)};var kb=function(){function r(t,e,n){n===void 0&&(n=!1),this._idbFactory=typeof indexedDB<"u"?indexedDB:void 0,this._currentSceneUrl=r._ReturnFullUrlLocation(t),this._db=null,this._enableSceneOffline=!1,this._enableTexturesOffline=!1,this._manifestVersionFound=0,this._mustUpdateRessources=!1,this._hasReachedQuota=!1,r.IDBStorageEnabled?n?(this._enableSceneOffline=!0,this._enableTexturesOffline=!0,this._manifestVersionFound=1,ze.S0.SetImmediate(function(){e(!0)})):this._checkManifestFile(e):e(!0)}return Object.defineProperty(r.prototype,"enableSceneOffline",{get:function(){return this._enableSceneOffline},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableTexturesOffline",{get:function(){return this._enableTexturesOffline},enumerable:!1,configurable:!0}),r.prototype._checkManifestFile=function(t){var e=this,n=function(){e._enableSceneOffline=!1,e._enableTexturesOffline=!1,t(!1)},i=function(){try{if(typeof URL=="function"&&e._currentSceneUrl.indexOf("http")===0){var l=new URL(e._currentSceneUrl);return l.pathname+=".manifest",l.toString()}}catch{}return"".concat(e._currentSceneUrl,".manifest")},o=!1,a=i(),s=new We.u;navigator.onLine&&(o=!0,a=a+(a.match(/\?/)==null?"?":"&")+Date.now()),s.open("GET",a),s.addEventListener("load",function(){if(s.status===200||r._ValidateXHRData(s,1))try{var l=JSON.parse(s.response);e._enableSceneOffline=l.enableSceneOffline,e._enableTexturesOffline=l.enableTexturesOffline&&r._IsUASupportingBlobStorage,l.version&&!isNaN(parseInt(l.version))&&(e._manifestVersionFound=l.version),t(!0)}catch{n()}else n()},!1),s.addEventListener("error",function(){if(o){o=!1;var l=i();s.open("GET",l),s.send()}else n()},!1);try{s.send()}catch{O.V.Error("Error on XHR send request."),t(!1)}},r.prototype.open=function(t,e){var n=this,i=function(){n._isSupported=!1,e&&e()};if(this._idbFactory&&(this._enableSceneOffline||this._enableTexturesOffline))if(this._db)t&&t();else{this._hasReachedQuota=!1,this._isSupported=!0;var o=this._idbFactory.open("babylonjs",1);o.onerror=function(){i()},o.onblocked=function(){O.V.Error("IDB request blocked. Please reload the page."),i()},o.onsuccess=function(){n._db=o.result,t()},o.onupgradeneeded=function(a){if(n._db=a.target.result,n._db)try{n._db.createObjectStore("scenes",{keyPath:"sceneUrl"}),n._db.createObjectStore("versions",{keyPath:"sceneUrl"}),n._db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(s){O.V.Error("Error while creating object stores. Exception: "+s.message),i()}}}else this._isSupported=!1,e&&e()},r.prototype.loadImage=function(t,e){var n=this,i=r._ReturnFullUrlLocation(t),o=function(){n._hasReachedQuota||n._db===null?e.src=t:n._saveImageIntoDBAsync(i,e)};this._mustUpdateRessources?o():this._loadImageFromDBAsync(i,e,o)},r.prototype._loadImageFromDBAsync=function(t,e,n){if(this._isSupported&&this._db!==null){var i,o=this._db.transaction(["textures"]);o.onabort=function(){e.src=t},o.oncomplete=function(){var s;i&&typeof URL=="function"?(s=URL.createObjectURL(i.data),e.onerror=function(){O.V.Error("Error loading image from blob URL: "+s+" switching back to web url: "+t),e.src=t},e.src=s):n()};var a=o.objectStore("textures").get(t);a.onsuccess=function(s){i=s.target.result},a.onerror=function(){O.V.Error("Error loading texture "+t+" from DB."),e.src=t}}else O.V.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),e.src=t},r.prototype._saveImageIntoDBAsync=function(t,e){var n,i=this;if(this._isSupported){var o=function(){var s;if(n&&typeof URL=="function")try{s=URL.createObjectURL(n)}catch{s=URL.createObjectURL(n)}s&&(e.src=s)};if(r._IsUASupportingBlobStorage){var a=new We.u;a.open("GET",t),a.responseType="blob",a.addEventListener("load",function(){if(a.status===200&&i._db){n=a.response;var s=i._db.transaction(["textures"],"readwrite");s.onabort=function(u){try{var d=u.target.error;d&&d.name==="QuotaExceededError"&&(i._hasReachedQuota=!0)}catch{}o()},s.oncomplete=function(){o()};var l={textureUrl:t,data:n};try{var c=s.objectStore("textures").put(l);c.onsuccess=function(){},c.onerror=function(){o()}}catch(u){u.code===25&&(r._IsUASupportingBlobStorage=!1,i._enableTexturesOffline=!1),e.src=t}}else e.src=t},!1),a.addEventListener("error",function(){O.V.Error("Error in XHR request in BABYLON.Database."),e.src=t},!1),a.send()}else e.src=t}else O.V.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),e.src=t},r.prototype._checkVersionFromDB=function(t,e){var n=this;this._loadVersionFromDBAsync(t,e,function(){n._saveVersionIntoDBAsync(t,e)})},r.prototype._loadVersionFromDBAsync=function(t,e,n){var i,o=this;if(this._isSupported&&this._db)try{var a=this._db.transaction(["versions"]);a.oncomplete=function(){i?o._manifestVersionFound!==i.data?(o._mustUpdateRessources=!0,n()):e(i.data):(o._mustUpdateRessources=!0,n())},a.onabort=function(){e(-1)};var s=a.objectStore("versions").get(t);s.onsuccess=function(l){i=l.target.result},s.onerror=function(){O.V.Error("Error loading version for scene "+t+" from DB."),e(-1)}}catch(l){O.V.Error("Error while accessing 'versions' object store (READ OP). Exception: "+l.message),e(-1)}else O.V.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),e(-1)},r.prototype._saveVersionIntoDBAsync=function(t,e){var n=this;if(this._isSupported&&!this._hasReachedQuota&&this._db)try{var i=this._db.transaction(["versions"],"readwrite");i.onabort=function(s){try{var l=s.target.error;l&&l.name==="QuotaExceededError"&&(n._hasReachedQuota=!0)}catch{}e(-1)},i.oncomplete=function(){e(n._manifestVersionFound)};var o={sceneUrl:t,data:this._manifestVersionFound},a=i.objectStore("versions").put(o);a.onsuccess=function(){},a.onerror=function(){O.V.Error("Error in DB add version request in BABYLON.Database.")}}catch(s){O.V.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+s.message),e(-1)}else e(-1)},r.prototype.loadFile=function(t,e,n,i,o){var a=this,s=r._ReturnFullUrlLocation(t),l=function(){a._saveFileAsync(s,e,n,o,i)};this._checkVersionFromDB(s,function(c){c!==-1?a._mustUpdateRessources?a._saveFileAsync(s,e,n,o,i):a._loadFileAsync(s,e,l,n):i&&i()})},r.prototype._loadFileAsync=function(t,e,n,i){if(this._isSupported&&this._db){var o,a;a=t.indexOf(".babylon")!==-1?"scenes":"textures";var s=this._db.transaction([a]);s.oncomplete=function(){var c;if(o){if(i){var u=((c=o.data)===null||c===void 0?void 0:c.byteLength)||0;i({total:u,loaded:u,lengthComputable:!0})}e(o.data)}else n()},s.onabort=function(){n()};var l=s.objectStore(a).get(t);l.onsuccess=function(c){o=c.target.result},l.onerror=function(){O.V.Error("Error loading file "+t+" from DB."),n()}}else O.V.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),e()},r.prototype._saveFileAsync=function(t,e,n,i,o){var a=this;if(this._isSupported){var s;s=t.indexOf(".babylon")!==-1?"scenes":"textures";var l,c=new We.u;c.open("GET",t+(t.match(/\?/)==null?"?":"&")+Date.now()),i&&(c.responseType="arraybuffer"),n&&(c.onprogress=n),c.addEventListener("load",function(){if(c.status===200||c.status<400&&r._ValidateXHRData(c,i?6:1))if(l=i?c.response:c.responseText,!a._hasReachedQuota&&a._db){var u=a._db.transaction([s],"readwrite");u.onabort=function(p){try{var m=p.target.error;m&&m.name==="QuotaExceededError"&&(a._hasReachedQuota=!0)}catch{}e(l)},u.oncomplete=function(){e(l)};var d;d=s==="scenes"?{sceneUrl:t,data:l,version:a._manifestVersionFound}:{textureUrl:t,data:l};try{var h=u.objectStore(s).put(d);h.onsuccess=function(){},h.onerror=function(){O.V.Error("Error in DB add file request in BABYLON.Database.")}}catch{e(l)}}else e(l);else c.status>=400&&o?o(c):e()},!1),c.addEventListener("error",function(){O.V.Error("error on XHR request."),o&&o()},!1),c.send()}else O.V.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),o&&o()},r._ValidateXHRData=function(t,e){e===void 0&&(e=7);try{if(1&e){if(t.responseText&&t.responseText.length>0)return!0;if(e===1)return!1}if(2&e){var n=(0,fa.O_)(t.response);if(n.width&&n.height&&n.width>0&&n.height>0)return!0;if(e===2)return!1}if(4&e){var i=new Uint8Array(t.response,0,3);return i[0]===68&&i[1]===68&&i[2]===83}}catch{}return!1},r._IsUASupportingBlobStorage=!0,r.IDBStorageEnabled=!1,r._ParseURL=function(t){document.createElement("a").href=t;var e=t.substring(0,t.lastIndexOf("#")),n=t.substring(e.lastIndexOf("/")+1,t.length);return t.substring(0,t.indexOf(n,0))},r._ReturnFullUrlLocation=function(t){return t.indexOf("http:/")===-1&&t.indexOf("https:/")===-1&&typeof window<"u"?r._ParseURL(window.location.href)+t:t},r}(),Go=function(){function r(){this.direction1=new _.Pq(0,1,0),this.direction2=new _.Pq(0,1,0),this.minEmitBox=new _.Pq(-.5,-.5,-.5),this.maxEmitBox=new _.Pq(.5,.5,.5)}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=(0,qe.RandomRange)(this.direction1.x,this.direction2.x),a=(0,qe.RandomRange)(this.direction1.y,this.direction2.y),s=(0,qe.RandomRange)(this.direction1.z,this.direction2.z);if(i)return e.x=o,e.y=a,void(e.z=s);_.Pq.TransformNormalFromFloatsToRef(o,a,s,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=(0,qe.RandomRange)(this.minEmitBox.x,this.maxEmitBox.x),a=(0,qe.RandomRange)(this.minEmitBox.y,this.maxEmitBox.y),s=(0,qe.RandomRange)(this.minEmitBox.z,this.maxEmitBox.z);if(i)return e.x=o,e.y=a,void(e.z=s);_.Pq.TransformCoordinatesFromFloatsToRef(o,a,s,t,e)},r.prototype.clone=function(){var t=new r;return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setVector3("direction1",this.direction1),t.setVector3("direction2",this.direction2),t.setVector3("minEmitBox",this.minEmitBox),t.setVector3("maxEmitBox",this.maxEmitBox)},r.prototype.buildUniformLayout=function(t){t.addUniform("direction1",3),t.addUniform("direction2",3),t.addUniform("minEmitBox",3),t.addUniform("maxEmitBox",3)},r.prototype.getEffectDefines=function(){return"#define BOXEMITTER"},r.prototype.getClassName=function(){return"BoxParticleEmitter"},r.prototype.serialize=function(){var t={};return t.type=this.getClassName(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t},r.prototype.parse=function(t){_.Pq.FromArrayToRef(t.direction1,0,this.direction1),_.Pq.FromArrayToRef(t.direction2,0,this.direction2),_.Pq.FromArrayToRef(t.minEmitBox,0,this.minEmitBox),_.Pq.FromArrayToRef(t.maxEmitBox,0,this.maxEmitBox)},r}(),Ol=function(){function r(t,e,n){t===void 0&&(t=1),e===void 0&&(e=Math.PI),n===void 0&&(n=0),this.directionRandomizer=n,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=e,this.radius=t}return Object.defineProperty(r.prototype,"radius",{get:function(){return this._radius},set:function(t){this._radius=t,this._buildHeight()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._buildHeight()},enumerable:!1,configurable:!0}),r.prototype._buildHeight=function(){this._angle!==0?this._height=this._radius/Math.tan(this._angle/2):this._height=1},r.prototype.startDirectionFunction=function(t,e,n,i){i?_.AA.Vector3[0].copyFrom(n._localPosition).normalize():n.position.subtractToRef(t.getTranslation(),_.AA.Vector3[0]).normalize();var o=(0,qe.RandomRange)(0,this.directionRandomizer),a=(0,qe.RandomRange)(0,this.directionRandomizer),s=(0,qe.RandomRange)(0,this.directionRandomizer);e.x=_.AA.Vector3[0].x+o,e.y=_.AA.Vector3[0].y+a,e.z=_.AA.Vector3[0].z+s,e.normalize()},r.prototype.startPositionFunction=function(t,e,n,i){var o,a=(0,qe.RandomRange)(0,2*Math.PI);o=this.emitFromSpawnPointOnly?1e-4:1-(o=(0,qe.RandomRange)(0,this.heightRange))*o;var s=this._radius-(0,qe.RandomRange)(0,this._radius*this.radiusRange),l=(s*=o)*Math.sin(a),c=s*Math.cos(a),u=o*this._height;if(i)return e.x=l,e.y=u,void(e.z=c);_.Pq.TransformCoordinatesFromFloatsToRef(l,u,c,t,e)},r.prototype.clone=function(){var t=new r(this._radius,this._angle,this.directionRandomizer);return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setFloat2("radius",this._radius,this.radiusRange),t.setFloat("coneAngle",this._angle),t.setFloat2("height",this._height,this.heightRange),t.setFloat("directionRandomizer",this.directionRandomizer)},r.prototype.buildUniformLayout=function(t){t.addUniform("radius",2),t.addUniform("coneAngle",1),t.addUniform("height",2),t.addUniform("directionRandomizer",1)},r.prototype.getEffectDefines=function(){var t="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(t+=`
|
||
#define CONEEMITTERSPAWNPOINT`),t},r.prototype.getClassName=function(){return"ConeParticleEmitter"},r.prototype.serialize=function(){var t={};return t.type=this.getClassName(),t.radius=this._radius,t.angle=this._angle,t.directionRandomizer=this.directionRandomizer,t.radiusRange=this.radiusRange,t.heightRange=this.heightRange,t.emitFromSpawnPointOnly=this.emitFromSpawnPointOnly,t},r.prototype.parse=function(t){this.radius=t.radius,this.angle=t.angle,this.directionRandomizer=t.directionRandomizer,this.radiusRange=t.radiusRange!==void 0?t.radiusRange:1,this.heightRange=t.radiusRange!==void 0?t.heightRange:1,this.emitFromSpawnPointOnly=t.emitFromSpawnPointOnly!==void 0&&t.emitFromSpawnPointOnly},r}(),lf=function(r){function t(e,n,i,o){e===void 0&&(e=1),n===void 0&&(n=Math.PI),i===void 0&&(i=new _.Pq(0,1,0)),o===void 0&&(o=new _.Pq(0,1,0));var a=r.call(this,e,n)||this;return a.direction1=i,a.direction2=o,a}return(0,A.C6)(t,r),t.prototype.startDirectionFunction=function(e,n){var i=(0,qe.RandomRange)(this.direction1.x,this.direction2.x),o=(0,qe.RandomRange)(this.direction1.y,this.direction2.y),a=(0,qe.RandomRange)(this.direction1.z,this.direction2.z);_.Pq.TransformNormalFromFloatsToRef(i,o,a,e,n)},t.prototype.clone=function(){var e=new t(this.radius,this.angle,this.direction1,this.direction2);return ot.r.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("radiusRange",1),e.addUniform("direction1",3),e.addUniform("direction2",3)},t.prototype.getEffectDefines=function(){return`#define CONEEMITTER
|
||
#define DIRECTEDCONEEMITTER`},t.prototype.getClassName=function(){return"ConeDirectedParticleEmitter"},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},t.prototype.parse=function(e){r.prototype.parse.call(this,e),this.direction1.copyFrom(e.direction1),this.direction2.copyFrom(e.direction2)},t}(Ol),Dl=function(){function r(t,e,n,i){t===void 0&&(t=1),e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=0),this.radius=t,this.height=e,this.radiusRange=n,this.directionRandomizer=i,this._tempVector=_.Pq.Zero()}return r.prototype.startDirectionFunction=function(t,e,n,i,o){n.position.subtractToRef(t.getTranslation(),this._tempVector),this._tempVector.normalize(),_.Pq.TransformNormalToRef(this._tempVector,o,this._tempVector);var a=(0,qe.RandomRange)(-this.directionRandomizer/2,this.directionRandomizer/2),s=Math.atan2(this._tempVector.x,this._tempVector.z);s+=(0,qe.RandomRange)(-Math.PI/2,Math.PI/2)*this.directionRandomizer,this._tempVector.y=a,this._tempVector.x=Math.sin(s),this._tempVector.z=Math.cos(s),this._tempVector.normalize(),i?e.copyFrom(this._tempVector):_.Pq.TransformNormalFromFloatsToRef(this._tempVector.x,this._tempVector.y,this._tempVector.z,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=(0,qe.RandomRange)(-this.height/2,this.height/2),a=(0,qe.RandomRange)(0,2*Math.PI),s=(0,qe.RandomRange)((1-this.radiusRange)*(1-this.radiusRange),1),l=Math.sqrt(s)*this.radius,c=l*Math.cos(a),u=l*Math.sin(a);i?e.copyFromFloats(c,o,u):_.Pq.TransformCoordinatesFromFloatsToRef(c,o,u,t,e)},r.prototype.clone=function(){var t=new r(this.radius,this.directionRandomizer);return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setFloat("radius",this.radius),t.setFloat("height",this.height),t.setFloat("radiusRange",this.radiusRange),t.setFloat("directionRandomizer",this.directionRandomizer)},r.prototype.buildUniformLayout=function(t){t.addUniform("radius",1),t.addUniform("height",1),t.addUniform("radiusRange",1),t.addUniform("directionRandomizer",1)},r.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},r.prototype.getClassName=function(){return"CylinderParticleEmitter"},r.prototype.serialize=function(){var t={};return t.type=this.getClassName(),t.radius=this.radius,t.height=this.height,t.radiusRange=this.radiusRange,t.directionRandomizer=this.directionRandomizer,t},r.prototype.parse=function(t){this.radius=t.radius,this.height=t.height,this.radiusRange=t.radiusRange,this.directionRandomizer=t.directionRandomizer},r}(),cf=function(r){function t(e,n,i,o,a){e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=1),o===void 0&&(o=new _.Pq(0,1,0)),a===void 0&&(a=new _.Pq(0,1,0));var s=r.call(this,e,n,i)||this;return s.direction1=o,s.direction2=a,s}return(0,A.C6)(t,r),t.prototype.startDirectionFunction=function(e,n,i,o){var a=(0,qe.RandomRange)(this.direction1.x,this.direction2.x),s=(0,qe.RandomRange)(this.direction1.y,this.direction2.y),l=(0,qe.RandomRange)(this.direction1.z,this.direction2.z);o?n.copyFromFloats(a,s,l):_.Pq.TransformNormalFromFloatsToRef(a,s,l,e,n)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return ot.r.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("height",1),e.addUniform("radiusRange",1),e.addUniform("direction1",3),e.addUniform("direction2",3)},t.prototype.getEffectDefines=function(){return`#define CYLINDEREMITTER
|
||
#define DIRECTEDCYLINDEREMITTER`},t.prototype.getClassName=function(){return"CylinderDirectedParticleEmitter"},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},t.prototype.parse=function(e){r.prototype.parse.call(this,e),_.Pq.FromArrayToRef(e.direction1,0,this.direction1),_.Pq.FromArrayToRef(e.direction2,0,this.direction2)},t}(Dl),uf=function(){function r(t,e,n){t===void 0&&(t=1),e===void 0&&(e=1),n===void 0&&(n=0),this.radius=t,this.radiusRange=e,this.directionRandomizer=n}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=n.position.subtract(t.getTranslation()).normalize(),a=(0,qe.RandomRange)(0,this.directionRandomizer),s=(0,qe.RandomRange)(0,this.directionRandomizer),l=(0,qe.RandomRange)(0,this.directionRandomizer);o.x+=a,o.y+=s,o.z+=l,o.normalize(),i?e.copyFrom(o):_.Pq.TransformNormalFromFloatsToRef(o.x,o.y,o.z,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=this.radius-(0,qe.RandomRange)(0,this.radius*this.radiusRange),a=(0,qe.RandomRange)(0,1),s=(0,qe.RandomRange)(0,2*Math.PI),l=Math.acos(2*a-1),c=o*Math.cos(s)*Math.sin(l),u=o*Math.cos(l),d=o*Math.sin(s)*Math.sin(l);i?e.copyFromFloats(c,Math.abs(u),d):_.Pq.TransformCoordinatesFromFloatsToRef(c,Math.abs(u),d,t,e)},r.prototype.clone=function(){var t=new r(this.radius,this.directionRandomizer);return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setFloat("radius",this.radius),t.setFloat("radiusRange",this.radiusRange),t.setFloat("directionRandomizer",this.directionRandomizer)},r.prototype.buildUniformLayout=function(t){t.addUniform("radius",1),t.addUniform("radiusRange",1),t.addUniform("directionRandomizer",1)},r.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},r.prototype.getClassName=function(){return"HemisphericParticleEmitter"},r.prototype.serialize=function(){var t={};return t.type=this.getClassName(),t.radius=this.radius,t.radiusRange=this.radiusRange,t.directionRandomizer=this.directionRandomizer,t},r.prototype.parse=function(t){this.radius=t.radius,this.radiusRange=t.radiusRange,this.directionRandomizer=t.directionRandomizer},r}(),df=function(){function r(){this.direction1=new _.Pq(0,1,0),this.direction2=new _.Pq(0,1,0)}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=(0,qe.RandomRange)(this.direction1.x,this.direction2.x),a=(0,qe.RandomRange)(this.direction1.y,this.direction2.y),s=(0,qe.RandomRange)(this.direction1.z,this.direction2.z);i?e.copyFromFloats(o,a,s):_.Pq.TransformNormalFromFloatsToRef(o,a,s,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){i?e.copyFromFloats(0,0,0):_.Pq.TransformCoordinatesFromFloatsToRef(0,0,0,t,e)},r.prototype.clone=function(){var t=new r;return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setVector3("direction1",this.direction1),t.setVector3("direction2",this.direction2)},r.prototype.buildUniformLayout=function(t){t.addUniform("direction1",3),t.addUniform("direction2",3)},r.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},r.prototype.getClassName=function(){return"PointParticleEmitter"},r.prototype.serialize=function(){var t={};return t.type=this.getClassName(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},r.prototype.parse=function(t){_.Pq.FromArrayToRef(t.direction1,0,this.direction1),_.Pq.FromArrayToRef(t.direction2,0,this.direction2)},r}(),Nl=function(){function r(t,e,n){t===void 0&&(t=1),e===void 0&&(e=1),n===void 0&&(n=0),this.radius=t,this.radiusRange=e,this.directionRandomizer=n}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=n.position.subtract(t.getTranslation()).normalize(),a=(0,qe.RandomRange)(0,this.directionRandomizer),s=(0,qe.RandomRange)(0,this.directionRandomizer),l=(0,qe.RandomRange)(0,this.directionRandomizer);o.x+=a,o.y+=s,o.z+=l,o.normalize(),i?e.copyFrom(o):_.Pq.TransformNormalFromFloatsToRef(o.x,o.y,o.z,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=this.radius-(0,qe.RandomRange)(0,this.radius*this.radiusRange),a=(0,qe.RandomRange)(0,1),s=(0,qe.RandomRange)(0,2*Math.PI),l=Math.acos(2*a-1),c=o*Math.cos(s)*Math.sin(l),u=o*Math.cos(l),d=o*Math.sin(s)*Math.sin(l);i?e.copyFromFloats(c,u,d):_.Pq.TransformCoordinatesFromFloatsToRef(c,u,d,t,e)},r.prototype.clone=function(){var t=new r(this.radius,this.directionRandomizer);return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setFloat("radius",this.radius),t.setFloat("radiusRange",this.radiusRange),t.setFloat("directionRandomizer",this.directionRandomizer)},r.prototype.buildUniformLayout=function(t){t.addUniform("radius",1),t.addUniform("radiusRange",1),t.addUniform("directionRandomizer",1)},r.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},r.prototype.getClassName=function(){return"SphereParticleEmitter"},r.prototype.serialize=function(){var t={};return t.type=this.getClassName(),t.radius=this.radius,t.radiusRange=this.radiusRange,t.directionRandomizer=this.directionRandomizer,t},r.prototype.parse=function(t){this.radius=t.radius,this.radiusRange=t.radiusRange,this.directionRandomizer=t.directionRandomizer},r}(),hf=function(r){function t(e,n,i){e===void 0&&(e=1),n===void 0&&(n=new _.Pq(0,1,0)),i===void 0&&(i=new _.Pq(0,1,0));var o=r.call(this,e)||this;return o.direction1=n,o.direction2=i,o}return(0,A.C6)(t,r),t.prototype.startDirectionFunction=function(e,n){var i=(0,qe.RandomRange)(this.direction1.x,this.direction2.x),o=(0,qe.RandomRange)(this.direction1.y,this.direction2.y),a=(0,qe.RandomRange)(this.direction1.z,this.direction2.z);_.Pq.TransformNormalFromFloatsToRef(i,o,a,e,n)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return ot.r.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.buildUniformLayout=function(e){e.addUniform("radius",1),e.addUniform("radiusRange",1),e.addUniform("direction1",3),e.addUniform("direction2",3)},t.prototype.getEffectDefines=function(){return`#define SPHEREEMITTER
|
||
#define DIRECTEDSPHEREEMITTER`},t.prototype.getClassName=function(){return"SphereDirectedParticleEmitter"},t.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},t.prototype.parse=function(e){r.prototype.parse.call(this,e),this.direction1.copyFrom(e.direction1),this.direction2.copyFrom(e.direction2)},t}(Nl),ko=function(){function r(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return r.prototype.startDirectionFunction=function(t,e,n,i){var o=_.AA.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,n,o);var a=_.AA.Vector3[1];o.subtractToRef(n.position,a),a.scaleToRef(1/n.lifeTime,o)}else o.set(0,0,0);i?e.copyFrom(o):_.Pq.TransformNormalToRef(o,t,e)},r.prototype.startPositionFunction=function(t,e,n,i){var o=_.AA.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,n,o):o.set(0,0,0),i?e.copyFrom(o):_.Pq.TransformCoordinatesToRef(o,t,e)},r.prototype.clone=function(){var t=new r;return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){},r.prototype.buildUniformLayout=function(t){},r.prototype.getEffectDefines=function(){return"#define CUSTOMEMITTER"},r.prototype.getClassName=function(){return"CustomParticleEmitter"},r.prototype.serialize=function(){var t={};return t.type=this.getClassName(),t.particlePositionGenerator=this.particlePositionGenerator,t.particleDestinationGenerator=this.particleDestinationGenerator,t},r.prototype.parse=function(t){t.particlePositionGenerator&&(this.particlePositionGenerator=t.particlePositionGenerator),t.particleDestinationGenerator&&(this.particleDestinationGenerator=t.particleDestinationGenerator)},r}(),zb=function(){function r(t){t===void 0&&(t=null),this._indices=null,this._positions=null,this._normals=null,this._storedNormal=_.Pq.Zero(),this._mesh=null,this.direction1=new _.Pq(0,1,0),this.direction2=new _.Pq(0,1,0),this.useMeshNormalsForDirection=!0,this.mesh=t}return Object.defineProperty(r.prototype,"mesh",{get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh=t,t?(this._indices=t.getIndices(),this._positions=t.getVerticesData(Y.R.PositionKind),this._normals=t.getVerticesData(Y.R.NormalKind)):(this._indices=null,this._positions=null,this._normals=null))},enumerable:!1,configurable:!0}),r.prototype.startDirectionFunction=function(t,e,n,i){if(this.useMeshNormalsForDirection&&this._normals)_.Pq.TransformNormalToRef(this._storedNormal,t,e);else{var o=(0,qe.RandomRange)(this.direction1.x,this.direction2.x),a=(0,qe.RandomRange)(this.direction1.y,this.direction2.y),s=(0,qe.RandomRange)(this.direction1.z,this.direction2.z);i?e.copyFromFloats(o,a,s):_.Pq.TransformNormalFromFloatsToRef(o,a,s,t,e)}},r.prototype.startPositionFunction=function(t,e,n,i){if(this._indices&&this._positions){var o=3*Math.random()*(this._indices.length/3)|0,a=Math.random(),s=Math.random()*(1-a),l=1-a-s,c=this._indices[o],u=this._indices[o+1],d=this._indices[o+2],h=_.AA.Vector3[0],p=_.AA.Vector3[1],m=_.AA.Vector3[2],v=_.AA.Vector3[3];_.Pq.FromArrayToRef(this._positions,3*c,h),_.Pq.FromArrayToRef(this._positions,3*u,p),_.Pq.FromArrayToRef(this._positions,3*d,m),v.x=a*h.x+s*p.x+l*m.x,v.y=a*h.y+s*p.y+l*m.y,v.z=a*h.z+s*p.z+l*m.z,i?e.copyFromFloats(v.x,v.y,v.z):_.Pq.TransformCoordinatesFromFloatsToRef(v.x,v.y,v.z,t,e),this.useMeshNormalsForDirection&&this._normals&&(_.Pq.FromArrayToRef(this._normals,3*c,h),_.Pq.FromArrayToRef(this._normals,3*u,p),_.Pq.FromArrayToRef(this._normals,3*d,m),this._storedNormal.x=a*h.x+s*p.x+l*m.x,this._storedNormal.y=a*h.y+s*p.y+l*m.y,this._storedNormal.z=a*h.z+s*p.z+l*m.z)}},r.prototype.clone=function(){var t=new r(this.mesh);return ot.r.DeepCopy(this,t),t},r.prototype.applyToShader=function(t){t.setVector3("direction1",this.direction1),t.setVector3("direction2",this.direction2)},r.prototype.buildUniformLayout=function(t){t.addUniform("direction1",3),t.addUniform("direction2",3)},r.prototype.getEffectDefines=function(){return""},r.prototype.getClassName=function(){return"MeshParticleEmitter"},r.prototype.serialize=function(){var t,e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.meshId=(t=this.mesh)===null||t===void 0?void 0:t.id,e.useMeshNormalsForDirection=this.useMeshNormalsForDirection,e},r.prototype.parse=function(t,e){_.Pq.FromArrayToRef(t.direction1,0,this.direction1),_.Pq.FromArrayToRef(t.direction2,0,this.direction2),t.meshId&&e&&(this.mesh=e.getLastMeshById(t.meshId)),this.useMeshNormalsForDirection=t.useMeshNormalsForDirection},r}(),HC=function(){function r(t){this._isUbo(t)?(this.setMatrix3x3=t.updateMatrix3x3.bind(t),this.setMatrix2x2=t.updateMatrix2x2.bind(t),this.setFloat=t.updateFloat.bind(t),this.setFloat2=t.updateFloat2.bind(t),this.setFloat3=t.updateFloat3.bind(t),this.setFloat4=t.updateFloat4.bind(t),this.setFloatArray=t.updateFloatArray.bind(t),this.setArray=t.updateArray.bind(t),this.setIntArray=t.updateIntArray.bind(t),this.setMatrix=t.updateMatrix.bind(t),this.setMatrices=t.updateMatrices.bind(t),this.setVector3=t.updateVector3.bind(t),this.setVector4=t.updateVector4.bind(t),this.setColor3=t.updateColor3.bind(t),this.setColor4=t.updateColor4.bind(t),this.setDirectColor4=t.updateDirectColor4.bind(t),this.setInt=t.updateInt.bind(t),this.setInt2=t.updateInt2.bind(t),this.setInt3=t.updateInt3.bind(t),this.setInt4=t.updateInt4.bind(t)):(this.setMatrix3x3=t.setMatrix3x3.bind(t),this.setMatrix2x2=t.setMatrix2x2.bind(t),this.setFloat=t.setFloat.bind(t),this.setFloat2=t.setFloat2.bind(t),this.setFloat3=t.setFloat3.bind(t),this.setFloat4=t.setFloat4.bind(t),this.setFloatArray=t.setFloatArray.bind(t),this.setArray=t.setArray.bind(t),this.setIntArray=t.setIntArray.bind(t),this.setMatrix=t.setMatrix.bind(t),this.setMatrices=t.setMatrices.bind(t),this.setVector3=t.setVector3.bind(t),this.setVector4=t.setVector4.bind(t),this.setColor3=t.setColor3.bind(t),this.setColor4=t.setColor4.bind(t),this.setDirectColor4=t.setDirectColor4.bind(t),this.setInt=t.setInt.bind(t),this.setInt2=t.setInt2.bind(t),this.setInt3=t.setInt3.bind(t),this.setInt4=t.setInt4.bind(t))}return r.prototype._isUbo=function(t){return t.addUniform!==void 0},r}();Gt.l.ShadersStore.gpuUpdateParticlesPixelShader=`#version 300 es
|
||
void main() {discard;}
|
||
`,Gt.l.ShadersStore.gpuUpdateParticlesVertexShader=`#version 300 es
|
||
#define PI 3.14159
|
||
uniform float currentCount;uniform float timeDelta;uniform float stopFactor;
|
||
#ifndef LOCAL
|
||
uniform mat4 emitterWM;
|
||
#endif
|
||
uniform vec2 lifeTime;uniform vec2 emitPower;uniform vec2 sizeRange;uniform vec4 scaleRange;
|
||
#ifndef COLORGRADIENTS
|
||
uniform vec4 color1;uniform vec4 color2;
|
||
#endif
|
||
uniform vec3 gravity;uniform sampler2D randomSampler;uniform sampler2D randomSampler2;uniform vec4 angleRange;
|
||
#ifdef BOXEMITTER
|
||
uniform vec3 direction1;uniform vec3 direction2;uniform vec3 minEmitBox;uniform vec3 maxEmitBox;
|
||
#endif
|
||
#ifdef POINTEMITTER
|
||
uniform vec3 direction1;uniform vec3 direction2;
|
||
#endif
|
||
#ifdef HEMISPHERICEMITTER
|
||
uniform float radius;uniform float radiusRange;uniform float directionRandomizer;
|
||
#endif
|
||
#ifdef SPHEREEMITTER
|
||
uniform float radius;uniform float radiusRange;
|
||
#ifdef DIRECTEDSPHEREEMITTER
|
||
uniform vec3 direction1;uniform vec3 direction2;
|
||
#else
|
||
uniform float directionRandomizer;
|
||
#endif
|
||
#endif
|
||
#ifdef CYLINDEREMITTER
|
||
uniform float radius;uniform float height;uniform float radiusRange;
|
||
#ifdef DIRECTEDCYLINDEREMITTER
|
||
uniform vec3 direction1;uniform vec3 direction2;
|
||
#else
|
||
uniform float directionRandomizer;
|
||
#endif
|
||
#endif
|
||
#ifdef CONEEMITTER
|
||
uniform vec2 radius;uniform float coneAngle;uniform vec2 height;
|
||
#ifdef DIRECTEDCONEEMITTER
|
||
uniform vec3 direction1;uniform vec3 direction2;
|
||
#else
|
||
uniform float directionRandomizer;
|
||
#endif
|
||
#endif
|
||
in vec3 position;
|
||
#ifdef CUSTOMEMITTER
|
||
in vec3 initialPosition;
|
||
#endif
|
||
in float age;in float life;in vec4 seed;in vec3 size;
|
||
#ifndef COLORGRADIENTS
|
||
in vec4 color;
|
||
#endif
|
||
in vec3 direction;
|
||
#ifndef BILLBOARD
|
||
in vec3 initialDirection;
|
||
#endif
|
||
#ifdef ANGULARSPEEDGRADIENTS
|
||
in float angle;
|
||
#else
|
||
in vec2 angle;
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
in float cellIndex;
|
||
#ifdef ANIMATESHEETRANDOMSTART
|
||
in float cellStartOffset;
|
||
#endif
|
||
#endif
|
||
#ifdef NOISE
|
||
in vec3 noiseCoordinates1;in vec3 noiseCoordinates2;
|
||
#endif
|
||
out vec3 outPosition;
|
||
#ifdef CUSTOMEMITTER
|
||
out vec3 outInitialPosition;
|
||
#endif
|
||
out float outAge;out float outLife;out vec4 outSeed;out vec3 outSize;
|
||
#ifndef COLORGRADIENTS
|
||
out vec4 outColor;
|
||
#endif
|
||
out vec3 outDirection;
|
||
#ifndef BILLBOARD
|
||
out vec3 outInitialDirection;
|
||
#endif
|
||
#ifdef ANGULARSPEEDGRADIENTS
|
||
out float outAngle;
|
||
#else
|
||
out vec2 outAngle;
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
out float outCellIndex;
|
||
#ifdef ANIMATESHEETRANDOMSTART
|
||
out float outCellStartOffset;
|
||
#endif
|
||
#endif
|
||
#ifdef NOISE
|
||
out vec3 outNoiseCoordinates1;out vec3 outNoiseCoordinates2;
|
||
#endif
|
||
#ifdef SIZEGRADIENTS
|
||
uniform sampler2D sizeGradientSampler;
|
||
#endif
|
||
#ifdef ANGULARSPEEDGRADIENTS
|
||
uniform sampler2D angularSpeedGradientSampler;
|
||
#endif
|
||
#ifdef VELOCITYGRADIENTS
|
||
uniform sampler2D velocityGradientSampler;
|
||
#endif
|
||
#ifdef LIMITVELOCITYGRADIENTS
|
||
uniform sampler2D limitVelocityGradientSampler;uniform float limitVelocityDamping;
|
||
#endif
|
||
#ifdef DRAGGRADIENTS
|
||
uniform sampler2D dragGradientSampler;
|
||
#endif
|
||
#ifdef NOISE
|
||
uniform vec3 noiseStrength;uniform sampler2D noiseSampler;
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
uniform vec4 cellInfos;
|
||
#endif
|
||
vec3 getRandomVec3(float offset) {return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;}
|
||
vec4 getRandomVec4(float offset) {return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));}
|
||
void main() {float newAge=age+timeDelta;
|
||
if (newAge>=life && stopFactor != 0.) {vec3 newPosition;vec3 newDirection;vec4 randoms=getRandomVec4(seed.x);outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;outAge=newAge-life;outSeed=seed;
|
||
#ifdef SIZEGRADIENTS
|
||
outSize.x=texture(sizeGradientSampler,vec2(0,0)).r;
|
||
#else
|
||
outSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;
|
||
#endif
|
||
outSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a;
|
||
#ifndef COLORGRADIENTS
|
||
outColor=color1+(color2-color1)*randoms.b;
|
||
#endif
|
||
#ifndef ANGULARSPEEDGRADIENTS
|
||
outAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
|
||
#else
|
||
outAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
|
||
#endif
|
||
#ifdef POINTEMITTER
|
||
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=vec3(0,0,0);newDirection=direction1+(direction2-direction1)*randoms3;
|
||
#elif defined(BOXEMITTER)
|
||
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;newDirection=direction1+(direction2-direction1)*randoms3;
|
||
#elif defined(HEMISPHERICEMITTER)
|
||
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);newDirection=newPosition+directionRandomizer*randoms3;
|
||
#elif defined(SPHEREEMITTER)
|
||
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float phi=2.0*PI*randoms2.x;float theta=acos(2.0*randoms2.y-1.0);float randX=cos(phi)*sin(theta);float randY=cos(theta);float randZ=sin(phi)*sin(theta);newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);
|
||
#ifdef DIRECTEDSPHEREEMITTER
|
||
newDirection=normalize(direction1+(direction2-direction1)*randoms3);
|
||
#else
|
||
newDirection=normalize(newPosition+directionRandomizer*randoms3);
|
||
#endif
|
||
#elif defined(CYLINDEREMITTER)
|
||
vec3 randoms2=getRandomVec3(seed.y);vec3 randoms3=getRandomVec3(seed.z);float yPos=(randoms2.x-0.5)*height;float angle=randoms2.y*PI*2.;float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));float xPos=positionRadius*cos(angle);float zPos=positionRadius*sin(angle);newPosition=vec3(xPos,yPos,zPos);
|
||
#ifdef DIRECTEDCYLINDEREMITTER
|
||
newDirection=direction1+(direction2-direction1)*randoms3;
|
||
#else
|
||
angle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;newDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));newDirection=normalize(newDirection);
|
||
#endif
|
||
#elif defined(CONEEMITTER)
|
||
vec3 randoms2=getRandomVec3(seed.y);float s=2.0*PI*randoms2.x;
|
||
#ifdef CONEEMITTERSPAWNPOINT
|
||
float h=0.0001;
|
||
#else
|
||
float h=randoms2.y*height.y;h=1.-h*h;
|
||
#endif
|
||
float lRadius=radius.x-radius.x*randoms2.z*radius.y;lRadius=lRadius*h;float randX=lRadius*sin(s);float randZ=lRadius*cos(s);float randY=h *height.x;newPosition=vec3(randX,randY,randZ);
|
||
vec3 randoms3=getRandomVec3(seed.z);
|
||
#ifdef DIRECTEDCONEEMITTER
|
||
newDirection=direction1+(direction2-direction1)*randoms3;
|
||
#else
|
||
if (abs(cos(coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {newDirection=normalize(newPosition+directionRandomizer*randoms3); }
|
||
#endif
|
||
#elif defined(CUSTOMEMITTER)
|
||
newPosition=initialPosition;outInitialPosition=initialPosition;
|
||
#else
|
||
newPosition=vec3(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));
|
||
#endif
|
||
float power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;
|
||
#ifdef LOCAL
|
||
outPosition=newPosition;
|
||
#else
|
||
outPosition=(emitterWM*vec4(newPosition,1.)).xyz;
|
||
#endif
|
||
#ifdef CUSTOMEMITTER
|
||
outDirection=direction;
|
||
#ifndef BILLBOARD
|
||
outInitialDirection=direction;
|
||
#endif
|
||
#else
|
||
#ifdef LOCAL
|
||
vec3 initial=newDirection;
|
||
#else
|
||
vec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;
|
||
#endif
|
||
outDirection=initial*power;
|
||
#ifndef BILLBOARD
|
||
outInitialDirection=initial;
|
||
#endif
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
outCellIndex=cellInfos.x;
|
||
#ifdef ANIMATESHEETRANDOMSTART
|
||
outCellStartOffset=randoms.a*outLife;
|
||
#endif
|
||
#endif
|
||
#ifdef NOISE
|
||
outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;
|
||
#endif
|
||
} else {float directionScale=timeDelta;outAge=newAge;float ageGradient=newAge/life;
|
||
#ifdef VELOCITYGRADIENTS
|
||
directionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;
|
||
#endif
|
||
#ifdef DRAGGRADIENTS
|
||
directionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;
|
||
#endif
|
||
#if defined(CUSTOMEMITTER)
|
||
outPosition=position+(direction-position)*ageGradient;
|
||
outInitialPosition=initialPosition;
|
||
#else
|
||
outPosition=position+direction*directionScale;
|
||
#endif
|
||
outLife=life;outSeed=seed;
|
||
#ifndef COLORGRADIENTS
|
||
outColor=color;
|
||
#endif
|
||
#ifdef SIZEGRADIENTS
|
||
outSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;outSize.yz=size.yz;
|
||
#else
|
||
outSize=size;
|
||
#endif
|
||
#ifndef BILLBOARD
|
||
outInitialDirection=initialDirection;
|
||
#endif
|
||
#ifdef CUSTOMEMITTER
|
||
outDirection=direction;
|
||
#else
|
||
vec3 updatedDirection=direction+gravity*timeDelta;
|
||
#ifdef LIMITVELOCITYGRADIENTS
|
||
float limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;float currentVelocity=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*limitVelocityDamping;}
|
||
#endif
|
||
outDirection=updatedDirection;
|
||
#ifdef NOISE
|
||
float fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;outDirection=outDirection+force*timeDelta;outNoiseCoordinates1=noiseCoordinates1;outNoiseCoordinates2=noiseCoordinates2;
|
||
#endif
|
||
#endif
|
||
#ifdef ANGULARSPEEDGRADIENTS
|
||
float angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;outAngle=angle+angularSpeed*timeDelta;
|
||
#else
|
||
outAngle=vec2(angle.x+angle.y*timeDelta,angle.y);
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
float offsetAge=outAge;float dist=cellInfos.y-cellInfos.x;
|
||
#ifdef ANIMATESHEETRANDOMSTART
|
||
outCellStartOffset=cellStartOffset;offsetAge+=cellStartOffset;
|
||
#else
|
||
float cellStartOffset=0.;
|
||
#endif
|
||
float ratio=0.;if (cellInfos.w==1.0) {ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);}
|
||
else {ratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);}
|
||
outCellIndex=float(int(cellInfos.x+ratio*dist));
|
||
#endif
|
||
}}`;var Wb=function(){function r(t,e){this._renderVAO=[],this._updateVAO=[],this.alignDataInBuffer=!1,this._parent=t,this._engine=e,this._updateEffectOptions={attributes:["position","initialPosition","age","life","seed","size","color","direction","initialDirection","angle","cellIndex","cellStartOffset","noiseCoordinates1","noiseCoordinates2"],uniformsNames:["currentCount","timeDelta","emitterWM","lifeTime","color1","color2","sizeRange","scaleRange","gravity","emitPower","direction1","direction2","minEmitBox","maxEmitBox","radius","directionRandomizer","height","coneAngle","stopFactor","angleRange","radiusRange","cellInfos","noiseStrength","limitVelocityDamping"],uniformBuffersNames:[],samplers:["randomSampler","randomSampler2","sizeGradientSampler","angularSpeedGradientSampler","velocityGradientSampler","limitVelocityGradientSampler","noiseSampler","dragGradientSampler"],defines:"",fallbacks:null,onCompiled:null,onError:null,indexParameters:null,maxSimultaneousLights:0,transformFeedbackVaryings:[]}}return r.prototype.contextLost=function(){this._updateEffect=void 0,this._renderVAO.length=0,this._updateVAO.length=0},r.prototype.isUpdateBufferCreated=function(){return!!this._updateEffect},r.prototype.isUpdateBufferReady=function(){var t,e;return(e=(t=this._updateEffect)===null||t===void 0?void 0:t.isReady())!==null&&e!==void 0&&e},r.prototype.createUpdateBuffer=function(t){return this._updateEffectOptions.transformFeedbackVaryings=["outPosition"],this._updateEffectOptions.transformFeedbackVaryings.push("outAge"),this._updateEffectOptions.transformFeedbackVaryings.push("outSize"),this._updateEffectOptions.transformFeedbackVaryings.push("outLife"),this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"),this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),this._parent.particleEmitterType instanceof ko&&this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"),this._parent._colorGradientsTexture||this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),this._parent._isBillboardBased||this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),this._parent.noiseTexture&&(this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),this._parent.isAnimationSheetEnabled&&(this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),this._parent.spriteRandomStartCell&&this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),this._updateEffectOptions.defines=t,this._updateEffect=new ti.M("gpuUpdateParticles",this._updateEffectOptions,this._engine),new HC(this._updateEffect)},r.prototype.createVertexBuffers=function(t,e){this._updateVAO.push(this._createUpdateVAO(t)),this._renderVAO.push(this._engine.recordVertexArrayObject(e,null,this._parent._getWrapper(this._parent.blendMode).effect)),this._engine.bindArrayBuffer(null),this._renderVertexBuffers=e},r.prototype.createParticleBuffer=function(t){return t},r.prototype.bindDrawBuffers=function(t,e,n){n?this._engine.bindBuffers(this._renderVertexBuffers,n,e):this._engine.bindVertexArrayObject(this._renderVAO[t],null)},r.prototype.preUpdateParticleBuffer=function(){var t=this._engine;if(this._engine.enableEffect(this._updateEffect),!t.setState)throw new Error("GPU particles cannot work without a full Engine. ThinEngine is not supported")},r.prototype.updateParticleBuffer=function(t,e,n){this._updateEffect.setTexture("randomSampler",this._parent._randomTexture),this._updateEffect.setTexture("randomSampler2",this._parent._randomTexture2),this._parent._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._parent._sizeGradientsTexture),this._parent._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._parent._angularSpeedGradientsTexture),this._parent._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._parent._velocityGradientsTexture),this._parent._limitVelocityGradientsTexture&&this._updateEffect.setTexture("limitVelocityGradientSampler",this._parent._limitVelocityGradientsTexture),this._parent._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._parent._dragGradientsTexture),this._parent.noiseTexture&&this._updateEffect.setTexture("noiseSampler",this._parent.noiseTexture),this._engine.bindVertexArrayObject(this._updateVAO[t],null);var i=this._engine;i.bindTransformFeedbackBuffer(e.getBuffer()),i.setRasterizerState(!1),i.beginTransformFeedback(!0),i.drawArraysType(P.Y.MATERIAL_PointListDrawMode,0,n),i.endTransformFeedback(),i.setRasterizerState(!0),i.bindTransformFeedbackBuffer(null)},r.prototype.releaseBuffers=function(){},r.prototype.releaseVertexBuffers=function(){for(var t=0;t<this._updateVAO.length;t++)this._engine.releaseVertexArrayObject(this._updateVAO[t]);for(this._updateVAO.length=0,t=0;t<this._renderVAO.length;t++)this._engine.releaseVertexArrayObject(this._renderVAO[t]);this._renderVAO.length=0},r.prototype._createUpdateVAO=function(t){var e={};e.position=t.createVertexBuffer("position",0,3);var n=3;e.age=t.createVertexBuffer("age",n,1),n+=1,e.size=t.createVertexBuffer("size",n,3),n+=3,e.life=t.createVertexBuffer("life",n,1),n+=1,e.seed=t.createVertexBuffer("seed",n,4),n+=4,e.direction=t.createVertexBuffer("direction",n,3),n+=3,this._parent.particleEmitterType instanceof ko&&(e.initialPosition=t.createVertexBuffer("initialPosition",n,3),n+=3),this._parent._colorGradientsTexture||(e.color=t.createVertexBuffer("color",n,4),n+=4),this._parent._isBillboardBased||(e.initialDirection=t.createVertexBuffer("initialDirection",n,3),n+=3),this._parent.noiseTexture&&(e.noiseCoordinates1=t.createVertexBuffer("noiseCoordinates1",n,3),n+=3,e.noiseCoordinates2=t.createVertexBuffer("noiseCoordinates2",n,3),n+=3),this._parent._angularSpeedGradientsTexture?(e.angle=t.createVertexBuffer("angle",n,1),n+=1):(e.angle=t.createVertexBuffer("angle",n,2),n+=2),this._parent._isAnimationSheetEnabled&&(e.cellIndex=t.createVertexBuffer("cellIndex",n,1),n+=1,this._parent.spriteRandomStartCell&&(e.cellStartOffset=t.createVertexBuffer("cellStartOffset",n,1),n+=1));var i=this._engine.recordVertexArrayObject(e,null,this._updateEffect);return this._engine.bindArrayBuffer(null),i},r}();(0,j.Y5)("BABYLON.WebGL2ParticleSystem",Wb),Gt.l.ShadersStoreWGSL.gpuUpdateParticlesComputeShader=`struct Particle {position : vec3<f32>,
|
||
age : f32,
|
||
size : vec3<f32>,
|
||
life : f32,
|
||
seed : vec4<f32>,
|
||
direction : vec3<f32>,
|
||
dummy0: f32,
|
||
#ifdef CUSTOMEMITTER
|
||
initialPosition : vec3<f32>,
|
||
dummy1: f32,
|
||
#endif
|
||
#ifndef COLORGRADIENTS
|
||
color : vec4<f32>,
|
||
#endif
|
||
#ifndef BILLBOARD
|
||
initialDirection : vec3<f32>,
|
||
dummy2: f32,
|
||
#endif
|
||
#ifdef NOISE
|
||
noiseCoordinates1 : vec3<f32>,
|
||
dummy3: f32,
|
||
noiseCoordinates2 : vec3<f32>,
|
||
dummy4: f32,
|
||
#endif
|
||
#ifdef ANGULARSPEEDGRADIENTS
|
||
angle : f32,
|
||
#else
|
||
angle : vec2<f32>,
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
cellIndex : f32,
|
||
#ifdef ANIMATESHEETRANDOMSTART
|
||
cellStartOffset : f32,
|
||
#endif
|
||
#endif
|
||
};struct Particles {particles : array<Particle>,};struct SimParams {currentCount : f32,
|
||
timeDelta : f32,
|
||
stopFactor : f32,
|
||
randomTextureSize: i32,
|
||
lifeTime : vec2<f32>,
|
||
emitPower : vec2<f32>,
|
||
#ifndef COLORGRADIENTS
|
||
color1 : vec4<f32>,
|
||
color2 : vec4<f32>,
|
||
#endif
|
||
sizeRange : vec2<f32>,
|
||
scaleRange : vec4<f32>,
|
||
angleRange : vec4<f32>,
|
||
gravity : vec3<f32>,
|
||
#ifdef LIMITVELOCITYGRADIENTS
|
||
limitVelocityDamping : f32,
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
cellInfos : vec4<f32>,
|
||
#endif
|
||
#ifdef NOISE
|
||
noiseStrength : vec3<f32>,
|
||
#endif
|
||
#ifndef LOCAL
|
||
emitterWM : mat4x4<f32>,
|
||
#endif
|
||
#ifdef BOXEMITTER
|
||
direction1 : vec3<f32>,
|
||
direction2 : vec3<f32>,
|
||
minEmitBox : vec3<f32>,
|
||
maxEmitBox : vec3<f32>,
|
||
#endif
|
||
#ifdef CONEEMITTER
|
||
radius : vec2<f32>,
|
||
coneAngle : f32,
|
||
height : vec2<f32>,
|
||
#ifdef DIRECTEDCONEEMITTER
|
||
direction1 : vec3<f32>,
|
||
direction2 : vec3<f32>,
|
||
#else
|
||
directionRandomizer : f32,
|
||
#endif
|
||
#endif
|
||
#ifdef CYLINDEREMITTER
|
||
radius : f32,
|
||
height : f32,
|
||
radiusRange : f32,
|
||
#ifdef DIRECTEDCYLINDEREMITTER
|
||
direction1 : vec3<f32>,
|
||
direction2 : vec3<f32>,
|
||
#else
|
||
directionRandomizer : f32,
|
||
#endif
|
||
#endif
|
||
#ifdef HEMISPHERICEMITTER
|
||
radius : f32,
|
||
radiusRange : f32,
|
||
directionRandomizer : f32,
|
||
#endif
|
||
#ifdef POINTEMITTER
|
||
direction1 : vec3<f32>,
|
||
direction2 : vec3<f32>,
|
||
#endif
|
||
#ifdef SPHEREEMITTER
|
||
radius : f32,
|
||
radiusRange : f32,
|
||
#ifdef DIRECTEDSPHEREEMITTER
|
||
direction1 : vec3<f32>,
|
||
direction2 : vec3<f32>,
|
||
#else
|
||
directionRandomizer : f32,
|
||
#endif
|
||
#endif
|
||
};@binding(0) @group(0) var<uniform> params : SimParams;@binding(1) @group(0) var<storage,read> particlesIn : Particles;@binding(2) @group(0) var<storage,read_write> particlesOut : Particles;@binding(3) @group(0) var randomTexture : texture_2d<f32>;@binding(4) @group(0) var randomTexture2 : texture_2d<f32>;
|
||
#ifdef SIZEGRADIENTS
|
||
@binding(0) @group(1) var sizeGradientSampler : sampler;@binding(1) @group(1) var sizeGradientTexture : texture_2d<f32>;
|
||
#endif
|
||
#ifdef ANGULARSPEEDGRADIENTS
|
||
@binding(2) @group(1) var angularSpeedGradientSampler : sampler;@binding(3) @group(1) var angularSpeedGradientTexture : texture_2d<f32>;
|
||
#endif
|
||
#ifdef VELOCITYGRADIENTS
|
||
@binding(4) @group(1) var velocityGradientSampler : sampler;@binding(5) @group(1) var velocityGradientTexture : texture_2d<f32>;
|
||
#endif
|
||
#ifdef LIMITVELOCITYGRADIENTS
|
||
@binding(6) @group(1) var limitVelocityGradientSampler : sampler;@binding(7) @group(1) var limitVelocityGradientTexture : texture_2d<f32>;
|
||
#endif
|
||
#ifdef DRAGGRADIENTS
|
||
@binding(8) @group(1) var dragGradientSampler : sampler;@binding(9) @group(1) var dragGradientTexture : texture_2d<f32>;
|
||
#endif
|
||
#ifdef NOISE
|
||
@binding(10) @group(1) var noiseSampler : sampler;@binding(11) @group(1) var noiseTexture : texture_2d<f32>;
|
||
#endif
|
||
fn getRandomVec3(offset : f32,vertexID : f32)->vec3<f32> {return textureLoad(randomTexture2,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0).rgb;}
|
||
fn getRandomVec4(offset : f32,vertexID : f32)->vec4<f32> {return textureLoad(randomTexture,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0);}
|
||
@compute @workgroup_size(64)
|
||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {let index : u32=GlobalInvocationID.x;let vertexID : f32=f32(index);if (index>=u32(params.currentCount)) {return;}
|
||
let PI : f32=3.14159;let timeDelta : f32=params.timeDelta;let newAge : f32=particlesIn.particles[index].age+timeDelta;let life : f32=particlesIn.particles[index].life;let seed : vec4<f32>=particlesIn.particles[index].seed;let direction : vec3<f32>=particlesIn.particles[index].direction;if (newAge>=life && params.stopFactor != 0.) {var newPosition : vec3<f32>;var newDirection : vec3<f32>;let randoms : vec4<f32>=getRandomVec4(seed.x,vertexID);let outLife : f32=params.lifeTime.x+(params.lifeTime.y-params.lifeTime.x)*randoms.r;particlesOut.particles[index].life=outLife;particlesOut.particles[index].age=newAge-life;particlesOut.particles[index].seed=seed;var sizex : f32;
|
||
#ifdef SIZEGRADIENTS
|
||
sizex=textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(0.,0.),0.).r;
|
||
#else
|
||
sizex=params.sizeRange.x+(params.sizeRange.y-params.sizeRange.x)*randoms.g;
|
||
#endif
|
||
particlesOut.particles[index].size=vec3<f32>(
|
||
sizex,
|
||
params.scaleRange.x+(params.scaleRange.y-params.scaleRange.x)*randoms.b,
|
||
params.scaleRange.z+(params.scaleRange.w-params.scaleRange.z)*randoms.a);
|
||
#ifndef COLORGRADIENTS
|
||
particlesOut.particles[index].color=params.color1+(params.color2-params.color1)*randoms.b;
|
||
#endif
|
||
#ifndef ANGULARSPEEDGRADIENTS
|
||
particlesOut.particles[index].angle=vec2<f32>(
|
||
params.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r,
|
||
params.angleRange.x+(params.angleRange.y-params.angleRange.x)*randoms.a);
|
||
#else
|
||
particlesOut.particles[index].angle=params.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r;
|
||
#endif
|
||
#if defined(POINTEMITTER)
|
||
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);newPosition=vec3<f32>(0.,0.,0.);newDirection=params.direction1+(params.direction2-params.direction1)*randoms3;
|
||
#elif defined(BOXEMITTER)
|
||
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);newPosition=params.minEmitBox+(params.maxEmitBox-params.minEmitBox)*randoms2;newDirection=params.direction1+(params.direction2-params.direction1)*randoms3;
|
||
#elif defined(HEMISPHERICEMITTER)
|
||
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);let phi : f32=2.0*PI*randoms2.x;let theta : f32=acos(-1.0+2.0*randoms2.y);let randX : f32=cos(phi)*sin(theta);let randY : f32=cos(theta);let randZ : f32=sin(phi)*sin(theta);newPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,abs(randY),randZ);newDirection=normalize(newPosition+params.directionRandomizer*randoms3);
|
||
#elif defined(SPHEREEMITTER)
|
||
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);let phi : f32=2.0*PI*randoms2.x;let theta : f32=acos(-1.0+2.0*randoms2.y);let randX : f32=cos(phi)*sin(theta);let randY : f32=cos(theta);let randZ : f32=sin(phi)*sin(theta);newPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,randY,randZ);
|
||
#ifdef DIRECTEDSPHEREEMITTER
|
||
newDirection=normalize(params.direction1+(params.direction2-params.direction1)*randoms3);
|
||
#else
|
||
newDirection=normalize(newPosition+params.directionRandomizer*randoms3);
|
||
#endif
|
||
#elif defined(CYLINDEREMITTER)
|
||
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);let yPos : f32=(-0.5+randoms2.x)*params.height;var angle : f32=randoms2.y*PI*2.;let inverseRadiusRangeSquared : f32=(1.-params.radiusRange)*(1.-params.radiusRange);let positionRadius : f32=params.radius*sqrt(inverseRadiusRangeSquared+randoms2.z*(1.-inverseRadiusRangeSquared));let xPos : f32=positionRadius*cos(angle);let zPos : f32=positionRadius*sin(angle);newPosition=vec3<f32>(xPos,yPos,zPos);
|
||
#ifdef DIRECTEDCYLINDEREMITTER
|
||
newDirection=params.direction1+(params.direction2-params.direction1)*randoms3;
|
||
#else
|
||
angle=angle+(-0.5+randoms3.x)*PI*params.directionRandomizer;newDirection=vec3<f32>(cos(angle),(-0.5+randoms3.y)*params.directionRandomizer,sin(angle));newDirection=normalize(newDirection);
|
||
#endif
|
||
#elif defined(CONEEMITTER)
|
||
let randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);let s : f32=2.0*PI*randoms2.x;
|
||
#ifdef CONEEMITTERSPAWNPOINT
|
||
let h : f32=0.0001;
|
||
#else
|
||
var h : f32=randoms2.y*params.height.y;h=1.-h*h;
|
||
#endif
|
||
var lRadius : f32=params.radius.x-params.radius.x*randoms2.z*params.radius.y;lRadius=lRadius*h;let randX : f32=lRadius*sin(s);let randZ : f32=lRadius*cos(s);let randY : f32=h *params.height.x;newPosition=vec3<f32>(randX,randY,randZ);
|
||
let randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);
|
||
#ifdef DIRECTEDCONEEMITTER
|
||
newDirection=params.direction1+(params.direction2-params.direction1)*randoms3;
|
||
#else
|
||
if (abs(cos(params.coneAngle))==1.0) {newDirection=vec3<f32>(0.,1.0,0.);} else {newDirection=normalize(newPosition+params.directionRandomizer*randoms3); }
|
||
#endif
|
||
#elif defined(CUSTOMEMITTER)
|
||
newPosition=particlesIn.particles[index].initialPosition;particlesOut.particles[index].initialPosition=newPosition;
|
||
#else
|
||
newPosition=vec3<f32>(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w,vertexID)-vec3<f32>(0.5,0.5,0.5));
|
||
#endif
|
||
let power : f32=params.emitPower.x+(params.emitPower.y-params.emitPower.x)*randoms.a;
|
||
#ifdef LOCAL
|
||
particlesOut.particles[index].position=newPosition;
|
||
#else
|
||
particlesOut.particles[index].position=(params.emitterWM*vec4<f32>(newPosition,1.)).xyz;
|
||
#endif
|
||
#ifdef CUSTOMEMITTER
|
||
particlesOut.particles[index].direction=direction;
|
||
#ifndef BILLBOARD
|
||
particlesOut.particles[index].initialDirection=direction;
|
||
#endif
|
||
#else
|
||
#ifdef LOCAL
|
||
let initial : vec3<f32>=newDirection;
|
||
#else
|
||
let initial : vec3<f32>=(params.emitterWM*vec4<f32>(newDirection,0.)).xyz;
|
||
#endif
|
||
particlesOut.particles[index].direction=initial*power;
|
||
#ifndef BILLBOARD
|
||
particlesOut.particles[index].initialDirection=initial;
|
||
#endif
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
particlesOut.particles[index].cellIndex=params.cellInfos.x;
|
||
#ifdef ANIMATESHEETRANDOMSTART
|
||
particlesOut.particles[index].cellStartOffset=randoms.a*outLife;
|
||
#endif
|
||
#endif
|
||
#ifdef NOISE
|
||
particlesOut.particles[index].noiseCoordinates1=particlesIn.particles[index].noiseCoordinates1;particlesOut.particles[index].noiseCoordinates2=particlesIn.particles[index].noiseCoordinates2;
|
||
#endif
|
||
} else {var directionScale : f32=timeDelta;particlesOut.particles[index].age=newAge;let ageGradient : f32=newAge/life;
|
||
#ifdef VELOCITYGRADIENTS
|
||
directionScale=directionScale*textureSampleLevel(velocityGradientTexture,velocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;
|
||
#endif
|
||
#ifdef DRAGGRADIENTS
|
||
directionScale=directionScale*(1.0-textureSampleLevel(dragGradientTexture,dragGradientSampler,vec2<f32>(ageGradient,0.),0.).r);
|
||
#endif
|
||
let position : vec3<f32>=particlesIn.particles[index].position;
|
||
#if defined(CUSTOMEMITTER)
|
||
particlesOut.particles[index].position=position+(direction-position)*ageGradient;
|
||
particlesOut.particles[index].initialPosition=particlesIn.particles[index].initialPosition;
|
||
#else
|
||
particlesOut.particles[index].position=position+direction*directionScale;
|
||
#endif
|
||
particlesOut.particles[index].life=life;particlesOut.particles[index].seed=seed;
|
||
#ifndef COLORGRADIENTS
|
||
particlesOut.particles[index].color=particlesIn.particles[index].color;
|
||
#endif
|
||
#ifdef SIZEGRADIENTS
|
||
particlesOut.particles[index].size=vec3<f32>(
|
||
textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(ageGradient,0.),0.).r,
|
||
particlesIn.particles[index].size.yz);
|
||
#else
|
||
particlesOut.particles[index].size=particlesIn.particles[index].size;
|
||
#endif
|
||
#ifndef BILLBOARD
|
||
particlesOut.particles[index].initialDirection=particlesIn.particles[index].initialDirection;
|
||
#endif
|
||
#ifdef CUSTOMEMITTER
|
||
particlesOut.particles[index].direction=direction;
|
||
#else
|
||
var updatedDirection : vec3<f32>=direction+params.gravity*timeDelta;
|
||
#ifdef LIMITVELOCITYGRADIENTS
|
||
let limitVelocity : f32=textureSampleLevel(limitVelocityGradientTexture,limitVelocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;let currentVelocity : f32=length(updatedDirection);if (currentVelocity>limitVelocity) {updatedDirection=updatedDirection*params.limitVelocityDamping;}
|
||
#endif
|
||
particlesOut.particles[index].direction=updatedDirection;
|
||
#ifdef NOISE
|
||
let noiseCoordinates1 : vec3<f32>=particlesIn.particles[index].noiseCoordinates1;let noiseCoordinates2 : vec3<f32>=particlesIn.particles[index].noiseCoordinates2;let fetchedR : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.x,noiseCoordinates1.y)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;let fetchedG : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.z,noiseCoordinates2.x)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;let fetchedB : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates2.y,noiseCoordinates2.z)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;let force : vec3<f32>=vec3<f32>(-1.+2.*fetchedR,-1.+2.*fetchedG,-1.+2.*fetchedB)*params.noiseStrength;particlesOut.particles[index].direction=particlesOut.particles[index].direction+force*timeDelta;particlesOut.particles[index].noiseCoordinates1=noiseCoordinates1;particlesOut.particles[index].noiseCoordinates2=noiseCoordinates2;
|
||
#endif
|
||
#endif
|
||
#ifdef ANGULARSPEEDGRADIENTS
|
||
let angularSpeed : f32=textureSampleLevel(angularSpeedGradientTexture,angularSpeedGradientSampler,vec2<f32>(ageGradient,0.),0.).r;particlesOut.particles[index].angle=particlesIn.particles[index].angle+angularSpeed*timeDelta;
|
||
#else
|
||
let angle : vec2<f32>=particlesIn.particles[index].angle;particlesOut.particles[index].angle=vec2<f32>(angle.x+angle.y*timeDelta,angle.y);
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
var offsetAge : f32=particlesOut.particles[index].age;let dist : f32=params.cellInfos.y-params.cellInfos.x;
|
||
#ifdef ANIMATESHEETRANDOMSTART
|
||
let cellStartOffset : f32=particlesIn.particles[index].cellStartOffset;particlesOut.particles[index].cellStartOffset=cellStartOffset;offsetAge=offsetAge+cellStartOffset;
|
||
#else
|
||
let cellStartOffset : f32=0.;
|
||
#endif
|
||
var ratio : f32;if (params.cellInfos.w==1.0) {ratio=clamp(((cellStartOffset+params.cellInfos.z*offsetAge) % life)/life,0.,1.0);}
|
||
else {ratio=clamp((cellStartOffset+params.cellInfos.z*offsetAge)/life,0.,1.0);}
|
||
particlesOut.particles[index].cellIndex=f32(i32(params.cellInfos.x+ratio*dist));
|
||
#endif
|
||
}}
|
||
`;var Hb=function(){function r(t,e){this._bufferComputeShader=[],this._renderVertexBuffers=[],this.alignDataInBuffer=!0,this._parent=t,this._engine=e}return r.prototype.contextLost=function(){this._updateComputeShader=void 0,this._bufferComputeShader.length=0,this._renderVertexBuffers.length=0},r.prototype.isUpdateBufferCreated=function(){return!!this._updateComputeShader},r.prototype.isUpdateBufferReady=function(){var t,e;return(e=(t=this._updateComputeShader)===null||t===void 0?void 0:t.isReady())!==null&&e!==void 0&&e},r.prototype.createUpdateBuffer=function(t){var e,n={params:{group:0,binding:0},particlesIn:{group:0,binding:1},particlesOut:{group:0,binding:2},randomTexture:{group:0,binding:3},randomTexture2:{group:0,binding:4}};return this._parent._sizeGradientsTexture&&(n.sizeGradientTexture={group:1,binding:1}),this._parent._angularSpeedGradientsTexture&&(n.angularSpeedGradientTexture={group:1,binding:3}),this._parent._velocityGradientsTexture&&(n.velocityGradientTexture={group:1,binding:5}),this._parent._limitVelocityGradientsTexture&&(n.limitVelocityGradientTexture={group:1,binding:7}),this._parent._dragGradientsTexture&&(n.dragGradientTexture={group:1,binding:9}),this._parent.noiseTexture&&(n.noiseTexture={group:1,binding:11}),this._updateComputeShader=new eg.H("updateParticles",this._engine,"gpuUpdateParticles",{bindingsMapping:n,defines:t.split(`
|
||
`)}),(e=this._simParamsComputeShader)===null||e===void 0||e.dispose(),this._simParamsComputeShader=new Ui.D(this._engine,void 0,void 0,"ComputeShaderParticleSystemUBO"),this._simParamsComputeShader.addUniform("currentCount",1),this._simParamsComputeShader.addUniform("timeDelta",1),this._simParamsComputeShader.addUniform("stopFactor",1),this._simParamsComputeShader.addUniform("randomTextureSize",1),this._simParamsComputeShader.addUniform("lifeTime",2),this._simParamsComputeShader.addUniform("emitPower",2),this._parent._colorGradientsTexture||(this._simParamsComputeShader.addUniform("color1",4),this._simParamsComputeShader.addUniform("color2",4)),this._simParamsComputeShader.addUniform("sizeRange",2),this._simParamsComputeShader.addUniform("scaleRange",4),this._simParamsComputeShader.addUniform("angleRange",4),this._simParamsComputeShader.addUniform("gravity",3),this._parent._limitVelocityGradientsTexture&&this._simParamsComputeShader.addUniform("limitVelocityDamping",1),this._parent.isAnimationSheetEnabled&&this._simParamsComputeShader.addUniform("cellInfos",4),this._parent.noiseTexture&&this._simParamsComputeShader.addUniform("noiseStrength",3),this._parent.isLocal||this._simParamsComputeShader.addUniform("emitterWM",16),this._parent.particleEmitterType&&this._parent.particleEmitterType.buildUniformLayout(this._simParamsComputeShader),this._updateComputeShader.setUniformBuffer("params",this._simParamsComputeShader),new HC(this._simParamsComputeShader)},r.prototype.createVertexBuffers=function(t,e){this._renderVertexBuffers.push(e)},r.prototype.createParticleBuffer=function(t){var e=new um.K(this._engine,4*t.length,P.Y.BUFFER_CREATIONFLAG_READWRITE|P.Y.BUFFER_CREATIONFLAG_VERTEX,"ComputeShaderParticleSystemBuffer");return e.update(t),this._bufferComputeShader.push(e),e.getBuffer()},r.prototype.bindDrawBuffers=function(t,e,n){this._engine.bindBuffers(this._renderVertexBuffers[t],n,e)},r.prototype.preUpdateParticleBuffer=function(){},r.prototype.updateParticleBuffer=function(t,e,n){this._simParamsComputeShader.update(),this._updateComputeShader.setTexture("randomTexture",this._parent._randomTexture,!1),this._updateComputeShader.setTexture("randomTexture2",this._parent._randomTexture2,!1),this._parent._sizeGradientsTexture&&this._updateComputeShader.setTexture("sizeGradientTexture",this._parent._sizeGradientsTexture),this._parent._angularSpeedGradientsTexture&&this._updateComputeShader.setTexture("angularSpeedGradientTexture",this._parent._angularSpeedGradientsTexture),this._parent._velocityGradientsTexture&&this._updateComputeShader.setTexture("velocityGradientTexture",this._parent._velocityGradientsTexture),this._parent._limitVelocityGradientsTexture&&this._updateComputeShader.setTexture("limitVelocityGradientTexture",this._parent._limitVelocityGradientsTexture),this._parent._dragGradientsTexture&&this._updateComputeShader.setTexture("dragGradientTexture",this._parent._dragGradientsTexture),this._parent.noiseTexture&&this._updateComputeShader.setTexture("noiseTexture",this._parent.noiseTexture),this._updateComputeShader.setStorageBuffer("particlesIn",this._bufferComputeShader[t]),this._updateComputeShader.setStorageBuffer("particlesOut",this._bufferComputeShader[1^t]),this._updateComputeShader.dispatch(Math.ceil(n/64))},r.prototype.releaseBuffers=function(){for(var t,e=0;e<this._bufferComputeShader.length;++e)this._bufferComputeShader[e].dispose();this._bufferComputeShader.length=0,(t=this._simParamsComputeShader)===null||t===void 0||t.dispose(),this._simParamsComputeShader=null,this._updateComputeShader=null},r.prototype.releaseVertexBuffers=function(){this._renderVertexBuffers.length=0},r}();(0,j.Y5)("BABYLON.ComputeShaderParticleSystem",Hb);var ff,pf=function(){function r(t,e,n){this.gradient=t,this.color1=e,this.color2=n}return r.prototype.getColorToRef=function(t){this.color2?z.ov.LerpToRef(this.color1,this.color2,Math.random(),t):t.copyFrom(this.color1)},r}(),Yb=function(r,t){this.gradient=r,this.color=t},_f=function(){function r(t,e,n){this.gradient=t,this.factor1=e,this.factor2=n}return r.prototype.getFactor=function(){return this.factor2===void 0||this.factor2===this.factor1?this.factor1:this.factor1+(this.factor2-this.factor1)*Math.random()},r}(),Wi=function(){function r(){}return r.GetCurrentGradient=function(t,e,n){if(e[0].gradient>t)n(e[0],e[0],1);else{for(var i=0;i<e.length-1;i++){var o=e[i],a=e[i+1];if(t>=o.gradient&&t<=a.gradient)return void n(o,a,(t-o.gradient)/(a.gradient-o.gradient))}var s=e.length-1;n(e[s],e[s],1)}},r}(),Xb=function(){function r(t){this.particleSystem=t,this.position=_.Pq.Zero(),this.direction=_.Pq.Zero(),this.color=new z.ov(0,0,0,0),this.colorStep=new z.ov(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new _.I9(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new z.ov(0,0,0,0),this._currentColor2=new z.ov(0,0,0,0),this._currentSize1=0,this._currentSize2=0,this._currentAngularSpeed1=0,this._currentAngularSpeed2=0,this._currentVelocity1=0,this._currentVelocity2=0,this._currentLimitVelocity1=0,this._currentLimitVelocity2=0,this._currentDrag1=0,this._currentDrag2=0,this.id=r._Count++,this.particleSystem.isAnimationSheetEnabled&&this._updateCellInfoFromSystem()}return r.prototype._updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},r.prototype.updateCellIndex=function(){var t=this.age,e=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(this._randomCellOffset===void 0&&(this._randomCellOffset=Math.random()*this.lifeTime),e===0?(e=1,t=this._randomCellOffset):t+=this._randomCellOffset);var n,i=this._initialEndSpriteCellID-this._initialStartSpriteCellID+1;n=this._initialSpriteCellLoop?(0,qe.Clamp)(t*e%this.lifeTime/this.lifeTime):(0,qe.Clamp)(t*e/this.lifeTime),this.cellIndex=this._initialStartSpriteCellID+n*i|0},r.prototype._inheritParticleInfoToSubEmitter=function(t){if(t.particleSystem.emitter.position){var e=t.particleSystem.emitter;if(e.position.copyFrom(this.position),t.inheritDirection){var n=_.AA.Vector3[0];this.direction.normalizeToRef(n),e.setDirection(n,0,Math.PI/2)}}else t.particleSystem.emitter.copyFrom(this.position);this.direction.scaleToRef(t.inheritedVelocityAmount/2,_.AA.Vector3[0]),t.particleSystem._inheritedVelocityOffset.copyFrom(_.AA.Vector3[0])},r.prototype._inheritParticleInfoToSubEmitters=function(){var t=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>0&&this._attachedSubEmitters.forEach(function(e){t._inheritParticleInfoToSubEmitter(e)})},r.prototype._reset=function(){this.age=0,this.id=r._Count++,this._currentColorGradient=null,this._currentSizeGradient=null,this._currentAngularSpeedGradient=null,this._currentVelocityGradient=null,this._currentLimitVelocityGradient=null,this._currentDragGradient=null,this.cellIndex=this.particleSystem.startSpriteCellID,this._randomCellOffset=void 0},r.prototype.copyTo=function(t){t.position.copyFrom(this.position),this._initialDirection?t._initialDirection?t._initialDirection.copyFrom(this._initialDirection):t._initialDirection=this._initialDirection.clone():t._initialDirection=null,t.direction.copyFrom(this.direction),this._localPosition&&(t._localPosition?t._localPosition.copyFrom(this._localPosition):t._localPosition=this._localPosition.clone()),t.color.copyFrom(this.color),t.colorStep.copyFrom(this.colorStep),t.lifeTime=this.lifeTime,t.age=this.age,t._randomCellOffset=this._randomCellOffset,t.size=this.size,t.scale.copyFrom(this.scale),t.angle=this.angle,t.angularSpeed=this.angularSpeed,t.particleSystem=this.particleSystem,t.cellIndex=this.cellIndex,t.id=this.id,t._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(t._currentColorGradient=this._currentColorGradient,t._currentColor1.copyFrom(this._currentColor1),t._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(t._currentSizeGradient=this._currentSizeGradient,t._currentSize1=this._currentSize1,t._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(t._currentAngularSpeedGradient=this._currentAngularSpeedGradient,t._currentAngularSpeed1=this._currentAngularSpeed1,t._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(t._currentVelocityGradient=this._currentVelocityGradient,t._currentVelocity1=this._currentVelocity1,t._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(t._currentLimitVelocityGradient=this._currentLimitVelocityGradient,t._currentLimitVelocity1=this._currentLimitVelocity1,t._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(t._currentDragGradient=this._currentDragGradient,t._currentDrag1=this._currentDrag1,t._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(t._initialStartSpriteCellID=this._initialStartSpriteCellID,t._initialEndSpriteCellID=this._initialEndSpriteCellID,t._initialSpriteCellLoop=this._initialSpriteCellLoop),this.particleSystem.useRampGradients&&(t.remapData&&this.remapData?t.remapData.copyFrom(this.remapData):t.remapData=new _.IU(0,0,0,0)),this._randomNoiseCoordinates1&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),t._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(t._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),t._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},r._Count=0,r}(),YC=L(27181),vN=function(r){function t(e,n,i,o,a,s){o===void 0&&(o=null),a===void 0&&(a=!1),s===void 0&&(s=.01);var l=r.call(this,e)||this;l._emitterInverseWorldMatrix=_.uq.Identity(),l._inheritedVelocityOffset=new _.Pq,l.onDisposeObservable=new K.cP,l.onStoppedObservable=new K.cP,l._particles=new Array,l._stockParticles=new Array,l._newPartsExcess=0,l._vertexBuffers={},l._scaledColorStep=new z.ov(0,0,0,0),l._colorDiff=new z.ov(0,0,0,0),l._scaledDirection=_.Pq.Zero(),l._scaledGravity=_.Pq.Zero(),l._currentRenderId=-1,l._useInstancing=!1,l._started=!1,l._stopped=!1,l._actualFrame=0,l._currentEmitRate1=0,l._currentEmitRate2=0,l._currentStartSize1=0,l._currentStartSize2=0,l.updateInAnimate=!0,l._rawTextureWidth=256,l._useRampGradients=!1,l.isLocal=!1,l.isGPU=!1,l._shaderLanguage=0,l._onBeforeDrawParticlesObservable=null,l._emitFromParticle=function(u){},l.recycleParticle=function(u){var d=l._particles.pop();d!==u&&d.copyTo(u),l._stockParticles.push(d)},l._createParticle=function(){var u;return l._stockParticles.length!==0?(u=l._stockParticles.pop())._reset():u=new Xb(l),l._prepareParticle(u),u},l._shadersLoaded=!1,l._capacity=n,l._epsilon=s,l._isAnimationSheetEnabled=a,i&&i.getClassName()!=="Scene"?(l._engine=i,l.defaultProjectionMatrix=_.uq.PerspectiveFovLH(.8,1,.1,100,l._engine.isNDCHalfZRange)):(l._scene=i||Ve.q.LastCreatedScene,l._engine=l._scene.getEngine(),l.uniqueId=l._scene.getUniqueId(),l._scene.particleSystems.push(l)),l._engine.getCaps().vertexArrayObject&&(l._vertexArrayObject=null),l._initShaderSourceAsync(),l._attachImageProcessingConfiguration(null),l._customWrappers={0:new jn.E(l._engine)},l._customWrappers[0].effect=o,l._drawWrappers=[],l._useInstancing=l._engine.getCaps().instancedArrays,l._createIndexBuffer(),l._createVertexBuffers(),l.particleEmitterType=new Go;var c=null;return l.updateFunction=function(u){var d,h=null;l.noiseTexture&&(h=l.noiseTexture.getSize(),(d=l.noiseTexture.getContent())===null||d===void 0||d.then(function(E){c=E}));for(var p,m=u===l._particles,v=function(E){var C=u[E],T=l._scaledUpdateSpeed,f=C.age;if(C.age+=T,C.age>C.lifeTime){var g=C.age-f;T=(C.lifeTime-f)*T/g,C.age=C.lifeTime}var S=C.age/C.lifeTime;l._colorGradients&&l._colorGradients.length>0?Wi.GetCurrentGradient(S,l._colorGradients,function(B,F,X){B!==C._currentColorGradient&&(C._currentColor1.copyFrom(C._currentColor2),F.getColorToRef(C._currentColor2),C._currentColorGradient=B),z.ov.LerpToRef(C._currentColor1,C._currentColor2,X,C.color)}):(C.colorStep.scaleToRef(T,l._scaledColorStep),C.color.addInPlace(l._scaledColorStep),C.color.a<0&&(C.color.a=0)),l._angularSpeedGradients&&l._angularSpeedGradients.length>0&&Wi.GetCurrentGradient(S,l._angularSpeedGradients,function(B,F,X){B!==C._currentAngularSpeedGradient&&(C._currentAngularSpeed1=C._currentAngularSpeed2,C._currentAngularSpeed2=F.getFactor(),C._currentAngularSpeedGradient=B),C.angularSpeed=(0,qe.Lerp)(C._currentAngularSpeed1,C._currentAngularSpeed2,X)}),C.angle+=C.angularSpeed*T;var y=T;if(l._velocityGradients&&l._velocityGradients.length>0&&Wi.GetCurrentGradient(S,l._velocityGradients,function(B,F,X){B!==C._currentVelocityGradient&&(C._currentVelocity1=C._currentVelocity2,C._currentVelocity2=F.getFactor(),C._currentVelocityGradient=B),y*=(0,qe.Lerp)(C._currentVelocity1,C._currentVelocity2,X)}),C.direction.scaleToRef(y,l._scaledDirection),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&Wi.GetCurrentGradient(S,l._limitVelocityGradients,function(B,F,X){B!==C._currentLimitVelocityGradient&&(C._currentLimitVelocity1=C._currentLimitVelocity2,C._currentLimitVelocity2=F.getFactor(),C._currentLimitVelocityGradient=B);var $=(0,qe.Lerp)(C._currentLimitVelocity1,C._currentLimitVelocity2,X);C.direction.length()>$&&C.direction.scaleInPlace(l.limitVelocityDamping)}),l._dragGradients&&l._dragGradients.length>0&&Wi.GetCurrentGradient(S,l._dragGradients,function(B,F,X){B!==C._currentDragGradient&&(C._currentDrag1=C._currentDrag2,C._currentDrag2=F.getFactor(),C._currentDragGradient=B);var $=(0,qe.Lerp)(C._currentDrag1,C._currentDrag2,X);l._scaledDirection.scaleInPlace(1-$)}),l.isLocal&&C._localPosition?(C._localPosition.addInPlace(l._scaledDirection),_.Pq.TransformCoordinatesToRef(C._localPosition,l._emitterWorldMatrix,C.position)):C.position.addInPlace(l._scaledDirection),c&&h&&C._randomNoiseCoordinates1){var x=l._fetchR(C._randomNoiseCoordinates1.x,C._randomNoiseCoordinates1.y,h.width,h.height,c),R=l._fetchR(C._randomNoiseCoordinates1.z,C._randomNoiseCoordinates2.x,h.width,h.height,c),I=l._fetchR(C._randomNoiseCoordinates2.y,C._randomNoiseCoordinates2.z,h.width,h.height,c),M=_.AA.Vector3[0],D=_.AA.Vector3[1];M.copyFromFloats((2*x-1)*l.noiseStrength.x,(2*R-1)*l.noiseStrength.y,(2*I-1)*l.noiseStrength.z),M.scaleToRef(T,D),C.direction.addInPlace(D)}if(l.gravity.scaleToRef(T,l._scaledGravity),C.direction.addInPlace(l._scaledGravity),l._sizeGradients&&l._sizeGradients.length>0&&Wi.GetCurrentGradient(S,l._sizeGradients,function(B,F,X){B!==C._currentSizeGradient&&(C._currentSize1=C._currentSize2,C._currentSize2=F.getFactor(),C._currentSizeGradient=B),C.size=(0,qe.Lerp)(C._currentSize1,C._currentSize2,X)}),l._useRampGradients&&(l._colorRemapGradients&&l._colorRemapGradients.length>0&&Wi.GetCurrentGradient(S,l._colorRemapGradients,function(B,F,X){var $=(0,qe.Lerp)(B.factor1,F.factor1,X),Q=(0,qe.Lerp)(B.factor2,F.factor2,X);C.remapData.x=$,C.remapData.y=Q-$}),l._alphaRemapGradients&&l._alphaRemapGradients.length>0&&Wi.GetCurrentGradient(S,l._alphaRemapGradients,function(B,F,X){var $=(0,qe.Lerp)(B.factor1,F.factor1,X),Q=(0,qe.Lerp)(B.factor2,F.factor2,X);C.remapData.z=$,C.remapData.w=Q-$})),l._isAnimationSheetEnabled&&C.updateCellIndex(),C._inheritParticleInfoToSubEmitters(),C.age>=C.lifeTime)return l._emitFromParticle(C),C._attachedSubEmitters&&(C._attachedSubEmitters.forEach(function(B){B.particleSystem.disposeOnStop=!0,B.particleSystem.stop()}),C._attachedSubEmitters=null),l.recycleParticle(C),m&&E--,p=E,"continue";p=E},b=0;b<u.length;b++)v(b),b=p},l}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useRampGradients",{get:function(){return this._useRampGradients},set:function(e){this._useRampGradients!==e&&(this._useRampGradients=e,this._resetEffect())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"particles",{get:function(){return this._particles},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),t.prototype.getActiveCount=function(){return this._particles.length},t.prototype.getClassName=function(){return"ParticleSystem"},t.prototype.isStopping=function(){return this._stopped&&this.isAlive()},t.prototype.getCustomEffect=function(e){var n,i;return e===void 0&&(e=0),(i=(n=this._customWrappers[e])===null||n===void 0?void 0:n.effect)!==null&&i!==void 0?i:this._customWrappers[0].effect},t.prototype._getCustomDrawWrapper=function(e){var n;return e===void 0&&(e=0),(n=this._customWrappers[e])!==null&&n!==void 0?n:this._customWrappers[0]},t.prototype.setCustomEffect=function(e,n){n===void 0&&(n=0),this._customWrappers[n]=new jn.E(this._engine),this._customWrappers[n].effect=e,this._customWrappers[n].drawContext&&(this._customWrappers[n].drawContext.useInstancing=this._useInstancing)},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new K.cP),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"particles"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexBuffers",{get:function(){return this._vertexBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexBuffer",{get:function(){return this._indexBuffer},enumerable:!1,configurable:!0}),t.prototype.serialize=function(e){throw new Error("Method not implemented.")},t.prototype.clone=function(e,n,i){throw new Error("Method not implemented.")},t.prototype._addFactorGradient=function(e,n,i,o){var a=new _f(n,i,o);e.push(a),e.sort(function(s,l){return s.gradient<l.gradient?-1:s.gradient>l.gradient?1:0})},t.prototype._removeFactorGradient=function(e,n){if(e)for(var i=0,o=0,a=e;o<a.length;o++){if(a[o].gradient===n){e.splice(i,1);break}i++}},t.prototype.addLifeTimeGradient=function(e,n,i){return this._lifeTimeGradients||(this._lifeTimeGradients=[]),this._addFactorGradient(this._lifeTimeGradients,e,n,i),this},t.prototype.removeLifeTimeGradient=function(e){return this._removeFactorGradient(this._lifeTimeGradients,e),this},t.prototype.addSizeGradient=function(e,n,i){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,n,i),this},t.prototype.removeSizeGradient=function(e){return this._removeFactorGradient(this._sizeGradients,e),this},t.prototype.addColorRemapGradient=function(e,n,i){return this._colorRemapGradients||(this._colorRemapGradients=[]),this._addFactorGradient(this._colorRemapGradients,e,n,i),this},t.prototype.removeColorRemapGradient=function(e){return this._removeFactorGradient(this._colorRemapGradients,e),this},t.prototype.addAlphaRemapGradient=function(e,n,i){return this._alphaRemapGradients||(this._alphaRemapGradients=[]),this._addFactorGradient(this._alphaRemapGradients,e,n,i),this},t.prototype.removeAlphaRemapGradient=function(e){return this._removeFactorGradient(this._alphaRemapGradients,e),this},t.prototype.addAngularSpeedGradient=function(e,n,i){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,n,i),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeFactorGradient(this._angularSpeedGradients,e),this},t.prototype.addVelocityGradient=function(e,n,i){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,n,i),this},t.prototype.removeVelocityGradient=function(e){return this._removeFactorGradient(this._velocityGradients,e),this},t.prototype.addLimitVelocityGradient=function(e,n,i){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,n,i),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeFactorGradient(this._limitVelocityGradients,e),this},t.prototype.addDragGradient=function(e,n,i){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,n,i),this},t.prototype.removeDragGradient=function(e){return this._removeFactorGradient(this._dragGradients,e),this},t.prototype.addEmitRateGradient=function(e,n,i){return this._emitRateGradients||(this._emitRateGradients=[]),this._addFactorGradient(this._emitRateGradients,e,n,i),this},t.prototype.removeEmitRateGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},t.prototype.addStartSizeGradient=function(e,n,i){return this._startSizeGradients||(this._startSizeGradients=[]),this._addFactorGradient(this._startSizeGradients,e,n,i),this},t.prototype.removeStartSizeGradient=function(e){return this._removeFactorGradient(this._startSizeGradients,e),this},t.prototype._createRampGradientTexture=function(){if(this._rampGradients&&this._rampGradients.length&&!this._rampGradientsTexture&&this._scene){for(var e=new Uint8Array(4*this._rawTextureWidth),n=z.IG.Color3[0],i=function(s){var l=s/o._rawTextureWidth;Wi.GetCurrentGradient(l,o._rampGradients,function(c,u,d){z.v9.LerpToRef(c.color,u.color,d,n),e[4*s]=255*n.r,e[4*s+1]=255*n.g,e[4*s+2]=255*n.b,e[4*s+3]=255})},o=this,a=0;a<this._rawTextureWidth;a++)i(a);this._rampGradientsTexture=Ln.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE)}},t.prototype.getRampGradients=function(){return this._rampGradients},t.prototype.forceRefreshGradients=function(){this._syncRampGradientTexture()},t.prototype._syncRampGradientTexture=function(){this._rampGradients&&(this._rampGradients.sort(function(e,n){return e.gradient<n.gradient?-1:e.gradient>n.gradient?1:0}),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture())},t.prototype.addRampGradient=function(e,n){this._rampGradients||(this._rampGradients=[]);var i=new Yb(e,n);return this._rampGradients.push(i),this._syncRampGradientTexture(),this},t.prototype.removeRampGradient=function(e){return this._removeGradientAndTexture(e,this._rampGradients,this._rampGradientsTexture),this._rampGradientsTexture=null,this._rampGradients&&this._rampGradients.length>0&&this._createRampGradientTexture(),this},t.prototype.addColorGradient=function(e,n,i){this._colorGradients||(this._colorGradients=[]);var o=new pf(e,n,i);return this._colorGradients.push(o),this._colorGradients.sort(function(a,s){return a.gradient<s.gradient?-1:a.gradient>s.gradient?1:0}),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var n=0,i=0,o=this._colorGradients;i<o.length;i++){if(o[i].gradient===e){this._colorGradients.splice(n,1);break}n++}return this},t.prototype.resetDrawCache=function(){for(var e=0,n=this._drawWrappers;e<n.length;e++){var i=n[e];if(i)for(var o=0,a=i;o<a.length;o++){var s=a[o];s?.dispose()}}this._drawWrappers=[]},t.prototype._fetchR=function(e,n,i,o,a){return a[4*(((e=.5*Math.abs(e)+.5)*i%i|0)+((n=.5*Math.abs(n)+.5)*o%o|0)*i)]/255},t.prototype._reset=function(){this._resetEffect()},t.prototype._resetEffect=function(){this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),this._createVertexBuffers()},t.prototype._createVertexBuffers=function(){this._vertexBufferSize=this._useInstancing?10:12,this._isAnimationSheetEnabled&&(this._vertexBufferSize+=1),this._isBillboardBased&&this.billboardMode!==P.Y.PARTICLES_BILLBOARDMODE_STRETCHED&&this.billboardMode!==P.Y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL||(this._vertexBufferSize+=3),this._useRampGradients&&(this._vertexBufferSize+=4);var e=this._engine,n=this._vertexBufferSize*(this._useInstancing?1:4);this._vertexData=new Float32Array(this._capacity*n),this._vertexBuffer=new Y.h(e,this._vertexData,!0,n);var i=0,o=this._vertexBuffer.createVertexBuffer(Y.R.PositionKind,i,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Y.R.PositionKind]=o,i+=3;var a=this._vertexBuffer.createVertexBuffer(Y.R.ColorKind,i,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Y.R.ColorKind]=a,i+=4;var s=this._vertexBuffer.createVertexBuffer("angle",i,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.angle=s,i+=1;var l,c=this._vertexBuffer.createVertexBuffer("size",i,2,this._vertexBufferSize,this._useInstancing);if(this._vertexBuffers.size=c,i+=2,this._isAnimationSheetEnabled){var u=this._vertexBuffer.createVertexBuffer("cellIndex",i,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.cellIndex=u,i+=1}if(!this._isBillboardBased||this.billboardMode===P.Y.PARTICLES_BILLBOARDMODE_STRETCHED||this.billboardMode===P.Y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL){var d=this._vertexBuffer.createVertexBuffer("direction",i,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.direction=d,i+=3}if(this._useRampGradients){var h=this._vertexBuffer.createVertexBuffer("remapData",i,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.remapData=h,i+=4}if(this._useInstancing){var p=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new Y.h(e,p,!1,2),l=this._spriteBuffer.createVertexBuffer("offset",0,2)}else l=this._vertexBuffer.createVertexBuffer("offset",i,2,this._vertexBufferSize,this._useInstancing),i+=2;this._vertexBuffers.offset=l,this.resetDrawCache()},t.prototype._createIndexBuffer=function(){if(this._useInstancing)this._linesIndexBufferUseInstancing=this._engine.createIndexBuffer(new Uint32Array([0,1,1,3,3,2,2,0,0,3]));else{for(var e=[],n=[],i=0,o=0;o<this._capacity;o++)e.push(i),e.push(i+1),e.push(i+2),e.push(i),e.push(i+2),e.push(i+3),n.push(i,i+1,i+1,i+2,i+2,i+3,i+3,i,i,i+3),i+=4;this._indexBuffer=this._engine.createIndexBuffer(e),this._linesIndexBuffer=this._engine.createIndexBuffer(n)}},t.prototype.getCapacity=function(){return this._capacity},t.prototype.isAlive=function(){return this._alive},t.prototype.isStarted=function(){return this._started},t.prototype._preStart=function(){},t.prototype.start=function(e){var n,i=this;if(e===void 0&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";if(e)setTimeout(function(){i.start(0)},e);else{if(this._started=!0,this._stopped=!1,this._actualFrame=0,this._preStart(),this._emitRateGradients&&(this._emitRateGradients.length>0&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),this._emitRateGradients.length>1&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(this._startSizeGradients.length>0&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),this._startSizeGradients.length>1&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){((n=this.emitter)===null||n===void 0?void 0:n.getClassName().indexOf("Mesh"))!==-1&&this.emitter.computeWorldMatrix(!0);var o=this.noiseTexture;if(o&&o.onGeneratedObservable)o.onGeneratedObservable.addOnce(function(){setTimeout(function(){for(var s=0;s<i.preWarmCycles;s++)i.animate(!0),o.render()})});else for(var a=0;a<this.preWarmCycles;a++)this.animate(!0)}this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){e===void 0&&(e=!0),this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0,this._postStop(e))},t.prototype._postStop=function(e){},t.prototype.reset=function(){this._stockParticles.length=0,this._particles.length=0},t.prototype._appendParticleVertex=function(e,n,i,o){var a=e*this._vertexBufferSize;if(this._vertexData[a++]=n.position.x+this.worldOffset.x,this._vertexData[a++]=n.position.y+this.worldOffset.y,this._vertexData[a++]=n.position.z+this.worldOffset.z,this._vertexData[a++]=n.color.r,this._vertexData[a++]=n.color.g,this._vertexData[a++]=n.color.b,this._vertexData[a++]=n.color.a,this._vertexData[a++]=n.angle,this._vertexData[a++]=n.scale.x*n.size,this._vertexData[a++]=n.scale.y*n.size,this._isAnimationSheetEnabled&&(this._vertexData[a++]=n.cellIndex),this._isBillboardBased)this.billboardMode!==P.Y.PARTICLES_BILLBOARDMODE_STRETCHED&&this.billboardMode!==P.Y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL||(this._vertexData[a++]=n.direction.x,this._vertexData[a++]=n.direction.y,this._vertexData[a++]=n.direction.z);else if(n._initialDirection){var s=n._initialDirection;this.isLocal&&(_.Pq.TransformNormalToRef(s,this._emitterWorldMatrix,_.AA.Vector3[0]),s=_.AA.Vector3[0]),s.x===0&&s.z===0&&(s.x=.001),this._vertexData[a++]=s.x,this._vertexData[a++]=s.y,this._vertexData[a++]=s.z}else{var l=n.direction;this.isLocal&&(_.Pq.TransformNormalToRef(l,this._emitterWorldMatrix,_.AA.Vector3[0]),l=_.AA.Vector3[0]),l.x===0&&l.z===0&&(l.x=.001),this._vertexData[a++]=l.x,this._vertexData[a++]=l.y,this._vertexData[a++]=l.z}this._useRampGradients&&n.remapData&&(this._vertexData[a++]=n.remapData.x,this._vertexData[a++]=n.remapData.y,this._vertexData[a++]=n.remapData.z,this._vertexData[a++]=n.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(i===0?i=this._epsilon:i===1&&(i=1-this._epsilon),o===0?o=this._epsilon:o===1&&(o=1-this._epsilon)),this._vertexData[a++]=i,this._vertexData[a++]=o)},t.prototype._prepareParticle=function(e){},t.prototype._update=function(e){var n,i=this;if(this._alive=this._particles.length>0,this.emitter.position){var o=this.emitter;this._emitterWorldMatrix=o.getWorldMatrix()}else{var a=this.emitter;this._emitterWorldMatrix=_.uq.Translation(a.x,a.y,a.z)}this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),this.updateFunction(this._particles);for(var s=function(u){if(l._particles.length===l._capacity)return"break";if(n=l._createParticle(),l._particles.push(n),l.targetStopDuration&&l._lifeTimeGradients&&l._lifeTimeGradients.length>0){var d=(0,qe.Clamp)(l._actualFrame/l.targetStopDuration);Wi.GetCurrentGradient(d,l._lifeTimeGradients,function(v,b){var E=v,C=b,T=E.getFactor(),f=C.getFactor(),g=(d-E.gradient)/(C.gradient-E.gradient);n.lifeTime=(0,qe.Lerp)(T,f,g)})}else n.lifeTime=(0,qe.RandomRange)(l.minLifeTime,l.maxLifeTime);var h=(0,qe.RandomRange)(l.minEmitPower,l.maxEmitPower);if(l.startPositionFunction?l.startPositionFunction(l._emitterWorldMatrix,n.position,n,l.isLocal):l.particleEmitterType.startPositionFunction(l._emitterWorldMatrix,n.position,n,l.isLocal),l.isLocal&&(n._localPosition?n._localPosition.copyFrom(n.position):n._localPosition=n.position.clone(),_.Pq.TransformCoordinatesToRef(n._localPosition,l._emitterWorldMatrix,n.position)),l.startDirectionFunction?l.startDirectionFunction(l._emitterWorldMatrix,n.direction,n,l.isLocal):l.particleEmitterType.startDirectionFunction(l._emitterWorldMatrix,n.direction,n,l.isLocal,l._emitterInverseWorldMatrix),h===0?n._initialDirection?n._initialDirection.copyFrom(n.direction):n._initialDirection=n.direction.clone():n._initialDirection=null,n.direction.scaleInPlace(h),l._sizeGradients&&l._sizeGradients.length!==0?(n._currentSizeGradient=l._sizeGradients[0],n._currentSize1=n._currentSizeGradient.getFactor(),n.size=n._currentSize1,l._sizeGradients.length>1?n._currentSize2=l._sizeGradients[1].getFactor():n._currentSize2=n._currentSize1):n.size=(0,qe.RandomRange)(l.minSize,l.maxSize),n.scale.copyFromFloats((0,qe.RandomRange)(l.minScaleX,l.maxScaleX),(0,qe.RandomRange)(l.minScaleY,l.maxScaleY)),l._startSizeGradients&&l._startSizeGradients[0]&&l.targetStopDuration){var p=l._actualFrame/l.targetStopDuration;Wi.GetCurrentGradient(p,l._startSizeGradients,function(v,b,E){v!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=b.getFactor(),i._currentStartSizeGradient=v);var C=(0,qe.Lerp)(i._currentStartSize1,i._currentStartSize2,E);n.scale.scaleInPlace(C)})}if(l._angularSpeedGradients&&l._angularSpeedGradients.length!==0?(n._currentAngularSpeedGradient=l._angularSpeedGradients[0],n.angularSpeed=n._currentAngularSpeedGradient.getFactor(),n._currentAngularSpeed1=n.angularSpeed,l._angularSpeedGradients.length>1?n._currentAngularSpeed2=l._angularSpeedGradients[1].getFactor():n._currentAngularSpeed2=n._currentAngularSpeed1):n.angularSpeed=(0,qe.RandomRange)(l.minAngularSpeed,l.maxAngularSpeed),n.angle=(0,qe.RandomRange)(l.minInitialRotation,l.maxInitialRotation),l._velocityGradients&&l._velocityGradients.length>0&&(n._currentVelocityGradient=l._velocityGradients[0],n._currentVelocity1=n._currentVelocityGradient.getFactor(),l._velocityGradients.length>1?n._currentVelocity2=l._velocityGradients[1].getFactor():n._currentVelocity2=n._currentVelocity1),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&(n._currentLimitVelocityGradient=l._limitVelocityGradients[0],n._currentLimitVelocity1=n._currentLimitVelocityGradient.getFactor(),l._limitVelocityGradients.length>1?n._currentLimitVelocity2=l._limitVelocityGradients[1].getFactor():n._currentLimitVelocity2=n._currentLimitVelocity1),l._dragGradients&&l._dragGradients.length>0&&(n._currentDragGradient=l._dragGradients[0],n._currentDrag1=n._currentDragGradient.getFactor(),l._dragGradients.length>1?n._currentDrag2=l._dragGradients[1].getFactor():n._currentDrag2=n._currentDrag1),l._colorGradients&&l._colorGradients.length!==0)n._currentColorGradient=l._colorGradients[0],n._currentColorGradient.getColorToRef(n.color),n._currentColor1.copyFrom(n.color),l._colorGradients.length>1?l._colorGradients[1].getColorToRef(n._currentColor2):n._currentColor2.copyFrom(n.color);else{var m=(0,qe.RandomRange)(0,1);z.ov.LerpToRef(l.color1,l.color2,m,n.color),l.colorDead.subtractToRef(n.color,l._colorDiff),l._colorDiff.scaleToRef(1/n.lifeTime,n.colorStep)}l._isAnimationSheetEnabled&&(n._initialStartSpriteCellID=l.startSpriteCellID,n._initialEndSpriteCellID=l.endSpriteCellID,n._initialSpriteCellLoop=l.spriteCellLoop),n.direction.addInPlace(l._inheritedVelocityOffset),l._useRampGradients&&(n.remapData=new _.IU(0,1,0,1)),l.noiseTexture&&(n._randomNoiseCoordinates1?(n._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),n._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(n._randomNoiseCoordinates1=new _.Pq(Math.random(),Math.random(),Math.random()),n._randomNoiseCoordinates2=new _.Pq(Math.random(),Math.random(),Math.random()))),n._inheritParticleInfoToSubEmitters()},l=this,c=0;c<e&&s()!=="break";c++);},t._GetAttributeNamesOrOptions=function(e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1);var o=[Y.R.PositionKind,Y.R.ColorKind,"angle","offset","size"];return e&&o.push("cellIndex"),n||o.push("direction"),i&&o.push("remapData"),o},t._GetEffectCreationOptions=function(e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1);var o=["invView","view","projection","textureMask","translationPivot","eyePosition"];return(0,tn.TV)(o),e&&o.push("particlesInfos"),n&&o.push("logarithmicDepthConstant"),i&&(o.push("vFogInfos"),o.push("vFogColor")),o},t.prototype.fillDefines=function(e,n,i){if(i===void 0&&(i=!0),this._scene&&((0,tn.tv)(this,this._scene,e),this.applyFog&&this._scene.fogEnabled&&this._scene.fogMode!==P.Y.FOGMODE_NONE&&e.push("#define FOG")),this._isAnimationSheetEnabled&&e.push("#define ANIMATESHEET"),this.useLogarithmicDepth&&e.push("#define LOGARITHMICDEPTH"),n===Ei.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this._useRampGradients&&e.push("#define RAMPGRADIENT"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case P.Y.PARTICLES_BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case P.Y.PARTICLES_BILLBOARDMODE_STRETCHED:case P.Y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL:e.push("#define BILLBOARDSTRETCHED"),this.billboardMode===P.Y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL&&e.push("#define BILLBOARDSTRETCHED_LOCAL");break;case P.Y.PARTICLES_BILLBOARDMODE_ALL:e.push("#define BILLBOARDMODE_ALL")}i&&this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e.push(this._imageProcessingConfigurationDefines.toString()))},t.prototype.fillUniformsAttributesAndSamplerNames=function(e,n,i){n.push.apply(n,t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled,this._isBillboardBased&&this.billboardMode!==P.Y.PARTICLES_BILLBOARDMODE_STRETCHED&&this.billboardMode!==P.Y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL,this._useRampGradients)),e.push.apply(e,t._GetEffectCreationOptions(this._isAnimationSheetEnabled,this.useLogarithmicDepth,this.applyFog)),i.push("diffuseSampler","rampSampler"),this._imageProcessingConfiguration&&((0,YC._)(e,this._imageProcessingConfigurationDefines),(0,YC.C)(i,this._imageProcessingConfigurationDefines))},t.prototype._getWrapper=function(e){var n=this._getCustomDrawWrapper(e);if(n?.effect)return n;var i=[];this.fillDefines(i,e);var o=this._engine._features.supportRenderPasses?this._engine.currentRenderPassId:P.Y.RENDERPASS_MAIN,a=this._drawWrappers[o];a||(a=this._drawWrappers[o]=[]);var s=a[e];s||((s=new jn.E(this._engine)).drawContext&&(s.drawContext.useInstancing=this._useInstancing),a[e]=s);var l=i.join(`
|
||
`);if(s.defines!==l){var c=[],u=[],d=[];this.fillUniformsAttributesAndSamplerNames(u,c,d),s.setEffect(this._engine.createEffect("particles",c,u,d,l,void 0,void 0,void 0,void 0,this._shaderLanguage),l)}return s},t.prototype.animate=function(e){var n,i=this;if(e===void 0&&(e=!1),this._started){if(!e&&this._scene){if(!this.isReady()||this._currentRenderId===this._scene.getFrameId())return;this._currentRenderId=this._scene.getFrameId()}var o;if(this._scaledUpdateSpeed=this.updateSpeed*(e?this.preWarmStepOffset:((n=this._scene)===null||n===void 0?void 0:n.getAnimationRatio())||1),this.manualEmitCount>-1)o=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var a=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var s=this._actualFrame/this.targetStopDuration;Wi.GetCurrentGradient(s,this._emitRateGradients,function(d,h,p){d!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=h.getFactor(),i._currentEmitRateGradient=d),a=(0,qe.Lerp)(i._currentEmitRate1,i._currentEmitRate2,p)})}o=a*this._scaledUpdateSpeed|0,this._newPartsExcess+=a*this._scaledUpdateSpeed-o}if(this._newPartsExcess>1&&(o+=0|this._newPartsExcess,this._newPartsExcess-=0|this._newPartsExcess),this._alive=!1,this._stopped?o=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(o),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene&&this._scene._toBeDisposed.push(this))),!e){for(var l=0,c=0;c<this._particles.length;c++){var u=this._particles[c];this._appendParticleVertices(l,u),l+=this._useInstancing?1:4}this._vertexBuffer&&this._vertexBuffer.updateDirectly(this._vertexData,0,this._particles.length)}this.manualEmitCount===0&&this.disposeOnStop&&this.stop()}},t.prototype._appendParticleVertices=function(e,n){this._appendParticleVertex(e++,n,0,0),this._useInstancing||(this._appendParticleVertex(e++,n,1,0),this._appendParticleVertex(e++,n,1,1),this._appendParticleVertex(e++,n,0,1))},t.prototype.rebuild=function(){var e;this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObject=null),this._createIndexBuffer(),(e=this._spriteBuffer)===null||e===void 0||e._rebuild(),this._createVertexBuffers(),this.resetDrawCache()},t.prototype._initShaderSourceAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return!this._engine.isWebGPU||t.ForceGLSL?[3,2]:(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,66348)),Promise.resolve().then(L.bind(L,45514))])]);case 1:return e.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,33355)),Promise.resolve().then(L.bind(L,90821))])];case 3:e.sent(),e.label=4;case 4:return this._shadersLoaded=!0,[2]}})})},t.prototype.isReady=function(){if(!this._shadersLoaded||!this.emitter||this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady()||!this.particleTexture||!this.particleTexture.isReady())return!1;if(this.blendMode!==Ei.BLENDMODE_MULTIPLYADD){if(!this._getWrapper(this.blendMode).effect.isReady())return!1}else if(!this._getWrapper(Ei.BLENDMODE_MULTIPLY).effect.isReady()||!this._getWrapper(Ei.BLENDMODE_ADD).effect.isReady())return!1;return!0},t.prototype._render=function(e){var n,i,o,a,s,l,c,u,d=this._getWrapper(e),h=d.effect,p=this._engine;p.enableEffect(d);var m=(n=this.defaultViewMatrix)!==null&&n!==void 0?n:this._scene.getViewMatrix();if(h.setTexture("diffuseSampler",this.particleTexture),h.setMatrix("view",m),h.setMatrix("projection",(i=this.defaultProjectionMatrix)!==null&&i!==void 0?i:this._scene.getProjectionMatrix()),this._isAnimationSheetEnabled&&this.particleTexture){var v=this.particleTexture.getBaseSize();h.setFloat3("particlesInfos",this.spriteCellWidth/v.width,this.spriteCellHeight/v.height,this.spriteCellWidth/v.width)}if(h.setVector2("translationPivot",this.translationPivot),h.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._isBillboardBased&&this._scene){var b=this._scene.activeCamera;h.setVector3("eyePosition",b.globalPosition)}this._rampGradientsTexture&&(this._rampGradients&&this._rampGradients.length||(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),h.setTexture("rampSampler",this._rampGradientsTexture));var E=h.defines;switch(this._scene&&((0,tn.gS)(h,this,this._scene),this.applyFog&&(0,Re.Yy)(this._scene,void 0,h)),E.indexOf("#define BILLBOARDMODE_ALL")>=0&&(m.invertToRef(_.AA.Matrix[0]),h.setMatrix("invView",_.AA.Matrix[0])),this._vertexArrayObject!==void 0?!((o=this._scene)===null||o===void 0)&&o.forceWireframe?p.bindBuffers(this._vertexBuffers,this._linesIndexBufferUseInstancing,h):(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,null,h)),this._engine.bindVertexArrayObject(this._vertexArrayObject,!((a=this._scene)===null||a===void 0)&&a.forceWireframe?this._linesIndexBufferUseInstancing:this._indexBuffer)):this._indexBuffer?p.bindBuffers(this._vertexBuffers,!((l=this._scene)===null||l===void 0)&&l.forceWireframe?this._linesIndexBuffer:this._indexBuffer,h):p.bindBuffers(this._vertexBuffers,!((s=this._scene)===null||s===void 0)&&s.forceWireframe?this._linesIndexBufferUseInstancing:null,h),this.useLogarithmicDepth&&this._scene&&(0,Re.DL)(E,h,this._scene),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(h),e){case Ei.BLENDMODE_ADD:p.setAlphaMode(P.Y.ALPHA_ADD);break;case Ei.BLENDMODE_ONEONE:p.setAlphaMode(P.Y.ALPHA_ONEONE);break;case Ei.BLENDMODE_STANDARD:p.setAlphaMode(P.Y.ALPHA_COMBINE);break;case Ei.BLENDMODE_MULTIPLY:p.setAlphaMode(P.Y.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(h),this._useInstancing?!((c=this._scene)===null||c===void 0)&&c.forceWireframe?p.drawElementsType(P.Y.MATERIAL_LineStripDrawMode,0,10,this._particles.length):p.drawArraysType(P.Y.MATERIAL_TriangleStripDrawMode,0,4,this._particles.length):!((u=this._scene)===null||u===void 0)&&u.forceWireframe?p.drawElementsType(P.Y.MATERIAL_WireFrameFillMode,0,10*this._particles.length):p.drawElementsType(P.Y.MATERIAL_TriangleFillMode,0,6*this._particles.length),this._particles.length},t.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var e=this._engine;e.setState&&(e.setState(!1),this.forceDepthWrite&&e.setDepthWrite(!0));var n;return n=this.blendMode===Ei.BLENDMODE_MULTIPLYADD?this._render(Ei.BLENDMODE_MULTIPLY)+this._render(Ei.BLENDMODE_ADD):this._render(this.blendMode),this._engine.unbindInstanceAttributes(),this._engine.setAlphaMode(P.Y.ALPHA_DISABLE),n},t.prototype._onDispose=function(e,n){},t.prototype.dispose=function(e,n,i){if(e===void 0&&(e=!0),n===void 0&&(n=!1),i===void 0&&(i=!1),this.resetDrawCache(),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._linesIndexBuffer&&(this._engine._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null),this._linesIndexBufferUseInstancing&&(this._engine._releaseBuffer(this._linesIndexBufferUseInstancing),this._linesIndexBufferUseInstancing=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._onDispose(n,i),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.clear(),this._scene){var o=this._scene.particleSystems.indexOf(this);o>-1&&this._scene.particleSystems.splice(o,1),this._scene._activeParticleSystems.dispose()}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onStoppedObservable.clear(),this.reset()},t.ForceGLSL=!1,t}(Ei);(function(r){r[r.ATTACHED=0]="ATTACHED",r[r.END=1]="END"})(ff||(ff={}));var _s=function(){function r(t){if(this.particleSystem=t,this.type=1,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!t.emitter||!t.emitter.dispose){var e=(0,j.n9)("BABYLON.AbstractMesh");t.emitter=new e("SubemitterSystemEmitter",t.getScene()),t._disposeEmitterOnDispose=!0}}return r.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof _.Pq?t=t.clone():t.getClassName().indexOf("Mesh")!==-1&&((t=new((0,j.n9)("BABYLON.Mesh"))("",t.getScene())).isVisible=!1):t=new _.Pq;var e=new r(this.particleSystem.clone(this.particleSystem.name,t));return e.particleSystem.name+="Clone",e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem._disposeEmitterOnDispose=!0,e.particleSystem.disposeOnStop=!0,e},r.prototype.serialize=function(t){t===void 0&&(t=!1);var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(t),e},r._ParseParticleSystem=function(t,e,n,i){throw(0,gt.n)("ParseParticle")},r.Parse=function(t,e,n){var i=t.particleSystem,o=new r(r._ParseParticleSystem(i,e,n,!0));return o.type=t.type,o.inheritDirection=t.inheritDirection,o.inheritedVelocityAmount=t.inheritedVelocityAmount,o.particleSystem._isSubEmitter=!0,o},r.prototype.dispose=function(){this.particleSystem.dispose()},r}();function XC(r,t){var e=new df;return e.direction1=r,e.direction2=t,e}function jC(r,t){return r===void 0&&(r=1),t===void 0&&(t=1),new uf(r,t)}function qC(r,t){return r===void 0&&(r=1),t===void 0&&(t=1),new Nl(r,t)}function KC(r,t,e){return r===void 0&&(r=1),t===void 0&&(t=new _.Pq(0,1,0)),e===void 0&&(e=new _.Pq(0,1,0)),new hf(r,t,e)}function ZC(r,t,e,n){return r===void 0&&(r=1),t===void 0&&(t=1),e===void 0&&(e=1),n===void 0&&(n=0),new Dl(r,t,e,n)}function QC(r,t,e,n,i){return r===void 0&&(r=1),t===void 0&&(t=1),e===void 0&&(e=1),n===void 0&&(n=new _.Pq(0,1,0)),i===void 0&&(i=new _.Pq(0,1,0)),new cf(r,t,e,n,i)}function JC(r,t){return r===void 0&&(r=1),t===void 0&&(t=Math.PI/4),new Ol(r,t)}function $C(r,t,e,n){return r===void 0&&(r=1),t===void 0&&(t=Math.PI/4),e===void 0&&(e=new _.Pq(0,1,0)),n===void 0&&(n=new _.Pq(0,1,0)),new lf(r,t,e,n)}var Pn=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._disposeEmitterOnDispose=!1,e._emitFromParticle=function(n){if(e._subEmitters&&e._subEmitters.length!==0){var i=Math.floor(Math.random()*e._subEmitters.length);e._subEmitters[i].forEach(function(o){if(o.type===1){var a=o.clone();n._inheritParticleInfoToSubEmitter(a),a.particleSystem._rootParticleSystem=e,e.activeSubSystems.push(a.particleSystem),a.particleSystem.start()}})}},e}return(0,A.C6)(t,r),t.prototype.createPointEmitter=function(e,n){var i=XC(e,n);return this.particleEmitterType=i,i},t.prototype.createHemisphericEmitter=function(e,n){e===void 0&&(e=1),n===void 0&&(n=1);var i=jC(e,n);return this.particleEmitterType=i,i},t.prototype.createSphereEmitter=function(e,n){e===void 0&&(e=1),n===void 0&&(n=1);var i=qC(e,n);return this.particleEmitterType=i,i},t.prototype.createDirectedSphereEmitter=function(e,n,i){e===void 0&&(e=1),n===void 0&&(n=new _.Pq(0,1,0)),i===void 0&&(i=new _.Pq(0,1,0));var o=KC(e,n,i);return this.particleEmitterType=o,o},t.prototype.createCylinderEmitter=function(e,n,i,o){e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=1),o===void 0&&(o=0);var a=ZC(e,n,i,o);return this.particleEmitterType=a,a},t.prototype.createDirectedCylinderEmitter=function(e,n,i,o,a){e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=1),o===void 0&&(o=new _.Pq(0,1,0)),a===void 0&&(a=new _.Pq(0,1,0));var s=QC(e,n,i,o,a);return this.particleEmitterType=s,s},t.prototype.createConeEmitter=function(e,n){e===void 0&&(e=1),n===void 0&&(n=Math.PI/4);var i=JC(e,n);return this.particleEmitterType=i,i},t.prototype.createDirectedConeEmitter=function(e,n,i,o){e===void 0&&(e=1),n===void 0&&(n=Math.PI/4),i===void 0&&(i=new _.Pq(0,1,0)),o===void 0&&(o=new _.Pq(0,1,0));var a=$C(e,n,i,o);return this.particleEmitterType=a,a},t.prototype.createBoxEmitter=function(e,n,i,o){var a=new Go;return this.particleEmitterType=a,this.direction1=e,this.direction2=n,this.minEmitBox=i,this.maxEmitBox=o,a},t.prototype._prepareSubEmitterInternalArray=function(){var e=this;this._subEmitters=new Array,this.subEmitters&&this.subEmitters.forEach(function(n){n instanceof t?e._subEmitters.push([new _s(n)]):n instanceof _s?e._subEmitters.push([n]):n instanceof Array&&e._subEmitters.push(n)})},t.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach(function(e){e.stop(!0)}),this.activeSubSystems=[])},t.prototype._removeFromRoot=function(){if(this._rootParticleSystem){var e=this._rootParticleSystem.activeSubSystems.indexOf(this);e!==-1&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},t.prototype._preStart=function(){this._prepareSubEmitterInternalArray(),this._subEmitters&&this._subEmitters.length!=0&&(this.activeSubSystems=[])},t.prototype._postStop=function(e){e&&this._stopSubEmitters()},t.prototype._prepareParticle=function(e){if(this._subEmitters&&this._subEmitters.length>0){var n=this._subEmitters[Math.floor(Math.random()*this._subEmitters.length)];e._attachedSubEmitters=[],n.forEach(function(i){if(i.type===0){var o=i.clone();e._attachedSubEmitters.push(o),o.particleSystem.start()}})}},t.prototype._onDispose=function(e,n){var i;if(e===void 0&&(e=!1),n===void 0&&(n=!1),this._removeFromRoot(),this.subEmitters&&!this._subEmitters&&this._prepareSubEmitterInternalArray(),e&&((i=this.particles)===null||i===void 0||i.forEach(function(c){if(c._attachedSubEmitters)for(var u=c._attachedSubEmitters.length-1;u>=0;u-=1)c._attachedSubEmitters[u].dispose()})),n&&this.activeSubSystems)for(var o=this.activeSubSystems.length-1;o>=0;o-=1)this.activeSubSystems[o].dispose();if(this._subEmitters&&this._subEmitters.length){for(var a=0;a<this._subEmitters.length;a++)for(var s=0,l=this._subEmitters[a];s<l.length;s++)l[s].dispose();this._subEmitters=[],this.subEmitters=[]}this._disposeEmitterOnDispose&&this.emitter&&this.emitter.dispose&&this.emitter.dispose(!0)},t._Parse=function(e,n,i,o){var a,s,l,c;c=i instanceof Be.$?null:i;var u,d=(0,j.n9)("BABYLON.Texture");if(d&&c&&(e.texture?n.particleTexture=d.Parse(e.texture,c,o):e.textureName&&(n.particleTexture=new d(o+e.textureName,c,!1,e.invertY===void 0||e.invertY),n.particleTexture.name=e.textureName)),e.emitterId||e.emitterId===0||e.emitter!==void 0?e.emitterId&&c?n.emitter=c.getLastMeshById(e.emitterId):n.emitter=_.Pq.FromArray(e.emitter):n.emitter=_.Pq.Zero(),n.isLocal=!!e.isLocal,e.renderingGroupId!==void 0&&(n.renderingGroupId=e.renderingGroupId),e.isBillboardBased!==void 0&&(n.isBillboardBased=e.isBillboardBased),e.billboardMode!==void 0&&(n.billboardMode=e.billboardMode),e.useLogarithmicDepth!==void 0&&(n.useLogarithmicDepth=e.useLogarithmicDepth),e.animations){for(var h=0;h<e.animations.length;h++){var p=e.animations[h],m=(0,j.n9)("BABYLON.Animation");m&&n.animations.push(m.Parse(p))}n.beginAnimationOnStart=e.beginAnimationOnStart,n.beginAnimationFrom=e.beginAnimationFrom,n.beginAnimationTo=e.beginAnimationTo,n.beginAnimationLoop=e.beginAnimationLoop}if(e.autoAnimate&&c&&c.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),n.startDelay=0|e.startDelay,n.minAngularSpeed=e.minAngularSpeed,n.maxAngularSpeed=e.maxAngularSpeed,n.minSize=e.minSize,n.maxSize=e.maxSize,e.minScaleX&&(n.minScaleX=e.minScaleX,n.maxScaleX=e.maxScaleX,n.minScaleY=e.minScaleY,n.maxScaleY=e.maxScaleY),e.preWarmCycles!==void 0&&(n.preWarmCycles=e.preWarmCycles,n.preWarmStepOffset=e.preWarmStepOffset),e.minInitialRotation!==void 0&&(n.minInitialRotation=e.minInitialRotation,n.maxInitialRotation=e.maxInitialRotation),n.minLifeTime=e.minLifeTime,n.maxLifeTime=e.maxLifeTime,n.minEmitPower=e.minEmitPower,n.maxEmitPower=e.maxEmitPower,n.emitRate=e.emitRate,n.gravity=_.Pq.FromArray(e.gravity),e.noiseStrength&&(n.noiseStrength=_.Pq.FromArray(e.noiseStrength)),n.color1=z.ov.FromArray(e.color1),n.color2=z.ov.FromArray(e.color2),n.colorDead=z.ov.FromArray(e.colorDead),n.updateSpeed=e.updateSpeed,n.targetStopDuration=e.targetStopDuration,n.blendMode=e.blendMode,e.colorGradients)for(var v=0,b=e.colorGradients;v<b.length;v++){var E=b[v];n.addColorGradient(E.gradient,z.ov.FromArray(E.color1),E.color2?z.ov.FromArray(E.color2):void 0)}if(e.rampGradients){for(var C=0,T=e.rampGradients;C<T.length;C++){var f=T[C];n.addRampGradient(f.gradient,z.v9.FromArray(f.color))}n.useRampGradients=e.useRampGradients}if(e.colorRemapGradients)for(var g=0,S=e.colorRemapGradients;g<S.length;g++){var y=S[g];n.addColorRemapGradient(y.gradient,y.factor1!==void 0?y.factor1:y.factor,y.factor2)}if(e.alphaRemapGradients)for(var x=0,R=e.alphaRemapGradients;x<R.length;x++){var I=R[x];n.addAlphaRemapGradient(I.gradient,I.factor1!==void 0?I.factor1:I.factor,I.factor2)}if(e.sizeGradients)for(var M=0,D=e.sizeGradients;M<D.length;M++){var B=D[M];n.addSizeGradient(B.gradient,B.factor1!==void 0?B.factor1:B.factor,B.factor2)}if(e.angularSpeedGradients)for(var F=0,X=e.angularSpeedGradients;F<X.length;F++){var $=X[F];n.addAngularSpeedGradient($.gradient,$.factor1!==void 0?$.factor1:$.factor,$.factor2)}if(e.velocityGradients)for(var Q=0,ie=e.velocityGradients;Q<ie.length;Q++){var q=ie[Q];n.addVelocityGradient(q.gradient,q.factor1!==void 0?q.factor1:q.factor,q.factor2)}if(e.dragGradients)for(var ee=0,te=e.dragGradients;ee<te.length;ee++){var ce=te[ee];n.addDragGradient(ce.gradient,ce.factor1!==void 0?ce.factor1:ce.factor,ce.factor2)}if(e.emitRateGradients)for(var fe=0,de=e.emitRateGradients;fe<de.length;fe++){var Te=de[fe];n.addEmitRateGradient(Te.gradient,Te.factor1!==void 0?Te.factor1:Te.factor,Te.factor2)}if(e.startSizeGradients)for(var ue=0,U=e.startSizeGradients;ue<U.length;ue++){var N=U[ue];n.addStartSizeGradient(N.gradient,N.factor1!==void 0?N.factor1:N.factor,N.factor2)}if(e.lifeTimeGradients)for(var w=0,k=e.lifeTimeGradients;w<k.length;w++){var J=k[w];n.addLifeTimeGradient(J.gradient,J.factor1!==void 0?J.factor1:J.factor,J.factor2)}if(e.limitVelocityGradients){for(var le=0,be=e.limitVelocityGradients;le<be.length;le++){var ve=be[le];n.addLimitVelocityGradient(ve.gradient,ve.factor1!==void 0?ve.factor1:ve.factor,ve.factor2)}n.limitVelocityDamping=e.limitVelocityDamping}if(e.noiseTexture&&c){var ye=(0,j.n9)("BABYLON.ProceduralTexture");n.noiseTexture=ye.Parse(e.noiseTexture,c,o)}if(e.particleEmitterType){switch(e.particleEmitterType.type){case"SphereParticleEmitter":u=new Nl;break;case"SphereDirectedParticleEmitter":u=new hf;break;case"ConeEmitter":case"ConeParticleEmitter":u=new Ol;break;case"ConeDirectedParticleEmitter":u=new lf;break;case"CylinderParticleEmitter":u=new Dl;break;case"CylinderDirectedParticleEmitter":u=new cf;break;case"HemisphericParticleEmitter":u=new uf;break;case"PointParticleEmitter":u=new df;break;case"MeshParticleEmitter":u=new zb;break;case"CustomParticleEmitter":u=new ko;break;default:u=new Go}u.parse(e.particleEmitterType,c)}else(u=new Go).parse(e,c);n.particleEmitterType=u,n.startSpriteCellID=e.startSpriteCellID,n.endSpriteCellID=e.endSpriteCellID,n.spriteCellLoop=(a=e.spriteCellLoop)===null||a===void 0||a,n.spriteCellWidth=e.spriteCellWidth,n.spriteCellHeight=e.spriteCellHeight,n.spriteCellChangeSpeed=e.spriteCellChangeSpeed,n.spriteRandomStartCell=e.spriteRandomStartCell,n.disposeOnStop=(s=e.disposeOnStop)!==null&&s!==void 0&&s,n.manualEmitCount=(l=e.manualEmitCount)!==null&&l!==void 0?l:-1},t.Parse=function(e,n,i,o,a){o===void 0&&(o=!1);var s,l=e.name,c=null,u=null;if(s=n instanceof Be.$?n:n.getEngine(),e.customShader&&s.createEffectForParticles){var d=(u=e.customShader).shaderOptions.defines.length>0?u.shaderOptions.defines.join(`
|
||
`):"";c=s.createEffectForParticles(u.shaderPath.fragmentElement,u.shaderOptions.uniforms,u.shaderOptions.samplers,d)}var h=new t(l,a||e.capacity,n,c,e.isAnimationSheetEnabled);if(h.customShader=u,h._rootUrl=i,e.id&&(h.id=e.id),e.subEmitters){h.subEmitters=[];for(var p=0,m=e.subEmitters;p<m.length;p++){for(var v=[],b=0,E=m[p];b<E.length;b++){var C=E[b];v.push(_s.Parse(C,n,i))}h.subEmitters.push(v)}}return t._Parse(e,h,n,i),e.textureMask&&(h.textureMask=z.ov.FromArray(e.textureMask)),e.worldOffset&&(h.worldOffset=_.Pq.FromArray(e.worldOffset)),e.preventAutoStart&&(h.preventAutoStart=e.preventAutoStart),o||h.preventAutoStart||h.start(),h},t.prototype.serialize=function(e){e===void 0&&(e=!1);var n={};if(t._Serialize(n,this,e),n.textureMask=this.textureMask.asArray(),n.customShader=this.customShader,n.preventAutoStart=this.preventAutoStart,n.worldOffset=this.worldOffset.asArray(),this.subEmitters){n.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var i=0,o=this._subEmitters;i<o.length;i++){for(var a=[],s=0,l=o[i];s<l.length;s++){var c=l[s];a.push(c.serialize(e))}n.subEmitters.push(a)}}return n},t._Serialize=function(e,n,i){if(e.name=n.name,e.id=n.id,e.capacity=n.getCapacity(),e.disposeOnStop=n.disposeOnStop,e.manualEmitCount=n.manualEmitCount,n.emitter.position){var o=n.emitter;e.emitterId=o.id}else{var a=n.emitter;e.emitter=a.asArray()}n.particleEmitterType&&(e.particleEmitterType=n.particleEmitterType.serialize()),n.particleTexture&&(i?e.texture=n.particleTexture.serialize():(e.textureName=n.particleTexture.name,e.invertY=!!n.particleTexture._invertY)),e.isLocal=n.isLocal,tt.p.AppendSerializedAnimations(n,e),e.beginAnimationOnStart=n.beginAnimationOnStart,e.beginAnimationFrom=n.beginAnimationFrom,e.beginAnimationTo=n.beginAnimationTo,e.beginAnimationLoop=n.beginAnimationLoop,e.startDelay=n.startDelay,e.renderingGroupId=n.renderingGroupId,e.isBillboardBased=n.isBillboardBased,e.billboardMode=n.billboardMode,e.minAngularSpeed=n.minAngularSpeed,e.maxAngularSpeed=n.maxAngularSpeed,e.minSize=n.minSize,e.maxSize=n.maxSize,e.minScaleX=n.minScaleX,e.maxScaleX=n.maxScaleX,e.minScaleY=n.minScaleY,e.maxScaleY=n.maxScaleY,e.minEmitPower=n.minEmitPower,e.maxEmitPower=n.maxEmitPower,e.minLifeTime=n.minLifeTime,e.maxLifeTime=n.maxLifeTime,e.emitRate=n.emitRate,e.gravity=n.gravity.asArray(),e.noiseStrength=n.noiseStrength.asArray(),e.color1=n.color1.asArray(),e.color2=n.color2.asArray(),e.colorDead=n.colorDead.asArray(),e.updateSpeed=n.updateSpeed,e.targetStopDuration=n.targetStopDuration,e.blendMode=n.blendMode,e.preWarmCycles=n.preWarmCycles,e.preWarmStepOffset=n.preWarmStepOffset,e.minInitialRotation=n.minInitialRotation,e.maxInitialRotation=n.maxInitialRotation,e.startSpriteCellID=n.startSpriteCellID,e.spriteCellLoop=n.spriteCellLoop,e.endSpriteCellID=n.endSpriteCellID,e.spriteCellChangeSpeed=n.spriteCellChangeSpeed,e.spriteCellWidth=n.spriteCellWidth,e.spriteCellHeight=n.spriteCellHeight,e.spriteRandomStartCell=n.spriteRandomStartCell,e.isAnimationSheetEnabled=n.isAnimationSheetEnabled,e.useLogarithmicDepth=n.useLogarithmicDepth;var s=n.getColorGradients();if(s){e.colorGradients=[];for(var l=0,c=s;l<c.length;l++){var u=c[l],d={gradient:u.gradient,color1:u.color1.asArray()};u.color2?d.color2=u.color2.asArray():d.color2=u.color1.asArray(),e.colorGradients.push(d)}}var h=n.getRampGradients();if(h){e.rampGradients=[];for(var p=0,m=h;p<m.length;p++){var v=m[p];d={gradient:v.gradient,color:v.color.asArray()},e.rampGradients.push(d)}e.useRampGradients=n.useRampGradients}var b=n.getColorRemapGradients();if(b){e.colorRemapGradients=[];for(var E=0,C=b;E<C.length;E++){var T=C[E];d={gradient:T.gradient,factor1:T.factor1},T.factor2!==void 0?d.factor2=T.factor2:d.factor2=T.factor1,e.colorRemapGradients.push(d)}}var f=n.getAlphaRemapGradients();if(f){e.alphaRemapGradients=[];for(var g=0,S=f;g<S.length;g++){var y=S[g];d={gradient:y.gradient,factor1:y.factor1},y.factor2!==void 0?d.factor2=y.factor2:d.factor2=y.factor1,e.alphaRemapGradients.push(d)}}var x=n.getSizeGradients();if(x){e.sizeGradients=[];for(var R=0,I=x;R<I.length;R++){var M=I[R];d={gradient:M.gradient,factor1:M.factor1},M.factor2!==void 0?d.factor2=M.factor2:d.factor2=M.factor1,e.sizeGradients.push(d)}}var D=n.getAngularSpeedGradients();if(D){e.angularSpeedGradients=[];for(var B=0,F=D;B<F.length;B++){var X=F[B];d={gradient:X.gradient,factor1:X.factor1},X.factor2!==void 0?d.factor2=X.factor2:d.factor2=X.factor1,e.angularSpeedGradients.push(d)}}var $=n.getVelocityGradients();if($){e.velocityGradients=[];for(var Q=0,ie=$;Q<ie.length;Q++){var q=ie[Q];d={gradient:q.gradient,factor1:q.factor1},q.factor2!==void 0?d.factor2=q.factor2:d.factor2=q.factor1,e.velocityGradients.push(d)}}var ee=n.getDragGradients();if(ee){e.dragGradients=[];for(var te=0,ce=ee;te<ce.length;te++){var fe=ce[te];d={gradient:fe.gradient,factor1:fe.factor1},fe.factor2!==void 0?d.factor2=fe.factor2:d.factor2=fe.factor1,e.dragGradients.push(d)}}var de=n.getEmitRateGradients();if(de){e.emitRateGradients=[];for(var Te=0,ue=de;Te<ue.length;Te++){var U=ue[Te];d={gradient:U.gradient,factor1:U.factor1},U.factor2!==void 0?d.factor2=U.factor2:d.factor2=U.factor1,e.emitRateGradients.push(d)}}var N=n.getStartSizeGradients();if(N){e.startSizeGradients=[];for(var w=0,k=N;w<k.length;w++){var J=k[w];d={gradient:J.gradient,factor1:J.factor1},J.factor2!==void 0?d.factor2=J.factor2:d.factor2=J.factor1,e.startSizeGradients.push(d)}}var le=n.getLifeTimeGradients();if(le){e.lifeTimeGradients=[];for(var be=0,ve=le;be<ve.length;be++){var ye=ve[be];d={gradient:ye.gradient,factor1:ye.factor1},ye.factor2!==void 0?d.factor2=ye.factor2:d.factor2=ye.factor1,e.lifeTimeGradients.push(d)}}var Me=n.getLimitVelocityGradients();if(Me){e.limitVelocityGradients=[];for(var we=0,He=Me;we<He.length;we++){var Ke=He[we];d={gradient:Ke.gradient,factor1:Ke.factor1},Ke.factor2!==void 0?d.factor2=Ke.factor2:d.factor2=Ke.factor1,e.limitVelocityGradients.push(d)}e.limitVelocityDamping=n.limitVelocityDamping}n.noiseTexture&&(e.noiseTexture=n.noiseTexture.serialize())},t.prototype.clone=function(e,n,i){i===void 0&&(i=!1);var o=(0,A.Cl)({},this._customWrappers),a=null,s=this._engine;if(s.createEffectForParticles&&this.customShader!=null){var l=(a=this.customShader).shaderOptions.defines.length>0?a.shaderOptions.defines.join(`
|
||
`):"",c=s.createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,l);o[0]?o[0].effect=c:this.setCustomEffect(c,0)}var u=this.serialize(i),d=t.Parse(u,this._scene||this._engine,this._rootUrl);return d.name=e,d.customShader=a,d._customWrappers=o,n===void 0&&(n=this.emitter),this.noiseTexture&&(d.noiseTexture=this.noiseTexture.clone()),d.emitter=n,this.preventAutoStart||d.start(),d},t.BILLBOARDMODE_Y=P.Y.PARTICLES_BILLBOARDMODE_Y,t.BILLBOARDMODE_ALL=P.Y.PARTICLES_BILLBOARDMODE_ALL,t.BILLBOARDMODE_STRETCHED=P.Y.PARTICLES_BILLBOARDMODE_STRETCHED,t.BILLBOARDMODE_STRETCHED_LOCAL=P.Y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL,t}(vN);_s._ParseParticleSystem=Pn.Parse,Gt.l.IncludesShadersStore.clipPlaneFragmentDeclaration2=`#ifdef CLIPPLANE
|
||
in float fClipDistance;
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
in float fClipDistance2;
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
in float fClipDistance3;
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
in float fClipDistance4;
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
in float fClipDistance5;
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
in float fClipDistance6;
|
||
#endif
|
||
`,Gt.l.ShadersStore.gpuRenderParticlesPixelShader=`precision highp float;
|
||
#ifdef LOGARITHMICDEPTH
|
||
#extension GL_EXT_frag_depth : enable
|
||
#endif
|
||
uniform sampler2D diffuseSampler;varying vec2 vUV;varying vec4 vColor;
|
||
#include<clipPlaneFragmentDeclaration2>
|
||
#include<imageProcessingDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#include<helperFunctions>
|
||
#include<imageProcessingFunctions>
|
||
#include<fogFragmentDeclaration>
|
||
void main() {
|
||
#include<clipPlaneFragment>
|
||
vec4 textureColor=texture2D(diffuseSampler,vUV);gl_FragColor=textureColor*vColor;
|
||
#ifdef BLENDMULTIPLYMODE
|
||
float alpha=vColor.a*textureColor.a;gl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);
|
||
#endif
|
||
#include<logDepthFragment>
|
||
#include<fogFragment>(color,gl_FragColor)
|
||
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
||
gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
|
||
#else
|
||
#ifdef IMAGEPROCESSING
|
||
gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);gl_FragColor=applyImageProcessing(gl_FragColor);
|
||
#endif
|
||
#endif
|
||
}
|
||
`,Gt.l.IncludesShadersStore.clipPlaneVertexDeclaration2=`#ifdef CLIPPLANE
|
||
uniform vec4 vClipPlane;out float fClipDistance;
|
||
#endif
|
||
#ifdef CLIPPLANE2
|
||
uniform vec4 vClipPlane2;out float fClipDistance2;
|
||
#endif
|
||
#ifdef CLIPPLANE3
|
||
uniform vec4 vClipPlane3;out float fClipDistance3;
|
||
#endif
|
||
#ifdef CLIPPLANE4
|
||
uniform vec4 vClipPlane4;out float fClipDistance4;
|
||
#endif
|
||
#ifdef CLIPPLANE5
|
||
uniform vec4 vClipPlane5;out float fClipDistance5;
|
||
#endif
|
||
#ifdef CLIPPLANE6
|
||
uniform vec4 vClipPlane6;out float fClipDistance6;
|
||
#endif
|
||
`,Gt.l.ShadersStore.gpuRenderParticlesVertexShader=`precision highp float;uniform mat4 view;uniform mat4 projection;uniform vec2 translationPivot;uniform vec3 worldOffset;
|
||
#ifdef LOCAL
|
||
uniform mat4 emitterWM;
|
||
#endif
|
||
attribute vec3 position;attribute float age;attribute float life;attribute vec3 size;
|
||
#ifndef BILLBOARD
|
||
attribute vec3 initialDirection;
|
||
#endif
|
||
#ifdef BILLBOARDSTRETCHED
|
||
attribute vec3 direction;
|
||
#endif
|
||
attribute float angle;
|
||
#ifdef ANIMATESHEET
|
||
attribute float cellIndex;
|
||
#endif
|
||
attribute vec2 offset;attribute vec2 uv;varying vec2 vUV;varying vec4 vColor;varying vec3 vPositionW;
|
||
#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
|
||
uniform mat4 invView;
|
||
#endif
|
||
#include<clipPlaneVertexDeclaration2>
|
||
#include<fogVertexDeclaration>
|
||
#include<logDepthDeclaration>
|
||
#ifdef COLORGRADIENTS
|
||
uniform sampler2D colorGradientSampler;
|
||
#else
|
||
uniform vec4 colorDead;attribute vec4 color;
|
||
#endif
|
||
#ifdef ANIMATESHEET
|
||
uniform vec3 sheetInfos;
|
||
#endif
|
||
#ifdef BILLBOARD
|
||
uniform vec3 eyePosition;
|
||
#endif
|
||
vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));vec3 zaxis=normalize(cross(yaxis,xaxis));vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;
|
||
#ifdef LOCAL
|
||
return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
|
||
#else
|
||
return (position+worldOffset)+alignedCorner;
|
||
#endif
|
||
}
|
||
#ifdef BILLBOARDSTRETCHED
|
||
vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {vec3 normalizedToCamera=normalize(toCamera);vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);mat3 rotMatrix= mat3(row0,row1,row2);vec3 alignedCorner=rotMatrix*rotatedCorner;
|
||
#ifdef LOCAL
|
||
return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
|
||
#else
|
||
return (position+worldOffset)+alignedCorner;
|
||
#endif
|
||
}
|
||
#endif
|
||
void main() {
|
||
#ifdef ANIMATESHEET
|
||
float rowOffset=floor(cellIndex/sheetInfos.z);float columnOffset=cellIndex-rowOffset*sheetInfos.z;vec2 uvScale=sheetInfos.xy;vec2 uvOffset=vec2(uv.x ,1.0-uv.y);vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
|
||
#else
|
||
vUV=uv;
|
||
#endif
|
||
float ratio=min(1.0,age/life);
|
||
#ifdef COLORGRADIENTS
|
||
vColor=texture2D(colorGradientSampler,vec2(ratio,0));
|
||
#else
|
||
vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);
|
||
#endif
|
||
vec2 cornerPos=(offset-translationPivot)*size.yz*size.x;
|
||
#ifdef BILLBOARD
|
||
vec4 rotatedCorner;rotatedCorner.w=0.;
|
||
#ifdef BILLBOARDY
|
||
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.y=0.;rotatedCorner.xz+=translationPivot;vec3 yaxis=(position+worldOffset)-eyePosition;yaxis.y=0.;vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));
|
||
#elif defined(BILLBOARDSTRETCHED)
|
||
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;vec3 toCamera=(position+worldOffset)-eyePosition;vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);vec4 viewPosition=(view*vec4(vPositionW,1.0));
|
||
#else
|
||
rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.z=0.;rotatedCorner.xy+=translationPivot;
|
||
#ifdef LOCAL
|
||
vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;
|
||
#else
|
||
vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;
|
||
#endif
|
||
vPositionW=(invView*viewPosition).xyz;
|
||
#endif
|
||
#else
|
||
vec3 rotatedCorner;rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);rotatedCorner.y=0.;rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);rotatedCorner.xz+=translationPivot;vec3 yaxis=normalize(initialDirection);vPositionW=rotate(yaxis,rotatedCorner);vec4 viewPosition=view*vec4(vPositionW,1.0);
|
||
#endif
|
||
gl_Position=projection*viewPosition;
|
||
#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) || defined(FOG)
|
||
vec4 worldPos=vec4(vPositionW,1.0);
|
||
#endif
|
||
#include<clipPlaneVertex>
|
||
#include<fogVertex>
|
||
#include<logDepthVertex>
|
||
}`;var zo=function(r){function t(e,n,i,o,a){o===void 0&&(o=null),a===void 0&&(a=!1);var s=r.call(this,e)||this;if(s.layerMask=268435455,s._accumulatedCount=0,s._renderVertexBuffers=[],s._targetIndex=0,s._currentRenderId=-1,s._currentRenderingCameraUniqueId=-1,s._started=!1,s._stopped=!1,s._timeDelta=0,s.updateInAnimate=!1,s._actualFrame=0,s._rawTextureWidth=256,s._rebuildingAfterContextLost=!1,s.onDisposeObservable=new K.cP,s.onStoppedObservable=new K.cP,s.forceDepthWrite=!1,s._preWarmDone=!1,s.isLocal=!1,s.isGPU=!0,s._onBeforeDrawParticlesObservable=null,i&&i.getClassName()!=="Scene"?(s._engine=i,s.defaultProjectionMatrix=_.uq.PerspectiveFovLH(.8,1,.1,100,s._engine.isNDCHalfZRange)):(s._scene=i||Ve.q.LastCreatedScene,s._engine=s._scene.getEngine(),s.uniqueId=s._scene.getUniqueId(),s._scene.particleSystems.push(s)),s._engine.getCaps().supportComputeShaders){if(!(0,j.n9)("BABYLON.ComputeShaderParticleSystem"))throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");s._platform=new((0,j.n9)("BABYLON.ComputeShaderParticleSystem"))(s,s._engine)}else{if(!(0,j.n9)("BABYLON.WebGL2ParticleSystem"))throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");s._platform=new((0,j.n9)("BABYLON.WebGL2ParticleSystem"))(s,s._engine)}s._customWrappers={0:new jn.E(s._engine)},s._customWrappers[0].effect=o,s._drawWrappers={0:new jn.E(s._engine)},s._drawWrappers[0].drawContext&&(s._drawWrappers[0].drawContext.useInstancing=!0),s._createIndexBuffer(),s._attachImageProcessingConfiguration(null),(n=n??{}).randomTextureSize||delete n.randomTextureSize;var l=(0,A.Cl)({capacity:5e4,randomTextureSize:s._engine.getCaps().maxTextureSize},n),c=n;isFinite(c)&&(l.capacity=c),s._capacity=l.capacity,s._maxActiveParticleCount=l.capacity,s._currentActiveCount=0,s._isAnimationSheetEnabled=a,s.particleEmitterType=new Go;for(var u=Math.min(s._engine.getCaps().maxTextureSize,l.randomTextureSize),d=[],h=0;h<u;++h)d.push(Math.random()),d.push(Math.random()),d.push(Math.random()),d.push(Math.random());for(s._randomTexture=new Ln(new Float32Array(d),u,1,P.Y.TEXTUREFORMAT_RGBA,i,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT),s._randomTexture.name="GPUParticleSystem_random1",s._randomTexture.wrapU=P.Y.TEXTURE_WRAP_ADDRESSMODE,s._randomTexture.wrapV=P.Y.TEXTURE_WRAP_ADDRESSMODE,d=[],h=0;h<u;++h)d.push(Math.random()),d.push(Math.random()),d.push(Math.random()),d.push(Math.random());return s._randomTexture2=new Ln(new Float32Array(d),u,1,P.Y.TEXTUREFORMAT_RGBA,i,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT),s._randomTexture2.name="GPUParticleSystem_random2",s._randomTexture2.wrapU=P.Y.TEXTURE_WRAP_ADDRESSMODE,s._randomTexture2.wrapV=P.Y.TEXTURE_WRAP_ADDRESSMODE,s._randomTextureSize=u,s}return(0,A.C6)(t,r),Object.defineProperty(t,"IsSupported",{get:function(){if(!Ve.q.LastCreatedEngine)return!1;var e=Ve.q.LastCreatedEngine.getCaps();return e.supportTransformFeedbacks||e.supportComputeShaders},enumerable:!1,configurable:!0}),t.prototype._createIndexBuffer=function(){this._linesIndexBufferUseInstancing=this._engine.createIndexBuffer(new Uint32Array([0,1,1,3,3,2,2,0,0,3]),void 0,"GPUParticleSystemLinesIndexBuffer")},t.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(t.prototype,"maxActiveParticleCount",{get:function(){return this._maxActiveParticleCount},set:function(e){this._maxActiveParticleCount=Math.min(e,this._capacity)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activeParticleCount",{get:function(){return this.maxActiveParticleCount},set:function(e){this.maxActiveParticleCount=e},enumerable:!1,configurable:!0}),t.prototype.createPointEmitter=function(e,n){var i=XC(e,n);return this.particleEmitterType=i,i},t.prototype.createHemisphericEmitter=function(e,n){e===void 0&&(e=1),n===void 0&&(n=1);var i=jC(e,n);return this.particleEmitterType=i,i},t.prototype.createSphereEmitter=function(e,n){e===void 0&&(e=1),n===void 0&&(n=1);var i=qC(e,n);return this.particleEmitterType=i,i},t.prototype.createDirectedSphereEmitter=function(e,n,i){e===void 0&&(e=1),n===void 0&&(n=new _.Pq(0,1,0)),i===void 0&&(i=new _.Pq(0,1,0));var o=KC(e,n,i);return this.particleEmitterType=o,o},t.prototype.createCylinderEmitter=function(e,n,i,o){e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=1),o===void 0&&(o=0);var a=ZC(e,n,i,o);return this.particleEmitterType=a,a},t.prototype.createDirectedCylinderEmitter=function(e,n,i,o,a){e===void 0&&(e=1),n===void 0&&(n=1),i===void 0&&(i=1),o===void 0&&(o=new _.Pq(0,1,0)),a===void 0&&(a=new _.Pq(0,1,0));var s=QC(e,n,i,o,a);return this.particleEmitterType=s,s},t.prototype.createConeEmitter=function(e,n){e===void 0&&(e=1),n===void 0&&(n=Math.PI/4);var i=JC(e,n);return this.particleEmitterType=i,i},t.prototype.createDirectedConeEmitter=function(e,n,i,o){e===void 0&&(e=1),n===void 0&&(n=Math.PI/4),i===void 0&&(i=new _.Pq(0,1,0)),o===void 0&&(o=new _.Pq(0,1,0));var a=$C(e,n,i,o);return this.particleEmitterType=a,a},t.prototype.createBoxEmitter=function(e,n,i,o){var a=new Go;return this.particleEmitterType=a,this.direction1=e,this.direction2=n,this.minEmitBox=i,this.maxEmitBox=o,a},t.prototype.isReady=function(){if(!this.emitter||this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady()||!this.particleTexture||!this.particleTexture.isReady()||this._rebuildingAfterContextLost)return!1;if(this.blendMode!==Pn.BLENDMODE_MULTIPLYADD){if(!this._getWrapper(this.blendMode).effect.isReady())return!1}else if(!this._getWrapper(Pn.BLENDMODE_MULTIPLY).effect.isReady()||!this._getWrapper(Pn.BLENDMODE_ADD).effect.isReady())return!1;return this._platform.isUpdateBufferCreated()?this._platform.isUpdateBufferReady():(this._recreateUpdateEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.isStopped=function(){return this._stopped},t.prototype.isStopping=function(){return!1},t.prototype.getActiveCount=function(){return this._currentActiveCount},t.prototype.start=function(e){var n=this;if(e===void 0&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";e?setTimeout(function(){n.start(0)},e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0)},t.prototype.reset=function(){this._releaseBuffers(),this._platform.releaseVertexBuffers(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype.getCustomEffect=function(e){var n,i;return e===void 0&&(e=0),(i=(n=this._customWrappers[e])===null||n===void 0?void 0:n.effect)!==null&&i!==void 0?i:this._customWrappers[0].effect},t.prototype._getCustomDrawWrapper=function(e){var n;return e===void 0&&(e=0),(n=this._customWrappers[e])!==null&&n!==void 0?n:this._customWrappers[0]},t.prototype.setCustomEffect=function(e,n){n===void 0&&(n=0),this._customWrappers[n]=new jn.E(this._engine),this._customWrappers[n].effect=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new K.cP),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"gpuRenderParticles"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexBuffers",{get:function(){return this._renderVertexBuffers[1^this._targetIndex]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexBuffer",{get:function(){return null},enumerable:!1,configurable:!0}),t.prototype._removeGradientAndTexture=function(e,n,i){return r.prototype._removeGradientAndTexture.call(this,e,n,i),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,n){this._colorGradients||(this._colorGradients=[]);var i=new pf(e,n);return this._colorGradients.push(i),this._refreshColorGradient(!0),this._releaseBuffers(),this},t.prototype._refreshColorGradient=function(e){e===void 0&&(e=!1),this._colorGradients&&(e&&this._colorGradients.sort(function(n,i){return n.gradient<i.gradient?-1:n.gradient>i.gradient?1:0}),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null))},t.prototype.forceRefreshGradients=function(){this._refreshColorGradient(),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture"),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture"),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture"),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture"),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture"),this.reset()},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype.resetDrawCache=function(){var e;for(var n in this._drawWrappers)(e=this._drawWrappers[n].drawContext)===null||e===void 0||e.reset()},t.prototype._addFactorGradient=function(e,n,i){var o=new _f(n,i);e.push(o),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,n){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,n),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype._refreshFactorGradient=function(e,n,i){if(i===void 0&&(i=!1),e){i&&e.sort(function(a,s){return a.gradient<s.gradient?-1:a.gradient>s.gradient?1:0});var o=this;o[n]&&(o[n].dispose(),o[n]=null)}},t.prototype.addAngularSpeedGradient=function(e,n){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,n),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},t.prototype.addVelocityGradient=function(e,n){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,n),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},t.prototype.addLimitVelocityGradient=function(e,n){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,n),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},t.prototype.addDragGradient=function(e,n){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,n),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},t.prototype.addEmitRateGradient=function(){return this},t.prototype.removeEmitRateGradient=function(){return this},t.prototype.addStartSizeGradient=function(){return this},t.prototype.removeStartSizeGradient=function(){return this},t.prototype.addColorRemapGradient=function(){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(){return this},t.prototype.removeAlphaRemapGradient=function(){return this},t.prototype.addRampGradient=function(){return this},t.prototype.removeRampGradient=function(){return this},t.prototype.getRampGradients=function(){return null},Object.defineProperty(t.prototype,"useRampGradients",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),t.prototype.addLifeTimeGradient=function(){return this},t.prototype.removeLifeTimeGradient=function(){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createVertexBuffers=function(e,n,i){var o={};o.position=n.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var a=3;o.age=n.createVertexBuffer("age",a,1,this._attributesStrideSize,!0),a+=1,o.size=n.createVertexBuffer("size",a,3,this._attributesStrideSize,!0),a+=3,o.life=n.createVertexBuffer("life",a,1,this._attributesStrideSize,!0),a+=1,a+=4,this.billboardMode===Pn.BILLBOARDMODE_STRETCHED&&(o.direction=n.createVertexBuffer("direction",a,3,this._attributesStrideSize,!0)),a+=3,this._platform.alignDataInBuffer&&(a+=1),this.particleEmitterType instanceof ko&&(a+=3,this._platform.alignDataInBuffer&&(a+=1)),this._colorGradientsTexture||(o.color=n.createVertexBuffer("color",a,4,this._attributesStrideSize,!0),a+=4),this._isBillboardBased||(o.initialDirection=n.createVertexBuffer("initialDirection",a,3,this._attributesStrideSize,!0),a+=3,this._platform.alignDataInBuffer&&(a+=1)),this.noiseTexture&&(o.noiseCoordinates1=n.createVertexBuffer("noiseCoordinates1",a,3,this._attributesStrideSize,!0),a+=3,this._platform.alignDataInBuffer&&(a+=1),o.noiseCoordinates2=n.createVertexBuffer("noiseCoordinates2",a,3,this._attributesStrideSize,!0),a+=3,this._platform.alignDataInBuffer&&(a+=1)),o.angle=n.createVertexBuffer("angle",a,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?a++:a+=2,this._isAnimationSheetEnabled&&(o.cellIndex=n.createVertexBuffer("cellIndex",a,1,this._attributesStrideSize,!0),a+=1,this.spriteRandomStartCell&&(o.cellStartOffset=n.createVertexBuffer("cellStartOffset",a,1,this._attributesStrideSize,!0),a+=1)),o.offset=i.createVertexBuffer("offset",0,2),o.uv=i.createVertexBuffer("uv",2,2),this._renderVertexBuffers.push(o),this._platform.createVertexBuffers(e,o),this.resetDrawCache()},t.prototype._initialize=function(e){if(e===void 0&&(e=!1),!this._buffer0||e){var n=this._engine,i=[];this._attributesStrideSize=21,this._targetIndex=0,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1),this.particleEmitterType instanceof ko&&(this._attributesStrideSize+=3,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1)),this.isBillboardBased||(this._attributesStrideSize+=3,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1)),this._colorGradientsTexture&&(this._attributesStrideSize-=4),this._angularSpeedGradientsTexture&&(this._attributesStrideSize-=1),this._isAnimationSheetEnabled&&(this._attributesStrideSize+=1,this.spriteRandomStartCell&&(this._attributesStrideSize+=1)),this.noiseTexture&&(this._attributesStrideSize+=6,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=2)),this._platform.alignDataInBuffer&&(this._attributesStrideSize+=3-(this._attributesStrideSize+3&3));for(var o=this.particleEmitterType instanceof ko,a=_.AA.Vector3[0],s=0,l=0;l<this._capacity;l++)if(i.push(0),i.push(0),i.push(0),i.push(0),i.push(0),i.push(0),i.push(0),i.push(0),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),o?(this.particleEmitterType.particleDestinationGenerator(l,null,a),i.push(a.x),i.push(a.y),i.push(a.z)):(i.push(0),i.push(0),i.push(0)),this._platform.alignDataInBuffer&&i.push(0),s+=16,o&&(this.particleEmitterType.particlePositionGenerator(l,null,a),i.push(a.x),i.push(a.y),i.push(a.z),this._platform.alignDataInBuffer&&i.push(0),s+=4),this._colorGradientsTexture||(i.push(0),i.push(0),i.push(0),i.push(0),s+=4),this.isBillboardBased||(i.push(0),i.push(0),i.push(0),this._platform.alignDataInBuffer&&i.push(0),s+=4),this.noiseTexture&&(i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),this._platform.alignDataInBuffer&&i.push(0),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),this._platform.alignDataInBuffer&&i.push(0),s+=8),i.push(0),s+=1,this._angularSpeedGradientsTexture||(i.push(0),s+=1),this._isAnimationSheetEnabled&&(i.push(0),s+=1,this.spriteRandomStartCell&&(i.push(0),s+=1)),this._platform.alignDataInBuffer){var c=3-(s+3&3);for(s+=c;c-- >0;)i.push(0)}var u=new Float32Array([.5,.5,1,1,-.5,.5,0,1,.5,-.5,1,0,-.5,-.5,0,0]),d=this._platform.createParticleBuffer(i),h=this._platform.createParticleBuffer(i);this._buffer0=new Y.h(n,d,!1,this._attributesStrideSize),this._buffer1=new Y.h(n,h,!1,this._attributesStrideSize),this._spriteBuffer=new Y.h(n,u,!1,4),this._renderVertexBuffers=[],this._createVertexBuffers(this._buffer0,this._buffer1,this._spriteBuffer),this._createVertexBuffers(this._buffer1,this._buffer0,this._spriteBuffer),this._sourceBuffer=this._buffer0,this._targetBuffer=this._buffer1}},t.prototype._recreateUpdateEffect=function(){this._createColorGradientTexture(),this._createSizeGradientTexture(),this._createAngularSpeedGradientTexture(),this._createVelocityGradientTexture(),this._createLimitVelocityGradientTexture(),this._createDragGradientTexture();var e=this.particleEmitterType?this.particleEmitterType.getEffectDefines():"";return this._isBillboardBased&&(e+=`
|
||
#define BILLBOARD`),this._colorGradientsTexture&&(e+=`
|
||
#define COLORGRADIENTS`),this._sizeGradientsTexture&&(e+=`
|
||
#define SIZEGRADIENTS`),this._angularSpeedGradientsTexture&&(e+=`
|
||
#define ANGULARSPEEDGRADIENTS`),this._velocityGradientsTexture&&(e+=`
|
||
#define VELOCITYGRADIENTS`),this._limitVelocityGradientsTexture&&(e+=`
|
||
#define LIMITVELOCITYGRADIENTS`),this._dragGradientsTexture&&(e+=`
|
||
#define DRAGGRADIENTS`),this.isAnimationSheetEnabled&&(e+=`
|
||
#define ANIMATESHEET`,this.spriteRandomStartCell&&(e+=`
|
||
#define ANIMATESHEETRANDOMSTART`)),this.noiseTexture&&(e+=`
|
||
#define NOISE`),this.isLocal&&(e+=`
|
||
#define LOCAL`),this._platform.isUpdateBufferCreated()&&this._cachedUpdateDefines===e||(this._cachedUpdateDefines=e,this._updateBuffer=this._platform.createUpdateBuffer(e)),this._platform.isUpdateBufferReady()},t.prototype._getWrapper=function(e){var n=this._getCustomDrawWrapper(e);if(n?.effect)return n;var i=[];this.fillDefines(i,e);var o=this._drawWrappers[e];o||((o=new jn.E(this._engine)).drawContext&&(o.drawContext.useInstancing=!0),this._drawWrappers[e]=o);var a=i.join(`
|
||
`);if(o.defines!==a){var s=[],l=[],c=[];this.fillUniformsAttributesAndSamplerNames(l,s,c),o.setEffect(this._engine.createEffect("gpuRenderParticles",s,l,c,a),a)}return o},t._GetAttributeNamesOrOptions=function(e,n,i,o){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=!1);var a=[Y.R.PositionKind,"age","life","size","angle"];return e||a.push(Y.R.ColorKind),n&&a.push("cellIndex"),i||a.push("initialDirection"),o&&a.push("direction"),a.push("offset",Y.R.UVKind),a},t._GetEffectCreationOptions=function(e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1),i===void 0&&(i=!1);var o=["emitterWM","worldOffset","view","projection","colorDead","invView","translationPivot","eyePosition"];return(0,tn.TV)(o),e&&o.push("sheetInfos"),n&&o.push("logarithmicDepthConstant"),i&&(o.push("vFogInfos"),o.push("vFogColor")),o},t.prototype.fillDefines=function(e,n,i){if(n===void 0&&(n=0),i===void 0&&(i=!0),this._scene&&((0,tn.tv)(this,this._scene,e),this.applyFog&&this._scene.fogEnabled&&this._scene.fogMode!==ke.Z.FOGMODE_NONE&&e.push("#define FOG")),n===Pn.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this.isLocal&&e.push("#define LOCAL"),this.useLogarithmicDepth&&e.push("#define LOGARITHMICDEPTH"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case Pn.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case Pn.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case Pn.BILLBOARDMODE_ALL:e.push("#define BILLBOARDMODE_ALL")}this._colorGradientsTexture&&e.push("#define COLORGRADIENTS"),this.isAnimationSheetEnabled&&e.push("#define ANIMATESHEET"),i&&this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e.push(""+this._imageProcessingConfigurationDefines.toString()))},t.prototype.fillUniformsAttributesAndSamplerNames=function(e,n,i){n.push.apply(n,t._GetAttributeNamesOrOptions(!!this._colorGradientsTexture,this._isAnimationSheetEnabled,this._isBillboardBased,this._isBillboardBased&&this.billboardMode===Pn.BILLBOARDMODE_STRETCHED)),e.push.apply(e,t._GetEffectCreationOptions(this._isAnimationSheetEnabled,this.useLogarithmicDepth,this.applyFog)),i.push("diffuseSampler","colorGradientSampler"),this._imageProcessingConfiguration&&(Ti.p.PrepareUniforms(e,this._imageProcessingConfigurationDefines),Ti.p.PrepareSamplers(i,this._imageProcessingConfigurationDefines))},t.prototype.animate=function(e){var n;e===void 0&&(e=!1),this._timeDelta=this.updateSpeed*(e?this.preWarmStepOffset:((n=this._scene)===null||n===void 0?void 0:n.getAnimationRatio())||1),this._actualFrame+=this._timeDelta,this._stopped||this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop(),this.updateInAnimate&&this._update()},t.prototype._createFactorGradientTexture=function(e,n){var i=this[n];if(e&&e.length&&!i){for(var o=new Float32Array(this._rawTextureWidth),a=function(c){var u=c/s._rawTextureWidth;Wi.GetCurrentGradient(u,e,function(d,h,p){o[c]=(0,qe.Lerp)(d.factor1,h.factor1,p)})},s=this,l=0;l<this._rawTextureWidth;l++)a(l);this[n]=Ln.CreateRTexture(o,this._rawTextureWidth,1,this._scene||this._engine,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE),this[n].name=n.substring(1)}},t.prototype._createSizeGradientTexture=function(){this._createFactorGradientTexture(this._sizeGradients,"_sizeGradientsTexture")},t.prototype._createAngularSpeedGradientTexture=function(){this._createFactorGradientTexture(this._angularSpeedGradients,"_angularSpeedGradientsTexture")},t.prototype._createVelocityGradientTexture=function(){this._createFactorGradientTexture(this._velocityGradients,"_velocityGradientsTexture")},t.prototype._createLimitVelocityGradientTexture=function(){this._createFactorGradientTexture(this._limitVelocityGradients,"_limitVelocityGradientsTexture")},t.prototype._createDragGradientTexture=function(){this._createFactorGradientTexture(this._dragGradients,"_dragGradientsTexture")},t.prototype._createColorGradientTexture=function(){if(this._colorGradients&&this._colorGradients.length&&!this._colorGradientsTexture){for(var e=new Uint8Array(4*this._rawTextureWidth),n=z.IG.Color4[0],i=function(s){var l=s/o._rawTextureWidth;Wi.GetCurrentGradient(l,o._colorGradients,function(c,u,d){z.ov.LerpToRef(c.color1,u.color1,d,n),e[4*s]=255*n.r,e[4*s+1]=255*n.g,e[4*s+2]=255*n.b,e[4*s+3]=255*n.a})},o=this,a=0;a<this._rawTextureWidth;a++)i(a);this._colorGradientsTexture=Ln.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE),this._colorGradientsTexture.name="colorGradients"}},t.prototype._render=function(e,n){var i,o,a,s,l,c=this._getWrapper(e),u=c.effect;this._engine.enableEffect(c);var d=((i=this._scene)===null||i===void 0?void 0:i.getViewMatrix())||_.uq.IdentityReadOnly;if(u.setMatrix("view",d),u.setMatrix("projection",(o=this.defaultProjectionMatrix)!==null&&o!==void 0?o:this._scene.getProjectionMatrix()),u.setTexture("diffuseSampler",this.particleTexture),u.setVector2("translationPivot",this.translationPivot),u.setVector3("worldOffset",this.worldOffset),this.isLocal&&u.setMatrix("emitterWM",n),this._colorGradientsTexture?u.setTexture("colorGradientSampler",this._colorGradientsTexture):u.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var h=this.particleTexture.getBaseSize();u.setFloat3("sheetInfos",this.spriteCellWidth/h.width,this.spriteCellHeight/h.height,h.width/this.spriteCellWidth)}if(this._isBillboardBased&&this._scene){var p=this._scene.activeCamera;u.setVector3("eyePosition",p.globalPosition)}var m=u.defines;if(this._scene&&((0,tn.gS)(u,this,this._scene),this.applyFog&&(0,Re.Yy)(this._scene,void 0,u)),m.indexOf("#define BILLBOARDMODE_ALL")>=0){var v=d.clone();v.invert(),u.setMatrix("invView",v)}switch(this.useLogarithmicDepth&&this._scene&&(0,Re.DL)(m,u,this._scene),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(u),e){case Pn.BLENDMODE_ADD:this._engine.setAlphaMode(P.Y.ALPHA_ADD);break;case Pn.BLENDMODE_ONEONE:this._engine.setAlphaMode(P.Y.ALPHA_ONEONE);break;case Pn.BLENDMODE_STANDARD:this._engine.setAlphaMode(P.Y.ALPHA_COMBINE);break;case Pn.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(P.Y.ALPHA_MULTIPLY)}return this._platform.bindDrawBuffers(this._targetIndex,u,!((a=this._scene)===null||a===void 0)&&a.forceWireframe?this._linesIndexBufferUseInstancing:null),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(u),!((s=this._scene)===null||s===void 0)&&s.forceWireframe?this._engine.drawElementsType(P.Y.MATERIAL_LineStripDrawMode,0,10,this._currentActiveCount):this._engine.drawArraysType(P.Y.MATERIAL_TriangleStripDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(P.Y.ALPHA_DISABLE),!((l=this._scene)===null||l===void 0)&&l.forceWireframe&&this._engine.unbindInstanceAttributes(),this._currentActiveCount},t.prototype._update=function(e){if(this.emitter&&this._targetBuffer&&this._recreateUpdateEffect()&&!this._rebuildingAfterContextLost){if(!e)if(this.emitter.position)e=this.emitter.getWorldMatrix();else{var n=this.emitter;e=_.AA.Matrix[0],_.uq.TranslationToRef(n.x,n.y,n.z,e)}this._platform.preUpdateParticleBuffer(),this._updateBuffer.setFloat("currentCount",this._currentActiveCount),this._updateBuffer.setFloat("timeDelta",this._timeDelta),this._updateBuffer.setFloat("stopFactor",this._stopped?0:1),this._updateBuffer.setInt("randomTextureSize",this._randomTextureSize),this._updateBuffer.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateBuffer.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateBuffer.setDirectColor4("color1",this.color1),this._updateBuffer.setDirectColor4("color2",this.color2)),this._updateBuffer.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateBuffer.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateBuffer.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateBuffer.setVector3("gravity",this.gravity),this._limitVelocityGradientsTexture&&this._updateBuffer.setFloat("limitVelocityDamping",this.limitVelocityDamping),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateBuffer),this._isAnimationSheetEnabled&&this._updateBuffer.setFloat4("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed,this.spriteCellLoop?1:0),this.noiseTexture&&this._updateBuffer.setVector3("noiseStrength",this.noiseStrength),this.isLocal||this._updateBuffer.setMatrix("emitterWM",e),this._platform.updateParticleBuffer(this._targetIndex,this._targetBuffer,this._currentActiveCount),this._targetIndex++,this._targetIndex===2&&(this._targetIndex=0);var i=this._sourceBuffer;this._sourceBuffer=this._targetBuffer,this._targetBuffer=i}},t.prototype.render=function(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=!1),!this._started||!this.isReady())return 0;if(!e&&this._scene){if(!this._preWarmDone&&this.preWarmCycles){for(var i=0;i<this.preWarmCycles;i++)this.animate(!0),this.render(!0,!0);this._preWarmDone=!0}if(this._currentRenderId===this._scene.getRenderId()&&(!this._scene.activeCamera||this._scene.activeCamera&&this._currentRenderingCameraUniqueId===this._scene.activeCamera.uniqueId))return 0;this._currentRenderId=this._scene.getRenderId(),this._scene.activeCamera&&(this._currentRenderingCameraUniqueId=this._scene.activeCamera.uniqueId)}if(this._initialize(),this._accumulatedCount+=this.emitRate*this._timeDelta,this._accumulatedCount>1){var o=0|this._accumulatedCount;this._accumulatedCount-=o,this._currentActiveCount+=o}if(this._currentActiveCount=Math.min(this._maxActiveParticleCount,this._currentActiveCount),!this._currentActiveCount)return 0;var a;if(this.emitter.position)a=this.emitter.getWorldMatrix();else{var s=this.emitter;a=_.AA.Matrix[0],_.uq.TranslationToRef(s.x,s.y,s.z,a)}var l=this._engine;this.updateInAnimate||this._update(a);var c=0;return e||n||(l.setState(!1),this.forceDepthWrite&&l.setDepthWrite(!0),c=this.blendMode===Pn.BLENDMODE_MULTIPLYADD?this._render(Pn.BLENDMODE_MULTIPLY,a)+this._render(Pn.BLENDMODE_ADD,a):this._render(this.blendMode,a),this._engine.setAlphaMode(P.Y.ALPHA_DISABLE)),c},t.prototype.rebuild=function(){var e=this,n=function(){e._recreateUpdateEffect()&&e._platform.isUpdateBufferReady()?(e._initialize(!0),e._rebuildingAfterContextLost=!1):setTimeout(n,10)};this._createIndexBuffer(),this._cachedUpdateDefines="",this._platform.contextLost(),this._rebuildingAfterContextLost=!0,n()},t.prototype._releaseBuffers=function(){this._buffer0&&(this._buffer0.dispose(),this._buffer0=null),this._buffer1&&(this._buffer1.dispose(),this._buffer1=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._platform.releaseBuffers()},t.prototype.dispose=function(e){for(var n in e===void 0&&(e=!0),this._drawWrappers)this._drawWrappers[n].dispose();if(this._drawWrappers={},this._scene){var i=this._scene.particleSystems.indexOf(this);i>-1&&this._scene.particleSystems.splice(i,1)}this._releaseBuffers(),this._platform.releaseVertexBuffers();for(var o=0;o<this._renderVertexBuffers.length;++o){var a=this._renderVertexBuffers[o];for(var s in a)a[s].dispose()}this._renderVertexBuffers=[],this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._randomTexture&&(this._randomTexture.dispose(),this._randomTexture=null),this._randomTexture2&&(this._randomTexture2.dispose(),this._randomTexture2=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this.onStoppedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,n,i){i===void 0&&(i=!1);var o=(0,A.Cl)({},this._customWrappers),a=null,s=this._engine;if(s.createEffectForParticles&&this.customShader!=null){var l=(a=this.customShader).shaderOptions.defines.length>0?a.shaderOptions.defines.join(`
|
||
`):"";o[0]=s.createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,l,void 0,void 0,void 0,this)}var c=this.serialize(i),u=t.Parse(c,this._scene||this._engine,this._rootUrl);return u.name=e,u.customShader=a,u._customWrappers=o,n===void 0&&(n=this.emitter),this.noiseTexture&&(u.noiseTexture=this.noiseTexture.clone()),u.emitter=n,u},t.prototype.serialize=function(e){e===void 0&&(e=!1);var n={};return Pn._Serialize(n,this,e),n.activeParticleCount=this.activeParticleCount,n.randomTextureSize=this._randomTextureSize,n.customShader=this.customShader,n},t.Parse=function(e,n,i,o,a){o===void 0&&(o=!1);var s,l=e.name;s=n instanceof Be.$?n:n.getEngine();var c=new t(l,{capacity:a||e.capacity,randomTextureSize:e.randomTextureSize},n,null,e.isAnimationSheetEnabled);if(c._rootUrl=i,e.customShader&&s.createEffectForParticles){var u=e.customShader,d=u.shaderOptions.defines.length>0?u.shaderOptions.defines.join(`
|
||
`):"",h=s.createEffectForParticles(u.shaderPath.fragmentElement,u.shaderOptions.uniforms,u.shaderOptions.samplers,d,void 0,void 0,void 0,c);c.setCustomEffect(h,0),c.customShader=u}return e.id&&(c.id=e.id),e.activeParticleCount&&(c.activeParticleCount=e.activeParticleCount),Pn._Parse(e,c,n,i),e.preventAutoStart&&(c.preventAutoStart=e.preventAutoStart),o||c.preventAutoStart||c.start(),c},t}(Ei),Ll=function(){function r(){this._emitterNodeIsOwned=!0,this.systems=[]}return Object.defineProperty(r.prototype,"emitterNode",{get:function(){return this._emitterNode},set:function(t){this._emitterNodeIsOwned&&this._emitterNode&&(this._emitterNode.dispose&&this._emitterNode.dispose(),this._emitterNodeIsOwned=!1);for(var e=0,n=this.systems;e<n.length;e++)n[e].emitter=t;this._emitterNode=t},enumerable:!1,configurable:!0}),r.prototype.setEmitterAsSphere=function(t,e,n){this._emitterNodeIsOwned&&this._emitterNode&&this._emitterNode.dispose&&this._emitterNode.dispose(),this._emitterNodeIsOwned=!0,this._emitterCreationOptions={kind:"Sphere",options:t,renderingGroupId:e};var i=li("emitterSphere",{diameter:t.diameter,segments:t.segments},n);i.renderingGroupId=e;var o=new qt("emitterSphereMaterial",n);o.emissiveColor=t.color,i.material=o;for(var a=0,s=this.systems;a<s.length;a++)s[a].emitter=i;this._emitterNode=i},r.prototype.start=function(t){for(var e=0,n=this.systems;e<n.length;e++){var i=n[e];t&&(i.emitter=t),i.start()}},r.prototype.dispose=function(){for(var t=0,e=this.systems;t<e.length;t++)e[t].dispose();this.systems.length=0,this._emitterNode&&(this._emitterNode.dispose&&this._emitterNode.dispose(),this._emitterNode=null)},r.prototype.serialize=function(t){t===void 0&&(t=!1);for(var e={systems:[]},n=0,i=this.systems;n<i.length;n++){var o=i[n];e.systems.push(o.serialize(t))}return this._emitterNode&&(e.emitter=this._emitterCreationOptions),e},r.Parse=function(t,e,n,i){n===void 0&&(n=!1);var o=new r,a=this.BaseAssetsUrl+"/textures/";e=e||Ve.q.LastCreatedScene;for(var s=0,l=t.systems;s<l.length;s++){var c=l[s];o.systems.push(n?zo.Parse(c,e,a,!0,i):Pn.Parse(c,e,a,!0,i))}if(t.emitter){var u=t.emitter.options;t.emitter.kind==="Sphere"&&o.setEmitterAsSphere({diameter:u.diameter,segments:u.segments,color:z.v9.FromArray(u.color)},t.emitter.renderingGroupId,e)}return o},r.BaseAssetsUrl="https://assets.babylonjs.com/particles",r}(),eR=function(){function r(){}return r.CreateDefault=function(t,e,n,i){var o;return e===void 0&&(e=500),i===void 0&&(i=!1),(o=i?new zo("default system",{capacity:e},n):new Pn("default system",e,n)).emitter=t,o.particleTexture=new Ie.g("https://assets.babylonjs.com/textures/flare.png",o.getScene()),o.createConeEmitter(.1,Math.PI/4),o.color1=new z.ov(1,1,1,1),o.color2=new z.ov(1,1,1,1),o.colorDead=new z.ov(1,1,1,0),o.minSize=.1,o.maxSize=.1,o.minEmitPower=2,o.maxEmitPower=2,o.updateSpeed=1/60,o.emitRate=30,o},r.CreateAsync=function(t,e,n,i){n===void 0&&(n=!1),e||(e=Ve.q.LastCreatedScene);var o={};return e.addPendingData(o),new Promise(function(a,s){if(n&&!zo.IsSupported)return e.removePendingData(o),s("Particle system with GPU is not supported.");ze.S0.LoadFile("".concat(r.BaseAssetsUrl,"/systems/").concat(t,".json"),function(l){e.removePendingData(o);var c=JSON.parse(l.toString());return a(Ll.Parse(c,e,n,i))},void 0,void 0,void 0,function(){return e.removePendingData(o),s("An error occurred with the creation of your particle system. Check if your type '".concat(t,"' exists."))})})},r.ExportSet=function(t){for(var e=new Ll,n=0,i=t;n<i.length;n++){var o=i[n];e.systems.push(o)}return e},r.ParseFromFileAsync=function(t,e,n,i,o,a){return i===void 0&&(i=!1),o===void 0&&(o=""),new Promise(function(s,l){var c=new We.u;c.addEventListener("readystatechange",function(){if(c.readyState==4)if(c.status==200){var u=JSON.parse(c.responseText),d=void 0;d=i?zo.Parse(u,n,o,!1,a):Pn.Parse(u,n,o,!1,a),t&&(d.name=t),s(d)}else l("Unable to load the particle system")}),c.open("GET",e),c.send()})},r.ParseFromSnippetAsync=function(t,e,n,i,o){var a=this;if(n===void 0&&(n=!1),i===void 0&&(i=""),t==="_BLANK"){var s=this.CreateDefault(null);return s.start(),Promise.resolve(s)}return new Promise(function(l,c){var u=new We.u;u.addEventListener("readystatechange",function(){if(u.readyState==4)if(u.status==200){var d=JSON.parse(JSON.parse(u.responseText).jsonPayload),h=JSON.parse(d.particleSystem),p=void 0;(p=n?zo.Parse(h,e,i,!1,o):Pn.Parse(h,e,i,!1,o)).snippetId=t,l(p)}else c("Unable to load the snippet "+t)}),u.open("GET",a.SnippetUrl+"/"+t.replace(/#/g,"/")),u.send()})},r.BaseAssetsUrl=Ll.BaseAssetsUrl,r.SnippetUrl=P.Y.SnippetUrl,r.CreateFromSnippetAsync=r.ParseFromSnippetAsync,r}();nt.d.AddParser(lt.v.NAME_PARTICLESYSTEM,function(r,t,e,n){var i=nt.d.GetIndividualParser(lt.v.NAME_PARTICLESYSTEM);if(i&&r.particleSystems!==void 0&&r.particleSystems!==null)for(var o=0,a=r.particleSystems.length;o<a;o++){var s=r.particleSystems[o];e.particleSystems.push(i(s,t,n))}}),nt.d.AddIndividualParser(lt.v.NAME_PARTICLESYSTEM,function(r,t,e){return r.activeParticleCount?zo.Parse(r,t,e):Pn.Parse(r,t,e)}),Be.$.prototype.createEffectForParticles=function(r,t,e,n,i,o,a,s,l){var c,u=this;t===void 0&&(t=[]),e===void 0&&(e=[]),n===void 0&&(n=""),l===void 0&&(l=0);var d=[],h=[],p=[];return s?s.fillUniformsAttributesAndSamplerNames(h,d,p):(d=Pn._GetAttributeNamesOrOptions(),h=Pn._GetEffectCreationOptions()),n.indexOf(" BILLBOARD")===-1&&(n+=`
|
||
#define BILLBOARD
|
||
`),s?.isAnimationSheetEnabled&&n.indexOf(" ANIMATESHEET")===-1&&(n+=`
|
||
#define ANIMATESHEET
|
||
`),e.indexOf("diffuseSampler")===-1&&e.push("diffuseSampler"),this.createEffect({vertex:(c=s?.vertexShaderName)!==null&&c!==void 0?c:"particles",fragmentElement:r},d,h.concat(t),p.concat(e),n,i,o,a,void 0,l,function(){return(0,A.sH)(u,void 0,void 0,function(){return(0,A.YH)(this,function(m){switch(m.label){case 0:return l!==0?[3,2]:[4,Promise.resolve().then(L.bind(L,33355))];case 1:return m.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,66348))];case 3:m.sent(),m.label=4;case 4:return[2]}})})})},xe.prototype.getEmittedParticleSystems=function(){for(var r=[],t=0;t<this.getScene().particleSystems.length;t++){var e=this.getScene().particleSystems[t];e.emitter===this&&r.push(e)}return r},xe.prototype.getHierarchyEmittedParticleSystems=function(){var r=[],t=this.getDescendants();t.push(this);for(var e=0;e<this.getScene().particleSystems.length;e++){var n=this.getScene().particleSystems[e],i=n.emitter;i.position&&t.indexOf(i)!==-1&&r.push(n)}return r};var mf,gf=function(){function r(t,e,n,i,o,a,s,l,c,u){c===void 0&&(c=null),u===void 0&&(u=null),this.idx=0,this.id=0,this.color=new z.ov(1,1,1,1),this.position=_.Pq.Zero(),this.rotation=_.Pq.Zero(),this.scaling=_.Pq.One(),this.uvs=new _.IU(0,0,1,1),this.velocity=_.Pq.Zero(),this.pivot=_.Pq.Zero(),this.translateFromPivot=!1,this.alive=!0,this.isVisible=!0,this._pos=0,this._ind=0,this.shapeId=0,this.idxInShape=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this.materialIndex=null,this.props=null,this.cullingStrategy=cn.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this._globalPosition=_.Pq.Zero(),this.idx=t,this.id=e,this._pos=n,this._ind=i,this._model=o,this.shapeId=a,this.idxInShape=s,this._sps=l,c&&(this._modelBoundingInfo=c,this._boundingInfo=new tr(c.minimum,c.maximum)),u!==null&&(this.materialIndex=u)}return r.prototype.getBoundingInfo=function(){return this._boundingInfo},Object.defineProperty(r.prototype,"hasBoundingInfo",{get:function(){return this._boundingInfo!==null},enumerable:!1,configurable:!0}),r.prototype.copyToRef=function(t){return t.position.copyFrom(this.position),t.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(t.rotationQuaternion?t.rotationQuaternion.copyFrom(this.rotationQuaternion):t.rotationQuaternion=this.rotationQuaternion.clone()),t.scaling.copyFrom(this.scaling),this.color&&(t.color?t.color.copyFrom(this.color):t.color=this.color.clone()),t.uvs.copyFrom(this.uvs),t.velocity.copyFrom(this.velocity),t.pivot.copyFrom(this.pivot),t.translateFromPivot=this.translateFromPivot,t.alive=this.alive,t.isVisible=this.isVisible,t.parentId=this.parentId,t.cullingStrategy=this.cullingStrategy,this.materialIndex!==null&&(t.materialIndex=this.materialIndex),this},Object.defineProperty(r.prototype,"scale",{get:function(){return this.scaling},set:function(t){this.scaling=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(t){this.rotationQuaternion=t},enumerable:!1,configurable:!0}),r.prototype.intersectsMesh=function(t){return!(!this._boundingInfo||!t.hasBoundingInfo)&&(this._sps._bSphereOnly?Zo.Intersects(this._boundingInfo.boundingSphere,t.getBoundingInfo().boundingSphere):this._boundingInfo.intersects(t.getBoundingInfo(),!1))},r.prototype.isInFrustum=function(t){return this._boundingInfo!==null&&this._boundingInfo.isInFrustum(t,this.cullingStrategy)},r.prototype.getRotationMatrix=function(t){var e;if(this.rotationQuaternion)e=this.rotationQuaternion;else{e=_.AA.Quaternion[0];var n=this.rotation;_.PT.RotationYawPitchRollToRef(n.y,n.x,n.z,e)}e.toRotationMatrix(t)},r}(),vf=function(){function r(t,e,n,i,o,a,s,l,c){this._indicesLength=0,this.shapeId=t,this._shape=e,this._indices=n,this._indicesLength=n.length,this._shapeUV=a,this._shapeColors=o,this._normals=i,this._positionFunction=s,this._vertexFunction=l,this._material=c}return Object.defineProperty(r.prototype,"shapeID",{get:function(){return this.shapeId},set:function(t){this.shapeId=t},enumerable:!1,configurable:!0}),r}(),jb=function(r,t,e,n){this.idx=0,this.ind=0,this.indicesLength=0,this.sqDistance=0,this.materialIndex=0,this.idx=r,this.ind=t,this.indicesLength=e,this.materialIndex=n},qb=function(){function r(){this.position=_.Pq.Zero(),this.color=new z.ov(1,1,1,1),this.uv=_.I9.Zero()}return Object.defineProperty(r.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"z",{get:function(){return this.position.z},set:function(t){this.position.z=t},enumerable:!1,configurable:!0}),r}(),tR=function(){function r(t,e,n){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.recomputeNormals=!1,this.counter=0,this.vars={},this._bSphereOnly=!1,this._bSphereRadiusFactor=1,this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._index=0,this._updatable=!0,this._pickable=!1,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._depthSort=!1,this._expandable=!1,this._shapeCounter=0,this._copy=new gf(0,0,0,0,null,0,0,this),this._color=new z.ov(0,0,0,0),this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeParticleVertex=!1,this._computeBoundingBox=!1,this._autoFixFaceOrientation=!1,this._depthSortParticles=!0,this._mustUnrotateFixedNormals=!1,this._particlesIntersect=!1,this._needs32Bits=!1,this._isNotBuilt=!0,this._lastParticleId=0,this._idxOfId=[],this._multimaterialEnabled=!1,this._useModelMaterial=!1,this._depthSortFunction=function(i,o){return o.sqDistance-i.sqDistance},this._materialSortFunction=function(i,o){return i.materialIndex-o.materialIndex},this._autoUpdateSubMeshes=!1,this._recomputeInvisibles=!1,this.name=t,this._scene=e||Ve.q.LastCreatedScene,this._camera=e.activeCamera,this._pickable=!!n&&n.isPickable,this._depthSort=!!n&&n.enableDepthSort,this._multimaterialEnabled=!!n&&n.enableMultiMaterial,this._useModelMaterial=!!n&&n.useModelMaterial,this._multimaterialEnabled=!!this._useModelMaterial||this._multimaterialEnabled,this._expandable=!!n&&n.expandable,this._particlesIntersect=!!n&&n.particleIntersection,this._bSphereOnly=!!n&&n.boundingSphereOnly,this._bSphereRadiusFactor=n&&n.bSphereRadiusFactor?n.bSphereRadiusFactor:1,this._computeBoundingBox=!!n?.computeBoundingBox&&n.computeBoundingBox,this._autoFixFaceOrientation=!!n?.autoFixFaceOrientation&&n.autoFixFaceOrientation,n&&n.updatable!==void 0?this._updatable=n.updatable:this._updatable=!0,this._pickable&&(this.pickedBySubMesh=[[]],this.pickedParticles=this.pickedBySubMesh[0]),(this._depthSort||this._multimaterialEnabled)&&(this.depthSortedParticles=[]),this._multimaterialEnabled&&(this._multimaterial=new Vr(this.name+"MultiMaterial",this._scene),this._materials=[],this._materialIndexesById={}),this._tmpVertex=new qb}return r.prototype.buildMesh=function(){if(!this._isNotBuilt&&this.mesh)return this.mesh;if(this.nbParticles===0&&!this.mesh){var t=ra("",{radius:1,tessellation:3},this._scene);this.addShape(t,1),t.dispose()}if(this._indices32=this._needs32Bits?new Uint32Array(this._indices):new Uint16Array(this._indices),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors),!this.mesh){var e=new xe(this.name,this._scene);this.mesh=e}!this._updatable&&this._multimaterialEnabled&&this._sortParticlesByMaterial(),this.recomputeNormals&&rt.ComputeNormals(this._positions32,this._indices32,this._normals),this._normals32=new Float32Array(this._normals),this._fixedNormal32=new Float32Array(this._normals),this._mustUnrotateFixedNormals&&this._unrotateFixedNormals();var n=new rt;if(n.indices=this._depthSort?this._indices:this._indices32,n.set(this._positions32,Y.R.PositionKind),n.set(this._normals32,Y.R.NormalKind),this._uvs32.length>0&&n.set(this._uvs32,Y.R.UVKind),this._colors32.length>0&&n.set(this._colors32,Y.R.ColorKind),n.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable){for(var i=0,o=0;o<this.nbParticles;o++)for(var a=this.particles[o],s=a._model._indicesLength,l=0;l<s;l++)if(l%3==0){var c={idx:a.idx,faceId:i};this.pickedParticles[i]=c,i++}}return this._multimaterialEnabled&&this.setMultiMaterial(this._materials),this._expandable||(this._depthSort||this._multimaterialEnabled||this._autoFixFaceOrientation||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0)),this._isNotBuilt=!1,this.recomputeNormals=!1,this._recomputeInvisibles=!0,this.mesh},r.prototype._getUVKind=function(t,e){var n,i;return e===-1&&(!((n=t.material)===null||n===void 0)&&n.diffuseTexture?e=t.material.diffuseTexture.coordinatesIndex:!((i=t.material)===null||i===void 0)&&i.albedoTexture&&(e=t.material.albedoTexture.coordinatesIndex)),"uv"+(e?e+1:"")},r.prototype.digest=function(t,e){var n,i=e&&e.facetNb||1,o=e&&e.number||0,a=e&&e.delta||0,s=t.getVerticesData(Y.R.PositionKind),l=t.getIndices(),c=t.getVerticesData(this._getUVKind(t,(n=e?.uvKind)!==null&&n!==void 0?n:0)),u=t.getVerticesData(Y.R.ColorKind),d=t.getVerticesData(Y.R.NormalKind),h=e&&e.storage?e.storage:null,p=0,m=l.length/3;o?(o=o>m?m:o,i=Math.round(m/o),a=0):i=i>m?m:i;for(var v=[],b=[],E=[],C=[],T=[],f=_.Pq.Zero(),g=i;p<m;){p>m-(i=g+Math.floor((1+a)*Math.random()))&&(i=m-p),v.length=0,b.length=0,E.length=0,C.length=0,T.length=0;for(var S=0,y=3*p;y<3*(p+i);y++){E.push(S);var x=l[y],R=3*x;if(v.push(s[R],s[R+1],s[R+2]),b.push(d[R],d[R+1],d[R+2]),c){var I=2*x;C.push(c[I],c[I+1])}if(u){var M=4*x;T.push(u[M],u[M+1],u[M+2],u[M+3])}S++}var D=this.nbParticles,B=this._posToShape(v),F=this._uvsToShapeUV(C),X=E.slice(),$=T.slice(),Q=b.slice();f.copyFromFloats(0,0,0);var ie=void 0;for(ie=0;ie<B.length;ie++)f.addInPlace(B[ie]);f.scaleInPlace(1/B.length);var q=new _.Pq(1/0,1/0,1/0),ee=new _.Pq(-1/0,-1/0,-1/0);for(ie=0;ie<B.length;ie++)B[ie].subtractInPlace(f),q.minimizeInPlaceFromFloats(B[ie].x,B[ie].y,B[ie].z),ee.maximizeInPlaceFromFloats(B[ie].x,B[ie].y,B[ie].z);var te=void 0;this._particlesIntersect&&(te=new tr(q,ee));var ce=null;this._useModelMaterial&&(ce=t.material?t.material:this._setDefaultMaterial());var fe=new vf(this._shapeCounter,B,X,Q,$,F,null,null,ce),de=this._positions.length,Te=this._indices.length;this._meshBuilder(this._index,Te,B,this._positions,X,this._indices,C,this._uvs,$,this._colors,Q,this._normals,D,0,null,fe),this._addParticle(D,this._lastParticleId,de,Te,fe,this._shapeCounter,0,te,h),this.particles[this.nbParticles].position.addInPlace(f),h||(this._index+=B.length,D++,this.nbParticles++,this._lastParticleId++),this._shapeCounter++,p+=i}return this._isNotBuilt=!0,this},r.prototype._unrotateFixedNormals=function(){for(var t=0,e=0,n=_.AA.Vector3[0],i=_.AA.Quaternion[0],o=_.AA.Matrix[0],a=0;a<this.particles.length;a++){var s=this.particles[a],l=s._model._shape;if(s.rotationQuaternion)s.rotationQuaternion.conjugateToRef(i);else{var c=s.rotation;_.PT.RotationYawPitchRollToRef(c.y,c.x,c.z,i),i.conjugateInPlace()}i.toRotationMatrix(o);for(var u=0;u<l.length;u++)e=t+3*u,_.Pq.TransformNormalFromFloatsToRef(this._normals32[e],this._normals32[e+1],this._normals32[e+2],o,n),n.toArray(this._fixedNormal32,e);t=e+3}},r.prototype._resetCopy=function(){var t=this._copy;t.position.setAll(0),t.rotation.setAll(0),t.rotationQuaternion=null,t.scaling.setAll(1),t.uvs.copyFromFloats(0,0,1,1),t.color=null,t.translateFromPivot=!1,t.shapeId=0,t.materialIndex=null},r.prototype._meshBuilder=function(t,e,n,i,o,a,s,l,c,u,d,h,p,m,v,b){var E,C=0,T=0,f=0;this._resetCopy();var g=this._copy,S=!(!v||!v.storage);if(g.idx=p,g.idxInShape=m,g.shapeId=b.shapeId,this._useModelMaterial){var y=b._material.uniqueId,x=this._materialIndexesById;Object.prototype.hasOwnProperty.call(x,y)||(x[y]=this._materials.length,this._materials.push(b._material));var R=x[y];g.materialIndex=R}if(v&&v.positionFunction&&(v.positionFunction(g,p,m),this._mustUnrotateFixedNormals=!0),S)return g;var I=_.AA.Matrix[0],M=this._tmpVertex,D=M.position,B=M.color,F=M.uv,X=_.AA.Vector3[1],$=_.AA.Vector3[2],Q=_.AA.Vector3[3];_.uq.IdentityToRef(I),g.getRotationMatrix(I),g.pivot.multiplyToRef(g.scaling,Q),g.translateFromPivot?$.setAll(0):$.copyFrom(Q);var ie=v&&v.vertexFunction;for(E=0;E<n.length;E++){if(D.copyFrom(n[E]),g.color&&B.copyFrom(g.color),s&&F.copyFromFloats(s[C],s[C+1]),ie&&v.vertexFunction(g,M,E),D.multiplyInPlace(g.scaling).subtractInPlace(Q),_.Pq.TransformCoordinatesToRef(D,I,X),X.addInPlace($).addInPlace(g.position),i.push(X.x,X.y,X.z),s){var q=g.uvs;l.push((q.z-q.x)*F.x+q.x,(q.w-q.y)*F.y+q.y),C+=2}if(g.color)this._color.copyFrom(B);else{var ee=this._color;c&&c[T]!==void 0?(ee.r=c[T],ee.g=c[T+1],ee.b=c[T+2],ee.a=c[T+3]):(ee.r=1,ee.g=1,ee.b=1,ee.a=1)}u.push(this._color.r,this._color.g,this._color.b,this._color.a),T+=4,!this.recomputeNormals&&d&&(_.Pq.TransformNormalFromFloatsToRef(d[f],d[f+1],d[f+2],I,D),h.push(D.x,D.y,D.z),f+=3)}for(E=0;E<o.length;E++){var te=t+o[E];a.push(te),te>65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var ce=g.materialIndex!==null?g.materialIndex:0;this.depthSortedParticles.push(new jb(p,e,o.length,ce))}return g},r.prototype._posToShape=function(t){for(var e=[],n=0;n<t.length;n+=3)e.push(_.Pq.FromArray(t,n));return e},r.prototype._uvsToShapeUV=function(t){var e=[];if(t)for(var n=0;n<t.length;n++)e.push(t[n]);return e},r.prototype._addParticle=function(t,e,n,i,o,a,s,l,c){l===void 0&&(l=null),c===void 0&&(c=null);var u=new gf(t,e,n,i,o,a,s,this,l);return(c||this.particles).push(u),u},r.prototype.addShape=function(t,e,n){var i=t.getVerticesData(Y.R.PositionKind),o=t.getIndices(),a=t.getVerticesData(Y.R.UVKind),s=t.getVerticesData(Y.R.ColorKind),l=t.getVerticesData(Y.R.NormalKind);this.recomputeNormals=!l;var c=Array.from(o),u=l?Array.from(l):[],d=s?Array.from(s):[],h=n&&n.storage?n.storage:null,p=null;this._particlesIntersect&&(p=t.getBoundingInfo());var m=this._posToShape(i),v=this._uvsToShapeUV(a),b=n?n.positionFunction:null,E=n?n.vertexFunction:null,C=null;this._useModelMaterial&&(C=t.material?t.material:this._setDefaultMaterial());for(var T=new vf(this._shapeCounter,m,c,u,d,v,b,E,C),f=0;f<e;f++)this._insertNewParticle(this.nbParticles,f,T,m,o,a,s,l,p,h,n);return this._shapeCounter++,this._isNotBuilt=!0,this._shapeCounter-1},r.prototype._rebuildParticle=function(t,e){e===void 0&&(e=!1),this._resetCopy();var n=this._copy;t._model._positionFunction&&t._model._positionFunction(n,t.idx,t.idxInShape);var i=_.AA.Matrix[0],o=_.AA.Vector3[0],a=_.AA.Vector3[1],s=_.AA.Vector3[2],l=_.AA.Vector3[3];n.getRotationMatrix(i),t.pivot.multiplyToRef(t.scaling,l),n.translateFromPivot?s.copyFromFloats(0,0,0):s.copyFrom(l);for(var c=t._model._shape,u=0;u<c.length;u++)o.copyFrom(c[u]),t._model._vertexFunction&&t._model._vertexFunction(n,o,u),o.multiplyInPlace(n.scaling).subtractInPlace(l),_.Pq.TransformCoordinatesToRef(o,i,a),a.addInPlace(s).addInPlace(n.position).toArray(this._positions32,t._pos+3*u);e&&(t.position.setAll(0),t.rotation.setAll(0),t.rotationQuaternion=null,t.scaling.setAll(1),t.uvs.setAll(0),t.pivot.setAll(0),t.translateFromPivot=!1,t.parentId=null)},r.prototype.rebuildMesh=function(t){t===void 0&&(t=!1);for(var e=0;e<this.particles.length;e++)this._rebuildParticle(this.particles[e],t);return this.mesh.updateVerticesData(Y.R.PositionKind,this._positions32,!1,!1),this},r.prototype.removeParticles=function(t,e){var n=e-t+1;if(!this._expandable||n<=0||n>=this.nbParticles||!this._updatable)return[];var i=this.particles,o=this.nbParticles;if(e<o-1)for(var a=e+1,s=i[a]._pos-i[t]._pos,l=i[a]._ind-i[t]._ind,c=a;c<o;c++){var u=i[c];u._pos-=s,u._ind-=l}var d=i.splice(t,n);this._positions.length=0,this._indices.length=0,this._colors.length=0,this._uvs.length=0,this._normals.length=0,this._index=0,this._idxOfId.length=0,(this._depthSort||this._multimaterialEnabled)&&(this.depthSortedParticles=[]);for(var h=0,p=i.length,m=0;m<p;m++){var v=i[m],b=v._model,E=b._shape,C=b._indices,T=b._normals,f=b._shapeColors,g=b._shapeUV;v.idx=m,this._idxOfId[v.id]=m,this._meshBuilder(this._index,h,E,this._positions,C,this._indices,g,this._uvs,f,this._colors,T,this._normals,v.idx,v.idxInShape,null,b),this._index+=E.length,h+=C.length}return this.nbParticles-=n,this._isNotBuilt=!0,d},r.prototype.insertParticlesFromArray=function(t){if(!this._expandable)return this;for(var e=0,n=t[0].shapeId,i=t.length,o=0;o<i;o++){var a=t[o],s=a._model,l=s._shape,c=s._indices,u=s._shapeUV,d=s._shapeColors,h=s._normals,p=!h;this.recomputeNormals=p||this.recomputeNormals;var m=a.getBoundingInfo(),v=this._insertNewParticle(this.nbParticles,e,s,l,c,u,d,h,m,null,null);a.copyToRef(v),e++,n!=a.shapeId&&(n=a.shapeId,e=0)}return this._isNotBuilt=!0,this},r.prototype._insertNewParticle=function(t,e,n,i,o,a,s,l,c,u,d){var h=this._positions.length,p=this._indices.length,m=this._meshBuilder(this._index,p,i,this._positions,o,this._indices,a,this._uvs,s,this._colors,l,this._normals,t,e,d,n),v=null;return this._updatable&&((v=this._addParticle(this.nbParticles,this._lastParticleId,h,p,n,this._shapeCounter,e,c,u)).position.copyFrom(m.position),v.rotation.copyFrom(m.rotation),m.rotationQuaternion&&(v.rotationQuaternion?v.rotationQuaternion.copyFrom(m.rotationQuaternion):v.rotationQuaternion=m.rotationQuaternion.clone()),m.color&&(v.color?v.color.copyFrom(m.color):v.color=m.color.clone()),v.scaling.copyFrom(m.scaling),v.uvs.copyFrom(m.uvs),m.materialIndex!==null&&(v.materialIndex=m.materialIndex),this.expandable&&(this._idxOfId[v.id]=v.idx)),u||(this._index+=i.length,this.nbParticles++,this._lastParticleId++),v},r.prototype.setParticles=function(t,e,n){if(t===void 0&&(t=0),e===void 0&&(e=this.nbParticles-1),n===void 0&&(n=!0),!this._updatable||this._isNotBuilt)return this;this.beforeUpdateParticles(t,e,n);var i=_.AA.Matrix[0],o=_.AA.Matrix[1],a=this.mesh,s=this._colors32,l=this._positions32,c=this._normals32,u=this._uvs32,d=this._indices32,h=this._indices,p=this._fixedNormal32,m=this._depthSort&&this._depthSortParticles,v=_.AA.Vector3,b=v[5].copyFromFloats(1,0,0),E=v[6].copyFromFloats(0,1,0),C=v[7].copyFromFloats(0,0,1),T=v[8].setAll(Number.MAX_VALUE),f=v[9].setAll(-Number.MAX_VALUE),g=v[10].setAll(0),S=this._tmpVertex,y=S.position,x=S.color,R=S.uv;if((this.billboard||this._depthSort)&&(this.mesh.computeWorldMatrix(!0),this.mesh._worldMatrix.invertToRef(o)),this.billboard){var I=v[0];this._camera.getDirectionToRef(Qn._0.Z,I),_.Pq.TransformNormalToRef(I,o,C),C.normalize();var M=this._camera.getViewMatrix(!0);_.Pq.TransformNormalFromFloatsToRef(M.m[1],M.m[5],M.m[9],o,E),_.Pq.CrossToRef(E,C,b),E.normalize(),b.normalize()}this._depthSort&&_.Pq.TransformCoordinatesToRef(this._camera.globalPosition,o,g),_.uq.IdentityToRef(i);var D=0,B=0,F=0,X=0,$=0,Q=0,ie=0;if(this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),e=e>=this.nbParticles?this.nbParticles-1:e,this._computeBoundingBox&&(t!=0||e!=this.nbParticles-1)){var q=this.mesh.getBoundingInfo();q&&(T.copyFrom(q.minimum),f.copyFrom(q.maximum))}var ee=(B=this.particles[t]._pos)/3|0;X=4*ee,Q=2*ee;for(var te=t;te<=e;te++){var ce=this.particles[te];this.updateParticle(ce);var fe=ce._model._shape,de=ce._model._shapeUV,Te=ce._rotationMatrix,ue=ce.position,U=ce.rotation,N=ce.scaling,w=ce._globalPosition;if(m){var k=this.depthSortedParticles[te];k.idx=ce.idx,k.ind=ce._ind,k.indicesLength=ce._model._indicesLength,k.sqDistance=_.Pq.DistanceSquared(ce.position,g)}if(ce.alive&&(!ce._stillInvisible||ce.isVisible||this._recomputeInvisibles)){if(ce.isVisible){ce._stillInvisible=!1;var J=v[12];if(ce.pivot.multiplyToRef(N,J),this.billboard&&(U.x=0,U.y=0),(this._computeParticleRotation||this.billboard)&&ce.getRotationMatrix(i),ce.parentId!==null){var le=this.getParticleById(ce.parentId);if(le){var be=le._rotationMatrix,ve=le._globalPosition,ye=ue.x*be[1]+ue.y*be[4]+ue.z*be[7],Me=ue.x*be[0]+ue.y*be[3]+ue.z*be[6],we=ue.x*be[2]+ue.y*be[5]+ue.z*be[8];if(w.x=ve.x+Me,w.y=ve.y+ye,w.z=ve.z+we,this._computeParticleRotation||this.billboard){var He=i.m;Te[0]=He[0]*be[0]+He[1]*be[3]+He[2]*be[6],Te[1]=He[0]*be[1]+He[1]*be[4]+He[2]*be[7],Te[2]=He[0]*be[2]+He[1]*be[5]+He[2]*be[8],Te[3]=He[4]*be[0]+He[5]*be[3]+He[6]*be[6],Te[4]=He[4]*be[1]+He[5]*be[4]+He[6]*be[7],Te[5]=He[4]*be[2]+He[5]*be[5]+He[6]*be[8],Te[6]=He[8]*be[0]+He[9]*be[3]+He[10]*be[6],Te[7]=He[8]*be[1]+He[9]*be[4]+He[10]*be[7],Te[8]=He[8]*be[2]+He[9]*be[5]+He[10]*be[8]}}else ce.parentId=null}else w.x=ue.x,w.y=ue.y,w.z=ue.z,(this._computeParticleRotation||this.billboard)&&(He=i.m,Te[0]=He[0],Te[1]=He[1],Te[2]=He[2],Te[3]=He[4],Te[4]=He[5],Te[5]=He[6],Te[6]=He[8],Te[7]=He[9],Te[8]=He[10]);var Ke=v[11];for(ce.translateFromPivot?Ke.setAll(0):Ke.copyFrom(J),ie=0;ie<fe.length;ie++){D=B+3*ie,F=X+4*ie,$=Q+2*ie;var Qe=2*ie,Je=Qe+1;y.copyFrom(fe[ie]),this._computeParticleColor&&ce.color&&x.copyFrom(ce.color),this._computeParticleTexture&&R.copyFromFloats(de[Qe],de[Je]),this._computeParticleVertex&&this.updateParticleVertex(ce,S,ie);var ht=y.x*N.x-J.x,mt=y.y*N.y-J.y,yt=y.z*N.z-J.z;Me=ht*Te[0]+mt*Te[3]+yt*Te[6],ye=ht*Te[1]+mt*Te[4]+yt*Te[7],we=ht*Te[2]+mt*Te[5]+yt*Te[8],Me+=Ke.x,ye+=Ke.y,we+=Ke.z;var zt=l[D]=w.x+b.x*Me+E.x*ye+C.x*we,$t=l[D+1]=w.y+b.y*Me+E.y*ye+C.y*we,St=l[D+2]=w.z+b.z*Me+E.z*ye+C.z*we;if(this._computeBoundingBox&&(T.minimizeInPlaceFromFloats(zt,$t,St),f.maximizeInPlaceFromFloats(zt,$t,St)),!this._computeParticleVertex){var Ot=p[D],Et=p[D+1],Vt=p[D+2],ln=Ot*Te[0]+Et*Te[3]+Vt*Te[6],Yt=Ot*Te[1]+Et*Te[4]+Vt*Te[7],Un=Ot*Te[2]+Et*Te[5]+Vt*Te[8];c[D]=b.x*ln+E.x*Yt+C.x*Un,c[D+1]=b.y*ln+E.y*Yt+C.y*Un,c[D+2]=b.z*ln+E.z*Yt+C.z*Un}if(this._computeParticleColor&&ce.color){var lr=this._colors32;lr[F]=x.r,lr[F+1]=x.g,lr[F+2]=x.b,lr[F+3]=x.a}if(this._computeParticleTexture){var ii=ce.uvs;u[$]=R.x*(ii.z-ii.x)+ii.x,u[$+1]=R.y*(ii.w-ii.y)+ii.y}}}else for(ce._stillInvisible=!0,ie=0;ie<fe.length;ie++){if(F=X+4*ie,$=Q+2*ie,l[D=B+3*ie]=l[D+1]=l[D+2]=0,c[D]=c[D+1]=c[D+2]=0,this._computeParticleColor&&ce.color){var Li=ce.color;s[F]=Li.r,s[F+1]=Li.g,s[F+2]=Li.b,s[F+3]=Li.a}this._computeParticleTexture&&(ii=ce.uvs,u[$]=de[2*ie]*(ii.z-ii.x)+ii.x,u[$+1]=de[2*ie+1]*(ii.w-ii.y)+ii.y)}if(this._particlesIntersect){var $r=ce.getBoundingInfo(),Xo=$r.boundingBox,jo=$r.boundingSphere,Or=ce._modelBoundingInfo;if(!this._bSphereOnly){var Dr=Or.boundingBox.vectors,Yi=v[1],eo=v[2];Yi.setAll(Number.MAX_VALUE),eo.setAll(-Number.MAX_VALUE);for(var Nr=0;Nr<8;Nr++){var mo=Dr[Nr].x*N.x,go=Dr[Nr].y*N.y,Pi=Dr[Nr].z*N.z,yr=(Me=mo*Te[0]+go*Te[3]+Pi*Te[6],ye=mo*Te[1]+go*Te[4]+Pi*Te[7],we=mo*Te[2]+go*Te[5]+Pi*Te[8],ue.x+b.x*Me+E.x*ye+C.x*we),ai=ue.y+b.y*Me+E.y*ye+C.y*we,Lr=ue.z+b.z*Me+E.z*ye+C.z*we;Yi.minimizeInPlaceFromFloats(yr,ai,Lr),eo.maximizeInPlaceFromFloats(yr,ai,Lr)}Xo.reConstruct(Yi,eo,a._worldMatrix)}var xo=Or.minimum.multiplyToRef(N,v[1]),vo=Or.maximum.multiplyToRef(N,v[2]),br=vo.addToRef(xo,v[3]).scaleInPlace(.5).addInPlace(w),Ai=vo.subtractToRef(xo,v[4]).scaleInPlace(.5*this._bSphereRadiusFactor),qo=br.subtractToRef(Ai,v[1]),Po=br.addToRef(Ai,v[2]);jo.reConstruct(qo,Po,a._worldMatrix)}B=D+3,X=F+4,Q=$+2}else B+=3*(ie=fe.length),X+=4*ie,Q+=2*ie}if(n){this._computeParticleColor&&((to=a.getVertexBuffer(Y.R.ColorKind))&&!a.isPickable?to.updateDirectly(s,0):a.updateVerticesData(Y.R.ColorKind,s,!1,!1)),this._computeParticleTexture&&((to=a.getVertexBuffer(Y.R.UVKind))&&!a.isPickable?to.updateDirectly(u,0):a.updateVerticesData(Y.R.UVKind,u,!1,!1));var cr=a.getVertexBuffer(Y.R.PositionKind);if(cr&&!a.isPickable?cr.updateDirectly(l,0):a.updateVerticesData(Y.R.PositionKind,l,!1,!1),!a.areNormalsFrozen||a.isFacetDataEnabled){if(this._computeParticleVertex||a.isFacetDataEnabled){var k_=a.isFacetDataEnabled?a.getFacetDataParameters():null;rt.ComputeNormals(l,d,c,k_);for(var Fr=0;Fr<c.length;Fr++)p[Fr]=c[Fr]}var to;a.areNormalsFrozen||((to=a.getVertexBuffer(Y.R.NormalKind))&&!a.isPickable?to.updateDirectly(c,0):a.updateVerticesData(Y.R.NormalKind,c,!1,!1))}if(m){var Ss=this.depthSortedParticles;Ss.sort(this._depthSortFunction);for(var z_=Ss.length,yc=0,bc=0,Tc=0;Tc<z_;Tc++){var Sc=Ss[Tc],W_=Sc.indicesLength,H_=Sc.ind;for(Fr=0;Fr<W_;Fr++)if(d[yc]=h[H_+Fr],yc++,this._pickable&&Fr%3==0){var Ec=this.pickedParticles[bc];Ec.idx=Sc.idx,Ec.faceId=bc,bc++}}}if(this._autoFixFaceOrientation)for(var ba=0,Ko=0;Ko<this.particles.length;Ko++){if((ce=m?this.particles[this.depthSortedParticles[Ko].idx]:this.particles[Ko]).scale.x*ce.scale.y*ce.scale.z<0)for(var yo=0;yo<ce._model._indicesLength;yo+=3){var xc=h[ce._ind+yo];d[ba+yo]=h[ce._ind+yo+1],d[ba+yo+1]=xc}ba+=ce._model._indicesLength}(m||this._autoFixFaceOrientation)&&a.updateIndices(d)}return this._computeBoundingBox&&(a.hasBoundingInfo?a.getBoundingInfo().reConstruct(T,f,a._worldMatrix):a.buildBoundingInfo(T,f,a._worldMatrix)),this._autoUpdateSubMeshes&&this.computeSubMeshes(),this._recomputeInvisibles=!1,this.afterUpdateParticles(t,e,n),this},r.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._normals32=null,this._fixedNormal32=null,this._uvs32=null,this._colors32=null,this.pickedParticles=null,this.pickedBySubMesh=null,this._materials=null,this._materialIndexes=null,this._indicesByMaterial=null,this._idxOfId=null},r.prototype.pickedParticle=function(t){if(t.hit){var e=t.subMeshId,n=t.faceId-this.mesh.subMeshes[e].indexStart/3,i=this.pickedBySubMesh;if(i[e]&&i[e][n])return i[e][n]}return null},r.prototype.getParticleById=function(t){var e=this.particles[t];if(e&&e.id==t)return e;var n=this.particles,i=this._idxOfId[t];if(i!==void 0)return n[i];for(var o=0,a=this.nbParticles;o<a;){var s=n[o];if(s.id==t)return s;o++}return null},r.prototype.getParticlesByShapeId=function(t){var e=[];return this.getParticlesByShapeIdToRef(t,e),e},r.prototype.getParticlesByShapeIdToRef=function(t,e){e.length=0;for(var n=0;n<this.nbParticles;n++){var i=this.particles[n];i.shapeId==t&&e.push(i)}return this},r.prototype.computeSubMeshes=function(){if(!this.mesh||!this._multimaterialEnabled)return this;var t=this.depthSortedParticles;if(this.particles.length>0)for(var e=0;e<this.particles.length;e++){var n=this.particles[e];n.materialIndex||(n.materialIndex=0);var i=t[e];i.materialIndex=n.materialIndex,i.ind=n._ind,i.indicesLength=n._model._indicesLength,i.idx=n.idx}this._sortParticlesByMaterial();var o=this._indicesByMaterial,a=this._materialIndexes,s=this.mesh;s.subMeshes=[];for(var l=s.getTotalVertices(),c=0;c<a.length;c++){var u=o[c],d=o[c+1]-u,h=a[c];new yi(h,0,l,u,d,s)}return this},r.prototype._sortParticlesByMaterial=function(){var t=[0];this._indicesByMaterial=t;var e=[];this._materialIndexes=e;var n=this.depthSortedParticles;n.sort(this._materialSortFunction);var i=n.length,o=this._indices32,a=this._indices,s=0,l=0,c=0,u=n[0].materialIndex;e.push(u),this._pickable&&(this.pickedBySubMesh=[[]],this.pickedParticles=this.pickedBySubMesh[0]);for(var d=0;d<i;d++){var h=n[d],p=h.indicesLength,m=h.ind;h.materialIndex!==u&&(u=h.materialIndex,t.push(c),e.push(u),this._pickable&&(s++,this.pickedBySubMesh[s]=[],l=0));for(var v=0,b=0;b<p;b++){if(o[c]=a[m+b],this._pickable&&b%3==0){var E=this.pickedBySubMesh[s][l];E?(E.idx=h.idx,E.faceId=v):this.pickedBySubMesh[s][l]={idx:h.idx,faceId:v},l++,v++}c++}}return t.push(o.length),this._updatable&&this.mesh.updateIndices(o),this},r.prototype._setMaterialIndexesById=function(){this._materialIndexesById={};for(var t=0;t<this._materials.length;t++){var e=this._materials[t].uniqueId;this._materialIndexesById[e]=t}},r.prototype._filterUniqueMaterialId=function(t){return t.filter(function(e,n,i){return i.indexOf(e)===n})},r.prototype._setDefaultMaterial=function(){return this._defaultMaterial||(this._defaultMaterial=new qt(this.name+"DefaultMaterial",this._scene)),this._defaultMaterial},r.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},r.prototype.setVisibilityBox=function(t){var e=t/2;this.mesh.buildBoundingInfo(new _.Pq(-e,-e,-e),new _.Pq(e,e,e))},Object.defineProperty(r.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(t){this._alwaysVisible=t,this.mesh.alwaysSelectAsActiveMesh=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isVisibilityBoxLocked",{get:function(){return this._isVisibilityBoxLocked},set:function(t){this._isVisibilityBoxLocked=t,this.mesh.getBoundingInfo().isLocked=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleRotation",{get:function(){return this._computeParticleRotation},set:function(t){this._computeParticleRotation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(t){this._computeParticleColor=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(t){this._computeParticleTexture=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleVertex",{get:function(){return this._computeParticleVertex},set:function(t){this._computeParticleVertex=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(t){this._computeBoundingBox=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"depthSortParticles",{get:function(){return this._depthSortParticles},set:function(t){this._depthSortParticles=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"expandable",{get:function(){return this._expandable},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"multimaterialEnabled",{get:function(){return this._multimaterialEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useModelMaterial",{get:function(){return this._useModelMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"materials",{get:function(){return this._materials},enumerable:!1,configurable:!0}),r.prototype.setMultiMaterial=function(t){this._materials=this._filterUniqueMaterialId(t),this._setMaterialIndexesById(),this._multimaterial&&this._multimaterial.dispose(),this._multimaterial=new Vr(this.name+"MultiMaterial",this._scene);for(var e=0;e<this._materials.length;e++)this._multimaterial.subMaterials.push(this._materials[e]);this.computeSubMeshes(),this.mesh.material=this._multimaterial},Object.defineProperty(r.prototype,"multimaterial",{get:function(){return this._multimaterial},set:function(t){this._multimaterial=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"autoUpdateSubMeshes",{get:function(){return this._autoUpdateSubMeshes},set:function(t){this._autoUpdateSubMeshes=t},enumerable:!1,configurable:!0}),r.prototype.initParticles=function(){},r.prototype.recycleParticle=function(t){return t},r.prototype.updateParticle=function(t){return t},r.prototype.updateParticleVertex=function(t,e,n){return this},r.prototype.beforeUpdateParticles=function(t,e,n){},r.prototype.afterUpdateParticles=function(t,e,n){},r}(),Kb=function(){function r(t,e,n,i,o){this.idx=0,this.color=new Ge.ov(1,1,1,1),this.position=Ge.Pq.Zero(),this.rotation=Ge.Pq.Zero(),this.uv=new Ge.I9(0,0),this.velocity=Ge.Pq.Zero(),this.pivot=Ge.Pq.Zero(),this.translateFromPivot=!1,this._pos=0,this._ind=0,this.groupId=0,this.idxInGroup=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this._globalPosition=Ge.Pq.Zero(),this.idx=t,this._group=e,this.groupId=n,this.idxInGroup=i,this._pcs=o}return Object.defineProperty(r.prototype,"size",{get:function(){return this.size},set:function(t){this.size=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(t){this.rotationQuaternion=t},enumerable:!1,configurable:!0}),r.prototype.intersectsMesh=function(t,e){if(!t.hasBoundingInfo)return!1;if(!this._pcs.mesh)throw new Error("Point Cloud System doesnt contain the Mesh");if(e)return t.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));var n=t.getBoundingInfo().boundingBox,i=n.maximumWorld.x,o=n.minimumWorld.x,a=n.maximumWorld.y,s=n.minimumWorld.y,l=n.maximumWorld.z,c=n.minimumWorld.z,u=this.position.x+this._pcs.mesh.position.x,d=this.position.y+this._pcs.mesh.position.y,h=this.position.z+this._pcs.mesh.position.z;return o<=u&&u<=i&&s<=d&&d<=a&&c<=h&&h<=l},r.prototype.getRotationMatrix=function(t){var e;if(this.rotationQuaternion)e=this.rotationQuaternion;else{e=Ge.AA.Quaternion[0];var n=this.rotation;Ge.PT.RotationYawPitchRollToRef(n.y,n.x,n.z,e)}e.toRotationMatrix(t)},r}(),Fl=function(){function r(t,e){this.groupId=t,this._positionFunction=e}return Object.defineProperty(r.prototype,"groupID",{get:function(){return this.groupId},set:function(t){this.groupId=t},enumerable:!1,configurable:!0}),r}();(function(r){r[r.Color=2]="Color",r[r.UV=1]="UV",r[r.Random=0]="Random",r[r.Stated=3]="Stated"})(mf||(mf={}));var nR=function(){function r(t,e,n,i){this.particles=new Array,this.nbParticles=0,this.counter=0,this.vars={},this._promises=[],this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._updatable=!0,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._groups=new Array,this._groupCounter=0,this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeBoundingBox=!1,this._isReady=!1,this.name=t,this._size=e,this._scene=n||Ve.q.LastCreatedScene,i&&i.updatable!==void 0?this._updatable=i.updatable:this._updatable=!0}return Object.defineProperty(r.prototype,"positions",{get:function(){return this._positions32},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"colors",{get:function(){return this._colors32},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"uvs",{get:function(){return this._uvs32},enumerable:!1,configurable:!0}),r.prototype.buildMeshAsync=function(t){var e=this;return Promise.all(this._promises).then(function(){return e._isReady=!0,e._buildMesh(t)})},r.prototype._buildMesh=function(t){this.nbParticles===0&&this.addPoints(1),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors);var e=new rt;e.set(this._positions32,Y.R.PositionKind),this._uvs32.length>0&&e.set(this._uvs32,Y.R.UVKind);var n=0;this._colors32.length>0&&(n=1,e.set(this._colors32,Y.R.ColorKind));var i=new xe(this.name,this._scene);e.applyToMesh(i,this._updatable),this.mesh=i,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var o=t;return o||((o=new qt("point cloud material",this._scene)).emissiveColor=new Ge.v9(n,n,n),o.disableLighting=!0,o.pointsCloud=!0,o.pointSize=this._size),i.material=o,new Promise(function(a){return a(i)})},r.prototype._addParticle=function(t,e,n,i){var o=new Kb(t,e,n,i,this);return this.particles.push(o),o},r.prototype._randomUnitVector=function(t){t.position=new _.Pq(Math.random(),Math.random(),Math.random()),t.color=new Ge.ov(1,1,1,1)},r.prototype._getColorIndicesForCoord=function(t,e,n,i){var o=t._groupImageData,a=n*(4*i)+4*e,s=[a,a+1,a+2,a+3],l=s[1],c=s[2],u=s[3],d=o[s[0]],h=o[l],p=o[c],m=o[u];return new Ge.ov(d/255,h/255,p/255,m)},r.prototype._setPointsColorOrUV=function(t,e,n,i,o,a,s,l){l=l??0,n&&t.updateFacetData();var c=2*t.getBoundingInfo().boundingSphere.radius,u=t.getVerticesData(Y.R.PositionKind),d=t.getIndices(),h=t.getVerticesData(Y.R.UVKind+(l?l+1:"")),p=t.getVerticesData(Y.R.ColorKind),m=_.Pq.Zero();t.computeWorldMatrix();var v=t.getWorldMatrix();if(!v.isIdentity()){u=u.slice(0);for(var b=0;b<u.length/3;b++)_.Pq.TransformCoordinatesFromFloatsToRef(u[3*b],u[3*b+1],u[3*b+2],v,m),u[3*b]=m.x,u[3*b+1]=m.y,u[3*b+2]=m.z}var E,C,T=0,f=0,g=0,S=0,y=0,x=0,R=0,I=0,M=0,D=0,B=0,F=0,X=0,$=_.Pq.Zero(),Q=_.Pq.Zero(),ie=_.Pq.Zero(),q=_.Pq.Zero(),ee=_.Pq.Zero(),te=0,ce=0,fe=0,de=0,Te=0,ue=0,U=_.I9.Zero(),N=_.I9.Zero(),w=_.I9.Zero(),k=_.I9.Zero(),J=_.I9.Zero(),le=0,be=0,ve=0,ye=0,Me=0,we=0,He=0,Ke=0,Qe=0,Je=0,ht=0,mt=0,yt=_.IU.Zero(),zt=_.IU.Zero(),$t=_.IU.Zero(),St=_.IU.Zero(),Ot=_.IU.Zero(),Et=0,Vt=0;s=s||0;for(var ln,Yt=new _.IU(0,0,0,0),Un=_.Pq.Zero(),lr=_.Pq.Zero(),ii=_.Pq.Zero(),Li=0,$r=_.Pq.Zero(),Xo=0,jo=0,Or=new fn(_.Pq.Zero(),new _.Pq(1,0,0)),Dr=_.Pq.Zero(),Yi=0;Yi<d.length/3;Yi++){f=d[3*Yi],g=d[3*Yi+1],S=d[3*Yi+2],y=u[3*f],x=u[3*f+1],R=u[3*f+2],I=u[3*g],M=u[3*g+1],D=u[3*g+2],B=u[3*S],F=u[3*S+1],X=u[3*S+2],$.set(y,x,R),Q.set(I,M,D),ie.set(B,F,X),Q.subtractToRef($,q),ie.subtractToRef(Q,ee),h&&(te=h[2*f],ce=h[2*f+1],fe=h[2*g],de=h[2*g+1],Te=h[2*S],ue=h[2*S+1],U.set(te,ce),N.set(fe,de),w.set(Te,ue),N.subtractToRef(U,k),w.subtractToRef(N,J)),p&&i&&(le=p[4*f],be=p[4*f+1],ve=p[4*f+2],ye=p[4*f+3],Me=p[4*g],we=p[4*g+1],He=p[4*g+2],Ke=p[4*g+3],Qe=p[4*S],Je=p[4*S+1],ht=p[4*S+2],mt=p[4*S+3],yt.set(le,be,ve,ye),zt.set(Me,we,He,Ke),$t.set(Qe,Je,ht,mt),zt.subtractToRef(yt,St),$t.subtractToRef(zt,Ot));for(var eo=void 0,Nr=void 0,mo=void 0,go=void 0,Pi=void 0,yr=void 0,ai=void 0,Lr=void 0,xo=new Ge.v9(0,0,0),vo=new Ge.v9(0,0,0),br=void 0,Ai=void 0,qo=0;qo<e._groupDensity[Yi];qo++)T=this.particles.length,this._addParticle(T,e,this._groupCounter,Yi+qo),Ai=this.particles[T],Et=Math.sqrt((0,qe.RandomRange)(0,1)),Vt=(0,qe.RandomRange)(0,1),E=$.add(q.scale(Et)).add(ee.scale(Et*Vt)),n&&(Un=t.getFacetNormal(Yi).normalize().scale(-1),lr=q.clone().normalize(),ii=_.Pq.Cross(Un,lr),Li=(0,qe.RandomRange)(0,2*Math.PI),$r=lr.scale(Math.cos(Li)).add(ii.scale(Math.sin(Li))),Li=(0,qe.RandomRange)(.1,Math.PI/2),Dr=$r.scale(Math.cos(Li)).add(Un.scale(Math.sin(Li))),Or.origin=E.add(Dr.scale(1e-5)),Or.direction=Dr,Or.length=c,(ln=Or.intersectsMesh(t)).hit&&(jo=ln.pickedPoint.subtract(E).length(),Xo=(0,qe.RandomRange)(0,1)*jo,E.addInPlace(Dr.scale(Xo)))),Ai.position=E.clone(),this._positions.push(Ai.position.x,Ai.position.y,Ai.position.z),i!==void 0?h&&(C=U.add(k.scale(Et)).add(J.scale(Et*Vt)),i?o&&e._groupImageData!==null?(eo=e._groupImgWidth,Nr=e._groupImgHeight,br=this._getColorIndicesForCoord(e,Math.round(C.x*eo),Math.round(C.y*Nr),eo),Ai.color=br,this._colors.push(br.r,br.g,br.b,br.a)):p?(Yt=yt.add(St.scale(Et)).add(Ot.scale(Et*Vt)),Ai.color=new Ge.ov(Yt.x,Yt.y,Yt.z,Yt.w),this._colors.push(Yt.x,Yt.y,Yt.z,Yt.w)):(Yt=yt.set(Math.random(),Math.random(),Math.random(),1),Ai.color=new Ge.ov(Yt.x,Yt.y,Yt.z,Yt.w),this._colors.push(Yt.x,Yt.y,Yt.z,Yt.w)):(Ai.uv=C.clone(),this._uvs.push(Ai.uv.x,Ai.uv.y))):(a?(xo.set(a.r,a.g,a.b),mo=(0,qe.RandomRange)(-s,s),go=(0,qe.RandomRange)(-s,s),Pi=(Lr=xo.toHSV()).r,(yr=Lr.g+mo)<0&&(yr=0),yr>1&&(yr=1),(ai=Lr.b+go)<0&&(ai=0),ai>1&&(ai=1),Ge.v9.HSVtoRGBToRef(Pi,yr,ai,vo),Yt.set(vo.r,vo.g,vo.b,1)):Yt=yt.set(Math.random(),Math.random(),Math.random(),1),Ai.color=new Ge.ov(Yt.x,Yt.y,Yt.z,Yt.w),this._colors.push(Yt.x,Yt.y,Yt.z,Yt.w))}},r.prototype._colorFromTexture=function(t,e,n){var i=this;if(t.material===null)return O.V.Warn(t.name+"has no material."),e._groupImageData=null,void this._setPointsColorOrUV(t,e,n,!0,!1);var o=t.material.getActiveTextures();if(o.length===0)return O.V.Warn(t.name+"has no usable texture."),e._groupImageData=null,void this._setPointsColorOrUV(t,e,n,!0,!1);var a=t.clone();a.setEnabled(!1),this._promises.push(new Promise(function(s){Ki.t.WhenAllReady(o,function(){var l=e._textureNb;l<0&&(l=0),l>o.length-1&&(l=o.length-1);var c=function(){e._groupImgWidth=o[l].getSize().width,e._groupImgHeight=o[l].getSize().height,i._setPointsColorOrUV(a,e,n,!0,!0,void 0,void 0,o[l].coordinatesIndex),a.dispose(),s()};e._groupImageData=null;var u=o[l].readPixels();u?u.then(function(d){e._groupImageData=d,c()}):c()})}))},r.prototype._calculateDensity=function(t,e,n){for(var i,o,a,s,l,c,u,d,h,p,m,v,b=_.Pq.Zero(),E=_.Pq.Zero(),C=_.Pq.Zero(),T=_.Pq.Zero(),f=_.Pq.Zero(),g=_.Pq.Zero(),S=[],y=0,x=n.length/3,R=0;R<x;R++)i=n[3*R],o=n[3*R+1],a=n[3*R+2],s=e[3*i],l=e[3*i+1],c=e[3*i+2],u=e[3*o],d=e[3*o+1],h=e[3*o+2],p=e[3*a],m=e[3*a+1],v=e[3*a+2],b.set(s,l,c),E.set(u,d,h),C.set(p,m,v),E.subtractToRef(b,T),C.subtractToRef(E,f),_.Pq.CrossToRef(T,f,g),y+=.5*g.length(),S[R]=y;var I=new Array(x),M=t;for(R=x-1;R>0;R--){var D=S[R];if(D===0)I[R]=0;else{var B=(D-S[R-1])/D*M,F=Math.floor(B),X=B-F,$=F+ +(Math.random()<X);I[R]=$,M-=$}}return I[0]=M,I},r.prototype.addPoints=function(t,e){e===void 0&&(e=this._randomUnitVector);for(var n,i=new Fl(this._groupCounter,e),o=this.nbParticles,a=0;a<t;a++)n=this._addParticle(o,i,this._groupCounter,a),i&&i._positionFunction&&i._positionFunction(n,o,a),this._positions.push(n.position.x,n.position.y,n.position.z),n.color&&this._colors.push(n.color.r,n.color.g,n.color.b,n.color.a),n.uv&&this._uvs.push(n.uv.x,n.uv.y),o++;return this.nbParticles+=t,this._groupCounter++,this._groupCounter},r.prototype.addSurfacePoints=function(t,e,n,i,o){var a=n||0;(isNaN(a)||a<0||a>3)&&(a=0);var s=t.getVerticesData(Y.R.PositionKind),l=t.getIndices();this._groups.push(this._groupCounter);var c=new Fl(this._groupCounter,null);switch(c._groupDensity=this._calculateDensity(e,s,l),a===2?c._textureNb=i||0:i=i||new Ge.ov(1,1,1,1),a){case 2:this._colorFromTexture(t,c,!1);break;case 1:this._setPointsColorOrUV(t,c,!1,!1,!1);break;case 0:this._setPointsColorOrUV(t,c,!1);break;case 3:this._setPointsColorOrUV(t,c,!1,void 0,void 0,i,o)}return this.nbParticles+=e,this._groupCounter++,this._groupCounter-1},r.prototype.addVolumePoints=function(t,e,n,i,o){var a=n||0;(isNaN(a)||a<0||a>3)&&(a=0);var s=t.getVerticesData(Y.R.PositionKind),l=t.getIndices();this._groups.push(this._groupCounter);var c=new Fl(this._groupCounter,null);switch(c._groupDensity=this._calculateDensity(e,s,l),a===2?c._textureNb=i||0:i=i||new Ge.ov(1,1,1,1),a){case 2:this._colorFromTexture(t,c,!0);break;case 1:this._setPointsColorOrUV(t,c,!0,!1,!1);break;case 0:this._setPointsColorOrUV(t,c,!0);break;case 3:this._setPointsColorOrUV(t,c,!0,void 0,void 0,i,o)}return this.nbParticles+=e,this._groupCounter++,this._groupCounter-1},r.prototype.setParticles=function(t,e,n){var i,o;if(t===void 0&&(t=0),e===void 0&&(e=this.nbParticles-1),n===void 0&&(n=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(t,e,n);var a=_.AA.Matrix[0],s=this.mesh,l=this._colors32,c=this._positions32,u=this._uvs32,d=_.AA.Vector3,h=d[5].copyFromFloats(1,0,0),p=d[6].copyFromFloats(0,1,0),m=d[7].copyFromFloats(0,0,1),v=d[8].setAll(Number.MAX_VALUE),b=d[9].setAll(-Number.MAX_VALUE);_.uq.IdentityToRef(a);var E=0;if(!((i=this.mesh)===null||i===void 0)&&i.isFacetDataEnabled&&(this._computeBoundingBox=!0),e=e>=this.nbParticles?this.nbParticles-1:e,this._computeBoundingBox&&(t!=0||e!=this.nbParticles-1)){var C=(o=this.mesh)===null||o===void 0?void 0:o.getBoundingInfo();C&&(v.copyFrom(C.minimum),b.copyFrom(C.maximum))}E=0;for(var T=0,f=0,g=0,S=t;S<=e;S++){var y=this.particles[S];T=3*(E=y.idx),f=4*E,g=2*E,this.updateParticle(y);var x=y._rotationMatrix,R=y.position,I=y._globalPosition;if(this._computeParticleRotation&&y.getRotationMatrix(a),y.parentId!==null){var M=this.particles[y.parentId],D=M._rotationMatrix,B=M._globalPosition,F=R.x*D[1]+R.y*D[4]+R.z*D[7],X=R.x*D[0]+R.y*D[3]+R.z*D[6],$=R.x*D[2]+R.y*D[5]+R.z*D[8];if(I.x=B.x+X,I.y=B.y+F,I.z=B.z+$,this._computeParticleRotation){var Q=a.m;x[0]=Q[0]*D[0]+Q[1]*D[3]+Q[2]*D[6],x[1]=Q[0]*D[1]+Q[1]*D[4]+Q[2]*D[7],x[2]=Q[0]*D[2]+Q[1]*D[5]+Q[2]*D[8],x[3]=Q[4]*D[0]+Q[5]*D[3]+Q[6]*D[6],x[4]=Q[4]*D[1]+Q[5]*D[4]+Q[6]*D[7],x[5]=Q[4]*D[2]+Q[5]*D[5]+Q[6]*D[8],x[6]=Q[8]*D[0]+Q[9]*D[3]+Q[10]*D[6],x[7]=Q[8]*D[1]+Q[9]*D[4]+Q[10]*D[7],x[8]=Q[8]*D[2]+Q[9]*D[5]+Q[10]*D[8]}}else I.x=0,I.y=0,I.z=0,this._computeParticleRotation&&(Q=a.m,x[0]=Q[0],x[1]=Q[1],x[2]=Q[2],x[3]=Q[4],x[4]=Q[5],x[5]=Q[6],x[6]=Q[8],x[7]=Q[9],x[8]=Q[10]);var ie=d[11];y.translateFromPivot?ie.setAll(0):ie.copyFrom(y.pivot);var q=d[0];q.copyFrom(y.position);var ee=q.x-y.pivot.x,te=q.y-y.pivot.y,ce=q.z-y.pivot.z,fe=ee*x[0]+te*x[3]+ce*x[6],de=ee*x[1]+te*x[4]+ce*x[7],Te=ee*x[2]+te*x[5]+ce*x[8];fe+=ie.x,de+=ie.y,Te+=ie.z;var ue=c[T]=I.x+h.x*fe+p.x*de+m.x*Te,U=c[T+1]=I.y+h.y*fe+p.y*de+m.y*Te,N=c[T+2]=I.z+h.z*fe+p.z*de+m.z*Te;if(this._computeBoundingBox&&(v.minimizeInPlaceFromFloats(ue,U,N),b.maximizeInPlaceFromFloats(ue,U,N)),this._computeParticleColor&&y.color){var w=y.color,k=this._colors32;k[f]=w.r,k[f+1]=w.g,k[f+2]=w.b,k[f+3]=w.a}if(this._computeParticleTexture&&y.uv){var J=y.uv,le=this._uvs32;le[g]=J.x,le[g+1]=J.y}}return s&&(n&&(this._computeParticleColor&&s.updateVerticesData(Y.R.ColorKind,l,!1,!1),this._computeParticleTexture&&s.updateVerticesData(Y.R.UVKind,u,!1,!1),s.updateVerticesData(Y.R.PositionKind,c,!1,!1)),this._computeBoundingBox&&(s.hasBoundingInfo?s.getBoundingInfo().reConstruct(v,b,s._worldMatrix):s.buildBoundingInfo(v,b,s._worldMatrix))),this.afterUpdateParticles(t,e,n),this},r.prototype.dispose=function(){var t;(t=this.mesh)===null||t===void 0||t.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._uvs32=null,this._colors32=null},r.prototype.refreshVisibleSize=function(){var t;return this._isVisibilityBoxLocked||(t=this.mesh)===null||t===void 0||t.refreshBoundingInfo(),this},r.prototype.setVisibilityBox=function(t){if(this.mesh){var e=t/2;this.mesh.buildBoundingInfo(new _.Pq(-e,-e,-e),new _.Pq(e,e,e))}},Object.defineProperty(r.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(t){this.mesh&&(this._alwaysVisible=t,this.mesh.alwaysSelectAsActiveMesh=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleRotation",{set:function(t){this._computeParticleRotation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(t){this._computeParticleColor=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(t){this._computeParticleTexture=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(t){this._computeBoundingBox=t},enumerable:!1,configurable:!0}),r.prototype.initParticles=function(){},r.prototype.recycleParticle=function(t){return t},r.prototype.updateParticle=function(t){return t},r.prototype.beforeUpdateParticles=function(t,e,n){},r.prototype.afterUpdateParticles=function(t,e,n){},r}(),iR=L(90821),rR=L(33355),oR=L(45514),aR=L(66348);Object.defineProperty(cn.prototype,"physicsImpostor",{get:function(){return this._physicsImpostor},set:function(r){var t=this;this._physicsImpostor!==r&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsImpostor=r,r&&(this._disposePhysicsObserver=this.onDisposeObservable.add(function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)})))},enumerable:!0,configurable:!0}),cn.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},cn.prototype.applyImpulse=function(r,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(r,t),this):this},cn.prototype.setPhysicsLinkWith=function(r,t,e,n){return this.physicsImpostor&&r.physicsImpostor?(this.physicsImpostor.createJoint(r.physicsImpostor,In.HingeJoint,{mainPivot:t,connectedPivot:e,nativeParams:n}),this):this};var yf,bf,Tf,Sf,Ef,xf,Pf,Zr,Af,Zb=function(){function r(t,e){e===void 0&&(e=r.DefaultPluginFactory()),this._physicsPlugin=e,this._physicsBodies=[],this._subTimeStep=0,t=t||new _.Pq(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return r.prototype.getPluginVersion=function(){return this._physicsPlugin.getPluginVersion()},r.DefaultPluginFactory=function(){throw(0,gt.n)("")},r.prototype.setGravity=function(t){this.gravity=t,this._physicsPlugin.setGravity(this.gravity)},r.prototype.setTimeStep=function(t){t===void 0&&(t=1/60),this._physicsPlugin.setTimeStep(t)},r.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},r.prototype.setSubTimeStep=function(t){t===void 0&&(t=0),this._subTimeStep=t},r.prototype.getSubTimeStep=function(){return this._subTimeStep},r.prototype.dispose=function(){this._physicsPlugin.dispose()},r.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},r.prototype.setVelocityLimits=function(t,e){this._physicsPlugin.setVelocityLimits(t,e)},r.prototype.getMaxLinearVelocity=function(){return this._physicsPlugin.getMaxLinearVelocity()},r.prototype.getMaxAngularVelocity=function(){return this._physicsPlugin.getMaxAngularVelocity()},r.prototype._step=function(t){t>.1?t=.1:t<=0&&(t=1/60),this._physicsPlugin.executeStep(t,this._physicsBodies)},r.prototype.addBody=function(t){this._physicsBodies.push(t)},r.prototype.removeBody=function(t){var e=this._physicsBodies.indexOf(t);e>-1&&this._physicsBodies.splice(e,1)},r.prototype.getBodies=function(){return this._physicsBodies},r.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},r.prototype.raycastToRef=function(t,e,n,i){this._physicsPlugin.raycast(t,e,n,i)},r.prototype.raycast=function(t,e,n){var i=new us;return this._physicsPlugin.raycast(t,e,i,n),i},r}();(function(r){r[r.FREE=0]="FREE",r[r.LIMITED=1]="LIMITED",r[r.LOCKED=2]="LOCKED"})(yf||(yf={})),function(r){r[r.LINEAR_X=0]="LINEAR_X",r[r.LINEAR_Y=1]="LINEAR_Y",r[r.LINEAR_Z=2]="LINEAR_Z",r[r.ANGULAR_X=3]="ANGULAR_X",r[r.ANGULAR_Y=4]="ANGULAR_Y",r[r.ANGULAR_Z=5]="ANGULAR_Z",r[r.LINEAR_DISTANCE=6]="LINEAR_DISTANCE"}(bf||(bf={})),function(r){r[r.BALL_AND_SOCKET=1]="BALL_AND_SOCKET",r[r.DISTANCE=2]="DISTANCE",r[r.HINGE=3]="HINGE",r[r.SLIDER=4]="SLIDER",r[r.LOCK=5]="LOCK",r[r.PRISMATIC=6]="PRISMATIC",r[r.SIX_DOF=7]="SIX_DOF"}(Tf||(Tf={})),function(r){r[r.SPHERE=0]="SPHERE",r[r.CAPSULE=1]="CAPSULE",r[r.CYLINDER=2]="CYLINDER",r[r.BOX=3]="BOX",r[r.CONVEX_HULL=4]="CONVEX_HULL",r[r.CONTAINER=5]="CONTAINER",r[r.MESH=6]="MESH",r[r.HEIGHTFIELD=7]="HEIGHTFIELD"}(Sf||(Sf={})),function(r){r[r.NONE=0]="NONE",r[r.VELOCITY=1]="VELOCITY",r[r.POSITION=2]="POSITION"}(Ef||(Ef={})),function(r){r.COLLISION_STARTED="COLLISION_STARTED",r.COLLISION_CONTINUED="COLLISION_CONTINUED",r.COLLISION_FINISHED="COLLISION_FINISHED",r.TRIGGER_ENTERED="TRIGGER_ENTERED",r.TRIGGER_EXITED="TRIGGER_EXITED"}(xf||(xf={})),function(r){r[r.STATIC=0]="STATIC",r[r.ANIMATED=1]="ANIMATED",r[r.DYNAMIC=2]="DYNAMIC"}(Pf||(Pf={})),function(r){r[r.DISABLED=0]="DISABLED",r[r.TELEPORT=1]="TELEPORT",r[r.ACTION=2]="ACTION"}(Zr||(Zr={})),function(r){r[r.SIMULATION_CONTROLLED=0]="SIMULATION_CONTROLLED",r[r.ALWAYS_ACTIVE=1]="ALWAYS_ACTIVE",r[r.ALWAYS_INACTIVE=2]="ALWAYS_INACTIVE"}(Af||(Af={}));var Cf,Qb=function(){function r(t,e,n,i){var o=this;if(this._pluginData=void 0,this._pluginDataInstances=[],this._collisionCBEnabled=!1,this._collisionEndedCBEnabled=!1,this.disableSync=!1,this._isDisposed=!1,this._shape=null,this._prestepType=Zr.DISABLED,i){var a=i.getPhysicsEngine();if(!a)throw new Error("No Physics Engine available.");if(this._physicsEngine=a,a.getPluginVersion()!=2)throw new Error("Plugin version is incorrect. Expected version 2.");var s=a.getPhysicsPlugin();if(!s)throw new Error("No Physics Plugin available.");this._physicsPlugin=s,t.rotationQuaternion||(t.rotationQuaternion=_.PT.FromEulerAngles(t.rotation.x,t.rotation.y,t.rotation.z)),this.startAsleep=n,this._motionType=e,this.disableSync=e==0;var l=t;l.hasThinInstances?this._physicsPlugin.initBodyInstances(this,e,l):(t.parent&&t.computeWorldMatrix(!0),this._physicsPlugin.initBody(this,e,t.absolutePosition,t.absoluteRotationQuaternion)),this.transformNode=t,t.physicsBody=this,a.addBody(this),this._nodeDisposeObserver=t.onDisposeObservable.add(function(){o.dispose()})}}return Object.defineProperty(r.prototype,"disablePreStep",{get:function(){return this._prestepType==Zr.DISABLED},set:function(t){this._prestepType=t?Zr.DISABLED:Zr.TELEPORT},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"PhysicsBody"},r.prototype.clone=function(t){var e=new r(t,this.getMotionType(),this.startAsleep,this.transformNode.getScene());return e.shape=this.shape,e.setMassProperties(this.getMassProperties()),e.setLinearDamping(this.getLinearDamping()),e.setAngularDamping(this.getAngularDamping()),e},r.prototype.updateBodyInstances=function(){var t=this.transformNode;t.hasThinInstances&&this._physicsPlugin.updateBodyInstances(this,t)},Object.defineProperty(r.prototype,"numInstances",{get:function(){return this._pluginDataInstances.length},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"motionType",{get:function(){return this._motionType},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shape",{get:function(){return this._shape},set:function(t){this._shape=t,t&&this._physicsPlugin.setShape(this,t)},enumerable:!1,configurable:!0}),r.prototype.getBoundingBox=function(){return this._physicsPlugin.getBodyBoundingBox(this)},r.prototype.setEventMask=function(t,e){this._physicsPlugin.setEventMask(this,t,e)},r.prototype.getEventMask=function(t){return this._physicsPlugin.getEventMask(this,t)},r.prototype.setMotionType=function(t,e){this.disableSync=t==0,this._physicsPlugin.setMotionType(this,t,e)},r.prototype.getMotionType=function(t){return this._physicsPlugin.getMotionType(this,t)},r.prototype.setPrestepType=function(t){this._prestepType=t},r.prototype.getPrestepType=function(){return this._prestepType},r.prototype.computeMassProperties=function(t){return this._physicsPlugin.computeMassProperties(this,t)},r.prototype.setMassProperties=function(t,e){this._physicsPlugin.setMassProperties(this,t,e)},r.prototype.getMassProperties=function(t){return this._physicsPlugin.getMassProperties(this,t)},r.prototype.setLinearDamping=function(t,e){this._physicsPlugin.setLinearDamping(this,t,e)},r.prototype.getLinearDamping=function(t){return this._physicsPlugin.getLinearDamping(this,t)},r.prototype.setAngularDamping=function(t,e){this._physicsPlugin.setAngularDamping(this,t,e)},r.prototype.getAngularDamping=function(t){return this._physicsPlugin.getAngularDamping(this,t)},r.prototype.setLinearVelocity=function(t,e){this._physicsPlugin.setLinearVelocity(this,t,e)},r.prototype.getLinearVelocityToRef=function(t,e){this._physicsPlugin.getLinearVelocityToRef(this,t,e)},r.prototype.getLinearVelocity=function(t){var e=new _.Pq;return this.getLinearVelocityToRef(e,t),e},r.prototype.setAngularVelocity=function(t,e){this._physicsPlugin.setAngularVelocity(this,t,e)},r.prototype.getAngularVelocityToRef=function(t,e){this._physicsPlugin.getAngularVelocityToRef(this,t,e)},r.prototype.getAngularVelocity=function(t){var e=new _.Pq;return this.getAngularVelocityToRef(e,t),e},r.prototype.applyImpulse=function(t,e,n){this._physicsPlugin.applyImpulse(this,t,e,n)},r.prototype.applyAngularImpulse=function(t,e){this._physicsPlugin.applyAngularImpulse(this,t,e)},r.prototype.applyForce=function(t,e,n){this._physicsPlugin.applyForce(this,t,e,n)},r.prototype.getGeometry=function(){return this._physicsPlugin.getBodyGeometry(this)},r.prototype.getCollisionObservable=function(){return this._physicsPlugin.getCollisionObservable(this)},r.prototype.getCollisionEndedObservable=function(){return this._physicsPlugin.getCollisionEndedObservable(this)},r.prototype.setCollisionCallbackEnabled=function(t){this._collisionCBEnabled=t,this._physicsPlugin.setCollisionCallbackEnabled(this,t)},r.prototype.setCollisionEndedCallbackEnabled=function(t){this._collisionEndedCBEnabled=t,this._physicsPlugin.setCollisionEndedCallbackEnabled(this,t)},r.prototype.getObjectCenterWorld=function(t){var e=new _.Pq;return this.getObjectCenterWorldToRef(e,t)},r.prototype.getObjectCenterWorldToRef=function(t,e){var n;if(((n=this._pluginDataInstances)===null||n===void 0?void 0:n.length)>0){var i=e||0,o=this.transformNode._thinInstanceDataStorage.matrixData;o&&t.set(o[16*i+12],o[16*i+13],o[16*i+14])}else t.copyFrom(this.transformNode.position);return t},r.prototype.addConstraint=function(t,e,n,i){this._physicsPlugin.addConstraint(this,t,e,n,i)},r.prototype.syncWithBone=function(t,e,n,i,o,a){var s=this.transformNode;if(s.rotationQuaternion)if(o){var l=_.AA.Quaternion[0];t.getRotationQuaternionToRef(1,e,l),l.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(1,e,s.rotationQuaternion);var c=_.AA.Vector3[0],u=_.AA.Vector3[1];a||((a=_.AA.Vector3[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,e,u),t.getAbsolutePositionToRef(e,c),i==null&&n&&(i=n.length()),i!=null&&(c.x+=u.x*i,c.y+=u.y*i,c.z+=u.z*i),s.setAbsolutePosition(c)},r.prototype.iterateOverAllInstances=function(t){var e;if(((e=this._pluginDataInstances)===null||e===void 0?void 0:e.length)>0)for(var n=0;n<this._pluginDataInstances.length;n++)t(this,n);else t(this,void 0)},r.prototype.setGravityFactor=function(t,e){this._physicsPlugin.setGravityFactor(this,t,e)},r.prototype.getGravityFactor=function(t){return this._physicsPlugin.getGravityFactor(this,t)},r.prototype.setTargetTransform=function(t,e,n){this._physicsPlugin.setTargetTransform(this,t,e,n)},Object.defineProperty(r.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._isDisposed||(this._collisionCBEnabled&&this.setCollisionCallbackEnabled(!1),this._collisionEndedCBEnabled&&this.setCollisionEndedCallbackEnabled(!1),this._nodeDisposeObserver&&(this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver),this._nodeDisposeObserver=null),this._physicsEngine.removeBody(this),this._physicsPlugin.removeBody(this),this._physicsPlugin.disposeBody(this),this.transformNode.physicsBody=null,this._pluginData=null,this._pluginDataInstances.length=0,this._isDisposed=!0,this.shape=null)},r}(),gr=function(){function r(t,e){var n;if(this._pluginData=void 0,this._isTrigger=!1,this._isDisposed=!1,e){var i=e.getPhysicsEngine();if(!i)throw new Error("No Physics Engine available.");if(i.getPluginVersion()!=2)throw new Error("Plugin version is incorrect. Expected version 2.");var o=i.getPhysicsPlugin();if(!o)throw new Error("No Physics Plugin available.");if(this._physicsPlugin=o,t.pluginData!==void 0&&t.pluginData!==null)this._pluginData=t.pluginData,this._type=this._physicsPlugin.getShapeType(this);else if(t.type!==void 0&&t.type!==null){this._type=t.type;var a=(n=t.parameters)!==null&&n!==void 0?n:{};this._physicsPlugin.initShape(this,t.type,a)}}}return r.prototype.getClassName=function(){return"PhysicsShape"},Object.defineProperty(r.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"filterMembershipMask",{get:function(){return this._physicsPlugin.getShapeFilterMembershipMask(this)},set:function(t){this._physicsPlugin.setShapeFilterMembershipMask(this,t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"filterCollideMask",{get:function(){return this._physicsPlugin.getShapeFilterCollideMask(this)},set:function(t){this._physicsPlugin.setShapeFilterCollideMask(this,t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"material",{get:function(){return this._material||(this._material=this._physicsPlugin.getMaterial(this)),this._material},set:function(t){this._physicsPlugin.setMaterial(this,t),this._material=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"density",{get:function(){return this._physicsPlugin.getDensity(this)},set:function(t){this._physicsPlugin.setDensity(this,t)},enumerable:!1,configurable:!0}),r.prototype.addChildFromParent=function(t,e,n){var i=n.computeWorldMatrix(!0),o=t.computeWorldMatrix(!0),a=_.AA.Matrix[0];i.multiplyToRef(_.uq.Invert(o),a);var s=_.AA.Vector3[0],l=_.AA.Quaternion[0],c=_.AA.Vector3[1];a.decompose(c,l,s),this._physicsPlugin.addChild(this,e,s,l,c)},r.prototype.addChild=function(t,e,n,i){this._physicsPlugin.addChild(this,t,e,n,i)},r.prototype.removeChild=function(t){this._physicsPlugin.removeChild(this,t)},r.prototype.getNumChildren=function(){return this._physicsPlugin.getNumChildren(this)},r.prototype.getBoundingBox=function(){return this._physicsPlugin.getBoundingBox(this)},Object.defineProperty(r.prototype,"isTrigger",{get:function(){return this._isTrigger},set:function(t){this._isTrigger!==t&&(this._isTrigger=t,this._physicsPlugin.setTrigger(this,t))},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._isDisposed||(this._physicsPlugin.disposeShape(this),this._isDisposed=!0)},r}(),sR=function(r){function t(e,n,i){return r.call(this,{type:0,parameters:{center:e,radius:n}},i)||this}return(0,A.C6)(t,r),t.FromMesh=function(e){var n=e.getBoundingInfo(),i=n.boundingSphere.center,o=n.boundingBox.extendSize;return new t(i,Math.max(o.x,o.y,o.z),e.getScene())},t}(gr),lR=function(r){function t(e,n,i,o){return r.call(this,{type:1,parameters:{pointA:e,pointB:n,radius:i}},o)||this}return(0,A.C6)(t,r),t.FromMesh=function(e){var n=e.getBoundingInfo(),i=n.boundingBox.extendSize.x,o=new _.Pq(0,n.boundingBox.extendSize.y-i,0);return new t(n.boundingBox.center.add(o),n.boundingBox.center.subtract(o),i,e.getScene())},t}(gr),cR=function(r){function t(e,n,i,o){return r.call(this,{type:2,parameters:{pointA:e,pointB:n,radius:i}},o)||this}return(0,A.C6)(t,r),t.FromMesh=function(e){var n=e.getBoundingInfo(),i=n.boundingBox.extendSize.x,o=new _.Pq(0,n.boundingBox.extendSize.y,0);return new t(n.boundingBox.center.add(o),n.boundingBox.center.subtract(o),i,e.getScene())},t}(gr),uR=function(r){function t(e,n,i,o){return r.call(this,{type:3,parameters:{center:e,rotation:n,extents:i}},o)||this}return(0,A.C6)(t,r),t.FromMesh=function(e){var n=e.getBoundingInfo(),i=n.boundingBox.center,o=n.boundingBox.extendSize.scale(2);return new t(i,_.PT.Identity(),o,e.getScene())},t}(gr),dR=function(r){function t(e,n){return r.call(this,{type:4,parameters:{mesh:e}},n)||this}return(0,A.C6)(t,r),t}(gr),hR=function(r){function t(e,n){return r.call(this,{type:6,parameters:{mesh:e}},n)||this}return(0,A.C6)(t,r),t}(gr),fR=function(r){function t(e){return r.call(this,{type:5,parameters:{}},e)||this}return(0,A.C6)(t,r),t}(gr),pR=function(r){function t(e,n,i,o,a,s){return r.call(this,{type:7,parameters:{heightFieldSizeX:e,heightFieldSizeZ:n,numHeightFieldSamplesX:i,numHeightFieldSamplesZ:o,heightFieldData:a}},s)||this}return(0,A.C6)(t,r),t}(gr),_R=function(r){function t(e,n){return r.call(this,{type:7,parameters:{groundMesh:e}},n)||this}return(0,A.C6)(t,r),t}(gr),co=function(){function r(t,e,n){if(this._pluginData=void 0,!n)throw new Error("Missing scene parameter for constraint constructor.");var i=n.getPhysicsEngine();if(!i)throw new Error("No Physics Engine available.");if(i.getPluginVersion()!=2)throw new Error("Plugin version is incorrect. Expected version 2.");var o=i.getPhysicsPlugin();if(!o)throw new Error("No Physics Plugin available.");this._physicsPlugin=o,this._options=e,this._type=t}return Object.defineProperty(r.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isEnabled",{get:function(){return this._physicsPlugin.getEnabled(this)},set:function(t){this._physicsPlugin.setEnabled(this,t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isCollisionsEnabled",{get:function(){return this._physicsPlugin.getCollisionsEnabled(this)},set:function(t){this._physicsPlugin.setCollisionsEnabled(this,t)},enumerable:!1,configurable:!0}),r.prototype.getBodiesUsingConstraint=function(){return this._physicsPlugin.getBodiesUsingConstraint(this)},r.prototype.dispose=function(){this._physicsPlugin.disposeConstraint(this)},r}(),mR=function(){},Jb=function(r){function t(e,n,i){var o=r.call(this,7,e,i)||this;return o.limits=n,o}return(0,A.C6)(t,r),t.prototype.setAxisFriction=function(e,n){this._physicsPlugin.setAxisFriction(this,e,n)},t.prototype.getAxisFriction=function(e){return this._physicsPlugin.getAxisFriction(this,e)},t.prototype.setAxisMode=function(e,n){this._physicsPlugin.setAxisMode(this,e,n)},t.prototype.getAxisMode=function(e){return this._physicsPlugin.getAxisMode(this,e)},t.prototype.setAxisMinLimit=function(e,n){this._physicsPlugin.setAxisMinLimit(this,e,n)},t.prototype.getAxisMinLimit=function(e){return this._physicsPlugin.getAxisMinLimit(this,e)},t.prototype.setAxisMaxLimit=function(e,n){this._physicsPlugin.setAxisMaxLimit(this,e,n)},t.prototype.getAxisMaxLimit=function(e){return this._physicsPlugin.getAxisMaxLimit(this,e)},t.prototype.setAxisMotorType=function(e,n){this._physicsPlugin.setAxisMotorType(this,e,n)},t.prototype.getAxisMotorType=function(e){return this._physicsPlugin.getAxisMotorType(this,e)},t.prototype.setAxisMotorTarget=function(e,n){this._physicsPlugin.setAxisMotorTarget(this,e,n)},t.prototype.getAxisMotorTarget=function(e){return this._physicsPlugin.getAxisMotorTarget(this,e)},t.prototype.setAxisMotorMaxForce=function(e,n){this._physicsPlugin.setAxisMotorMaxForce(this,e,n)},t.prototype.getAxisMotorMaxForce=function(e){return this._physicsPlugin.getAxisMotorMaxForce(this,e)},t}(co),gR=function(r){function t(e,n,i,o,a){return r.call(this,1,{pivotA:e,pivotB:n,axisA:i,axisB:o},a)||this}return(0,A.C6)(t,r),t}(co),vR=function(r){function t(e,n){return r.call(this,2,{maxDistance:e},n)||this}return(0,A.C6)(t,r),t}(co),yR=function(r){function t(e,n,i,o,a){return r.call(this,3,{pivotA:e,pivotB:n,axisA:i,axisB:o},a)||this}return(0,A.C6)(t,r),t}(co),bR=function(r){function t(e,n,i,o,a){return r.call(this,4,{pivotA:e,pivotB:n,axisA:i,axisB:o},a)||this}return(0,A.C6)(t,r),t}(co),TR=function(r){function t(e,n,i,o,a){return r.call(this,5,{pivotA:e,pivotB:n,axisA:i,axisB:o},a)||this}return(0,A.C6)(t,r),t}(co),SR=function(r){function t(e,n,i,o,a){return r.call(this,6,{pivotA:e,pivotB:n,axisA:i,axisB:o},a)||this}return(0,A.C6)(t,r),t}(co),ER=function(r){function t(e,n,i,o,a,s,l,c,u){return r.call(this,{pivotA:e,pivotB:n,axisA:i,axisB:o},[{axis:6,minLimit:a,maxLimit:s,stiffness:l,damping:c}],u)||this}return(0,A.C6)(t,r),t}(Jb);(function(r){r[r.GEOMETRIC_MEAN=0]="GEOMETRIC_MEAN",r[r.MINIMUM=1]="MINIMUM",r[r.MAXIMUM=2]="MAXIMUM",r[r.ARITHMETIC_MEAN=3]="ARITHMETIC_MEAN",r[r.MULTIPLY=4]="MULTIPLY"})(Cf||(Cf={}));var $b=function(){function r(t,e,n,i){n===void 0&&(n={mass:0});var o,a=this;if(this.transformNode=t,this.type=e,this._options=n,this._scene=i,this._disposeShapeWhenDisposed=!0,this.transformNode){var s=t;if(this.transformNode.parent&&this._options.mass!==0&&s.hasThinInstances&&O.V.Warn("A physics body has been created for an object which has a parent and thin instances. Babylon physics currently works in local space so unexpected issues may occur."),!this._scene&&t.getScene&&(this._scene=t.getScene()),this._scene){this._options.mass=n.mass===void 0?0:n.mass,this._options.friction=n.friction===void 0?.2:n.friction,this._options.restitution=n.restitution===void 0?.2:n.restitution;var l=this._options.mass===0?0:2,c=(o=this._options.startAsleep)!==null&&o!==void 0&&o;this.body=new Qb(t,l,c,this._scene),this._addSizeOptions(),e.getClassName&&e.getClassName()==="PhysicsShape"?(this.shape=e,this._disposeShapeWhenDisposed=!1):this.shape=new gr({type:e,parameters:this._options},this._scene),this._options.isTriggerShape&&(this.shape.isTrigger=!0),this.material={friction:this._options.friction,restitution:this._options.restitution},this.body.shape=this.shape,this.shape.material=this.material,this.body.setMassProperties({mass:this._options.mass}),this._nodeDisposeObserver=this.transformNode.onDisposeObservable.add(function(){a.dispose()})}}else O.V.Error("No object was provided. A physics object is obligatory")}return r.prototype._getObjectBoundingBox=function(){return this.transformNode.getRawBoundingInfo?this.transformNode.getRawBoundingInfo().boundingBox:new To(new _.Pq(-.5,-.5,-.5),new _.Pq(.5,.5,.5))},r.prototype._hasVertices=function(t){return t?.getTotalVertices()>0},r.prototype._addSizeOptions=function(){var t,e,n,i,o,a,s,l;this.transformNode.computeWorldMatrix(!0);var c=this._getObjectBoundingBox(),u=_.AA.Vector3[0];u.copyFrom(c.extendSize),u.scaleInPlace(2),u.multiplyInPlace(this.transformNode.absoluteScaling),u.x=Math.abs(u.x),u.y=Math.abs(u.y),u.z=Math.abs(u.z);var d=_.AA.Vector3[1];if(d.copyFrom(c.minimum),d.multiplyInPlace(this.transformNode.absoluteScaling),!this._options.center){var h=new _.Pq;h.copyFrom(c.center),h.multiplyInPlace(this.transformNode.absoluteScaling),this._options.center=h}switch(this.type){case 0:!this._options.radius&&(0,qe.WithinEpsilon)(u.x,u.y,1e-4)&&(0,qe.WithinEpsilon)(u.x,u.z,1e-4)?this._options.radius=u.x/2:this._options.radius||(O.V.Warn("Non uniform scaling is unsupported for sphere shapes. Setting the radius to the biggest bounding box extent."),this._options.radius=Math.max(u.x,u.y,u.z)/2);break;case 1:var p=u.x/2;this._options.radius=(t=this._options.radius)!==null&&t!==void 0?t:p,this._options.pointA=(e=this._options.pointA)!==null&&e!==void 0?e:new _.Pq(0,d.y+p,0),this._options.pointB=(n=this._options.pointB)!==null&&n!==void 0?n:new _.Pq(0,d.y+u.y-p,0);break;case 2:p=u.x/2,this._options.radius=(i=this._options.radius)!==null&&i!==void 0?i:p,this._options.pointA=(o=this._options.pointA)!==null&&o!==void 0?o:new _.Pq(0,d.y,0),this._options.pointB=(a=this._options.pointB)!==null&&a!==void 0?a:new _.Pq(0,d.y+u.y,0);break;case 6:case 4:case 7:if(!this._options.mesh&&this._hasVertices(this.transformNode))this._options.mesh=this.transformNode;else if(!this._options.mesh||!this._hasVertices(this._options.mesh))throw new Error("No valid mesh was provided for mesh or convex hull shape parameter. Please provide a mesh with valid geometry (number of vertices greater than 0).");break;case 3:this._options.extents=(s=this._options.extents)!==null&&s!==void 0?s:new _.Pq(u.x,u.y,u.z),this._options.rotation=(l=this._options.rotation)!==null&&l!==void 0?l:_.PT.Identity()}},r.prototype.dispose=function(){this._nodeDisposeObserver&&(this.body.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver),this._nodeDisposeObserver=null),this.body.dispose(),this._disposeShapeWhenDisposed&&this.shape.dispose()},r}(),xR=function(){},PR=function(){function r(t,e,n){this._boxConfigs=new Array,this._joints=new Array,this._bones=new Array,this._initialRotation=new Array,this._initialRotation2=new Array,this._boneNames=[],this._transforms=new Array,this._aggregates=new Array,this._ragdollMode=!1,this._rootBoneName="",this._rootBoneIndex=-1,this._mass=10,this._restitution=0,this.pauseSync=!1,this._defaultJoint=3,this._defaultJointMin=-90,this._defaultJointMax=90,this._skeleton=t,this._scene=t.getScene(),this._rootTransformNode=e,this._config=n,this._boxConfigs=[],this._putBoxesInBoneCenter=!1,this._defaultJoint=3,this._init()}return r.prototype.getAggregate=function(t){return t<0||t>=this._aggregates.length?this._aggregates[this._rootBoneIndex]:this._aggregates[t]},r.prototype._createColliders=function(){var t,e,n;this._rootTransformNode.computeWorldMatrix(),this._skeleton.computeAbsoluteMatrices(!0),this._skeleton.prepare(!0);for(var i=this._config,o=0;o<i.length;o++)for(var a=i[o].bone!==void 0?[i[o].bone]:i[o].bones,s=0;s<a.length;s++){var l=this._skeleton.bones[this._skeleton.getBoneIndexByName(a[s])];if(l==null)return;var c={width:this._config[o].width,depth:this._config[o].depth,height:this._config[o].height,size:this._config[o].size};c.width=(t=c.width)!==null&&t!==void 0?t:c.size,c.depth=(e=c.depth)!==null&&e!==void 0?e:c.size,c.height=(n=c.height)!==null&&n!==void 0?n:c.size;var u=new jt(a[s]+"_transform",this._scene);c.joint=i[o].joint!==void 0?i[o].joint:this._defaultJoint,c.rotationAxis=i[o].rotationAxis!==void 0?i[o].rotationAxis:Qn._0.X,c.min=i[o].min!==void 0?i[o].min:this._defaultJointMin,c.max=i[o].max!==void 0?i[o].max:this._defaultJointMax;var d=0;i[o].putBoxInBoneCenter!==void 0&&i[o].putBoxInBoneCenter||this._putBoxesInBoneCenter?(l.length===void 0&&O.V.Log("The length property is not defined for bone "+l.name),d=l.length/2):i[o].boxOffset!==void 0&&(d=i[o].boxOffset),c.boxOffset=d;var h=i[o].boneOffsetAxis!==void 0?i[o].boneOffsetAxis:Qn._0.Y,p=l.getDirection(h,this._rootTransformNode);c.boneOffsetAxis=h,u.position=l.getAbsolutePosition(this._rootTransformNode).add(p.scale(d));var m=i[o].mass!==void 0?i[o].mass:this._mass,v=i[o].restitution!==void 0?i[o].restitution:this._restitution,b=new $b(u,3,{mass:m,restitution:v,friction:.6,extents:new _.Pq(c.width,c.height,c.depth)},this._scene);b.body.setCollisionCallbackEnabled(!0),b.body.disablePreStep=!1,b.body.setMotionType(1),this._aggregates.push(b),this._bones.push(l),this._boneNames.push(l.name),this._transforms.push(u),this._boxConfigs.push(c),this._initialRotation.push(l.getRotationQuaternion(1,this._rootTransformNode)),this._initialRotation2.push(l.getRotationQuaternion(1))}},r.prototype._initJoints=function(){this._rootTransformNode.computeWorldMatrix();for(var t=0;t<this._bones.length;t++)if(t!=this._rootBoneIndex){var e=this._findNearestParent(t);if(e==null)return void O.V.Warn("Couldn't find a nearest parent bone in the configs for bone called "+this._boneNames[t]);var n=this._boneNames.indexOf(e.name),i=this._bones[t].getAbsolutePosition(this._rootTransformNode).subtract(this._transforms[n].position),o=this._transforms[n].computeWorldMatrix(),a=_.uq.Invert(o);i=_.Pq.TransformCoordinates(this._bones[t].getAbsolutePosition(this._rootTransformNode),a);var s=this._bones[t].getAbsolutePosition(this._rootTransformNode),l=this._transforms[t].position.clone(),c=s.subtract(l),u=new co(1,{pivotA:i,pivotB:c,axisA:this._boxConfigs[t].rotationAxis,axisB:this._boxConfigs[t].rotationAxis,collision:!1},this._scene);this._aggregates[n].body.addConstraint(this._aggregates[t].body,u),u.isEnabled=!1,this._joints.push(u)}},r.prototype._syncBonesToPhysics=function(){for(var t,e=this._rootTransformNode.getWorldMatrix(),n=0;n<this._bones.length;n++){var i=this._aggregates[n].transformNode,o=this._bones[n].getAbsolutePosition();_.Pq.TransformCoordinatesToRef(o,e,i.position),this._bones[n].getDirectionToRef(this._boxConfigs[n].boneOffsetAxis,this._rootTransformNode,_.AA.Vector3[0]),_.AA.Vector3[0].scaleInPlace((t=this._boxConfigs[n].boxOffset)!==null&&t!==void 0?t:0),i.position.addInPlace(_.AA.Vector3[0]),this._setBoneOrientationToBody(n)}},r.prototype._setBoneOrientationToBody=function(t){var e=this._aggregates[t].transformNode,n=this._bones[t];this._initialRotation[t].conjugateToRef(_.AA.Quaternion[0]),n.getRotationQuaternionToRef(1,this._rootTransformNode,_.AA.Quaternion[1]),_.AA.Quaternion[1].multiplyToRef(_.AA.Quaternion[0],e.rotationQuaternion),e.rotationQuaternion.normalize()},r.prototype._syncBonesAndBoxes=function(){if(!this.pauseSync)if(this._ragdollMode){this._setBodyOrientationToBone(this._rootBoneIndex);var t=this._aggregates[this._rootBoneIndex].body.transformNode.position;this._rootTransformNode.getWorldMatrix().invertToRef(_.AA.Matrix[0]),_.Pq.TransformCoordinatesToRef(t,_.AA.Matrix[0],_.AA.Vector3[0]),this._bones[this._rootBoneIndex].setAbsolutePosition(_.AA.Vector3[0]);for(var e=0;e<this._bones.length;e++)e!=this._rootBoneIndex&&this._setBodyOrientationToBone(e)}else this._syncBonesToPhysics()},r.prototype._setBodyOrientationToBone=function(t){var e,n,i,o=(e=this._rootTransformNode.rotationQuaternion)!==null&&e!==void 0?e:_.PT.FromEulerAngles(this._rootTransformNode.rotation.x,this._rootTransformNode.rotation.y,this._rootTransformNode.rotation.z),a=this._initialRotation2[t],s=(i=(n=this._aggregates[t].body)===null||n===void 0?void 0:n.transformNode)===null||i===void 0?void 0:i.rotationQuaternion;o.multiplyToRef(a,_.AA.Quaternion[1]),s.multiplyToRef(_.AA.Quaternion[1],_.AA.Quaternion[0]),this._bones[t].setRotationQuaternion(_.AA.Quaternion[0],1,this._rootTransformNode)},r.prototype._defineRootBone=function(){var t=this._skeleton.getChildren();return t.length!=1?(O.V.Log("Ragdoll creation failed: there can only be one root in the skeleton."),!1):(this._rootBoneName=t[0].name,this._rootBoneIndex=this._boneNames.indexOf(this._rootBoneName),this._rootBoneIndex!=-1||(O.V.Log("Ragdoll creation failed: the array boneNames doesn't have the root bone. The root bone is "+this._skeleton.getChildren()),!1))},r.prototype._findNearestParent=function(t){var e=this._bones[t].getParent();do{if(e!=null&&this._boneNames.includes(e.name))break;e=e?.getParent()}while(e!=null);return e},r.prototype._init=function(){var t=this;this._createColliders(),this._defineRootBone()&&(this._initJoints(),this._scene.registerBeforeRender(function(){t._syncBonesAndBoxes()}),this._syncBonesToPhysics())},r.prototype.ragdoll=function(){this._ragdollMode=!0,this._skeleton.bones.forEach(function(e){e.linkTransformNode(null)});for(var t=0;t<this._joints.length;t++)this._joints[t].isEnabled=!0;for(t=0;t<this._aggregates.length;t++)this._aggregates[t].body.setMotionType(2)},r.prototype.dispose=function(){this._aggregates.forEach(function(t){t.dispose()})},r}(),yN=function(){function r(t,e,n){this._vertices=[],this._indices=[],this._isRightHanded=n.useRightHandedSystem,this._collectIndices=e}return r.prototype.addNodeMeshes=function(t,e){var n=this;t.computeWorldMatrix(!0);var i=_.AA.Matrix[0];if(_.uq.ScalingToRef(t.absoluteScaling.x,t.absoluteScaling.y,t.absoluteScaling.z,i),t instanceof xe?this._addMesh(t,i):t instanceof Co&&this._addMesh(t.sourceMesh,i),e){var o=_.AA.Matrix[1];t.computeWorldMatrix().invertToRef(o);var a=_.AA.Matrix[2];o.multiplyToRef(i,a),t.getChildMeshes(!1).filter(function(s){return!s.physicsBody}).forEach(function(s){var l=s.computeWorldMatrix(),c=_.AA.Matrix[3];l.multiplyToRef(a,c),s instanceof xe?n._addMesh(s,c):s instanceof Co&&n._addMesh(s.sourceMesh,c)})}},r.prototype._addMesh=function(t,e){for(var n=t.getVerticesData(Y.R.PositionKind)||[],i=n.length/3,o=this._vertices.length,a=0;a<i;a++){var s=new _.Pq(n[3*a+0],n[3*a+1],n[3*a+2]);this._vertices.push(_.Pq.TransformCoordinates(s,e))}if(this._collectIndices){var l=t.getIndices();if(l)for(var c=0;c<l.length;c+=3)this._isRightHanded?(this._indices.push(l[c+0]+o),this._indices.push(l[c+1]+o),this._indices.push(l[c+2]+o)):(this._indices.push(l[c+2]+o),this._indices.push(l[c+1]+o),this._indices.push(l[c+0]+o))}},r.prototype.getVertices=function(t){for(var e=3*this._vertices.length,n=4*e,i=t._malloc(n),o=new Float32Array(t.HEAPU8.buffer,i,e),a=0;a<this._vertices.length;a++)o[3*a+0]=this._vertices[a].x,o[3*a+1]=this._vertices[a].y,o[3*a+2]=this._vertices[a].z;return{offset:i,numObjects:e}},r.prototype.freeBuffer=function(t,e){t._free(e.offset)},r.prototype.getTriangles=function(t){for(var e=4*this._indices.length,n=t._malloc(e),i=new Int32Array(t.HEAPU8.buffer,n,this._indices.length),o=0;o<this._indices.length;o++)i[o]=this._indices[o];return{offset:n,numObjects:this._indices.length}},r}(),AR=function(r){this.hpBodyId=r,this.userMassProps={centerOfMass:void 0,mass:void 0,inertia:void 0,inertiaOrientation:void 0}},CR=function(){this.bodyId=BigInt(0),this.position=new _.Pq,this.normal=new _.Pq},RR=function(){function r(){this.contactOnA=new CR,this.contactOnB=new CR,this.impulseApplied=0,this.type=0}return r.readToRef=function(t,e,n){var i=new Int32Array(t,e),o=new Float32Array(t,e);n.contactOnA.bodyId=BigInt(i[2]),n.contactOnA.position.set(o[10],o[11],o[12]),n.contactOnA.normal.set(o[13],o[14],o[15]),n.contactOnB.bodyId=BigInt(i[18]),n.contactOnB.position.set(o[26],o[27],o[28]),n.contactOnB.normal.set(o[29],o[30],o[31]),n.impulseApplied=o[34],n.type=i[0]},r}(),IR=function(){function r(){this.bodyIdA=BigInt(0),this.bodyIdB=BigInt(0),this.type=0}return r.readToRef=function(t,e,n){var i=new Int32Array(t,e);n.type=i[0],n.bodyIdA=BigInt(i[2]),n.bodyIdB=BigInt(i[6])},r}(),MR=function(){function r(t,e){t===void 0&&(t=!0),e===void 0&&(e=HK),this._useDeltaForWorldStep=t,this._hknp={},this.name="HavokPlugin",this._fixedTimeStep=1/60,this._tmpVec3=(0,st.mI)(3,_.Pq.Zero),this._bodies=new Map,this._shapes=new Map,this._bodyCollisionObservable=new Map,this._constraintToBodyIdPair=new Map,this._bodyCollisionEndedObservable=new Map,this.onCollisionObservable=new K.cP,this.onCollisionEndedObservable=new K.cP,this.onTriggerCollisionObservable=new K.cP,typeof e!="function"?(this._hknp=e,this.isSupported()?(this.world=this._hknp.HP_World_Create()[1],this._queryCollector=this._hknp.HP_QueryCollector_Create(1)[1]):O.V.Error("Havok is not available. Please make sure you included the js file.")):O.V.Error("Havok is not ready. Please make sure you await HK() before using the plugin.")}return r.prototype.isSupported=function(){return this._hknp!==void 0},r.prototype.setGravity=function(t){this._hknp.HP_World_SetGravity(this.world,this._bVecToV3(t))},r.prototype.setTimeStep=function(t){this._fixedTimeStep=t},r.prototype.getTimeStep=function(){return this._fixedTimeStep},r.prototype.executeStep=function(t,e){for(var n=0,i=e;n<i.length;n++)(l=i[n]).disablePreStep||this.setPhysicsBodyTransformation(l,l.transformNode);var o=this._useDeltaForWorldStep?t:this._fixedTimeStep;this._hknp.HP_World_SetIdealStepTime(this.world,o),this._hknp.HP_World_Step(this.world,o),this._bodyBuffer=this._hknp.HP_World_GetBodyBuffer(this.world)[1];for(var a=0,s=e;a<s.length;a++){var l;(l=s[a]).disableSync||this.sync(l)}this._notifyCollisions(),this._notifyTriggers()},r.prototype.getPluginVersion=function(){return 2},r.prototype.setVelocityLimits=function(t,e){this._hknp.HP_World_SetSpeedLimit(this.world,t,e)},r.prototype.getMaxLinearVelocity=function(){return this._hknp.HP_World_GetSpeedLimit(this.world)[1]},r.prototype.getMaxAngularVelocity=function(){return this._hknp.HP_World_GetSpeedLimit(this.world)[2]},r.prototype.initBody=function(t,e,n,i){t._pluginData=new AR(this._hknp.HP_Body_Create()[1]),this._internalSetMotionType(t._pluginData,e);var o=[this._bVecToV3(n),this._bQuatToV4(i)];this._hknp.HP_Body_SetQTransform(t._pluginData.hpBodyId,o),this._hknp.HP_World_AddBody(this.world,t._pluginData.hpBodyId,t.startAsleep),this._bodies.set(t._pluginData.hpBodyId[0],{body:t,index:0})},r.prototype.removeBody=function(t){if(t._pluginDataInstances&&t._pluginDataInstances.length>0)for(var e=0,n=t._pluginDataInstances;e<n.length;e++){var i=n[e];this._bodyCollisionObservable.delete(i.hpBodyId[0]),this._hknp.HP_World_RemoveBody(this.world,i.hpBodyId),this._bodies.delete(i.hpBodyId[0])}t._pluginData&&(this._bodyCollisionObservable.delete(t._pluginData.hpBodyId[0]),this._hknp.HP_World_RemoveBody(this.world,t._pluginData.hpBodyId),this._bodies.delete(t._pluginData.hpBodyId[0]))},r.prototype.initBodyInstances=function(t,e,n){var i,o,a=this,s=(o=(i=n._thinInstanceDataStorage)===null||i===void 0?void 0:i.instancesCount)!==null&&o!==void 0?o:0,l=n._thinInstanceDataStorage.matrixData;l&&(this._createOrUpdateBodyInstances(t,e,l,0,s,!1),t._pluginDataInstances.forEach(function(c,u){a._bodies.set(c.hpBodyId[0],{body:t,index:u})}))},r.prototype._createOrUpdateBodyInstances=function(t,e,n,i,o,a){for(var s=_.AA.Quaternion[0],l=_.uq.Identity(),c=i;c<o;c++){var u,d=[n[16*c+12],n[16*c+13],n[16*c+14]];u=a?t._pluginDataInstances[c].hpBodyId:this._hknp.HP_Body_Create()[1],l.setRowFromFloats(0,n[16*c+0],n[16*c+1],n[16*c+2],0),l.setRowFromFloats(1,n[16*c+4],n[16*c+5],n[16*c+6],0),l.setRowFromFloats(2,n[16*c+8],n[16*c+9],n[16*c+10],0),_.PT.FromRotationMatrixToRef(l,s);var h=[d,[s.x,s.y,s.z,s.w]];if(this._hknp.HP_Body_SetQTransform(u,h),!a){var p=new AR(u);t._pluginDataInstances.length&&(p.userMassProps=t._pluginDataInstances[0].userMassProps),this._internalSetMotionType(p,e),this._internalUpdateMassProperties(p),t._pluginDataInstances.push(p),this._hknp.HP_World_AddBody(this.world,u,t.startAsleep),p.worldTransformOffset=this._hknp.HP_Body_GetWorldTransformOffset(u)[1]}}},r.prototype.updateBodyInstances=function(t,e){var n,i,o,a=(i=(n=e._thinInstanceDataStorage)===null||n===void 0?void 0:n.instancesCount)!==null&&i!==void 0?i:0,s=e._thinInstanceDataStorage.matrixData;if(s){var l=t._pluginDataInstances.length,c=this.getMotionType(t);if(a>l){this._createOrUpdateBodyInstances(t,c,s,l,a,!1);var u=this._hknp.HP_Body_GetShape(t._pluginDataInstances[0].hpBodyId)[1];u[0]||(u[0]=(o=t.shape)===null||o===void 0?void 0:o._pluginData[0]);for(var d=l;d<a;d++)this._hknp.HP_Body_SetShape(t._pluginDataInstances[d].hpBodyId,u),this._internalUpdateMassProperties(t._pluginDataInstances[d]),this._bodies.set(t._pluginDataInstances[d].hpBodyId[0],{body:t,index:d})}else if(a<l){var h=l-a;for(d=0;d<h;d++){var p=t._pluginDataInstances.pop();this._bodies.delete(p.hpBodyId[0]),this._hknp.HP_World_RemoveBody(this.world,p.hpBodyId),this._hknp.HP_Body_Release(p.hpBodyId)}this._createOrUpdateBodyInstances(t,c,s,0,a,!0)}}},r.prototype.sync=function(t){this.syncTransform(t,t.transformNode)},r.prototype.syncTransform=function(t,e){var n;if(t._pluginDataInstances.length){var i=e,o=i._thinInstanceDataStorage.matrixData;if(!o)return;for(var a=t._pluginDataInstances.length,s=0;s<a;s++){for(var l=t._pluginDataInstances[s].worldTransformOffset,c=new Float32Array(this._hknp.HEAPU8.buffer,this._bodyBuffer+l,16),u=16*s,d=0;d<15;d++)3&~d&&(o[u+d]=c[d]);o[u+15]=1}i.thinInstanceBufferUpdated("matrix")}else try{var h=this._hknp.HP_Body_GetQTransform(t._pluginData.hpBodyId)[1],p=h[0],m=h[1],v=_.AA.Quaternion[0];v.set(m[0],m[1],m[2],m[3]);var b=e.parent;if(b&&!b.getWorldMatrix().isIdentity()){b.computeWorldMatrix(!0),_.AA.Vector3[1].copyFrom(e.scaling),v.normalize();var E=_.AA.Matrix[0],C=_.AA.Vector3[0];C.copyFromFloats(p[0],p[1],p[2]),_.uq.ComposeToRef(e.absoluteScaling,v,C,E);var T=_.AA.Matrix[1];b.getWorldMatrix().invertToRef(T);var f=_.AA.Matrix[2];E.multiplyToRef(T,f),f.decomposeToTransformNode(e),(n=e.rotationQuaternion)===null||n===void 0||n.normalize(),e.scaling.copyFrom(_.AA.Vector3[1])}else e.position.set(p[0],p[1],p[2]),e.rotationQuaternion?e.rotationQuaternion.copyFrom(v):v.toEulerAnglesToRef(e.rotation)}catch(g){O.V.Error("Syncing transform failed for node ".concat(e.name,": ").concat(g.message,"..."))}},r.prototype.setShape=function(t,e){var n,i,o,a=e&&e._pluginData?e._pluginData:BigInt(0);if(!(t.transformNode instanceof xe&&(!((n=t.transformNode._thinInstanceDataStorage)===null||n===void 0)&&n.matrixData)))return this._hknp.HP_Body_SetShape(t._pluginData.hpBodyId,a),void this._internalUpdateMassProperties(t._pluginData);for(var s=(o=(i=t.transformNode._thinInstanceDataStorage)===null||i===void 0?void 0:i.instancesCount)!==null&&o!==void 0?o:0,l=0;l<s;l++)this._hknp.HP_Body_SetShape(t._pluginDataInstances[l].hpBodyId,a),this._internalUpdateMassProperties(t._pluginDataInstances[l])},r.prototype._getPluginReference=function(t,e){var n;return!((n=t._pluginDataInstances)===null||n===void 0)&&n.length?t._pluginDataInstances[e??0]:t._pluginData},r.prototype.getShape=function(t){var e=this._getPluginReference(t),n=this._hknp.HP_Body_GetShape(e.hpBodyId)[1];if(n!=0){var i=t.transformNode.getScene();return new gr({pluginData:n},i)}return null},r.prototype.getShapeType=function(t){return t.type?t.type:this._hknp.HP_Shape_GetType(t._pluginData)},r.prototype.setEventMask=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._hknp.HP_Body_SetEventMask(o.hpBodyId,e)},n)},r.prototype.getEventMask=function(t,e){var n=this._getPluginReference(t,e);return this._hknp.HP_Body_GetEventMask(n.hpBodyId)[1]},r.prototype._fromMassPropertiesTuple=function(t){return{centerOfMass:_.Pq.FromArray(t[0]),mass:t[1],inertia:_.Pq.FromArray(t[2]),inertiaOrientation:_.PT.FromArray(t[3])}},r.prototype._internalUpdateMassProperties=function(t){var e=this._internalComputeMassProperties(t),n=t.userMassProps;n.centerOfMass&&(e[0]=n.centerOfMass.asArray()),n.mass!=null&&(e[1]=n.mass),n.inertia&&(e[2]=n.inertia.asArray()),n.inertiaOrientation&&(e[3]=n.inertiaOrientation.asArray()),this._hknp.HP_Body_SetMassProperties(t.hpBodyId,e)},r.prototype._internalSetMotionType=function(t,e){switch(e){case 0:this._hknp.HP_Body_SetMotionType(t.hpBodyId,this._hknp.MotionType.STATIC);break;case 1:this._hknp.HP_Body_SetMotionType(t.hpBodyId,this._hknp.MotionType.KINEMATIC);break;case 2:this._hknp.HP_Body_SetMotionType(t.hpBodyId,this._hknp.MotionType.DYNAMIC)}},r.prototype.setMotionType=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._internalSetMotionType(o,e)},n)},r.prototype.getMotionType=function(t,e){var n=this._getPluginReference(t,e),i=this._hknp.HP_Body_GetMotionType(n.hpBodyId)[1];switch(i){case this._hknp.MotionType.STATIC:return 0;case this._hknp.MotionType.KINEMATIC:return 1;case this._hknp.MotionType.DYNAMIC:return 2}throw new Error("Unknown motion type: "+i)},r.prototype.setActivationControl=function(t,e){switch(e){case 1:this._hknp.HP_Body_SetActivationControl(t._pluginData.hpBodyId,this._hknp.ActivationControl.ALWAYS_ACTIVE);break;case 2:this._hknp.HP_Body_SetActivationControl(t._pluginData.hpBodyId,this._hknp.ActivationControl.ALWAYS_INACTIVE);break;case 0:this._hknp.HP_Body_SetActivationControl(t._pluginData.hpBodyId,this._hknp.ActivationControl.SIMULATION_CONTROLLED)}},r.prototype._internalComputeMassProperties=function(t){var e=this._hknp.HP_Body_GetShape(t.hpBodyId);if(e[0]==this._hknp.Result.RESULT_OK){var n=this._hknp.HP_Shape_BuildMassProperties(e[1]);if(n[0]==this._hknp.Result.RESULT_OK)return n[1]}return[[0,0,0],1,[1,1,1],[0,0,0,1]]},r.prototype.computeMassProperties=function(t,e){var n=this._getPluginReference(t,e),i=this._internalComputeMassProperties(n);return this._fromMassPropertiesTuple(i)},r.prototype.setMassProperties=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){o.userMassProps=e,i._internalUpdateMassProperties(o)},n)},r.prototype.getMassProperties=function(t,e){var n=this._getPluginReference(t,e),i=this._hknp.HP_Body_GetMassProperties(n.hpBodyId)[1];return this._fromMassPropertiesTuple(i)},r.prototype.setLinearDamping=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._hknp.HP_Body_SetLinearDamping(o.hpBodyId,e)},n)},r.prototype.getLinearDamping=function(t,e){var n=this._getPluginReference(t,e);return this._hknp.HP_Body_GetLinearDamping(n.hpBodyId)[1]},r.prototype.setAngularDamping=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._hknp.HP_Body_SetAngularDamping(o.hpBodyId,e)},n)},r.prototype.getAngularDamping=function(t,e){var n=this._getPluginReference(t,e);return this._hknp.HP_Body_GetAngularDamping(n.hpBodyId)[1]},r.prototype.setLinearVelocity=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._hknp.HP_Body_SetLinearVelocity(o.hpBodyId,i._bVecToV3(e))},n)},r.prototype.getLinearVelocityToRef=function(t,e,n){var i=this._getPluginReference(t,n),o=this._hknp.HP_Body_GetLinearVelocity(i.hpBodyId)[1];this._v3ToBvecRef(o,e)},r.prototype._applyToBodyOrInstances=function(t,e,n){var i;if(((i=t._pluginDataInstances)===null||i===void 0?void 0:i.length)>0&&n===void 0)for(var o=0;o<t._pluginDataInstances.length;o++)e(t._pluginDataInstances[o]);else e(this._getPluginReference(t,n))},r.prototype.applyImpulse=function(t,e,n,i){var o=this;this._applyToBodyOrInstances(t,function(a){o._hknp.HP_Body_ApplyImpulse(a.hpBodyId,o._bVecToV3(n),o._bVecToV3(e))},i)},r.prototype.applyAngularImpulse=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._hknp.HP_Body_ApplyAngularImpulse(o.hpBodyId,i._bVecToV3(e))},n)},r.prototype.applyForce=function(t,e,n,i){e.scaleToRef(this.getTimeStep(),this._tmpVec3[0]),this.applyImpulse(t,this._tmpVec3[0],n,i)},r.prototype.setAngularVelocity=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._hknp.HP_Body_SetAngularVelocity(o.hpBodyId,i._bVecToV3(e))},n)},r.prototype.getAngularVelocityToRef=function(t,e,n){var i=this._getPluginReference(t,n),o=this._hknp.HP_Body_GetAngularVelocity(i.hpBodyId)[1];this._v3ToBvecRef(o,e)},r.prototype.setPhysicsBodyTransformation=function(t,e){if(t.getPrestepType()==Zr.TELEPORT){var n=t.transformNode;if(t.numInstances>0){var i=n._thinInstanceDataStorage.matrixData;if(!i)return;var o=t.numInstances;this._createOrUpdateBodyInstances(t,t.getMotionType(),i,0,o,!0)}else this._hknp.HP_Body_SetQTransform(t._pluginData.hpBodyId,this._getTransformInfos(e))}else t.getPrestepType()==Zr.ACTION?this.setTargetTransform(t,e.absolutePosition,e.absoluteRotationQuaternion):t.getPrestepType()==Zr.DISABLED?O.V.Warn("Prestep type is set to DISABLED. Unable to set physics body transformation."):O.V.Warn("Invalid prestep type set to physics body.")},r.prototype.setTargetTransform=function(t,e,n,i){var o=this;this._applyToBodyOrInstances(t,function(a){o._hknp.HP_Body_SetTargetQTransform(a.hpBodyId,[o._bVecToV3(e),o._bQuatToV4(n)])},i)},r.prototype.setGravityFactor=function(t,e,n){var i=this;this._applyToBodyOrInstances(t,function(o){i._hknp.HP_Body_SetGravityFactor(o.hpBodyId,e)},n)},r.prototype.getGravityFactor=function(t,e){var n=this._getPluginReference(t,e);return this._hknp.HP_Body_GetGravityFactor(n.hpBodyId)[1]},r.prototype.disposeBody=function(t){if(t._pluginDataInstances&&t._pluginDataInstances.length>0)for(var e=0,n=t._pluginDataInstances;e<n.length;e++){var i=n[e];this._hknp.HP_Body_Release(i.hpBodyId),i.hpBodyId=void 0}t._pluginData&&(this._hknp.HP_Body_Release(t._pluginData.hpBodyId),t._pluginData.hpBodyId=void 0)},r.prototype._createOptionsFromGroundMesh=function(t){var e=t.groundMesh;if(e){var n,i=e.getVerticesData(Y.R.PositionKind),o=e.computeWorldMatrix(!0),a=[];for(n=0;n<i.length;n+=3)_.Pq.FromArrayToRef(i,n,_.AA.Vector3[0]),_.Pq.TransformCoordinatesToRef(_.AA.Vector3[0],o,_.AA.Vector3[1]),_.AA.Vector3[1].toArray(a,n);i=a;for(var s=~~(Math.sqrt(i.length/3)-1),l=e.getBoundingInfo(),c=Math.min(l.boundingBox.extendSizeWorld.x,l.boundingBox.extendSizeWorld.z),u=l.boundingBox.minimumWorld.x,d=l.boundingBox.minimumWorld.y,h=l.boundingBox.minimumWorld.z,p=new Float32Array((s+1)*(s+1)),m=2*c/s,v=0;v<p.length;v++)p[v]=d;for(v=0;v<i.length;v+=3){var b=Math.round((i[v+0]-u)/m),E=s-Math.round((i[v+2]-h)/m),C=i[v+1]-d;p[E*(s+1)+b]=C}t.numHeightFieldSamplesX=s+1,t.numHeightFieldSamplesZ=s+1,t.heightFieldSizeX=2*l.boundingBox.extendSizeWorld.x,t.heightFieldSizeZ=2*l.boundingBox.extendSizeWorld.z,t.heightFieldData=p}},r.prototype.initShape=function(t,e,n){switch(e){case 0:var i=n.radius||1,o=n.center?this._bVecToV3(n.center):[0,0,0];t._pluginData=this._hknp.HP_Shape_CreateSphere(o,i)[1];break;case 3:var a=n.rotation?this._bQuatToV4(n.rotation):[0,0,0,1],s=n.extents?this._bVecToV3(n.extents):[1,1,1];o=n.center?this._bVecToV3(n.center):[0,0,0],t._pluginData=this._hknp.HP_Shape_CreateBox(o,a,s)[1];break;case 1:var l=n.pointA?this._bVecToV3(n.pointA):[0,0,0],c=n.pointB?this._bVecToV3(n.pointB):[0,1,0];i=n.radius||0,t._pluginData=this._hknp.HP_Shape_CreateCapsule(l,c,i)[1];break;case 5:t._pluginData=this._hknp.HP_Shape_CreateContainer()[1];break;case 2:l=n.pointA?this._bVecToV3(n.pointA):[0,0,0],c=n.pointB?this._bVecToV3(n.pointB):[0,1,0],i=n.radius||0,t._pluginData=this._hknp.HP_Shape_CreateCylinder(l,c,i)[1];break;case 4:case 6:var u=n.mesh;if(!u)throw new Error("No mesh provided to create physics shape.");var d=!!n.includeChildMeshes,h=new yN(u,e!=4,u?.getScene());h.addNodeMeshes(u,d);var p=h.getVertices(this._hknp),m=p.numObjects/3;if(e==4)t._pluginData=this._hknp.HP_Shape_CreateConvexHull(p.offset,m)[1];else{var v=h.getTriangles(this._hknp),b=v.numObjects/3;t._pluginData=this._hknp.HP_Shape_CreateMesh(p.offset,m,v.offset,b)[1],h.freeBuffer(this._hknp,v)}h.freeBuffer(this._hknp,p);break;case 7:if(n.groundMesh&&this._createOptionsFromGroundMesh(n),!(n.numHeightFieldSamplesX&&n.numHeightFieldSamplesZ&&n.heightFieldSizeX&&n.heightFieldSizeZ&&n.heightFieldData))throw new Error("Missing required heightfield parameters");for(var E=n.numHeightFieldSamplesX*n.numHeightFieldSamplesZ,C=4*E,T=this._hknp._malloc(C),f=new Float32Array(this._hknp.HEAPU8.buffer,T,E),g=0;g<n.numHeightFieldSamplesX;g++)for(var S=0;S<n.numHeightFieldSamplesZ;S++){var y=S*n.numHeightFieldSamplesX+g,x=(n.numHeightFieldSamplesX-1-g)*n.numHeightFieldSamplesZ+S;f[y]=n.heightFieldData[x]}var R=n.heightFieldSizeX/(n.numHeightFieldSamplesX-1),I=n.heightFieldSizeZ/(n.numHeightFieldSamplesZ-1);t._pluginData=this._hknp.HP_Shape_CreateHeightField(n.numHeightFieldSamplesX,n.numHeightFieldSamplesZ,[R,1,I],T)[1],this._hknp._free(T);break;default:throw new Error("Unsupported Shape Type.")}this._shapes.set(t._pluginData[0],t)},r.prototype.setShapeFilterMembershipMask=function(t,e){var n=this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][1];this._hknp.HP_Shape_SetFilterInfo(t._pluginData,[e,n])},r.prototype.getShapeFilterMembershipMask=function(t){return this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][0]},r.prototype.setShapeFilterCollideMask=function(t,e){var n=this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][0];this._hknp.HP_Shape_SetFilterInfo(t._pluginData,[n,e])},r.prototype.getShapeFilterCollideMask=function(t){return this._hknp.HP_Shape_GetFilterInfo(t._pluginData)[1][1]},r.prototype.setMaterial=function(t,e){var n,i,o,a,s,l=(n=e.friction)!==null&&n!==void 0?n:.5,c=(i=e.staticFriction)!==null&&i!==void 0?i:l,u=(o=e.restitution)!==null&&o!==void 0?o:0,d=(a=e.frictionCombine)!==null&&a!==void 0?a:1,h=(s=e.restitutionCombine)!==null&&s!==void 0?s:2,p=[c,l,u,this._materialCombineToNative(d),this._materialCombineToNative(h)];this._hknp.HP_Shape_SetMaterial(t._pluginData,p)},r.prototype.getMaterial=function(t){var e=this._hknp.HP_Shape_GetMaterial(t._pluginData)[1];return{staticFriction:e[0],friction:e[1],restitution:e[2],frictionCombine:this._nativeToMaterialCombine(e[3]),restitutionCombine:this._nativeToMaterialCombine(e[4])}},r.prototype.setDensity=function(t,e){this._hknp.HP_Shape_SetDensity(t._pluginData,e)},r.prototype.getDensity=function(t){return this._hknp.HP_Shape_GetDensity(t._pluginData)[1]},r.prototype._getTransformInfos=function(t){if(t.parent)return t.computeWorldMatrix(!0),[this._bVecToV3(t.absolutePosition),this._bQuatToV4(t.absoluteRotationQuaternion)];var e=_.AA.Quaternion[0];if(t.rotationQuaternion)e=t.rotationQuaternion;else{var n=t.rotation;_.PT.FromEulerAnglesToRef(n.x,n.y,n.z,e)}return[this._bVecToV3(t.position),this._bQuatToV4(e)]},r.prototype.addChild=function(t,e,n,i,o){var a=[n?this._bVecToV3(n):[0,0,0],i?this._bQuatToV4(i):[0,0,0,1],o?this._bVecToV3(o):[1,1,1]];this._hknp.HP_Shape_AddChild(t._pluginData,e._pluginData,a)},r.prototype.removeChild=function(t,e){this._hknp.HP_Shape_RemoveChild(t._pluginData,e)},r.prototype.getNumChildren=function(t){return this._hknp.HP_Shape_GetNumChildren(t._pluginData)[1]},r.prototype.setTrigger=function(t,e){this._hknp.HP_Shape_SetTrigger(t._pluginData,e)},r.prototype.getBoundingBox=function(t){var e=this._hknp.HP_Shape_GetBoundingBox(t._pluginData,[[0,0,0],[0,0,0,1]])[1];return _.AA.Vector3[0].set(e[0][0],e[0][1],e[0][2]),_.AA.Vector3[1].set(e[1][0],e[1][1],e[1][2]),new To(_.AA.Vector3[0],_.AA.Vector3[1],_.uq.IdentityReadOnly)},r.prototype.getBodyBoundingBox=function(t){var e=this.getBoundingBox(t.shape);return new To(e.minimum,e.maximum,t.transformNode.getWorldMatrix())},r.prototype.getBodyGeometry=function(t){var e,n=((e=t._pluginDataInstances)===null||e===void 0?void 0:e.length)>0?t._pluginDataInstances[0]:t._pluginData,i=this._hknp.HP_Body_GetShape(n.hpBodyId)[1],o=this._hknp.HP_Shape_CreateDebugDisplayGeometry(i);if(o[0]!=this._hknp.Result.RESULT_OK)return{positions:[],indices:[]};var a=this._hknp.HP_DebugGeometry_GetInfo(o[1])[1],s=new Float32Array(this._hknp.HEAPU8.buffer,a[0],3*a[1]),l=new Uint32Array(this._hknp.HEAPU8.buffer,a[2],3*a[3]),c=s.slice(0),u=l.slice(0);return this._hknp.HP_DebugGeometry_Release(o[1]),{positions:c,indices:u}},r.prototype.disposeShape=function(t){this._hknp.HP_Shape_Release(t._pluginData),t._pluginData=void 0},r.prototype.initConstraint=function(t,e,n,i,o){var a,s,l,c,u,d=t.type,h=t.options;if(d&&h)if(e._pluginDataInstances.length>0&&i===void 0||n._pluginDataInstances.length>0&&o===void 0)O.V.Warn("Body is instanced but no instance index was specified. Constraint will not be applied.");else{t._pluginData=(a=t._pluginData)!==null&&a!==void 0?a:[];var p=this._hknp.HP_Constraint_Create()[1];t._pluginData.push(p);var m=this._getPluginReference(e,i).hpBodyId,v=this._getPluginReference(n,o).hpBodyId;this._hknp.HP_Constraint_SetParentBody(p,m),this._hknp.HP_Constraint_SetChildBody(p,v),this._constraintToBodyIdPair.set(p[0],[m[0],v[0]]);var b=h.pivotA?this._bVecToV3(h.pivotA):this._bVecToV3(_.Pq.Zero()),E=(s=h.axisA)!==null&&s!==void 0?s:new _.Pq(1,0,0),C=this._tmpVec3[0];h.perpAxisA?C.copyFrom(h.perpAxisA):E.getNormalToRef(C),this._hknp.HP_Constraint_SetAnchorInParent(p,b,this._bVecToV3(E),this._bVecToV3(C));var T=h.pivotB?this._bVecToV3(h.pivotB):this._bVecToV3(_.Pq.Zero()),f=(l=h.axisB)!==null&&l!==void 0?l:new _.Pq(1,0,0),g=this._tmpVec3[0];if(h.perpAxisB?g.copyFrom(h.perpAxisB):f.getNormalToRef(g),this._hknp.HP_Constraint_SetAnchorInChild(p,T,this._bVecToV3(f),this._bVecToV3(g)),t._initOptions||(t._initOptions={axisA:E.clone(),axisB:f.clone(),perpAxisA:C.clone(),perpAxisB:g.clone(),pivotA:new _.Pq(b[0],b[1],b[2]),pivotB:new _.Pq(T[0],T[1],T[2])}),d==5)this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(d==2){var S=h.maxDistance||0,y=this._hknp.ConstraintAxis.LINEAR_DISTANCE;this._hknp.HP_Constraint_SetAxisMode(p,y,this._hknp.ConstraintAxisLimitMode.LIMITED),this._hknp.HP_Constraint_SetAxisMinLimit(p,y,S),this._hknp.HP_Constraint_SetAxisMaxLimit(p,y,S)}else if(d==3)this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(d==6)this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(d==4)this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.ANGULAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else if(d==1)this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_X,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Y,this._hknp.ConstraintAxisLimitMode.LOCKED),this._hknp.HP_Constraint_SetAxisMode(p,this._hknp.ConstraintAxis.LINEAR_Z,this._hknp.ConstraintAxisLimitMode.LOCKED);else{if(d!=7)throw new Error("Unsupported Constraint Type.");for(var x=0,R=t.limits;x<R.length;x++){var I=R[x],M=this._constraintAxisToNative(I.axis);((c=I.minLimit)!==null&&c!==void 0?c:-1)==0&&((u=I.maxLimit)!==null&&u!==void 0?u:-1)==0?this._hknp.HP_Constraint_SetAxisMode(p,M,this._hknp.ConstraintAxisLimitMode.LOCKED):(I.minLimit!=null&&(this._hknp.HP_Constraint_SetAxisMode(p,M,this._hknp.ConstraintAxisLimitMode.LIMITED),this._hknp.HP_Constraint_SetAxisMinLimit(p,M,I.minLimit)),I.maxLimit!=null&&(this._hknp.HP_Constraint_SetAxisMode(p,M,this._hknp.ConstraintAxisLimitMode.LIMITED),this._hknp.HP_Constraint_SetAxisMaxLimit(p,M,I.maxLimit))),I.stiffness&&this._hknp.HP_Constraint_SetAxisStiffness(p,M,I.stiffness),I.damping&&this._hknp.HP_Constraint_SetAxisDamping(p,M,I.damping)}}var D=!!h.collision;this._hknp.HP_Constraint_SetCollisionsEnabled(p,D),this._hknp.HP_Constraint_SetEnabled(p,!0)}else O.V.Warn("No constraint type or options. Constraint is invalid.")},r.prototype.getBodiesUsingConstraint=function(t){for(var e=[],n=0,i=t._pluginData;n<i.length;n++){var o=i[n],a=this._constraintToBodyIdPair.get(o[0]);if(a){var s=this._bodies.get(a[0]),l=this._bodies.get(a[1]);s&&l&&e.push({parentBody:s.body,parentBodyIndex:s.index,childBody:l.body,childBodyIndex:l.index})}}return e},r.prototype.addConstraint=function(t,e,n,i,o){this.initConstraint(n,t,e,i,o)},r.prototype.setEnabled=function(t,e){for(var n=0,i=t._pluginData;n<i.length;n++){var o=i[n];this._hknp.HP_Constraint_SetEnabled(o,e)}},r.prototype.getEnabled=function(t){var e=t._pluginData&&t._pluginData[0];return!!e&&this._hknp.HP_Constraint_GetEnabled(e)[1]},r.prototype.setCollisionsEnabled=function(t,e){for(var n=0,i=t._pluginData;n<i.length;n++){var o=i[n];this._hknp.HP_Constraint_SetCollisionsEnabled(o,e)}},r.prototype.getCollisionsEnabled=function(t){var e=t._pluginData&&t._pluginData[0];return!!e&&this._hknp.HP_Constraint_GetCollisionsEnabled(e)[1]},r.prototype.setAxisFriction=function(t,e,n){for(var i=0,o=t._pluginData;i<o.length;i++){var a=o[i];this._hknp.HP_Constraint_SetAxisFriction(a,this._constraintAxisToNative(e),n)}},r.prototype.getAxisFriction=function(t,e){var n=t._pluginData&&t._pluginData[0];return n?this._hknp.HP_Constraint_GetAxisFriction(n,this._constraintAxisToNative(e))[1]:null},r.prototype.setAxisMode=function(t,e,n){for(var i=0,o=t._pluginData;i<o.length;i++){var a=o[i];this._hknp.HP_Constraint_SetAxisMode(a,this._constraintAxisToNative(e),this._limitModeToNative(n))}},r.prototype.getAxisMode=function(t,e){var n=t._pluginData&&t._pluginData[0];if(n){var i=this._hknp.HP_Constraint_GetAxisMode(n,this._constraintAxisToNative(e))[1];return this._nativeToLimitMode(i)}return null},r.prototype.setAxisMinLimit=function(t,e,n){for(var i=0,o=t._pluginData;i<o.length;i++){var a=o[i];this._hknp.HP_Constraint_SetAxisMinLimit(a,this._constraintAxisToNative(e),n)}},r.prototype.getAxisMinLimit=function(t,e){var n=t._pluginData&&t._pluginData[0];return n?this._hknp.HP_Constraint_GetAxisMinLimit(n,this._constraintAxisToNative(e))[1]:null},r.prototype.setAxisMaxLimit=function(t,e,n){for(var i=0,o=t._pluginData;i<o.length;i++){var a=o[i];this._hknp.HP_Constraint_SetAxisMaxLimit(a,this._constraintAxisToNative(e),n)}},r.prototype.getAxisMaxLimit=function(t,e){var n=t._pluginData&&t._pluginData[0];return n?this._hknp.HP_Constraint_GetAxisMaxLimit(n,this._constraintAxisToNative(e))[1]:null},r.prototype.setAxisMotorType=function(t,e,n){for(var i=0,o=t._pluginData;i<o.length;i++){var a=o[i];this._hknp.HP_Constraint_SetAxisMotorType(a,this._constraintAxisToNative(e),this._constraintMotorTypeToNative(n))}},r.prototype.getAxisMotorType=function(t,e){var n=t._pluginData&&t._pluginData[0];return n?this._nativeToMotorType(this._hknp.HP_Constraint_GetAxisMotorType(n,this._constraintAxisToNative(e))[1]):null},r.prototype.setAxisMotorTarget=function(t,e,n){for(var i=0,o=t._pluginData;i<o.length;i++){var a=o[i];this._hknp.HP_Constraint_SetAxisMotorTarget(a,this._constraintAxisToNative(e),n)}},r.prototype.getAxisMotorTarget=function(t,e){return t._pluginData&&t._pluginData[0]?this._hknp.HP_Constraint_GetAxisMotorTarget(t._pluginData,this._constraintAxisToNative(e))[1]:null},r.prototype.setAxisMotorMaxForce=function(t,e,n){for(var i=0,o=t._pluginData;i<o.length;i++){var a=o[i];this._hknp.HP_Constraint_SetAxisMotorMaxForce(a,this._constraintAxisToNative(e),n)}},r.prototype.getAxisMotorMaxForce=function(t,e){var n=t._pluginData&&t._pluginData[0];return n?this._hknp.HP_Constraint_GetAxisMotorMaxForce(n,this._constraintAxisToNative(e))[1]:null},r.prototype.disposeConstraint=function(t){for(var e=0,n=t._pluginData;e<n.length;e++){var i=n[e];this._hknp.HP_Constraint_SetEnabled(i,!1),this._hknp.HP_Constraint_Release(i)}t._pluginData.length=0},r.prototype._populateHitData=function(t,e){var n=this._bodies.get(t[0][0]);e.body=n?.body,e.bodyIndex=n?.index;var i=this._shapes.get(t[1][0]);e.shape=i;var o=t[3],a=t[4],s=t[5];e.setHitData({x:a[0],y:a[1],z:a[2]},{x:o[0],y:o[1],z:o[2]},s)},r.prototype.raycast=function(t,e,n,i){var o,a,s,l=(o=i?.membership)!==null&&o!==void 0?o:-1,c=(a=i?.collideWith)!==null&&a!==void 0?a:-1,u=(s=i?.shouldHitTriggers)!==null&&s!==void 0&&s;n.reset(t,e);var d=[BigInt(0)],h=[this._bVecToV3(t),this._bVecToV3(e),[l,c],u,d];if(this._hknp.HP_World_CastRayWithCollector(this.world,this._queryCollector,h),this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1]>0){var p=this._hknp.HP_QueryCollector_GetCastRayResult(this._queryCollector,0)[1][1];this._populateHitData(p,n),n.calculateHitDistance()}},r.prototype.pointProximity=function(t,e){var n,i,o,a,s=(i=(n=t?.collisionFilter)===null||n===void 0?void 0:n.membership)!==null&&i!==void 0?i:-1,l=(a=(o=t?.collisionFilter)===null||o===void 0?void 0:o.collideWith)!==null&&a!==void 0?a:-1;e.reset();var c=t.ignoreBody?[BigInt(t.ignoreBody._pluginData.hpBodyId[0])]:[BigInt(0)],u=[this._bVecToV3(t.position),t.maxDistance,[s,l],t.shouldHitTriggers,c];if(this._hknp.HP_World_PointProximityWithCollector(this.world,this._queryCollector,u),this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1]>0){var d=this._hknp.HP_QueryCollector_GetPointProximityResult(this._queryCollector,0)[1],h=d[0],p=d[1];this._populateHitData(p,e),e.setHitDistance(h)}},r.prototype.shapeProximity=function(t,e,n){e.reset(),n.reset();var i=t.shape._pluginData,o=t.ignoreBody?[BigInt(t.ignoreBody._pluginData.hpBodyId[0])]:[BigInt(0)],a=[i,this._bVecToV3(t.position),this._bQuatToV4(t.rotation),t.maxDistance,t.shouldHitTriggers,o];if(this._hknp.HP_World_ShapeProximityWithCollector(this.world,this._queryCollector,a),this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1]>0){var s=this._hknp.HP_QueryCollector_GetShapeProximityResult(this._queryCollector,0)[1],l=s[0],c=s[1],u=s[2];this._populateHitData(c,e),this._populateHitData(u,n),e.setHitDistance(l),n.setHitDistance(l)}},r.prototype.shapeCast=function(t,e,n){e.reset(),n.reset();var i=t.shape._pluginData,o=t.ignoreBody?[BigInt(t.ignoreBody._pluginData.hpBodyId[0])]:[BigInt(0)],a=[i,this._bQuatToV4(t.rotation),this._bVecToV3(t.startPosition),this._bVecToV3(t.endPosition),t.shouldHitTriggers,o];if(this._hknp.HP_World_ShapeCastWithCollector(this.world,this._queryCollector,a),this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1]>0){var s=this._hknp.HP_QueryCollector_GetShapeCastResult(this._queryCollector,0)[1],l=s[0],c=s[1],u=s[2];this._populateHitData(c,e),this._populateHitData(u,n),e.setHitFraction(l),n.setHitFraction(l)}},r.prototype.getCollisionObservable=function(t){var e=t._pluginData.hpBodyId[0],n=this._bodyCollisionObservable.get(e);return n||(n=new K.cP,this._bodyCollisionObservable.set(e,n)),n},r.prototype.getCollisionEndedObservable=function(t){var e=t._pluginData.hpBodyId[0],n=this._bodyCollisionEndedObservable.get(e);return n||(n=new K.cP,this._bodyCollisionEndedObservable.set(e,n)),n},r.prototype.setCollisionCallbackEnabled=function(t,e){var n=this,i=this._hknp.EventType.COLLISION_STARTED.value|this._hknp.EventType.COLLISION_CONTINUED.value|this._hknp.EventType.COLLISION_FINISHED.value;t._pluginDataInstances&&t._pluginDataInstances.length?t._pluginDataInstances.forEach(function(o){n._hknp.HP_Body_SetEventMask(o.hpBodyId,e?i:0)}):t._pluginData&&this._hknp.HP_Body_SetEventMask(t._pluginData.hpBodyId,e?i:0)},r.prototype.setCollisionEndedCallbackEnabled=function(t,e){var n=this,i=this._getPluginReference(t),o=this._hknp.HP_Body_GetEventMask(i.hpBodyId)[1];o=e?o|this._hknp.EventType.COLLISION_FINISHED.value:o&~this._hknp.EventType.COLLISION_FINISHED.value,t._pluginDataInstances&&t._pluginDataInstances.length?t._pluginDataInstances.forEach(function(a){n._hknp.HP_Body_SetEventMask(a.hpBodyId,o)}):t._pluginData&&this._hknp.HP_Body_SetEventMask(t._pluginData.hpBodyId,o)},r.prototype._notifyTriggers=function(){for(var t=this._hknp.HP_World_GetTriggerEvents(this.world)[1],e=new IR;t;){IR.readToRef(this._hknp.HEAPU8.buffer,t,e);var n=this._bodies.get(e.bodyIdA),i=this._bodies.get(e.bodyIdB);if(n&&i){var o={collider:n.body,colliderIndex:n.index,collidedAgainst:i.body,collidedAgainstIndex:i.index,type:this._nativeTriggerCollisionValueToCollisionType(e.type)};this.onTriggerCollisionObservable.notifyObservers(o)}t=this._hknp.HP_World_GetNextTriggerEvent(this.world,t)}},r.prototype._notifyCollisions=function(){for(var t=this._hknp.HP_World_GetCollisionEvents(this.world)[1],e=new RR,n=Number(this.world);t;){RR.readToRef(this._hknp.HEAPU8.buffer,t,e);var i=this._bodies.get(e.contactOnA.bodyId),o=this._bodies.get(e.contactOnB.bodyId);if(i&&o){var a={collider:i.body,colliderIndex:i.index,collidedAgainst:o.body,collidedAgainstIndex:o.index,type:this._nativeCollisionValueToCollisionType(e.type)};if(a.type==="COLLISION_FINISHED")this.onCollisionEndedObservable.notifyObservers(a);else{e.contactOnB.position.subtractToRef(e.contactOnA.position,this._tmpVec3[0]);var s=_.Pq.Dot(this._tmpVec3[0],e.contactOnA.normal);a.point=e.contactOnA.position,a.distance=s,a.impulse=e.impulseApplied,a.normal=e.contactOnA.normal,this.onCollisionObservable.notifyObservers(a)}if(this._bodyCollisionObservable.size&&a.type!=="COLLISION_FINISHED"){var l=this._bodyCollisionObservable.get(e.contactOnA.bodyId),c=this._bodyCollisionObservable.get(e.contactOnB.bodyId);if(e.contactOnA.position.subtractToRef(e.contactOnB.position,this._tmpVec3[0]),s=_.Pq.Dot(this._tmpVec3[0],e.contactOnB.normal),l&&l.notifyObservers(a),c){var u={collider:o.body,colliderIndex:o.index,collidedAgainst:i.body,collidedAgainstIndex:i.index,point:e.contactOnB.position,distance:s,impulse:e.impulseApplied,normal:e.contactOnB.normal,type:this._nativeCollisionValueToCollisionType(e.type)};c.notifyObservers(u)}}else this._bodyCollisionEndedObservable.size&&(l=this._bodyCollisionEndedObservable.get(e.contactOnA.bodyId),c=this._bodyCollisionEndedObservable.get(e.contactOnB.bodyId),e.contactOnA.position.subtractToRef(e.contactOnB.position,this._tmpVec3[0]),s=_.Pq.Dot(this._tmpVec3[0],e.contactOnB.normal),l&&l.notifyObservers(a),c&&(u={collider:o.body,colliderIndex:o.index,collidedAgainst:i.body,collidedAgainstIndex:i.index,point:e.contactOnB.position,distance:s,impulse:e.impulseApplied,normal:e.contactOnB.normal,type:this._nativeCollisionValueToCollisionType(e.type)},c.notifyObservers(u)))}t=this._hknp.HP_World_GetNextCollisionEvent(n,t)}},Object.defineProperty(r.prototype,"numBodies",{get:function(){return this._hknp.HP_World_GetNumBodies(this.world)[1]},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._queryCollector&&(this._hknp.HP_QueryCollector_Release(this._queryCollector),this._queryCollector=void 0),this.world&&(this._hknp.HP_World_Release(this.world),this.world=void 0)},r.prototype._v3ToBvecRef=function(t,e){e.set(t[0],t[1],t[2])},r.prototype._bVecToV3=function(t){return[t._x,t._y,t._z]},r.prototype._bQuatToV4=function(t){return[t._x,t._y,t._z,t._w]},r.prototype._constraintMotorTypeToNative=function(t){switch(t){case 2:return this._hknp.ConstraintMotorType.POSITION;case 1:return this._hknp.ConstraintMotorType.VELOCITY}return this._hknp.ConstraintMotorType.NONE},r.prototype._nativeToMotorType=function(t){switch(t){case this._hknp.ConstraintMotorType.POSITION:return 2;case this._hknp.ConstraintMotorType.VELOCITY:return 1}return 0},r.prototype._materialCombineToNative=function(t){switch(t){case 0:return this._hknp.MaterialCombine.GEOMETRIC_MEAN;case 1:return this._hknp.MaterialCombine.MINIMUM;case 2:return this._hknp.MaterialCombine.MAXIMUM;case 3:return this._hknp.MaterialCombine.ARITHMETIC_MEAN;case 4:return this._hknp.MaterialCombine.MULTIPLY}},r.prototype._nativeToMaterialCombine=function(t){switch(t){case this._hknp.MaterialCombine.GEOMETRIC_MEAN:return 0;case this._hknp.MaterialCombine.MINIMUM:return 1;case this._hknp.MaterialCombine.MAXIMUM:return 2;case this._hknp.MaterialCombine.ARITHMETIC_MEAN:return 3;case this._hknp.MaterialCombine.MULTIPLY:return 4;default:return}},r.prototype._constraintAxisToNative=function(t){switch(t){case 0:return this._hknp.ConstraintAxis.LINEAR_X;case 1:return this._hknp.ConstraintAxis.LINEAR_Y;case 2:return this._hknp.ConstraintAxis.LINEAR_Z;case 3:return this._hknp.ConstraintAxis.ANGULAR_X;case 4:return this._hknp.ConstraintAxis.ANGULAR_Y;case 5:return this._hknp.ConstraintAxis.ANGULAR_Z;case 6:return this._hknp.ConstraintAxis.LINEAR_DISTANCE}},r.prototype._nativeToLimitMode=function(t){switch(t){case this._hknp.ConstraintAxisLimitMode.FREE:return 0;case this._hknp.ConstraintAxisLimitMode.LIMITED:return 1;case this._hknp.ConstraintAxisLimitMode.LOCKED:return 2}return 0},r.prototype._limitModeToNative=function(t){switch(t){case 0:return this._hknp.ConstraintAxisLimitMode.FREE;case 1:return this._hknp.ConstraintAxisLimitMode.LIMITED;case 2:return this._hknp.ConstraintAxisLimitMode.LOCKED}},r.prototype._nativeCollisionValueToCollisionType=function(t){switch(t){case this._hknp.EventType.COLLISION_STARTED.value:return"COLLISION_STARTED";case this._hknp.EventType.COLLISION_FINISHED.value:return"COLLISION_FINISHED";case this._hknp.EventType.COLLISION_CONTINUED.value:return"COLLISION_CONTINUED"}return"COLLISION_STARTED"},r.prototype._nativeTriggerCollisionValueToCollisionType=function(t){switch(t){case 8:return"TRIGGER_ENTERED";case 16:return"TRIGGER_EXITED"}return"TRIGGER_ENTERED"},r}();ke.Z.prototype.getPhysicsEngine=function(){return this._physicsEngine},ke.Z.prototype.enablePhysics=function(r,t){if(r===void 0&&(r=null),this._physicsEngine)return!0;var e=this._getComponent(lt.v.NAME_PHYSICSENGINE);e||(e=new bN(this),this._addComponent(e));try{if(t&&t?.getPluginVersion()!==1){if(t?.getPluginVersion()!==2)throw new Error("Unsupported Physics plugin version.");this._physicsEngine=new Zb(r,t)}else this._physicsEngine=new _h(r,t);return this._physicsTimeAccumulator=0,!0}catch(n){return O.V.Error(n.message),!1}},ke.Z.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},ke.Z.prototype.isPhysicsEnabled=function(){return this._physicsEngine!==void 0},ke.Z.prototype.deleteCompoundImpostor=function(r){var t=r.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},ke.Z.prototype._advancePhysicsEngineStep=function(r){if(this._physicsEngine){var t=this._physicsEngine.getSubTimeStep();if(t>0)for(this._physicsTimeAccumulator+=r;this._physicsTimeAccumulator>t;)this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(t/1e3),this.onAfterPhysicsObservable.notifyObservers(this),this._physicsTimeAccumulator-=t;else this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(r/1e3),this.onAfterPhysicsObservable.notifyObservers(this)}};var bN=function(){function r(t){var e=this;this.name=lt.v.NAME_PHYSICSENGINE,this.scene=t,this.scene.onBeforePhysicsObservable=new K.cP,this.scene.onAfterPhysicsObservable=new K.cP,this.scene.getDeterministicFrameTime=function(){return e.scene._physicsEngine?1e3*e.scene._physicsEngine.getTimeStep():1e3/60}}return r.prototype.register=function(){},r.prototype.rebuild=function(){},r.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},r}();Object.defineProperty(jt.prototype,"physicsBody",{get:function(){return this._physicsBody},set:function(r){var t=this;this._physicsBody!==r&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsBody=r,r&&(this._disposePhysicsObserver=this.onDisposeObservable.add(function(){t.physicsBody&&(t.physicsBody.dispose(),t.physicsBody=null)})))},enumerable:!0,configurable:!0}),jt.prototype.getPhysicsBody=function(){return this.physicsBody},jt.prototype.applyImpulse=function(r,t){if(!this.physicsBody)throw new Error("No Physics Body for TransformNode");return this.physicsBody.applyImpulse(r,t),this},jt.prototype.applyAngularImpulse=function(r){if(!this.physicsBody)throw new Error("No Physics Body for TransformNode");return this.physicsBody.applyAngularImpulse(r),this};var Rf,If,pa=function(){function r(){}return r.GetContactPointToRef=function(t,e,n,i,o){var a=t.getScene().getPhysicsEngine(),s=a?.getPluginVersion();if(s===1){var l=new fn(e,n).intersectsMesh(t);if(l.hit&&l.pickedPoint)return i.copyFrom(l.pickedPoint),!0}else if(s===2)return t.physicsBody.getObjectCenterWorldToRef(i,o),!0;return!1},r.HasAppliedForces=function(t,e){var n,i,o;return t.getMotionType(e)===0||((i=(n=t.getMassProperties(e))===null||n===void 0?void 0:n.mass)!==null&&i!==void 0?i:0)===0||((o=t.transformNode)===null||o===void 0?void 0:o.getTotalVertices())===0},r.IsInsideCylinder=function(t,e,n,i){var o=_.AA.Vector3[0];return t.subtractToRef(e,o),Math.abs(o.x)<=n&&Math.abs(o.z)<=n&&o.y>=0&&o.y<=i},r}(),OR=function(){function r(t){this._hitData={force:new _.Pq,contactPoint:new _.Pq,distanceFromOrigin:0},this._scene=t,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||O.V.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return r.prototype.applyRadialExplosionImpulse=function(t,e,n,i){var o=this;if(!this._physicsEngine)return O.V.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;if(this._physicsEngine.getPluginVersion()===1&&this._physicsEngine.getImpostors().length===0||this._physicsEngine.getPluginVersion()===2&&this._physicsEngine.getBodies().length===0)return null;var a=!1;if(typeof e=="number"){var s=e;(e=new _a).radius=s,e.strength=n??e.strength,e.falloff=i??e.falloff}else a=!(!e.affectedImpostorsCallback&&!e.affectedBodiesCallback);var l=new DR(this._scene,e),c=this._hitData;if(this._physicsEngine.getPluginVersion()===1){var u=Array();this._physicsEngine.getImpostors().forEach(function(d){l.getImpostorHitData(d,t,c)&&(d.applyImpulse(c.force,c.contactPoint),a&&u.push({impostor:d,hitData:o._copyPhysicsHitData(c)}))}),l.triggerAffectedImpostorsCallback(u)}else this._applicationForBodies(l,t,c,a,function(d,h){d.applyImpulse(h.force,h.contactPoint,h.instanceIndex)});return l.dispose(!1),l},r.prototype.applyRadialExplosionForce=function(t,e,n,i){var o=this;if(!this._physicsEngine)return O.V.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(this._physicsEngine.getPluginVersion()===1&&this._physicsEngine.getImpostors().length===0||this._physicsEngine.getPluginVersion()===2&&this._physicsEngine.getBodies().length===0)return null;var a=!1;if(typeof e=="number"){var s=e;(e=new _a).radius=s,e.strength=n??e.strength,e.falloff=i??e.falloff}else a=!(!e.affectedImpostorsCallback&&!e.affectedBodiesCallback);var l=new DR(this._scene,e),c=this._hitData;if(this._physicsEngine.getPluginVersion()===1){var u=Array();this._physicsEngine.getImpostors().forEach(function(d){l.getImpostorHitData(d,t,c)&&(d.applyForce(c.force,c.contactPoint),a&&u.push({impostor:d,hitData:o._copyPhysicsHitData(c)}))}),l.triggerAffectedImpostorsCallback(u)}else this._applicationForBodies(l,t,c,a,function(d,h){d.applyForce(h.force,h.contactPoint,h.instanceIndex)});return l.dispose(!1),l},r.prototype._applicationForBodies=function(t,e,n,i,o){for(var a=this,s=Array(),l=0,c=this._physicsEngine.getBodies();l<c.length;l++)c[l].iterateOverAllInstances(function(u,d){t.getBodyHitData(u,e,n,d)&&(o(u,n),i&&s.push({body:u,hitData:a._copyPhysicsHitData(n)}))});t.triggerAffectedBodiesCallback(s)},r.prototype.gravitationalField=function(t,e,n,i){if(!this._physicsEngine)return O.V.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(this._physicsEngine.getPluginVersion()===1&&this._physicsEngine.getImpostors().length===0||this._physicsEngine.getPluginVersion()===2&&this._physicsEngine.getBodies().length===0)return null;if(typeof e=="number"){var o=e;(e=new _a).radius=o,e.strength=n??e.strength,e.falloff=i??e.falloff}var a=new TN(this,this._scene,t,e);return a.dispose(!1),a},r.prototype.updraft=function(t,e,n,i,o){if(!this._physicsEngine)return O.V.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(this._physicsEngine.getPluginVersion()===1&&this._physicsEngine.getImpostors().length===0||this._physicsEngine.getPluginVersion()===2&&this._physicsEngine.getBodies().length===0)return null;if(typeof e=="number"){var a=e;(e=new Mf).radius=a,e.strength=n??e.strength,e.height=i??e.height,e.updraftMode=o??e.updraftMode}var s=new SN(this._scene,t,e);return s.dispose(!1),s},r.prototype.vortex=function(t,e,n,i){if(!this._physicsEngine)return O.V.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(this._physicsEngine.getPluginVersion()===1&&this._physicsEngine.getImpostors().length===0||this._physicsEngine.getPluginVersion()===2&&this._physicsEngine.getBodies().length===0)return null;if(typeof e=="number"){var o=e;(e=new Of).radius=o,e.strength=n??e.strength,e.height=i??e.height}var a=new EN(this._scene,t,e);return a.dispose(!1),a},r.prototype._copyPhysicsHitData=function(t){return{force:t.force.clone(),contactPoint:t.contactPoint.clone(),distanceFromOrigin:t.distanceFromOrigin,instanceIndex:t.instanceIndex}},r}(),DR=function(){function r(t,e){this._scene=t,this._options=e,this._dataFetched=!1,this._options=(0,A.Cl)((0,A.Cl)({},new _a),this._options)}return r.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},r.prototype._getHitData=function(t,e,n,i){var o=_.AA.Vector3[0];o.copyFrom(e).subtractInPlace(n);var a=_.AA.Vector3[1];if(!pa.GetContactPointToRef(t,n,o,a,i.instanceIndex))return!1;var s=_.Pq.Distance(n,a);if(s>this._options.radius)return!1;var l=this._options.falloff===0?this._options.strength:this._options.strength*(1-s/this._options.radius);return o.scaleInPlace(l),i.force.copyFrom(o),i.contactPoint.copyFrom(a),i.distanceFromOrigin=s,!0},r.prototype.getBodyHitData=function(t,e,n,i){if(pa.HasAppliedForces(t,i))return!1;var o=t.transformNode,a=t.getObjectCenterWorld(i);return n.instanceIndex=i,this._getHitData(o,a,e,n)},r.prototype.getImpostorHitData=function(t,e,n){if(t.mass===0||t.object.getClassName()!=="Mesh"&&t.object.getClassName()!=="InstancedMesh")return!1;var i=t.object;if(!this._intersectsWithSphere(i,e,this._options.radius))return!1;var o=t.getObjectCenter();return this._getHitData(i,o,e,n),!0},r.prototype.triggerAffectedImpostorsCallback=function(t){this._options.affectedImpostorsCallback&&this._options.affectedImpostorsCallback(t)},r.prototype.triggerAffectedBodiesCallback=function(t){this._options.affectedBodiesCallback&&this._options.affectedBodiesCallback(t)},r.prototype.dispose=function(t){var e=this;t===void 0&&(t=!0),this._sphere&&(t?this._sphere.dispose():setTimeout(function(){e._dataFetched||e._sphere.dispose()},0))},r.prototype._prepareSphere=function(){this._sphere||(this._sphere=li("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},r.prototype._intersectsWithSphere=function(t,e,n){return this._prepareSphere(),this._sphere.position=e,this._sphere.scaling.setAll(2*n),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(t,!0)},r}(),TN=function(){function r(t,e,n,i){var o=this;this._physicsHelper=t,this._scene=e,this._origin=n,this._options=i,this._dataFetched=!1,this._options=(0,A.Cl)((0,A.Cl)({},new _a),this._options),this._tickCallback=function(){return o._tick()},this._options.strength=-1*this._options.strength}return r.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},r.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},r.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},r.prototype.dispose=function(t){var e=this;t===void 0&&(t=!0),this._sphere&&(t?this._sphere.dispose():setTimeout(function(){e._dataFetched||e._sphere.dispose()},0))},r.prototype._tick=function(){var t;if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);e&&(this._sphere=(t=e.getData().sphere)===null||t===void 0?void 0:t.clone("radialExplosionEventSphereClone"))}},r}(),SN=function(){function r(t,e,n){var i=this;this._scene=t,this._origin=e,this._options=n,this._originTop=_.Pq.Zero(),this._originDirection=_.Pq.Zero(),this._cylinderPosition=_.Pq.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=(0,A.Cl)((0,A.Cl)({},new Mf),this._options),this._origin.addToRef(new _.Pq(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new _.Pq(0,this._options.height,0),this._originTop),this._options.updraftMode===1&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=function(){return i._tick()},this._physicsEngine.getPluginVersion()===1&&this._prepareCylinder()}return r.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},r.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},r.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},r.prototype.dispose=function(t){var e=this;t===void 0&&(t=!0),this._cylinder&&(t?(this._cylinder.dispose(),this._cylinder=void 0):setTimeout(function(){!e._dataFetched&&e._cylinder&&(e._cylinder.dispose(),e._cylinder=void 0)},0))},r.prototype._getHitData=function(t,e){var n;n=this._options.updraftMode===1?this._originDirection:t.subtract(this._originTop);var i=_.Pq.Distance(this._origin,t),o=-1*this._options.strength,a=n.multiplyByFloats(o,o,o);e.force.copyFrom(a),e.contactPoint.copyFrom(t),e.distanceFromOrigin=i},r.prototype._getBodyHitData=function(t,e,n){if(pa.HasAppliedForces(t))return!1;var i=t.getObjectCenterWorld(n);return!!pa.IsInsideCylinder(i,this._origin,this._options.radius,this._options.height)&&(e.instanceIndex=n,this._getHitData(i,e),!0)},r.prototype._getImpostorHitData=function(t,e){if(t.mass===0)return!1;var n=t.object;if(!this._intersectsWithCylinder(n))return!1;var i=t.getObjectCenter();return this._getHitData(i,e),!0},r.prototype._tick=function(){var t=this,e=r._HitData;this._physicsEngine.getPluginVersion()===1?this._physicsEngine.getImpostors().forEach(function(n){t._getImpostorHitData(n,e)&&n.applyForce(e.force,e.contactPoint)}):this._physicsEngine.getBodies().forEach(function(n){n.iterateOverAllInstances(function(i,o){t._getBodyHitData(i,e,o)&&i.applyForce(e.force,e.contactPoint,e.instanceIndex)})})},r.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=_i("updraftEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},r.prototype._intersectsWithCylinder=function(t){return!!this._cylinder&&(this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0))},r._HitData={force:new _.Pq,contactPoint:new _.Pq,distanceFromOrigin:0},r}(),EN=function(){function r(t,e,n){var i=this;this._scene=t,this._origin=e,this._options=n,this._originTop=_.Pq.Zero(),this._cylinderPosition=_.Pq.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=(0,A.Cl)((0,A.Cl)({},new Of),this._options),this._origin.addToRef(new _.Pq(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new _.Pq(0,this._options.height,0),this._originTop),this._tickCallback=function(){return i._tick()},this._physicsEngine.getPluginVersion()===1&&this._prepareCylinder()}return r.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},r.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},r.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},r.prototype.dispose=function(t){var e=this;t===void 0&&(t=!0),this._cylinder&&(t?this._cylinder.dispose():setTimeout(function(){e._dataFetched||e._cylinder.dispose()},0))},r.prototype._getHitData=function(t,e,n){var i=r._OriginOnPlane;i.set(this._origin.x,e.y,this._origin.z);var o=_.AA.Vector3[0];e.subtractToRef(i,o);var a=_.AA.Vector3[1];if(!pa.GetContactPointToRef(t,i,o,a,n.instanceIndex))return!1;var s,l,c,u=_.Pq.Distance(a,i)/this._options.radius,d=_.AA.Vector3[2];if(a.normalizeToRef(d),u>this._options.centripetalForceThreshold&&d.negateInPlace(),u>this._options.centripetalForceThreshold)s=d.x*this._options.centripetalForceMultiplier,l=d.y*this._options.updraftForceMultiplier,c=d.z*this._options.centripetalForceMultiplier;else{var h=_.Pq.Cross(i,e).normalize();s=(h.x+d.x)*this._options.centrifugalForceMultiplier,l=this._originTop.y*this._options.updraftForceMultiplier,c=(h.z+d.z)*this._options.centrifugalForceMultiplier}var p=_.AA.Vector3[3];return p.set(s,l,c),p.scaleInPlace(this._options.strength),n.force.copyFrom(p),n.contactPoint.copyFrom(e),n.distanceFromOrigin=u,!0},r.prototype._getBodyHitData=function(t,e,n){if(pa.HasAppliedForces(t,n))return!1;var i=t.transformNode,o=t.getObjectCenterWorld(n);return!!pa.IsInsideCylinder(o,this._origin,this._options.radius,this._options.height)&&(e.instanceIndex=n,this._getHitData(i,o,e))},r.prototype._getImpostorHitData=function(t,e){if(t.mass===0||t.object.getClassName()!=="Mesh"&&t.object.getClassName()!=="InstancedMesh")return!1;var n=t.object;if(!this._intersectsWithCylinder(n))return!1;var i=t.getObjectCenter();return this._getHitData(n,i,e),!0},r.prototype._tick=function(){var t=this,e=r._HitData;this._physicsEngine.getPluginVersion()===1?this._physicsEngine.getImpostors().forEach(function(n){t._getImpostorHitData(n,e)&&n.applyForce(e.force,e.contactPoint)}):this._physicsEngine.getBodies().forEach(function(n){n.iterateOverAllInstances(function(i,o){t._getBodyHitData(i,e,o)&&i.applyForce(e.force,e.contactPoint,e.instanceIndex)})})},r.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=_i("vortexEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},r.prototype._intersectsWithCylinder=function(t){return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},r._OriginOnPlane=_.Pq.Zero(),r._HitData={force:new _.Pq,contactPoint:new _.Pq,distanceFromOrigin:0},r}(),_a=function(){this.radius=5,this.strength=10,this.falloff=0,this.sphere={segments:32,diameter:1}},Mf=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=0},Of=function(){this.radius=5,this.strength=10,this.height=10,this.centripetalForceThreshold=.7,this.centripetalForceMultiplier=5,this.centrifugalForceMultiplier=.5,this.updraftForceMultiplier=.02};(function(r){r[r.Constant=0]="Constant",r[r.Linear=1]="Linear"})(Rf||(Rf={})),function(r){r[r.Center=0]="Center",r[r.Perpendicular=1]="Perpendicular"}(If||(If={}));var NR=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._hitDistance=0,e}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),t.prototype.setHitDistance=function(e){this._hitDistance=e},t.prototype.reset=function(){r.prototype.reset.call(this),this._hitDistance=0},t}(Iv),LR=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._hitFraction=0,e}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"hitFraction",{get:function(){return this._hitFraction},enumerable:!1,configurable:!0}),t.prototype.setHitFraction=function(e){this._hitFraction=e},t}(Iv),eT=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e,"blackAndWhite",["degree"],null,n,i,o,a,s)||this;return l.degree=1,l.onApplyObservable.add(function(c){c.setFloat("degree",l.degree)}),l}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"BlackAndWhitePostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,44520)))):n.push(Promise.resolve().then(L.bind(L,5439))),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"degree",void 0),t}(_t.w);(0,j.Y5)("BABYLON.BlackAndWhitePostProcess",eT);var Ut=function(){function r(t,e,n,i){this._name=e,this._singleInstance=i||!0,this._getPostProcesses=n,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(r.prototype,"isSupported",{get:function(){for(var t in this._postProcesses)if(Object.prototype.hasOwnProperty.call(this._postProcesses,t)){for(var e=this._postProcesses[t],n=0;n<e.length;n++)if(!e[n].isSupported)return!1}return!0},enumerable:!1,configurable:!0}),r.prototype._update=function(){},r.prototype._attachCameras=function(t){var e,n=this,i=ze.S0.MakeArray(t||this._cameras);if(i)for(var o=function(l){var c=i[l];if(!c)return"continue";var u=c.name;if(e=a._singleInstance?0:u,!a._postProcesses[e]){var d=a._getPostProcesses();d&&(a._postProcesses[e]=Array.isArray(d)?d:[d])}a._indicesForCamera[u]||(a._indicesForCamera[u]=[]),a._postProcesses[e].forEach(function(h){var p=c.attachPostProcess(h);n._indicesForCamera[u].push(p)}),a._cameras[u]||(a._cameras[u]=c)},a=this,s=0;s<i.length;s++)o(s)},r.prototype._detachCameras=function(t){var e=ze.S0.MakeArray(t||this._cameras);if(e)for(var n=function(a){var s=e[a],l=s.name,c=i._postProcesses[i._singleInstance?0:l];c&&c.forEach(function(u){s.detachPostProcess(u)}),i._cameras[l]&&(i._cameras[l]=null),delete i._indicesForCamera[l]},i=this,o=0;o<e.length;o++)n(o)},r.prototype._enable=function(t){var e=ze.S0.MakeArray(t||this._cameras);if(e)for(var n=0;n<e.length;n++)for(var i=e[n],o=i.name,a=this._singleInstance?0:o,s=0;s<this._indicesForCamera[o].length;s++){var l=this._indicesForCamera[o][s];i._postProcesses[l]==null&&e[n].attachPostProcess(this._postProcesses[a][s],l)}},r.prototype._disable=function(t){var e=ze.S0.MakeArray(t||this._cameras);if(e)for(var n=function(a){var s=e[a],l=s.name;i._postProcesses[i._singleInstance?0:l].forEach(function(c){s.detachPostProcess(c)})},i=this,o=0;o<e.length;o++)n(o)},r.prototype.getPostProcesses=function(t){return this._singleInstance?this._postProcesses[0]:t?this._postProcesses[t.name]:null},r}(),Df=function(r){function t(e,n,i,o,a,s,l,c){l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT),c===void 0&&(c=!1);var u=r.call(this,e,"extractHighlights",["threshold","exposure"],null,n,i,o,a,s,null,l,void 0,null,c)||this;return u.threshold=.9,u._exposure=1,u._inputPostProcess=null,u.onApplyObservable.add(function(d){u.externalTextureSamplerBinding=!!u._inputPostProcess,u._inputPostProcess&&d.setTextureFromPostProcess("textureSampler",u._inputPostProcess),d.setFloat("threshold",Math.pow(u.threshold,pt.rv)),d.setFloat("exposure",u._exposure)}),u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ExtractHighlightsPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,71263)))):n.push(Promise.resolve().then(L.bind(L,57372))),r.prototype._gatherImports.call(this,e,n)},(0,A.Cg)([(0,V.lK)()],t.prototype,"threshold",void 0),t}(_t.w);(0,j.Y5)("BABYLON.ExtractHighlightsPostProcess",Df);var Nf=function(r){function t(e,n,i,o,a,s,l,c,u,d,h){d===void 0&&(d=P.Y.TEXTURETYPE_UNSIGNED_INT),h===void 0&&(h=!1);var p=r.call(this,e,"bloomMerge",["bloomWeight"],["bloomBlur"],a,s,l,c,u,null,d,void 0,null,!0)||this;return p.weight=1,p.weight=o,p.externalTextureSamplerBinding=!0,p.onApplyObservable.add(function(m){m.setTextureFromPostProcess("textureSampler",n),m.setTextureFromPostProcessOutput("bloomBlur",i),m.setFloat("bloomWeight",p.weight)}),h||p.updateEffect(),p}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"BloomMergePostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,92008)))):n.push(Promise.resolve().then(L.bind(L,25781))),r.prototype._gatherImports.call(this,e,n)},(0,A.Cg)([(0,V.lK)()],t.prototype,"weight",void 0),t}(_t.w);(0,j.Y5)("BABYLON.BloomMergePostProcess",Nf);var Lf=function(r){function t(e,n,i,o,a,s){a===void 0&&(a=0),s===void 0&&(s=!1);var l=r.call(this,e.getEngine(),"bloom",function(){return l._effects},!0)||this;return l._bloomScale=n,l._effects=[],l._downscale=new Df("highlights",1,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,s),l._blurX=new ci("horizontal blur",new _.I9(1,0),10,n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,void 0,s),l._blurX.alwaysForcePOT=!0,l._blurX.autoClear=!1,l._blurY=new ci("vertical blur",new _.I9(0,1),10,n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,void 0,s),l._blurY.alwaysForcePOT=!0,l._blurY.autoClear=!1,l.kernel=o,l._effects=[l._downscale,l._blurX,l._blurY],l._merge=new Nf("bloomMerge",l._downscale,l._blurY,i,n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a,s),l._merge.autoClear=!1,l._effects.push(l._merge),l}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"threshold",{get:function(){return this._downscale.threshold},set:function(e){this._downscale.threshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weight",{get:function(){return this._merge.weight},set:function(e){this._merge.weight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"kernel",{get:function(){return this._blurX.kernel/this._bloomScale},set:function(e){this._blurX.kernel=e*this._bloomScale,this._blurY.kernel=e*this._bloomScale},enumerable:!1,configurable:!0}),t.prototype.disposeEffects=function(e){for(var n=0;n<this._effects.length;n++)this._effects[n].dispose(e)},t.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},t.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},t}(Ut),Ff=function(r){function t(e,n,i,o,a,s,l,c,u,d){u===void 0&&(u=P.Y.TEXTURETYPE_UNSIGNED_INT),d===void 0&&(d=!1);var h=r.call(this,e,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],o,a,s,l,c,null,u,void 0,null,d)||this;return h.aberrationAmount=30,h.radialIntensity=0,h.direction=new _.I9(.707,.707),h.centerPosition=new _.I9(.5,.5),h.screenWidth=n,h.screenHeight=i,h.onApplyObservable.add(function(p){p.setFloat("chromatic_aberration",h.aberrationAmount),p.setFloat("screen_width",n),p.setFloat("screen_height",i),p.setFloat("radialIntensity",h.radialIntensity),p.setFloat2("direction",h.direction.x,h.direction.y),p.setFloat2("centerPosition",h.centerPosition.x,h.centerPosition.y)}),h}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ChromaticAberrationPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,58036))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,95579))])),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.screenWidth,e.screenHeight,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"aberrationAmount",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"radialIntensity",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"direction",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"centerPosition",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"screenWidth",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"screenHeight",void 0),t}(_t.w);(0,j.Y5)("BABYLON.ChromaticAberrationPostProcess",Ff);var wf=function(r){function t(e,n,i,o,a,s,l,c,u){c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=!1);var d=r.call(this,e,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],i,o,a,s,l,null,c,void 0,null,u)||this;return d.lensSize=50,d.fStop=1.4,d.focusDistance=2e3,d.focalLength=50,d._depthTexture=null,d._depthTexture=n,d.onApplyObservable.add(function(h){if(d._depthTexture){h.setTexture("depthSampler",d._depthTexture);var p=d.lensSize/d.fStop*d.focalLength/(d.focusDistance-d.focalLength);h.setFloat("focusDistance",d.focusDistance),h.setFloat("cocPrecalculation",p);var m=d._depthTexture.activeCamera;h.setFloat2("cameraMinMaxZ",m.minZ,m.maxZ-m.minZ)}else O.V.Warn("No depth texture set on CircleOfConfusionPostProcess")}),d}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"CircleOfConfusionPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,78642)))):n.push(Promise.resolve().then(L.bind(L,26345))),r.prototype._gatherImports.call(this,e,n)},Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._depthTexture=e},enumerable:!1,configurable:!0}),(0,A.Cg)([(0,V.lK)()],t.prototype,"lensSize",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"fStop",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"focusDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"focalLength",void 0),t}(_t.w);(0,j.Y5)("BABYLON.CircleOfConfusionPostProcess",wf);var tT=function(r){function t(e,n,i,o,a,s,l){var c=r.call(this,e,"colorCorrection",null,["colorTable"],i,o,a,s,l)||this,u=o?.getScene()||null;return c._colorTableTexture=new Ie.g(n,u,!0,!1,Ie.g.TRILINEAR_SAMPLINGMODE),c._colorTableTexture.anisotropicFilteringLevel=1,c._colorTableTexture.wrapU=Ie.g.CLAMP_ADDRESSMODE,c._colorTableTexture.wrapV=Ie.g.CLAMP_ADDRESSMODE,c.colorTableUrl=n,c.onApply=function(d){d.setTexture("colorTable",c._colorTableTexture)},c}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ColorCorrectionPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,31342))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,88977))])),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.colorTableUrl,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"colorTableUrl",void 0),t}(_t.w);(0,j.Y5)("BABYLON.ColorCorrectionPostProcess",tT);var nT=function(r){function t(e,n,i,o,a,s,l,c){c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT);var u=r.call(this,e,"convolution",["kernel","screenSize"],null,i,o,a,s,l,null,c)||this;return u.kernel=n,u.onApply=function(d){d.setFloat2("screenSize",u.width,u.height),d.setArray("kernel",u.kernel)},u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ConvolutionPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,44993))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,9406))])),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.kernel,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType)},e,i,o)},t.EdgeDetect0Kernel=[1,0,-1,0,0,0,-1,0,1],t.EdgeDetect1Kernel=[0,1,0,1,-4,1,0,1,0],t.EdgeDetect2Kernel=[-1,-1,-1,-1,8,-1,-1,-1,-1],t.SharpenKernel=[0,-1,0,-1,5,-1,0,-1,0],t.EmbossKernel=[-2,-1,0,-1,1,1,0,1,2],t.GaussianKernel=[0,1,0,1,1,1,0,1,0],(0,A.Cg)([(0,V.lK)()],t.prototype,"kernel",void 0),t}(_t.w);(0,j.Y5)("BABYLON.ConvolutionPostProcess",nT);var wl=function(r){function t(e,n,i,o,a,s,l,c,u,d,h,p,m,v){c===void 0&&(c=null),u===void 0&&(u=Ie.g.BILINEAR_SAMPLINGMODE),p===void 0&&(p=P.Y.TEXTURETYPE_UNSIGNED_INT),m===void 0&&(m=!1),v===void 0&&(v=P.Y.TEXTUREFORMAT_RGBA);var b=r.call(this,e,i,o,a,s,u=P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,d,h,p,`#define DOF 1
|
||
`,m,v)||this;return b.direction=i,b.externalTextureSamplerBinding=!!c,b.onApplyObservable.add(function(E){c!=null&&E.setTextureFromPostProcess("textureSampler",c),E.setTextureFromPostProcessOutput("circleOfConfusionSampler",l)}),b}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DepthOfFieldBlurPostProcess"},(0,A.Cg)([(0,V.lK)()],t.prototype,"direction",void 0),t}(ci);(0,j.Y5)("BABYLON.DepthOfFieldBlurPostProcess",wl);var Bf,iT=function(r){function t(e,n,i,o,a,s,l,c,u,d,h){d===void 0&&(d=P.Y.TEXTURETYPE_UNSIGNED_INT),h===void 0&&(h=!1);var p=r.call(this,e,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],a,s,l,c,u,null,d,void 0,null,!0)||this;return p._blurSteps=o,p.externalTextureSamplerBinding=!0,p.onApplyObservable.add(function(m){m.setTextureFromPostProcess("textureSampler",n),m.setTextureFromPostProcessOutput("circleOfConfusionSampler",i),o.forEach(function(v,b){m.setTextureFromPostProcessOutput("blurStep"+(o.length-b-1),v)})}),h||p.updateEffect(),p}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DepthOfFieldMergePostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,80239)))):n.push(Promise.resolve().then(L.bind(L,88456))),r.prototype._gatherImports.call(this,e,n)},t.prototype.updateEffect=function(e,n,i,o,a,s){e===void 0&&(e=null),n===void 0&&(n=null),i===void 0&&(i=null),e||(e="",e+="#define BLUR_LEVEL "+(this._blurSteps.length-1)+`
|
||
`),r.prototype.updateEffect.call(this,e,n,i,o,a,s)},t}(_t.w);(function(r){r[r.Low=0]="Low",r[r.Medium=1]="Medium",r[r.High=2]="High"})(Bf||(Bf={}));var Vf=function(r){function t(e,n,i,o,a){i===void 0&&(i=0),o===void 0&&(o=0),a===void 0&&(a=!1);var s=r.call(this,e.getEngine(),"depth of field",function(){return s._effects},!0)||this;s._effects=[];var l=e.getEngine(),c=l.isWebGPU||l.version>1?P.Y.TEXTUREFORMAT_RED:P.Y.TEXTUREFORMAT_RGBA;s._circleOfConfusion=new wf("circleOfConfusion",n,1,null,Ie.g.BILINEAR_SAMPLINGMODE,l,!1,o,a),s._depthOfFieldBlurY=[],s._depthOfFieldBlurX=[];var u=1,d=15;switch(i){case 2:u=3,d=51;break;case 1:u=2,d=31;break;default:d=15,u=1}for(var h=d/Math.pow(2,u-1),p=1,m=0;m<u;m++){var v=new wl("vertical blur",e,new _.I9(0,1),h,p,null,s._circleOfConfusion,m==0?s._circleOfConfusion:null,Ie.g.BILINEAR_SAMPLINGMODE,l,!1,o,a,m==0?c:P.Y.TEXTUREFORMAT_RGBA);v.autoClear=!1,p=.75/Math.pow(2,m);var b=new wl("horizontal blur",e,new _.I9(1,0),h,p,null,s._circleOfConfusion,null,Ie.g.BILINEAR_SAMPLINGMODE,l,!1,o,a);b.autoClear=!1,s._depthOfFieldBlurY.push(v),s._depthOfFieldBlurX.push(b)}for(s._effects=[s._circleOfConfusion],m=0;m<s._depthOfFieldBlurX.length;m++)s._effects.push(s._depthOfFieldBlurY[m]),s._effects.push(s._depthOfFieldBlurX[m]);return s._dofMerge=new iT("dofMerge",s._circleOfConfusion,s._circleOfConfusion,s._depthOfFieldBlurX,p,null,Ie.g.BILINEAR_SAMPLINGMODE,l,!1,o,a),s._dofMerge.autoClear=!1,s._effects.push(s._dofMerge),s}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"focalLength",{get:function(){return this._circleOfConfusion.focalLength},set:function(e){this._circleOfConfusion.focalLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fStop",{get:function(){return this._circleOfConfusion.fStop},set:function(e){this._circleOfConfusion.fStop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"focusDistance",{get:function(){return this._circleOfConfusion.focusDistance},set:function(e){this._circleOfConfusion.focusDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lensSize",{get:function(){return this._circleOfConfusion.lensSize},set:function(e){this._circleOfConfusion.lensSize=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DepthOfFieldEffect"},Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._circleOfConfusion.depthTexture=e},enumerable:!1,configurable:!0}),t.prototype.disposeEffects=function(e){for(var n=0;n<this._effects.length;n++)this._effects[n].dispose(e)},t.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},t.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},t}(Ut),rT=function(r){function t(e,n,i,o,a,s){return r.call(this,e,"displayPass",["passSampler"],["passSampler"],n,i,o,a,s)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"DisplayPassPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,25910))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,30145))])),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},t}(_t.w);(0,j.Y5)("BABYLON.DisplayPassPostProcess",rT);var oT=function(r){function t(e,n,i,o,a,s,l){var c=r.call(this,e,"filter",["kernelMatrix"],null,i,o,a,s,l)||this;return c.kernelMatrix=n,c.onApply=function(u){u.setMatrix("kernelMatrix",c.kernelMatrix)},c}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FilterPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,27401))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,80432))])),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.kernelMatrix,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},(0,A.Cg)([(0,V.GG)()],t.prototype,"kernelMatrix",void 0),t}(_t.w);(0,j.Y5)("BABYLON.FilterPostProcess",oT);var ms=function(r){function t(e,n,i,o,a,s,l){i===void 0&&(i=null),l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT);var c=r.call(this,e,"fxaa",["texelSize"],null,n,i,o||Ie.g.BILINEAR_SAMPLINGMODE,a,s,null,l,"fxaa",void 0,!0)||this,u=c._getDefines();return c.updateEffect(u),c.onApplyObservable.add(function(d){var h=c.texelSize;d.setFloat2("texelSize",h.x,h.y)}),c}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FxaaPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,23459)),Promise.resolve().then(L.bind(L,13481))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,59210)),Promise.resolve().then(L.bind(L,93100))])),r.prototype._gatherImports.call(this,e,n)},t.prototype._getDefines=function(){var e=this.getEngine();return e&&e.extractDriverInfo().toLowerCase().indexOf("mali")>-1?`#define MALI 1
|
||
`:null},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},t}(_t.w);(0,j.Y5)("BABYLON.FxaaPostProcess",ms);var Uf=function(r){function t(e,n,i,o,a,s,l,c){l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT),c===void 0&&(c=!1);var u=r.call(this,e,"grain",["intensity","animatedSeed"],[],n,i,o,a,s,null,l,void 0,null,c)||this;return u.intensity=30,u.animated=!1,u.onApplyObservable.add(function(d){d.setFloat("intensity",u.intensity),d.setFloat("animatedSeed",u.animated?Math.random()+1:1)}),u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"GrainPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,78138))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,47469))])),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"intensity",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"animated",void 0),t}(_t.w);(0,j.Y5)("BABYLON.GrainPostProcess",Uf);var FR=function(r){function t(e,n,i,o,a,s,l){return l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT),r.call(this,e,"highlights",null,null,n,i,o,a,s,null,l)||this}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"HighlightsPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,40856))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,36489))])),r.prototype._gatherImports.call(this,e,n)},t}(_t.w),Gf=function(r){function t(e,n,i,o,a,s,l,c){i===void 0&&(i=null),l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT);var u=r.call(this,e,"imageProcessing",[],[],n,i,o,a,s,null,l,"postprocess",null,!0)||this;return u._fromLinearSpace=!0,u._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:0,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,DITHER:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1,SKIPFINALCOLORCLAMP:!1},c?(c.applyByPostProcess=!0,u._attachImageProcessingConfiguration(c,!0),u._updateParameters()):(u._attachImageProcessingConfiguration(null,!0),u.imageProcessingConfiguration.applyByPostProcess=!0),u.onApply=function(d){u.imageProcessingConfiguration.bind(d,u.aspectRatio)},u}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,n){var i=this;if(n===void 0&&(n=!1),e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{var o=null,a=this.getEngine(),s=this.getCamera();if(s)o=s.getScene();else if(a&&a.scenes){var l=a.scenes;o=l[l.length-1]}else o=Ve.q.LastCreatedScene;this._imageProcessingConfiguration=o?o.imageProcessingConfiguration:new Ti.p}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){i._updateParameters()})),n||this._updateParameters()}},Object.defineProperty(t.prototype,"isSupported",{get:function(){var e=this.getEffect();return!e||e.isSupported},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingType",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCenterX},set:function(e){this.imageProcessingConfiguration.vignetteCenterX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCenterY},set:function(e){this.imageProcessingConfiguration.vignetteCenterY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCenterY",{get:function(){return this.imageProcessingConfiguration.vignetteCenterY},set:function(e){this.imageProcessingConfiguration.vignetteCenterY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCenterX",{get:function(){return this.imageProcessingConfiguration.vignetteCenterX},set:function(e){this.imageProcessingConfiguration.vignetteCenterX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ditheringIntensity",{get:function(){return this.imageProcessingConfiguration.ditheringIntensity},set:function(e){this.imageProcessingConfiguration.ditheringIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ditheringEnabled",{get:function(){return this.imageProcessingConfiguration.ditheringEnabled},set:function(e){this.imageProcessingConfiguration.ditheringEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!1,configurable:!0}),t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.resolve().then(L.bind(L,68805)))):n.push(Promise.resolve().then(L.bind(L,14830))),r.prototype._gatherImports.call(this,e,n)},t.prototype.getClassName=function(){return"ImageProcessingPostProcess"},t.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var e="";for(var n in this._defines){var i=this._defines[n];switch(typeof i){case"number":case"string":e+="#define ".concat(n," ").concat(i,`;
|
||
`);break;default:i&&(e+="#define ".concat(n,`;
|
||
`))}}var o=["textureSampler"],a=["scale"];Ti.p&&(Ti.p.PrepareSamplers(o,this._defines),Ti.p.PrepareUniforms(a,this._defines)),this.updateEffect(e,a,o)},t.prototype.dispose=function(e){r.prototype.dispose.call(this,e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},(0,A.Cg)([(0,V.lK)()],t.prototype,"_fromLinearSpace",void 0),t}(_t.w),wR=L(93102),BR=L(779),VR=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","boneTextureWidth"];(0,tn.TV)(VR);var zn=function(){function r(t,e,n,i){e===void 0&&(e=1),n===void 0&&(n=P.Y.TEXTUREFORMAT_DEPTH16),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this.generateNormalsInWorldSpace=!1,this._normalsAreUnsigned=!1,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._clearColor=new z.ov(0,0,0,0),this._clearDepthColor=new z.ov(1e8,0,0,1),this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthIndex=-1,this._normalIndex=-1,this._linkedWithPrePass=!1,this.useSpecificClearForDepthTexture=!1,this._shaderLanguage=0,this._shadersLoaded=!1,this._scene=t,this._ratioOrDimensions=e,this._useUbo=t.getEngine().supportsUniformBuffers,this._depthFormat=n,this._textureTypesAndFormats=i||{},this._initShaderSourceAsync(),r._SceneComponentInitialization(this._scene),this._createRenderTargets()}return Object.defineProperty(r.prototype,"normalsAreUnsigned",{get:function(){return this._normalsAreUnsigned},enumerable:!1,configurable:!0}),r.prototype._linkPrePassRenderer=function(t){this._linkedWithPrePass=!0,this._prePassRenderer=t,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add(function(){}))},r.prototype._unlinkPrePassRenderer=function(){this._linkedWithPrePass=!1,this._createRenderTargets()},r.prototype._resetLayout=function(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachmentsFromPrePass=[]},r.prototype._forceTextureType=function(t,e){t===r.POSITION_TEXTURE_TYPE?(this._positionIndex=e,this._enablePosition=!0):t===r.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=e,this._enableVelocity=!0):t===r.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=e,this._enableReflectivity=!0):t===r.DEPTH_TEXTURE_TYPE?this._depthIndex=e:t===r.NORMAL_TEXTURE_TYPE&&(this._normalIndex=e)},r.prototype._setAttachments=function(t){this._attachmentsFromPrePass=t},r.prototype._linkInternalTexture=function(t){this._multiRenderTarget.setInternalTexture(t,0,!1)},Object.defineProperty(r.prototype,"renderList",{get:function(){return this._multiRenderTarget.renderList},set:function(t){this._multiRenderTarget.renderList=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!1,configurable:!0}),r.prototype.getTextureIndex=function(t){switch(t){case r.POSITION_TEXTURE_TYPE:return this._positionIndex;case r.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case r.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;case r.DEPTH_TEXTURE_TYPE:return this._linkedWithPrePass?this._depthIndex:0;case r.NORMAL_TEXTURE_TYPE:return this._linkedWithPrePass?this._normalIndex:1;default:return-1}},Object.defineProperty(r.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(t){this._enablePosition=t,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(t){this._enableVelocity=t,t||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets()),this._scene.needsPreviousWorldMatrices=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableReflectivity",{get:function(){return this._enableReflectivity},set:function(t){this._enableReflectivity=t,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ratio",{get:function(){return typeof this._ratioOrDimensions=="object"?1:this._ratioOrDimensions},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._initShaderSourceAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:return!this._scene.getEngine().isWebGPU||r.ForceGLSL?[3,2]:(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,40877)),Promise.resolve().then(L.bind(L,51319))])]);case 1:return t.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,779)),Promise.resolve().then(L.bind(L,93102))])];case 3:t.sent(),t.label=4;case 4:return this._shadersLoaded=!0,[2]}})})},r.prototype.isReady=function(t,e){if(!this._shadersLoaded)return!1;var n=t.getMaterial();if(n&&n.disableDepthWrite)return!1;var i=[],o=[Y.R.PositionKind,Y.R.NormalKind],a=t.getMesh();if(n){var s=!1;if(n.needAlphaTesting()&&n.getAlphaTestTexture()&&(i.push("#define ALPHATEST"),i.push("#define ALPHATEST_UV".concat(n.getAlphaTestTexture().coordinatesIndex+1)),s=!0),n.bumpTexture&&$e.BumpTextureEnabled&&(i.push("#define BUMP"),i.push("#define BUMP_UV".concat(n.bumpTexture.coordinatesIndex+1)),s=!0),this._enableReflectivity){var l=!1;n.getClassName()==="PBRMetallicRoughnessMaterial"?(n.metallicRoughnessTexture&&(i.push("#define ORMTEXTURE"),i.push("#define REFLECTIVITY_UV".concat(n.metallicRoughnessTexture.coordinatesIndex+1)),i.push("#define METALLICWORKFLOW"),s=!0,l=!0),n.metallic!=null&&(i.push("#define METALLIC"),i.push("#define METALLICWORKFLOW"),l=!0),n.roughness!=null&&(i.push("#define ROUGHNESS"),i.push("#define METALLICWORKFLOW"),l=!0),l&&(n.baseTexture&&(i.push("#define ALBEDOTEXTURE"),i.push("#define ALBEDO_UV".concat(n.baseTexture.coordinatesIndex+1)),n.baseTexture.gammaSpace&&i.push("#define GAMMAALBEDO"),s=!0),n.baseColor&&i.push("#define ALBEDOCOLOR"))):n.getClassName()==="PBRSpecularGlossinessMaterial"?(n.specularGlossinessTexture?(i.push("#define SPECULARGLOSSINESSTEXTURE"),i.push("#define REFLECTIVITY_UV".concat(n.specularGlossinessTexture.coordinatesIndex+1)),s=!0,n.specularGlossinessTexture.gammaSpace&&i.push("#define GAMMAREFLECTIVITYTEXTURE")):n.specularColor&&i.push("#define REFLECTIVITYCOLOR"),n.glossiness!=null&&i.push("#define GLOSSINESS")):n.getClassName()==="PBRMaterial"?(n.metallicTexture&&(i.push("#define ORMTEXTURE"),i.push("#define REFLECTIVITY_UV".concat(n.metallicTexture.coordinatesIndex+1)),i.push("#define METALLICWORKFLOW"),s=!0,l=!0),n.metallic!=null&&(i.push("#define METALLIC"),i.push("#define METALLICWORKFLOW"),l=!0),n.roughness!=null&&(i.push("#define ROUGHNESS"),i.push("#define METALLICWORKFLOW"),l=!0),l?(n.albedoTexture&&(i.push("#define ALBEDOTEXTURE"),i.push("#define ALBEDO_UV".concat(n.albedoTexture.coordinatesIndex+1)),n.albedoTexture.gammaSpace&&i.push("#define GAMMAALBEDO"),s=!0),n.albedoColor&&i.push("#define ALBEDOCOLOR")):(n.reflectivityTexture?(i.push("#define SPECULARGLOSSINESSTEXTURE"),i.push("#define REFLECTIVITY_UV".concat(n.reflectivityTexture.coordinatesIndex+1)),n.reflectivityTexture.gammaSpace&&i.push("#define GAMMAREFLECTIVITYTEXTURE"),s=!0):n.reflectivityColor&&i.push("#define REFLECTIVITYCOLOR"),n.microSurface!=null&&i.push("#define GLOSSINESS"))):n.getClassName()==="StandardMaterial"&&(n.specularTexture&&(i.push("#define REFLECTIVITYTEXTURE"),i.push("#define REFLECTIVITY_UV".concat(n.specularTexture.coordinatesIndex+1)),n.specularTexture.gammaSpace&&i.push("#define GAMMAREFLECTIVITYTEXTURE"),s=!0),n.specularColor&&i.push("#define REFLECTIVITYCOLOR"))}s&&(i.push("#define NEED_UV"),a.isVerticesDataPresent(Y.R.UVKind)&&(o.push(Y.R.UVKind),i.push("#define UV1")),a.isVerticesDataPresent(Y.R.UV2Kind)&&(o.push(Y.R.UV2Kind),i.push("#define UV2")))}this._linkedWithPrePass&&(i.push("#define PREPASS"),this._depthIndex!==-1&&(i.push("#define DEPTH_INDEX "+this._depthIndex),i.push("#define PREPASS_DEPTH")),this._normalIndex!==-1&&(i.push("#define NORMAL_INDEX "+this._normalIndex),i.push("#define PREPASS_NORMAL"))),this._enablePosition&&(i.push("#define POSITION"),i.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(i.push("#define VELOCITY"),i.push("#define VELOCITY_INDEX "+this._velocityIndex),this.excludedSkinnedMeshesFromVelocity.indexOf(a)===-1&&i.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(i.push("#define REFLECTIVITY"),i.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),this.generateNormalsInWorldSpace&&i.push("#define NORMAL_WORLDSPACE"),this._normalsAreUnsigned&&i.push("#define ENCODE_NORMAL"),a.useBones&&a.computeBonesUsingShaders&&a.skeleton?(o.push(Y.R.MatricesIndicesKind),o.push(Y.R.MatricesWeightsKind),a.numBoneInfluencers>4&&(o.push(Y.R.MatricesIndicesExtraKind),o.push(Y.R.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),i.push("#define BONETEXTURE "+a.skeleton.isUsingTextureForMatrices),i.push("#define BonesPerMesh "+(a.skeleton.bones.length+1))):(i.push("#define NUM_BONE_INFLUENCERS 0"),i.push("#define BONETEXTURE false"),i.push("#define BonesPerMesh 0"));var c=a.morphTargetManager,u=0;c&&(u=c.numMaxInfluencers||c.numInfluencers)>0&&(i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+u),c.isUsingTextureForTargets&&i.push("#define MORPHTARGETS_TEXTURE"),(0,Re.MF)(o,a,u)),e&&(i.push("#define INSTANCES"),(0,Re.te)(o,this._enableVelocity),t.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES")),this._linkedWithPrePass?i.push("#define SCENE_MRT_COUNT "+this._attachmentsFromPrePass.length):i.push("#define SCENE_MRT_COUNT "+this._multiRenderTarget.textures.length),(0,tn.tv)(n,this._scene,i);var d=this._scene.getEngine(),h=t._getDrawWrapper(void 0,!0),p=h.defines,m=i.join(`
|
||
`);return p!==m&&h.setEffect(d.createEffect("geometry",{attributes:o,uniformsNames:VR,samplers:["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets","boneSampler"],defines:m,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:u},shaderLanguage:this.shaderLanguage},d),m),h.effect.isReady()},r.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(r.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(t){this._multiRenderTarget.samples=t},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.getGBuffer().dispose()},r.prototype._assignRenderTargetIndices=function(){var t=[],e=[],n=2;return t.push("gBuffer_Depth","gBuffer_Normal"),e.push(this._textureTypesAndFormats[r.DEPTH_TEXTURE_TYPE]),e.push(this._textureTypesAndFormats[r.NORMAL_TEXTURE_TYPE]),this._enablePosition&&(this._positionIndex=n,n++,t.push("gBuffer_Position"),e.push(this._textureTypesAndFormats[r.POSITION_TEXTURE_TYPE])),this._enableVelocity&&(this._velocityIndex=n,n++,t.push("gBuffer_Velocity"),e.push(this._textureTypesAndFormats[r.VELOCITY_TEXTURE_TYPE])),this._enableReflectivity&&(this._reflectivityIndex=n,n++,t.push("gBuffer_Reflectivity"),e.push(this._textureTypesAndFormats[r.REFLECTIVITY_TEXTURE_TYPE])),[n,t,e]},r.prototype._createRenderTargets=function(){var t,e=this,n=this._scene.getEngine(),i=(t=this._assignRenderTargetIndices())[0],o=t[1],a=t[2],s=P.Y.TEXTURETYPE_UNSIGNED_BYTE;n._caps.textureFloat&&n._caps.textureFloatLinearFiltering?s=P.Y.TEXTURETYPE_FLOAT:n._caps.textureHalfFloat&&n._caps.textureHalfFloatLinearFiltering&&(s=P.Y.TEXTURETYPE_HALF_FLOAT);for(var l=this._ratioOrDimensions.width!==void 0?this._ratioOrDimensions:{width:n.getRenderWidth()*this._ratioOrDimensions,height:n.getRenderHeight()*this._ratioOrDimensions},c=[],u=[],d=0,h=a;d<h.length;d++){var p=h[d];p?(c.push(p.textureType),u.push(p.textureFormat)):(c.push(s),u.push(P.Y.TEXTUREFORMAT_RGBA))}if(this._normalsAreUnsigned=c[r.NORMAL_TEXTURE_TYPE]===P.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV||c[r.NORMAL_TEXTURE_TYPE]===P.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,this._multiRenderTarget=new Kr("gBuffer",l,i,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,types:c,formats:u,depthTextureFormat:this._depthFormat},o.concat("gBuffer_DepthBuffer")),this.isSupported){this._multiRenderTarget.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null;for(var m=[!0],v=[!1],b=[!0],E=1;E<i;++E)m.push(!0),b.push(!1),v.push(!0);var C=n.buildTextureLayout(m),T=n.buildTextureLayout(v),f=n.buildTextureLayout(b);this._multiRenderTarget.onClearObservable.add(function(S){S.bindAttachments(e.useSpecificClearForDepthTexture?T:C),S.clear(e._clearColor,!0,!0,!0),e.useSpecificClearForDepthTexture&&(S.bindAttachments(f),S.clear(e._clearDepthColor,!0,!0,!0)),S.bindAttachments(C)}),this._resizeObserver=n.onResizeObservable.add(function(){if(e._multiRenderTarget){var S=e._ratioOrDimensions.width!==void 0?e._ratioOrDimensions:{width:n.getRenderWidth()*e._ratioOrDimensions,height:n.getRenderHeight()*e._ratioOrDimensions};e._multiRenderTarget.resize(S)}});var g=function(S){var y=S.getRenderingMesh(),x=S.getEffectiveMesh(),R=e._scene,I=R.getEngine(),M=S.getMaterial();if(M){if(x._internalAbstractMeshDataInfo._isActiveIntermediate=!1,e._enableVelocity&&!e._previousTransformationMatrices[x.uniqueId]&&(e._previousTransformationMatrices[x.uniqueId]={world:_.uq.Identity(),viewProjection:R.getTransformMatrix()},y.skeleton)){var D=y.skeleton.getTransformMatrices(y);e._previousBonesTransformationMatrices[y.uniqueId]=e._copyBonesTransformationMatrices(D,new Float32Array(D.length))}var B=y._getInstancesRenderList(S._id,!!S.getReplacementMesh());if(!B.mustReturn){var F=I.getCaps().instancedArrays&&(B.visibleInstances[S._id]!==null||y.hasThinInstances),X=x.getWorldMatrix();if(e.isReady(S,F)){var $=S._getDrawWrapper();if(!$)return;var Q=$.effect;I.enableEffect($),F||y._bind(S,Q,M.fillMode),e._useUbo?((0,Re._8)(Q,e._scene.getSceneUniformBuffer()),e._scene.finalizeSceneUbo()):(Q.setMatrix("viewProjection",R.getTransformMatrix()),Q.setMatrix("view",R.getViewMatrix()));var ie=void 0,q=y._instanceDataStorage;if(q.isFrozen||!M.backFaceCulling&&M.sideOrientation===null)ie=q.sideOrientation;else{var ee=x._getWorldMatrixDeterminant();ie=M._getEffectiveOrientation(y),ee<0&&(ie=ie===Lt.ClockWiseSideOrientation?Lt.CounterClockWiseSideOrientation:Lt.ClockWiseSideOrientation)}if(M._preBind($,ie),M.needAlphaTesting()){var te=M.getAlphaTestTexture();te&&(Q.setTexture("diffuseSampler",te),Q.setMatrix("diffuseMatrix",te.getTextureMatrix()))}if(M.bumpTexture&&R.getEngine().getCaps().standardDerivatives&&$e.BumpTextureEnabled&&(Q.setFloat3("vBumpInfos",M.bumpTexture.coordinatesIndex,1/M.bumpTexture.level,M.parallaxScaleBias),Q.setMatrix("bumpMatrix",M.bumpTexture.getTextureMatrix()),Q.setTexture("bumpSampler",M.bumpTexture),Q.setFloat2("vTangentSpaceParams",M.invertNormalMapX?-1:1,M.invertNormalMapY?-1:1)),e._enableReflectivity&&(M.getClassName()==="PBRMetallicRoughnessMaterial"?(M.metallicRoughnessTexture!==null&&(Q.setTexture("reflectivitySampler",M.metallicRoughnessTexture),Q.setMatrix("reflectivityMatrix",M.metallicRoughnessTexture.getTextureMatrix())),M.metallic!==null&&Q.setFloat("metallic",M.metallic),M.roughness!==null&&Q.setFloat("glossiness",1-M.roughness),M.baseTexture!==null&&(Q.setTexture("albedoSampler",M.baseTexture),Q.setMatrix("albedoMatrix",M.baseTexture.getTextureMatrix())),M.baseColor!==null&&Q.setColor3("albedoColor",M.baseColor)):M.getClassName()==="PBRSpecularGlossinessMaterial"?(M.specularGlossinessTexture!==null?(Q.setTexture("reflectivitySampler",M.specularGlossinessTexture),Q.setMatrix("reflectivityMatrix",M.specularGlossinessTexture.getTextureMatrix())):M.specularColor!==null&&Q.setColor3("reflectivityColor",M.specularColor),M.glossiness!==null&&Q.setFloat("glossiness",M.glossiness)):M.getClassName()==="PBRMaterial"?(M.metallicTexture!==null&&(Q.setTexture("reflectivitySampler",M.metallicTexture),Q.setMatrix("reflectivityMatrix",M.metallicTexture.getTextureMatrix())),M.metallic!==null&&Q.setFloat("metallic",M.metallic),M.roughness!==null&&Q.setFloat("glossiness",1-M.roughness),M.roughness!==null||M.metallic!==null||M.metallicTexture!==null?(M.albedoTexture!==null&&(Q.setTexture("albedoSampler",M.albedoTexture),Q.setMatrix("albedoMatrix",M.albedoTexture.getTextureMatrix())),M.albedoColor!==null&&Q.setColor3("albedoColor",M.albedoColor)):(M.reflectivityTexture!==null?(Q.setTexture("reflectivitySampler",M.reflectivityTexture),Q.setMatrix("reflectivityMatrix",M.reflectivityTexture.getTextureMatrix())):M.reflectivityColor!==null&&Q.setColor3("reflectivityColor",M.reflectivityColor),M.microSurface!==null&&Q.setFloat("glossiness",M.microSurface))):M.getClassName()==="StandardMaterial"&&(M.specularTexture!==null&&(Q.setTexture("reflectivitySampler",M.specularTexture),Q.setMatrix("reflectivityMatrix",M.specularTexture.getTextureMatrix())),M.specularColor!==null&&Q.setColor3("reflectivityColor",M.specularColor))),(0,tn.gS)(Q,M,e._scene),y.useBones&&y.computeBonesUsingShaders&&y.skeleton){var ce=y.skeleton;if(ce.isUsingTextureForMatrices&&Q.getUniformIndex("boneTextureWidth")>-1){var fe=ce.getTransformMatrixTexture(y);Q.setTexture("boneSampler",fe),Q.setFloat("boneTextureWidth",4*(ce.bones.length+1))}else Q.setMatrices("mBones",y.skeleton.getTransformMatrices(y));e._enableVelocity&&Q.setMatrices("mPreviousBones",e._previousBonesTransformationMatrices[y.uniqueId])}(0,Re.nR)(y,Q),y.morphTargetManager&&y.morphTargetManager.isUsingTextureForTargets&&y.morphTargetManager._bind(Q),e._enableVelocity&&(Q.setMatrix("previousWorld",e._previousTransformationMatrices[x.uniqueId].world),Q.setMatrix("previousViewProjection",e._previousTransformationMatrices[x.uniqueId].viewProjection)),F&&y.hasThinInstances&&Q.setMatrix("world",X),y._processRendering(x,S,Q,M.fillMode,B,F,function(de,Te){de||Q.setMatrix("world",Te)})}e._enableVelocity&&(e._previousTransformationMatrices[x.uniqueId].world=X.clone(),e._previousTransformationMatrices[x.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),y.skeleton&&e._copyBonesTransformationMatrices(y.skeleton.getTransformMatrices(y),e._previousBonesTransformationMatrices[x.uniqueId]))}}};this._multiRenderTarget.customIsReadyFunction=function(S,y,x){if((x||y===0)&&S.subMeshes)for(var R=0;R<S.subMeshes.length;++R){var I=S.subMeshes[R],M=I.getMaterial(),D=I.getRenderingMesh();if(M){var B=D._getInstancesRenderList(I._id,!!I.getReplacementMesh()),F=n.getCaps().instancedArrays&&(B.visibleInstances[I._id]!==null||D.hasThinInstances);if(!e.isReady(I,F))return!1}}return!0},this._multiRenderTarget.customRenderFunction=function(S,y,x,R){var I;if(e._linkedWithPrePass){if(!e._prePassRenderer.enabled)return;e._scene.getEngine().bindAttachments(e._attachmentsFromPrePass)}if(R.length){for(n.setColorWrite(!1),I=0;I<R.length;I++)g(R.data[I]);n.setColorWrite(!0)}for(I=0;I<S.length;I++)g(S.data[I]);for(n.setDepthWrite(!1),I=0;I<y.length;I++)g(y.data[I]);if(e.renderTransparentMeshes)for(I=0;I<x.length;I++)g(x.data[I]);n.setDepthWrite(!0)}}},r.prototype._copyBonesTransformationMatrices=function(t,e){for(var n=0;n<t.length;n++)e[n]=t[n];return e},r.ForceGLSL=!1,r.DEPTH_TEXTURE_TYPE=0,r.NORMAL_TEXTURE_TYPE=1,r.POSITION_TEXTURE_TYPE=2,r.VELOCITY_TEXTURE_TYPE=3,r.REFLECTIVITY_TEXTURE_TYPE=4,r._SceneComponentInitialization=function(t){throw(0,gt.n)("GeometryBufferRendererSceneComponent")},r}(),xN=function(){this.enabled=!1,this.name="motionBlur",this.texturesRequired=[P.Y.PREPASS_VELOCITY_TEXTURE_TYPE]};Object.defineProperty(ke.Z.prototype,"geometryBufferRenderer",{get:function(){return this._geometryBufferRenderer},set:function(r){r&&r.isSupported&&(this._geometryBufferRenderer=r)},enumerable:!0,configurable:!0}),ke.Z.prototype.enableGeometryBufferRenderer=function(r,t,e){return r===void 0&&(r=1),t===void 0&&(t=P.Y.TEXTUREFORMAT_DEPTH16),this._geometryBufferRenderer||(this._geometryBufferRenderer=new zn(this,r,t,e),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null)),this._geometryBufferRenderer},ke.Z.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};var aT=function(){function r(t){this.name=lt.v.NAME_GEOMETRYBUFFERRENDERER,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(lt.v.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER,this,this._gatherRenderTargets)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r.prototype._gatherRenderTargets=function(t){this.scene._geometryBufferRenderer&&t.push(this.scene._geometryBufferRenderer.getGBuffer())},r}();zn._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_GEOMETRYBUFFERRENDERER);t||(t=new aT(r),r._addComponent(t))};var kf=function(r){function t(e,n,i,o,a,s,l,c,u,d){c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=!1),d===void 0&&(d=!1);var h=r.call(this,e,"motionBlur",["motionStrength","motionScale","screenSize","inverseViewProjection","prevViewProjection","projection"],["velocitySampler","depthSampler"],i,o,a,s,l,`#define GEOMETRY_SUPPORTED
|
||
#define SAMPLES 64.0
|
||
#define OBJECT_BASED`,c,void 0,null,u)||this;return h.motionStrength=1,h._motionBlurSamples=32,h._isObjectBased=!0,h._forceGeometryBuffer=!1,h._invViewProjection=null,h._previousViewProjection=null,h._forceGeometryBuffer=d,h._forceGeometryBuffer?(n.enableGeometryBufferRenderer(),h._geometryBufferRenderer&&(h._geometryBufferRenderer.enableVelocity=h._isObjectBased)):(n.enablePrePassRenderer(),h._prePassRenderer&&(h._prePassRenderer.markAsDirty(),h._prePassEffectConfiguration=new xN)),h._applyMode(),h}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this._motionBlurSamples=e,this._updateEffect()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isObjectBased",{get:function(){return this._isObjectBased},set:function(e){this._isObjectBased!==e&&(this._isObjectBased=e,this._applyMode())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_geometryBufferRenderer",{get:function(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_prePassRenderer",{get:function(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"MotionBlurPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,70154))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,35007))])),r.prototype._gatherImports.call(this,e,n)},t.prototype.excludeSkinnedMesh=function(e){if(e.skeleton){var n=void 0;if(this._geometryBufferRenderer)n=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;n=this._prePassRenderer.excludedSkinnedMesh}n.push(e)}},t.prototype.removeExcludedSkinnedMesh=function(e){if(e.skeleton){var n=void 0;if(this._geometryBufferRenderer)n=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;n=this._prePassRenderer.excludedSkinnedMesh}var i=n.indexOf(e);i!==-1&&n.splice(i,1)}},t.prototype.dispose=function(e){this._geometryBufferRenderer&&(this._geometryBufferRenderer._previousTransformationMatrices={},this._geometryBufferRenderer._previousBonesTransformationMatrices={},this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity=[]),r.prototype.dispose.call(this,e)},t.prototype._applyMode=function(){var e=this;if(!this._geometryBufferRenderer&&!this._prePassRenderer)return O.V.Warn("Multiple Render Target support needed to compute object based motion blur"),this.updateEffect();this._geometryBufferRenderer&&(this._geometryBufferRenderer.enableVelocity=this._isObjectBased),this._updateEffect(),this._invViewProjection=null,this._previousViewProjection=null,this.isObjectBased?(this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=P.Y.PREPASS_VELOCITY_TEXTURE_TYPE),this.onApply=function(n){return e._onApplyObjectBased(n)}):(this._invViewProjection=_.uq.Identity(),this._previousViewProjection=this._scene.getTransformMatrix().clone(),this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=P.Y.PREPASS_DEPTH_TEXTURE_TYPE),this.onApply=function(n){return e._onApplyScreenBased(n)})},t.prototype._onApplyObjectBased=function(e){if(e.setVector2("screenSize",new _.I9(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){var n=this._geometryBufferRenderer.getTextureIndex(zn.VELOCITY_TEXTURE_TYPE);e.setTexture("velocitySampler",this._geometryBufferRenderer.getGBuffer().textures[n])}else this._prePassRenderer&&(n=this._prePassRenderer.getIndex(P.Y.PREPASS_VELOCITY_TEXTURE_TYPE),e.setTexture("velocitySampler",this._prePassRenderer.getRenderTarget().textures[n]))},t.prototype._onApplyScreenBased=function(e){var n=_.AA.Matrix[0];if(n.copyFrom(this._scene.getTransformMatrix()),n.invertToRef(this._invViewProjection),e.setMatrix("inverseViewProjection",this._invViewProjection),e.setMatrix("prevViewProjection",this._previousViewProjection),this._previousViewProjection.copyFrom(n),e.setMatrix("projection",this._scene.getProjectionMatrix()),e.setVector2("screenSize",new _.I9(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){var i=this._geometryBufferRenderer.getTextureIndex(zn.DEPTH_TEXTURE_TYPE);e.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[i])}else this._prePassRenderer&&(i=this._prePassRenderer.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE),e.setTexture("depthSampler",this._prePassRenderer.getRenderTarget().textures[i]))},t.prototype._updateEffect=function(){if(this._geometryBufferRenderer||this._prePassRenderer){var e=["#define GEOMETRY_SUPPORTED","#define SAMPLES "+this._motionBlurSamples.toFixed(1),this._isObjectBased?"#define OBJECT_BASED":"#define SCREEN_BASED"];this.updateEffect(e.join(`
|
||
`))}},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,i,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,!1)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"motionStrength",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"motionBlurSamples",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"isObjectBased",null),t}(_t.w);(0,j.Y5)("BABYLON.MotionBlurPostProcess",kf),Gt.l.ShadersStore.refractionPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D refractionSampler;uniform vec3 baseColor;uniform float depth;uniform float colorLevel;void main() {float ref=1.0-texture2D(refractionSampler,vUV).r;vec2 uv=vUV-vec2(0.5);vec2 offset=uv*depth*ref;vec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;gl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);}";var sT=function(r){function t(e,n,i,o,a,s,l,c,u,d){var h=r.call(this,e,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],s,l,c,u,d)||this;return h._ownRefractionTexture=!0,h.color=i,h.depth=o,h.colorLevel=a,h.refractionTextureUrl=n,h.onActivateObservable.add(function(p){h._refTexture=h._refTexture||new Ie.g(n,p.getScene())}),h.onApplyObservable.add(function(p){p.setColor3("baseColor",h.color),p.setFloat("depth",h.depth),p.setFloat("colorLevel",h.colorLevel),p.setTexture("refractionSampler",h._refTexture)}),h}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refTexture},set:function(e){this._refTexture&&this._ownRefractionTexture&&this._refTexture.dispose(),this._refTexture=e,this._ownRefractionTexture=!1},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"RefractionPostProcess"},t.prototype.dispose=function(e){this._refTexture&&this._ownRefractionTexture&&(this._refTexture.dispose(),this._refTexture=null),r.prototype.dispose.call(this,e)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.refractionTextureUrl,e.color,e.depth,e.colorLevel,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"color",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"depth",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"colorLevel",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"refractionTextureUrl",void 0),t}(_t.w);(0,j.Y5)("BABYLON.RefractionPostProcess",sT);var UR=L(22129),zf=function(r){function t(e,n,i,o,a,s,l,c){l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT),c===void 0&&(c=!1);var u=r.call(this,e,"sharpen",["sharpnessAmounts","screenSize"],null,n,i,o,a,s,null,l,void 0,null,c)||this;return u.colorAmount=1,u.edgeAmount=.3,u.onApply=function(d){d.setFloat2("screenSize",u.width,u.height),d.setFloat2("sharpnessAmounts",u.edgeAmount,u.colorAmount)},u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SharpenPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,89950))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,22129))])),r.prototype._gatherImports.call(this,e,n)},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"colorAmount",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"edgeAmount",void 0),t}(_t.w);(0,j.Y5)("BABYLON.SharpenPostProcess",zf);var uo=function(){function r(t,e){this._engine=t,this._name=e,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cameras",{get:function(){return this._cameras},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"engine",{get:function(){return this._engine},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"PostProcessRenderPipeline"},Object.defineProperty(r.prototype,"isSupported",{get:function(){for(var t in this._renderEffects)if(Object.prototype.hasOwnProperty.call(this._renderEffects,t)&&!this._renderEffects[t].isSupported)return!1;return!0},enumerable:!1,configurable:!0}),r.prototype.addEffect=function(t){this._renderEffects[t._name]=t},r.prototype._rebuild=function(){},r.prototype._enableEffect=function(t,e){var n=this._renderEffects[t];n&&n._enable(ze.S0.MakeArray(e||this._cameras))},r.prototype._disableEffect=function(t,e){var n=this._renderEffects[t];n&&n._disable(ze.S0.MakeArray(e||this._cameras))},r.prototype._attachCameras=function(t,e){var n=ze.S0.MakeArray(t||this._cameras);if(n){var i,o=[];for(i=0;i<n.length;i++){var a=n[i];a&&(this._cameras.indexOf(a)===-1?this._cameras.push(a):e&&o.push(i))}for(i=0;i<o.length;i++)n.splice(o[i],1);for(var s in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,s)&&this._renderEffects[s]._attachCameras(n)}},r.prototype._detachCameras=function(t){var e=ze.S0.MakeArray(t||this._cameras);if(e){for(var n in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,n)&&this._renderEffects[n]._detachCameras(e);for(var i=0;i<e.length;i++)this._cameras.splice(this._cameras.indexOf(e[i]),1)}},r.prototype._update=function(){for(var t in this._renderEffects)Object.prototype.hasOwnProperty.call(this._renderEffects,t)&&this._renderEffects[t]._update();for(var e=0;e<this._cameras.length;e++)if(this._cameras[e]){var n=this._cameras[e].name;this._renderEffectsForIsolatedPass[n]&&this._renderEffectsForIsolatedPass[n]._update()}},r.prototype._reset=function(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array},r.prototype._enableMSAAOnFirstPostProcess=function(t){if(!this._engine._features.supportMSAA)return!1;var e=Object.keys(this._renderEffects);if(e.length>0){var n=this._renderEffects[e[0]].getPostProcesses();n&&(n[0].samples=t)}return!0},r.prototype._adaptPostProcessesToViewPort=function(){for(var t=0,e=Object.keys(this._renderEffects);t<e.length;t++){var n=e[t],i=this._renderEffects[n].getPostProcesses();if(i)for(var o=0,a=i;o<a.length;o++)a[o].adaptScaleToCurrentViewport=!0}},r.prototype.setPrePassRenderer=function(t){return!1},r.prototype.dispose=function(){},(0,A.Cg)([(0,V.lK)()],r.prototype,"_name",void 0),r}(),lT=function(){function r(){this._renderPipelines={}}return Object.defineProperty(r.prototype,"supportedPipelines",{get:function(){var t=[];for(var e in this._renderPipelines)if(Object.prototype.hasOwnProperty.call(this._renderPipelines,e)){var n=this._renderPipelines[e];n.isSupported&&t.push(n)}return t},enumerable:!1,configurable:!0}),r.prototype.addPipeline=function(t){this._renderPipelines[t._name]=t},r.prototype.removePipeline=function(t){delete this._renderPipelines[t]},r.prototype.attachCamerasToRenderPipeline=function(t,e,n){n===void 0&&(n=!1);var i=this._renderPipelines[t];i&&i._attachCameras(e,n)},r.prototype.detachCamerasFromRenderPipeline=function(t,e){var n=this._renderPipelines[t];n&&n._detachCameras(e)},r.prototype.enableEffectInPipeline=function(t,e,n){var i=this._renderPipelines[t];i&&i._enableEffect(e,n)},r.prototype.disableEffectInPipeline=function(t,e,n){var i=this._renderPipelines[t];i&&i._disableEffect(e,n)},r.prototype.update=function(){for(var t in this._renderPipelines)if(Object.prototype.hasOwnProperty.call(this._renderPipelines,t)){var e=this._renderPipelines[t];e.isSupported?e._update():(e.dispose(),delete this._renderPipelines[t])}},r.prototype._rebuild=function(){for(var t in this._renderPipelines)Object.prototype.hasOwnProperty.call(this._renderPipelines,t)&&this._renderPipelines[t]._rebuild()},r.prototype.dispose=function(){for(var t in this._renderPipelines)Object.prototype.hasOwnProperty.call(this._renderPipelines,t)&&this._renderPipelines[t].dispose()},r}();Object.defineProperty(ke.Z.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var r=this._getComponent(lt.v.NAME_POSTPROCESSRENDERPIPELINEMANAGER);r||(r=new cT(this),this._addComponent(r)),this._postProcessRenderPipelineManager=new lT}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var cT=function(){function r(t){this.name=lt.v.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(lt.v.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)},r.prototype.rebuild=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()},r.prototype.dispose=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()},r.prototype._gatherRenderTargets=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},r}(),uT=function(r){function t(e,n,i,o,a){e===void 0&&(e=""),n===void 0&&(n=!0),i===void 0&&(i=Ve.q.LastCreatedScene),a===void 0&&(a=!0);var s=r.call(this,i.getEngine(),e)||this;s._camerasToBeAttached=[],s.SharpenPostProcessId="SharpenPostProcessEffect",s.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",s.FxaaPostProcessId="FxaaPostProcessEffect",s.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",s.GrainPostProcessId="GrainPostProcessEffect",s._glowLayer=null,s.animations=[],s._imageProcessingConfigurationObserver=null,s._sharpenEnabled=!1,s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._depthOfFieldBlurLevel=0,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.5,s._chromaticAberrationEnabled=!1,s._grainEnabled=!1,s._buildAllowed=!0,s.onBuildObservable=new K.cP,s._resizeObserver=null,s._hardwareScaleLevel=1,s._bloomKernel=64,s._bloomWeight=.15,s._bloomThreshold=.9,s._samples=1,s._hasCleared=!1,s._prevPostProcess=null,s._prevPrevPostProcess=null,s._depthOfFieldSceneObserver=null,s._activeCameraChangedObserver=null,s._activeCamerasChangedObserver=null,s._cameras=o||i.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._buildAllowed=a,s._scene=i;var l=s._scene.getEngine().getCaps();s._hdr=n&&(l.textureHalfFloatRender||l.textureFloatRender),s._hdr?l.textureHalfFloatRender?s._defaultPipelineTextureType=P.Y.TEXTURETYPE_HALF_FLOAT:l.textureFloatRender&&(s._defaultPipelineTextureType=P.Y.TEXTURETYPE_FLOAT):s._defaultPipelineTextureType=P.Y.TEXTURETYPE_UNSIGNED_INT,i.postProcessRenderPipelineManager.addPipeline(s);var c=s._scene.getEngine();s.sharpen=new zf("sharpen",1,null,Ie.g.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),s._sharpenEffect=new Ut(c,s.SharpenPostProcessId,function(){return s.sharpen},!0),s.depthOfField=new Vf(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s._hardwareScaleLevel=c.getHardwareScalingLevel(),s._resizeObserver=c.onResizeObservable.add(function(){s._hardwareScaleLevel=c.getHardwareScalingLevel(),s.bloomKernel=s._bloomKernel}),s.bloom=new Lf(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel/s._hardwareScaleLevel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new Ff("ChromaticAberration",c.getRenderWidth(),c.getRenderHeight(),1,null,Ie.g.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),s._chromaticAberrationEffect=new Ut(c,s.ChromaticAberrationPostProcessId,function(){return s.chromaticAberration},!0),s.grain=new Uf("Grain",1,null,Ie.g.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),s._grainEffect=new Ut(c,s.GrainPostProcessId,function(){return s.grain},!0);var u=!0;return s._imageProcessingConfigurationObserver=s._scene.imageProcessingConfiguration.onUpdateParameters.add(function(){s.bloom._downscale._exposure=s._scene.imageProcessingConfiguration.exposure,s.imageProcessingEnabled!==s._scene.imageProcessingConfiguration.isEnabled&&(s._imageProcessingEnabled=s._scene.imageProcessingConfiguration.isEnabled,u?ze.S0.SetImmediate(function(){s._buildPipeline()}):s._buildPipeline())}),s._buildPipeline(),u=!1,s}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"automaticBuild",{get:function(){return this._buildAllowed},set:function(e){this._buildAllowed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomKernel",{get:function(){return this._bloomKernel},set:function(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomWeight",{get:function(){return this._bloomWeight},set:function(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomThreshold",{get:function(){return this._bloomThreshold},set:function(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomScale",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Lf(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel/this._hardwareScaleLevel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var n=0;n<this._cameras.length;n++)e.disposeEffects(this._cameras[n])},Object.defineProperty(t.prototype,"depthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthOfFieldBlurLevel",{get:function(){return this._depthOfFieldBlurLevel},set:function(e){if(this._depthOfFieldBlurLevel!==e){this._depthOfFieldBlurLevel=e;var n=this.depthOfField;this.depthOfField=new Vf(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),this.depthOfField.focalLength=n.focalLength,this.depthOfField.focusDistance=n.focusDistance,this.depthOfField.fStop=n.fStop,this.depthOfField.lensSize=n.lensSize;for(var i=0;i<this._cameras.length;i++)n.disposeEffects(this._cameras[i]);this._buildPipeline()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingEnabled",{get:function(){return this._imageProcessingEnabled},set:function(e){this._imageProcessingEnabled!==e&&(this._scene.imageProcessingConfiguration.isEnabled=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glowLayerEnabled",{get:function(){return this._glowLayer!=null},set:function(e){e&&!this._glowLayer?this._glowLayer=new vl("",this._scene):!e&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glowLayer",{get:function(){return this._glowLayer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chromaticAberrationEnabled",{get:function(){return this._chromaticAberrationEnabled},set:function(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"grainEnabled",{get:function(){return this._grainEnabled},set:function(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DefaultRenderingPipeline"},t.prototype.prepare=function(){var e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e},t.prototype._setAutoClearAndTextureSharing=function(e,n){n===void 0&&(n=!1),this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),n||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)},t.prototype._buildPipeline=function(){var e=this;if(this._buildAllowed){this._scene.autoClear=!0;var n=this._scene.getEngine();if(this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(var i=0,o=this._cameras;i<o.length;i++){var a=o[i];(s=this._scene.enableDepthRenderer(a)).useOnlyInActiveCamera=!0}this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add(function(l){e._cameras.indexOf(l.activeCamera)>-1&&(e.depthOfField.depthTexture=l.enableDepthRenderer(l.activeCamera).getDepthMap())})}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var s=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=s.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new Gf("imageProcessing",1,null,Ie.g.BILINEAR_SAMPLINGMODE,n,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),this._hdr?(this.addEffect(new Ut(n,this.ImageProcessingPostProcessId,function(){return e.imageProcessing},!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this._cameras&&this._cameras.length!==0||(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new ms("fxaa",1,null,Ie.g.BILINEAR_SAMPLINGMODE,n,!1,this._defaultPipelineTextureType),this.addEffect(new Ut(n,this.FxaaPostProcessId,function(){return e.fxaa},!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),(this._scene.activeCameras&&this._scene.activeCameras.length>1||this._scene.activeCamera&&this._cameras.indexOf(this._scene.activeCamera)===-1)&&(this._scene.autoClear=!0),this._activeCameraChangedObserver||(this._activeCameraChangedObserver=this._scene.onActiveCameraChanged.add(function(){e._scene.activeCamera&&e._cameras.indexOf(e._scene.activeCamera)===-1&&(e._scene.autoClear=!0)})),this._activeCamerasChangedObserver||(this._activeCamerasChangedObserver=this._scene.onActiveCamerasChanged.add(function(){e._scene.activeCameras&&e._scene.activeCameras.length>1&&(e._scene.autoClear=!0)})),this._adaptPostProcessesToViewPort(),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&O.V.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}},t.prototype._disposePostProcesses=function(e){e===void 0&&(e=!1);for(var n=0;n<this._cameras.length;n++){var i=this._cameras[n];this.imageProcessing&&this.imageProcessing.dispose(i),this.fxaa&&this.fxaa.dispose(i),e&&(this.sharpen&&this.sharpen.dispose(i),this.depthOfField&&(this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),this.depthOfField.disposeEffects(i)),this.bloom&&this.bloom.disposeEffects(i),this.chromaticAberration&&this.chromaticAberration.dispose(i),this.grain&&this.grain.dispose(i),this._glowLayer&&this._glowLayer.dispose())}this.imageProcessing=null,this.fxaa=null,e&&(this.sharpen=null,this._sharpenEffect=null,this.depthOfField=null,this.bloom=null,this.chromaticAberration=null,this._chromaticAberrationEffect=null,this.grain=null,this._grainEffect=null,this._glowLayer=null)},t.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},t.prototype.removeCamera=function(e){var n=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(n,1),this._buildPipeline()},t.prototype.dispose=function(){this._buildAllowed=!1,this.onBuildObservable.clear(),this._disposePostProcesses(!0),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._scene._postProcessRenderPipelineManager.removePipeline(this.name),this._scene.autoClear=!0,this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this._scene.onActiveCameraChanged.remove(this._activeCameraChangedObserver),this._scene.onActiveCamerasChanged.remove(this._activeCamerasChangedObserver),this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),r.prototype.dispose.call(this)},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.customType="DefaultRenderingPipeline",e},t.Parse=function(e,n,i){return tt.p.Parse(function(){return new t(e._name,e._name._hdr,n)},e,n,i)},(0,A.Cg)([(0,V.lK)()],t.prototype,"sharpenEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"bloomKernel",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"_bloomWeight",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_bloomThreshold",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_hdr",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"bloomWeight",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"bloomThreshold",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"bloomScale",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"bloomEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"depthOfFieldEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"depthOfFieldBlurLevel",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"fxaaEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"samples",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"imageProcessingEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"glowLayerEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"chromaticAberrationEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"grainEnabled",null),t}(uo);(0,j.Y5)("BABYLON.DefaultRenderingPipeline",uT);var GR=L(95579);Gt.l.ShadersStore.lensHighlightsPixelShader=`uniform sampler2D textureSampler;
|
||
uniform float gain;uniform float threshold;uniform float screen_width;uniform float screen_height;varying vec2 vUV;vec4 highlightColor(vec4 color) {vec4 highlight=color;float luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));float lum_threshold;if (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }
|
||
else { lum_threshold=0.5+0.44*threshold; }
|
||
luminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);highlight*=luminance*gain;highlight.a=1.0;return highlight;}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec4 original=texture2D(textureSampler,vUV);if (gain==-1.0) {gl_FragColor=vec4(0.0,0.0,0.0,1.0);return;}
|
||
float w=2.0/screen_width;float h=2.0/screen_height;float weight=1.0;vec4 blurred=vec4(0.0,0.0,0.0,0.0);
|
||
#ifdef PENTAGON
|
||
blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));
|
||
#else
|
||
blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));
|
||
#endif
|
||
blurred/=39.0;gl_FragColor=blurred;}`,Gt.l.ShadersStore.depthOfFieldPixelShader=`uniform sampler2D textureSampler;uniform sampler2D highlightsSampler;uniform sampler2D depthSampler;uniform sampler2D grainSampler;uniform float grain_amount;uniform bool blur_noise;uniform float screen_width;uniform float screen_height;uniform float distortion;uniform bool dof_enabled;uniform float screen_distance;
|
||
uniform float aperture;uniform float darken;uniform float edge_blur;uniform bool highlights;uniform float near;uniform float far;varying vec2 vUV;
|
||
#define PI 3.14159265
|
||
#define TWOPI 6.28318530
|
||
#define inverse_focal_length 0.1
|
||
vec2 centered_screen_pos;vec2 distorted_coords;float radius2;float radius;vec2 rand(vec2 co)
|
||
{float noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));float noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));return clamp(vec2(noise1,noise2),0.0,1.0);}
|
||
vec2 getDistortedCoords(vec2 coords) {if (distortion==0.0) { return coords; }
|
||
vec2 direction=1.0*normalize(centered_screen_pos);vec2 dist_coords=vec2(0.5,0.5);dist_coords.x=0.5+direction.x*radius2*1.0;dist_coords.y=0.5+direction.y*radius2*1.0;float dist_amount=clamp(distortion*0.23,0.0,1.0);dist_coords=mix(coords,dist_coords,dist_amount);return dist_coords;}
|
||
float sampleScreen(inout vec4 color,in vec2 offset,in float weight) {vec2 coords=distorted_coords;float angle=rand(coords*100.0).x*TWOPI;coords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));color+=texture2D(textureSampler,coords)*weight;return weight;}
|
||
float getBlurLevel(float size) {return min(3.0,ceil(size/1.0));}
|
||
vec4 getBlurColor(float size) {vec4 col=texture2D(textureSampler,distorted_coords);float blur_level=getBlurLevel(size);float w=(size/screen_width);float h=(size/screen_height);float total_weight=1.0;vec2 sample_coords;total_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);total_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);total_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);total_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);total_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);total_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);total_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);total_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);total_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);total_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);if (blur_level>1.0) {total_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);total_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);total_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);total_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);total_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);total_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);total_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);total_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);total_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);total_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);}
|
||
if (blur_level>2.0) {total_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);total_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);total_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);total_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);total_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);total_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);total_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);total_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);total_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);}
|
||
col/=total_weight;
|
||
if (darken>0.0) {col.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);}
|
||
return col;}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{centered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);radius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;radius=sqrt(radius2);distorted_coords=getDistortedCoords(vUV);
|
||
vec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height);
|
||
float depth=texture2D(depthSampler,distorted_coords).r;
|
||
float distance=near+(far-near)*depth;
|
||
vec4 color=texture2D(textureSampler,vUV);
|
||
float coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));if (dof_enabled==false || coc<0.07) { coc=0.0; }
|
||
float edge_blur_amount=0.0;if (edge_blur>0.0) {edge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;}
|
||
float blur_amount=max(edge_blur_amount,coc);if (blur_amount==0.0) {gl_FragColor=texture2D(textureSampler,distorted_coords);}
|
||
else {gl_FragColor=getBlurColor(blur_amount*1.7);if (highlights) {gl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;}
|
||
if (blur_noise) {vec2 noise=rand(distorted_coords)*0.01*blur_amount;vec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);gl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;}}
|
||
if (grain_amount>0.0) {vec4 grain_color=texture2D(grainSampler,texels_coords*0.003);gl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;}}
|
||
`;var kR=function(r){function t(e,n,i,o,a){o===void 0&&(o=1);var s=r.call(this,i.getEngine(),e)||this;return s.LensChromaticAberrationEffect="LensChromaticAberrationEffect",s.HighlightsEnhancingEffect="HighlightsEnhancingEffect",s.LensDepthOfFieldEffect="LensDepthOfFieldEffect",s._pentagonBokehIsEnabled=!1,s._scene=i,s._depthTexture=i.enableDepthRenderer().getDepthMap(),n.grain_texture?s._grainTexture=n.grain_texture:s._createGrainTexture(),s._edgeBlur=n.edge_blur?n.edge_blur:0,s._grainAmount=n.grain_amount?n.grain_amount:0,s._chromaticAberration=n.chromatic_aberration?n.chromatic_aberration:0,s._distortion=n.distortion?n.distortion:0,s._highlightsGain=n.dof_gain!==void 0?n.dof_gain:-1,s._highlightsThreshold=n.dof_threshold?n.dof_threshold:1,s._dofDistance=n.dof_focus_distance!==void 0?n.dof_focus_distance:-1,s._dofAperture=n.dof_aperture?n.dof_aperture:1,s._dofDarken=n.dof_darken?n.dof_darken:0,s._dofPentagon=n.dof_pentagon===void 0||n.dof_pentagon,s._blurNoise=n.blur_noise===void 0||n.blur_noise,s._createChromaticAberrationPostProcess(o),s._createHighlightsPostProcess(o),s._createDepthOfFieldPostProcess(o/4),s.addEffect(new Ut(i.getEngine(),s.LensChromaticAberrationEffect,function(){return s._chromaticAberrationPostProcess},!0)),s.addEffect(new Ut(i.getEngine(),s.HighlightsEnhancingEffect,function(){return s._highlightsPostProcess},!0)),s.addEffect(new Ut(i.getEngine(),s.LensDepthOfFieldEffect,function(){return s._depthOfFieldPostProcess},!0)),s._highlightsGain===-1&&s._disableEffect(s.HighlightsEnhancingEffect,null),i.postProcessRenderPipelineManager.addPipeline(s),a&&i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,a),s}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"LensRenderingPipeline"},Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edgeBlur",{get:function(){return this._edgeBlur},set:function(e){this.setEdgeBlur(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"grainAmount",{get:function(){return this._grainAmount},set:function(e){this.setGrainAmount(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chromaticAberration",{get:function(){return this._chromaticAberration},set:function(e){this.setChromaticAberration(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dofAperture",{get:function(){return this._dofAperture},set:function(e){this.setAperture(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edgeDistortion",{get:function(){return this._distortion},set:function(e){this.setEdgeDistortion(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dofDistortion",{get:function(){return this._dofDistance},set:function(e){this.setFocusDistance(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"darkenOutOfFocus",{get:function(){return this._dofDarken},set:function(e){this.setDarkenOutOfFocus(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurNoise",{get:function(){return this._blurNoise},set:function(e){this._blurNoise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pentagonBokeh",{get:function(){return this._pentagonBokehIsEnabled},set:function(e){e?this.enablePentagonBokeh():this.disablePentagonBokeh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightsGain",{get:function(){return this._highlightsGain},set:function(e){this.setHighlightsGain(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightsThreshold",{get:function(){return this._highlightsThreshold},set:function(e){this.setHighlightsThreshold(e)},enumerable:!1,configurable:!0}),t.prototype.setEdgeBlur=function(e){this._edgeBlur=e},t.prototype.disableEdgeBlur=function(){this._edgeBlur=0},t.prototype.setGrainAmount=function(e){this._grainAmount=e},t.prototype.disableGrain=function(){this._grainAmount=0},t.prototype.setChromaticAberration=function(e){this._chromaticAberration=e},t.prototype.disableChromaticAberration=function(){this._chromaticAberration=0},t.prototype.setEdgeDistortion=function(e){this._distortion=e},t.prototype.disableEdgeDistortion=function(){this._distortion=0},t.prototype.setFocusDistance=function(e){this._dofDistance=e},t.prototype.disableDepthOfField=function(){this._dofDistance=-1},t.prototype.setAperture=function(e){this._dofAperture=e},t.prototype.setDarkenOutOfFocus=function(e){this._dofDarken=e},t.prototype.enablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect(`#define PENTAGON
|
||
`),this._pentagonBokehIsEnabled=!0},t.prototype.disablePentagonBokeh=function(){this._pentagonBokehIsEnabled=!1,this._highlightsPostProcess.updateEffect()},t.prototype.enableNoiseBlur=function(){this._blurNoise=!0},t.prototype.disableNoiseBlur=function(){this._blurNoise=!1},t.prototype.setHighlightsGain=function(e){this._highlightsGain=e},t.prototype.setHighlightsThreshold=function(e){this._highlightsGain===-1&&(this._highlightsGain=1),this._highlightsThreshold=e},t.prototype.disableHighlights=function(){this._highlightsGain=-1},t.prototype.dispose=function(e){e===void 0&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=null,this._highlightsPostProcess=null,this._depthOfFieldPostProcess=null,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()},t.prototype._createChromaticAberrationPostProcess=function(e){var n=this;this._chromaticAberrationPostProcess=new _t.w("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],e,null,Ie.g.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=function(i){i.setFloat("chromatic_aberration",n._chromaticAberration),i.setFloat("screen_width",n._scene.getEngine().getRenderWidth()),i.setFloat("screen_height",n._scene.getEngine().getRenderHeight()),i.setFloat("radialIntensity",1),i.setFloat2("direction",17,17),i.setFloat2("centerPosition",.5,.5)}},t.prototype._createHighlightsPostProcess=function(e){var n=this;this._highlightsPostProcess=new _t.w("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],e,null,Ie.g.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?`#define PENTAGON
|
||
`:""),this._highlightsPostProcess.externalTextureSamplerBinding=!0,this._highlightsPostProcess.onApply=function(i){i.setFloat("gain",n._highlightsGain),i.setFloat("threshold",n._highlightsThreshold),i.setTextureFromPostProcess("textureSampler",n._chromaticAberrationPostProcess),i.setFloat("screen_width",n._scene.getEngine().getRenderWidth()),i.setFloat("screen_height",n._scene.getEngine().getRenderHeight())}},t.prototype._createDepthOfFieldPostProcess=function(e){var n=this;this._depthOfFieldPostProcess=new _t.w("LensDepthOfField","depthOfField",["grain_amount","blur_noise","screen_width","screen_height","distortion","dof_enabled","screen_distance","aperture","darken","edge_blur","highlights","near","far"],["depthSampler","grainSampler","highlightsSampler"],e,null,Ie.g.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.externalTextureSamplerBinding=!0,this._depthOfFieldPostProcess.onApply=function(i){i.setTexture("depthSampler",n._depthTexture),i.setTexture("grainSampler",n._grainTexture),i.setTextureFromPostProcess("textureSampler",n._highlightsPostProcess),i.setTextureFromPostProcess("highlightsSampler",n._depthOfFieldPostProcess),i.setFloat("grain_amount",n._grainAmount),i.setBool("blur_noise",n._blurNoise),i.setFloat("screen_width",n._scene.getEngine().getRenderWidth()),i.setFloat("screen_height",n._scene.getEngine().getRenderHeight()),i.setFloat("distortion",n._distortion),i.setBool("dof_enabled",n._dofDistance!==-1),i.setFloat("screen_distance",1/(.1-1/n._dofDistance)),i.setFloat("aperture",n._dofAperture),i.setFloat("darken",n._dofDarken),i.setFloat("edge_blur",n._edgeBlur),i.setBool("highlights",n._highlightsGain!==-1),n._scene.activeCamera&&(i.setFloat("near",n._scene.activeCamera.minZ),i.setFloat("far",n._scene.activeCamera.maxZ))}},t.prototype._createGrainTexture=function(){for(var e=new Uint8Array(1048576),n=0;n<e.length;){var i=Math.floor(255*(0,qe.RandomRange)(.42,.58));e[n++]=i,e[n++]=i,e[n++]=i,e[n++]=255}var o=Ln.CreateRGBATexture(e,512,512,this._scene,!1,!1,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE);o.name="LensNoiseTexture",o.wrapU=Ie.g.WRAP_ADDRESSMODE,o.wrapV=Ie.g.WRAP_ADDRESSMODE,this._grainTexture=o},t}(uo),PN=function(){this.enabled=!1,this.name="ssao2",this.texturesRequired=[P.Y.PREPASS_NORMAL_TEXTURE_TYPE,P.Y.PREPASS_DEPTH_TEXTURE_TYPE]},dT=function(r){function t(e,n,i,o,a,s){a===void 0&&(a=!1),s===void 0&&(s=P.Y.TEXTURETYPE_UNSIGNED_INT);var l,c,u=this;if((u=r.call(this,n.getEngine(),e)||this).SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",u.SSAORenderEffect="SSAORenderEffect",u.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",u.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",u.SSAOCombineRenderEffect="SSAOCombineRenderEffect",u.totalStrength=1,u.maxZ=100,u.minZAspect=.2,u._epsilon=.02,u._samples=8,u._textureSamples=1,u._forceGeometryBuffer=!1,u.radius=2,u.base=0,u._bypassBlur=!1,u._expensiveBlur=!0,u.bilateralSamples=16,u.bilateralSoften=0,u.bilateralTolerance=0,u._bits=new Uint32Array(1),u._scene=n,u._ratio=i,u._textureType=s,u._forceGeometryBuffer=a,!u.isSupported)return O.V.Error("The current engine does not support SSAO 2."),u;var d=u._ratio.ssaoRatio||i,h=u._ratio.blurRatio||i;return u._forceGeometryBuffer?(n.enableGeometryBufferRenderer(),!((l=n.geometryBufferRenderer)===null||l===void 0)&&l.generateNormalsInWorldSpace&&O.V.Error("SSAO2RenderingPipeline does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!")):(n.enablePrePassRenderer(),!((c=n.prePassRenderer)===null||c===void 0)&&c.generateNormalsInWorldSpace&&O.V.Error("SSAO2RenderingPipeline does not support generateNormalsInWorldSpace=true for the prepass renderer!")),u._createRandomTexture(),u._originalColorPostProcess=new ro.v("SSAOOriginalSceneColor",1,null,Ie.g.BILINEAR_SAMPLINGMODE,n.getEngine(),void 0,u._textureType),u._originalColorPostProcess.samples=u.textureSamples,u._createSSAOPostProcess(1,s),u._createBlurPostProcess(d,h,u._textureType),u._createSSAOCombinePostProcess(h,u._textureType),u.addEffect(new Ut(n.getEngine(),u.SSAOOriginalSceneColorEffect,function(){return u._originalColorPostProcess},!0)),u.addEffect(new Ut(n.getEngine(),u.SSAORenderEffect,function(){return u._ssaoPostProcess},!0)),u.addEffect(new Ut(n.getEngine(),u.SSAOBlurHRenderEffect,function(){return u._blurHPostProcess},!0)),u.addEffect(new Ut(n.getEngine(),u.SSAOBlurVRenderEffect,function(){return u._blurVPostProcess},!0)),u.addEffect(new Ut(n.getEngine(),u.SSAOCombineRenderEffect,function(){return u._ssaoCombinePostProcess},!0)),n.postProcessRenderPipelineManager.addPipeline(u),o&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,o),u}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"epsilon",{get:function(){return this._epsilon},set:function(e){this._epsilon=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()),this._sampleSphere=this._generateHemisphere()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureSamples",{get:function(){return this._textureSamples},set:function(e){this._textureSamples=e,this._prePassRenderer?this._prePassRenderer.samples=e:this._originalColorPostProcess.samples=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_geometryBufferRenderer",{get:function(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_prePassRenderer",{get:function(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bypassBlur",{get:function(){return this._bypassBlur},set:function(e){var n=this._getDefinesForBlur(this.expensiveBlur,e),i=this._getSamplersForBlur(e);this._blurHPostProcess.updateEffect(n.h,null,i),this._blurVPostProcess.updateEffect(n.v,null,i),this._bypassBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"expensiveBlur",{get:function(){return this._expensiveBlur},set:function(e){var n=this._getDefinesForBlur(e,this._bypassBlur);this._blurHPostProcess.updateEffect(n.h),this._blurVPostProcess.updateEffect(n.v),this._expensiveBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){var e=Ve.q.LastCreatedEngine;return!!e&&e._features.supportSSAO2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSAO2RenderingPipeline"},t.prototype.dispose=function(e){e===void 0&&(e=!1);for(var n=0;n<this._scene.cameras.length;n++){var i=this._scene.cameras[n];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),r.prototype.dispose.call(this)},t.prototype._rebuild=function(){r.prototype._rebuild.call(this)},t.prototype._getSamplersForBlur=function(e){return e?["textureSampler"]:["textureSampler","depthSampler"]},t.prototype._getDefinesForBlur=function(e,n){var i=`#define BLUR
|
||
`;return n&&(i+=`#define BLUR_BYPASS
|
||
`),e||(i+=`#define BLUR_LEGACY
|
||
`),{h:i+`#define BLUR_H
|
||
`,v:i}},t.prototype._createBlurPostProcess=function(e,n,i){var o=this._getDefinesForBlur(this.expensiveBlur,this.bypassBlur),a=this._getSamplersForBlur(this.bypassBlur);this._blurHPostProcess=this._createBlurFilter("BlurH",a,e,o.h,i,!0),this._blurVPostProcess=this._createBlurFilter("BlurV",a,n,o.v,i,!1)},t.prototype._createBlurFilter=function(e,n,i,o,a,s){var l=this,c=new _t.w(e,"ssao2",["outSize","samples","soften","tolerance"],n,i,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o,a,void 0,void 0,void 0,void 0,this._scene.getEngine().isWebGPU?1:0,function(u,d){u?d.push(Promise.resolve().then(L.bind(L,29059))):d.push(Promise.resolve().then(L.bind(L,16040)))});return c.onApply=function(u){if(l._scene.activeCamera){var d=s?l._ssaoCombinePostProcess.width:l._ssaoCombinePostProcess.height,h=s?l._originalColorPostProcess.width:l._originalColorPostProcess.height;u.setFloat("outSize",d>0?d:h),u.setInt("samples",l.bilateralSamples),u.setFloat("soften",l.bilateralSoften),u.setFloat("tolerance",l.bilateralTolerance),l._geometryBufferRenderer?u.setTexture("depthSampler",l._geometryBufferRenderer.getGBuffer().textures[0]):l._prePassRenderer&&u.setTexture("depthSampler",l._prePassRenderer.getRenderTarget().textures[l._prePassRenderer.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE)])}},c.samples=this.textureSamples,c.autoClear=!1,c},t.prototype._radicalInverse_VdC=function(e){return this._bits[0]=e,this._bits[0]=(this._bits[0]<<16|this._bits[0]>>16)>>>0,this._bits[0]=(1431655765&this._bits[0])<<1|(2863311530&this._bits[0])>>>1>>>0,this._bits[0]=(858993459&this._bits[0])<<2|(3435973836&this._bits[0])>>>2>>>0,this._bits[0]=(252645135&this._bits[0])<<4|(4042322160&this._bits[0])>>>4>>>0,this._bits[0]=(16711935&this._bits[0])<<8|(4278255360&this._bits[0])>>>8>>>0,23283064365386963e-26*this._bits[0]},t.prototype._hammersley=function(e,n){return[e/n,this._radicalInverse_VdC(e)]},t.prototype._hemisphereSample_uniform=function(e,n){var i=2*n*Math.PI,o=1-.85*e,a=Math.sqrt(1-o*o);return new _.Pq(Math.cos(i)*a,Math.sin(i)*a,o)},t.prototype._generateHemisphere=function(){for(var e,n=this.samples,i=[],o=0;o<n;){if(n<16)e=this._hemisphereSample_uniform(Math.random(),Math.random());else{var a=this._hammersley(o,n);e=this._hemisphereSample_uniform(a[0],a[1])}i.push(e.x,e.y,e.z),o++}return i},t.prototype._getDefinesForSSAO=function(){return`#define SSAO
|
||
#define SAMPLES `.concat(this.samples,`
|
||
#define EPSILON `).concat(this.epsilon.toFixed(4))},t.prototype._createSSAOPostProcess=function(e,n){var i=this;this._sampleSphere=this._generateHemisphere();var o=this._getDefinesForSSAO();this._ssaoPostProcess=new _t.w("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","texelSize","xViewport","yViewport","maxZ","minZAspect","depthProjection"],["randomSampler","depthSampler","normalSampler"],e,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o,n,void 0,void 0,void 0,void 0,this._scene.getEngine().isWebGPU?1:0,function(a,s){a?s.push(Promise.resolve().then(L.bind(L,29059))):s.push(Promise.resolve().then(L.bind(L,16040)))}),this._ssaoPostProcess.autoClear=!1,this._ssaoPostProcess.onApply=function(a){var s,l,c,u;if(i._scene.activeCamera){if(a.setArray3("sampleSphere",i._sampleSphere),a.setFloat("randTextureTiles",32),a.setFloat("samplesFactor",1/i.samples),a.setFloat("totalStrength",i.totalStrength),a.setFloat2("texelSize",1/i._ssaoPostProcess.width,1/i._ssaoPostProcess.height),a.setFloat("radius",i.radius),a.setFloat("maxZ",i.maxZ),a.setFloat("minZAspect",i.minZAspect),a.setFloat("base",i.base),a.setFloat("near",i._scene.activeCamera.minZ),i._scene.activeCamera.mode===Pt.PERSPECTIVE_CAMERA)a.setMatrix3x3("depthProjection",t.PERSPECTIVE_DEPTH_PROJECTION),a.setFloat("xViewport",Math.tan(i._scene.activeCamera.fov/2)*i._scene.getEngine().getAspectRatio(i._scene.activeCamera,!0)),a.setFloat("yViewport",Math.tan(i._scene.activeCamera.fov/2));else{var d=i._scene.getEngine().getRenderWidth()/2,h=i._scene.getEngine().getRenderHeight()/2,p=(s=i._scene.activeCamera.orthoLeft)!==null&&s!==void 0?s:-d,m=(l=i._scene.activeCamera.orthoRight)!==null&&l!==void 0?l:d,v=(c=i._scene.activeCamera.orthoBottom)!==null&&c!==void 0?c:-h,b=(u=i._scene.activeCamera.orthoTop)!==null&&u!==void 0?u:h;a.setMatrix3x3("depthProjection",t.ORTHO_DEPTH_PROJECTION),a.setFloat("xViewport",.5*(m-p)),a.setFloat("yViewport",.5*(b-v))}a.setMatrix("projection",i._scene.getProjectionMatrix()),i._geometryBufferRenderer?(a.setTexture("depthSampler",i._geometryBufferRenderer.getGBuffer().textures[0]),a.setTexture("normalSampler",i._geometryBufferRenderer.getGBuffer().textures[1])):i._prePassRenderer&&(a.setTexture("depthSampler",i._prePassRenderer.getRenderTarget().textures[i._prePassRenderer.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE)]),a.setTexture("normalSampler",i._prePassRenderer.getRenderTarget().textures[i._prePassRenderer.getIndex(P.Y.PREPASS_NORMAL_TEXTURE_TYPE)])),a.setTexture("randomSampler",i._randomTexture)}},this._ssaoPostProcess.samples=this.textureSamples,this._forceGeometryBuffer||(this._ssaoPostProcess._prePassEffectConfiguration=new PN)},t.prototype._createSSAOCombinePostProcess=function(e,n){var i=this;this._ssaoCombinePostProcess=new _t.w("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,void 0,n,void 0,void 0,void 0,void 0,this._scene.getEngine().isWebGPU?1:0,function(o,a){o?a.push(Promise.resolve().then(L.bind(L,61186))):a.push(Promise.resolve().then(L.bind(L,19061)))}),this._ssaoCombinePostProcess.onApply=function(o){var a=i._scene.activeCamera.viewport;o.setVector4("viewport",_.AA.Vector4[0].copyFromFloats(a.x,a.y,a.width,a.height)),o.setTextureFromPostProcessOutput("originalColor",i._originalColorPostProcess)},this._ssaoCombinePostProcess.autoClear=!1,this._ssaoCombinePostProcess.samples=this.textureSamples},t.prototype._createRandomTexture=function(){for(var e=new Uint8Array(65536),n=_.I9.Zero(),i=0;i<e.length;)n.set((0,qe.RandomRange)(0,1),(0,qe.RandomRange)(0,1)).normalize().scaleInPlace(255),e[i++]=Math.floor(n.x),e[i++]=Math.floor(n.y),e[i++]=0,e[i++]=255;var o=Ln.CreateRGBATexture(e,128,128,this._scene,!1,!1,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE);o.name="SSAORandomTexture",o.wrapU=Ie.g.WRAP_ADDRESSMODE,o.wrapV=Ie.g.WRAP_ADDRESSMODE,this._randomTexture=o},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.customType="SSAO2RenderingPipeline",e},t.Parse=function(e,n,i){return tt.p.Parse(function(){return new t(e._name,n,e._ratio,void 0,e._forceGeometryBuffer,e._textureType)},e,n,i)},t.ORTHO_DEPTH_PROJECTION=[1,0,0,0,1,0,0,0,1],t.PERSPECTIVE_DEPTH_PROJECTION=[0,0,0,0,0,0,1,1,1],(0,A.Cg)([(0,V.lK)()],t.prototype,"totalStrength",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"maxZ",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"minZAspect",void 0),(0,A.Cg)([(0,V.lK)("epsilon")],t.prototype,"_epsilon",void 0),(0,A.Cg)([(0,V.lK)("samples")],t.prototype,"_samples",void 0),(0,A.Cg)([(0,V.lK)("textureSamples")],t.prototype,"_textureSamples",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_forceGeometryBuffer",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_ratio",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_textureType",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"radius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"base",void 0),(0,A.Cg)([(0,V.lK)("bypassBlur")],t.prototype,"_bypassBlur",void 0),(0,A.Cg)([(0,V.lK)("expensiveBlur")],t.prototype,"_expensiveBlur",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"bilateralSamples",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"bilateralSoften",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"bilateralTolerance",void 0),t}(uo);(0,j.Y5)("BABYLON.SSAO2RenderingPipeline",dT),Gt.l.ShadersStore.ssaoPixelShader=`uniform sampler2D textureSampler;varying vec2 vUV;
|
||
#ifdef SSAO
|
||
uniform sampler2D randomSampler;uniform float randTextureTiles;uniform float samplesFactor;uniform vec3 sampleSphere[SAMPLES];uniform float totalStrength;uniform float radius;uniform float area;uniform float fallOff;uniform float base;vec3 normalFromDepth(float depth,vec2 coords)
|
||
{vec2 offset1=vec2(0.0,radius);vec2 offset2=vec2(radius,0.0);float depth1=texture2D(textureSampler,coords+offset1).r;float depth2=texture2D(textureSampler,coords+offset2).r;vec3 p1=vec3(offset1,depth1-depth);vec3 p2=vec3(offset2,depth2-depth);vec3 normal=cross(p1,p2);normal.z=-normal.z;return normalize(normal);}
|
||
void main()
|
||
{vec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);float depth=texture2D(textureSampler,vUV).r;vec3 position=vec3(vUV,depth);vec3 normal=normalFromDepth(depth,vUV);float radiusDepth=radius/depth;float occlusion=0.0;vec3 ray;vec3 hemiRay;float occlusionDepth;float difference;for (int i=0; i<SAMPLES; i++)
|
||
{ray=radiusDepth*reflect(sampleSphere[i],random);hemiRay=position+sign(dot(ray,normal))*ray;occlusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;difference=depth-occlusionDepth;occlusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));}
|
||
float ao=1.0-totalStrength*occlusion*samplesFactor;float result=clamp(ao+base,0.0,1.0);gl_FragColor.r=result;gl_FragColor.g=result;gl_FragColor.b=result;gl_FragColor.a=1.0;}
|
||
#endif
|
||
`;var zR=L(19061),WR=function(r){function t(e,n,i,o){var a=r.call(this,n.getEngine(),e)||this;a.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",a.SSAORenderEffect="SSAORenderEffect",a.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",a.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",a.SSAOCombineRenderEffect="SSAOCombineRenderEffect",a.totalStrength=1,a.radius=1e-4,a.area=.0075,a.fallOff=1e-6,a.base=.5,a._firstUpdate=!0,a._scene=n,a._createRandomTexture();var s=i.ssaoRatio||i,l=i.combineRatio||i;return a._originalColorPostProcess=new ro.v("SSAOOriginalSceneColor",l,null,Ie.g.BILINEAR_SAMPLINGMODE,n.getEngine(),!1),a._createSSAOPostProcess(s),a._createBlurPostProcess(s),a._createSSAOCombinePostProcess(l),a.addEffect(new Ut(n.getEngine(),a.SSAOOriginalSceneColorEffect,function(){return a._originalColorPostProcess},!0)),a.addEffect(new Ut(n.getEngine(),a.SSAORenderEffect,function(){return a._ssaoPostProcess},!0)),a.addEffect(new Ut(n.getEngine(),a.SSAOBlurHRenderEffect,function(){return a._blurHPostProcess},!0)),a.addEffect(new Ut(n.getEngine(),a.SSAOBlurVRenderEffect,function(){return a._blurVPostProcess},!0)),a.addEffect(new Ut(n.getEngine(),a.SSAOCombineRenderEffect,function(){return a._ssaoCombinePostProcess},!0)),n.postProcessRenderPipelineManager.addPipeline(a),o&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,o),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype._attachCameras=function(e,n){r.prototype._attachCameras.call(this,e,n);for(var i=0,o=this._cameras;i<o.length;i++){var a=o[i];this._scene.enableDepthRenderer(a).getDepthMap()}},t.prototype.getClassName=function(){return"SSAORenderingPipeline"},t.prototype.dispose=function(e){e===void 0&&(e=!1);for(var n=0;n<this._scene.cameras.length;n++){var i=this._scene.cameras[n];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),r.prototype.dispose.call(this)},t.prototype._createBlurPostProcess=function(e){var n=this;this._blurHPostProcess=new ci("BlurH",new _.I9(1,0),16,e,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,P.Y.TEXTURETYPE_UNSIGNED_INT),this._blurVPostProcess=new ci("BlurV",new _.I9(0,1),16,e,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,P.Y.TEXTURETYPE_UNSIGNED_INT),this._blurHPostProcess.onActivateObservable.add(function(){var i=n._blurHPostProcess.width/n._scene.getEngine().getRenderWidth();n._blurHPostProcess.kernel=16*i}),this._blurVPostProcess.onActivateObservable.add(function(){var i=n._blurVPostProcess.height/n._scene.getEngine().getRenderHeight();n._blurVPostProcess.kernel=16*i})},t.prototype._rebuild=function(){this._firstUpdate=!0,r.prototype._rebuild.call(this)},t.prototype._createSSAOPostProcess=function(e){var n=this,i=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271];this._ssaoPostProcess=new _t.w("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],e,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,`#define SAMPLES 16
|
||
#define SSAO`),this._ssaoPostProcess.externalTextureSamplerBinding=!0,this._ssaoPostProcess.onApply=function(o){n._firstUpdate&&(o.setArray3("sampleSphere",i),o.setFloat("samplesFactor",.0625),o.setFloat("randTextureTiles",4)),o.setFloat("totalStrength",n.totalStrength),o.setFloat("radius",n.radius),o.setFloat("area",n.area),o.setFloat("fallOff",n.fallOff),o.setFloat("base",n.base),o.setTexture("textureSampler",n._scene.enableDepthRenderer(n._scene.activeCamera).getDepthMap()),o.setTexture("randomSampler",n._randomTexture)}},t.prototype._createSSAOCombinePostProcess=function(e){var n=this;this._ssaoCombinePostProcess=new _t.w("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,Ie.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(i){i.setVector4("viewport",_.AA.Vector4[0].copyFromFloats(0,0,1,1)),i.setTextureFromPostProcess("originalColor",n._originalColorPostProcess)}},t.prototype._createRandomTexture=function(){for(var e=new Uint8Array(1048576),n=0;n<e.length;)e[n++]=Math.floor(255*Math.max(0,(0,qe.RandomRange)(-1,1))),e[n++]=Math.floor(255*Math.max(0,(0,qe.RandomRange)(-1,1))),e[n++]=Math.floor(255*Math.max(0,(0,qe.RandomRange)(-1,1))),e[n++]=255;var i=Ln.CreateRGBATexture(e,512,512,this._scene,!1,!1,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE);i.name="SSAORandomTexture",i.wrapU=Ie.g.WRAP_ADDRESSMODE,i.wrapV=Ie.g.WRAP_ADDRESSMODE,this._randomTexture=i},(0,A.Cg)([(0,V.lK)()],t.prototype,"totalStrength",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"radius",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"area",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"fallOff",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"base",void 0),t}(uo),AN=function(){this.enabled=!1,this.name="screenSpaceReflections",this.texturesRequired=[P.Y.PREPASS_NORMAL_TEXTURE_TYPE,P.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE,P.Y.PREPASS_POSITION_TEXTURE_TYPE]};Gt.l.ShadersStore.screenSpaceReflectionPixelShader=`uniform sampler2D textureSampler;
|
||
#ifdef SSR_SUPPORTED
|
||
uniform sampler2D reflectivitySampler;uniform sampler2D normalSampler;uniform sampler2D positionSampler;
|
||
#endif
|
||
uniform mat4 view;uniform mat4 projection;uniform float stepSize;uniform float strength;uniform float threshold;uniform float roughnessFactor;uniform float reflectionSpecularFalloffExponent;varying vec2 vUV;
|
||
#ifdef SSR_SUPPORTED
|
||
struct ReflectionInfo {vec3 color;vec4 coords;};/**
|
||
* According to specular,see https:
|
||
*/
|
||
vec3 fresnelSchlick(float cosTheta,vec3 F0)
|
||
{return F0+(1.0-F0)*pow(1.0-cosTheta,5.0);}
|
||
/**
|
||
* Once the pixel's coordinates has been found,let's adjust (smooth) a little bit
|
||
* by sampling multiple reflection pixels.
|
||
*/
|
||
ReflectionInfo smoothReflectionInfo(vec3 dir,vec3 hitCoord)
|
||
{ReflectionInfo info;info.color=vec3(0.0);vec4 projectedCoord;float sampledDepth;for(int i=0; i<SMOOTH_STEPS; i++)
|
||
{projectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);sampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;float depth=sampledDepth-hitCoord.z;dir*=0.5;if(depth>0.0)
|
||
hitCoord-=dir;else
|
||
hitCoord+=dir;info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;}
|
||
projectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);info.coords=vec4(projectedCoord.xy,sampledDepth,1.0);info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;info.color/=float(SMOOTH_STEPS+1);return info;}
|
||
/**
|
||
* Tests the given world position (hitCoord) according to the given reflection vector (dir)
|
||
* until it finds a collision (means that depth is enough close to say "it's the pixel to sample!").
|
||
*/
|
||
ReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)
|
||
{ReflectionInfo info;vec4 projectedCoord;float sampledDepth;dir*=stepSize;for(int i=0; i<REFLECTION_SAMPLES; i++)
|
||
{hitCoord+=dir;projectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);sampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;float depth=sampledDepth-hitCoord.z;
|
||
#ifdef RIGHT_HANDED_SCENE
|
||
depth*=-1.0;
|
||
#endif
|
||
if(((depth-dir.z)<threshold) && depth<=0.0)
|
||
{
|
||
#ifdef ENABLE_SMOOTH_REFLECTIONS
|
||
return smoothReflectionInfo(dir,hitCoord);
|
||
#else
|
||
info.color=texture2D(textureSampler,projectedCoord.xy).rgb;info.coords=vec4(projectedCoord.xy,sampledDepth,0.0);return info;
|
||
#endif
|
||
}}
|
||
info.color=texture2D(textureSampler,projectedCoord.xy).rgb;info.coords=vec4(projectedCoord.xy,sampledDepth,0.0);return info;}
|
||
vec3 hash(vec3 a)
|
||
{a=fract(a*0.8);a+=dot(a,a.yxz+19.19);return fract((a.xxy+a.yxx)*a.zyx);}
|
||
#endif
|
||
void main()
|
||
{
|
||
#ifdef SSR_SUPPORTED
|
||
vec4 albedoFull=texture2D(textureSampler,vUV);vec3 albedo=albedoFull.rgb;float spec=texture2D(reflectivitySampler,vUV).r;if (spec==0.0) {gl_FragColor=albedoFull;return;}
|
||
vec3 normal=(texture2D(normalSampler,vUV)).xyz;vec3 position=(view*texture2D(positionSampler,vUV)).xyz;vec3 reflected=normalize(reflect(normalize(position),normalize(normal)));float roughness=1.0-texture2D(reflectivitySampler,vUV).a;vec3 jitt=mix(vec3(0.0),hash(position),roughness)*roughnessFactor;ReflectionInfo info=getReflectionInfo(jitt+reflected,position);vec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-info.coords.xy));float screenEdgefactor=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);vec3 F0=vec3(0.04);F0 =mix(F0,albedo,spec);vec3 fresnel=fresnelSchlick(max(dot(normalize(normal),normalize(position)),0.0),F0);
|
||
#ifdef RIGHT_HANDED_SCENE
|
||
reflected.z*=-1.0;
|
||
#endif
|
||
float reflectionMultiplier=clamp(pow(spec*strength,reflectionSpecularFalloffExponent)*screenEdgefactor*reflected.z,0.0,0.9);float albedoMultiplier=1.0-reflectionMultiplier;vec3 SSR=info.color*fresnel;gl_FragColor=vec4((albedo*albedoMultiplier)+(SSR*reflectionMultiplier),albedoFull.a);
|
||
#else
|
||
gl_FragColor=texture2D(textureSampler,vUV);
|
||
#endif
|
||
}
|
||
`;var Wf=function(r){function t(e,n,i,o,a,s,l,c,u,d){c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=!1),d===void 0&&(d=!1);var h=r.call(this,e,"screenSpaceReflection",["projection","view","threshold","reflectionSpecularFalloffExponent","strength","stepSize","roughnessFactor"],["textureSampler","normalSampler","positionSampler","reflectivitySampler"],i,o,a,s,l,`#define SSR_SUPPORTED
|
||
#define REFLECTION_SAMPLES 64
|
||
#define SMOOTH_STEPS 5
|
||
`,c,void 0,null,u)||this;if(h.threshold=1.2,h.strength=1,h.reflectionSpecularFalloffExponent=3,h.step=1,h.roughnessFactor=.2,h._forceGeometryBuffer=!1,h._enableSmoothReflections=!1,h._reflectionSamples=64,h._smoothSteps=5,h._forceGeometryBuffer=d,h._forceGeometryBuffer){var p=n.enableGeometryBufferRenderer();p&&p.isSupported&&(p.enablePosition=!0,p.enableReflectivity=!0,p.generateNormalsInWorldSpace&&O.V.Error("ScreenSpaceReflectionPostProcess does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!"))}else{var m=n.enablePrePassRenderer();m?.markAsDirty(),m?.generateNormalsInWorldSpace&&O.V.Error("ScreenSpaceReflectionPostProcess does not support generateNormalsInWorldSpace=true for the prepass renderer!"),h._prePassEffectConfiguration=new AN}return h._updateEffectDefines(),h.onApply=function(v){var b=h._geometryBufferRenderer,E=h._prePassRenderer;if(E||b){if(b){var C=b.getTextureIndex(zn.POSITION_TEXTURE_TYPE),T=b.getTextureIndex(zn.REFLECTIVITY_TEXTURE_TYPE);v.setTexture("normalSampler",b.getGBuffer().textures[1]),v.setTexture("positionSampler",b.getGBuffer().textures[C]),v.setTexture("reflectivitySampler",b.getGBuffer().textures[T])}else if(E){C=E.getIndex(P.Y.PREPASS_POSITION_TEXTURE_TYPE),T=E.getIndex(P.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE);var f=E.getIndex(P.Y.PREPASS_NORMAL_TEXTURE_TYPE);v.setTexture("normalSampler",E.getRenderTarget().textures[f]),v.setTexture("positionSampler",E.getRenderTarget().textures[C]),v.setTexture("reflectivitySampler",E.getRenderTarget().textures[T])}var g=n.activeCamera;if(g){var S=g.getViewMatrix(!0),y=g.getProjectionMatrix(!0);v.setMatrix("projection",y),v.setMatrix("view",S),v.setFloat("threshold",h.threshold),v.setFloat("reflectionSpecularFalloffExponent",h.reflectionSpecularFalloffExponent),v.setFloat("strength",h.strength),v.setFloat("stepSize",h.step),v.setFloat("roughnessFactor",h.roughnessFactor)}}},h._isSceneRightHanded=n.useRightHandedSystem,h}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"_geometryBufferRenderer",{get:function(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_prePassRenderer",{get:function(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"ScreenSpaceReflectionPostProcess"},Object.defineProperty(t.prototype,"enableSmoothReflections",{get:function(){return this._enableSmoothReflections},set:function(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionSamples",{get:function(){return this._reflectionSamples},set:function(e){e!==this._reflectionSamples&&(this._reflectionSamples=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"smoothSteps",{get:function(){return this._smoothSteps},set:function(e){e!==this._smoothSteps&&(this._smoothSteps=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),t.prototype._updateEffectDefines=function(){var e=[];(this._geometryBufferRenderer||this._prePassRenderer)&&e.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&e.push("#define ENABLE_SMOOTH_REFLECTIONS"),this._isSceneRightHanded&&e.push("#define RIGHT_HANDED_SCENE"),e.push("#define REFLECTION_SAMPLES "+(0|this._reflectionSamples)),e.push("#define SMOOTH_STEPS "+(0|this._smoothSteps)),this.updateEffect(e.join(`
|
||
`))},t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,i,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"threshold",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"strength",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"reflectionSpecularFalloffExponent",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"step",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"roughnessFactor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"enableSmoothReflections",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"reflectionSamples",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"smoothSteps",null),t}(_t.w);(0,j.Y5)("BABYLON.ScreenSpaceReflectionPostProcess",Wf),Gt.l.ShadersStore.standardPixelShader=`uniform sampler2D textureSampler;varying vec2 vUV;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
#if defined(PASS_POST_PROCESS)
|
||
void main(void)
|
||
{vec4 color=texture2D(textureSampler,vUV);gl_FragColor=color;}
|
||
#endif
|
||
#if defined(DOWN_SAMPLE_X4)
|
||
uniform vec2 dsOffsets[16];void main(void)
|
||
{vec4 average=vec4(0.0,0.0,0.0,0.0);average=texture2D(textureSampler,vUV+dsOffsets[0]);average+=texture2D(textureSampler,vUV+dsOffsets[1]);average+=texture2D(textureSampler,vUV+dsOffsets[2]);average+=texture2D(textureSampler,vUV+dsOffsets[3]);average+=texture2D(textureSampler,vUV+dsOffsets[4]);average+=texture2D(textureSampler,vUV+dsOffsets[5]);average+=texture2D(textureSampler,vUV+dsOffsets[6]);average+=texture2D(textureSampler,vUV+dsOffsets[7]);average+=texture2D(textureSampler,vUV+dsOffsets[8]);average+=texture2D(textureSampler,vUV+dsOffsets[9]);average+=texture2D(textureSampler,vUV+dsOffsets[10]);average+=texture2D(textureSampler,vUV+dsOffsets[11]);average+=texture2D(textureSampler,vUV+dsOffsets[12]);average+=texture2D(textureSampler,vUV+dsOffsets[13]);average+=texture2D(textureSampler,vUV+dsOffsets[14]);average+=texture2D(textureSampler,vUV+dsOffsets[15]);average/=16.0;gl_FragColor=average;}
|
||
#endif
|
||
#if defined(BRIGHT_PASS)
|
||
uniform vec2 dsOffsets[4];uniform float brightThreshold;void main(void)
|
||
{vec4 average=vec4(0.0,0.0,0.0,0.0);average=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));average+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));average*=0.25;float luminance=length(average.rgb);if (luminance<brightThreshold) {average=vec4(0.0,0.0,0.0,1.0);}
|
||
gl_FragColor=average;}
|
||
#endif
|
||
#if defined(TEXTURE_ADDER)
|
||
uniform sampler2D otherSampler;uniform sampler2D lensSampler;uniform float exposure;void main(void)
|
||
{vec3 colour=texture2D(textureSampler,vUV).rgb;colour*=exposure;vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);colour=retColor*retColor;colour+=colour*texture2D(lensSampler,vUV).rgb;vec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);gl_FragColor=finalColor;}
|
||
#endif
|
||
#if defined(VLS)
|
||
#define PI 3.1415926535897932384626433832795
|
||
uniform mat4 shadowViewProjection;uniform mat4 lightWorld;uniform vec3 cameraPosition;uniform vec3 sunDirection;uniform vec3 sunColor;uniform vec2 depthValues;uniform float scatteringCoefficient;uniform float scatteringPower;uniform sampler2D shadowMapSampler;uniform sampler2D positionSampler;float computeScattering(float lightDotView)
|
||
{float result=1.0-scatteringCoefficient*scatteringCoefficient;result/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));return result;}
|
||
void main(void)
|
||
{vec3 worldPos=texture2D(positionSampler,vUV).rgb;vec3 startPosition=cameraPosition;vec3 rayVector=worldPos-startPosition;float rayLength=length(rayVector);vec3 rayDirection=rayVector/rayLength;float stepLength=rayLength/NB_STEPS;vec3 stepL=rayDirection*stepLength;vec3 currentPosition=startPosition;vec3 accumFog=vec3(0.0);for (int i=0; i<int(NB_STEPS); i++)
|
||
{vec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);float depthMetric= (worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depthMetric,0.0,1.0);worldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;worldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);float shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;if (shadowMapValue>shadowPixelDepth)
|
||
accumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));currentPosition+=stepL;}
|
||
accumFog/=NB_STEPS;vec3 color=accumFog*scatteringPower;gl_FragColor=vec4(color*exp(color) ,1.0);}
|
||
#endif
|
||
#if defined(VLSMERGE)
|
||
uniform sampler2D originalSampler;void main(void)
|
||
{gl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);}
|
||
#endif
|
||
#if defined(LUMINANCE)
|
||
uniform vec2 lumOffsets[4];void main()
|
||
{float average=0.0;vec4 color=vec4(0.0);float maximum=-1e20;vec3 weight=vec3(0.299,0.587,0.114);for (int i=0; i<4; i++)
|
||
{color=texture2D(textureSampler,vUV+ lumOffsets[i]);float GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));
|
||
#ifdef WEIGHTED_AVERAGE
|
||
float GreyValue=dot(color.rgb,weight);
|
||
#endif
|
||
#ifdef BRIGHTNESS
|
||
float GreyValue=max(color.r,max(color.g,color.b));
|
||
#endif
|
||
#ifdef HSL_COMPONENT
|
||
float GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));
|
||
#endif
|
||
#ifdef MAGNITUDE
|
||
float GreyValue=length(color.rgb);
|
||
#endif
|
||
maximum=max(maximum,GreyValue);average+=(0.25*log(1e-5+GreyValue));}
|
||
average=exp(average);gl_FragColor=vec4(average,maximum,0.0,1.0);}
|
||
#endif
|
||
#if defined(LUMINANCE_DOWN_SAMPLE)
|
||
uniform vec2 dsOffsets[9];uniform float halfDestPixelSize;
|
||
#ifdef FINAL_DOWN_SAMPLER
|
||
#include<packingFunctions>
|
||
#endif
|
||
void main()
|
||
{vec4 color=vec4(0.0);float average=0.0;for (int i=0; i<9; i++)
|
||
{color=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);average+=color.r;}
|
||
average/=9.0;
|
||
#ifdef FINAL_DOWN_SAMPLER
|
||
gl_FragColor=pack(average);
|
||
#else
|
||
gl_FragColor=vec4(average,average,0.0,1.0);
|
||
#endif
|
||
}
|
||
#endif
|
||
#if defined(HDR)
|
||
uniform sampler2D textureAdderSampler;uniform float averageLuminance;void main()
|
||
{vec4 color=texture2D(textureAdderSampler,vUV);
|
||
#ifndef AUTO_EXPOSURE
|
||
vec4 adjustedColor=color/averageLuminance;color=adjustedColor;color.a=1.0;
|
||
#endif
|
||
gl_FragColor=color;}
|
||
#endif
|
||
#if defined(LENS_FLARE)
|
||
#define GHOSTS 3
|
||
uniform sampler2D lensColorSampler;uniform float strength;uniform float ghostDispersal;uniform float haloWidth;uniform vec2 resolution;uniform float distortionStrength;float hash(vec2 p)
|
||
{float h=dot(p,vec2(127.1,311.7));return -1.0+2.0*fract(sin(h)*43758.5453123);}
|
||
float noise(in vec2 p)
|
||
{vec2 i=floor(p);vec2 f=fract(p);vec2 u=f*f*(3.0-2.0*f);return mix(mix(hash(i+vec2(0.0,0.0)),
|
||
hash(i+vec2(1.0,0.0)),u.x),
|
||
mix(hash(i+vec2(0.0,1.0)),
|
||
hash(i+vec2(1.0,1.0)),u.x),u.y);}
|
||
float fbm(vec2 p)
|
||
{float f=0.0;f+=0.5000*noise(p); p*=2.02;f+=0.2500*noise(p); p*=2.03;f+=0.1250*noise(p); p*=2.01;f+=0.0625*noise(p); p*=2.04;f/=0.9375;return f;}
|
||
vec3 pattern(vec2 uv)
|
||
{vec2 p=-1.0+2.0*uv;float p2=dot(p,p);float f=fbm(vec2(15.0*p2))/2.0;float r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));float g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));float b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));return (1.0-f)*vec3(r,g,b);}
|
||
float luminance(vec3 color)
|
||
{return dot(color.rgb,vec3(0.2126,0.7152,0.0722));}
|
||
vec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)
|
||
{return vec4(
|
||
texture2D(tex,texcoord+direction*distortion.r).r,
|
||
texture2D(tex,texcoord+direction*distortion.g).g,
|
||
texture2D(tex,texcoord+direction*distortion.b).b,
|
||
1.0
|
||
);}
|
||
void main(void)
|
||
{vec2 uv=-vUV+vec2(1.0);vec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;vec2 texelSize=1.0/resolution;vec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);vec4 result=vec4(0.0);float ghostIndice=1.0;for (int i=0; i<GHOSTS; ++i)
|
||
{vec2 offset=fract(uv+ghostDir*ghostIndice);float weight=length(vec2(0.5)-offset)/length(vec2(0.5));weight=pow(1.0-weight,10.0);result+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;ghostIndice+=1.0;}
|
||
vec2 haloVec=normalize(ghostDir)*haloWidth;float weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));weight=pow(1.0-weight,10.0);result+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;result*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));gl_FragColor=result;}
|
||
#endif
|
||
#if defined(LENS_FLARE_COMPOSE)
|
||
uniform sampler2D otherSampler;uniform sampler2D lensDirtSampler;uniform sampler2D lensStarSampler;uniform mat4 lensStarMatrix;void main(void)
|
||
{vec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;vec4 lensMod=texture2D(lensDirtSampler,vUV);lensMod+=texture2D(lensStarSampler,vUV/*lensFlareCoords*/);vec4 result=texture2D(textureSampler,vUV)*lensMod;gl_FragColor=texture2D(otherSampler,vUV)+result;}
|
||
#endif
|
||
#if defined(DEPTH_OF_FIELD)
|
||
uniform sampler2D otherSampler;uniform sampler2D depthSampler;uniform float distance;void main(void)
|
||
{vec4 sharp=texture2D(otherSampler,vUV);vec4 blur=texture2D(textureSampler,vUV);float dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);float factor=0.0;if (dist<0.05)
|
||
factor=1.0;else if (dist<0.1)
|
||
factor=20.0*(0.1-dist);else if (dist<0.5)
|
||
factor=0.0;else
|
||
factor=2.0*(dist-0.5);factor=clamp(factor,0.0,0.90);gl_FragColor=mix(sharp,blur,factor);}
|
||
#endif
|
||
#if defined(MOTION_BLUR)
|
||
uniform mat4 inverseViewProjection;uniform mat4 prevViewProjection;uniform vec2 screenSize;uniform float motionScale;uniform float motionStrength;uniform sampler2D depthSampler;void main(void)
|
||
{vec2 texelSize=1.0/screenSize;float depth=texture2D(depthSampler,vUV).r;vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);cpos=cpos*inverseViewProjection;vec4 ppos=cpos*prevViewProjection;ppos.xyz/=ppos.w;ppos.xy=ppos.xy*0.5+0.5;vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;float speed=length(velocity/texelSize);int nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));vec4 result=texture2D(textureSampler,vUV);for (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {if (i>=nSamples)
|
||
break;vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);result+=texture2D(textureSampler,offset1);}
|
||
gl_FragColor=result/float(nSamples);}
|
||
#endif
|
||
`;var hT=function(r){function t(e,n,i,o,a){o===void 0&&(o=null);var s=r.call(this,n.getEngine(),e)||this;return s.downSampleX4PostProcess=null,s.brightPassPostProcess=null,s.blurHPostProcesses=[],s.blurVPostProcesses=[],s.textureAdderPostProcess=null,s.volumetricLightPostProcess=null,s.volumetricLightSmoothXPostProcess=null,s.volumetricLightSmoothYPostProcess=null,s.volumetricLightMergePostProces=null,s.volumetricLightFinalPostProcess=null,s.luminancePostProcess=null,s.luminanceDownSamplePostProcesses=[],s.hdrPostProcess=null,s.textureAdderFinalPostProcess=null,s.lensFlareFinalPostProcess=null,s.hdrFinalPostProcess=null,s.lensFlarePostProcess=null,s.lensFlareComposePostProcess=null,s.motionBlurPostProcess=null,s.depthOfFieldPostProcess=null,s.fxaaPostProcess=null,s.screenSpaceReflectionPostProcess=null,s.brightThreshold=1,s.blurWidth=512,s.horizontalBlur=!1,s.lensTexture=null,s.volumetricLightCoefficient=.2,s.volumetricLightPower=4,s.volumetricLightBlurScale=64,s.sourceLight=null,s.hdrMinimumLuminance=1,s.hdrDecreaseRate=.5,s.hdrIncreaseRate=.5,s.lensColorTexture=null,s.lensFlareStrength=20,s.lensFlareGhostDispersal=1.4,s.lensFlareHaloWidth=.7,s.lensFlareDistortionStrength=16,s.lensFlareBlurWidth=512,s.lensStarTexture=null,s.lensFlareDirtTexture=null,s.depthOfFieldDistance=10,s.depthOfFieldBlurWidth=64,s.animations=[],s._currentDepthOfFieldSource=null,s._fixedExposure=1,s._currentExposure=1,s._hdrAutoExposure=!1,s._hdrCurrentLuminance=1,s._motionStrength=1,s._isObjectBasedMotionBlur=!1,s._camerasToBeAttached=[],s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._vlsEnabled=!1,s._lensFlareEnabled=!1,s._hdrEnabled=!1,s._motionBlurEnabled=!1,s._fxaaEnabled=!1,s._screenSpaceReflectionsEnabled=!1,s._motionBlurSamples=64,s._volumetricLightStepsCount=50,s._samples=1,s._cameras=a||n.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._scene=n,s._basePostProcess=o,s._ratio=i,s._floatTextureType=n.getEngine().getCaps().textureFloatRender?P.Y.TEXTURETYPE_FLOAT:P.Y.TEXTURETYPE_HALF_FLOAT,n.postProcessRenderPipelineManager.addPipeline(s),s._buildPipeline(),s}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._fixedExposure},set:function(e){this._fixedExposure=e,this._currentExposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hdrAutoExposure",{get:function(){return this._hdrAutoExposure},set:function(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){var n=["#define HDR"];e&&n.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(n.join(`
|
||
`))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionStrength",{get:function(){return this._motionStrength},set:function(e){this._motionStrength=e,this._isObjectBasedMotionBlur&&this.motionBlurPostProcess&&(this.motionBlurPostProcess.motionStrength=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"objectBasedMotionBlur",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var n=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,n&&this._buildPipeline()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e&&!this._scene.enableGeometryBufferRenderer())return void O.V.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screenSpaceReflectionsEnabled",{get:function(){return this._screenSpaceReflectionsEnabled},set:function(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect(`#define VLS
|
||
#define NB_STEPS `+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&(this._isObjectBasedMotionBlur?this.motionBlurPostProcess.motionBlurSamples=e:this.motionBlurPostProcess.updateEffect(`#define MOTION_BLUR
|
||
#define MAX_MOTION_SAMPLES `+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,n=this._ratio,i=this._scene;this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new Wf("HDRPass",i,n,null,Ie.g.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add(function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess}),this.addEffect(new Ut(i.getEngine(),"HDRScreenSpaceReflections",function(){return e.screenSpaceReflectionPostProcess},!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new _t.w("HDRPass","standard",[],[],n,null,Ie.g.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.autoClear=!this.screenSpaceReflectionPostProcess,this.originalPostProcess.onApplyObservable.add(function(){e._currentDepthOfFieldSource=e.originalPostProcess}),this.addEffect(new Ut(i.getEngine(),"HDRPassPostProcess",function(){return e.originalPostProcess},!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(i,n/4),this._createBrightPassPostProcess(i,n/4),this._createBlurPostProcesses(i,n/4,1),this._createTextureAdderPostProcess(i,n),this.textureAdderFinalPostProcess=new _t.w("HDRDepthOfFieldSource","standard",[],[],n,null,Ie.g.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",P.Y.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Ut(i.getEngine(),"HDRBaseDepthOfFieldSource",function(){return e.textureAdderFinalPostProcess},!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,n),this.volumetricLightFinalPostProcess=new _t.w("HDRVLSFinal","standard",[],[],n,null,Ie.g.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",P.Y.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Ut(i.getEngine(),"HDRVLSFinal",function(){return e.volumetricLightFinalPostProcess},!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,n),this.lensFlareFinalPostProcess=new _t.w("HDRPostLensFlareDepthOfFieldSource","standard",[],[],n,null,Ie.g.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",P.Y.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Ut(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",function(){return e.lensFlareFinalPostProcess},!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,n),this.hdrFinalPostProcess=new _t.w("HDRPostHDReDepthOfFieldSource","standard",[],[],n,null,Ie.g.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",P.Y.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Ut(i.getEngine(),"HDRPostHDReDepthOfFieldSource",function(){return e.hdrFinalPostProcess},!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(i,n/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(i,n)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(i,n),this._fxaaEnabled&&(this.fxaaPostProcess=new ms("fxaa",1,null,Ie.g.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,P.Y.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Ut(i.getEngine(),"HDRFxaa",function(){return e.fxaaPostProcess},!0))),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&O.V.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},t.prototype._createDownSampleX4PostProcess=function(e,n){var i=this,o=new Array(32);this.downSampleX4PostProcess=new _t.w("HDRDownSampleX4","standard",["dsOffsets"],[],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(a){for(var s=0,l=i.downSampleX4PostProcess.width,c=i.downSampleX4PostProcess.height,u=-2;u<2;u++)for(var d=-2;d<2;d++)o[s]=(u+.5)*(1/l),o[s+1]=(d+.5)*(1/c),s+=2;a.setArray2("dsOffsets",o)},this.addEffect(new Ut(e.getEngine(),"HDRDownSampleX4",function(){return i.downSampleX4PostProcess},!0))},t.prototype._createBrightPassPostProcess=function(e,n){var i=this,o=new Array(8);this.brightPassPostProcess=new _t.w("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(a){var s=1/i.brightPassPostProcess.width,l=1/i.brightPassPostProcess.height;o[0]=-.5*s,o[1]=.5*l,o[2]=.5*s,o[3]=.5*l,o[4]=-.5*s,o[5]=-.5*l,o[6]=.5*s,o[7]=-.5*l,a.setArray2("dsOffsets",o),a.setFloat("brightThreshold",i.brightThreshold)},this.addEffect(new Ut(e.getEngine(),"HDRBrightPass",function(){return i.brightPassPostProcess},!0))},t.prototype._createBlurPostProcesses=function(e,n,i,o){var a=this;o===void 0&&(o="blurWidth");var s=e.getEngine(),l=new ci("HDRBlurH_"+i,new _.I9(1,0),this[o],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),c=new ci("HDRBlurV_"+i,new _.I9(0,1),this[o],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);l.onActivateObservable.add(function(){var u=l.width/s.getRenderWidth();l.kernel=a[o]*u}),c.onActivateObservable.add(function(){var u=c.height/s.getRenderHeight();c.kernel=a.horizontalBlur?64*u:a[o]*u}),this.addEffect(new Ut(e.getEngine(),"HDRBlurH"+i,function(){return l},!0)),this.addEffect(new Ut(e.getEngine(),"HDRBlurV"+i,function(){return c},!0)),this.blurHPostProcesses.push(l),this.blurVPostProcesses.push(c)},t.prototype._createTextureAdderPostProcess=function(e,n){var i=this;this.textureAdderPostProcess=new _t.w("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(o){o.setTextureFromPostProcess("otherSampler",i._vlsEnabled?i._currentDepthOfFieldSource:i.originalPostProcess),o.setTexture("lensSampler",i.lensTexture),o.setFloat("exposure",i._currentExposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new Ut(e.getEngine(),"HDRTextureAdder",function(){return i.textureAdderPostProcess},!0))},t.prototype._createVolumetricLightPostProcess=function(e,n){var i=this,o=e.enableGeometryBufferRenderer();o.enablePosition=!0;var a=o.getGBuffer();this.volumetricLightPostProcess=new _t.w("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],n/8,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,`#define VLS
|
||
#define NB_STEPS `+this._volumetricLightStepsCount.toFixed(1));var s=_.I9.Zero();this.volumetricLightPostProcess.onApply=function(l){if(i.sourceLight&&i.sourceLight.getShadowGenerator()&&i._scene.activeCamera){var c=i.sourceLight.getShadowGenerator();l.setTexture("shadowMapSampler",c.getShadowMap()),l.setTexture("positionSampler",a.textures[2]),l.setColor3("sunColor",i.sourceLight.diffuse),l.setVector3("sunDirection",i.sourceLight.getShadowDirection()),l.setVector3("cameraPosition",i._scene.activeCamera.globalPosition),l.setMatrix("shadowViewProjection",c.getTransformMatrix()),l.setFloat("scatteringCoefficient",i.volumetricLightCoefficient),l.setFloat("scatteringPower",i.volumetricLightPower),s.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),s.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),l.setVector2("depthValues",s)}},this.addEffect(new Ut(e.getEngine(),"HDRVLS",function(){return i.volumetricLightPostProcess},!0)),this._createBlurPostProcesses(e,n/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new _t.w("HDRVLSMerge","standard",[],["originalSampler"],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(l){l.setTextureFromPostProcess("originalSampler",i._bloomEnabled?i.textureAdderFinalPostProcess:i.originalPostProcess),i._currentDepthOfFieldSource=i.volumetricLightFinalPostProcess},this.addEffect(new Ut(e.getEngine(),"HDRVLSMerge",function(){return i.volumetricLightMergePostProces},!0))},t.prototype._createLuminancePostProcesses=function(e,n){var i=this,o=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new _t.w("HDRLuminance","standard",["lumOffsets"],[],{width:o,height:o},null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",n);var a=[];this.luminancePostProcess.onApply=function(d){var h=1/i.luminancePostProcess.width,p=1/i.luminancePostProcess.height;a[0]=-.5*h,a[1]=.5*p,a[2]=.5*h,a[3]=.5*p,a[4]=-.5*h,a[5]=-.5*p,a[6]=.5*h,a[7]=-.5*p,d.setArray2("lumOffsets",a)},this.addEffect(new Ut(e.getEngine(),"HDRLuminance",function(){return i.luminancePostProcess},!0));for(var s=t.LuminanceSteps-1;s>=0;s--){o=Math.pow(3,s);var l=`#define LUMINANCE_DOWN_SAMPLE
|
||
`;s===0&&(l+="#define FINAL_DOWN_SAMPLER");var c=new _t.w("HDRLuminanceDownSample"+s,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,l,n);this.luminanceDownSamplePostProcesses.push(c)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach(function(d,h){var p=new Array(18);d.onApply=function(m){if(u){for(var v=0,b=-1;b<2;b++)for(var E=-1;E<2;E++)p[v]=b/u.width,p[v+1]=E/u.height,v+=2;m.setArray2("dsOffsets",p),m.setFloat("halfDestPixelSize",.5/u.width),u=h===i.luminanceDownSamplePostProcesses.length-1?i.luminancePostProcess:d}},h===i.luminanceDownSamplePostProcesses.length-1&&(d.onAfterRender=function(){var m=e.getEngine().readPixels(0,0,1,1),v=new _.IU(1/16581375,1/65025,1/255,1);m.then(function(b){var E=new Uint8Array(b.buffer);i._hdrCurrentLuminance=(E[0]*v.x+E[1]*v.y+E[2]*v.z+E[3]*v.w)/100})}),i.addEffect(new Ut(e.getEngine(),"HDRLuminanceDownSample"+h,function(){return d},!0))})},t.prototype._createHdrPostProcess=function(e,n){var i=this,o=["#define HDR"];this._hdrAutoExposure&&o.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new _t.w("HDR","standard",["averageLuminance"],["textureAdderSampler"],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,o.join(`
|
||
`),P.Y.TEXTURETYPE_UNSIGNED_INT);var a=1,s=0,l=0;this.hdrPostProcess.onApply=function(c){if(c.setTextureFromPostProcess("textureAdderSampler",i._currentDepthOfFieldSource),s+=e.getEngine().getDeltaTime(),a<0)a=i._hdrCurrentLuminance;else{var u=(l-s)/1e3;i._hdrCurrentLuminance<a+i.hdrDecreaseRate*u?a+=i.hdrDecreaseRate*u:i._hdrCurrentLuminance>a-i.hdrIncreaseRate*u?a-=i.hdrIncreaseRate*u:a=i._hdrCurrentLuminance}i.hdrAutoExposure?i._currentExposure=i._fixedExposure/a:(a=(0,qe.Clamp)(a,i.hdrMinimumLuminance,1e20),c.setFloat("averageLuminance",a)),l=s,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new Ut(e.getEngine(),"HDR",function(){return i.hdrPostProcess},!0))},t.prototype._createLensFlarePostProcess=function(e,n){var i=this;this.lensFlarePostProcess=new _t.w("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],n/2,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",P.Y.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Ut(e.getEngine(),"HDRLensFlare",function(){return i.lensFlarePostProcess},!0)),this._createBlurPostProcesses(e,n/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new _t.w("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",P.Y.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Ut(e.getEngine(),"HDRLensFlareCompose",function(){return i.lensFlareComposePostProcess},!0));var o=new _.I9(0,0);this.lensFlarePostProcess.externalTextureSamplerBinding=!0,this.lensFlarePostProcess.onApply=function(l){l.setTextureFromPostProcess("textureSampler",i._bloomEnabled?i.blurHPostProcesses[0]:i.originalPostProcess),l.setTexture("lensColorSampler",i.lensColorTexture),l.setFloat("strength",i.lensFlareStrength),l.setFloat("ghostDispersal",i.lensFlareGhostDispersal),l.setFloat("haloWidth",i.lensFlareHaloWidth),o.x=i.lensFlarePostProcess.width,o.y=i.lensFlarePostProcess.height,l.setVector2("resolution",o),l.setFloat("distortionStrength",i.lensFlareDistortionStrength)};var a=_.uq.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=_.uq.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(l){if(i._scene.activeCamera){l.setTextureFromPostProcess("otherSampler",i.lensFlarePostProcess),l.setTexture("lensDirtSampler",i.lensFlareDirtTexture),l.setTexture("lensStarSampler",i.lensStarTexture);var c=i._scene.activeCamera.getViewMatrix().getRow(0),u=i._scene.activeCamera.getViewMatrix().getRow(2),d=_.Pq.Dot(c.toVector3(),new _.Pq(1,0,0))+_.Pq.Dot(u.toVector3(),new _.Pq(0,0,1));d*=4;var h=_.uq.FromValues(.5*Math.cos(d),-Math.sin(d),0,0,Math.sin(d),.5*Math.cos(d),0,0,0,0,1,0,0,0,0,1),p=s.multiply(h).multiply(a);l.setMatrix("lensStarMatrix",p),i._currentDepthOfFieldSource=i.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,n){var i=this;this.depthOfFieldPostProcess=new _t.w("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",P.Y.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(o){o.setTextureFromPostProcess("otherSampler",i._currentDepthOfFieldSource),o.setTexture("depthSampler",i._getDepthTexture()),o.setFloat("distance",i.depthOfFieldDistance)},this.addEffect(new Ut(e.getEngine(),"HDRDepthOfField",function(){return i.depthOfFieldPostProcess},!0))},t.prototype._createMotionBlurPostProcess=function(e,n){var i=this;if(this._isObjectBasedMotionBlur){var o=new kf("HDRMotionBlur",e,n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,P.Y.TEXTURETYPE_UNSIGNED_INT);o.motionStrength=this.motionStrength,o.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=o}else{this.motionBlurPostProcess=new _t.w("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],n,null,Ie.g.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,`#define MOTION_BLUR
|
||
#define MAX_MOTION_SAMPLES `+this.motionBlurSamples.toFixed(1),P.Y.TEXTURETYPE_UNSIGNED_INT);var a=0,s=_.uq.Identity(),l=_.uq.Identity(),c=_.uq.Identity(),u=_.I9.Zero();this.motionBlurPostProcess.onApply=function(d){(c=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(l),d.setMatrix("inverseViewProjection",l),d.setMatrix("prevViewProjection",s),s=c,u.x=i.motionBlurPostProcess.width,u.y=i.motionBlurPostProcess.height,d.setVector2("screenSize",u),a=e.getEngine().getFps()/60,d.setFloat("motionScale",a),d.setFloat("motionStrength",i.motionStrength),d.setTexture("depthSampler",i._getDepthTexture())}}this.addEffect(new Ut(e.getEngine(),"HDRMotionBlur",function(){return i.motionBlurPostProcess},!0))},t.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},t.prototype._disposePostProcesses=function(){for(var e=0;e<this._cameras.length;e++){var n=this._cameras[e];this.originalPostProcess&&this.originalPostProcess.dispose(n),this.screenSpaceReflectionPostProcess&&this.screenSpaceReflectionPostProcess.dispose(n),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(n),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(n),this.textureAdderPostProcess&&this.textureAdderPostProcess.dispose(n),this.volumetricLightPostProcess&&this.volumetricLightPostProcess.dispose(n),this.volumetricLightSmoothXPostProcess&&this.volumetricLightSmoothXPostProcess.dispose(n),this.volumetricLightSmoothYPostProcess&&this.volumetricLightSmoothYPostProcess.dispose(n),this.volumetricLightMergePostProces&&this.volumetricLightMergePostProces.dispose(n),this.volumetricLightFinalPostProcess&&this.volumetricLightFinalPostProcess.dispose(n),this.lensFlarePostProcess&&this.lensFlarePostProcess.dispose(n),this.lensFlareComposePostProcess&&this.lensFlareComposePostProcess.dispose(n);for(var i=0;i<this.luminanceDownSamplePostProcesses.length;i++)this.luminanceDownSamplePostProcesses[i].dispose(n);for(this.luminancePostProcess&&this.luminancePostProcess.dispose(n),this.hdrPostProcess&&this.hdrPostProcess.dispose(n),this.hdrFinalPostProcess&&this.hdrFinalPostProcess.dispose(n),this.depthOfFieldPostProcess&&this.depthOfFieldPostProcess.dispose(n),this.motionBlurPostProcess&&this.motionBlurPostProcess.dispose(n),this.fxaaPostProcess&&this.fxaaPostProcess.dispose(n),i=0;i<this.blurHPostProcesses.length;i++)this.blurHPostProcesses[i].dispose(n);for(i=0;i<this.blurVPostProcesses.length;i++)this.blurVPostProcesses[i].dispose(n)}this.originalPostProcess=null,this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.textureAdderPostProcess=null,this.textureAdderFinalPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.luminancePostProcess=null,this.hdrPostProcess=null,this.hdrFinalPostProcess=null,this.depthOfFieldPostProcess=null,this.motionBlurPostProcess=null,this.fxaaPostProcess=null,this.screenSpaceReflectionPostProcess=null,this.luminanceDownSamplePostProcesses.length=0,this.blurHPostProcesses.length=0,this.blurVPostProcesses.length=0},t.prototype.dispose=function(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),r.prototype.dispose.call(this)},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return this.sourceLight&&(e.sourceLightId=this.sourceLight.id),this.screenSpaceReflectionPostProcess&&(e.screenSpaceReflectionPostProcess=tt.p.Serialize(this.screenSpaceReflectionPostProcess)),e.customType="StandardRenderingPipeline",e},t.Parse=function(e,n,i){var o=tt.p.Parse(function(){return new t(e._name,n,e._ratio)},e,n,i);return e.sourceLightId&&(o.sourceLight=n.getLightById(e.sourceLightId)),e.screenSpaceReflectionPostProcess&&tt.p.Parse(function(){return o.screenSpaceReflectionPostProcess},e.screenSpaceReflectionPostProcess,n,i),o},t.LuminanceSteps=6,(0,A.Cg)([(0,V.lK)()],t.prototype,"brightThreshold",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"blurWidth",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"horizontalBlur",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"exposure",null),(0,A.Cg)([(0,V.uM)("lensTexture")],t.prototype,"lensTexture",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"volumetricLightCoefficient",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"volumetricLightPower",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"volumetricLightBlurScale",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"hdrMinimumLuminance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"hdrDecreaseRate",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"hdrIncreaseRate",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"hdrAutoExposure",null),(0,A.Cg)([(0,V.uM)("lensColorTexture")],t.prototype,"lensColorTexture",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lensFlareStrength",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lensFlareGhostDispersal",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lensFlareHaloWidth",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lensFlareDistortionStrength",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"lensFlareBlurWidth",void 0),(0,A.Cg)([(0,V.uM)("lensStarTexture")],t.prototype,"lensStarTexture",void 0),(0,A.Cg)([(0,V.uM)("lensFlareDirtTexture")],t.prototype,"lensFlareDirtTexture",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"depthOfFieldDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"depthOfFieldBlurWidth",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"motionStrength",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"objectBasedMotionBlur",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"_ratio",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"BloomEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"DepthOfFieldEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"LensFlareEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"HDREnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"VLSEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"MotionBlurEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"fxaaEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"screenSpaceReflectionsEnabled",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"volumetricLightStepsCount",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"motionBlurSamples",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"samples",null),t}(uo);(0,j.Y5)("BABYLON.StandardRenderingPipeline",hT);var CN=function(){this.enabled=!1,this.name="screenSpaceReflections2",this.texturesRequired=[P.Y.PREPASS_NORMAL_TEXTURE_TYPE,P.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE,P.Y.PREPASS_DEPTH_TEXTURE_TYPE]},RN=_.uq.Compose(new _.Pq(.5,.5,.5),_.PT.Identity(),new _.Pq(.5,.5,.5)),IN=_.uq.Compose(new _.Pq(.5,.5,1),_.PT.Identity(),new _.Pq(.5,.5,0)),fT=function(r){function t(e,n,i,o,a){o===void 0&&(o=!1),a===void 0&&(a=P.Y.TEXTURETYPE_UNSIGNED_BYTE);var s=r.call(this,n.getEngine(),e)||this;if(s.SSRRenderEffect="SSRRenderEffect",s.SSRBlurRenderEffect="SSRBlurRenderEffect",s.SSRCombineRenderEffect="SSRCombineRenderEffect",s._samples=1,s.maxDistance=1e3,s.step=1,s.thickness=.5,s.strength=1,s.reflectionSpecularFalloffExponent=1,s.maxSteps=1e3,s.roughnessFactor=.2,s.selfCollisionNumSkip=1,s._reflectivityThreshold=.04,s._ssrDownsample=0,s._blurDispersionStrength=.03,s._blurDownsample=0,s._enableSmoothReflections=!1,s._environmentTextureIsProbe=!1,s._attenuateScreenBorders=!0,s._attenuateIntersectionDistance=!0,s._attenuateIntersectionIterations=!0,s._attenuateFacingCamera=!1,s._attenuateBackfaceReflection=!1,s._clipToFrustum=!0,s._useFresnel=!1,s._enableAutomaticThicknessComputation=!1,s._backfaceDepthTextureDownsample=0,s._backfaceForceDepthWriteTransparentMeshes=!0,s._isEnabled=!0,s._inputTextureColorIsInGammaSpace=!0,s._generateOutputInGammaSpace=!0,s._debug=!1,s._forceGeometryBuffer=!1,s._isDirty=!1,s._camerasToBeAttached=[],s._cameras=i||n.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._scene=n,s._textureType=a,s._forceGeometryBuffer=o,s.isSupported){if(n.postProcessRenderPipelineManager.addPipeline(s),s._forceGeometryBuffer){var l=n.enableGeometryBufferRenderer();l&&(l.enableReflectivity=!0,l.useSpecificClearForDepthTexture=!0)}else{var c=n.enablePrePassRenderer();c&&(c.useSpecificClearForDepthTexture=!0,c.markAsDirty())}s._buildPipeline()}return s}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectivityThreshold",{get:function(){return this._reflectivityThreshold},set:function(e){e!==this._reflectivityThreshold&&(e===0&&this._reflectivityThreshold!==0||e!==0&&this._reflectivityThreshold===0?(this._reflectivityThreshold=e,this._buildPipeline()):this._reflectivityThreshold=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ssrDownsample",{get:function(){return this._ssrDownsample},set:function(e){e!==this._ssrDownsample&&(this._ssrDownsample=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurDispersionStrength",{get:function(){return this._blurDispersionStrength},set:function(e){if(e!==this._blurDispersionStrength){var n=e===0&&this._blurDispersionStrength!==0||e!==0&&this._blurDispersionStrength===0;this._blurDispersionStrength=e,n&&this._buildPipeline()}},enumerable:!1,configurable:!0}),t.prototype._useBlur=function(){return this._blurDispersionStrength>0},Object.defineProperty(t.prototype,"blurDownsample",{get:function(){return this._blurDownsample},set:function(e){e!==this._blurDownsample&&(this._blurDownsample=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableSmoothReflections",{get:function(){return this._enableSmoothReflections},set:function(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture=e,this._updateEffectDefines()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"environmentTextureIsProbe",{get:function(){return this._environmentTextureIsProbe},set:function(e){this._environmentTextureIsProbe=e,this._updateEffectDefines()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateScreenBorders",{get:function(){return this._attenuateScreenBorders},set:function(e){this._attenuateScreenBorders!==e&&(this._attenuateScreenBorders=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateIntersectionDistance",{get:function(){return this._attenuateIntersectionDistance},set:function(e){this._attenuateIntersectionDistance!==e&&(this._attenuateIntersectionDistance=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateIntersectionIterations",{get:function(){return this._attenuateIntersectionIterations},set:function(e){this._attenuateIntersectionIterations!==e&&(this._attenuateIntersectionIterations=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateFacingCamera",{get:function(){return this._attenuateFacingCamera},set:function(e){this._attenuateFacingCamera!==e&&(this._attenuateFacingCamera=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attenuateBackfaceReflection",{get:function(){return this._attenuateBackfaceReflection},set:function(e){this._attenuateBackfaceReflection!==e&&(this._attenuateBackfaceReflection=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clipToFrustum",{get:function(){return this._clipToFrustum},set:function(e){this._clipToFrustum!==e&&(this._clipToFrustum=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useFresnel",{get:function(){return this._useFresnel},set:function(e){this._useFresnel!==e&&(this._useFresnel=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enableAutomaticThicknessComputation",{get:function(){return this._enableAutomaticThicknessComputation},set:function(e){this._enableAutomaticThicknessComputation!==e&&(this._enableAutomaticThicknessComputation=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backfaceDepthRenderer",{get:function(){return this._depthRenderer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backfaceDepthTextureDownsample",{get:function(){return this._backfaceDepthTextureDownsample},set:function(e){this._backfaceDepthTextureDownsample!==e&&(this._backfaceDepthTextureDownsample=e,this._resizeDepthRenderer())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"backfaceForceDepthWriteTransparentMeshes",{get:function(){return this._backfaceForceDepthWriteTransparentMeshes},set:function(e){this._backfaceForceDepthWriteTransparentMeshes!==e&&(this._backfaceForceDepthWriteTransparentMeshes=e,this._depthRenderer&&(this._depthRenderer.forceDepthWriteTransparentMeshes=e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,e?e&&(this._isDirty?this._buildPipeline():this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)):this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"inputTextureColorIsInGammaSpace",{get:function(){return this._inputTextureColorIsInGammaSpace},set:function(e){this._inputTextureColorIsInGammaSpace!==e&&(this._inputTextureColorIsInGammaSpace=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generateOutputInGammaSpace",{get:function(){return this._generateOutputInGammaSpace},set:function(e){this._generateOutputInGammaSpace!==e&&(this._generateOutputInGammaSpace=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug!==e&&(this._debug=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype.getScene=function(){return this._scene},Object.defineProperty(t.prototype,"_geometryBufferRenderer",{get:function(){return this._forceGeometryBuffer?this._scene.geometryBufferRenderer:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_prePassRenderer",{get:function(){return this._forceGeometryBuffer?null:this._scene.prePassRenderer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSupported",{get:function(){var e=this._scene.getEngine().getCaps();return e.drawBuffersExtension&&e.texelFetch},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSRRenderingPipeline"},t.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},t.prototype.removeCamera=function(e){var n=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(n,1),this._buildPipeline()},t.prototype.dispose=function(e){e===void 0&&(e=!1),this._disposeDepthRenderer(),this._disposePostProcesses(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),r.prototype.dispose.call(this)},t.prototype._getTextureSize=function(){var e,n,i=this._scene.getEngine(),o=this._prePassRenderer,a={width:i.getRenderWidth(),height:i.getRenderHeight()};if(o&&((e=this._scene.activeCamera)===null||e===void 0?void 0:e._getFirstPostProcess())===this._ssrPostProcess){var s=o.getRenderTarget();s&&s.textures&&(a=s.textures[o.getIndex(P.Y.PREPASS_COLOR_TEXTURE_TYPE)].getSize())}else!((n=this._ssrPostProcess)===null||n===void 0)&&n.inputTexture&&(a.width=this._ssrPostProcess.inputTexture.width,a.height=this._ssrPostProcess.inputTexture.height);return a},t.prototype._updateEffectDefines=function(){var e,n,i,o,a,s,l=[];(this._geometryBufferRenderer||this._prePassRenderer)&&l.push("#define SSR_SUPPORTED"),this._enableSmoothReflections&&l.push("#define SSRAYTRACE_ENABLE_REFINEMENT"),this._scene.useRightHandedSystem&&l.push("#define SSRAYTRACE_RIGHT_HANDED_SCENE"),this._environmentTexture&&(l.push("#define SSR_USE_ENVIRONMENT_CUBE"),this._environmentTexture.boundingBoxSize&&l.push("#define SSR_USE_LOCAL_REFLECTIONMAP_CUBIC"),this._environmentTexture.gammaSpace&&l.push("#define SSR_ENVIRONMENT_CUBE_IS_GAMMASPACE")),this._environmentTextureIsProbe&&l.push("#define SSR_INVERTCUBICMAP"),this._enableAutomaticThicknessComputation&&l.push("#define SSRAYTRACE_USE_BACK_DEPTHBUFFER"),this._attenuateScreenBorders&&l.push("#define SSR_ATTENUATE_SCREEN_BORDERS"),this._attenuateIntersectionDistance&&l.push("#define SSR_ATTENUATE_INTERSECTION_DISTANCE"),this._attenuateIntersectionIterations&&l.push("#define SSR_ATTENUATE_INTERSECTION_NUMITERATIONS"),this._attenuateFacingCamera&&l.push("#define SSR_ATTENUATE_FACING_CAMERA"),this._attenuateBackfaceReflection&&l.push("#define SSR_ATTENUATE_BACKFACE_REFLECTION"),this._clipToFrustum&&l.push("#define SSRAYTRACE_CLIP_TO_FRUSTUM"),this._useBlur()&&l.push("#define SSR_USE_BLUR"),this._debug&&l.push("#define SSRAYTRACE_DEBUG"),this._inputTextureColorIsInGammaSpace&&l.push("#define SSR_INPUT_IS_GAMMA_SPACE"),this._generateOutputInGammaSpace&&l.push("#define SSR_OUTPUT_IS_GAMMA_SPACE"),this._useFresnel&&l.push("#define SSR_BLEND_WITH_FRESNEL"),this._reflectivityThreshold===0&&l.push("#define SSR_DISABLE_REFLECTIVITY_TEST"),((n=(e=this._geometryBufferRenderer)===null||e===void 0?void 0:e.generateNormalsInWorldSpace)!==null&&n!==void 0?n:!((i=this._prePassRenderer)===null||i===void 0)&&i.generateNormalsInWorldSpace)&&l.push("#define SSR_NORMAL_IS_IN_WORLDSPACE"),!((o=this._geometryBufferRenderer)===null||o===void 0)&&o.normalsAreUnsigned&&l.push("#define SSR_DECODE_NORMAL");var c=(a=this._cameras)===null||a===void 0?void 0:a[0];c&&c.mode===P.Y.ORTHOGRAPHIC_CAMERA&&l.push("#define ORTHOGRAPHIC_CAMERA"),(s=this._ssrPostProcess)===null||s===void 0||s.updateEffect(l.join(`
|
||
`))},t.prototype._buildPipeline=function(){var e,n=this;if(this.isSupported)if(this._isEnabled){this._isDirty=!1;var i=this._scene.getEngine();if(this._disposeDepthRenderer(),this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._enableAutomaticThicknessComputation){var o=(e=this._cameras)===null||e===void 0?void 0:e[0];o&&(this._depthRendererCamera=o,this._depthRenderer=new ls(this._scene,void 0,void 0,void 0,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,!0,"SSRBackDepth"),this._depthRenderer.clearColor.r=1e8,this._depthRenderer.reverseCulling=!0,this._depthRenderer.forceDepthWriteTransparentMeshes=this._backfaceForceDepthWriteTransparentMeshes,this._resizeDepthRenderer(),o.customRenderTargets.push(this._depthRenderer.getDepthMap()))}this._createSSRPostProcess(),this.addEffect(new Ut(i,this.SSRRenderEffect,function(){return n._ssrPostProcess},!0)),this._useBlur()&&(this._createBlurAndCombinerPostProcesses(),this.addEffect(new Ut(i,this.SSRBlurRenderEffect,function(){return[n._blurPostProcessX,n._blurPostProcessY]},!0)),this.addEffect(new Ut(i,this.SSRCombineRenderEffect,function(){return n._blurCombinerPostProcess},!0))),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)}else this._isDirty=!0},t.prototype._resizeDepthRenderer=function(){if(this._depthRenderer){var e=this._getTextureSize(),n=this._depthRenderer.getDepthMap().getSize(),i=Math.floor(e.width/(this._backfaceDepthTextureDownsample+1)),o=Math.floor(e.height/(this._backfaceDepthTextureDownsample+1));n.width===i&&n.height===o||this._depthRenderer.getDepthMap().resize({width:i,height:o})}},t.prototype._disposeDepthRenderer=function(){var e;if(this._depthRenderer){if(this._depthRendererCamera){var n=(e=this._depthRendererCamera.customRenderTargets.indexOf(this._depthRenderer.getDepthMap()))!==null&&e!==void 0?e:-1;n!==-1&&this._depthRendererCamera.customRenderTargets.splice(n,1)}this._depthRendererCamera=null,this._depthRenderer.getDepthMap().dispose()}this._depthRenderer=null},t.prototype._disposePostProcesses=function(){for(var e,n,i,o,a=0;a<this._cameras.length;a++){var s=this._cameras[a];(e=this._ssrPostProcess)===null||e===void 0||e.dispose(s),(n=this._blurPostProcessX)===null||n===void 0||n.dispose(s),(i=this._blurPostProcessY)===null||i===void 0||i.dispose(s),(o=this._blurCombinerPostProcess)===null||o===void 0||o.dispose(s)}this._ssrPostProcess=null,this._blurPostProcessX=null,this._blurPostProcessY=null,this._blurCombinerPostProcess=null},t.prototype._createSSRPostProcess=function(){var e=this;this._ssrPostProcess=new _t.w("ssr","screenSpaceReflection2",["projection","invProjectionMatrix","view","invView","thickness","reflectionSpecularFalloffExponent","strength","stepSize","maxSteps","roughnessFactor","projectionPixel","nearPlaneZ","maxDistance","selfCollisionNumSkip","vReflectionPosition","vReflectionSize","backSizeFactor","reflectivityThreshold"],["textureSampler","normalSampler","reflectivitySampler","depthSampler","envCubeSampler","backDepthSampler"],1,null,this._textureType,this._scene.getEngine(),!1,"",this._textureType,void 0,void 0,void 0,void 0,this._scene.getEngine().isWebGPU?1:0,function(n,i){n?i.push(Promise.resolve().then(L.bind(L,78850))):i.push(Promise.resolve().then(L.bind(L,72527)))}),this._updateEffectDefines(),this._ssrPostProcess.onApply=function(n){e._resizeDepthRenderer();var i=e._geometryBufferRenderer,o=e._prePassRenderer;if(o||i){if(i){var a=i.getTextureIndex(zn.REFLECTIVITY_TEXTURE_TYPE);n.setTexture("normalSampler",i.getGBuffer().textures[1]),n.setTexture("reflectivitySampler",i.getGBuffer().textures[a]),n.setTexture("depthSampler",i.getGBuffer().textures[0])}else if(o){var s=o.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE),l=(a=o.getIndex(P.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE),o.getIndex(P.Y.PREPASS_NORMAL_TEXTURE_TYPE));n.setTexture("normalSampler",o.getRenderTarget().textures[l]),n.setTexture("depthSampler",o.getRenderTarget().textures[s]),n.setTexture("reflectivitySampler",o.getRenderTarget().textures[a])}e._enableAutomaticThicknessComputation&&e._depthRenderer&&(n.setTexture("backDepthSampler",e._depthRenderer.getDepthMap()),n.setFloat("backSizeFactor",e._backfaceDepthTextureDownsample+1));var c=e._scene.activeCamera;if(c){var u=c.getViewMatrix(),d=c.getProjectionMatrix();d.invertToRef(_.AA.Matrix[0]),u.invertToRef(_.AA.Matrix[1]),n.setMatrix("projection",d),n.setMatrix("view",u),n.setMatrix("invView",_.AA.Matrix[1]),n.setMatrix("invProjectionMatrix",_.AA.Matrix[0]),n.setFloat("thickness",e.thickness),n.setFloat("reflectionSpecularFalloffExponent",e.reflectionSpecularFalloffExponent),n.setFloat("strength",e.strength),n.setFloat("stepSize",e.step),n.setFloat("maxSteps",e.maxSteps),n.setFloat("roughnessFactor",e.roughnessFactor),n.setFloat("nearPlaneZ",c.minZ),n.setFloat("maxDistance",e.maxDistance),n.setFloat("selfCollisionNumSkip",e.selfCollisionNumSkip),n.setFloat("reflectivityThreshold",e._reflectivityThreshold);var h=e._getTextureSize();_.uq.ScalingToRef(h.width,h.height,1,_.AA.Matrix[2]),d.multiplyToRef(e._scene.getEngine().isWebGPU?IN:RN,_.AA.Matrix[3]),_.AA.Matrix[3].multiplyToRef(_.AA.Matrix[2],_.AA.Matrix[4]),n.setMatrix("projectionPixel",_.AA.Matrix[4]),e._environmentTexture&&(n.setTexture("envCubeSampler",e._environmentTexture),e._environmentTexture.boundingBoxSize&&(n.setVector3("vReflectionPosition",e._environmentTexture.boundingBoxPosition),n.setVector3("vReflectionSize",e._environmentTexture.boundingBoxSize)))}}},this._ssrPostProcess.samples=this.samples,this._forceGeometryBuffer||(this._ssrPostProcess._prePassEffectConfiguration=new CN)},t.prototype._createBlurAndCombinerPostProcesses=function(){var e=this,n=this._scene.getEngine();this._blurPostProcessX=new _t.w("SSRblurX","screenSpaceReflection2Blur",["texelOffsetScale"],["textureSampler"],this._useBlur()?1/(this._ssrDownsample+1):1,null,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,n,!1,"",this._textureType,void 0,void 0,void 0,void 0,this._scene.getEngine().isWebGPU?1:0,function(s,l){s?l.push(Promise.resolve().then(L.bind(L,88101))):l.push(Promise.resolve().then(L.bind(L,12064)))}),this._blurPostProcessX.autoClear=!1,this._blurPostProcessX.onApplyObservable.add(function(s){var l,c,u=(c=(l=e._blurPostProcessX)===null||l===void 0?void 0:l.inputTexture.width)!==null&&c!==void 0?c:e._scene.getEngine().getRenderWidth();s.setFloat2("texelOffsetScale",e._blurDispersionStrength/u,0)}),this._blurPostProcessY=new _t.w("SSRblurY","screenSpaceReflection2Blur",["texelOffsetScale"],["textureSampler"],this._useBlur()?1/(this._blurDownsample+1):1,null,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,n,!1,"",this._textureType,void 0,void 0,void 0,void 0,this._scene.getEngine().isWebGPU?1:0,function(s,l){s?l.push(Promise.resolve().then(L.bind(L,88101))):l.push(Promise.resolve().then(L.bind(L,12064)))}),this._blurPostProcessY.autoClear=!1,this._blurPostProcessY.onApplyObservable.add(function(s){var l,c,u=(c=(l=e._blurPostProcessY)===null||l===void 0?void 0:l.inputTexture.height)!==null&&c!==void 0?c:e._scene.getEngine().getRenderHeight();s.setFloat2("texelOffsetScale",0,e._blurDispersionStrength/u)});var i=["strength","reflectionSpecularFalloffExponent","reflectivityThreshold"],o=["textureSampler","mainSampler","reflectivitySampler"],a="";this._debug&&(a+=`#define SSRAYTRACE_DEBUG
|
||
`),this._inputTextureColorIsInGammaSpace&&(a+=`#define SSR_INPUT_IS_GAMMA_SPACE
|
||
`),this._generateOutputInGammaSpace&&(a+=`#define SSR_OUTPUT_IS_GAMMA_SPACE
|
||
`),this.useFresnel&&(a+=`#define SSR_BLEND_WITH_FRESNEL
|
||
`,i.push("projection","invProjectionMatrix"),o.push("depthSampler","normalSampler")),this._reflectivityThreshold===0&&(a+="#define SSR_DISABLE_REFLECTIVITY_TEST"),this._blurCombinerPostProcess=new _t.w("SSRblurCombiner","screenSpaceReflection2BlurCombiner",i,o,this._useBlur()?1/(this._blurDownsample+1):1,null,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,n,!1,a,this._textureType,void 0,void 0,void 0,void 0,this._scene.getEngine().isWebGPU?1:0,function(s,l){s?l.push(Promise.resolve().then(L.bind(L,93050))):l.push(Promise.resolve().then(L.bind(L,88331)))}),this._blurCombinerPostProcess.autoClear=!1,this._blurCombinerPostProcess.onApplyObservable.add(function(s){var l,c=e._geometryBufferRenderer,u=e._prePassRenderer;if(u||c){if(u&&((l=e._scene.activeCamera)===null||l===void 0?void 0:l._getFirstPostProcess())===e._ssrPostProcess){var d=u.getRenderTarget();d&&d.textures&&s.setTexture("mainSampler",d.textures[u.getIndex(P.Y.PREPASS_COLOR_TEXTURE_TYPE)])}else s.setTextureFromPostProcess("mainSampler",e._ssrPostProcess);if(c){var h=c.getTextureIndex(zn.REFLECTIVITY_TEXTURE_TYPE);s.setTexture("reflectivitySampler",c.getGBuffer().textures[h]),e.useFresnel&&(s.setTexture("normalSampler",c.getGBuffer().textures[1]),s.setTexture("depthSampler",c.getGBuffer().textures[0]))}else if(u&&(h=u.getIndex(P.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE),s.setTexture("reflectivitySampler",u.getRenderTarget().textures[h]),e.useFresnel)){var p=u.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE),m=u.getIndex(P.Y.PREPASS_NORMAL_TEXTURE_TYPE);s.setTexture("normalSampler",u.getRenderTarget().textures[m]),s.setTexture("depthSampler",u.getRenderTarget().textures[p])}if(s.setFloat("strength",e.strength),s.setFloat("reflectionSpecularFalloffExponent",e.reflectionSpecularFalloffExponent),s.setFloat("reflectivityThreshold",e._reflectivityThreshold),e.useFresnel){var v=e._scene.activeCamera;if(v){var b=v.getProjectionMatrix();b.invertToRef(_.AA.Matrix[0]),s.setMatrix("projection",b),s.setMatrix("invProjectionMatrix",_.AA.Matrix[0])}}}})},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.customType="SSRRenderingPipeline",e},t.Parse=function(e,n,i){return tt.p.Parse(function(){return new t(e._name,n,e._ratio)},e,n,i)},(0,A.Cg)([(0,V.lK)()],t.prototype,"samples",null),(0,A.Cg)([(0,V.lK)()],t.prototype,"maxDistance",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"step",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"thickness",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"strength",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"reflectionSpecularFalloffExponent",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"maxSteps",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"roughnessFactor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"selfCollisionNumSkip",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"_reflectivityThreshold",void 0),(0,A.Cg)([(0,V.lK)("_ssrDownsample")],t.prototype,"_ssrDownsample",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"ssrDownsample",null),(0,A.Cg)([(0,V.lK)("blurDispersionStrength")],t.prototype,"_blurDispersionStrength",void 0),(0,A.Cg)([(0,V.lK)("blurDownsample")],t.prototype,"_blurDownsample",void 0),(0,A.Cg)([(0,V.lK)("enableSmoothReflections")],t.prototype,"_enableSmoothReflections",void 0),(0,A.Cg)([(0,V.lK)("environmentTexture")],t.prototype,"_environmentTexture",void 0),(0,A.Cg)([(0,V.lK)("environmentTextureIsProbe")],t.prototype,"_environmentTextureIsProbe",void 0),(0,A.Cg)([(0,V.lK)("attenuateScreenBorders")],t.prototype,"_attenuateScreenBorders",void 0),(0,A.Cg)([(0,V.lK)("attenuateIntersectionDistance")],t.prototype,"_attenuateIntersectionDistance",void 0),(0,A.Cg)([(0,V.lK)("attenuateIntersectionIterations")],t.prototype,"_attenuateIntersectionIterations",void 0),(0,A.Cg)([(0,V.lK)("attenuateFacingCamera")],t.prototype,"_attenuateFacingCamera",void 0),(0,A.Cg)([(0,V.lK)("attenuateBackfaceReflection")],t.prototype,"_attenuateBackfaceReflection",void 0),(0,A.Cg)([(0,V.lK)("clipToFrustum")],t.prototype,"_clipToFrustum",void 0),(0,A.Cg)([(0,V.lK)("useFresnel")],t.prototype,"_useFresnel",void 0),(0,A.Cg)([(0,V.lK)("enableAutomaticThicknessComputation")],t.prototype,"_enableAutomaticThicknessComputation",void 0),(0,A.Cg)([(0,V.lK)("backfaceDepthTextureDownsample")],t.prototype,"_backfaceDepthTextureDownsample",void 0),(0,A.Cg)([(0,V.lK)("backfaceForceDepthWriteTransparentMeshes")],t.prototype,"_backfaceForceDepthWriteTransparentMeshes",void 0),(0,A.Cg)([(0,V.lK)("isEnabled")],t.prototype,"_isEnabled",void 0),(0,A.Cg)([(0,V.lK)("inputTextureColorIsInGammaSpace")],t.prototype,"_inputTextureColorIsInGammaSpace",void 0),(0,A.Cg)([(0,V.lK)("generateOutputInGammaSpace")],t.prototype,"_generateOutputInGammaSpace",void 0),(0,A.Cg)([(0,V.lK)("debug")],t.prototype,"_debug",void 0),t}(uo);(0,j.Y5)("BABYLON.SSRRenderingPipeline",fT),Gt.l.ShadersStore.taaPixelShader=`varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D historySampler;uniform float factor;void main() {vec4 c=texelFetch(textureSampler,ivec2(gl_FragCoord.xy),0);vec4 h=texelFetch(historySampler,ivec2(gl_FragCoord.xy),0);gl_FragColor=mix(h,c,factor);}
|
||
`;var pT=function(r){function t(e,n,i,o){o===void 0&&(o=P.Y.TEXTURETYPE_UNSIGNED_BYTE);var a=this,s=n.getEngine();return(a=r.call(this,s,e)||this).TAARenderEffect="TAARenderEffect",a.TAAPassEffect="TAAPassEffect",a._samples=8,a._msaaSamples=1,a.factor=.05,a.disableOnCameraMove=!0,a._isEnabled=!0,a._isDirty=!1,a._camerasToBeAttached=[],a._pingpong=0,a._firstUpdate=!0,a._cameras=i||n.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=n,a._textureType=o,a._hs=new c0(a.samples),a.isSupported&&(a._createPingPongTextures(s.getRenderWidth(),s.getRenderHeight()),n.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline()),a}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._hs.regenerate(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"msaaSamples",{get:function(){return this._msaaSamples},set:function(e){this._msaaSamples!==e&&(this._msaaSamples=e,this._taaPostProcess&&(this._taaPostProcess.samples=e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,e?e&&(this._isDirty?this._buildPipeline():this._cameras!==null&&(this._firstUpdate=!0,this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras))):this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._scene.getEngine().getCaps().texelFetch},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"TAARenderingPipeline"},t.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},t.prototype.removeCamera=function(e){var n=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(n,1),this._buildPipeline()},t.prototype.dispose=function(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._ping.dispose(),this._pong.dispose(),r.prototype.dispose.call(this)},t.prototype._createPingPongTextures=function(e,n){var i,o,a=this._scene.getEngine();(i=this._ping)===null||i===void 0||i.dispose(),(o=this._pong)===null||o===void 0||o.dispose(),this._ping=a.createRenderTargetTexture({width:e,height:n},{generateMipMaps:!1,generateDepthBuffer:!1,type:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_NEAREST}),this._pong=a.createRenderTargetTexture({width:e,height:n},{generateMipMaps:!1,generateDepthBuffer:!1,type:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_NEAREST}),this._hs.setDimensions(e/2,n/2),this._hs.next(),this._firstUpdate=!0},t.prototype._updateEffectDefines=function(){var e;(e=this._taaPostProcess)===null||e===void 0||e.updateEffect([].join(`
|
||
`))},t.prototype._buildPipeline=function(){var e=this;if(this.isSupported)if(this._isEnabled){this._isDirty=!1;var n=this._scene.getEngine();this._disposePostProcesses(),this._cameras!==null&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._createTAAPostProcess(),this.addEffect(new Ut(n,this.TAARenderEffect,function(){return e._taaPostProcess},!0)),this._createPassPostProcess(),this.addEffect(new Ut(n,this.TAAPassEffect,function(){return e._passPostProcess},!0)),this._cameras!==null&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)}else this._isDirty=!0},t.prototype._disposePostProcesses=function(){for(var e,n,i=0;i<this._cameras.length;i++){var o=this._cameras[i];(e=this._taaPostProcess)===null||e===void 0||e.dispose(o),(n=this._passPostProcess)===null||n===void 0||n.dispose(o),o.getProjectionMatrix(!0)}this._taaPostProcess=null,this._passPostProcess=null},t.prototype._createTAAPostProcess=function(){var e=this;this._taaPostProcess=new _t.w("TAA","taa",{uniforms:["factor"],samplers:["historySampler"],size:1,engine:this._scene.getEngine(),textureType:this._textureType}),this._taaPostProcess.samples=this._msaaSamples,this._updateEffectDefines(),this._taaPostProcess.onActivateObservable.add(function(){var n,i,o,a=e._scene.activeCamera;if(((n=e._taaPostProcess)===null||n===void 0?void 0:n.width)!==e._ping.width||((i=e._taaPostProcess)===null||i===void 0?void 0:i.height)!==e._ping.height){var s=e._scene.getEngine();e._createPingPongTextures(s.getRenderWidth(),s.getRenderHeight())}a&&!a.hasMoved&&(a.mode===Pt.PERSPECTIVE_CAMERA?(o=a.getProjectionMatrix()).setRowFromFloats(2,e._hs.x,e._hs.y,o.m[10],o.m[11]):(o=a.getProjectionMatrix(!0)).setRowFromFloats(3,e._hs.x+o.m[12],e._hs.y+o.m[13],o.m[14],o.m[15])),e._passPostProcess&&(e._passPostProcess.inputTexture=e._pingpong?e._ping:e._pong),e._pingpong=1^e._pingpong,e._hs.next()}),this._taaPostProcess.onApplyObservable.add(function(n){var i=e._scene.activeCamera;n._bindTexture("historySampler",e._pingpong?e._ping.texture:e._pong.texture),n.setFloat("factor",i?.hasMoved&&e.disableOnCameraMove||e._firstUpdate?1:e.factor),e._firstUpdate=!1})},t.prototype._createPassPostProcess=function(){var e=this._scene.getEngine();this._passPostProcess=new ro.v("TAAPass",1,null,P.Y.TEXTURE_NEAREST_NEAREST,e),this._passPostProcess.inputTexture=this._ping,this._passPostProcess.autoClear=!1},t.prototype.serialize=function(){var e=tt.p.Serialize(this);return e.customType="TAARenderingPipeline",e},t.Parse=function(e,n,i){return tt.p.Parse(function(){return new t(e._name,n,e._ratio)},e,n,i)},(0,A.Cg)([(0,V.lK)("samples")],t.prototype,"_samples",void 0),(0,A.Cg)([(0,V.lK)("msaaSamples")],t.prototype,"_msaaSamples",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"factor",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"disableOnCameraMove",void 0),(0,A.Cg)([(0,V.lK)("isEnabled")],t.prototype,"_isEnabled",void 0),t}(uo);(0,j.Y5)("BABYLON.TAARenderingPipeline",pT);var Hf,HR=L(16040),YR=L(29059),XR=L(61186),jR=L(72527),qR=L(12064),KR=L(88331),ZR=L(78850),QR=L(88101),JR=L(93050);(function(r){r[r.Hable=0]="Hable",r[r.Reinhard=1]="Reinhard",r[r.HejiDawson=2]="HejiDawson",r[r.Photographic=3]="Photographic"})(Hf||(Hf={}));var $R=function(r){function t(e,n,i,o,a,s,l,c){a===void 0&&(a=P.Y.TEXTURE_BILINEAR_SAMPLINGMODE),l===void 0&&(l=P.Y.TEXTURETYPE_UNSIGNED_INT);var u=r.call(this,e,"tonemap",["_ExposureAdjustment"],null,1,o,a,s,c,null,l)||this;u._operator=n,u.exposureAdjustment=i;var d="#define ";return u._operator===0?d+="HABLE_TONEMAPPING":u._operator===1?d+="REINHARD_TONEMAPPING":u._operator===2?d+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":u._operator===3&&(d+="PHOTOGRAPHIC_TONEMAPPING"),u.updateEffect(d),u.onApply=function(h){h.setFloat("_ExposureAdjustment",u.exposureAdjustment)},u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"TonemapPostProcess"},t.prototype._gatherImports=function(e,n){e?(this._webGPUReady=!0,n.push(Promise.all([Promise.resolve().then(L.bind(L,31197))]))):n.push(Promise.all([Promise.resolve().then(L.bind(L,1746))])),r.prototype._gatherImports.call(this,e,n)},t}(_t.w);Gt.l.ShadersStore.volumetricLightScatteringPixelShader=`uniform sampler2D textureSampler;uniform sampler2D lightScatteringSampler;uniform float decay;uniform float exposure;uniform float weight;uniform float density;uniform vec2 meshPositionOnScreen;varying vec2 vUV;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
vec2 tc=vUV;vec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);deltaTexCoord*=1.0/float(NUM_SAMPLES)*density;float illuminationDecay=1.0;vec4 color=texture2D(lightScatteringSampler,tc)*0.4;for(int i=0; i<NUM_SAMPLES; i++) {tc-=deltaTexCoord;vec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;dataSample*=illuminationDecay*weight;color+=dataSample;illuminationDecay*=decay;}
|
||
vec4 realColor=texture2D(textureSampler,vUV);gl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}
|
||
`,L(64400),L(49334),Gt.l.ShadersStore.volumetricLightScatteringPassVertexShader=`attribute vec3 position;
|
||
#include<bonesDeclaration>
|
||
#include<bakedVertexAnimationDeclaration>
|
||
#include<morphTargetsVertexGlobalDeclaration>
|
||
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesDeclaration>
|
||
uniform mat4 viewProjection;uniform vec2 depthValues;
|
||
#if defined(ALPHATEST) || defined(NEED_UV)
|
||
varying vec2 vUV;uniform mat4 diffuseMatrix;
|
||
#ifdef UV1
|
||
attribute vec2 uv;
|
||
#endif
|
||
#ifdef UV2
|
||
attribute vec2 uv2;
|
||
#endif
|
||
#endif
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void)
|
||
{vec3 positionUpdated=position;
|
||
#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)
|
||
vec2 uvUpdated=uv;
|
||
#endif
|
||
#include<morphTargetsVertexGlobal>
|
||
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
||
#include<instancesVertex>
|
||
#include<bonesVertex>
|
||
#include<bakedVertexAnimation>
|
||
gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
|
||
#if defined(ALPHATEST) || defined(BASIC_RENDER)
|
||
#ifdef UV1
|
||
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
|
||
#endif
|
||
#ifdef UV2
|
||
vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
|
||
#endif
|
||
#endif
|
||
}
|
||
`,Gt.l.ShadersStore.volumetricLightScatteringPassPixelShader=`#if defined(ALPHATEST) || defined(NEED_UV)
|
||
varying vec2 vUV;
|
||
#endif
|
||
#if defined(ALPHATEST)
|
||
uniform sampler2D diffuseSampler;
|
||
#endif
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{
|
||
#if defined(ALPHATEST)
|
||
vec4 diffuseColor=texture2D(diffuseSampler,vUV);if (diffuseColor.a<0.4)
|
||
discard;
|
||
#endif
|
||
gl_FragColor=vec4(0.0,0.0,0.0,1.0);}
|
||
`;var _T=function(r){function t(e,n,i,o,a,s,l,c,u){a===void 0&&(a=100),s===void 0&&(s=Ie.g.BILINEAR_SAMPLINGMODE);var d,h,p=this;return(p=r.call(this,e,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],n.postProcessRatio||n,i,s,l,c,"#define NUM_SAMPLES "+a)||this)._screenCoordinates=_.I9.Zero(),p.customMeshPosition=_.Pq.Zero(),p.useCustomMeshPosition=!1,p.invert=!0,p.excludedMeshes=[],p.includedMeshes=[],p.exposure=.3,p.decay=.96815,p.weight=.58767,p.density=.926,l=(u=(h=(d=i?.getScene())!==null&&d!==void 0?d:u)!==null&&h!==void 0?h:p._scene).getEngine(),p._viewPort=new Br.L(0,0,1,1).toGlobal(l.getRenderWidth(),l.getRenderHeight()),p.mesh=o??t.CreateDefaultMesh("VolumetricLightScatteringMesh",u),p._createPass(u,n.passRatio||n),p.onActivate=function(m){p.isSupported||p.dispose(m),p.onActivate=null},p.onApplyObservable.add(function(m){p._updateMeshScreenCoordinates(u),m.setTexture("lightScatteringSampler",p._volumetricLightScatteringRTT),m.setFloat("exposure",p.exposure),m.setFloat("decay",p.decay),m.setFloat("weight",p.weight),m.setFloat("density",p.density),m.setVector2("meshPositionOnScreen",p._screenCoordinates)}),p}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"useDiffuseColor",{get:function(){return O.V.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),!1},set:function(e){O.V.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"VolumetricLightScatteringPostProcess"},t.prototype._isReady=function(e,n){var i,o=e.getMesh();if(o===this.mesh&&o.material)return o.material.isReady(o);var a=(i=o._internalAbstractMeshDataInfo._materialForRenderPass)===null||i===void 0?void 0:i[this._scene.getEngine().currentRenderPassId];if(a)return a.isReadyForSubMesh(o,e,n);var s=[],l=[Y.R.PositionKind],c=e.getMaterial();c&&(c.needAlphaTesting()&&s.push("#define ALPHATEST"),o.isVerticesDataPresent(Y.R.UVKind)&&(l.push(Y.R.UVKind),s.push("#define UV1")),o.isVerticesDataPresent(Y.R.UV2Kind)&&(l.push(Y.R.UV2Kind),s.push("#define UV2")));var u=new Tr;if(o.useBones&&o.computeBonesUsingShaders&&o.skeleton){l.push(Y.R.MatricesIndicesKind),l.push(Y.R.MatricesWeightsKind),o.numBoneInfluencers>4&&(l.push(Y.R.MatricesIndicesExtraKind),l.push(Y.R.MatricesWeightsExtraKind)),s.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),o.numBoneInfluencers>0&&u.addCPUSkinningFallback(0,o);var d=o.skeleton;d.isUsingTextureForMatrices?s.push("#define BONETEXTURE"):s.push("#define BonesPerMesh "+(d.bones.length+1))}else s.push("#define NUM_BONE_INFLUENCERS 0");var h=o.morphTargetManager,p=0;h&&(p=h.numMaxInfluencers||h.numInfluencers)>0&&(s.push("#define MORPHTARGETS"),s.push("#define NUM_MORPH_INFLUENCERS "+p),h.isUsingTextureForTargets&&s.push("#define MORPHTARGETS_TEXTURE"),(0,Re.MF)(l,o,p)),n&&(s.push("#define INSTANCES"),(0,Re.te)(l),e.getRenderingMesh().hasThinInstances&&s.push("#define THIN_INSTANCES"));var m=o.bakedVertexAnimationManager;m&&m.isEnabled&&(s.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),n&&l.push("bakedVertexAnimationSettingsInstanced"));var v=e._getDrawWrapper(void 0,!0),b=v.defines,E=s.join(`
|
||
`);return b!==E&&v.setEffect(o.getScene().getEngine().createEffect("volumetricLightScatteringPass",{attributes:l,uniformsNames:["world","mBones","boneTextureWidth","viewProjection","diffuseMatrix","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],uniformBuffersNames:[],samplers:["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"],defines:E,fallbacks:u,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:p}},o.getScene().getEngine()),E),v.effect.isReady()},t.prototype.setCustomMeshPosition=function(e){this.customMeshPosition=e},t.prototype.getCustomMeshPosition=function(){return this.customMeshPosition},t.prototype.dispose=function(e){var n=e.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);n!==-1&&e.getScene().customRenderTargets.splice(n,1),this._volumetricLightScatteringRTT.dispose(),r.prototype.dispose.call(this,e)},t.prototype.getPass=function(){return this._volumetricLightScatteringRTT},t.prototype._meshExcluded=function(e){return this.includedMeshes.length>0&&this.includedMeshes.indexOf(e)===-1||this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1},t.prototype._createPass=function(e,n){var i=this,o=e.getEngine();this._volumetricLightScatteringRTT=new un.$("volumetricLightScatteringMap",{width:o.getRenderWidth()*n,height:o.getRenderHeight()*n},e,!1,!0,P.Y.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var a=this.getCamera();a?a.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var s,l=function(u){var d,h=u.getRenderingMesh(),p=u.getEffectiveMesh();if(!i._meshExcluded(h)){p._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var m=u.getMaterial();if(m){var v=h.getScene(),b=v.getEngine();b.setState(m.backFaceCulling,void 0,void 0,void 0,m.cullBackFaces);var E=h._getInstancesRenderList(u._id,!!u.getReplacementMesh());if(!E.mustReturn){var C=b.getCaps().instancedArrays&&(E.visibleInstances[u._id]!==null||h.hasThinInstances);if(i._isReady(u,C)){var T=(d=p._internalAbstractMeshDataInfo._materialForRenderPass)===null||d===void 0?void 0:d[b.currentRenderPassId],f=u._getDrawWrapper();if(h!==i.mesh||f||(f=m._getDrawWrapper()),!f)return;var g=f.effect;if(b.enableEffect(f),C||h._bind(u,g,m.fillMode),h===i.mesh)m.bind(p.getWorldMatrix(),h);else if(T)T.bindForSubMesh(p.getWorldMatrix(),p,u);else{if(g.setMatrix("viewProjection",v.getTransformMatrix()),m.needAlphaTesting()){var S=m.getAlphaTestTexture();S&&(g.setTexture("diffuseSampler",S),g.setMatrix("diffuseMatrix",S.getTextureMatrix()))}(0,Re.f$)(h,g),(0,Re.nR)(h,g),h.morphTargetManager&&h.morphTargetManager.isUsingTextureForTargets&&h.morphTargetManager._bind(g);var y=u.getMesh().bakedVertexAnimationManager;y&&y.isEnabled&&y.bind(g,C)}C&&h.hasThinInstances&&g.setMatrix("world",p.getWorldMatrix()),h._processRendering(p,u,g,Lt.TriangleFillMode,E,C,function(x,R){x||g.setMatrix("world",R)})}}}}},c=new z.ov(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function(){s=e.clearColor,e.clearColor=c}),this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function(){e.clearColor=s}),this._volumetricLightScatteringRTT.customIsReadyFunction=function(u,d,h){if((h||d===0)&&u.subMeshes)for(var p=0;p<u.subMeshes.length;++p){var m=u.subMeshes[p],v=m.getMaterial(),b=m.getRenderingMesh();if(v){var E=b._getInstancesRenderList(m._id,!!m.getReplacementMesh()),C=o.getCaps().instancedArrays&&(E.visibleInstances[m._id]!==null||b.hasThinInstances);if(!i._isReady(m,C))return!1}}return!0},this._volumetricLightScatteringRTT.customRenderFunction=function(u,d,h,p){var m,v=e.getEngine();if(p.length){for(v.setColorWrite(!1),m=0;m<p.length;m++)l(p.data[m]);v.setColorWrite(!0)}for(m=0;m<u.length;m++)l(u.data[m]);for(m=0;m<d.length;m++)l(d.data[m]);if(h.length){for(m=0;m<h.length;m++){var b=h.data[m],E=b.getBoundingInfo();E&&e.activeCamera&&(b._alphaIndex=b.getMesh().alphaIndex,b._distanceToCamera=E.boundingSphere.centerWorld.subtract(e.activeCamera.position).length())}var C=h.data.slice(0,h.length);for(C.sort(function(T,f){return T._alphaIndex>f._alphaIndex?1:T._alphaIndex<f._alphaIndex?-1:T._distanceToCamera<f._distanceToCamera?1:T._distanceToCamera>f._distanceToCamera?-1:0}),v.setAlphaMode(P.Y.ALPHA_COMBINE),m=0;m<C.length;m++)l(C[m]);v.setAlphaMode(P.Y.ALPHA_DISABLE)}}},t.prototype._updateMeshScreenCoordinates=function(e){var n,i=e.getTransformMatrix();n=this.useCustomMeshPosition?this.customMeshPosition:this.attachedNode?this.attachedNode.position:this.mesh.parent?this.mesh.getAbsolutePosition():this.mesh.position;var o=_.Pq.Project(n,_.uq.Identity(),i,this._viewPort);this._screenCoordinates.x=o.x/this._viewPort.width,this._screenCoordinates.y=o.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},t.CreateDefaultMesh=function(e,n){var i=Ur(e,{size:1},n);i.billboardMode=cn.BILLBOARDMODE_ALL;var o=new qt(e+"Material",n);return o.emissiveColor=new z.v9(1,1,1),i.material=o,i},(0,A.Cg)([(0,V.P_)()],t.prototype,"customMeshPosition",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"useCustomMeshPosition",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"invert",void 0),(0,A.Cg)([(0,V.xG)()],t.prototype,"mesh",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"excludedMeshes",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"includedMeshes",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"exposure",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"decay",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"weight",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"density",void 0),t}(_t.w);(0,j.Y5)("BABYLON.VolumetricLightScatteringPostProcess",_T),Gt.l.ShadersStore.screenSpaceCurvaturePixelShader=`precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform sampler2D normalSampler;uniform float curvature_ridge;uniform float curvature_valley;
|
||
#ifndef CURVATURE_OFFSET
|
||
#define CURVATURE_OFFSET 1
|
||
#endif
|
||
float curvature_soft_clamp(float curvature,float control)
|
||
{if (curvature<0.5/control)
|
||
return curvature*(1.0-curvature*control);return 0.25/control;}
|
||
float calculate_curvature(ivec2 texel,float ridge,float valley)
|
||
{vec2 normal_up =texelFetch(normalSampler,texel+ivec2(0, CURVATURE_OFFSET),0).rb;vec2 normal_down =texelFetch(normalSampler,texel+ivec2(0,-CURVATURE_OFFSET),0).rb;vec2 normal_left =texelFetch(normalSampler,texel+ivec2(-CURVATURE_OFFSET,0),0).rb;vec2 normal_right=texelFetch(normalSampler,texel+ivec2( CURVATURE_OFFSET,0),0).rb;float normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));if (normal_diff<0.0)
|
||
return -2.0*curvature_soft_clamp(-normal_diff,valley);return 2.0*curvature_soft_clamp(normal_diff,ridge);}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{ivec2 texel=ivec2(gl_FragCoord.xy);vec4 baseColor=texture2D(textureSampler,vUV);float curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);baseColor.rgb*=curvature+1.0;gl_FragColor=baseColor;}`;var mT=function(r){function t(e,n,i,o,a,s,l,c,u){c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT),u===void 0&&(u=!1);var d=r.call(this,e,"screenSpaceCurvature",["curvature_ridge","curvature_valley"],["textureSampler","normalSampler"],i,o,a,s,l,void 0,c,void 0,null,u)||this;return d.ridge=1,d.valley=1,d._geometryBufferRenderer=n.enableGeometryBufferRenderer(),d._geometryBufferRenderer?(d._geometryBufferRenderer.generateNormalsInWorldSpace&&O.V.Error("ScreenSpaceCurvaturePostProcess does not support generateNormalsInWorldSpace=true for the geometry buffer renderer!"),d.onApply=function(h){h.setFloat("curvature_ridge",.5/Math.max(d.ridge*d.ridge,1e-4)),h.setFloat("curvature_valley",.7/Math.max(d.valley*d.valley,1e-4));var p=d._geometryBufferRenderer.getGBuffer().textures[1];h.setTexture("normalSampler",p)}):O.V.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."),d}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"ScreenSpaceCurvaturePostProcess"},Object.defineProperty(t,"IsSupported",{get:function(){var e=Ve.q.LastCreatedEngine;return!!e&&e.getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),t._Parse=function(e,n,i,o){return tt.p.Parse(function(){return new t(e.name,i,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable)},e,i,o)},(0,A.Cg)([(0,V.lK)()],t.prototype,"ridge",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"valley",void 0),t}(_t.w);(0,j.Y5)("BABYLON.ScreenSpaceCurvaturePostProcess",mT);var eI=L(96795),tI=L(3072),nI=L(42015),iI=L(41182),rI=L(76832),oI=L(7621),aI=L(56017),sI=L(25750),lI=L(59448),cI=L(33739),uI=L(67291),dI=L(15390),hI=L(68805),fI=L(14830),pI=L(89950),_I=L(47469),mI=L(78138),gI=L(58036),vI=L(88456),yI=L(80239),bI=L(26345),TI=L(78642),SI=L(25781),EI=L(92008),xI=L(57372),PI=L(71263),AI=L(59210),CI=L(93100),RI=L(23459),II=L(13481),MI=L(5439),OI=L(44520),DI=L(10534),NI=L(89111),LI=L(9406),FI=L(44993),wI=L(88977),BI=L(31342),VI=L(35007),UI=L(70154),GI=L(80432),kI=L(27401),zI=L(36489),WI=L(40856),HI=L(30145),YI=L(25910),XI=L(1746),jI=L(31197);Object.defineProperty(ke.Z.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(r){this._forceShowBoundingBoxes=r,r&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),ke.Z.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new gT(this)),this._boundingBoxRenderer},Object.defineProperty(cn.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(r){this._showBoundingBox=r,r&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var gT=function(){function r(t){this.name=lt.v.NAME_BOUNDINGBOXRENDERER,this.frontColor=new z.v9(1,1,1),this.backColor=new z.v9(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new K.cP,this.onAfterBoxRenderingObservable=new K.cP,this.onResourcesReadyObservable=new K.cP,this.enabled=!0,this._shaderLanguage=0,this.renderList=new er.L(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this.scene=t,this.scene.getEngine().isWebGPU&&(this._shaderLanguage=1),t._addComponent(this),this._uniformBufferFront=new Ui.D(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront",!0),this._buildUniformLayout(this._uniformBufferFront),this._uniformBufferBack=new Ui.D(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack",!0),this._buildUniformLayout(this._uniformBufferBack)}return Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._buildUniformLayout=function(t){t.addUniform("color",4),t.addUniform("world",16),t.addUniform("viewProjection",16),t.addUniform("viewProjectionR",16),t.create()},r.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(lt.v.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(lt.v.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(lt.v.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(lt.v.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)},r.prototype._evaluateSubMesh=function(t,e){if(t.showSubMeshesBoundingBox){var n=e.getBoundingInfo();n!=null&&(n.boundingBox._tag=t.renderingGroupId,this.renderList.push(n.boundingBox))}},r.prototype._preActiveMesh=function(t){if(t.showBoundingBox||this.scene.forceShowBoundingBoxes){var e=t.getBoundingInfo();e.boundingBox._tag=t.renderingGroupId,this.renderList.push(e.boundingBox)}},r.prototype._prepareResources=function(){var t=this;if(!this._colorShader){this._colorShader=new pi("colorShader",this.scene,"boundingBoxRenderer",{attributes:[Y.R.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(i){switch(i.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,34063)),Promise.resolve().then(L.bind(L,30025))])];case 1:return i.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,67569)),Promise.resolve().then(L.bind(L,72627))])];case 3:i.sent(),i.label=4;case 4:return[2]}})})}},!1),this._colorShader.doNotSerialize=!0,this._colorShader.reservedDataStore={hidden:!0},this._colorShaderForOcclusionQuery=new pi("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{attributes:[Y.R.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(i){switch(i.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,34063)),Promise.resolve().then(L.bind(L,30025))])];case 1:return i.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,67569)),Promise.resolve().then(L.bind(L,72627))])];case 3:i.sent(),i.label=4;case 4:return[2]}})})}},!0),this._colorShaderForOcclusionQuery.doNotSerialize=!0,this._colorShaderForOcclusionQuery.reservedDataStore={hidden:!0};var e=this.scene.getEngine(),n=Ys({size:1});this._vertexBuffers[Y.R.PositionKind]=new Y.R(e,n.positions,Y.R.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=n.indices,this.onResourcesReadyObservable.notifyObservers(this)}},r.prototype._createIndexBuffer=function(){var t=this.scene.getEngine();this._indexBuffer=t.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])},r.prototype.rebuild=function(){var t=this._vertexBuffers[Y.R.PositionKind];t&&t._rebuild(),this._createIndexBuffer()},r.prototype.reset=function(){this.renderList.reset()},r.prototype.render=function(t){var e,n;if(this.renderList.length!==0&&this.enabled&&(this._prepareResources(),this._colorShader.isReady())){var i=this.scene.getEngine();i.setDepthWrite(!1);for(var o=this.scene.getTransformMatrix(),a=0;a<this.renderList.length;a++){var s=this.renderList.data[a];if(s._tag===t){this._createWrappersForBoundingBox(s),this.onBeforeBoxRenderingObservable.notifyObservers(s);var l=s.minimum,c=s.maximum.subtract(l),u=l.add(c.scale(.5)),d=_.uq.Scaling(c.x,c.y,c.z).multiply(_.uq.Translation(u.x,u.y,u.z)).multiply(s.getWorldMatrix()),h=i.useReverseDepthBuffer;if(this.showBackLines){var p=(e=s._drawWrapperBack)!==null&&e!==void 0?e:this._colorShader._getDrawWrapper();this._colorShader._preBind(p),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),h?i.setDepthFunctionToLessOrEqual():i.setDepthFunctionToGreaterOrEqual(),this._uniformBufferBack.bindToEffect(p.effect,"BoundingBoxRenderer"),this._uniformBufferBack.updateColor4("color",this.backColor,1),this._uniformBufferBack.updateMatrix("world",d),this._uniformBufferBack.updateMatrix("viewProjection",o),this._uniformBufferBack.update(),i.drawElementsType(Lt.LineListDrawMode,0,24)}var m=(n=s._drawWrapperFront)!==null&&n!==void 0?n:this._colorShader._getDrawWrapper();this._colorShader._preBind(m),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),h?i.setDepthFunctionToGreater():i.setDepthFunctionToLess(),this._uniformBufferFront.bindToEffect(m.effect,"BoundingBoxRenderer"),this._uniformBufferFront.updateColor4("color",this.frontColor,1),this._uniformBufferFront.updateMatrix("world",d),this._uniformBufferFront.updateMatrix("viewProjection",o),this._uniformBufferFront.update(),i.drawElementsType(Lt.LineListDrawMode,0,24),this.onAfterBoxRenderingObservable.notifyObservers(s)}}this._colorShader.unbind(),i.setDepthFunctionToLessOrEqual(),i.setDepthWrite(!0)}},r.prototype._createWrappersForBoundingBox=function(t){if(!t._drawWrapperFront){var e=this.scene.getEngine();t._drawWrapperFront=new jn.E(e),t._drawWrapperBack=new jn.E(e),t._drawWrapperFront.setEffect(this._colorShader.getEffect()),t._drawWrapperBack.setEffect(this._colorShader.getEffect())}},r.prototype.renderOcclusionBoundingBox=function(t){var e=this.scene.getEngine();this._renderPassIdForOcclusionQuery===void 0&&(this._renderPassIdForOcclusionQuery=e.createRenderPassId("Render pass for occlusion query"));var n=e.currentRenderPassId;e.currentRenderPassId=this._renderPassIdForOcclusionQuery,this._prepareResources();var i=t.subMeshes[0];if(this._colorShaderForOcclusionQuery.isReady(t,void 0,i)&&t.hasBoundingInfo){this._fillIndexBuffer||(this._fillIndexBuffer=e.createIndexBuffer(this._fillIndexData));var o=e.useReverseDepthBuffer;e.setDepthWrite(!1),e.setColorWrite(!1);var a=t.getBoundingInfo().boundingBox,s=a.minimum,l=a.maximum.subtract(s),c=s.add(l.scale(.5)),u=_.uq.Scaling(l.x,l.y,l.z).multiply(_.uq.Translation(c.x,c.y,c.z)).multiply(a.getWorldMatrix()),d=i._drawWrapper;this._colorShaderForOcclusionQuery._preBind(d),e.bindBuffers(this._vertexBuffers,this._fillIndexBuffer,d.effect),o?e.setDepthFunctionToGreater():e.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._uniformBufferFront.bindToEffect(d.effect,"BoundingBoxRenderer"),this._uniformBufferFront.updateMatrix("world",u),this._uniformBufferFront.updateMatrix("viewProjection",this.scene.getTransformMatrix()),this._uniformBufferFront.update(),e.drawElementsType(Lt.TriangleFillMode,0,36),this._colorShaderForOcclusionQuery.unbind(),e.setDepthFunctionToLessOrEqual(),e.setDepthWrite(!0),e.setColorWrite(!0),e.currentRenderPassId=n}else e.currentRenderPassId=n},r.prototype.dispose=function(){if(this._renderPassIdForOcclusionQuery!==void 0&&(this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery),this._renderPassIdForOcclusionQuery=void 0),this._colorShader){this.onBeforeBoxRenderingObservable.clear(),this.onAfterBoxRenderingObservable.clear(),this.onResourcesReadyObservable.clear(),this.renderList.dispose(),this._colorShader.dispose(),this._colorShaderForOcclusionQuery.dispose(),this._uniformBufferFront.dispose(),this._uniformBufferBack.dispose();var t=this._vertexBuffers[Y.R.PositionKind];t&&(t.dispose(),this._vertexBuffers[Y.R.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer),this._fillIndexBuffer&&(this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),this._fillIndexBuffer=null)}},r}();ke.Z.prototype.enableDepthRenderer=function(r,t,e,n,i){if(t===void 0&&(t=!1),e===void 0&&(e=!1),n===void 0&&(n=P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),i===void 0&&(i=!1),!(r=r||this.activeCamera))throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[r.id]){var o,a=!!this.getEngine().getCaps().textureFloatRender;o=!this.getEngine().getCaps().textureHalfFloatRender||e&&a?a?P.Y.TEXTURETYPE_FLOAT:P.Y.TEXTURETYPE_UNSIGNED_BYTE:P.Y.TEXTURETYPE_HALF_FLOAT,this._depthRenderer[r.id]=new ls(this,o,r,t,n,i)}return this._depthRenderer[r.id]},ke.Z.prototype.disableDepthRenderer=function(r){(r=r||this.activeCamera)&&this._depthRenderer&&this._depthRenderer[r.id]&&this._depthRenderer[r.id].dispose()};var vT=function(){function r(t){this.name=lt.v.NAME_DEPTHRENDERER,this.scene=t}return r.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(lt.v.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(lt.v.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){for(var t in this.scene._depthRenderer)this.scene._depthRenderer[t].dispose()},r.prototype._gatherRenderTargets=function(t){if(this.scene._depthRenderer)for(var e in this.scene._depthRenderer){var n=this.scene._depthRenderer[e];n.enabled&&!n.useOnlyInActiveCamera&&t.push(n.getDepthMap())}},r.prototype._gatherActiveCameraRenderTargets=function(t){if(this.scene._depthRenderer)for(var e in this.scene._depthRenderer){var n=this.scene._depthRenderer[e];n.enabled&&n.useOnlyInActiveCamera&&this.scene.activeCamera.id===e&&t.push(n.getDepthMap())}},r}();ls._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_DEPTHRENDERER);t||(t=new vT(r),r._addComponent(t))};var MN=function(){this.enabled=!0,this.name="depthPeeling",this.texturesRequired=[P.Y.PREPASS_COLOR_TEXTURE_TYPE]},yT=function(){function r(t,e){if(e===void 0&&(e=5),this._thinTextures=[],this._currentPingPongState=0,this._layoutCacheFormat=[[!0],[!0,!0],[!0,!0,!0]],this._layoutCache=[],this._candidateSubMeshes=new er.L(10),this._excludedSubMeshes=new er.L(10),this._excludedMeshes=[],this._colorCache=[new z.ov(r._DEPTH_CLEAR_VALUE,r._DEPTH_CLEAR_VALUE,0,0),new z.ov(-r._MIN_DEPTH,r._MAX_DEPTH,0,0),new z.ov(0,0,0,0)],this._shaderLanguage=0,this._scene=t,this._engine=t.getEngine(),this._passCount=e,t.enablePrePassRenderer()){for(var n=0;n<this._layoutCacheFormat.length;++n)this._layoutCache[n]=this._engine.buildTextureLayout(this._layoutCacheFormat[n]);this._renderPassIds=[],this.useRenderPasses=!1,this._engine.isWebGPU&&(this._shaderLanguage=1),this._prePassEffectConfiguration=new MN,this._createTextures(),this._createEffects()}else O.V.Warn("Depth peeling for order independant transparency could not enable PrePass, aborting.")}return Object.defineProperty(r.prototype,"passCount",{get:function(){return this._passCount},set:function(t){this._passCount!==t&&(this._passCount=t,this._createRenderPassIds())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useRenderPasses",{get:function(){return this._useRenderPasses},set:function(t){this._useRenderPasses!==t&&(this._useRenderPasses=t,this._createRenderPassIds())},enumerable:!1,configurable:!0}),r.prototype.addExcludedMesh=function(t){this._excludedMeshes.indexOf(t.uniqueId)===-1&&this._excludedMeshes.push(t.uniqueId)},r.prototype.removeExcludedMesh=function(t){var e=this._excludedMeshes.indexOf(t.uniqueId);e!==-1&&this._excludedMeshes.splice(e,1)},Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._createRenderPassIds=function(){if(this._releaseRenderPassIds(),this._useRenderPasses)for(var t=0;t<this._passCount+1;++t)this._renderPassIds[t]||(this._renderPassIds[t]=this._engine.createRenderPassId("DepthPeelingRenderer - pass #".concat(t)))},r.prototype._releaseRenderPassIds=function(){for(var t=0;t<this._renderPassIds.length;++t)this._engine.releaseRenderPassId(this._renderPassIds[t]);this._renderPassIds=[]},r.prototype._createTextures=function(){var t={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()};this._depthMrts=[new Kr("depthPeelingDepth0MRT",t,3,this._scene,void 0,["depthPeelingDepth0MRT_depth","depthPeelingDepth0MRT_frontColor","depthPeelingDepth0MRT_backColor"]),new Kr("depthPeelingDepth1MRT",t,3,this._scene,void 0,["depthPeelingDepth1MRT_depth","depthPeelingDepth1MRT_frontColor","depthPeelingDepth1MRT_backColor"])],this._colorMrts=[new Kr("depthPeelingColor0MRT",t,2,this._scene,{generateDepthBuffer:!1},["depthPeelingColor0MRT_frontColor","depthPeelingColor0MRT_backColor"]),new Kr("depthPeelingColor1MRT",t,2,this._scene,{generateDepthBuffer:!1},["depthPeelingColor1MRT_frontColor","depthPeelingColor1MRT_backColor"])],this._blendBackMrt=new Kr("depthPeelingBackMRT",t,1,this._scene,{generateDepthBuffer:!1},["depthPeelingBackMRT_blendBack"]),this._outputRT=new un.$("depthPeelingOutputRTT",t,this._scene,!1);for(var e=[{format:P.Y.TEXTUREFORMAT_RG,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,type:this._engine.getCaps().textureFloatLinearFiltering?P.Y.TEXTURETYPE_FLOAT:P.Y.TEXTURETYPE_HALF_FLOAT,label:"DepthPeelingRenderer-DepthTexture"},{format:P.Y.TEXTUREFORMAT_RGBA,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,type:P.Y.TEXTURETYPE_HALF_FLOAT,label:"DepthPeelingRenderer-ColorTexture"}],n=0;n<2;n++){var i=this._engine._createInternalTexture(t,e[0],!1),o=this._engine._createInternalTexture(t,e[1],!1),a=this._engine._createInternalTexture(t,e[1],!1);this._depthMrts[n].setInternalTexture(i,0),this._depthMrts[n].setInternalTexture(o,1),this._depthMrts[n].setInternalTexture(a,2),this._colorMrts[n].setInternalTexture(o,0),this._colorMrts[n].setInternalTexture(a,1),this._thinTextures.push(new da.D(i),new da.D(o),new da.D(a))}},r.prototype._disposeTextures=function(){for(var t=0;t<this._thinTextures.length;t++)t!==6&&this._thinTextures[t].dispose();for(t=0;t<2;t++)this._depthMrts[t].dispose(!0),this._colorMrts[t].dispose(!0),this._blendBackMrt.dispose(!0);this._outputRT.dispose(),this._thinTextures=[],this._colorMrts=[],this._depthMrts=[]},r.prototype._updateTextures=function(){return this._depthMrts[0].getSize().width===this._engine.getRenderWidth()&&this._depthMrts[0].getSize().height===this._engine.getRenderHeight()||(this._disposeTextures(),this._createTextures()),this._updateTextureReferences()},r.prototype._updateTextureReferences=function(){var t,e=this._scene.prePassRenderer;if(!e)return!1;var n=e.getIndex(P.Y.PREPASS_COLOR_TEXTURE_TYPE),i=!((t=e.defaultRT.textures)===null||t===void 0)&&t.length?e.defaultRT.textures[n].getInternalTexture():null;return!!i&&(this._blendBackTexture!==i&&(this._blendBackTexture=i,this._blendBackMrt.setInternalTexture(this._blendBackTexture,0),this._thinTextures[6]&&this._thinTextures[6].dispose(),this._thinTextures[6]=new da.D(this._blendBackTexture),e.defaultRT.renderTarget.shareDepth(this._depthMrts[0].renderTarget)),!0)},r.prototype._createEffects=function(){var t=this;this._blendBackEffectWrapper=new Ni.$({fragmentShader:"oitBackBlend",useShaderStore:!0,engine:this._engine,samplerNames:["uBackColor"],uniformNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,27993))];case 1:return e.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,37624))];case 3:e.sent(),e.label=4;case 4:return[2]}})})}}),this._blendBackEffectWrapperPingPong=new Ni.$({fragmentShader:"oitBackBlend",useShaderStore:!0,engine:this._engine,samplerNames:["uBackColor"],uniformNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,27993))];case 1:return e.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,37624))];case 3:e.sent(),e.label=4;case 4:return[2]}})})}}),this._finalEffectWrapper=new Ni.$({fragmentShader:"oitFinal",useShaderStore:!0,engine:this._engine,samplerNames:["uFrontColor","uBackColor"],uniformNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(e){switch(e.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,5519))];case 1:return e.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,73758))];case 3:e.sent(),e.label=4;case 4:return[2]}})})}}),this._effectRenderer=new Ni.J(this._engine)},r.prototype.setPrePassRenderer=function(t){t.addEffectConfiguration(this._prePassEffectConfiguration)},r.prototype.bind=function(t){t.setTexture("oitDepthSampler",this._thinTextures[3*this._currentPingPongState]),t.setTexture("oitFrontColorSampler",this._thinTextures[3*this._currentPingPongState+1])},r.prototype._renderSubMeshes=function(t){var e;this._useRenderPasses&&(e={});for(var n=0;n<t.length;n++){var i=t.data[n].getMaterial(),o=!0,a=!1,s=t.data[n],l=void 0,c=!1;if(this._useRenderPasses&&(c=!(l=s._getDrawWrapper())),i&&(o=i.allowShaderHotSwapping,a=i.backFaceCulling,i.allowShaderHotSwapping=!1,i.backFaceCulling=!1),s.render(!1),c&&(l=s._getDrawWrapper()).materialContext){var u=e[l.materialContext.uniqueId];u||(u=e[l.materialContext.uniqueId]=this._engine.createMaterialContext()),s._getDrawWrapper().materialContext=u}i&&(i.allowShaderHotSwapping=o,i.backFaceCulling=a)}},r.prototype._finalCompose=function(t){var e;!((e=this._scene.prePassRenderer)===null||e===void 0)&&e.setCustomOutput(this._outputRT)?this._engine.bindFramebuffer(this._outputRT.renderTarget):this._engine.restoreDefaultFramebuffer(),this._engine.setAlphaMode(P.Y.ALPHA_DISABLE),this._engine.applyStates(),this._engine.enableEffect(this._finalEffectWrapper._drawWrapper),this._finalEffectWrapper.effect.setTexture("uFrontColor",this._thinTextures[3*t+1]),this._finalEffectWrapper.effect.setTexture("uBackColor",this._thinTextures[6]),this._effectRenderer.render(this._finalEffectWrapper)},r.prototype.isReady=function(){return this._blendBackEffectWrapper.effect.isReady()&&this._blendBackEffectWrapperPingPong.effect.isReady()&&this._finalEffectWrapper.effect.isReady()&&this._updateTextures()},r.prototype.render=function(t){if(this._candidateSubMeshes.length=0,this._excludedSubMeshes.length=0,!this.isReady())return this._excludedSubMeshes;this._scene.activeCamera&&this._engine.setViewport(this._scene.activeCamera.viewport);for(var e=0;e<t.length;e++){var n=t.data[e],i=n.getMaterial(),o=i&&n.getRenderingMesh()._getRenderingFillMode(i.fillMode);!i||o!==Lt.TriangleFanDrawMode&&o!==Lt.TriangleFillMode&&o!==Lt.TriangleStripDrawMode||this._excludedMeshes.indexOf(n.getMesh().uniqueId)!==-1?this._excludedSubMeshes.push(n):this._candidateSubMeshes.push(n)}if(!this._candidateSubMeshes.length)return this._engine.bindFramebuffer(this._colorMrts[1].renderTarget),this._engine.bindAttachments(this._layoutCache[1]),this._engine.clear(this._colorCache[2],!0,!1,!1),this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget),this._finalCompose(1),this._excludedSubMeshes;var a=this._engine.currentRenderPassId;this._scene.prePassRenderer._enabled=!1,this._useRenderPasses&&(this._engine.currentRenderPassId=this._renderPassIds[0]),this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.clear(this._colorCache[0],!0,!1,!1),this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget),this._engine.bindFramebuffer(this._depthMrts[1].renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.clear(this._colorCache[1],!0,!1,!1),this._engine.unBindFramebuffer(this._depthMrts[1].renderTarget),this._engine.bindFramebuffer(this._colorMrts[0].renderTarget),this._engine.bindAttachments(this._layoutCache[1]),this._engine.clear(this._colorCache[2],!0,!1,!1),this._engine.unBindFramebuffer(this._colorMrts[0].renderTarget),this._engine.bindFramebuffer(this._colorMrts[1].renderTarget),this._engine.bindAttachments(this._layoutCache[1]),this._engine.clear(this._colorCache[2],!0,!1,!1),this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget),this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.setAlphaMode(P.Y.ALPHA_ONEONE_ONEONE),this._engine.setAlphaEquation(P.Y.ALPHA_EQUATION_MAX),this._engine.depthCullingState.depthMask=!1,this._engine.depthCullingState.depthTest=!0,this._engine.applyStates(),this._currentPingPongState=1,this._renderSubMeshes(this._candidateSubMeshes),this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget),this._scene.resetCachedMaterial();var s=0,l=0;for(e=0;e<this._passCount;e++){l=1-(s=e%2),this._currentPingPongState=s,this._useRenderPasses&&(this._engine.currentRenderPassId=this._renderPassIds[e+1]),this._scene.activeCamera&&this._engine.setViewport(this._scene.activeCamera.viewport),this._engine.bindFramebuffer(this._depthMrts[l].renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.clear(this._colorCache[0],!0,!1,!1),this._engine.unBindFramebuffer(this._depthMrts[l].renderTarget),this._engine.bindFramebuffer(this._colorMrts[l].renderTarget),this._engine.bindAttachments(this._layoutCache[1]),this._engine.clear(this._colorCache[2],!0,!1,!1),this._engine.unBindFramebuffer(this._colorMrts[l].renderTarget),this._engine.bindFramebuffer(this._depthMrts[l].renderTarget),this._engine.bindAttachments(this._layoutCache[2]),this._engine.setAlphaMode(P.Y.ALPHA_ONEONE_ONEONE),this._engine.setAlphaEquation(P.Y.ALPHA_EQUATION_MAX),this._engine.depthCullingState.depthTest=!1,this._engine.applyStates(),this._renderSubMeshes(this._candidateSubMeshes),this._engine.unBindFramebuffer(this._depthMrts[l].renderTarget),this._scene.resetCachedMaterial(),this._engine.bindFramebuffer(this._blendBackMrt.renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.setAlphaEquation(P.Y.ALPHA_EQUATION_ADD),this._engine.setAlphaMode(P.Y.ALPHA_LAYER_ACCUMULATE),this._engine.applyStates();var c=l!==0&&this._useRenderPasses?this._blendBackEffectWrapperPingPong:this._blendBackEffectWrapper;this._engine.enableEffect(c._drawWrapper),c.effect.setTexture("uBackColor",this._thinTextures[3*l+2]),this._effectRenderer.render(c),this._engine.unBindFramebuffer(this._blendBackMrt.renderTarget)}return this._engine.currentRenderPassId=a,this._finalCompose(l),this._scene.prePassRenderer._enabled=!0,this._engine.depthCullingState.depthMask=!0,this._engine.depthCullingState.depthTest=!0,this._excludedSubMeshes},r.prototype.dispose=function(){this._disposeTextures(),this._blendBackEffectWrapper.dispose(),this._finalEffectWrapper.dispose(),this._effectRenderer.dispose(),this._releaseRenderPassIds()},r._DEPTH_CLEAR_VALUE=-99999,r._MIN_DEPTH=0,r._MAX_DEPTH=1,r}();Object.defineProperty(ke.Z.prototype,"depthPeelingRenderer",{get:function(){if(!this._depthPeelingRenderer){var r=this._getComponent(lt.v.NAME_DEPTHPEELINGRENDERER);r||(r=new bT(this),this._addComponent(r))}return this._depthPeelingRenderer},set:function(r){this._depthPeelingRenderer=r},enumerable:!0,configurable:!0}),Object.defineProperty(ke.Z.prototype,"useOrderIndependentTransparency",{get:function(){return this._useOrderIndependentTransparency},set:function(r){var t;this._useOrderIndependentTransparency!==r&&(this._useOrderIndependentTransparency=r,this.markAllMaterialsAsDirty(P.Y.MATERIAL_AllDirtyFlag),(t=this.prePassRenderer)===null||t===void 0||t.markAsDirty())},enumerable:!0,configurable:!0});var bT=function(){function r(t){this.name=lt.v.NAME_DEPTHPEELINGRENDERER,this.scene=t,t.depthPeelingRenderer=new yT(t)}return r.prototype.register=function(){},r.prototype.rebuild=function(){},r.prototype.dispose=function(){var t;(t=this.scene.depthPeelingRenderer)===null||t===void 0||t.dispose(),this.scene.depthPeelingRenderer=null},r}();cn.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},cn.prototype.enableEdgesRendering=function(r,t,e){return r===void 0&&(r=.95),t===void 0&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Yf(this,r,t,!0,e),this},Object.defineProperty(cn.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),aa.prototype.enableEdgesRendering=function(r,t){return r===void 0&&(r=.95),t===void 0&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new TT(this,r,t),this},Lu.prototype.enableEdgesRendering=function(r,t){return r===void 0&&(r=.95),t===void 0&&(t=!1),aa.prototype.enableEdgesRendering.apply(this,arguments),this};var ON=function(){this.edges=[],this.edgesConnectedCount=0},Yf=function(){function r(t,e,n,i,o){e===void 0&&(e=.95),n===void 0&&(n=!1),i===void 0&&(i=!0);var a,s=this;this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._buffersForInstances={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this.customInstances=new er.L(32),this._shaderLanguage=0,this._source=t,this._checkVerticesInsteadOfIndices=n,this._options=o??null,this._epsilon=e;var l=this._source.getScene().getEngine();l.isWebGPU&&(this._drawWrapper=new jn.E(l),this._shaderLanguage=1),this._prepareRessources(),i&&((a=o?.useAlternateEdgeFinder)===null||a===void 0||a?this._generateEdgesLinesAlternate():this._generateEdgesLines()),this._meshRebuildObserver=this._source.onRebuildObservable.add(function(){s._rebuild()}),this._meshDisposeObserver=this._source.onDisposeObservable.add(function(){s.dispose()})}return Object.defineProperty(r.prototype,"linesPositions",{get:function(){return this._linesPositions},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linesNormals",{get:function(){return this._linesNormals},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linesIndices",{get:function(){return this._linesIndices},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"lineShader",{get:function(){return this._lineShader},set:function(t){this._lineShader=t},enumerable:!1,configurable:!0}),r._GetShader=function(t,e){var n=this;if(!t._edgeRenderLineShader){var i=new pi("lineShader",t,"line",{attributes:["position","normal"],uniforms:["world","viewProjection","color","width","aspectRatio"],uniformBuffers:["Scene","Mesh"],shaderLanguage:e,extraInitializationsAsync:function(){return(0,A.sH)(n,void 0,void 0,function(){return(0,A.YH)(this,function(o){switch(o.label){case 0:return e!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,63327)),Promise.resolve().then(L.bind(L,34873))])];case 1:return o.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,60738)),Promise.resolve().then(L.bind(L,97468))])];case 3:o.sent(),o.label=4;case 4:return[2]}})})}},!1);i.disableDepthWrite=!0,i.backFaceCulling=!1,i.checkReadyOnEveryCall=t.getEngine().isWebGPU,t._edgeRenderLineShader=i}return t._edgeRenderLineShader},Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=r._GetShader(this._source.getScene(),this._shaderLanguage))},r.prototype._rebuild=function(){var t=this._buffers[Y.R.PositionKind];t&&t._rebuild(),(t=this._buffers[Y.R.NormalKind])&&t._rebuild();var e=this._source.getScene().getEngine();this._ib=e.createIndexBuffer(this._linesIndices)},r.prototype.dispose=function(){var t;this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var e=this._buffers[Y.R.PositionKind];e&&(e.dispose(),this._buffers[Y.R.PositionKind]=null),(e=this._buffers[Y.R.NormalKind])&&(e.dispose(),this._buffers[Y.R.NormalKind]=null),this._ib&&this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose(),(t=this._drawWrapper)===null||t===void 0||t.dispose()},r.prototype._processEdgeForAdjacencies=function(t,e,n,i,o){return t===n&&e===i||t===i&&e===n?0:t===i&&e===o||t===o&&e===i?1:t===o&&e===n||t===n&&e===o?2:-1},r.prototype._processEdgeForAdjacenciesWithVertices=function(t,e,n,i,o){var a=1e-10;return t.equalsWithEpsilon(n,a)&&e.equalsWithEpsilon(i,a)||t.equalsWithEpsilon(i,a)&&e.equalsWithEpsilon(n,a)?0:t.equalsWithEpsilon(i,a)&&e.equalsWithEpsilon(o,a)||t.equalsWithEpsilon(o,a)&&e.equalsWithEpsilon(i,a)?1:t.equalsWithEpsilon(o,a)&&e.equalsWithEpsilon(n,a)||t.equalsWithEpsilon(n,a)&&e.equalsWithEpsilon(o,a)?2:-1},r.prototype._checkEdge=function(t,e,n,i,o){(e===void 0||_.Pq.Dot(n[t],n[e])<this._epsilon)&&this.createLine(i,o,this._linesPositions.length/3)},r.prototype.createLine=function(t,e,n){this._linesPositions.push(t.x,t.y,t.z,t.x,t.y,t.z,e.x,e.y,e.z,e.x,e.y,e.z),this._linesNormals.push(e.x,e.y,e.z,-1,e.x,e.y,e.z,1,t.x,t.y,t.z,-1,t.x,t.y,t.z,1),this._linesIndices.push(n,n+1,n+2,n,n+2,n+3)},r.prototype._tessellateTriangle=function(t,e,n,i){var o=function(R,I,M){M>=0&&I.push(M);for(var D=0;D<R.length;++D)I.push(R[D][0])},a=0;t[1].length>=t[0].length&&t[1].length>=t[2].length?a=1:t[2].length>=t[0].length&&t[2].length>=t[1].length&&(a=2);for(var s=0;s<3;++s)s===a?t[s].sort(function(R,I){return R[1]<I[1]?-1:R[1]>I[1]?1:0}):t[s].sort(function(R,I){return R[1]>I[1]?-1:R[1]<I[1]?1:0});var l=[],c=[];o(t[a],l,-1);for(var u=l.length,d=a+2;d>=a+1;--d)o(t[d%3],c,d!==a+2?i[n[e+(d+1)%3]]:-1);var h=c.length;n.push(i[n[e+a]],l[0],c[0]),n.push(i[n[e+(a+1)%3]],c[h-1],l[u-1]);for(var p=u<=h,m=p?u:h,v=p?h:u,b=p?u-1:h-1,E=p?0:1,C=u+h-2,T=0,f=0,g=p?l:c,S=p?c:l,y=0;C-- >0;){E?n.push(g[T],S[f]):n.push(S[f],g[T]);var x=void 0;(y+=m)>=v&&T<b?(x=g[++T],y-=v):x=S[++f],n.push(x)}n[e+0]=n[n.length-3],n[e+1]=n[n.length-2],n[e+2]=n[n.length-1],n.length=n.length-3},r.prototype._generateEdgesLinesAlternate=function(){var t,e,n,i,o,a,s,l,c,u,d=this._source.getVerticesData(Y.R.PositionKind),h=this._source.getIndices();if(h&&d){Array.isArray(h)||(h=Array.from(h));var p=(e=(t=this._options)===null||t===void 0?void 0:t.useFastVertexMerger)===null||e===void 0||e,m=p?Math.round(-Math.log((i=(n=this._options)===null||n===void 0?void 0:n.epsilonVertexMerge)!==null&&i!==void 0?i:1e-6)/Math.log(10)):(a=(o=this._options)===null||o===void 0?void 0:o.epsilonVertexMerge)!==null&&a!==void 0?a:1e-6,v=[],b=[];if(p)for(var E={},C=0;C<d.length;C+=3){var T=d[C+0],f=d[C+1],g=d[C+2];if(E[Ke=T.toFixed(m)+"|"+f.toFixed(m)+"|"+g.toFixed(m)]!==void 0)v.push(E[Ke]);else{var S=C/3;E[Ke]=S,v.push(S),b.push(S)}}else for(C=0;C<d.length;C+=3){T=d[C+0],f=d[C+1],g=d[C+2];for(var y=!1,x=0;x<C&&!y;x+=3){var R=d[x+0],I=d[x+1],M=d[x+2];if(Math.abs(T-R)<m&&Math.abs(f-I)<m&&Math.abs(g-M)<m){v.push(x/3),y=!0;break}}y||(v.push(C/3),b.push(C/3))}if(!((s=this._options)===null||s===void 0)&&s.applyTessellation){for(var D=(c=(l=this._options)===null||l===void 0?void 0:l.epsilonVertexAligned)!==null&&c!==void 0?c:1e-6,B=[],F=0;F<h.length;F+=3)for(var X=void 0,$=0;$<3;++$){var Q=v[h[F+$]],ie=v[h[F+($+1)%3]],q=v[h[F+($+2)%3]];if(Q!==ie)for(var ee=d[3*Q+0],te=d[3*Q+1],ce=d[3*Q+2],fe=d[3*ie+0],de=d[3*ie+1],Te=d[3*ie+2],ue=Math.sqrt((fe-ee)*(fe-ee)+(de-te)*(de-te)+(Te-ce)*(Te-ce)),U=0;U<b.length-1;U++){var N=b[U];if(N!==Q&&N!==ie&&N!==q){var w=d[3*N+0],k=d[3*N+1],J=d[3*N+2],le=Math.sqrt((w-ee)*(w-ee)+(k-te)*(k-te)+(J-ce)*(J-ce)),be=Math.sqrt((w-fe)*(w-fe)+(k-de)*(k-de)+(J-Te)*(J-Te));Math.abs(le+be-ue)<D&&(X||(X={index:F,edgesPoints:[[],[],[]]},B.push(X)),X.edgesPoints[$].push([N,le]))}}}for(var ve=0;ve<B.length;++ve){var ye=B[ve];this._tessellateTriangle(ye.edgesPoints,ye.index,h,v)}B.length=0}var Me={};for(F=0;F<h.length;F+=3){var we=void 0;for($=0;$<3;++$)if(Q=v[h[F+$]],ie=v[h[F+($+1)%3]],q=v[h[F+($+2)%3]],Q!==ie&&(Q!==q&&ie!==q||!(!((u=this._options)===null||u===void 0)&&u.removeDegeneratedTriangles))){if(_.AA.Vector3[0].copyFromFloats(d[3*Q+0],d[3*Q+1],d[3*Q+2]),_.AA.Vector3[1].copyFromFloats(d[3*ie+0],d[3*ie+1],d[3*ie+2]),_.AA.Vector3[2].copyFromFloats(d[3*q+0],d[3*q+1],d[3*q+2]),we||(_.AA.Vector3[1].subtractToRef(_.AA.Vector3[0],_.AA.Vector3[3]),_.AA.Vector3[2].subtractToRef(_.AA.Vector3[1],_.AA.Vector3[4]),(we=_.Pq.Cross(_.AA.Vector3[3],_.AA.Vector3[4])).normalize()),Q>ie){var He=Q;Q=ie,ie=He}(Qe=Me[Ke=Q+"_"+ie])?Qe.done||(_.Pq.Dot(we,Qe.normal)<this._epsilon&&this.createLine(_.AA.Vector3[0],_.AA.Vector3[1],this._linesPositions.length/3),Qe.done=!0):Me[Ke]={normal:we,done:!1,index:F,i:$}}}for(var Ke in Me){var Qe;(Qe=Me[Ke]).done||(Q=v[h[Qe.index+Qe.i]],ie=v[h[Qe.index+(Qe.i+1)%3]],_.AA.Vector3[0].copyFromFloats(d[3*Q+0],d[3*Q+1],d[3*Q+2]),_.AA.Vector3[1].copyFromFloats(d[3*ie+0],d[3*ie+1],d[3*ie+2]),this.createLine(_.AA.Vector3[0],_.AA.Vector3[1],this._linesPositions.length/3))}var Je=this._source.getScene().getEngine();this._buffers[Y.R.PositionKind]=new Y.R(Je,this._linesPositions,Y.R.PositionKind,!1),this._buffers[Y.R.NormalKind]=new Y.R(Je,this._linesNormals,Y.R.NormalKind,!1,!1,4),this._buffersForInstances[Y.R.PositionKind]=this._buffers[Y.R.PositionKind],this._buffersForInstances[Y.R.NormalKind]=this._buffers[Y.R.NormalKind],this._ib=Je.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},r.prototype._generateEdgesLines=function(){var t=this._source.getVerticesData(Y.R.PositionKind),e=this._source.getIndices();if(e&&t){var n,i,o=[],a=[];for(n=0;n<e.length;n+=3){i=new ON;var s=e[n],l=e[n+1],c=e[n+2];i.p0=new _.Pq(t[3*s],t[3*s+1],t[3*s+2]),i.p1=new _.Pq(t[3*l],t[3*l+1],t[3*l+2]),i.p2=new _.Pq(t[3*c],t[3*c+1],t[3*c+2]);var u=_.Pq.Cross(i.p1.subtract(i.p0),i.p2.subtract(i.p1));u.normalize(),a.push(u),o.push(i)}for(n=0;n<o.length;n++){i=o[n];for(var d=n+1;d<o.length;d++){var h=o[d];if(i.edgesConnectedCount===3)break;if(h.edgesConnectedCount!==3)for(var p=e[3*d],m=e[3*d+1],v=e[3*d+2],b=0;b<3;b++){var E=0;if(i.edges[b]===void 0){switch(b){case 0:E=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(i.p0,i.p1,h.p0,h.p1,h.p2):this._processEdgeForAdjacencies(e[3*n],e[3*n+1],p,m,v);break;case 1:E=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(i.p1,i.p2,h.p0,h.p1,h.p2):this._processEdgeForAdjacencies(e[3*n+1],e[3*n+2],p,m,v);break;case 2:E=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(i.p2,i.p0,h.p0,h.p1,h.p2):this._processEdgeForAdjacencies(e[3*n+2],e[3*n],p,m,v)}if(E!==-1&&(i.edges[b]=d,h.edges[E]=n,i.edgesConnectedCount++,h.edgesConnectedCount++,i.edgesConnectedCount===3))break}}}}for(n=0;n<o.length;n++){var C=o[n];this._checkEdge(n,C.edges[0],a,C.p0,C.p1),this._checkEdge(n,C.edges[1],a,C.p1,C.p2),this._checkEdge(n,C.edges[2],a,C.p2,C.p0)}var T=this._source.getScene().getEngine();this._buffers[Y.R.PositionKind]=new Y.R(T,this._linesPositions,Y.R.PositionKind,!1),this._buffers[Y.R.NormalKind]=new Y.R(T,this._linesNormals,Y.R.NormalKind,!1,!1,4),this._buffersForInstances[Y.R.PositionKind]=this._buffers[Y.R.PositionKind],this._buffersForInstances[Y.R.NormalKind]=this._buffers[Y.R.NormalKind],this._ib=T.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},r.prototype.isReady=function(){return this._lineShader.isReady(this._source,this._source.hasInstances&&this.customInstances.length>0||this._source.hasThinInstances)},r.prototype.render=function(){var t=this._source.getScene(),e=this._lineShader._getDrawWrapper();if(this._drawWrapper&&this._lineShader._setDrawWrapper(this._drawWrapper),this.isReady()&&t.activeCamera){var n=this._source.hasInstances&&this.customInstances.length>0,i=n||this._source.hasThinInstances,o=0;if(i)if(this._buffersForInstances.world0=this._source.getVertexBuffer("world0"),this._buffersForInstances.world1=this._source.getVertexBuffer("world1"),this._buffersForInstances.world2=this._source.getVertexBuffer("world2"),this._buffersForInstances.world3=this._source.getVertexBuffer("world3"),n){var a=this._source._instanceDataStorage;if(o=this.customInstances.length,!a.instancesData)return void(this._source.getScene()._activeMeshesFrozen||this.customInstances.reset());if(!a.isFrozen){for(var s=0,l=0;l<o;++l)this.customInstances.data[l].copyToArray(a.instancesData,s),s+=16;a.instancesBuffer.updateDirectly(a.instancesData,0,o)}}else o=this._source.thinInstanceCount;var c=t.getEngine();this._lineShader._preBind(),this._source.edgesColor.a!==1?c.setAlphaMode(P.Y.ALPHA_COMBINE):c.setAlphaMode(P.Y.ALPHA_DISABLE),c.bindBuffers(i?this._buffersForInstances:this._buffers,this._ib,this._lineShader.getEffect()),t.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),t.activeCamera.mode===Pt.ORTHOGRAPHIC_CAMERA?this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForOrthographic):this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForPerspective),this._lineShader.setFloat("aspectRatio",c.getAspectRatio(t.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix(),this._source),c.drawElementsType(Lt.TriangleFillMode,0,this._indicesCount,o),this._lineShader.unbind(),i&&c.unbindInstanceAttributes(),this._source.getScene()._activeMeshesFrozen||this.customInstances.reset(),this._lineShader._setDrawWrapper(e)}else this._lineShader._setDrawWrapper(e)},r}(),TT=function(r){function t(e,n,i){n===void 0&&(n=.95),i===void 0&&(i=!1);var o=r.call(this,e,n,i,!1)||this;return o._generateEdgesLines(),o}return(0,A.C6)(t,r),t.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(Y.R.PositionKind),n=this._source.getIndices();if(n&&e){for(var i=_.AA.Vector3[0],o=_.AA.Vector3[1],a=n.length-1,s=0,l=0;s<a;s+=2,l+=4)_.Pq.FromArrayToRef(e,3*n[s],i),_.Pq.FromArrayToRef(e,3*n[s+1],o),this.createLine(i,o,l);var c=this._source.getScene().getEngine();this._buffers[Y.R.PositionKind]=new Y.R(c,this._linesPositions,Y.R.PositionKind,!1),this._buffers[Y.R.NormalKind]=new Y.R(c,this._linesNormals,Y.R.NormalKind,!1,!1,4),this._ib=c.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},t}(Yf),DN=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e,i,o,a,s)||this;return l._beforeCompositionPostProcesses=[],l._internalTextureDirty=!1,l.enabled=!1,l.renderTargetTexture=null,l.renderTargetTexture=n,l}return(0,A.C6)(t,r),t.prototype._createCompositionEffect=function(){this.imageProcessingPostProcess=new Gf("prePassComposition",1,null,void 0,this._engine),this.imageProcessingPostProcess._updateParameters()},t.prototype._checkSize=function(){var e=this._engine.getRenderWidth(!0),n=this._engine.getRenderHeight(!0),i=this.getRenderWidth(),o=this.getRenderHeight();i===e&&o===n||(this.resize({width:e,height:n}),this._internalTextureDirty=!0)},t.prototype.updateCount=function(e,n,i){r.prototype.updateCount.call(this,e,n,i),this._internalTextureDirty=!0},t.prototype._resetPostProcessChain=function(){this._beforeCompositionPostProcesses.length=0},t.prototype.dispose=function(){var e=this._scene;if(r.prototype.dispose.call(this),e&&e.prePassRenderer){var n=e.prePassRenderer.renderTargets.indexOf(this);n!==-1&&e.prePassRenderer.renderTargets.splice(n,1)}this.imageProcessingPostProcess&&this.imageProcessingPostProcess.dispose(),this.renderTargetTexture&&(this.renderTargetTexture._prePassRenderTarget=null),this._outputPostProcess&&(this._outputPostProcess.autoClear=!0,this._outputPostProcess.restoreDefaultInputTexture())},t}(Kr),gs=function(){function r(t){this.excludedSkinnedMesh=[],this.excludedMaterials=[],this.mrtCount=0,this._mrtTypes=[],this._mrtFormats=[],this._mrtLayout=[],this._mrtNames=[],this._textureIndices=[],this._generateNormalsInWorldSpace=!1,this._useSpecificClearForDepthTexture=!1,this._isDirty=!0,this._effectConfigurations=[],this.doNotUseGeometryRendererFallback=!0,this.renderTargets=[],this._clearColor=new z.ov(0,0,0,0),this._clearDepthColor=new z.ov(1e8,0,0,1),this._enabled=!1,this._needsCompositionForThisPass=!1,this.disableGammaTransform=!1,this._scene=t,this._engine=t.getEngine();var e=P.Y.TEXTURETYPE_UNSIGNED_BYTE;this._engine._caps.textureFloat&&this._engine._caps.textureFloatLinearFiltering?e=P.Y.TEXTURETYPE_FLOAT:this._engine._caps.textureHalfFloat&&this._engine._caps.textureHalfFloatLinearFiltering&&(e=P.Y.TEXTURETYPE_HALF_FLOAT);for(var n=0;n<r.TextureFormats.length;++n){var i=r.TextureFormats[n].format;r.TextureFormats[n].type===P.Y.TEXTURETYPE_FLOAT&&(r.TextureFormats[n].type=e,e!==P.Y.TEXTURETYPE_FLOAT||i!==P.Y.TEXTUREFORMAT_R&&i!==P.Y.TEXTUREFORMAT_RG&&i!==P.Y.TEXTUREFORMAT_RGBA||this._engine._caps.supportFloatTexturesResolve||(r.TextureFormats[n].type=P.Y.TEXTURETYPE_HALF_FLOAT))}r._SceneComponentInitialization(this._scene),this.defaultRT=this._createRenderTarget("sceneprePassRT",null),this._currentTarget=this.defaultRT}return Object.defineProperty(r.prototype,"generateNormalsInWorldSpace",{get:function(){return this._generateNormalsInWorldSpace},set:function(t){this._generateNormalsInWorldSpace!==t&&(this._generateNormalsInWorldSpace=t,this._markAllMaterialsAsPrePassDirty())},enumerable:!1,configurable:!0}),r.prototype.getIndex=function(t){return this._textureIndices[t]},Object.defineProperty(r.prototype,"samples",{get:function(){return this.defaultRT.samples},set:function(t){this.defaultRT.samples=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useSpecificClearForDepthTexture",{get:function(){return this._useSpecificClearForDepthTexture},set:function(t){this._useSpecificClearForDepthTexture!==t&&(this._useSpecificClearForDepthTexture=t,this._isDirty=!0)},enumerable:!1,configurable:!0}),r.prototype.getRenderTarget=function(){return this._currentTarget},r.prototype._setRenderTarget=function(t){var e,n;t?this._currentTarget=t:(this._currentTarget=this.defaultRT,this._engine.currentRenderPassId=(n=(e=this._scene.activeCamera)===null||e===void 0?void 0:e.renderPassId)!==null&&n!==void 0?n:this._currentTarget.renderPassId)},Object.defineProperty(r.prototype,"currentRTisSceneRT",{get:function(){return this._currentTarget===this.defaultRT},enumerable:!1,configurable:!0}),r.prototype._refreshGeometryBufferRendererLink=function(){if(this.doNotUseGeometryRendererFallback)this._geometryBuffer&&this._geometryBuffer._unlinkPrePassRenderer(),this._geometryBuffer=null,this._scene.disableGeometryBufferRenderer();else{if(this._geometryBuffer=this._scene.enableGeometryBufferRenderer(),!this._geometryBuffer)return void(this.doNotUseGeometryRendererFallback=!0);this._geometryBuffer._linkPrePassRenderer(this)}},Object.defineProperty(r.prototype,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),r.prototype._createRenderTarget=function(t,e){var n=new DN(t,e,{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},0,this._scene,{generateMipMaps:!1,generateStencilBuffer:this._engine.isStencilEnable,defaultType:P.Y.TEXTURETYPE_UNSIGNED_INT,types:[],drawOnlyOnFirstAttachmentByDefault:!0});return this.renderTargets.push(n),this._enabled&&this._update(),n},Object.defineProperty(r.prototype,"isSupported",{get:function(){return this._scene.getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),r.prototype.bindAttachmentsForEffect=function(t,e){var n=e.getMaterial(),i=n&&n.isPrePassCapable,o=n&&this.excludedMaterials.indexOf(n)!==-1;this.enabled&&this._currentTarget.enabled&&(t._multiTarget&&i&&!o?this._engine.bindAttachments(this._multiRenderAttachments):(this._engine._currentRenderTarget?this._engine.bindAttachments(this._defaultAttachments):this._engine.restoreSingleAttachment(),this._geometryBuffer&&this.currentRTisSceneRT&&!o&&this._geometryBuffer.renderList.push(e.getRenderingMesh())))},r.prototype._reinitializeAttachments=function(){for(var t=[],e=[!1],n=[!1],i=[!0],o=0;o<this.mrtCount;o++)t.push(!0),o>0&&(this._useSpecificClearForDepthTexture&&this._mrtLayout[o]===P.Y.PREPASS_DEPTH_TEXTURE_TYPE?(e.push(!1),n.push(!0)):(e.push(!0),n.push(!1)),i.push(!1));this._multiRenderAttachments=this._engine.buildTextureLayout(t),this._clearAttachments=this._engine.buildTextureLayout(e),this._clearDepthAttachments=this._engine.buildTextureLayout(n),this._defaultAttachments=this._engine.buildTextureLayout(i)},r.prototype._resetLayout=function(){for(var t=0;t<r.TextureFormats.length;t++)this._textureIndices[r.TextureFormats[t].purpose]=-1;this._textureIndices[P.Y.PREPASS_COLOR_TEXTURE_TYPE]=0,this._mrtLayout=[P.Y.PREPASS_COLOR_TEXTURE_TYPE],this._mrtTypes=[r.TextureFormats[P.Y.PREPASS_COLOR_TEXTURE_TYPE].type],this._mrtFormats=[r.TextureFormats[P.Y.PREPASS_COLOR_TEXTURE_TYPE].format],this._mrtNames=[r.TextureFormats[P.Y.PREPASS_COLOR_TEXTURE_TYPE].name],this.mrtCount=1},r.prototype._updateGeometryBufferLayout=function(){if(this._refreshGeometryBufferRendererLink(),this._geometryBuffer){this._geometryBuffer._resetLayout();for(var t=[],e=0;e<this._mrtLayout.length;e++)t.push(!1);this._geometryBuffer._linkInternalTexture(this.defaultRT.getInternalTexture());var n=[{prePassConstant:P.Y.PREPASS_DEPTH_TEXTURE_TYPE,geometryBufferConstant:zn.DEPTH_TEXTURE_TYPE},{prePassConstant:P.Y.PREPASS_NORMAL_TEXTURE_TYPE,geometryBufferConstant:zn.NORMAL_TEXTURE_TYPE},{prePassConstant:P.Y.PREPASS_POSITION_TEXTURE_TYPE,geometryBufferConstant:zn.POSITION_TEXTURE_TYPE},{prePassConstant:P.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE,geometryBufferConstant:zn.REFLECTIVITY_TEXTURE_TYPE},{prePassConstant:P.Y.PREPASS_VELOCITY_TEXTURE_TYPE,geometryBufferConstant:zn.VELOCITY_TEXTURE_TYPE}];for(e=0;e<n.length;e++){var i=this._mrtLayout.indexOf(n[e].prePassConstant);i!==-1&&(this._geometryBuffer._forceTextureType(n[e].geometryBufferConstant,i),t[i]=!0)}this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(t))}},r.prototype.restoreAttachments=function(){this.enabled&&this._currentTarget.enabled&&this._defaultAttachments&&(this._engine._currentRenderTarget?this._engine.bindAttachments(this._defaultAttachments):this._engine.restoreSingleAttachment())},r.prototype._beforeDraw=function(t,e,n){this._isDirty&&this._update(),this._enabled&&this._currentTarget.enabled&&(this._geometryBuffer&&(this._geometryBuffer.renderList=[]),this._setupOutputForThisPass(this._currentTarget,t))},r.prototype._prepareFrame=function(t,e,n){t.renderTargetTexture?t.renderTargetTexture._prepareFrame(this._scene,e,n,t.renderTargetTexture.useCameraPostProcesses):this._postProcessesSourceForThisPass.length?this._scene.postProcessManager._prepareFrame():this._engine.restoreDefaultFramebuffer()},r.prototype.setCustomOutput=function(t){var e=this._postProcessesSourceForThisPass[0];return!!e&&(e.inputTexture=t.renderTarget,!0)},r.prototype._renderPostProcesses=function(t,e){var n,i=this._postProcessesSourceForThisPass[0],o=i?i.inputTexture:t.renderTargetTexture?t.renderTargetTexture.renderTarget:null,a=this._currentTarget._beforeCompositionPostProcesses;this._needsCompositionForThisPass&&(a=a.concat([this._currentTarget.imageProcessingPostProcess])),a.length&&(this._scene.postProcessManager._prepareFrame((n=this._currentTarget.renderTarget)===null||n===void 0?void 0:n.texture,a),this._scene.postProcessManager.directRender(a,o,!1,e))},r.prototype._afterDraw=function(t,e){this._enabled&&this._currentTarget.enabled&&(this._prepareFrame(this._currentTarget,t,e),this._renderPostProcesses(this._currentTarget,t))},r.prototype._clear=function(){this._isDirty&&this._update(),this._enabled&&this._currentTarget.enabled&&(this._bindFrameBuffer(),this._engine.bindAttachments(this._clearAttachments),this._engine.clear(this._clearColor,!0,!1,!1),this._useSpecificClearForDepthTexture&&(this._engine.bindAttachments(this._clearDepthAttachments),this._engine.clear(this._clearDepthColor,!0,!1,!1)),this._engine.bindAttachments(this._defaultAttachments))},r.prototype._bindFrameBuffer=function(){if(this._enabled&&this._currentTarget.enabled){this._currentTarget._checkSize();var t=this._currentTarget.renderTarget;t&&this._engine.bindFramebuffer(t)}},r.prototype._setEnabled=function(t){this._enabled=t},r.prototype._setRenderTargetEnabled=function(t,e){t.enabled=e,e||this._unlinkInternalTexture(t)},r.prototype.addEffectConfiguration=function(t){for(var e=0;e<this._effectConfigurations.length;e++)if(this._effectConfigurations[e].name===t.name)return this._effectConfigurations[e];return this._effectConfigurations.push(t),t},r.prototype.getEffectConfiguration=function(t){for(var e=0;e<this._effectConfigurations.length;e++)if(this._effectConfigurations[e].name===t)return this._effectConfigurations[e];return null},r.prototype._enable=function(){for(var t=this.mrtCount,e=0;e<this._effectConfigurations.length;e++)this._effectConfigurations[e].enabled&&this._enableTextures(this._effectConfigurations[e].texturesRequired);for(e=0;e<this.renderTargets.length;e++){this.mrtCount===t&&this.renderTargets[e].count===this.mrtCount||this.renderTargets[e].updateCount(this.mrtCount,{types:this._mrtTypes,formats:this._mrtFormats},this._mrtNames.concat("prePass_DepthBuffer")),this.renderTargets[e]._resetPostProcessChain();for(var n=0;n<this._effectConfigurations.length;n++)this._effectConfigurations[n].enabled&&(!this._effectConfigurations[n].postProcess&&this._effectConfigurations[n].createPostProcess&&this._effectConfigurations[n].createPostProcess(),this._effectConfigurations[n].postProcess&&this.renderTargets[e]._beforeCompositionPostProcesses.push(this._effectConfigurations[n].postProcess))}this._reinitializeAttachments(),this._setEnabled(!0),this._updateGeometryBufferLayout()},r.prototype._disable=function(){this._setEnabled(!1);for(var t=0;t<this.renderTargets.length;t++)this._setRenderTargetEnabled(this.renderTargets[t],!1);for(this._resetLayout(),t=0;t<this._effectConfigurations.length;t++)this._effectConfigurations[t].enabled=!1},r.prototype._getPostProcessesSource=function(t,e){if(e)return e._postProcesses;if(t.renderTargetTexture){if(t.renderTargetTexture.useCameraPostProcesses){var n=t.renderTargetTexture.activeCamera?t.renderTargetTexture.activeCamera:this._scene.activeCamera;return n?n._postProcesses:[]}return t.renderTargetTexture.postProcesses?t.renderTargetTexture.postProcesses:[]}return this._scene.activeCamera?this._scene.activeCamera._postProcesses:[]},r.prototype._setupOutputForThisPass=function(t,e){var n=e&&this._scene.activeCameras&&!!this._scene.activeCameras.length&&this._scene.activeCameras.indexOf(e)!==0;this._postProcessesSourceForThisPass=this._getPostProcessesSource(t,e),this._postProcessesSourceForThisPass=this._postProcessesSourceForThisPass.filter(function(l){return l!=null}),this._scene.autoClear=!0;var i=this._hasImageProcessing(this._postProcessesSourceForThisPass);this._needsCompositionForThisPass=!i&&!this.disableGammaTransform&&this._needsImageProcessing()&&!n;var o=this._getFirstPostProcess(this._postProcessesSourceForThisPass),a=t._beforeCompositionPostProcesses&&t._beforeCompositionPostProcesses[0],s=null;this._scene.imageProcessingConfiguration.applyByPostProcess=this._needsCompositionForThisPass||i,this._needsCompositionForThisPass&&!t.imageProcessingPostProcess&&t._createCompositionEffect(),a?s=a:this._needsCompositionForThisPass?s=t.imageProcessingPostProcess:o&&(s=o),this._bindFrameBuffer(),this._linkInternalTexture(t,s)},r.prototype._linkInternalTexture=function(t,e){e&&(e.autoClear=!1,e.inputTexture=t.renderTarget),t._outputPostProcess!==e&&(t._outputPostProcess&&this._unlinkInternalTexture(t),t._outputPostProcess=e),t._internalTextureDirty&&(this._updateGeometryBufferLayout(),t._internalTextureDirty=!1)},r.prototype._unlinkInternalTexture=function(t){t._outputPostProcess&&(t._outputPostProcess.autoClear=!0,t._outputPostProcess.restoreDefaultInputTexture(),t._outputPostProcess=null)},r.prototype._needsImageProcessing=function(){for(var t=0;t<this._effectConfigurations.length;t++)if(this._effectConfigurations[t].enabled&&this._effectConfigurations[t].needsImageProcessing)return!0;return!1},r.prototype._hasImageProcessing=function(t){var e,n=!1;if(t){for(var i=0;i<t.length;i++)if(((e=t[i])===null||e===void 0?void 0:e.getClassName())==="ImageProcessingPostProcess"){n=!0;break}}return n},r.prototype._getFirstPostProcess=function(t){for(var e=0;e<t.length;e++)if(t[e]!==null)return t[e];return null},r.prototype.markAsDirty=function(){this._isDirty=!0},r.prototype._enableTextures=function(t){this._scene.needsPreviousWorldMatrices=!1;for(var e=0;e<t.length;e++){var n=t[e];this._textureIndices[n]===-1&&(this._textureIndices[n]=this._mrtLayout.length,this._mrtLayout.push(n),this._mrtTypes.push(r.TextureFormats[n].type),this._mrtFormats.push(r.TextureFormats[n].format),this._mrtNames.push(r.TextureFormats[n].name),this.mrtCount++),n!==P.Y.PREPASS_VELOCITY_TEXTURE_TYPE&&n!==P.Y.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE||(this._scene.needsPreviousWorldMatrices=!0)}},r.prototype.update=function(){this._isDirty&&this._update()},r.prototype._update=function(){this._disable();var t,e=!1;this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this._scene._depthPeelingRenderer&&this._scene.useOrderIndependentTransparency&&(this._scene._depthPeelingRenderer.setPrePassRenderer(this),e=!0);for(var n=0;n<this._scene.materials.length;n++)this._scene.materials[n].setPrePassRenderer(this)&&(e=!0);for(e&&this._setRenderTargetEnabled(this.defaultRT,!0),n=0;n<this.renderTargets.length;n++){if(this.renderTargets[n].renderTargetTexture)t=this._getPostProcessesSource(this.renderTargets[n]);else{var i=this._scene.activeCamera;if(!i)continue;t=i._postProcesses}if(t&&(t=t.filter(function(a){return a!=null}))){for(var o=0;o<t.length;o++)t[o].setPrePassRenderer(this)&&(this._setRenderTargetEnabled(this.renderTargets[n],!0),e=!0);this._hasImageProcessing(t)&&(this._scene.imageProcessingConfiguration.applyByPostProcess=!0)}}this._markAllMaterialsAsPrePassDirty(),this._isDirty=!1,e&&this._enable()},r.prototype._markAllMaterialsAsPrePassDirty=function(){for(var t=this._scene.materials,e=0;e<t.length;e++)t[e].markAsDirty(Lt.PrePassDirtyFlag)},r.prototype.dispose=function(){for(var t=this.renderTargets.length-1;t>=0;t--)this.renderTargets[t].dispose();for(t=0;t<this._effectConfigurations.length;t++)this._effectConfigurations[t].dispose&&this._effectConfigurations[t].dispose()},r._SceneComponentInitialization=function(t){throw(0,gt.n)("PrePassRendererSceneComponent")},r.TextureFormats=[{purpose:P.Y.PREPASS_IRRADIANCE_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_HALF_FLOAT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_Irradiance"},{purpose:P.Y.PREPASS_POSITION_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_HALF_FLOAT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_Position"},{purpose:P.Y.PREPASS_VELOCITY_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_UNSIGNED_INT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_Velocity"},{purpose:P.Y.PREPASS_REFLECTIVITY_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_UNSIGNED_INT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_Reflectivity"},{purpose:P.Y.PREPASS_COLOR_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_HALF_FLOAT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_Color"},{purpose:P.Y.PREPASS_DEPTH_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_FLOAT,format:P.Y.TEXTUREFORMAT_R,name:"prePass_Depth"},{purpose:P.Y.PREPASS_NORMAL_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_HALF_FLOAT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_Normal"},{purpose:P.Y.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_UNSIGNED_INT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_Albedo"},{purpose:P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_UNSIGNED_INT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_WorldNormal"},{purpose:P.Y.PREPASS_LOCAL_POSITION_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_HALF_FLOAT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_LocalPosition"},{purpose:P.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_FLOAT,format:P.Y.TEXTUREFORMAT_R,name:"prePass_ScreenDepth"},{purpose:P.Y.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE,type:P.Y.TEXTURETYPE_HALF_FLOAT,format:P.Y.TEXTUREFORMAT_RGBA,name:"prePass_VelocityLinear"}],r}(),NN=function(){function r(t,e,n,i){n===void 0&&(n=6),i===void 0&&(i=!0);var o=this;this._voxelMrtsXaxis=[],this._voxelMrtsYaxis=[],this._voxelMrtsZaxis=[],this._isVoxelGrid3D=!0,this._renderInFlight=!1,this._renderTargets=[],this._triPlanarVoxelization=!0,this._voxelizationInProgress=!1,this._voxelResolution=64,this._voxelResolutionExp=6,this._mipArray=[],this._voxelDebugEnabled=!1,this._voxelDebugAxis=-1,this._debugSizeParams=new _.IU(0,0,0,0),this._debugMipNumber=0,this._debugPassName="Voxelization Debug Pass",this._scene=t,this._engine=t.getEngine(),this._triPlanarVoxelization=i,this._renderPipeline=e,this._engine.getCaps().drawBuffersExtension||O.V.Error("Can't do voxel rendering without the draw buffers extension.");var a=this._engine.isWebGPU;this._maxDrawBuffers=this._engine.getCaps().maxDrawBuffers||0,this._copyMipEffectRenderer=new Ni.J(this._engine),this._copyMipEffectWrapper=new Ni.$({engine:this._engine,fragmentShader:"copyTexture3DLayerToTexture",useShaderStore:!0,uniformNames:["layerNum"],samplerNames:["textureSampler"],shaderLanguage:a?1:0,extraInitializationsAsync:function(){return(0,A.sH)(o,void 0,void 0,function(){return(0,A.YH)(this,function(s){switch(s.label){case 0:return a?[4,Promise.resolve().then(L.bind(L,79147))]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,37592))];case 3:s.sent(),s.label=4;case 4:return[2]}})})}}),this.voxelResolutionExp=n}return r.prototype.getVoxelGrid=function(){return this._triPlanarVoxelization?this._voxelGridRT:this._voxelGridZaxis},r.prototype.getDebugPassPP=function(){return this._voxelDebugPass||this._createDebugPass(),this._voxelDebugPass},Object.defineProperty(r.prototype,"triPlanarVoxelization",{get:function(){return this._triPlanarVoxelization},set:function(t){this._triPlanarVoxelization!==t&&(this._triPlanarVoxelization=t,this._disposeVoxelTextures(),this._createTextures(),this._renderPipeline.updateVoxelization())},enumerable:!1,configurable:!0}),r.prototype.setWorldScaleMatrix=function(t){this._invWorldScaleMatrix=t},r.prototype.isVoxelizationInProgress=function(){return this._voxelizationInProgress},Object.defineProperty(r.prototype,"voxelResolutionExp",{get:function(){return this._voxelResolutionExp},set:function(t){this._voxelResolutionExp===t&&this._voxelGridZaxis||(this._voxelResolutionExp=Math.round(Math.min(Math.max(t,3),9)),this._voxelResolution=Math.pow(2,this._voxelResolutionExp),this._disposeVoxelTextures(),this._createTextures())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"voxelDebugAxis",{get:function(){return this._voxelDebugAxis},set:function(t){this._voxelDebugAxis=t},enumerable:!1,configurable:!0}),r.prototype.setDebugDisplayParams=function(t,e,n,i){this._debugSizeParams.set(t,e,n,i)},r.prototype.setDebugMipNumber=function(t){this._debugMipNumber=t},Object.defineProperty(r.prototype,"debugPassName",{get:function(){return this._debugPassName},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"voxelDebugEnabled",{get:function(){return this._voxelDebugEnabled},set:function(t){this._voxelDebugEnabled!==t&&(this._voxelDebugEnabled=t,t?(this._voxelSlabDebugRT=new un.$("voxelSlabDebug",{ratio:1},this._scene,{generateDepthBuffer:!0,generateMipMaps:!1,type:P.Y.TEXTURETYPE_UNSIGNED_BYTE,format:P.Y.TEXTUREFORMAT_R,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE}),this._voxelSlabDebugRT.noPrePassRenderer=!0):this._voxelSlabDebugRT&&this._removeVoxelRTs([this._voxelSlabDebugRT]))},enumerable:!1,configurable:!0}),r.prototype._createDebugPass=function(){var t=this,e=this._engine.isWebGPU;if(!this._voxelDebugPass){var n={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_R,textureType:P.Y.TEXTURETYPE_UNSIGNED_BYTE,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,uniforms:["sizeParams","mipNumber"],samplers:["voxelTexture","voxelSlabTexture"],engine:this._engine,reusable:!1,shaderLanguage:e?1:0,extraInitializations:function(i,o){t._isVoxelGrid3D?i?o.push(Promise.resolve().then(L.bind(L,42362))):o.push(Promise.resolve().then(L.bind(L,48533))):i?o.push(Promise.resolve().then(L.bind(L,39768))):o.push(Promise.resolve().then(L.bind(L,76933)))}};this._voxelDebugPass=new _t.w(this.debugPassName,this._isVoxelGrid3D?"iblVoxelGrid3dDebug":"iblVoxelGrid2dArrayDebug",n),this._voxelDebugPass.onApplyObservable.add(function(i){t._voxelDebugAxis===0?i.setTexture("voxelTexture",t._voxelGridXaxis):t._voxelDebugAxis===1?i.setTexture("voxelTexture",t._voxelGridYaxis):t._voxelDebugAxis===2?i.setTexture("voxelTexture",t._voxelGridZaxis):i.setTexture("voxelTexture",t.getVoxelGrid()),i.setTexture("voxelSlabTexture",t._voxelSlabDebugRT),i.setVector4("sizeParams",t._debugSizeParams),i.setFloat("mipNumber",t._debugMipNumber)})}},r.prototype._generateMipMaps=function(){for(var t=Math.ceil(Math.log2(this._voxelResolution)),e=1;e<t+1;e++)this._generateMipMap(e)},r.prototype._generateMipMap=function(t){var e=this._mipArray[t-1];e&&(e.setTexture("srcMip",t===1?this.getVoxelGrid():this._mipArray[t-2]),e.render())},r.prototype._copyMipMaps=function(){for(var t=Math.ceil(Math.log2(this._voxelResolution)),e=1;e<t+1;e++)this._copyMipMap(e)},r.prototype._copyMipMap=function(t){var e=this._mipArray[t-1];if(e){var n,i=this.getVoxelGrid();if(n=i instanceof un.$&&i.renderTarget?i.renderTarget:i._rtWrapper){this._copyMipEffectRenderer.saveStates();for(var o=e.getSize().width,a=0;a<o;a++)this._engine.bindFramebuffer(n,0,o,o,!0,t,a),this._copyMipEffectRenderer.applyEffectWrapper(this._copyMipEffectWrapper),this._copyMipEffectWrapper.effect.setTexture("textureSampler",e),this._copyMipEffectWrapper.effect.setInt("layerNum",a),this._copyMipEffectRenderer.draw(),this._engine.unBindFramebuffer(n,!0);this._copyMipEffectRenderer.restoreStates()}}},r.prototype._computeNumberOfSlabs=function(){return Math.ceil(this._voxelResolution/this._maxDrawBuffers)},r.prototype._createTextures=function(){var t=this,e=this._engine.isWebGPU,n={width:this._voxelResolution,height:this._voxelResolution,layers:this._isVoxelGrid3D?void 0:this._voxelResolution,depth:this._isVoxelGrid3D?this._voxelResolution:void 0},i={generateDepthBuffer:!1,generateMipMaps:!1,type:P.Y.TEXTURETYPE_UNSIGNED_BYTE,format:P.Y.TEXTUREFORMAT_R,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE},o=this._computeNumberOfSlabs(),a={generateDepthBuffer:!1,generateMipMaps:!0,type:P.Y.TEXTURETYPE_UNSIGNED_BYTE,format:P.Y.TEXTUREFORMAT_R,samplingMode:P.Y.TEXTURE_NEAREST_NEAREST_MIPNEAREST,shaderLanguage:e?1:0,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(h){switch(h.label){case 0:return e?[4,Promise.resolve().then(L.bind(L,8866))]:[3,2];case 1:return h.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,82911))];case 3:h.sent(),h.label=4;case 4:return[2]}})})}};this._triPlanarVoxelization?(this._voxelGridXaxis=new un.$("voxelGridXaxis",n,this._scene,i),this._voxelGridYaxis=new un.$("voxelGridYaxis",n,this._scene,i),this._voxelGridZaxis=new un.$("voxelGridZaxis",n,this._scene,i),this._voxelMrtsXaxis=this._createVoxelMRTs("x_axis_",this._voxelGridXaxis,o),this._voxelMrtsYaxis=this._createVoxelMRTs("y_axis_",this._voxelGridYaxis,o),this._voxelMrtsZaxis=this._createVoxelMRTs("z_axis_",this._voxelGridZaxis,o),this._voxelGridRT=new xr("combinedVoxelGrid",n,"iblCombineVoxelGrids",this._scene,a,!1),this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._voxelGridRT),1),this._voxelGridRT.setFloat("layer",0),this._voxelGridRT.setTexture("voxelXaxisSampler",this._voxelGridXaxis),this._voxelGridRT.setTexture("voxelYaxisSampler",this._voxelGridYaxis),this._voxelGridRT.setTexture("voxelZaxisSampler",this._voxelGridZaxis),this._voxelGridRT.autoClear=!1,this._voxelGridRT.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._voxelGridRT.wrapV=Ie.g.CLAMP_ADDRESSMODE):(this._voxelGridZaxis=new un.$("voxelGridZaxis",n,this._scene,a),this._voxelMrtsZaxis=this._createVoxelMRTs("z_axis_",this._voxelGridZaxis,o));var s={generateDepthBuffer:!1,generateMipMaps:!1,type:P.Y.TEXTURETYPE_UNSIGNED_BYTE,format:P.Y.TEXTUREFORMAT_R,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,shaderLanguage:e?1:0,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(h){switch(h.label){case 0:return e?[4,Promise.resolve().then(L.bind(L,52651))]:[3,2];case 1:return h.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,92228))];case 3:h.sent(),h.label=4;case 4:return[2]}})})}};this._mipArray=new Array(Math.ceil(Math.log2(this._voxelResolution)));for(var l=1;l<=this._mipArray.length;l++){var c=this._voxelResolution>>l,u={width:c,height:c,depth:c};this._mipArray[l-1]=new xr("voxelMip"+l,u,"iblGenerateVoxelMip",this._scene,s,!1),this._scene.proceduralTextures.splice(this._scene.proceduralTextures.indexOf(this._mipArray[l-1]),1);var d=this._mipArray[l-1];d.autoClear=!1,d.wrapU=Ie.g.CLAMP_ADDRESSMODE,d.wrapV=Ie.g.CLAMP_ADDRESSMODE,d.setTexture("srcMip",l>1?this._mipArray[l-2]:this.getVoxelGrid()),d.setInt("layerNum",0)}},r.prototype._createVoxelMRTs=function(t,e,n){var i=this;e.wrapU=Ie.g.CLAMP_ADDRESSMODE,e.wrapV=Ie.g.CLAMP_ADDRESSMODE,e.noPrePassRenderer=!0;for(var o=[],a=new Array(this._maxDrawBuffers).fill(this._isVoxelGrid3D?P.Y.TEXTURE_3D:P.Y.TEXTURE_2D_ARRAY),s=function(u){var d=new Array(l._maxDrawBuffers).fill(0);d=d.map(function(v,b){return u*i._maxDrawBuffers+b});var h=new Array(l._maxDrawBuffers).fill("");h=h.map(function(v,b){return"voxel_grid_"+t+(u*i._maxDrawBuffers+b)});var p=new Kr("mrt_"+t+u,{width:l._voxelResolution,height:l._voxelResolution,depth:l._isVoxelGrid3D?l._voxelResolution:void 0},l._maxDrawBuffers,l._scene,{types:new Array(l._maxDrawBuffers).fill(P.Y.TEXTURETYPE_UNSIGNED_BYTE),samplingModes:new Array(l._maxDrawBuffers).fill(P.Y.TEXTURE_TRILINEAR_SAMPLINGMODE),generateMipMaps:!1,targetTypes:a,formats:new Array(l._maxDrawBuffers).fill(P.Y.TEXTUREFORMAT_R),faceIndex:new Array(l._maxDrawBuffers).fill(0),layerIndex:d,layerCounts:new Array(l._maxDrawBuffers).fill(l._voxelResolution),generateDepthBuffer:!1,generateStencilBuffer:!1},h);p.clearColor=new z.ov(0,0,0,1),p.noPrePassRenderer=!0;for(var m=0;m<l._maxDrawBuffers;m++)p.setInternalTexture(e.getInternalTexture(),m);o.push(p)},l=this,c=0;c<n;c++)s(c);return o},r.prototype._disposeVoxelTextures=function(){var t,e,n,i;this._stopVoxelization();for(var o=0;o<this._voxelMrtsZaxis.length;o++)this._triPlanarVoxelization&&(this._voxelMrtsXaxis[o].dispose(!0),this._voxelMrtsYaxis[o].dispose(!0)),this._voxelMrtsZaxis[o].dispose(!0);this._triPlanarVoxelization&&((t=this._voxelGridXaxis)===null||t===void 0||t.dispose(),(e=this._voxelGridYaxis)===null||e===void 0||e.dispose(),(n=this._voxelGridRT)===null||n===void 0||n.dispose()),(i=this._voxelGridZaxis)===null||i===void 0||i.dispose(),this._mipArray.forEach(function(a){a.dispose()}),this._mipArray=[],this._voxelMrtsXaxis=[],this._voxelMrtsYaxis=[],this._voxelMrtsZaxis=[]},r.prototype._createVoxelMaterial=function(){var t=this,e=this._engine.isWebGPU,n=new pi("voxelization",this._scene,"iblVoxelGrid",{uniforms:["world","viewMatrix","invWorldScale","nearPlane","farPlane","stepSize"],defines:["MAX_DRAW_BUFFERS "+this._maxDrawBuffers],shaderLanguage:e?1:0,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(i){switch(i.label){case 0:return e?[4,Promise.all([Promise.resolve().then(L.bind(L,30738)),Promise.resolve().then(L.bind(L,90564))])]:[3,2];case 1:return i.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,81487)),Promise.resolve().then(L.bind(L,90453))])];case 3:i.sent(),i.label=4;case 4:return[2]}})})}});return n.cullBackFaces=!1,n.backFaceCulling=!1,n.depthFunction=Zt.ALWAYS,n},r.prototype.isReady=function(){for(var t=this.getVoxelGrid().isReady(),e=0;e<this._mipArray.length;e++){var n=this._mipArray[e].isReady();t&&(t=n)}return!(!t||this._voxelizationInProgress)},r.prototype._stopVoxelization=function(){this._removeVoxelRTs(this._voxelMrtsXaxis),this._removeVoxelRTs(this._voxelMrtsYaxis),this._removeVoxelRTs(this._voxelMrtsZaxis)},r.prototype._removeVoxelRTs=function(t){var e=this._renderTargets.findIndex(function(i){return i===t[0]});if(e>=0)this._renderTargets.splice(e,t.length);else{var n=this._scene.customRenderTargets.findIndex(function(i){return i===t[0]});n>=0&&this._scene.customRenderTargets.splice(n,t.length)}},r.prototype.updateVoxelGrid=function(t){this._stopVoxelization(),this._voxelizationInProgress=!0,this._triPlanarVoxelization?(this._addRTsForRender(this._voxelMrtsXaxis,t,0),this._addRTsForRender(this._voxelMrtsYaxis,t,1),this._addRTsForRender(this._voxelMrtsZaxis,t,2)):this._addRTsForRender(this._voxelMrtsZaxis,t,2),this._voxelDebugEnabled&&(this._removeVoxelRTs([this._voxelSlabDebugRT]),this._addRTsForRender([this._voxelSlabDebugRT],[],this._voxelDebugAxis,1,!0)),this.boundVoxelGridRenderFn=this._renderVoxelGrid.bind(this),this._scene.onAfterRenderTargetsRenderObservable.add(this.boundVoxelGridRenderFn)},r.prototype._renderVoxelGrid=function(){var t=this;if(this._voxelizationInProgress){for(var e=this.getVoxelGrid().isReady(),n=0;n<this._mipArray.length;n++){var i=this._mipArray[n].isReady();e&&(e=i)}for(n=0;n<this._renderTargets.length;n++){var o=this._renderTargets[n].isReadyForRendering();e&&(e=o)}e?(this._renderInFlight=!1,this._scene.prePassRenderer._setEnabled(!1),this._renderTargets.forEach(function(a){a.render()}),this._stopVoxelization(),this._triPlanarVoxelization&&this._voxelGridRT.render(),this._generateMipMaps(),this._copyMipMaps(),this._voxelizationInProgress=!1,this._scene.onAfterRenderTargetsRenderObservable.removeCallback(this.boundVoxelGridRenderFn),this._scene.prePassRenderer._setEnabled(!0)):this._renderInFlight||(this._renderInFlight=!0,setTimeout(function(){t._renderVoxelGrid()},16))}},r.prototype._addRTsForRender=function(t,e,n,i,o){var a=this;i===void 0&&(i=0),o===void 0&&(o=!1);var s=1/this._computeNumberOfSlabs(),l=this._scene.meshes;t.forEach(function(c,u){c.renderList=[];var d,h=u*s,p=(u+1)*s,m=s/a._maxDrawBuffers;if(i===0)d=a._createVoxelMaterial();else{var v=a._engine.isWebGPU;d=new pi("voxelSlabDebug",a._scene,"iblVoxelSlabDebug",{uniforms:["world","viewMatrix","cameraViewMatrix","projection","invWorldScale","nearPlane","farPlane","stepSize"],defines:["MAX_DRAW_BUFFERS "+a._maxDrawBuffers],shaderLanguage:v?1:0,extraInitializationsAsync:function(){return(0,A.sH)(a,void 0,void 0,function(){return(0,A.YH)(this,function(T){switch(T.label){case 0:return v?[4,Promise.all([Promise.resolve().then(L.bind(L,56809)),Promise.resolve().then(L.bind(L,64015))])]:[3,2];case 1:return T.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,77142)),Promise.resolve().then(L.bind(L,99032))])];case 3:T.sent(),T.label=4;case 4:return[2]}})})}}),a._scene.onBeforeRenderObservable.add(function(){d.setMatrix("projection",a._scene.activeCamera.getProjectionMatrix()),d.setMatrix("cameraViewMatrix",a._scene.activeCamera.getViewMatrix())})}var b=new _.Pq(0,0,0),E=new _.Pq(0,0,1);n===0?E=new _.Pq(1,0,0):n===1&&(E=new _.Pq(0,1,0));var C=new _.Pq(0,1,0);n===1&&(C=new _.Pq(1,0,0)),d.setMatrix("viewMatrix",_.uq.LookAtLH(b,E,C)),d.setMatrix("invWorldScale",a._invWorldScaleMatrix),d.setFloat("nearPlane",h),d.setFloat("farPlane",p),d.setFloat("stepSize",m),l.forEach(function(T){var f;T instanceof xe&&T.material&&e.indexOf(T.uniqueId)===-1&&((f=c.renderList)===null||f===void 0||f.push(T),c.setMaterialForRendering(T,d))})}),o?this._scene.customRenderTargets=this._scene.customRenderTargets.concat(t):this._renderTargets=this._renderTargets.concat(t)},r.prototype.resize=function(){var t;(t=this._voxelSlabDebugRT)===null||t===void 0||t.resize({width:this._scene.getEngine().getRenderWidth(),height:this._scene.getEngine().getRenderHeight()})},r.prototype.dispose=function(){this._disposeVoxelTextures(),this._voxelSlabDebugRT&&(this._removeVoxelRTs([this._voxelSlabDebugRT]),this._voxelSlabDebugRT.dispose()),this._voxelDebugPass&&this._voxelDebugPass.dispose()},r}(),LN=function(){function r(t,e){this._voxelShadowOpacity=1,this._sssSamples=16,this._sssStride=8,this._sssMaxDist=.05,this._sssThickness=.5,this._ssShadowOpacity=1,this._cameraInvView=_.uq.Identity(),this._cameraInvProj=_.uq.Identity(),this._invWorldScaleMatrix=_.uq.Identity(),this._frameId=0,this._sampleDirections=4,this.debugEnabled=!1,this._debugPassName="Voxel Tracing Debug Pass",this._envRotation=0,this._downscale=1,this._debugVoxelMarchEnabled=!1,this._debugSizeParams=new _.IU(0,0,0,0),this._scene=t,this._engine=t.getEngine(),this._renderPipeline=e,this._createTextures()}return Object.defineProperty(r.prototype,"voxelShadowOpacity",{get:function(){return this._voxelShadowOpacity},set:function(t){this._voxelShadowOpacity=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ssShadowOpacity",{get:function(){return this._ssShadowOpacity},set:function(t){this._ssShadowOpacity=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sssSamples",{get:function(){return this._sssSamples},set:function(t){this._sssSamples=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sssStride",{get:function(){return this._sssStride},set:function(t){this._sssStride=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sssMaxDist",{get:function(){return this._sssMaxDist},set:function(t){this._sssMaxDist=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sssThickness",{get:function(){return this._sssThickness},set:function(t){this._sssThickness=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sampleDirections",{get:function(){return this._sampleDirections},set:function(t){this._sampleDirections=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"envRotation",{get:function(){return this._envRotation},set:function(t){this._envRotation=t},enumerable:!1,configurable:!0}),r.prototype.getPassPP=function(){return this._outputPP},r.prototype.getDebugPassPP=function(){return this._debugPassPP||this._createDebugPass(),this._debugPassPP},Object.defineProperty(r.prototype,"debugPassName",{get:function(){return this._debugPassName},enumerable:!1,configurable:!0}),r.prototype.setWorldScaleMatrix=function(t){this._invWorldScaleMatrix=t},r.prototype.setDebugDisplayParams=function(t,e,n,i){this._debugSizeParams.set(t,e,n,i)},r.prototype._createDebugPass=function(){var t=this,e=this._engine.isWebGPU;if(!this._debugPassPP){var n={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),uniforms:["sizeParams"],samplers:["debugSampler"],engine:this._engine,reusable:!1,shaderLanguage:e?1:0,extraInitializations:function(i,o){i?o.push(Promise.resolve().then(L.bind(L,35139))):o.push(Promise.resolve().then(L.bind(L,45310)))}};this._debugPassPP=new _t.w(this.debugPassName,"iblShadowDebug",n),this._debugPassPP.autoClear=!1,this._debugPassPP.onApplyObservable.add(function(i){i.setTextureFromPostProcessOutput("debugSampler",t._outputPP),i.setVector4("sizeParams",t._debugSizeParams)})}},r.prototype._createTextures=function(){var t=this,e="";this._debugVoxelMarchEnabled&&(e+=`#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u
|
||
`);var n=this._engine.isWebGPU,i={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_RG,textureType:P.Y.TEXTURETYPE_UNSIGNED_BYTE,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,uniforms:["viewMtx","projMtx","invProjMtx","invViewMtx","wsNormalizationMtx","shadowParameters","offsetDataParameters","sssParameters","shadowOpacity"],samplers:["voxelGridSampler","icdfySampler","icdfxSampler","blueNoiseSampler","worldNormalSampler","depthSampler","worldPositionSampler"],defines:e,engine:this._engine,reusable:!1,shaderLanguage:n?1:0,extraInitializations:function(o,a){o?a.push(Promise.resolve().then(L.bind(L,75626))):a.push(Promise.resolve().then(L.bind(L,53365)))}};this._outputPP=new _t.w("voxelTracingPass","iblShadowVoxelTracing",i),this._outputPP.autoClear=!1,this._outputPP.onApplyObservable.add(function(o){t._updatePostProcess(o,t._scene.activeCamera)})},r.prototype._updatePostProcess=function(t,e){t.setMatrix("viewMtx",e.getViewMatrix()),t.setMatrix("projMtx",e.getProjectionMatrix()),e.getProjectionMatrix().invertToRef(this._cameraInvProj),e.getViewMatrix().invertToRef(this._cameraInvView),t.setMatrix("invProjMtx",this._cameraInvProj),t.setMatrix("invViewMtx",this._cameraInvView),t.setMatrix("wsNormalizationMtx",this._invWorldScaleMatrix),this._frameId++;var n=this._downscale*this._downscale,i=this._scene.useRightHandedSystem?-this._envRotation-.5*Math.PI:-this._envRotation-Math.PI;i%=2*Math.PI,t.setVector4("shadowParameters",new _.IU(this._sampleDirections,this._frameId/n,this._downscale,i));var o=new _.I9(0,0),a=this._renderPipeline.getVoxelGridTexture(),s=Math.floor(Math.log2(a.getSize().width));t.setVector4("offsetDataParameters",new _.IU(o.x,o.y,s,0)),t.setVector4("sssParameters",new _.IU(this._sssSamples,this._sssStride,this._sssMaxDist,this._sssThickness)),t.setVector4("shadowOpacity",new _.IU(this._voxelShadowOpacity,this._ssShadowOpacity,0,0)),t.setTexture("voxelGridSampler",a),t.setTexture("blueNoiseSampler",this._renderPipeline._noiseTexture),t.setTexture("icdfySampler",this._renderPipeline.getIcdfyTexture()),t.setTexture("icdfxSampler",this._renderPipeline.getIcdfxTexture()),this._debugVoxelMarchEnabled&&(t.defines=`#define VOXEL_MARCH_DIAGNOSTIC_INFO_OPTION 1u
|
||
`);var l=this._scene.prePassRenderer;if(l){var c=l.getIndex(P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE),u=l.getIndex(P.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE),d=l.getIndex(P.Y.PREPASS_POSITION_TEXTURE_TYPE);c>=0&&t.setTexture("worldNormalSampler",l.getRenderTarget().textures[c]),u>=0&&t.setTexture("depthSampler",l.getRenderTarget().textures[u]),d>=0&&t.setTexture("worldPositionSampler",l.getRenderTarget().textures[d])}},r.prototype.isReady=function(){return this._outputPP.isReady()&&!(this._debugPassPP&&!this._debugPassPP.isReady())&&this._renderPipeline.getIcdfyTexture().isReady()&&this._renderPipeline.getIcdfxTexture().isReady()&&this._renderPipeline.getVoxelGridTexture().isReady()},r.prototype.dispose=function(){this._outputPP.dispose(),this._debugPassPP&&this._debugPassPP.dispose()},r}(),FN=function(){function r(t){this.debugEnabled=!1,this._debugSizeParams=new _.IU(0,0,0,0),this._debugPassName="Importance Sample Debug",this.onReadyObservable=new K.cP,this._scene=t,this._engine=t.getEngine()}return Object.defineProperty(r.prototype,"iblSource",{get:function(){return this._iblSource},set:function(t){this._iblSource!==t&&(this._disposeTextures(),this._iblSource=t,t.isCube,t.isReadyOrNotBlocking()?this._recreateAssetsFromNewIbl(t):t.onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this,t)))},enumerable:!1,configurable:!0}),r.prototype._recreateAssetsFromNewIbl=function(t){var e=this;this._debugPass&&this._debugPass.dispose(),this._createTextures(),this._debugPass&&this._createDebugPass(),this._icdfxPT.onGeneratedObservable.addOnce(function(){e.onReadyObservable.notifyObservers()})},r.prototype.getIcdfyTexture=function(){return this._icdfyPT},r.prototype.getIcdfxTexture=function(){return this._icdfxPT},r.prototype.setDebugDisplayParams=function(t,e,n,i){this._debugSizeParams.set(t,e,n,i)},Object.defineProperty(r.prototype,"debugPassName",{get:function(){return this._debugPassName},enumerable:!1,configurable:!0}),r.prototype.getDebugPassPP=function(){return this._debugPass||this._createDebugPass(),this._debugPass},r.prototype._createTextures=function(){var t=this,e=this._iblSource?this._iblSource.getSize():{width:1,height:1};this._iblSource||(this._iblSource=Ln.CreateRTexture(new Uint8Array([255]),1,1,this._scene,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_UNSIGNED_BYTE),this._iblSource.name="Placeholder IBL Source"),this._iblSource.isCube&&(e.width*=4,e.height*=2);var n=this._engine.isWebGPU,i={generateDepthBuffer:!1,generateMipMaps:!1,format:P.Y.TEXTUREFORMAT_R,type:P.Y.TEXTURETYPE_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,shaderLanguage:n?1:0,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(a){switch(a.label){case 0:return n?[4,Promise.all([Promise.resolve().then(L.bind(L,24726)),Promise.resolve().then(L.bind(L,23387))])]:[3,2];case 1:return a.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,12191)),Promise.resolve().then(L.bind(L,31898))])];case 3:a.sent(),a.label=4;case 4:return[2]}})})}},o={generateDepthBuffer:!1,generateMipMaps:!1,format:P.Y.TEXTUREFORMAT_R,type:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,shaderLanguage:n?1:0,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(a){switch(a.label){case 0:return n?[4,Promise.all([Promise.resolve().then(L.bind(L,84659)),Promise.resolve().then(L.bind(L,37326))])]:[3,2];case 1:return a.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,41888)),Promise.resolve().then(L.bind(L,99381))])];case 3:a.sent(),a.label=4;case 4:return[2]}})})}};this._cdfyPT=new xr("cdfyTexture",{width:e.width,height:e.height+1},"iblShadowsCdfy",this._scene,i,!1,!1),this._cdfyPT.autoClear=!1,this._cdfyPT.setTexture("iblSource",this._iblSource),this._cdfyPT.setInt("iblHeight",e.height),this._iblSource.isCube&&(this._cdfyPT.defines=`#define IBL_USE_CUBE_MAP
|
||
`),this._cdfyPT.refreshRate=0,this._icdfyPT=new xr("icdfyTexture",{width:e.width,height:e.height},"iblShadowsIcdfy",this._scene,o,!1,!1),this._icdfyPT.autoClear=!1,this._icdfyPT.setTexture("cdfy",this._cdfyPT),this._icdfyPT.refreshRate=0,this._cdfxPT=new xr("cdfxTexture",{width:e.width+1,height:1},"iblShadowsCdfx",this._scene,i,!1,!1),this._cdfxPT.autoClear=!1,this._cdfxPT.setTexture("cdfy",this._cdfyPT),this._cdfxPT.refreshRate=0,this._icdfxPT=new xr("icdfxTexture",{width:e.width,height:1},"iblShadowsIcdfx",this._scene,o,!1,!1),this._icdfxPT.autoClear=!1,this._icdfxPT.setTexture("cdfx",this._cdfxPT),this._icdfxPT.refreshRate=0},r.prototype._disposeTextures=function(){var t,e,n,i,o;(t=this._cdfyPT)===null||t===void 0||t.dispose(),(e=this._icdfyPT)===null||e===void 0||e.dispose(),(n=this._cdfxPT)===null||n===void 0||n.dispose(),(i=this._icdfxPT)===null||i===void 0||i.dispose(),(o=this._iblSource)===null||o===void 0||o.dispose()},r.prototype._createDebugPass=function(){var t,e,n,i=this;this._debugPass&&this._debugPass.dispose();var o=this._engine.isWebGPU,a={width:this._scene.getEngine().getRenderWidth(),height:this._scene.getEngine().getRenderHeight(),samplingMode:Ie.g.BILINEAR_SAMPLINGMODE,engine:this._engine,textureType:P.Y.TEXTURETYPE_UNSIGNED_INT,uniforms:["sizeParams"],samplers:["cdfy","icdfy","cdfx","icdfx","iblSource"],defines:!((t=this._iblSource)===null||t===void 0)&&t.isCube?`#define IBL_USE_CUBE_MAP
|
||
`:"",shaderLanguage:o?1:0,extraInitializations:function(l,c){l?c.push(Promise.resolve().then(L.bind(L,55627))):c.push(Promise.resolve().then(L.bind(L,54428)))}};this._debugPass=new _t.w(this._debugPassName,"iblShadowsImportanceSamplingDebug",a);var s=this._debugPass.getEffect();s&&(s.defines=!((e=this._iblSource)===null||e===void 0)&&e.isCube?`#define IBL_USE_CUBE_MAP
|
||
`:""),!((n=this._iblSource)===null||n===void 0)&&n.isCube&&this._debugPass.updateEffect(`#define IBL_USE_CUBE_MAP
|
||
`),this._debugPass.onApplyObservable.add(function(l){l.setTexture("cdfy",i._cdfyPT),l.setTexture("icdfy",i._icdfyPT),l.setTexture("cdfx",i._cdfxPT),l.setTexture("icdfx",i._icdfxPT),l.setTexture("iblSource",i._iblSource),l.setFloat4("sizeParams",i._debugSizeParams.x,i._debugSizeParams.y,i._debugSizeParams.z,i._debugSizeParams.w)})},r.prototype.isReady=function(){return this._iblSource&&this._iblSource.name!=="Placeholder IBL Source"&&this._iblSource.isReady()&&this._cdfyPT&&this._cdfyPT.isReady()&&this._icdfyPT&&this._icdfyPT.isReady()&&this._cdfxPT&&this._cdfxPT.isReady()&&this._icdfxPT&&this._icdfxPT.isReady()},r.prototype.dispose=function(){this._disposeTextures(),this._debugPass&&this._debugPass.dispose()},r}(),wN=function(){function r(t){this._worldScale=1,this._debugPassName="Spatial Blur Debug Pass",this.debugEnabled=!1,this._debugSizeParams=new _.IU(0,0,0,0),this._scene=t,this._engine=t.getEngine(),this._createTextures()}return r.prototype.getPassPP=function(){return this._outputPP},r.prototype.getDebugPassPP=function(){return this._debugPassPP||this._createDebugPass(),this._debugPassPP},Object.defineProperty(r.prototype,"debugPassName",{get:function(){return this._debugPassName},enumerable:!1,configurable:!0}),r.prototype.setWorldScale=function(t){this._worldScale=t},r.prototype.setDebugDisplayParams=function(t,e,n,i){this._debugSizeParams.set(t,e,n,i)},r.prototype._createDebugPass=function(){var t=this;if(!this._debugPassPP){var e=this._engine.isWebGPU,n={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_R,textureType:P.Y.TEXTURETYPE_UNSIGNED_BYTE,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,uniforms:["sizeParams"],samplers:["debugSampler"],engine:this._engine,reusable:!1,shaderLanguage:e?1:0,extraInitializations:function(i,o){i?o.push(Promise.resolve().then(L.bind(L,35139))):o.push(Promise.resolve().then(L.bind(L,45310)))}};this._debugPassPP=new _t.w(this.debugPassName,"iblShadowDebug",n),this._debugPassPP.autoClear=!1,this._debugPassPP.onApplyObservable.add(function(i){i.setTextureFromPostProcessOutput("debugSampler",t._outputPP),i.setVector4("sizeParams",t._debugSizeParams)})}},r.prototype._createTextures=function(){var t=this,e=this._engine.isWebGPU,n={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_RG,textureType:P.Y.TEXTURETYPE_UNSIGNED_BYTE,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,uniforms:["blurParameters"],samplers:["shadowSampler","worldNormalSampler","linearDepthSampler"],engine:this._engine,reusable:!1,shaderLanguage:e?1:0,extraInitializations:function(i,o){i?o.push(Promise.resolve().then(L.bind(L,79401))):o.push(Promise.resolve().then(L.bind(L,31984)))}};this._outputPP=new _t.w("spacialBlurPP","iblShadowSpatialBlur",n),this._outputPP.autoClear=!1,this._outputPP.onApplyObservable.add(function(i){t._updatePostProcess(i)})},r.prototype._updatePostProcess=function(t){t.setVector4("blurParameters",new _.IU(1,this._worldScale,0,0));var e=this._scene.prePassRenderer;if(e){var n=e.getIndex(P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE),i=e.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE);n>=0&&t.setTexture("worldNormalSampler",e.getRenderTarget().textures[n]),i>=0&&t.setTexture("linearDepthSampler",e.getRenderTarget().textures[i])}},r.prototype.isReady=function(){return this._outputPP.isReady()&&!(this._debugPassPP&&!this._debugPassPP.isReady())},r.prototype.dispose=function(){this._outputPP.dispose(),this._debugPassPP&&this._debugPassPP.dispose()},r}(),BN=function(){function r(t){this.debugEnabled=!1,this._debugPassName="Shadow Accumulation Debug Pass",this._remenance=.9,this._reset=!0,this._debugSizeParams=new _.IU(0,0,0,0),this._scene=t,this._engine=t.getEngine(),this._createTextures()}return r.prototype.getPassPP=function(){return this._outputPP},r.prototype.getDebugPassPP=function(){return this._debugPassPP||this._createDebugPass(),this._debugPassPP},Object.defineProperty(r.prototype,"debugPassName",{get:function(){return this._debugPassName},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"remenance",{get:function(){return this._remenance},set:function(t){this._remenance=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"reset",{get:function(){return this._reset},set:function(t){this._reset=t},enumerable:!1,configurable:!0}),r.prototype.setDebugDisplayParams=function(t,e,n,i){this._debugSizeParams.set(t,e,n,i)},r.prototype._createDebugPass=function(){var t=this;if(!this._debugPassPP){var e=this._engine.isWebGPU,n={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_RG,textureType:P.Y.TEXTURETYPE_UNSIGNED_BYTE,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,uniforms:["sizeParams"],samplers:["debugSampler"],engine:this._engine,reusable:!1,shaderLanguage:e?1:0,extraInitializations:function(i,o){i?o.push(Promise.resolve().then(L.bind(L,35139))):o.push(Promise.resolve().then(L.bind(L,45310)))}};this._debugPassPP=new _t.w(this.debugPassName,"iblShadowDebug",n),this._debugPassPP.autoClear=!1,this._debugPassPP.onApplyObservable.add(function(i){i.setTextureFromPostProcessOutput("debugSampler",t._outputPP),i.setVector4("sizeParams",t._debugSizeParams)})}},r.prototype._createTextures=function(){var t=this,e=this._engine.isWebGPU,n={generateDepthBuffer:!1,generateMipMaps:!1,format:P.Y.TEXTUREFORMAT_RGBA,type:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE};this._oldLocalPositionRT=new un.$("oldLocalPositionRT",{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},this._scene,n);var i={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_RGBA,textureType:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,engine:this._engine,reusable:!1,defines:"#define PASS_SAMPLER sampler",shaderLanguage:e?1:0,extraInitializations:function(u,d){u?d.push(Promise.resolve().then(L.bind(L,59448))):d.push(Promise.resolve().then(L.bind(L,56017)))}},o=new _t.w("Copy Local Position Texture","pass",i);o.autoClear=!1,o.onApplyObservable.add(function(u){var d=t._scene.prePassRenderer,h=d.getIndex(P.Y.PREPASS_POSITION_TEXTURE_TYPE);h>=0&&u.setTexture("textureSampler",d.getRenderTarget().textures[h])}),this._oldLocalPositionRT.addPostProcess(o),this._oldLocalPositionRT.skipInitialClear=!0,this._oldLocalPositionRT.noPrePassRenderer=!0,this._scene.customRenderTargets.push(this._oldLocalPositionRT);var a={generateDepthBuffer:!1,generateMipMaps:!1,format:P.Y.TEXTUREFORMAT_RG,type:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE};this._oldAccumulationRT=new un.$("oldAccumulationRT",{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},this._scene,a);var s={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_RG,textureType:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,engine:this._engine,reusable:!1,defines:"#define PASS_SAMPLER sampler",shaderLanguage:e?1:0,extraInitializations:function(u,d){u?d.push(Promise.resolve().then(L.bind(L,59448))):d.push(Promise.resolve().then(L.bind(L,56017)))}},l=new _t.w("Copy Accumulation Texture","pass",s);l.autoClear=!1,l.onApplyObservable.add(function(u){var d;!((d=t._outputPP._outputTexture)===null||d===void 0)&&d.texture?u.setTextureFromPostProcessOutput("textureSampler",t._outputPP):u._bindTexture("textureSampler",t._outputPP.inputTexture.texture)}),this._oldAccumulationRT.addPostProcess(l),this._oldAccumulationRT.skipInitialClear=!0,this._oldAccumulationRT.noPrePassRenderer=!0,this._scene.customRenderTargets.push(this._oldAccumulationRT);var c={width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight(),textureFormat:P.Y.TEXTUREFORMAT_RG,textureType:P.Y.TEXTURETYPE_HALF_FLOAT,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,uniforms:["accumulationParameters"],samplers:["oldAccumulationSampler","prevLocalPositionSampler","localPositionSampler","motionSampler"],engine:this._engine,reusable:!1,shaderLanguage:e?1:0,extraInitializations:function(u,d){u?d.push(Promise.resolve().then(L.bind(L,21181))):d.push(Promise.resolve().then(L.bind(L,84586)))}};this._outputPP=new _t.w("accumulationPassPP","iblShadowAccumulation",c),this._outputPP.autoClear=!1,this._outputPP.resize(this._engine.getRenderWidth(),this._engine.getRenderHeight()),this._outputPP.onApplyObservable.add(function(u){t._updatePostProcess(u)})},r.prototype._updatePostProcess=function(t){t.setVector4("accumulationParameters",new _.IU(this.remenance,this.reset?1:0,0,0)),t.setTexture("oldAccumulationSampler",this._oldAccumulationRT),t.setTexture("prevLocalPositionSampler",this._oldLocalPositionRT);var e=this._scene.prePassRenderer;if(e){var n=e.getIndex(P.Y.PREPASS_POSITION_TEXTURE_TYPE);n>=0&&t.setTexture("localPositionSampler",e.getRenderTarget().textures[n]);var i=e.getIndex(P.Y.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE);i>=0&&t.setTexture("motionSampler",e.getRenderTarget().textures[i])}this.reset=!1},r.prototype.resize=function(){this._oldAccumulationRT.resize({width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()}),this._oldLocalPositionRT.resize({width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()})},r.prototype._disposeTextures=function(){this._oldAccumulationRT.dispose(),this._oldLocalPositionRT.dispose()},r.prototype.isReady=function(){return this._oldAccumulationRT&&this._oldAccumulationRT.isReadyForRendering()&&this._oldLocalPositionRT&&this._oldLocalPositionRT.isReadyForRendering()&&this._outputPP.isReady()&&!(this._debugPassPP&&!this._debugPassPP.isReady())},r.prototype.dispose=function(){this._disposeTextures(),this._outputPP.dispose(),this._debugPassPP&&this._debugPassPP.dispose()},r}(),VN=function(){this.enabled=!0,this.name="iblShadows",this.texturesRequired=[P.Y.PREPASS_DEPTH_TEXTURE_TYPE,P.Y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE,P.Y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE,P.Y.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE,P.Y.PREPASS_POSITION_TEXTURE_TYPE,P.Y.PREPASS_LOCAL_POSITION_TEXTURE_TYPE]},qI=function(r){function t(e,n,i,o){i===void 0&&(i={});var a=r.call(this,n.getEngine(),e)||this;return a._voxelizationDirty=!0,a._boundsNeedUpdate=!0,a._allowDebugPasses=!1,a._debugPasses=[],a._excludedMeshes=[],a._shadowOpacity=.75,a._enabled=!0,a.voxelGridSize=1,a._gbufferDebugEnabled=!1,a._gBufferDebugSizeParams=new _.IU(0,0,0,0),a.scene=n,n.enablePrePassRenderer()?(a.shadowOpacity=i.shadowOpacity||.75,a._prePassEffectConfiguration=new VN,a._voxelRenderer=new NN(a.scene,a,i?i.resolutionExp:6,i.triPlanarVoxelization===void 0||i.triPlanarVoxelization),a._importanceSamplingRenderer=new FN(a.scene),a._voxelTracingPass=new LN(a.scene,a),a.sampleDirections=i.sampleDirections||2,a.voxelShadowOpacity=i.voxelShadowOpacity||1,a.ssShadowOpacity=i.ssShadowsEnabled===void 0||i.ssShadowsEnabled?1:0,a.ssShadowMaxDist=i.ssShadowMaxDist||.05,a.ssShadowSamples=i.ssShadowSampleCount||16,a.ssShadowStride=i.ssShadowStride||8,a.ssShadowThickness=i.ssShadowThickness||.5,a._spatialBlurPass=new wN(a.scene),a._accumulationPass=new BN(a.scene),a.shadowRemenance=i.shadowRemenance||.75,a._noiseTexture=new Ie.g("https://assets.babylonjs.com/textures/blue_noise/blue_noise_rgb.png",a.scene,!1,!0,P.Y.TEXTURE_NEAREST_SAMPLINGMODE),a.scene.environmentTexture&&(a._importanceSamplingRenderer.iblSource=a.scene.environmentTexture),a._createShadowCombinePostProcess(),n.postProcessRenderPipelineManager.addPipeline(a),a.scene.onNewMeshAddedObservable.add(a.updateSceneBounds.bind(a)),a.scene.onMeshRemovedObservable.add(a.updateSceneBounds.bind(a)),a.scene.onActiveCameraChanged.add(a._listenForCameraChanges.bind(a)),a.scene.onBeforeRenderObservable.add(a._updateBeforeRender.bind(a)),a._listenForCameraChanges(),a.scene.getEngine().onResizeObservable.add(a._handleResize.bind(a)),a._importanceSamplingRenderer.onReadyObservable.addOnce(function(){a._createEffectPasses(o);var s=function(){a._voxelRenderer.isReady()?(a.toggleShadow(a._enabled),a._enabled&&(a._voxelizationDirty=!0)):setTimeout(function(){s()},16)};s()}),a):(O.V.Warn("IBL Shadows Render Pipeline could not enable PrePass, aborting."),a)}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"shadowOpacity",{get:function(){return this._shadowOpacity},set:function(e){this._shadowOpacity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"voxelShadowOpacity",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.voxelShadowOpacity},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.voxelShadowOpacity=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ssShadowOpacity",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.ssShadowOpacity},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.ssShadowOpacity=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ssShadowSamples",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.sssSamples},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.sssSamples=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ssShadowStride",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.sssStride},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.sssStride=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ssShadowMaxDist",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.sssMaxDist},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.sssMaxDist=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ssShadowThickness",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.sssThickness},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.sssThickness=e)},enumerable:!1,configurable:!0}),t.prototype.setIblTexture=function(e){this._importanceSamplingRenderer&&(this._importanceSamplingRenderer.iblSource=e)},t.prototype.getVoxelGridTexture=function(){var e;return(e=this._voxelRenderer)===null||e===void 0?void 0:e.getVoxelGrid()},t.prototype.getIcdfyTexture=function(){return this._importanceSamplingRenderer.getIcdfyTexture()},t.prototype.getIcdfxTexture=function(){return this._importanceSamplingRenderer.getIcdfxTexture()},Object.defineProperty(t.prototype,"gbufferDebugEnabled",{get:function(){return this._gbufferDebugEnabled},set:function(e){!e||this.allowDebugPasses?(this._gbufferDebugEnabled=e,e?this._enableEffect(this._getGBufferDebugPass().name,this.cameras):this._disableEffect(this._getGBufferDebugPass().name,this.cameras)):O.V.Warn("Can't enable G-Buffer debug view without setting allowDebugPasses to true.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"importanceSamplingDebugEnabled",{get:function(){var e;return(e=this._importanceSamplingRenderer)===null||e===void 0?void 0:e.debugEnabled},set:function(e){this._importanceSamplingRenderer&&(!e||this.allowDebugPasses?e!==this._importanceSamplingRenderer.debugEnabled&&(this._importanceSamplingRenderer.debugEnabled=e,e?this._enableEffect(this._importanceSamplingRenderer.debugPassName,this.cameras):this._disableEffect(this._importanceSamplingRenderer.debugPassName,this.cameras)):O.V.Warn("Can't enable importance sampling debug view without setting allowDebugPasses to true."))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"voxelDebugEnabled",{get:function(){var e;return(e=this._voxelRenderer)===null||e===void 0?void 0:e.voxelDebugEnabled},set:function(e){this._voxelRenderer&&(!e||this.allowDebugPasses?(this._voxelRenderer.voxelDebugEnabled=e,e?this._enableEffect(this._voxelRenderer.debugPassName,this.cameras):this._disableEffect(this._voxelRenderer.debugPassName,this.cameras)):O.V.Warn("Can't enable voxel debug view without setting allowDebugPasses to true."))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"voxelDebugAxis",{get:function(){var e;return(e=this._voxelRenderer)===null||e===void 0?void 0:e.voxelDebugAxis},set:function(e){this._voxelRenderer&&(this._voxelRenderer.voxelDebugAxis=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"voxelDebugDisplayMip",{set:function(e){this._voxelRenderer&&this._voxelRenderer.setDebugMipNumber(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"voxelTracingDebugEnabled",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.debugEnabled},set:function(e){this._voxelTracingPass&&(!e||this.allowDebugPasses?e!==this._voxelTracingPass.debugEnabled&&(this._voxelTracingPass.debugEnabled=e,e?this._enableEffect(this._voxelTracingPass.debugPassName,this.cameras):this._disableEffect(this._voxelTracingPass.debugPassName,this.cameras)):O.V.Warn("Can't enable voxel tracing debug view without setting allowDebugPasses to true."))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"spatialBlurPassDebugEnabled",{get:function(){var e;return(e=this._spatialBlurPass)===null||e===void 0?void 0:e.debugEnabled},set:function(e){this._spatialBlurPass&&(!e||this.allowDebugPasses?e!==this._spatialBlurPass.debugEnabled&&(this._spatialBlurPass.debugEnabled=e,e?this._enableEffect(this._spatialBlurPass.debugPassName,this.cameras):this._disableEffect(this._spatialBlurPass.debugPassName,this.cameras)):O.V.Warn("Can't enable spatial blur debug view without setting allowDebugPasses to true."))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"accumulationPassDebugEnabled",{get:function(){var e;return(e=this._accumulationPass)===null||e===void 0?void 0:e.debugEnabled},set:function(e){this._accumulationPass&&(!e||this.allowDebugPasses?e!==this._accumulationPass.debugEnabled&&(this._accumulationPass.debugEnabled=e,e?this._enableEffect(this._accumulationPass.debugPassName,this.cameras):this._disableEffect(this._accumulationPass.debugPassName,this.cameras)):O.V.Warn("Can't enable accumulation pass debug view without setting allowDebugPasses to true."))},enumerable:!1,configurable:!0}),t.prototype.addExcludedMesh=function(e){this._excludedMeshes.indexOf(e.uniqueId)===-1&&this._excludedMeshes.push(e.uniqueId)},t.prototype.removeExcludedMesh=function(e){var n=this._excludedMeshes.indexOf(e.uniqueId);n!==-1&&this._excludedMeshes.splice(n,1)},Object.defineProperty(t.prototype,"resolutionExp",{get:function(){return this._voxelRenderer.voxelResolutionExp},set:function(e){e!==this._voxelRenderer.voxelResolutionExp&&(this._voxelRenderer.isVoxelizationInProgress()?O.V.Warn("Can't change the resolution of the voxel grid while voxelization is in progress."):(this._voxelRenderer.voxelResolutionExp=e,this.updateVoxelization(),this._accumulationPass.reset=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sampleDirections",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.sampleDirections},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.sampleDirections=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowRemenance",{get:function(){var e;return(e=this._accumulationPass)===null||e===void 0?void 0:e.remenance},set:function(e){this._accumulationPass&&(this._accumulationPass.remenance=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"envRotation",{get:function(){var e;return(e=this._voxelTracingPass)===null||e===void 0?void 0:e.envRotation},set:function(e){this._voxelTracingPass&&(this._voxelTracingPass.envRotation=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"allowDebugPasses",{get:function(){return this._allowDebugPasses},set:function(e){var n=this;this._allowDebugPasses!==e&&(this._allowDebugPasses=e,e?this._importanceSamplingRenderer.isReady()?this._createDebugPasses():this._importanceSamplingRenderer.onReadyObservable.addOnce(function(){n._createDebugPasses()}):this._disposeDebugPasses())},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){var e=Ve.q.LastCreatedEngine;return!!e&&e._features.supportIBLShadows},enumerable:!1,configurable:!0}),t.prototype.toggleShadow=function(e){this._enabled=e,e?(this._enableEffect("IBLShadowVoxelTracingPass",this.cameras),this._enableEffect("IBLShadowSpatialBlurPass",this.cameras),this._enableEffect("IBLShadowAccumulationBlurPass",this.cameras),this._enableEffect("IBLShadowCompositePass",this.cameras)):(this._disableEffect("IBLShadowVoxelTracingPass",null),this._disableEffect("IBLShadowSpatialBlurPass",null),this._disableEffect("IBLShadowAccumulationBlurPass",null),this._disableEffect("IBLShadowCompositePass",null))},t.prototype._handleResize=function(){var e;this._voxelRenderer.resize(),(e=this._accumulationPass)===null||e===void 0||e.resize()},t.prototype._createShadowCombinePostProcess=function(){var e=this,n=this.engine.isWebGPU,i={width:this.scene.getEngine().getRenderWidth(),height:this.scene.getEngine().getRenderHeight(),uniforms:["shadowOpacity"],samplers:["sceneTexture"],samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,engine:this.scene.getEngine(),textureType:P.Y.TEXTURETYPE_UNSIGNED_BYTE,reusable:!1,shaderLanguage:n?1:0,extraInitializations:function(o,a){o?a.push(Promise.resolve().then(L.bind(L,83898))):a.push(Promise.resolve().then(L.bind(L,41037)))}};this._shadowCompositePP=new _t.w("iblShadowsCombine","iblShadowsCombine",i),this._shadowCompositePP.autoClear=!1,this._shadowCompositePP.onApplyObservable.add(function(o){var a,s,l,c,u;o.setTextureFromPostProcess("sceneTexture",e._voxelTracingPass.getPassPP()),o.setFloat("shadowOpacity",e._shadowOpacity),!((a=e._importanceSamplingRenderer)===null||a===void 0)&&a.isReady()&&(!((s=e._voxelRenderer)===null||s===void 0)&&s.isReady())&&(!((l=e._voxelTracingPass)===null||l===void 0)&&l.isReady())&&(!((c=e._spatialBlurPass)===null||c===void 0)&&c.isReady())&&(!((u=e._accumulationPass)===null||u===void 0)&&u.isReady())&&e.update()}),this._shadowCompositePP._prePassEffectConfiguration=this._prePassEffectConfiguration},t.prototype._createEffectPasses=function(e){var n=this;this.addEffect(new Ut(this.scene.getEngine(),"IBLShadowVoxelTracingPass",function(){return n._voxelTracingPass.getPassPP()},!0)),this.addEffect(new Ut(this.scene.getEngine(),"IBLShadowSpatialBlurPass",function(){return n._spatialBlurPass.getPassPP()},!0)),this.addEffect(new Ut(this.scene.getEngine(),"IBLShadowAccumulationBlurPass",function(){return n._accumulationPass.getPassPP()},!0)),this.addEffect(new Ut(this.scene.getEngine(),"IBLShadowCompositePass",function(){return n._shadowCompositePP},!0)),e&&this.scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name,e),this.toggleShadow(!1),this._enabled=!0},t.prototype._getGBufferDebugPass=function(){var e=this;if(this._gbufferDebugPass)return this._gbufferDebugPass;var n=this.engine.isWebGPU,i=this._prePassEffectConfiguration.texturesRequired.map(function(a){return gs.TextureFormats[a].name.toString()}),o={width:this.scene.getEngine().getRenderWidth(),height:this.scene.getEngine().getRenderHeight(),samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,engine:this.scene.getEngine(),textureType:P.Y.TEXTURETYPE_UNSIGNED_INT,textureFormat:P.Y.TEXTUREFORMAT_RGBA,uniforms:["sizeParams"],samplers:i,reusable:!1,shaderLanguage:n?1:0,extraInitializations:function(a,s){a?s.push(Promise.resolve().then(L.bind(L,75866))):s.push(Promise.resolve().then(L.bind(L,41745)))}};return this._gbufferDebugPass=new _t.w("iblShadowGBufferDebug","iblShadowGBufferDebug",o),this._gbufferDebugPass.autoClear=!1,this._gbufferDebugPass.onApplyObservable.add(function(a){e._prePassEffectConfiguration.texturesRequired.forEach(function(s){var l=e.scene.prePassRenderer;if(l){var c=l.getIndex(s);c>=0&&a.setTexture(gs.TextureFormats[s].name,l.getRenderTarget().textures[c])}else O.V.Error("Can't enable G-Buffer debug rendering since prepassRenderer doesn't exist.")}),a.setVector4("sizeParams",e._gBufferDebugSizeParams),e.scene.activeCamera&&a.setFloat("maxDepth",e.scene.activeCamera.maxZ)}),this._gbufferDebugPass},t.prototype._createDebugPasses=function(){var e,n,i,o,a,s=this;this._debugPasses=[{pass:(e=this._importanceSamplingRenderer)===null||e===void 0?void 0:e.getDebugPassPP(),enabled:this.importanceSamplingDebugEnabled},{pass:(n=this._voxelRenderer)===null||n===void 0?void 0:n.getDebugPassPP(),enabled:this.voxelDebugEnabled},{pass:(i=this._voxelTracingPass)===null||i===void 0?void 0:i.getDebugPassPP(),enabled:this.voxelTracingDebugEnabled},{pass:(o=this._spatialBlurPass)===null||o===void 0?void 0:o.getDebugPassPP(),enabled:this.spatialBlurPassDebugEnabled},{pass:(a=this._accumulationPass)===null||a===void 0?void 0:a.getDebugPassPP(),enabled:this.accumulationPassDebugEnabled},{pass:this._getGBufferDebugPass(),enabled:this.gbufferDebugEnabled}];for(var l=function(h){if(!c._debugPasses[h].pass)return"continue";c.addEffect(new Ut(c.scene.getEngine(),c._debugPasses[h].pass.name,function(){return s._debugPasses[h].pass},!0))},c=this,u=0;u<this._debugPasses.length;u++)l(u);var d=this.cameras.slice();for(this.scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this.name,this.cameras),this.scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this.name,d),u=0;u<this._debugPasses.length;u++)this._debugPasses[u].pass&&(this._debugPasses[u].enabled?this._enableEffect(this._debugPasses[u].pass.name,this.cameras):this._disableEffect(this._debugPasses[u].pass.name,this.cameras))},t.prototype._disposeEffectPasses=function(){this.scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this.name,this.cameras),this._disableEffect("IBLShadowVoxelTracingPass",this.cameras),this._disableEffect("IBLShadowSpatialBlurPass",this.cameras),this._disableEffect("IBLShadowAccumulationBlurPass",this.cameras),this._disableEffect("IBLShadowCompositePass",this.cameras),this._disposeDebugPasses(),this._reset()},t.prototype._disposeDebugPasses=function(){for(var e=0;e<this._debugPasses.length;e++)this._disableEffect(this._debugPasses[e].pass.name,this.cameras),this._debugPasses[e].pass.dispose();this._debugPasses=[]},t.prototype._updateDebugPasses=function(){var e=0;this._gbufferDebugEnabled&&e++,this.importanceSamplingDebugEnabled&&e++,this.voxelDebugEnabled&&e++,this.voxelTracingDebugEnabled&&e++,this.spatialBlurPassDebugEnabled&&e++,this.accumulationPassDebugEnabled&&e++;var n=Math.ceil(Math.sqrt(e)),i=Math.ceil(e/n),o=1/i,a=1/n,s=0,l=0;if(this.gbufferDebugEnabled){if(!this.scene.prePassRenderer)return void O.V.Error("Can't enable G-Buffer debug rendering since prepassRenderer doesn't exist.");this._gBufferDebugSizeParams.set(s,l,i,n),(s-=o)<=-1&&(s=0,l-=a)}this.importanceSamplingDebugEnabled&&(this._importanceSamplingRenderer.setDebugDisplayParams(s,l,i,n),(s-=o)<=-1&&(s=0,l-=a)),this.voxelDebugEnabled&&(this._voxelRenderer.setDebugDisplayParams(s,l,i,n),(s-=o)<=-1&&(s=0,l-=a)),this.voxelTracingDebugEnabled&&(this._voxelTracingPass.setDebugDisplayParams(s,l,i,n),(s-=o)<=-1&&(s=0,l-=a)),this.spatialBlurPassDebugEnabled&&(this._spatialBlurPass.setDebugDisplayParams(s,l,i,n),(s-=o)<=-1&&(s=0,l-=a)),this.accumulationPassDebugEnabled&&(this._accumulationPass.setDebugDisplayParams(s,l,i,n),(s-=o)<=-1&&(s=0,l-=a))},t.prototype.updateVoxelization=function(){this._voxelizationDirty=!0},t.prototype.updateSceneBounds=function(){this._voxelizationDirty=!0,this._boundsNeedUpdate=!0},t.prototype._updateBeforeRender=function(){this._updateDebugPasses()},t.prototype._listenForCameraChanges=function(){var e=this;this.scene.activeCamera instanceof zr&&this.scene.onBeforeCameraRenderObservable.add(function(n){n instanceof zr?n.inertialAlphaOffset!==0||n.inertialBetaOffset!==0||n.inertialRadiusOffset!==0||n.inertialPanningX!==0||n.inertialPanningY:n instanceof _r&&(n.cameraDirection.x!==0||n.cameraDirection.y!==0||n.cameraDirection.z!==0||n.cameraRotation.x!==0||n.cameraRotation.y),e._accumulationPass})},t.prototype.setPrePassRenderer=function(e){return!!e.addEffectConfiguration(this._prePassEffectConfiguration)},t.prototype.isReady=function(){return this._noiseTexture.isReady()&&this._voxelRenderer.isReady()&&this._importanceSamplingRenderer.isReady()&&(!this._voxelTracingPass||this._voxelTracingPass.isReady())&&(!this._spatialBlurPass||this._spatialBlurPass.isReady())&&(!this._accumulationPass||this._accumulationPass.isReady())},t.prototype.update=function(){var e,n,i=this;if(!this._voxelRenderer.isVoxelizationInProgress()){if(this._boundsNeedUpdate){var o=this.scene.getWorldExtends(function(u){return u instanceof xe&&i._excludedMeshes.indexOf(u.uniqueId)===-1}),a=o.max.subtract(o.min);if(this.voxelGridSize=Math.max(a.x,Math.max(a.y,a.z)),!isFinite(this.voxelGridSize)||this.voxelGridSize===0)return O.V.Warn("IBL Shadows: Scene size is invalid. Can't update bounds."),this._boundsNeedUpdate=!1,void(this.voxelGridSize=1);var s=this.voxelGridSize/2,l=o.max.add(o.min).multiplyByFloats(-.5,-.5,-.5),c=_.uq.Compose(new _.Pq(1/s,1/s,1/s),new _.PT,new _.Pq(0,0,0));_.uq.Compose(new _.Pq(1,1,1),new _.PT,l).multiplyToRef(c,c),(e=this._voxelTracingPass)===null||e===void 0||e.setWorldScaleMatrix(c),this._voxelRenderer.setWorldScaleMatrix(c),(n=this._spatialBlurPass)===null||n===void 0||n.setWorldScale(2*s),this._boundsNeedUpdate=!1,this.ssShadowMaxDist=1.1*this.voxelGridSize/(1<<this.resolutionExp)}this._voxelizationDirty&&(this._voxelRenderer.updateVoxelGrid(this._excludedMeshes),this._voxelizationDirty=!1,this.ssShadowMaxDist=1.1*this.voxelGridSize/(1<<this.resolutionExp))}},t.prototype.getClassName=function(){return"IBLShadowsRenderPipeline"},t.prototype.dispose=function(){var e,n,i;this._disposeEffectPasses(),this._noiseTexture.dispose(),this._voxelRenderer.dispose(),this._importanceSamplingRenderer.dispose(),(e=this._voxelTracingPass)===null||e===void 0||e.dispose(),(n=this._spatialBlurPass)===null||n===void 0||n.dispose(),(i=this._accumulationPass)===null||i===void 0||i.dispose(),r.prototype.dispose.call(this)},t}(uo);Object.defineProperty(ke.Z.prototype,"prePassRenderer",{get:function(){return this._prePassRenderer},set:function(r){r&&r.isSupported&&(this._prePassRenderer=r)},enumerable:!0,configurable:!0}),ke.Z.prototype.enablePrePassRenderer=function(){return this._prePassRenderer||(this._prePassRenderer=new gs(this),this._prePassRenderer.isSupported||(this._prePassRenderer=null,O.V.Error(`PrePassRenderer needs WebGL 2 support.
|
||
Maybe you tried to use the following features that need the PrePassRenderer :
|
||
+ Subsurface Scattering`))),this._prePassRenderer},ke.Z.prototype.disablePrePassRenderer=function(){this._prePassRenderer&&(this._prePassRenderer.dispose(),this._prePassRenderer=null)};var ST=function(){function r(t){this.name=lt.v.NAME_PREPASSRENDERER,this.scene=t}return r.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(lt.v.STEP_BEFORECAMERADRAW_PREPASS,this,this._beforeCameraDraw),this.scene._afterCameraDrawStage.registerStep(lt.v.STEP_AFTERCAMERADRAW_PREPASS,this,this._afterCameraDraw),this.scene._beforeRenderTargetDrawStage.registerStep(lt.v.STEP_BEFORERENDERTARGETDRAW_PREPASS,this,this._beforeRenderTargetDraw),this.scene._afterRenderTargetDrawStage.registerStep(lt.v.STEP_AFTERCAMERADRAW_PREPASS,this,this._afterRenderTargetDraw),this.scene._beforeClearStage.registerStep(lt.v.STEP_BEFORECLEAR_PREPASS,this,this._beforeClearStage),this.scene._beforeRenderTargetClearStage.registerStep(lt.v.STEP_BEFORERENDERTARGETCLEAR_PREPASS,this,this._beforeRenderTargetClearStage),this.scene._beforeRenderingMeshStage.registerStep(lt.v.STEP_BEFORERENDERINGMESH_PREPASS,this,this._beforeRenderingMeshStage),this.scene._afterRenderingMeshStage.registerStep(lt.v.STEP_AFTERRENDERINGMESH_PREPASS,this,this._afterRenderingMeshStage)},r.prototype._beforeRenderTargetDraw=function(t,e,n){this.scene.prePassRenderer&&!t.noPrePassRenderer&&(this.scene.prePassRenderer._setRenderTarget(t._prePassRenderTarget),this.scene.prePassRenderer._beforeDraw(void 0,e,n))},r.prototype._afterRenderTargetDraw=function(t,e,n){this.scene.prePassRenderer&&!t.noPrePassRenderer&&this.scene.prePassRenderer._afterDraw(e,n)},r.prototype._beforeRenderTargetClearStage=function(t){this.scene.prePassRenderer&&!t.noPrePassRenderer&&(t._prePassRenderTarget||(t._prePassRenderTarget=this.scene.prePassRenderer._createRenderTarget(t.name+"_prePassRTT",t)),this.scene.prePassRenderer._setRenderTarget(t._prePassRenderTarget),this.scene.prePassRenderer._clear())},r.prototype._beforeCameraDraw=function(t){this.scene.prePassRenderer&&(this.scene.prePassRenderer._setRenderTarget(null),this.scene.prePassRenderer._beforeDraw(t))},r.prototype._afterCameraDraw=function(){this.scene.prePassRenderer&&this.scene.prePassRenderer._afterDraw()},r.prototype._beforeClearStage=function(){this.scene.prePassRenderer&&(this.scene.prePassRenderer._setRenderTarget(null),this.scene.prePassRenderer._clear())},r.prototype._beforeRenderingMeshStage=function(t,e,n,i){if(i){var o=t.getScene();o.prePassRenderer&&o.prePassRenderer.bindAttachmentsForEffect(i,e)}},r.prototype._afterRenderingMeshStage=function(t){var e=t.getScene();e.prePassRenderer&&e.prePassRenderer.restoreAttachments()},r.prototype.rebuild=function(){},r.prototype.dispose=function(){this.scene.disablePrePassRenderer()},r}();gs._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_PREPASSRENDERER);t||(t=new ST(r),r._addComponent(t))},Gt.l.IncludesShadersStore.fibonacci=`#define rcp(x) 1./x
|
||
#define GOLDEN_RATIO 1.618033988749895
|
||
#define TWO_PI 6.2831855
|
||
vec2 Golden2dSeq(int i,float n)
|
||
{return vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));}
|
||
vec2 SampleDiskGolden(int i,int sampleCount)
|
||
{vec2 f=Golden2dSeq(i,float(sampleCount));return vec2(sqrt(f.x),TWO_PI*f.y);}`,L(5447),Gt.l.IncludesShadersStore.diffusionProfile="uniform vec3 diffusionS[5];uniform float diffusionD[5];uniform float filterRadii[5];",Gt.l.ShadersStore.subSurfaceScatteringPixelShader=`#include<fibonacci>
|
||
#include<helperFunctions>
|
||
#include<subSurfaceScatteringFunctions>
|
||
#include<diffusionProfile>
|
||
varying vec2 vUV;uniform vec2 texelSize;uniform sampler2D textureSampler;uniform sampler2D irradianceSampler;uniform sampler2D depthSampler;uniform sampler2D albedoSampler;uniform vec2 viewportSize;uniform float metersPerUnit;const float LOG2_E=1.4426950408889634;const float SSS_PIXELS_PER_SAMPLE=4.;const int _SssSampleBudget=40;
|
||
#define rcp(x) 1./x
|
||
#define Sq(x) x*x
|
||
#define SSS_BILATERAL_FILTER true
|
||
vec3 EvalBurleyDiffusionProfile(float r,vec3 S)
|
||
{vec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S);
|
||
vec3 expSum=exp_13*(1.+exp_13*exp_13);
|
||
return (S*rcp(8.*PI))*expSum; }
|
||
vec2 SampleBurleyDiffusionProfile(float u,float rcpS)
|
||
{u=1.-u;
|
||
float g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));float n=exp2(log2(g)*(-1.0/3.0));
|
||
float p=(g*n)*n;
|
||
float c=1.+p+n;
|
||
float d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u);
|
||
float x=(3./LOG2_E)*log2(c)-d;
|
||
float rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));float r=x*rcpS;float rcpPdf=(8.*PI*rcpS)*rcpExp;
|
||
return vec2(r,rcpPdf);}
|
||
vec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)
|
||
{
|
||
#ifndef SSS_BILATERAL_FILTER
|
||
z=0.;
|
||
#endif
|
||
float r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));float area=rcpPdf;
|
||
#if SSS_CLAMP_ARTIFACT
|
||
return clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);
|
||
#else
|
||
return EvalBurleyDiffusionProfile(r,S)*area;
|
||
#endif
|
||
}
|
||
void EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,
|
||
float phase,inout vec3 totalIrradiance,inout vec3 totalWeight)
|
||
{float scale =rcp(float(n));float offset=rcp(float(n))*0.5;float sinPhase,cosPhase;sinPhase=sin(phase);cosPhase=cos(phase);vec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);float r=bdp.x;float rcpPdf=bdp.y;float phi=SampleDiskGolden(i,n).y;float sinPhi,cosPhi;sinPhi=sin(phi);cosPhi=cos(phi);float sinPsi=cosPhase*sinPhi+sinPhase*cosPhi;
|
||
float cosPsi=cosPhase*cosPhi-sinPhase*sinPhi;
|
||
vec2 vec=r*vec2(cosPsi,sinPsi);vec2 position;
|
||
float xy2;position=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;xy2 =r*r;vec4 textureSample=texture2D(irradianceSampler,position);float viewZ=texture2D(depthSampler,position).r;vec3 irradiance =textureSample.rgb;if (testLightingForSSS(textureSample.a))
|
||
{float relZ=viewZ-centerPosVS.z;vec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);totalIrradiance+=weight*irradiance;totalWeight +=weight;}
|
||
else
|
||
{}}
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void)
|
||
{vec4 irradianceAndDiffusionProfile =texture2D(irradianceSampler,vUV);vec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;int diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));float centerDepth =0.;vec4 inputColor=texture2D(textureSampler,vUV);bool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);if (passedStencilTest)
|
||
{centerDepth=texture2D(depthSampler,vUV).r;}
|
||
if (!passedStencilTest) {
|
||
gl_FragColor=inputColor;return;}
|
||
float distScale =1.;vec3 S =diffusionS[diffusionProfileIndex];float d =diffusionD[diffusionProfileIndex];float filterRadius=filterRadii[diffusionProfileIndex];vec2 centerPosNDC=vUV;vec2 cornerPosNDC=vUV+0.5*texelSize;vec3 centerPosVS =vec3(centerPosNDC*viewportSize,1.0)*centerDepth;
|
||
vec3 cornerPosVS =vec3(cornerPosNDC*viewportSize,1.0)*centerDepth;
|
||
float mmPerUnit =1000.*(metersPerUnit*rcp(distScale));float unitsPerMm=rcp(mmPerUnit);float unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);float pixelsPerMm =rcp(unitsPerPixel)*unitsPerMm;float filterArea =PI*Sq(filterRadius*pixelsPerMm);int sampleCount =int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));int sampleBudget=_SssSampleBudget;int texturingMode=0;vec3 albedo =texture2D(albedoSampler,vUV).rgb;if (distScale==0. || sampleCount<1)
|
||
{
|
||
#ifdef DEBUG_SSS_SAMPLES
|
||
vec3 green=vec3(0.,1.,0.);gl_FragColor=vec4(green,1.0);return;
|
||
#endif
|
||
gl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);return;}
|
||
#ifdef DEBUG_SSS_SAMPLES
|
||
vec3 red =vec3(1.,0.,0.);vec3 blue=vec3(0.,0.,1.);gl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);return;
|
||
#endif
|
||
float phase=0.;int n=min(sampleCount,sampleBudget);vec3 centerWeight =vec3(0.);
|
||
vec3 totalIrradiance=vec3(0.);vec3 totalWeight =vec3(0.);for (int i=0; i<n; i++)
|
||
{EvaluateSample(i,n,S,d,centerPosVS,mmPerUnit,pixelsPerMm,
|
||
phase,totalIrradiance,totalWeight);}
|
||
totalWeight=max(totalWeight,HALF_MIN);gl_FragColor=vec4(inputColor.rgb+albedo*max(totalIrradiance/totalWeight,vec3(0.0)),1.);}`;var UN=function(r){function t(e,n,i,o,a,s,l,c){o===void 0&&(o=null),c===void 0&&(c=P.Y.TEXTURETYPE_UNSIGNED_INT);var u=r.call(this,e,"subSurfaceScattering",["texelSize","viewportSize","metersPerUnit"],["diffusionS","diffusionD","filterRadii","irradianceSampler","depthSampler","albedoSampler"],i,o,a||Ie.g.BILINEAR_SAMPLINGMODE,s,l,null,c,"postprocess",void 0,!0)||this;return u._scene=n,u.updateEffect(),u.onApplyObservable.add(function(d){if(n.prePassRenderer&&n.subSurfaceConfiguration){var h=u.texelSize;d.setFloat("metersPerUnit",n.subSurfaceConfiguration.metersPerUnit),d.setFloat2("texelSize",h.x,h.y),d.setTexture("irradianceSampler",n.prePassRenderer.getRenderTarget().textures[n.prePassRenderer.getIndex(P.Y.PREPASS_IRRADIANCE_TEXTURE_TYPE)]),d.setTexture("depthSampler",n.prePassRenderer.getRenderTarget().textures[n.prePassRenderer.getIndex(P.Y.PREPASS_DEPTH_TEXTURE_TYPE)]),d.setTexture("albedoSampler",n.prePassRenderer.getRenderTarget().textures[n.prePassRenderer.getIndex(P.Y.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE)]),d.setFloat2("viewportSize",Math.tan(n.activeCamera.fov/2)*n.getEngine().getAspectRatio(n.activeCamera,!0),Math.tan(n.activeCamera.fov/2)),d.setArray3("diffusionS",n.subSurfaceConfiguration.ssDiffusionS),d.setArray("diffusionD",n.subSurfaceConfiguration.ssDiffusionD),d.setArray("filterRadii",n.subSurfaceConfiguration.ssFilterRadii)}else O.V.Error("PrePass and subsurface configuration needs to be enabled for subsurface scattering.")}),u}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"SubSurfaceScatteringPostProcess"},t}(_t.w),KI=function(){function r(t){this._ssDiffusionS=[],this._ssFilterRadii=[],this._ssDiffusionD=[],this.enabled=!1,this.needsImageProcessing=!0,this.name=lt.v.NAME_SUBSURFACE,this.ssDiffusionProfileColors=[],this.metersPerUnit=1,this.texturesRequired=[P.Y.PREPASS_DEPTH_TEXTURE_TYPE,P.Y.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,P.Y.PREPASS_COLOR_TEXTURE_TYPE,P.Y.PREPASS_IRRADIANCE_TEXTURE_TYPE],this.addDiffusionProfile(new z.v9(1,1,1)),this._scene=t,r._SceneComponentInitialization(this._scene)}return Object.defineProperty(r.prototype,"ssDiffusionS",{get:function(){return this._ssDiffusionS},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ssDiffusionD",{get:function(){return this._ssDiffusionD},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ssFilterRadii",{get:function(){return this._ssFilterRadii},enumerable:!1,configurable:!0}),r.prototype.addDiffusionProfile=function(t){if(this.ssDiffusionD.length>=5)return O.V.Error("You already reached the maximum number of diffusion profiles."),0;for(var e=0;e<this._ssDiffusionS.length/3;e++)if(this._ssDiffusionS[3*e]===t.r&&this._ssDiffusionS[3*e+1]===t.g&&this._ssDiffusionS[3*e+2]===t.b)return e;return this._ssDiffusionS.push(t.r,t.b,t.g),this._ssDiffusionD.push(Math.max(Math.max(t.r,t.b),t.g)),this._ssFilterRadii.push(this.getDiffusionProfileParameters(t)),this.ssDiffusionProfileColors.push(t),this._ssDiffusionD.length-1},r.prototype.createPostProcess=function(){return this.postProcess=new UN("subSurfaceScattering",this._scene,1,null,void 0,this._scene.getEngine()),this.postProcess.autoClear=!1,this.postProcess},r.prototype.clearAllDiffusionProfiles=function(){this._ssDiffusionD=[],this._ssDiffusionS=[],this._ssFilterRadii=[],this.ssDiffusionProfileColors=[]},r.prototype.dispose=function(){this.clearAllDiffusionProfiles(),this.postProcess&&this.postProcess.dispose()},r.prototype.getDiffusionProfileParameters=function(t){var e=Math.max(t.r,t.g,t.b);return this._sampleBurleyDiffusionProfile(.997,e)},r.prototype._sampleBurleyDiffusionProfile=function(t,e){var n=1+4*(t=1-t)*(2*t+Math.sqrt(1+4*t*t)),i=Math.pow(n,-1/3),o=1+n*i*i+i;return 3*Math.log(o/(4*t))*e},r._SceneComponentInitialization=function(t){throw(0,gt.n)("SubSurfaceSceneComponent")},r}();nt.d.AddParser(lt.v.NAME_SUBSURFACE,function(r,t){if(r.ssDiffusionProfileColors!==void 0&&r.ssDiffusionProfileColors!==null&&(t.enableSubSurfaceForPrePass(),t.subSurfaceConfiguration))for(var e=0,n=r.ssDiffusionProfileColors.length;e<n;e++){var i=r.ssDiffusionProfileColors[e];t.subSurfaceConfiguration.addDiffusionProfile(new z.v9(i.r,i.g,i.b))}}),Object.defineProperty(ke.Z.prototype,"subSurfaceConfiguration",{get:function(){return this._subSurfaceConfiguration},set:function(r){r&&this.enablePrePassRenderer()&&(this._subSurfaceConfiguration=r)},enumerable:!0,configurable:!0}),ke.Z.prototype.enableSubSurfaceForPrePass=function(){if(this._subSurfaceConfiguration)return this._subSurfaceConfiguration;var r=this.enablePrePassRenderer();return r?(this._subSurfaceConfiguration=new KI(this),r.addEffectConfiguration(this._subSurfaceConfiguration),this._subSurfaceConfiguration):null},ke.Z.prototype.disableSubSurfaceForPrePass=function(){this._subSurfaceConfiguration&&(this._subSurfaceConfiguration.dispose(),this._subSurfaceConfiguration=null)};var ET=function(){function r(t){this.name=lt.v.NAME_PREPASSRENDERER,this.scene=t}return r.prototype.register=function(){},r.prototype.serialize=function(t){if(this.scene.subSurfaceConfiguration){var e=this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;t.ssDiffusionProfileColors=[];for(var n=0;n<e.length;n++)t.ssDiffusionProfileColors.push({r:e[n].r,g:e[n].g,b:e[n].b})}},r.prototype.addFromContainer=function(){},r.prototype.removeFromContainer=function(){this.scene.prePassRenderer&&this.scene.subSurfaceConfiguration&&this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles()},r.prototype.rebuild=function(){},r.prototype.dispose=function(){},r}();KI._SceneComponentInitialization=function(r){var t=r._getComponent(lt.v.NAME_SUBSURFACE);t||(t=new ET(r),r._addComponent(t))},ke.Z.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new xT(this)),this._outlineRenderer},Object.defineProperty(xe.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(r){r&&this.getScene().getOutlineRenderer(),this._renderOutline=r},enumerable:!0,configurable:!0}),Object.defineProperty(xe.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(r){r&&this.getScene().getOutlineRenderer(),this._renderOverlay=r},enumerable:!0,configurable:!0});var Xf,xT=function(){function r(t){this.name=lt.v.NAME_OUTLINERENDERER,this.zOffset=1,this.zOffsetUnits=4,this._shaderLanguage=0,this.scene=t,this._engine=t.getEngine(),this.scene._addComponent(this),this._passIdForDrawWrapper=[];for(var e=0;e<4;++e)this._passIdForDrawWrapper[e]=this._engine.createRenderPassId("Outline Renderer (".concat(e,")"));this._engine.isWebGPU&&(this._shaderLanguage=1)}return Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(lt.v.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(lt.v.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},r.prototype.rebuild=function(){},r.prototype.dispose=function(){for(var t=0;t<this._passIdForDrawWrapper.length;++t)this._engine.releaseRenderPassId(this._passIdForDrawWrapper[t])},r.prototype.render=function(t,e,n,i){n===void 0&&(n=!1),i=i??this._passIdForDrawWrapper[0];var o=this.scene,a=o.getEngine(),s=a.getCaps().instancedArrays&&(e.visibleInstances[t._id]!==null&&e.visibleInstances[t._id]!==void 0||t.getRenderingMesh().hasThinInstances);if(this.isReady(t,s,i)){var l=t.getMesh(),c=l._internalAbstractMeshDataInfo._actAsRegularMesh?l:null,u=t.getRenderingMesh(),d=c||u,h=t.getMaterial();if(h&&o.activeCamera){var p=t._getDrawWrapper(i),m=jn.E.GetEffect(p);a.enableEffect(p),h.useLogarithmicDepth&&m.setFloat("logarithmicDepthConstant",2/(Math.log(o.activeCamera.maxZ+1)/Math.LN2)),m.setFloat("offset",n?0:u.outlineWidth),m.setColor4("color",n?u.overlayColor:u.outlineColor,n?u.overlayAlpha:h.alpha),m.setMatrix("viewProjection",o.getTransformMatrix()),m.setMatrix("world",d.getWorldMatrix()),(0,Re.f$)(u,m),(0,Re.nR)(u,m),u.morphTargetManager&&u.morphTargetManager.isUsingTextureForTargets&&u.morphTargetManager._bind(m),s||u._bind(t,m,h.fillMode);var v=t.getMesh().bakedVertexAnimationManager;if(v&&v.isEnabled&&v.bind(m,s),h&&h.needAlphaTesting()){var b=h.getAlphaTestTexture();b&&(m.setTexture("diffuseSampler",b),m.setMatrix("diffuseMatrix",b.getTextureMatrix()))}(0,tn.gS)(m,h,o),a.setZOffset(-this.zOffset),a.setZOffsetUnits(-this.zOffsetUnits),u._processRendering(d,t,m,h.fillMode,e,s,function(E,C){m.setMatrix("world",C)}),a.setZOffset(0),a.setZOffsetUnits(0)}}},r.prototype.isReady=function(t,e,n){var i=this;n=n??this._passIdForDrawWrapper[0];var o=[],a=[Y.R.PositionKind,Y.R.NormalKind],s=t.getMesh(),l=t.getMaterial();if(!l)return!1;var c=s.getScene();l.needAlphaTesting()&&(o.push("#define ALPHATEST"),s.isVerticesDataPresent(Y.R.UVKind)&&(a.push(Y.R.UVKind),o.push("#define UV1")),s.isVerticesDataPresent(Y.R.UV2Kind)&&(a.push(Y.R.UV2Kind),o.push("#define UV2"))),l.useLogarithmicDepth&&o.push("#define LOGARITHMICDEPTH"),(0,tn.tv)(l,c,o);var u=new Tr;if(s.useBones&&s.computeBonesUsingShaders&&s.skeleton){a.push(Y.R.MatricesIndicesKind),a.push(Y.R.MatricesWeightsKind),s.numBoneInfluencers>4&&(a.push(Y.R.MatricesIndicesExtraKind),a.push(Y.R.MatricesWeightsExtraKind));var d=s.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),s.numBoneInfluencers>0&&u.addCPUSkinningFallback(0,s),d.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(d.bones.length+1))}else o.push("#define NUM_BONE_INFLUENCERS 0");var h=s.morphTargetManager,p=0;h&&(p=h.numMaxInfluencers||h.numInfluencers)>0&&(o.push("#define MORPHTARGETS"),o.push("#define NUM_MORPH_INFLUENCERS "+p),h.isUsingTextureForTargets&&o.push("#define MORPHTARGETS_TEXTURE"),(0,Re.MF)(a,s,p)),e&&(o.push("#define INSTANCES"),(0,Re.te)(a),t.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES"));var m=s.bakedVertexAnimationManager;m&&m.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),e&&a.push("bakedVertexAnimationSettingsInstanced"));var v=t._getDrawWrapper(n,!0),b=v.defines,E=o.join(`
|
||
`);if(b!==E){var C=["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences","boneTextureWidth","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"];(0,tn.TV)(C),v.setEffect(this.scene.getEngine().createEffect("outline",{attributes:a,uniformsNames:C,uniformBuffersNames:[],samplers:["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],defines:E,fallbacks:u,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:p},shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(i,void 0,void 0,function(){return(0,A.YH)(this,function(T){switch(T.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,61189)),Promise.resolve().then(L.bind(L,27179))])];case 1:return T.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,23338)),Promise.resolve().then(L.bind(L,18924))])];case 3:T.sent(),T.label=4;case 4:return[2]}})})}},this.scene.getEngine()),E)}return v.effect.isReady()},r.prototype._beforeRenderingMesh=function(t,e,n){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var i=e.getMaterial();i&&i.needAlphaBlendingForMesh(t)&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(P.Y.REPLACE),this._engine.setStencilFunction(P.Y.ALWAYS),this._engine.setStencilMask(r._StencilReference),this._engine.setStencilFunctionReference(r._StencilReference),this._engine.stencilStateComposer.useStencilGlobalOnly=!0,this.render(e,n,!0,this._passIdForDrawWrapper[1]),this._engine.setColorWrite(!0),this._engine.setStencilFunction(P.Y.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(e,n,!1,this._passIdForDrawWrapper[0]),this._engine.setDepthWrite(this._savedDepthWrite),i&&i.needAlphaBlendingForMesh(t)&&(this._engine.stencilStateComposer.useStencilGlobalOnly=!1,this._engine.restoreStencilState())}},r.prototype._afterRenderingMesh=function(t,e,n){if(t.renderOverlay){var i=this._engine.getAlphaMode(),o=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(P.Y.ALPHA_COMBINE),this.render(e,n,!0,this._passIdForDrawWrapper[3]),this._engine.setAlphaMode(i),this._engine.setDepthWrite(this._savedDepthWrite),this._engine.alphaState.alphaBlend=o}t.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(e,n,!1,this._passIdForDrawWrapper[2]),this._engine.setColorWrite(!0))},r._StencilReference=4,r}(),ZI=L(85043),jf=function(){function r(t,e){this.priority=0,this._particleSize=.1,this.onParticleSizeChanged=new K.cP,this.particleThicknessAlpha=.05,this._useVelocity=!1,this._shaderLanguage=0,this._scene=t,this._engine=t.getEngine(),this._effectsAreDirty=!0,this._depthEffectWrapper=null,this._thicknessEffectWrapper=null,this._shaderLanguage=e??(this._engine.isWebGPU?1:0)}return Object.defineProperty(r.prototype,"particleSize",{get:function(){return this._particleSize},set:function(t){t!==this._particleSize&&(this._particleSize=t,this.onParticleSizeChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useInstancing",{get:function(){return!this.indexBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useVelocity",{get:function(){return this._useVelocity},set:function(t){this._useVelocity!==t&&this._hasVelocity()&&(this._useVelocity=t,this._effectsAreDirty=!0)},enumerable:!1,configurable:!0}),r.prototype._hasVelocity=function(){var t;return!!(!((t=this.vertexBuffers)===null||t===void 0)&&t.velocity)},Object.defineProperty(r.prototype,"indexBuffer",{get:function(){return null},enumerable:!1,configurable:!0}),r.prototype.getClassName=function(){return"FluidRenderingObject"},Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._createEffects=function(){var t=this,e=["view","projection","particleRadius","size"],n=["position","offset"],i=[];this._effectsAreDirty=!1,this.useVelocity&&(n.push("velocity"),i.push("#define FLUIDRENDERING_VELOCITY")),this._scene.useRightHandedSystem&&i.push("#define FLUIDRENDERING_RHS"),this._depthEffectWrapper=new Ni.$({engine:this._engine,useShaderStore:!0,vertexShader:"fluidRenderingParticleDepth",fragmentShader:"fluidRenderingParticleDepth",attributeNames:n,uniformNames:e,samplerNames:[],defines:i,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(o){switch(o.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,64780)),Promise.resolve().then(L.bind(L,76138))])];case 1:return o.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,29687)),Promise.resolve().then(L.bind(L,18337))])];case 3:o.sent(),o.label=4;case 4:return[2]}})})}}),e.push("particleAlpha"),this._thicknessEffectWrapper=new Ni.$({engine:this._engine,useShaderStore:!0,vertexShader:"fluidRenderingParticleThickness",fragmentShader:"fluidRenderingParticleThickness",attributeNames:["position","offset"],uniformNames:e,samplerNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(t,void 0,void 0,function(){return(0,A.YH)(this,function(o){switch(o.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.all([Promise.resolve().then(L.bind(L,37113)),Promise.resolve().then(L.bind(L,2835))])];case 1:return o.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,55214)),Promise.resolve().then(L.bind(L,10151))])];case 3:o.sent(),o.label=4;case 4:return[2]}})})}})},r.prototype.isReady=function(){if(this._effectsAreDirty&&this._createEffects(),!this._depthEffectWrapper||!this._thicknessEffectWrapper)return!1;var t=this._depthEffectWrapper._drawWrapper.effect,e=this._thicknessEffectWrapper._drawWrapper.effect;return t.isReady()&&e.isReady()},r.prototype.renderDepthTexture=function(){var t=this.numParticles;if(this._depthEffectWrapper&&t!==0){var e=this._depthEffectWrapper._drawWrapper,n=e.effect;this._engine.enableEffect(e),this._engine.bindBuffers(this.vertexBuffers,this.indexBuffer,n),n.setMatrix("view",this._scene.getViewMatrix()),n.setMatrix("projection",this._scene.getProjectionMatrix()),n.setFloat2("size",this._particleSize,this._particleSize),n.setFloat("particleRadius",this._particleSize/2),this.useInstancing?this._engine.drawArraysType(P.Y.MATERIAL_TriangleStripDrawMode,0,4,t):this._engine.drawElementsType(P.Y.MATERIAL_TriangleFillMode,0,t)}},r.prototype.renderThicknessTexture=function(){var t=this.numParticles;if(this._thicknessEffectWrapper&&t!==0){var e=this._thicknessEffectWrapper._drawWrapper,n=e.effect;this._engine.setAlphaMode(P.Y.ALPHA_ONEONE),this._engine.setDepthWrite(!1),this._engine.enableEffect(e),this._engine.bindBuffers(this.vertexBuffers,this.indexBuffer,n),n.setMatrix("view",this._scene.getViewMatrix()),n.setMatrix("projection",this._scene.getProjectionMatrix()),n.setFloat("particleAlpha",this.particleThicknessAlpha),n.setFloat2("size",this._particleSize,this._particleSize),this.useInstancing?this._engine.drawArraysType(P.Y.MATERIAL_TriangleStripDrawMode,0,4,t):this._engine.drawElementsType(P.Y.MATERIAL_TriangleFillMode,0,t),this._engine.setDepthWrite(!0),this._engine.setAlphaMode(P.Y.ALPHA_DISABLE)}},r.prototype.renderDiffuseTexture=function(){},r.prototype.dispose=function(){var t,e;(t=this._depthEffectWrapper)===null||t===void 0||t.dispose(!1),(e=this._thicknessEffectWrapper)===null||e===void 0||e.dispose(!1)},r}(),PT=function(r){function t(e,n,i){var o=r.call(this,e,i)||this;return o._useTrueRenderingForDiffuseTexture=!0,o._particleSystem=n,o._originalRender=n.render.bind(n),o._blendMode=n.blendMode,o._onBeforeDrawParticleObserver=null,o._updateInAnimate=o._particleSystem.updateInAnimate,o._particleSystem.updateInAnimate=!0,o._particleSystem.render=function(){return 0},o.particleSize=(n.minSize+n.maxSize)/2,o.useTrueRenderingForDiffuseTexture=!1,o}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"particleSystem",{get:function(){return this._particleSystem},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"FluidRenderingObjectParticleSystem"},Object.defineProperty(t.prototype,"useTrueRenderingForDiffuseTexture",{get:function(){return this._useTrueRenderingForDiffuseTexture},set:function(e){var n=this;this._useTrueRenderingForDiffuseTexture!==e&&(this._useTrueRenderingForDiffuseTexture=e,e?(this._particleSystem.blendMode=this._blendMode,this._particleSystem.onBeforeDrawParticlesObservable.remove(this._onBeforeDrawParticleObserver),this._onBeforeDrawParticleObserver=null):(this._particleSystem.blendMode=-1,this._onBeforeDrawParticleObserver=this._particleSystem.onBeforeDrawParticlesObservable.add(function(){n._engine.setAlphaMode(P.Y.ALPHA_COMBINE)})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexBuffers",{get:function(){return this._particleSystem.vertexBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexBuffer",{get:function(){return this._particleSystem.indexBuffer},enumerable:!1,configurable:!0}),t.prototype.isReady=function(){return r.prototype.isReady.call(this)&&this._particleSystem.isReady()},Object.defineProperty(t.prototype,"numParticles",{get:function(){return this._particleSystem.getActiveCount()},enumerable:!1,configurable:!0}),t.prototype.renderDiffuseTexture=function(){this._originalRender()},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._particleSystem.onBeforeDrawParticlesObservable.remove(this._onBeforeDrawParticleObserver),this._onBeforeDrawParticleObserver=null,this._particleSystem.render=this._originalRender,this._particleSystem.blendMode=this._blendMode,this._particleSystem.updateInAnimate=this._updateInAnimate},t}(jf),AT=function(){function r(t,e,n,i,o,a,s,l,c,u,d,h,p,m,v){s===void 0&&(s=P.Y.TEXTURETYPE_FLOAT),l===void 0&&(l=P.Y.TEXTUREFORMAT_R),c===void 0&&(c=P.Y.TEXTURETYPE_FLOAT),u===void 0&&(u=P.Y.TEXTUREFORMAT_R),d===void 0&&(d=!1),h===void 0&&(h=null),p===void 0&&(p=!0),m===void 0&&(m=1),this.enableBlur=!0,this.blurSizeDivisor=1,this.blurFilterSize=7,this._blurNumIterations=3,this.blurMaxFilterSize=100,this.blurDepthScale=10,this.particleSize=.02,this.onDisposeObservable=new K.cP,this._shaderLanguage=0,this._name=t,this._scene=e,this._camera=h,this._engine=e.getEngine(),this._width=n,this._height=i,this._blurTextureSizeX=o,this._blurTextureSizeY=a,this._textureType=s,this._textureFormat=l,this._blurTextureType=c,this._blurTextureFormat=u,this._useStandardBlur=d,this._generateDepthBuffer=p,this._samples=m,this._postProcessRunningIndex=0,this.enableBlur=o!==0&&a!==0,this._rt=null,this._texture=null,this._rtBlur=null,this._textureBlurred=null,this._blurPostProcesses=null,this._shaderLanguage=v??(this._engine.isWebGPU?1:0)}return Object.defineProperty(r.prototype,"blurNumIterations",{get:function(){return this._blurNumIterations},set:function(t){if(this._blurNumIterations!==t&&(this._blurNumIterations=t,this._blurPostProcesses!==null)){var e=this._blurPostProcesses[0],n=this._blurPostProcesses[1];this._blurPostProcesses=[];for(var i=0;i<2*this._blurNumIterations;++i)this._blurPostProcesses[i]=1&i?n:e}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"renderTarget",{get:function(){return this._rt},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"renderTargetBlur",{get:function(){return this._rtBlur},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"texture",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"textureBlur",{get:function(){return this._textureBlurred},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype.initialize=function(){if(this.dispose(),this._createRenderTarget(),this.enableBlur&&this._texture){var t=this._createBlurPostProcesses(this._texture,this._blurTextureType,this._blurTextureFormat,this.blurSizeDivisor,this._name,this._useStandardBlur),e=t[0],n=t[1],i=t[2];this._rtBlur=e,this._textureBlurred=n,this._blurPostProcesses=i}},r.prototype.applyBlurPostProcesses=function(){this.enableBlur&&this._blurPostProcesses&&(this._postProcessRunningIndex=0,this._scene.postProcessManager.directRender(this._blurPostProcesses,this._rtBlur,!0),this._engine.unBindFramebuffer(this._rtBlur))},r.prototype._createRenderTarget=function(){this._rt=this._engine.createRenderTargetTexture({width:this._width,height:this._height},{generateMipMaps:!1,type:this._textureType,format:this._textureFormat,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:!1,samples:this._samples,label:"FluidRenderingRTT-".concat(this._name)});var t=this._rt.texture;t.incrementReferences(),this._texture=new Ie.g(null,this._scene),this._texture.name="rtt"+this._name,this._texture._texture=t,this._texture.wrapU=Ie.g.CLAMP_ADDRESSMODE,this._texture.wrapV=Ie.g.CLAMP_ADDRESSMODE,this._texture.anisotropicFilteringLevel=1},r.prototype._createBlurPostProcesses=function(t,e,n,i,o,a){var s=this;a===void 0&&(a=!1);var l=this._scene.getEngine(),c=new _.I9(Math.floor(this._blurTextureSizeX/i),Math.floor(this._blurTextureSizeY/i)),u=e===P.Y.TEXTURETYPE_FLOAT&&l.getCaps().textureFloatLinearFiltering||e===P.Y.TEXTURETYPE_HALF_FLOAT&&l.getCaps().textureHalfFloatLinearFiltering,d=this._engine.createRenderTargetTexture({width:c.x,height:c.y},{generateMipMaps:!1,type:e,format:n,samplingMode:u?P.Y.TEXTURE_BILINEAR_SAMPLINGMODE:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1,samples:this._samples,label:"FluidRenderingRTTBlur-".concat(o)}),h=d.texture;h.incrementReferences();var p=new Ie.g(null,this._scene);if(p.name="rttBlurred"+o,p._texture=h,p.wrapU=Ie.g.CLAMP_ADDRESSMODE,p.wrapV=Ie.g.CLAMP_ADDRESSMODE,p.anisotropicFilteringLevel=1,a){var m=new _t.w("BilateralBlurX","fluidRenderingStandardBlur",["filterSize","blurDir"],null,1,null,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,e,void 0,void 0,void 0,n,this._shaderLanguage,function(){return(0,A.sH)(s,void 0,void 0,function(){return(0,A.YH)(this,function(g){switch(g.label){case 0:return this.shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,52063))];case 1:return g.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,31298))];case 3:g.sent(),g.label=4;case 4:return[2]}})})});m.samples=this._samples,m.externalTextureSamplerBinding=!0,m.onApplyObservable.add(function(g){s._postProcessRunningIndex===0?g.setTexture("textureSampler",t):g._bindTexture("textureSampler",m.inputTexture.texture),g.setInt("filterSize",s.blurFilterSize),g.setFloat2("blurDir",1/s._blurTextureSizeX,0),s._postProcessRunningIndex++}),m.onSizeChangedObservable.add(function(){m._textures.forEach(function(g){g.texture.wrapU=Ie.g.CLAMP_ADDRESSMODE,g.texture.wrapV=Ie.g.CLAMP_ADDRESSMODE})}),this._fixReusablePostProcess(m);var v=new _t.w("BilateralBlurY","fluidRenderingStandardBlur",["filterSize","blurDir"],null,1,null,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,e,void 0,void 0,void 0,n,this._shaderLanguage,function(){return(0,A.sH)(s,void 0,void 0,function(){return(0,A.YH)(this,function(g){switch(g.label){case 0:return this.shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,52063))];case 1:return g.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,31298))];case 3:g.sent(),g.label=4;case 4:return[2]}})})});v.samples=this._samples,v.onApplyObservable.add(function(g){g.setInt("filterSize",s.blurFilterSize),g.setFloat2("blurDir",0,1/s._blurTextureSizeY),s._postProcessRunningIndex++}),v.onSizeChangedObservable.add(function(){v._textures.forEach(function(g){g.texture.wrapU=Ie.g.CLAMP_ADDRESSMODE,g.texture.wrapV=Ie.g.CLAMP_ADDRESSMODE})}),this._fixReusablePostProcess(v),m.autoClear=!1,v.autoClear=!1;for(var b=[],E=0;E<2*this._blurNumIterations;++E)b[E]=1&E?v:m;return[d,p,b]}var C=["maxFilterSize","blurDir","projectedParticleConstant","depthThreshold"],T=new _t.w("BilateralBlurX","fluidRenderingBilateralBlur",C,null,1,null,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,e,void 0,void 0,void 0,n,this._shaderLanguage,function(){return(0,A.sH)(s,void 0,void 0,function(){return(0,A.YH)(this,function(g){switch(g.label){case 0:return this.shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,7060))];case 1:return g.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,48063))];case 3:g.sent(),g.label=4;case 4:return[2]}})})});T.samples=this._samples,T.externalTextureSamplerBinding=!0,T.onApplyObservable.add(function(g){s._postProcessRunningIndex===0?g.setTexture("textureSampler",t):g._bindTexture("textureSampler",T.inputTexture.texture),g.setInt("maxFilterSize",s.blurMaxFilterSize),g.setFloat2("blurDir",1/s._blurTextureSizeX,0),g.setFloat("projectedParticleConstant",s._getProjectedParticleConstant()),g.setFloat("depthThreshold",s._getDepthThreshold()),s._postProcessRunningIndex++}),T.onSizeChangedObservable.add(function(){T._textures.forEach(function(g){g.texture.wrapU=Ie.g.CLAMP_ADDRESSMODE,g.texture.wrapV=Ie.g.CLAMP_ADDRESSMODE})}),this._fixReusablePostProcess(T);var f=new _t.w("BilateralBlurY","fluidRenderingBilateralBlur",C,null,1,null,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,l,!0,null,e,void 0,void 0,void 0,n,this._shaderLanguage,function(){return(0,A.sH)(s,void 0,void 0,function(){return(0,A.YH)(this,function(g){switch(g.label){case 0:return this.shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,7060))];case 1:return g.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,48063))];case 3:g.sent(),g.label=4;case 4:return[2]}})})});for(f.samples=this._samples,f.onApplyObservable.add(function(g){g.setInt("maxFilterSize",s.blurMaxFilterSize),g.setFloat2("blurDir",0,1/s._blurTextureSizeY),g.setFloat("projectedParticleConstant",s._getProjectedParticleConstant()),g.setFloat("depthThreshold",s._getDepthThreshold()),s._postProcessRunningIndex++}),f.onSizeChangedObservable.add(function(){f._textures.forEach(function(g){g.texture.wrapU=Ie.g.CLAMP_ADDRESSMODE,g.texture.wrapV=Ie.g.CLAMP_ADDRESSMODE})}),this._fixReusablePostProcess(f),T.autoClear=!1,f.autoClear=!1,b=[],E=0;E<2*this._blurNumIterations;++E)b[E]=1&E?f:T;return[d,p,b]},r.prototype._fixReusablePostProcess=function(t){t.isReusable()&&(t.onActivateObservable.add(function(){t._currentRenderTextureInd=(t._currentRenderTextureInd+1)%2}),t.onApplyObservable.add(function(){t._currentRenderTextureInd=(t._currentRenderTextureInd+1)%2}))},r.prototype._getProjectedParticleConstant=function(){var t,e;return this.blurFilterSize*this.particleSize*.05*(this._height/2)/Math.tan(((e=(t=this._camera)===null||t===void 0?void 0:t.fov)!==null&&e!==void 0?e:45*Math.PI/180)/2)},r.prototype._getDepthThreshold=function(){return this.particleSize/2*this.blurDepthScale},r.prototype.dispose=function(){var t,e,n,i;this.onDisposeObservable.hasObservers()&&this.onDisposeObservable.notifyObservers(this),(t=this._rt)===null||t===void 0||t.dispose(),this._rt=null,(e=this._texture)===null||e===void 0||e.dispose(),this._texture=null,(n=this._rtBlur)===null||n===void 0||n.dispose(),this._rtBlur=null,(i=this._textureBlurred)===null||i===void 0||i.dispose(),this._textureBlurred=null,this._blurPostProcesses&&(this._blurPostProcesses[0].dispose(),this._blurPostProcesses[1].dispose()),this._blurPostProcesses=null},r}();(function(r){r[r.DepthTexture=0]="DepthTexture",r[r.DepthBlurredTexture=1]="DepthBlurredTexture",r[r.ThicknessTexture=2]="ThicknessTexture",r[r.ThicknessBlurredTexture=3]="ThicknessBlurredTexture",r[r.DiffuseTexture=4]="DiffuseTexture",r[r.Normals=5]="Normals",r[r.DiffuseRendering=6]="DiffuseRendering"})(Xf||(Xf={}));var qf,Kf=function(){function r(t,e,n){this._generateDiffuseTexture=!1,this.fluidColor=new z.v9(.085,.6375,.765),this.density=2,this.refractionStrength=.1,this.fresnelClamp=1,this.specularPower=250,this.minimumThickness=0,this.dirLight=new _.Pq(-2,-1,1).normalize(),this._debugFeature=1,this._debug=!1,this._enableBlurDepth=!0,this._blurDepthSizeDivisor=1,this._blurDepthFilterSize=7,this._blurDepthNumIterations=3,this._blurDepthMaxFilterSize=100,this._blurDepthDepthScale=10,this._enableBlurThickness=!0,this._blurThicknessSizeDivisor=1,this._blurThicknessFilterSize=5,this._blurThicknessNumIterations=1,this._useFixedThickness=!1,this._onUseVelocityChanged=new K.cP,this._useVelocity=!1,this._depthMapSize=null,this._thicknessMapSize=null,this._diffuseMapSize=null,this._samples=1,this._compositeMode=!1,this._shaderLanguage=0,this._scene=t,this._engine=t.getEngine(),this._camera=e??t.activeCamera,this._needInitialization=!0,this._bgDepthTexture=null,this._invProjectionMatrix=new _.uq,this._depthClearColor=new z.ov(1e6,1e6,1e6,1),this._thicknessClearColor=new z.ov(0,0,0,1),this._depthRenderTarget=null,this._diffuseRenderTarget=null,this._thicknessRenderTarget=null,this._renderPostProcess=null,this._shaderLanguage=n??(this._engine.isWebGPU?1:0)}return Object.defineProperty(r.prototype,"needInitialization",{get:function(){return this._needInitialization},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"generateDiffuseTexture",{get:function(){return this._generateDiffuseTexture},set:function(t){this._generateDiffuseTexture!==t&&(this._generateDiffuseTexture=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"debugFeature",{get:function(){return this._debugFeature},set:function(t){this._debugFeature!==t&&(this._needInitialization=!0,this._debugFeature=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"debug",{get:function(){return this._debug},set:function(t){this._debug!==t&&(this._debug=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"environmentMap",{get:function(){return this._environmentMap},set:function(t){this._environmentMap!==t&&(this._needInitialization=!0,this._environmentMap=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableBlurDepth",{get:function(){return this._enableBlurDepth},set:function(t){this._enableBlurDepth!==t&&(this._enableBlurDepth=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurDepthSizeDivisor",{get:function(){return this._blurDepthSizeDivisor},set:function(t){this._blurDepthSizeDivisor!==t&&(this._blurDepthSizeDivisor=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurDepthFilterSize",{get:function(){return this._blurDepthFilterSize},set:function(t){this._blurDepthFilterSize!==t&&(this._blurDepthFilterSize=t,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurDepthNumIterations",{get:function(){return this._blurDepthNumIterations},set:function(t){this._blurDepthNumIterations!==t&&(this._blurDepthNumIterations=t,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurDepthMaxFilterSize",{get:function(){return this._blurDepthMaxFilterSize},set:function(t){this._blurDepthMaxFilterSize!==t&&(this._blurDepthMaxFilterSize=t,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurDepthDepthScale",{get:function(){return this._blurDepthDepthScale},set:function(t){this._blurDepthDepthScale!==t&&(this._blurDepthDepthScale=t,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableBlurThickness",{get:function(){return this._enableBlurThickness},set:function(t){this._enableBlurThickness!==t&&(this._enableBlurThickness=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurThicknessSizeDivisor",{get:function(){return this._blurThicknessSizeDivisor},set:function(t){this._blurThicknessSizeDivisor!==t&&(this._blurThicknessSizeDivisor=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurThicknessFilterSize",{get:function(){return this._blurThicknessFilterSize},set:function(t){this._blurThicknessFilterSize!==t&&(this._blurThicknessFilterSize=t,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"blurThicknessNumIterations",{get:function(){return this._blurThicknessNumIterations},set:function(t){this._blurThicknessNumIterations!==t&&(this._blurThicknessNumIterations=t,this._setBlurParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useFixedThickness",{get:function(){return this._useFixedThickness},set:function(t){this._useFixedThickness!==t&&(this._useFixedThickness=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useVelocity",{get:function(){return this._useVelocity},set:function(t){this._useVelocity!==t&&(this._useVelocity=t,this._needInitialization=!0,this._onUseVelocityChanged.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"depthMapSize",{get:function(){return this._depthMapSize},set:function(t){this._depthMapSize!==t&&(this._depthMapSize=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"thicknessMapSize",{get:function(){return this._thicknessMapSize},set:function(t){this._thicknessMapSize!==t&&(this._thicknessMapSize=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"diffuseMapSize",{get:function(){return this._diffuseMapSize},set:function(t){this._diffuseMapSize!==t&&(this._diffuseMapSize=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"samples",{get:function(){return this._samples},set:function(t){this._samples!==t&&(this._samples=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"compositeMode",{get:function(){return this._compositeMode},set:function(t){this._compositeMode!==t&&(this._compositeMode=t,this._needInitialization=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"camera",{get:function(){return this._camera},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._initialize=function(){var t,e,n;this.dispose(),this._needInitialization=!1;var i=(t=this._depthMapSize)!==null&&t!==void 0?t:this._engine.getRenderWidth(),o=this._depthMapSize!==null?Math.round(this._depthMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();if(this._depthRenderTarget=new AT("Depth",this._scene,i,o,i,o,P.Y.TEXTURETYPE_FLOAT,P.Y.TEXTUREFORMAT_RG,P.Y.TEXTURETYPE_FLOAT,P.Y.TEXTUREFORMAT_RG,!1,this._camera,!0,this._samples,this._shaderLanguage),this._initializeRenderTarget(this._depthRenderTarget),this.generateDiffuseTexture){var a=(e=this._diffuseMapSize)!==null&&e!==void 0?e:this._engine.getRenderWidth(),s=this._diffuseMapSize!==null?Math.round(this._diffuseMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();this._diffuseRenderTarget=new AT("Diffuse",this._scene,a,s,0,0,P.Y.TEXTURETYPE_UNSIGNED_BYTE,P.Y.TEXTUREFORMAT_RGBA,P.Y.TEXTURETYPE_UNSIGNED_BYTE,P.Y.TEXTUREFORMAT_RGBA,!0,this._camera,!0,this._samples,this._shaderLanguage),this._initializeRenderTarget(this._diffuseRenderTarget)}var l=(n=this._thicknessMapSize)!==null&&n!==void 0?n:this._engine.getRenderWidth(),c=this._thicknessMapSize!==null?Math.round(this._thicknessMapSize*this._engine.getRenderHeight()/this._engine.getRenderWidth()):this._engine.getRenderHeight();this._useFixedThickness||(this._thicknessRenderTarget=new AT("Thickness",this._scene,l,c,l,c,P.Y.TEXTURETYPE_HALF_FLOAT,P.Y.TEXTUREFORMAT_R,P.Y.TEXTURETYPE_HALF_FLOAT,P.Y.TEXTUREFORMAT_R,!0,this._camera,!1,this._samples,this._shaderLanguage),this._initializeRenderTarget(this._thicknessRenderTarget)),this._createLiquidRenderingPostProcess()},r.prototype._setBlurParameters=function(t){t===void 0&&(t=null),t!==null&&t!==this._depthRenderTarget||this._setBlurDepthParameters(),t!==null&&t!==this._thicknessRenderTarget||this._setBlurThicknessParameters()},r.prototype._setBlurDepthParameters=function(){this._depthRenderTarget&&(this._depthRenderTarget.blurFilterSize=this.blurDepthFilterSize,this._depthRenderTarget.blurMaxFilterSize=this.blurDepthMaxFilterSize,this._depthRenderTarget.blurNumIterations=this.blurDepthNumIterations,this._depthRenderTarget.blurDepthScale=this.blurDepthDepthScale)},r.prototype._setBlurThicknessParameters=function(){this._thicknessRenderTarget&&(this._thicknessRenderTarget.blurFilterSize=this.blurThicknessFilterSize,this._thicknessRenderTarget.blurNumIterations=this.blurThicknessNumIterations)},r.prototype._initializeRenderTarget=function(t){t!==this._diffuseRenderTarget&&(t.enableBlur=t===this._depthRenderTarget?this.enableBlurDepth:this.enableBlurThickness,t.blurSizeDivisor=t===this._depthRenderTarget?this.blurDepthSizeDivisor:this.blurThicknessSizeDivisor),this._setBlurParameters(t),t.initialize()},r.prototype._createLiquidRenderingPostProcess=function(){var t,e=this,n=this._scene.getEngine(),i=["viewMatrix","projectionMatrix","invProjectionMatrix","texelSize","dirLight","cameraFar","density","refractionStrength","fresnelClamp","specularPower"],o=["depthSampler"],a=[];if(this.dispose(!0),this._camera){var s=this._depthRenderTarget.enableBlur?this._depthRenderTarget.textureBlur:this._depthRenderTarget.texture,l=new _.I9(1/s.getSize().width,1/s.getSize().height);this._scene.useRightHandedSystem&&a.push("#define FLUIDRENDERING_RHS"),this._environmentMap!==null&&((t=this._environmentMap)!==null&&t!==void 0?t:this._scene.environmentTexture)&&(o.push("reflectionSampler"),a.push("#define FLUIDRENDERING_ENVIRONMENT")),this._diffuseRenderTarget?(o.push("diffuseSampler"),a.push("#define FLUIDRENDERING_DIFFUSETEXTURE")):i.push("diffuseColor"),this._useVelocity&&(o.push("velocitySampler"),a.push("#define FLUIDRENDERING_VELOCITY")),this._useFixedThickness?(i.push("thickness"),o.push("bgDepthSampler"),a.push("#define FLUIDRENDERING_FIXED_THICKNESS")):(i.push("minimumThickness"),o.push("thicknessSampler")),this._compositeMode&&a.push("#define FLUIDRENDERING_COMPOSITE_MODE"),this._debug&&(a.push("#define FLUIDRENDERING_DEBUG"),this._debugFeature===5?a.push("#define FLUIDRENDERING_DEBUG_SHOWNORMAL"):this._debugFeature===6?a.push("#define FLUIDRENDERING_DEBUG_DIFFUSERENDERING"):(a.push("#define FLUIDRENDERING_DEBUG_TEXTURE"),o.push("debugSampler"),this._debugFeature!==0&&this._debugFeature!==1||a.push("#define FLUIDRENDERING_DEBUG_DEPTH"))),this._renderPostProcess=new _t.w("FluidRendering","fluidRenderingRender",i,o,1,null,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,n,!1,null,P.Y.TEXTURETYPE_UNSIGNED_BYTE,void 0,void 0,!0,void 0,this._shaderLanguage,function(){return(0,A.sH)(e,void 0,void 0,function(){return(0,A.YH)(this,function(d){switch(d.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,94727))];case 1:return d.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,36870))];case 3:d.sent(),d.label=4;case 4:return[2]}})})}),this._renderPostProcess.updateEffect(a.join(`
|
||
`)),this._renderPostProcess.samples=this._samples;var c=n,u=c.setTextureSampler;this._renderPostProcess.onApplyObservable.add(function(d){var h,p,m,v,b,E,C,T,f,g,S,y,x,R,I,M,D,B,F,X,$,Q,ie;if(e._invProjectionMatrix.copyFrom(e._scene.getProjectionMatrix()),e._invProjectionMatrix.invert(),u&&u.call(c,"textureSamplerSampler",e._renderPostProcess.inputTexture.texture),e._depthRenderTarget.enableBlur?(d.setTexture("depthSampler",e._depthRenderTarget.textureBlur),u&&u.call(c,"depthSamplerSampler",(v=(m=e._depthRenderTarget.textureBlur)===null||m===void 0?void 0:m.getInternalTexture())!==null&&v!==void 0?v:null)):(d.setTexture("depthSampler",e._depthRenderTarget.texture),u&&u.call(c,"depthSamplerSampler",(p=(h=e._depthRenderTarget.texture)===null||h===void 0?void 0:h.getInternalTexture())!==null&&p!==void 0?p:null)),e._diffuseRenderTarget?e._diffuseRenderTarget.enableBlur?(d.setTexture("diffuseSampler",e._diffuseRenderTarget.textureBlur),u&&u.call(c,"diffuseSamplerSampler",(T=(C=e._diffuseRenderTarget.textureBlur)===null||C===void 0?void 0:C.getInternalTexture())!==null&&T!==void 0?T:null)):(d.setTexture("diffuseSampler",e._diffuseRenderTarget.texture),u&&u.call(c,"diffuseSamplerSampler",(E=(b=e._diffuseRenderTarget.texture)===null||b===void 0?void 0:b.getInternalTexture())!==null&&E!==void 0?E:null)):d.setColor3("diffuseColor",e.fluidColor),e._useFixedThickness?(d.setFloat("thickness",e.minimumThickness),d._bindTexture("bgDepthSampler",e._bgDepthTexture),u&&u.call(c,"bgDepthSamplerSampler",(f=e._bgDepthTexture)!==null&&f!==void 0?f:null)):(e._thicknessRenderTarget.enableBlur?(d.setTexture("thicknessSampler",e._thicknessRenderTarget.textureBlur),u&&u.call(c,"thicknessSamplerSampler",(x=(y=e._thicknessRenderTarget.textureBlur)===null||y===void 0?void 0:y.getInternalTexture())!==null&&x!==void 0?x:null)):(d.setTexture("thicknessSampler",e._thicknessRenderTarget.texture),u&&u.call(c,"thicknessSamplerSampler",(S=(g=e._thicknessRenderTarget.texture)===null||g===void 0?void 0:g.getInternalTexture())!==null&&S!==void 0?S:null)),d.setFloat("minimumThickness",e.minimumThickness)),e._environmentMap!==null){var q=(R=e._environmentMap)!==null&&R!==void 0?R:e._scene.environmentTexture;q&&(d.setTexture("reflectionSampler",q),u&&u.call(c,"reflectionSamplerSampler",(I=q?.getInternalTexture())!==null&&I!==void 0?I:null))}if(d.setMatrix("viewMatrix",e._scene.getViewMatrix()),d.setMatrix("invProjectionMatrix",e._invProjectionMatrix),d.setMatrix("projectionMatrix",e._scene.getProjectionMatrix()),d.setVector2("texelSize",l),d.setFloat("density",e.density),d.setFloat("refractionStrength",e.refractionStrength),d.setFloat("fresnelClamp",e.fresnelClamp),d.setFloat("specularPower",e.specularPower),d.setVector3("dirLight",e.dirLight),d.setFloat("cameraFar",e._camera.maxZ),e._debug){var ee=null;switch(e._debugFeature){case 0:ee=e._depthRenderTarget.texture;break;case 1:ee=e._depthRenderTarget.enableBlur?e._depthRenderTarget.textureBlur:e._depthRenderTarget.texture;break;case 2:ee=(D=(M=e._thicknessRenderTarget)===null||M===void 0?void 0:M.texture)!==null&&D!==void 0?D:null;break;case 3:ee=!((B=e._thicknessRenderTarget)===null||B===void 0)&&B.enableBlur?(X=(F=e._thicknessRenderTarget)===null||F===void 0?void 0:F.textureBlur)!==null&&X!==void 0?X:null:(Q=($=e._thicknessRenderTarget)===null||$===void 0?void 0:$.texture)!==null&&Q!==void 0?Q:null;break;case 4:e._diffuseRenderTarget&&(ee=e._diffuseRenderTarget.texture)}e._debugFeature!==5&&(d.setTexture("debugSampler",ee),u&&u.call(c,"debugSamplerSampler",(ie=ee?.getInternalTexture())!==null&&ie!==void 0?ie:null))}})}},r.prototype._clearTargets=function(){var t,e,n;!((t=this._depthRenderTarget)===null||t===void 0)&&t.renderTarget&&(this._engine.bindFramebuffer(this._depthRenderTarget.renderTarget),this._engine.clear(this._depthClearColor,!0,!0,!1),this._engine.unBindFramebuffer(this._depthRenderTarget.renderTarget)),!((e=this._diffuseRenderTarget)===null||e===void 0)&&e.renderTarget&&(this._engine.bindFramebuffer(this._diffuseRenderTarget.renderTarget),this._engine.clear(this._thicknessClearColor,!0,!0,!1),this._engine.unBindFramebuffer(this._diffuseRenderTarget.renderTarget)),!((n=this._thicknessRenderTarget)===null||n===void 0)&&n.renderTarget&&(this._engine.bindFramebuffer(this._thicknessRenderTarget.renderTarget),this._engine.clear(this._thicknessClearColor,!0,!1,!1),this._engine.unBindFramebuffer(this._thicknessRenderTarget.renderTarget))},r.prototype._render=function(t){var e,n,i,o,a,s;if(!this._needInitialization&&t.isReady()){var l=this._engine._currentRenderTarget;this._engine.setState(!1,void 0,void 0,void 0,!0),this._engine.setDepthBuffer(!0),this._engine.setDepthWrite(!0),this._engine.setAlphaMode(P.Y.ALPHA_DISABLE),!((e=this._depthRenderTarget)===null||e===void 0)&&e.renderTarget&&(this._engine.bindFramebuffer(this._depthRenderTarget.renderTarget),t.renderDepthTexture(),this._engine.unbindInstanceAttributes(),this._engine.unBindFramebuffer(this._depthRenderTarget.renderTarget)),!((n=this._diffuseRenderTarget)===null||n===void 0)&&n.renderTarget&&(this._engine.bindFramebuffer(this._diffuseRenderTarget.renderTarget),t.renderDiffuseTexture(),this._engine.unbindInstanceAttributes(),this._engine.unBindFramebuffer(this._diffuseRenderTarget.renderTarget)),!((i=this._thicknessRenderTarget)===null||i===void 0)&&i.renderTarget&&(this._engine.bindFramebuffer(this._thicknessRenderTarget.renderTarget),t.renderThicknessTexture(),this._engine.unbindInstanceAttributes(),this._engine.unBindFramebuffer(this._thicknessRenderTarget.renderTarget)),(o=this._depthRenderTarget)===null||o===void 0||o.applyBlurPostProcesses(),(a=this._diffuseRenderTarget)===null||a===void 0||a.applyBlurPostProcesses(),(s=this._thicknessRenderTarget)===null||s===void 0||s.applyBlurPostProcesses(),l&&this._engine.bindFramebuffer(l)}},r.prototype.dispose=function(t){var e,n,i,o;t===void 0&&(t=!1),t||((e=this._depthRenderTarget)===null||e===void 0||e.dispose(),this._depthRenderTarget=null,(n=this._diffuseRenderTarget)===null||n===void 0||n.dispose(),this._diffuseRenderTarget=null,(i=this._thicknessRenderTarget)===null||i===void 0||i.dispose(),this._thicknessRenderTarget=null),this._renderPostProcess&&this._camera&&this._camera.detachPostProcess(this._renderPostProcess),(o=this._renderPostProcess)===null||o===void 0||o.dispose(),this._renderPostProcess=null,this._needInitialization=!1},r}(),CT=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a._numParticles=i,a._diffuseEffectWrapper=null,a._vertexBuffers={},a.addBuffers(n),a}return(0,A.C6)(t,r),t.prototype.getClassName=function(){return"FluidRenderingObjectCustomParticles"},Object.defineProperty(t.prototype,"vertexBuffers",{get:function(){return this._vertexBuffers},enumerable:!1,configurable:!0}),t.prototype.addBuffers=function(e){for(var n in e){var i=void 0,o=!0;switch(n){case"velocity":i=3;break;case"offset":o=!1}this._vertexBuffers[n]=new Y.R(this._engine,e[n],n,!0,!1,i,o)}},t.prototype._createEffects=function(){var e=this;r.prototype._createEffects.call(this),this._diffuseEffectWrapper=new Ni.$({engine:this._engine,useShaderStore:!0,vertexShader:"fluidRenderingParticleDiffuse",fragmentShader:"fluidRenderingParticleDiffuse",attributeNames:["position","offset","color"],uniformNames:["view","projection","size"],samplerNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:function(){return(0,A.sH)(e,void 0,void 0,function(){return(0,A.YH)(this,function(n){switch(n.label){case 0:return this._shaderLanguage!==1?[3,2]:[4,Promise.resolve().then(L.bind(L,70183))];case 1:return n.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,45868))];case 3:n.sent(),n.label=4;case 4:return[2]}})})}})},t.prototype.isReady=function(){var e,n;return this._vertexBuffers.offset||(this._vertexBuffers.offset=new Y.R(this._engine,[0,0,1,0,0,1,1,1],"offset",!1,!1,2)),r.prototype.isReady.call(this)&&(n=(e=this._diffuseEffectWrapper)===null||e===void 0?void 0:e.effect.isReady())!==null&&n!==void 0&&n},Object.defineProperty(t.prototype,"numParticles",{get:function(){return this._numParticles},enumerable:!1,configurable:!0}),t.prototype.setNumParticles=function(e){this._numParticles=e},t.prototype.renderDiffuseTexture=function(){var e=this.numParticles;if(this._diffuseEffectWrapper&&e!==0){var n=this._diffuseEffectWrapper._drawWrapper,i=n.effect;this._engine.enableEffect(n),this._engine.bindBuffers(this.vertexBuffers,this.indexBuffer,i),i.setMatrix("view",this._scene.getViewMatrix()),i.setMatrix("projection",this._scene.getProjectionMatrix()),this._particleSize!==null&&i.setFloat2("size",this._particleSize,this._particleSize),this.useInstancing?this._engine.drawArraysType(P.Y.MATERIAL_TriangleStripDrawMode,0,4,e):this._engine.drawElementsType(P.Y.MATERIAL_TriangleFillMode,0,e)}},t.prototype.dispose=function(){var e;for(var n in r.prototype.dispose.call(this),(e=this._diffuseEffectWrapper)===null||e===void 0||e.dispose(),this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers={}},t}(jf);(function(r){r[r.None=0]="None",r[r.ToLinearSpace=1]="ToLinearSpace",r[r.ToGammaSpace=2]="ToGammaSpace"})(qf||(qf={}));var RT=function(){function r(t,e){e===void 0&&(e=!1),this._shaderLanguage=0,this._shadersLoaded=!1,this._engine=t,this._isDepthTexture=e,this._renderer=new Ni.J(t),this._initShaderSourceAsync(e)}return Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype._textureIsInternal=function(t){return t.getInternalTexture===void 0},r.prototype._initShaderSourceAsync=function(t){return(0,A.sH)(this,void 0,void 0,function(){var e,n=this;return(0,A.YH)(this,function(i){switch(i.label){case 0:return(e=this._engine).isWebGPU?(this._shaderLanguage=1,[4,Promise.resolve().then(L.bind(L,70051))]):[3,2];case 1:return i.sent(),[3,4];case 2:return[4,Promise.resolve().then(L.bind(L,18778))];case 3:i.sent(),i.label=4;case 4:return this._shadersLoaded=!0,this._effectWrapper=new Ni.$({engine:e,name:"CopyTextureToTexture",fragmentShader:"copyTextureToTexture",useShaderStore:!0,uniformNames:["conversion"],samplerNames:["textureSampler"],defines:t?["#define DEPTH_TEXTURE"]:[],shaderLanguage:this._shaderLanguage}),this._effectWrapper.onApplyObservable.add(function(){t&&(e.setState(!1),e.setDepthBuffer(!0),e.depthCullingState.depthMask=!0,e.depthCullingState.depthFunc=P.Y.ALWAYS),n._textureIsInternal(n._source)?n._effectWrapper.effect._bindTexture("textureSampler",n._source):n._effectWrapper.effect.setTexture("textureSampler",n._source),n._effectWrapper.effect.setFloat("conversion",n._conversion)}),[2]}})})},r.prototype.isReady=function(){return this._shadersLoaded&&this._effectWrapper.effect.isReady()},r.prototype.copy=function(t,e,n){if(n===void 0&&(n=0),!this.isReady())return!1;this._source=t,this._conversion=n;var i=this._engine.depthCullingState.depthFunc;return this._renderer.render(this._effectWrapper,e),this._isDepthTexture&&i&&(this._engine.depthCullingState.depthFunc=i),!0},r.prototype.dispose=function(){this._effectWrapper.dispose(),this._renderer.dispose()},r}(),GN=function(){function r(t,e,n,i){i===void 0&&(i=1),this._engine=t,this._copyTextureToTexture=new RT(t,!0),this._depthRTWrapper=this._engine.createRenderTargetTexture({width:e,height:n},{generateMipMaps:!1,type:P.Y.TEXTURETYPE_UNSIGNED_BYTE,format:P.Y.TEXTUREFORMAT_R,samplingMode:P.Y.TEXTURE_NEAREST_SAMPLINGMODE,generateDepthBuffer:!0,generateStencilBuffer:!1,samples:i,noColorAttachment:!0,label:"FluidRenderingDepthTextureCopyRTT"}),this._depthRTWrapper.createDepthStencilTexture(0,!1,!1,1,void 0,"FluidRenderingDepthTextureCopyRTTDepthStencil").label="FluidDepthTextureCopy".concat(e,"x").concat(n,"x").concat(i)}return Object.defineProperty(r.prototype,"depthRTWrapper",{get:function(){return this._depthRTWrapper},enumerable:!1,configurable:!0}),r.prototype.copy=function(t){return this._copyTextureToTexture.copy(t,this._depthRTWrapper)},r.prototype.dispose=function(){this._depthRTWrapper.dispose(),this._copyTextureToTexture.dispose()},r}();function kN(r){return!!r.particleSystem}function zN(r){return!!r.addBuffers}Object.defineProperty(ke.Z.prototype,"fluidRenderer",{get:function(){return this._fluidRenderer},set:function(r){this._fluidRenderer=r},enumerable:!0,configurable:!0}),ke.Z.prototype.enableFluidRenderer=function(){return this._fluidRenderer||(this._fluidRenderer=new MT(this)),this._fluidRenderer},ke.Z.prototype.disableFluidRenderer=function(){var r;(r=this._fluidRenderer)===null||r===void 0||r.dispose(),this._fluidRenderer=null};var IT=function(){function r(t){this.name=lt.v.NAME_FLUIDRENDERER,this.scene=t}return r.prototype.register=function(){this.scene._gatherActiveCameraRenderTargetsStage.registerStep(lt.v.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER,this,this._gatherActiveCameraRenderTargets),this.scene._afterCameraDrawStage.registerStep(lt.v.STEP_AFTERCAMERADRAW_FLUIDRENDERER,this,this._afterCameraDraw)},r.prototype._gatherActiveCameraRenderTargets=function(t){var e;(e=this.scene.fluidRenderer)===null||e===void 0||e._prepareRendering()},r.prototype._afterCameraDraw=function(t){var e;(e=this.scene.fluidRenderer)===null||e===void 0||e._render(t)},r.prototype.rebuild=function(){var t=this.scene.fluidRenderer;if(t){for(var e=new Set,n=0;n<t.renderObjects.length;++n){var i=t.renderObjects[n].object;if(zN(i)){var o=i.vertexBuffers;for(var a in o)e.add(o[a].getWrapperBuffer())}}e.forEach(function(s){s._rebuild()})}},r.prototype.dispose=function(){this.scene.disableFluidRenderer()},r}(),MT=function(){function r(t){var e=this;this._shaderLanguage=0,this._scene=t,this._engine=t.getEngine(),this._onEngineResizeObserver=null,this.renderObjects=[],this.targetRenderers=[],this._cameras=new Map,r._SceneComponentInitialization(this._scene),this._onEngineResizeObserver=this._engine.onResizeObservable.add(function(){e._initialize()}),this._engine.isWebGPU&&(this._shaderLanguage=1)}return r._SceneComponentInitialization=function(t){var e=t._getComponent(lt.v.NAME_FLUIDRENDERER);e||(e=new IT(t),t._addComponent(e))},Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),r.prototype.recreate=function(){this._sortRenderingObjects(),this._initialize()},r.prototype.getRenderObjectFromParticleSystem=function(t){var e=this._getParticleSystemIndex(t);return e!==-1?this.renderObjects[e]:null},r.prototype.addParticleSystem=function(t,e,n,i){var o=this,a=new PT(this._scene,t,this._shaderLanguage);a.onParticleSizeChanged.add(function(){return o._setParticleSizeForRenderTargets()}),n||(n=new Kf(this._scene,i,this._shaderLanguage),this.targetRenderers.push(n)),n._onUseVelocityChanged.hasObservers()||n._onUseVelocityChanged.add(function(){return o._setUseVelocityForRenderObject()}),e!==void 0&&(n.generateDiffuseTexture=e);var s={object:a,targetRenderer:n};return this.renderObjects.push(s),this._sortRenderingObjects(),this._setParticleSizeForRenderTargets(),s},r.prototype.addCustomParticles=function(t,e,n,i,o){var a=this,s=new CT(this._scene,t,e,this._shaderLanguage);s.onParticleSizeChanged.add(function(){return a._setParticleSizeForRenderTargets()}),i||(i=new Kf(this._scene,o,this._shaderLanguage),this.targetRenderers.push(i)),i._onUseVelocityChanged.hasObservers()||i._onUseVelocityChanged.add(function(){return a._setUseVelocityForRenderObject()}),n!==void 0&&(i.generateDiffuseTexture=n);var l={object:s,targetRenderer:i};return this.renderObjects.push(l),this._sortRenderingObjects(),this._setParticleSizeForRenderTargets(),l},r.prototype.removeRenderObject=function(t,e){e===void 0&&(e=!0);var n=this.renderObjects.indexOf(t);return n!==-1&&(t.object.dispose(),this.renderObjects.splice(n,1),e&&this._removeUnusedTargetRenderers()?this._initialize():this._setParticleSizeForRenderTargets(),!0)},r.prototype._sortRenderingObjects=function(){this.renderObjects.sort(function(t,e){return t.object.priority<e.object.priority?-1:t.object.priority>e.object.priority?1:0})},r.prototype._removeUnusedTargetRenderers=function(){for(var t,e={},n=0;n<this.renderObjects.length;++n){var i=this.renderObjects[n].targetRenderer;e[this.targetRenderers.indexOf(i)]=!0}var o=!1,a=[];for(n=0;n<this.targetRenderers.length;++n)e[n]?a.push(this.targetRenderers[n]):(this.targetRenderers[n].dispose(),o=!0);return o&&(this.targetRenderers.length=0,(t=this.targetRenderers).push.apply(t,a)),o},r.prototype._getParticleSystemIndex=function(t){for(var e=0;e<this.renderObjects.length;++e){var n=this.renderObjects[e].object;if(kN(n)&&n.particleSystem===t)return e}return-1},r.prototype._initialize=function(){for(var t=this,e=0;e<this.targetRenderers.length;++e)this.targetRenderers[e].dispose();var n=new Map;for(e=0;e<this.targetRenderers.length;++e){var i=this.targetRenderers[e];i._initialize(),i.camera&&i._renderPostProcess&&((l=n.get(i.camera))||(l=[[],{}],n.set(i.camera,l)),l[0].push(i),i.camera.attachPostProcess(i._renderPostProcess,e))}for(var o=n.keys(),a=function(m){var v=m.value,b=n.get(v),E=v._getFirstPostProcess();if(!E)return"continue";var C=b[0],T=b[1];E.onSizeChangedObservable.add(function(){var f;E.inputTexture.depthStencilTexture||E.inputTexture.createDepthStencilTexture(0,!0,t._engine.isStencilEnable,C[0].samples,t._engine.isStencilEnable?P.Y.TEXTUREFORMAT_DEPTH24_STENCIL8:P.Y.TEXTUREFORMAT_DEPTH32_FLOAT,"PostProcessRTTDepthStencil-".concat(E.name));for(var g=0,S=C;g<S.length;g++){var y=(f=S[g]._thicknessRenderTarget)===null||f===void 0?void 0:f.renderTarget,x=y?.texture;if(y&&x){var R=x.width+"_"+x.height,I=T[R];I||(I=T[R]=new GN(t._engine,x.width,x.height)),I.depthRTWrapper.shareDepth(y)}}})},s=o.next();s.done!==!0;s=o.next())a(s);for(s=(o=this._cameras.keys()).next();s.done!==!0;s=o.next()){var l,c=s.value,u=(l=this._cameras.get(c))[1],d=n.get(c);if(d)for(var h in u)d[1][h]||u[h].dispose();else for(var p in u)u[p].dispose()}this._cameras.clear(),this._cameras=n,this._setParticleSizeForRenderTargets()},r.prototype._setParticleSizeForRenderTargets=function(){for(var t=new Map,e=0;e<this.renderObjects.length;++e){var n=this.renderObjects[e],i=t.get(n.targetRenderer);i===void 0&&(i=0),t.set(n.targetRenderer,Math.max(i,n.object.particleSize))}t.forEach(function(o,a){a._depthRenderTarget&&(a._depthRenderTarget.particleSize=o)})},r.prototype._setUseVelocityForRenderObject=function(){for(var t=0,e=this.renderObjects;t<e.length;t++){var n=e[t];n.object.useVelocity=n.targetRenderer.useVelocity}},r.prototype._prepareRendering=function(){for(var t=0,e=this.targetRenderers;t<e.length;t++)if(e[t].needInitialization)return void this._initialize()},r.prototype._render=function(t){for(var e,n=0;n<this.targetRenderers.length;++n)t&&this.targetRenderers[n].camera!==t||this.targetRenderers[n]._clearTargets();for(var i=this._cameras.keys(),o=i.next();o.done!==!0;o=i.next()){var a=o.value,s=this._cameras.get(a);if(!t||a===t){var l=a._getFirstPostProcess();if(l){var c=(e=l.inputTexture)===null||e===void 0?void 0:e.depthStencilTexture;if(c){for(var u=s[0],d=s[1],h=0,p=u;h<p.length;h++)p[h]._bgDepthTexture=c;for(var m in d)d[m].copy(c)}}}}for(n=0;n<this.renderObjects.length;++n){var v=this.renderObjects[n];t&&v.targetRenderer.camera!==t||v.targetRenderer._render(v.object)}},r.prototype.dispose=function(){this._engine.onResizeObservable.remove(this._onEngineResizeObserver),this._onEngineResizeObserver=null;for(var t=0;t<this.renderObjects.length;++t)this.renderObjects[t].object.dispose();for(t=0;t<this.targetRenderers.length;++t)this.targetRenderers[t].dispose();this._cameras.forEach(function(e){var n=e[1];for(var i in n)n[i].dispose()}),this.renderObjects=[],this.targetRenderers=[],this._cameras.clear()},r}(),QI=L(29687),JI=L(18337),$I=L(55214),eM=L(10151),tM="fluidRenderingParticleDiffuseVertexShader",nM=`attribute vec3 position;attribute vec2 offset;attribute vec4 color;uniform mat4 view;uniform mat4 projection;uniform vec2 size;varying vec2 uv;varying vec3 diffuseColor;void main(void) {vec3 cornerPos;cornerPos.xy=vec2(offset.x-0.5,offset.y-0.5)*size;cornerPos.z=0.0;vec3 viewPos=(view*vec4(position,1.0)).xyz+cornerPos;gl_Position=projection*vec4(viewPos,1.0);uv=offset;diffuseColor=color.rgb;}
|
||
`;Gt.l.ShadersStore[tM]=nM;var iM={name:tM,shader:nM},rM=L(45868),oM=L(48063),aM=L(31298),sM=L(36870),lM=L(64780),cM=L(76138),uM=L(37113),dM=L(2835),hM="fluidRenderingParticleDiffuseVertexShader",fM=`attribute position: vec3f;attribute offset: vec2f;attribute color: vec4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform size: vec2f;varying uv: vec2f;varying diffuseColor: vec3f;@vertex
|
||
fn main(input: VertexInputs)->FragmentInputs {var cornerPos: vec3f=vec3f(
|
||
vec2f(input.offset.x-0.5,input.offset.y-0.5)*uniforms.size,
|
||
0.0
|
||
);var viewPos: vec3f=(uniforms.view*vec4f(input.position,1.0)).xyz+cornerPos;vertexOutputs.position=uniforms.projection*vec4f(viewPos,1.0);vertexOutputs.uv=input.offset;vertexOutputs.diffuseColor=input.color.rgb;}
|
||
`;Gt.l.ShadersStoreWGSL[hM]=fM;var pM={name:hM,shader:fM},_M=L(70183),mM=L(7060),gM=L(52063),vM=L(94727),yM=function(){function r(t,e,n){n===void 0&&(n={width:512,height:512}),this._lightTransformMatrix=_.uq.Identity(),this._enable=!1,this.forceUpdateLightParameters=!1,this._scene=t,this._light=e,this._textureDimensions=n,this._regularMatToMatWithPlugin=new Map,this._counters=[{name:"RSM Generation "+e.name,value:0}],this._createMultiRenderTarget(),this._recomputeLightTransformationMatrix(),this.enable=!0}return Object.defineProperty(r.prototype,"enable",{get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this._customRenderTarget(t))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"positionWorldTexture",{get:function(){return this._mrt.textures[0]},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"normalWorldTexture",{get:function(){return this._mrt.textures[1]},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fluxTexture",{get:function(){return this._mrt.textures[2]},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"renderList",{get:function(){return this._mrt.renderList},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"light",{get:function(){return this._light},enumerable:!1,configurable:!0}),r.prototype.setTextureDimensions=function(t){var e=this,n=this._mrt.renderList;this._textureDimensions=t,this._disposeMultiRenderTarget(),this._createMultiRenderTarget(),n?.forEach(function(i){e._addMeshToMRT(i)})},r.prototype.addMesh=function(t){var e=this;t?this._addMeshToMRT(t):this._scene.meshes.forEach(function(n){e._addMeshToMRT(n)}),this._recomputeLightTransformationMatrix()},r.prototype.updateLightParameters=function(){this._recomputeLightTransformationMatrix()},Object.defineProperty(r.prototype,"lightTransformationMatrix",{get:function(){return this.forceUpdateLightParameters&&this.updateLightParameters(),this._lightTransformMatrix},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"countersGPU",{get:function(){return this._counters},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._disposeMultiRenderTarget()},r.prototype._createMultiRenderTarget=function(){var t,e,n=this,i=this._light.name,o=this._scene.getEngine().getCaps(),a=o.rg11b10ufColorRenderable?P.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:P.Y.TEXTURETYPE_HALF_FLOAT,s=o.rg11b10ufColorRenderable?P.Y.TEXTUREFORMAT_RGB:P.Y.TEXTUREFORMAT_RGBA;this._mrt=new Kr("RSMmrt_"+i,this._textureDimensions,3,this._scene,{types:[P.Y.TEXTURETYPE_HALF_FLOAT,P.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,a],samplingModes:[P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,P.Y.TEXTURE_BILINEAR_SAMPLINGMODE],generateMipMaps:!1,targetTypes:[P.Y.TEXTURE_2D,P.Y.TEXTURE_2D,P.Y.TEXTURE_2D],formats:[P.Y.TEXTUREFORMAT_RGBA,P.Y.TEXTUREFORMAT_RGBA,s]},["RSMPosition_"+i,"RSMNormal_"+i,"RSMFlux_"+i]),this._mrt.renderList=[],this._mrt.clearColor=new z.ov(0,0,0,1),this._mrt.noPrePassRenderer=!0;var l,c=this._scene.getEngine().supportsUniformBuffers;c&&(t=this._scene.createSceneUniformBuffer('Scene for RSM (light "'.concat(i,'")'))),this._mrt.onBeforeBindObservable.add(function(){e=n._scene.getSceneUniformBuffer(),l=n._light.shadowEnabled,n._light.shadowEnabled=!1}),this._mrt.onBeforeRenderObservable.add(function(u){t&&n._scene.setSceneUniformBuffer(t);var d=n._light.getViewMatrix(u),h=n._light.getProjectionMatrix(d||void 0,n._mrt.renderList||void 0);d&&h&&n._scene.setTransformMatrix(d,h),c&&(n._scene.getSceneUniformBuffer().unbindEffect(),n._scene.finalizeSceneUbo())}),this._mrt.onAfterUnbindObservable.add(function(){var u,d;t&&n._scene.setSceneUniformBuffer(e),n._scene.updateTransformMatrix(),n._light.shadowEnabled=l,n._counters[0].value=(d=(u=n._mrt.renderTarget.gpuTimeInFrame)===null||u===void 0?void 0:u.counter.lastSecAverage)!==null&&d!==void 0?d:0}),this._customRenderTarget(!0)},r.prototype._customRenderTarget=function(t){var e=this._scene.customRenderTargets.indexOf(this._mrt);t?e===-1&&this._scene.customRenderTargets.push(this._mrt):e!==-1&&this._scene.customRenderTargets.splice(e,1)},r.prototype._recomputeLightTransformationMatrix=function(){var t=this._light.getViewMatrix(),e=this._light.getProjectionMatrix(t||void 0,this._mrt.renderList||void 0);t&&e&&t.multiplyToRef(e,this._lightTransformMatrix)},r.prototype._addMeshToMRT=function(t){var e;(e=this._mrt.renderList)===null||e===void 0||e.push(t);var n=t.material;if(t.getTotalVertices()!==0&&n){var i=this._regularMatToMatWithPlugin.get(n);if(!i&&(i=n.clone("RSMCreate_"+n.name)||void 0)){Object.defineProperty(i,"canRenderToMRT",{get:function(){return!1},enumerable:!0,configurable:!0}),i.disableLighting=!0;var o=new Zf(i);o.isEnabled=!0,o.light=this._light,this._regularMatToMatWithPlugin.set(n,i)}this._mrt.setMaterialForRendering(t,i)}},r.prototype._disposeMultiRenderTarget=function(){this._customRenderTarget(!1),this._mrt.dispose()},r}(),WN=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.RSMCREATE=!1,e.RSMCREATE_PROJTEXTURE=!1,e.RSMCREATE_LIGHT_IS_SPOT=!1,e}return(0,A.C6)(t,r),t}(si),Zf=function(r){function t(e){var n=r.call(this,e,t.Name,300,new WN)||this;return n._lightColor=new z.v9,n._hasProjectionTexture=!1,n._isEnabled=!1,n.isEnabled=!1,n._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],n._varAlbedoName=e instanceof Tn?"surfaceAlbedo":"baseColor.rgb",n}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.prepareDefines=function(e){e.RSMCREATE=this._isEnabled,this._hasProjectionTexture=!1;var n=this.light.getTypeID()===hi.LIGHTTYPEID_SPOTLIGHT;if(n){var i=this.light;this._hasProjectionTexture=!!i.projectionTexture&&i.projectionTexture.isReady()}e.RSMCREATE_PROJTEXTURE=this._hasProjectionTexture,e.RSMCREATE_LIGHT_IS_SPOT=n,e.SCENE_MRT_COUNT=3},t.prototype.getClassName=function(){return"RSMCreatePluginMaterial"},t.prototype.getUniforms=function(){return{ubo:[{name:"rsmTextureProjectionMatrix",size:16,type:"mat4"},{name:"rsmSpotInfo",size:4,type:"vec4"},{name:"rsmLightColor",size:3,type:"vec3"},{name:"rsmLightPosition",size:3,type:"vec3"}],fragment:`#ifdef RSMCREATE
|
||
uniform mat4 rsmTextureProjectionMatrix;
|
||
uniform vec4 rsmSpotInfo;
|
||
uniform vec3 rsmLightColor;
|
||
uniform vec3 rsmLightPosition;
|
||
#endif`}},t.prototype.getSamplers=function(e){e.push("rsmTextureProjectionSampler")},t.prototype.bindForSubMesh=function(e){if(this._isEnabled&&(this.light.diffuse.scaleToRef(this.light.getScaledIntensity(),this._lightColor),e.updateColor3("rsmLightColor",this._lightColor),this.light.getTypeID()===hi.LIGHTTYPEID_SPOTLIGHT)){var n=this.light;this._hasProjectionTexture&&(e.updateMatrix("rsmTextureProjectionMatrix",n.projectionTextureMatrix),e.setTexture("rsmTextureProjectionSampler",n.projectionTexture));var i=_.AA.Vector3[0];n.computeTransformedInformation()?(e.updateFloat3("rsmLightPosition",this.light.transformedPosition.x,this.light.transformedPosition.y,this.light.transformedPosition.z),n.transformedDirection.normalizeToRef(i)):(e.updateFloat3("rsmLightPosition",this.light.position.x,this.light.position.y,this.light.position.z),n.direction.normalizeToRef(i)),e.updateFloat4("rsmSpotInfo",i.x,i.y,i.z,Math.cos(.5*n.angle))}},t.prototype.getCustomCode=function(e,n){return e==="vertex"?null:n===1?{CUSTOM_FRAGMENT_DEFINITIONS:`
|
||
#ifdef RSMCREATE
|
||
#ifdef RSMCREATE_PROJTEXTURE
|
||
var rsmTextureProjectionSamplerSampler: sampler;
|
||
var rsmTextureProjectionSampler: texture_2d<f32>;
|
||
#endif
|
||
#endif
|
||
`,CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR:`
|
||
#ifdef RSMCREATE
|
||
var rsmColor = `.concat(this._varAlbedoName,` * uniforms.rsmLightColor;
|
||
#ifdef RSMCREATE_PROJTEXTURE
|
||
{
|
||
var strq = uniforms.rsmTextureProjectionMatrix * vec4f(fragmentInputs.vPositionW, 1.0);
|
||
strq /= strq.w;
|
||
rsmColor *= textureSample(rsmTextureProjectionSampler, rsmTextureProjectionSamplerSampler, strq.xy).rgb;
|
||
}
|
||
#endif
|
||
#ifdef RSMCREATE_LIGHT_IS_SPOT
|
||
{
|
||
var cosAngle = max(0., dot(uniforms.rsmSpotInfo.xyz, normalize(fragmentInputs.vPositionW - uniforms.rsmLightPosition)));
|
||
rsmColor = sign(cosAngle - uniforms.rsmSpotInfo.w) * rsmColor;
|
||
}
|
||
#endif
|
||
|
||
#define MRT_AND_COLOR
|
||
fragmentOutputs.fragData0 = vec4f(fragmentInputs.vPositionW, 1.);
|
||
fragmentOutputs.fragData1 = vec4f(normalize(normalW) * 0.5 + 0.5, 1.);
|
||
fragmentOutputs.fragData2 = vec4f(rsmColor, 1.);
|
||
#endif
|
||
`)}:{CUSTOM_FRAGMENT_BEGIN:`
|
||
#ifdef RSMCREATE
|
||
#extension GL_EXT_draw_buffers : require
|
||
#endif
|
||
`,CUSTOM_FRAGMENT_DEFINITIONS:`
|
||
#ifdef RSMCREATE
|
||
#ifdef RSMCREATE_PROJTEXTURE
|
||
uniform highp sampler2D rsmTextureProjectionSampler;
|
||
#endif
|
||
layout(location = 0) out highp vec4 glFragData[3];
|
||
vec4 glFragColor;
|
||
#endif
|
||
`,CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR:`
|
||
#ifdef RSMCREATE
|
||
vec3 rsmColor = `.concat(this._varAlbedoName,` * rsmLightColor;
|
||
#ifdef RSMCREATE_PROJTEXTURE
|
||
{
|
||
vec4 strq = rsmTextureProjectionMatrix * vec4(vPositionW, 1.0);
|
||
strq /= strq.w;
|
||
rsmColor *= texture2D(rsmTextureProjectionSampler, strq.xy).rgb;
|
||
}
|
||
#endif
|
||
#ifdef RSMCREATE_LIGHT_IS_SPOT
|
||
{
|
||
float cosAngle = max(0., dot(rsmSpotInfo.xyz, normalize(vPositionW - rsmLightPosition)));
|
||
rsmColor = sign(cosAngle - rsmSpotInfo.w) * rsmColor;
|
||
}
|
||
#endif
|
||
glFragData[0] = vec4(vPositionW, 1.);
|
||
glFragData[1] = vec4(normalize(normalW) * 0.5 + 0.5, 1.);
|
||
glFragData[2] = vec4(rsmColor, 1.);
|
||
#endif
|
||
`)}},t.Name="RSMCreate",(0,A.Cg)([(0,V.lK)()],t.prototype,"light",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),t}(qi);(0,j.Y5)("BABYLON.RSMCreatePluginMaterial",Zf);var bM=function(){function r(t){this.numSamples=400,this.radius=.1,this.intensity=.1,this.edgeArtifactCorrection=.1,this.rotateSample=!0,this.noiseFactor=100,this.useFullTexture=!1,this.rsm=t}return r.prototype.dispose=function(){this.rsm.dispose()},r}(),TM=function(){function r(t,e,n,i,o){n===void 0&&(n={width:256,height:256}),i===void 0&&(i=2048),o===void 0&&(o=P.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV);var a=this;this._giRSM=[],this._blurRTT=null,this._blurPostProcesses=null,this._blurXPostprocess=null,this._blurYPostprocess=null,this._upsamplingXPostprocess=null,this._upsamplingYPostprocess=null,this._ppGlobalIllumination=[],this._firstActivation=!0,this._geomBufferEnabled=!1,this._geomBufferEnablePosition=!1,this._tempMatrix=new _.uq,this._enable=!1,this.pause=!1,this._enableBlur=!0,this._useQualityBlur=!1,this.blurDepthThreshold=.05,this.blurNormalThreshold=.25,this.blurKernel=12,this._forceFullSizeBlur=!1,this._useQualityUpsampling=!1,this.upsamplerKernel=6,this._showOnlyGI=!1,this._use32BitsDepthBuffer=!1,this._shaderLanguage=0,this._shadersLoaded=!1,this._onShaderLoadedObservable=new K.cP,this._scene=t,this._engine=t.getEngine(),this._outputDimensions=e,this._giTextureDimensions=n,this._giTextureType=o,this._materialsWithRenderPlugin=[],this._maxSamples=i,this._debugLayer=new gv("debug layer",null,this._scene,!1),this._debugLayer.isEnabled=!1,this._counters=[],this._countersRTW=[],this._initShaderSourceAsync(),this.generateSampleTexture(i),this._drawPhaseObserver=this._scene.onBeforeDrawPhaseObservable.add(function(){var s,l,c,u,d=a._engine._currentRenderTarget,h=!1;if(a._enable){a.pause||(a._scene.postProcessManager.directRender(a._ppGlobalIllumination,a._ppGlobalIllumination[0].inputTexture),a._engine.unBindFramebuffer(a._ppGlobalIllumination[0].inputTexture,!0),a._engine.setAlphaMode(P.Y.ALPHA_DISABLE),h=!0,a.enableBlur&&a._blurPostProcesses&&(a._scene.postProcessManager.directRender(a._blurPostProcesses,a._blurRTT.renderTarget,!0),a._engine.unBindFramebuffer(a._blurRTT.renderTarget,!0)));for(var p=0;p<a._counters.length;++p)for(var m=a._countersRTW[p],v=0;v<m.length;++v)v===0?a._counters[p].value=a.pause?0:(l=(s=m[v].gpuTimeInFrame)===null||s===void 0?void 0:s.counter.lastSecAverage)!==null&&l!==void 0?l:0:a.pause||(a._counters[p].value+=(u=(c=m[v].gpuTimeInFrame)===null||c===void 0?void 0:c.counter.lastSecAverage)!==null&&u!==void 0?u:0);a._scene.activeCamera&&a._engine.setViewport(a._scene.activeCamera.viewport)}h&&d&&a._engine.bindFramebuffer(d)})}return Object.defineProperty(r.prototype,"enable",{get:function(){return this._enable},set:function(t){this._giRSM.length===0&&(t=!1),t!==this._enable&&(this._enable=t,this._debugLayer.isEnabled=this._showOnlyGI&&t,this._materialsWithRenderPlugin.forEach(function(e){e.pluginManager&&(e.pluginManager.getPlugin(ma.Name).isEnabled=t)}),this.recreateResources(!t))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"enableBlur",{get:function(){return this._enableBlur},set:function(t){t!==this._enableBlur&&(this._enableBlur=t,this.recreateResources())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useQualityBlur",{get:function(){return this._useQualityBlur},set:function(t){t!==this._useQualityBlur&&(this._useQualityBlur=t,this.recreateResources())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fullSizeBlur",{get:function(){return this._forceFullSizeBlur},set:function(t){this._forceFullSizeBlur!==t&&(this._forceFullSizeBlur=t,this.recreateResources())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"useQualityUpsampling",{get:function(){return this._useQualityUpsampling},set:function(t){t!==this._useQualityUpsampling&&(this._useQualityUpsampling=t,this.recreateResources())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"showOnlyGI",{get:function(){return this._showOnlyGI},set:function(t){this._showOnlyGI!==t&&(this._showOnlyGI=t,this._debugLayer.isEnabled=t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"use32BitsDepthBuffer",{get:function(){return this._use32BitsDepthBuffer},set:function(t){this._use32BitsDepthBuffer!==t&&(this._use32BitsDepthBuffer=t,this.recreateResources())},enumerable:!1,configurable:!0}),r.prototype.setOutputDimensions=function(t){this._outputDimensions=t,this.recreateResources()},r.prototype.setGITextureDimensions=function(t){this._giTextureDimensions=t,this.recreateResources()},Object.defineProperty(r.prototype,"giTextureType",{get:function(){return this._giTextureType},set:function(t){this._giTextureType!==t&&(this._giTextureType=t,this.recreateResources())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"shaderLanguage",{get:function(){return this._shaderLanguage},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"giRSM",{get:function(){return this._giRSM},enumerable:!1,configurable:!0}),r.prototype.addGIRSM=function(t){var e;Array.isArray(t)?(e=this._giRSM).push.apply(e,t):this._giRSM.push(t),this.recreateResources()},r.prototype.removeGIRSM=function(t){if(Array.isArray(t))for(var e=0;e<t.length;++e){var n;(n=this._giRSM.indexOf(t[e]))!==-1&&this._giRSM.splice(n,1)}else(n=this._giRSM.indexOf(t))!==-1&&this._giRSM.splice(n,1);this._giRSM.length===0?this.enable=!1:this.recreateResources()},r.prototype.addMaterial=function(t){var e=this;t?this._addGISupportToMaterial(t):this._scene.meshes.forEach(function(n){n.getTotalVertices()>0&&n.isEnabled()&&n.material&&e._addGISupportToMaterial(n.material)})},Object.defineProperty(r.prototype,"countersGPU",{get:function(){return this._counters},enumerable:!1,configurable:!0}),r.prototype.recreateResources=function(t){var e=this;t===void 0&&(t=!1),this._shadersLoaded?(this._disposePostProcesses(t),this._createPostProcesses(),this._setPluginParameters()):this._onShaderLoadedObservable.addOnce(function(){e.recreateResources(t)})},r.prototype.generateSampleTexture=function(t){var e;(e=this._sampleTexture)===null||e===void 0||e.dispose(),this._maxSamples=t;for(var n=new Float32Array(4*this._maxSamples),i=0;i<this._maxSamples;i++){var o=Math.random(),a=Math.random(),s=o*Math.sin(2*Math.PI*a),l=o*Math.cos(2*Math.PI*a);n[4*i+0]=s,n[4*i+1]=l,n[4*i+2]=o*o,n[4*i+3]=1}this._sampleTexture=new Ln(n,this._maxSamples,1,P.Y.TEXTUREFORMAT_RGBA,this._scene,!1,!1,P.Y.TEXTURE_NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT),this._sampleTexture.name="GIRSMSamples"},r.prototype.dispose=function(){var t;this._disposePostProcesses(!0),(t=this._debugLayer.texture)===null||t===void 0||t.dispose(),this._debugLayer.dispose(),this._scene.onBeforeDrawPhaseObservable.remove(this._drawPhaseObserver)},r.prototype._initShaderSourceAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(t){switch(t.label){case 0:return this._engine.isWebGPU?(this._shaderLanguage=1,[4,Promise.all([Promise.resolve().then(L.bind(L,38884)),Promise.resolve().then(L.bind(L,15229)),Promise.resolve().then(L.bind(L,47257)),Promise.resolve().then(L.bind(L,97666))])]):[3,2];case 1:return t.sent(),[3,4];case 2:return[4,Promise.all([Promise.resolve().then(L.bind(L,87851)),Promise.resolve().then(L.bind(L,12132)),Promise.resolve().then(L.bind(L,76526)),Promise.resolve().then(L.bind(L,91209))])];case 3:t.sent(),t.label=4;case 4:return this._shadersLoaded=!0,this._onShaderLoadedObservable.notifyObservers(),[2]}})})},r.prototype._disposePostProcesses=function(t){var e,n,i,o,a;t===void 0&&(t=!1),(e=this._blurRTT)===null||e===void 0||e.dispose(),this._blurRTT=null,this._blurPostProcesses=[],(n=this._blurXPostprocess)===null||n===void 0||n.dispose(),this._blurXPostprocess=null,(i=this._blurYPostprocess)===null||i===void 0||i.dispose(),this._blurYPostprocess=null,(o=this._upsamplingXPostprocess)===null||o===void 0||o.dispose(),this._upsamplingXPostprocess=null,(a=this._upsamplingYPostprocess)===null||a===void 0||a.dispose(),this._upsamplingYPostprocess=null;for(var s=0,l=this._ppGlobalIllumination;s<l.length;s++)l[s].dispose();this._ppGlobalIllumination=[],t&&(this._geomBufferEnabled?(this._scene.enableGeometryBufferRenderer(),this._scene.geometryBufferRenderer.enablePosition=this._geomBufferEnablePosition):this._scene.disableGeometryBufferRenderer()),this._counters=[],this._countersRTW=[]},r.prototype._setPluginParameters=function(){var t=this;this._enable&&this._materialsWithRenderPlugin.forEach(function(e){if(e.pluginManager){var n=e.pluginManager.getPlugin(ma.Name);n.textureGIContrib=t.enableBlur?t._blurRTT.renderTarget.texture:t._ppGlobalIllumination[0].inputTexture.texture,n.outputTextureWidth=t._outputDimensions.width,n.outputTextureHeight=t._outputDimensions.height}})},r.prototype._createPostProcesses=function(){var t,e,n,i=this;if(this._enable){var o=this._giTextureType===P.Y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV?P.Y.TEXTUREFORMAT_RGB:P.Y.TEXTUREFORMAT_RGBA;this._firstActivation&&(this._firstActivation=!1,this._geomBufferEnabled=!!this._scene.geometryBufferRenderer,this._geomBufferEnablePosition=(e=(t=this._scene.geometryBufferRenderer)===null||t===void 0?void 0:t.enablePosition)!==null&&e!==void 0&&e),this._geomBufferEnabled||this._scene.disableGeometryBufferRenderer();var a=this._scene.enableGeometryBufferRenderer(this._enableBlur?this._outputDimensions:this._giTextureDimensions,this._use32BitsDepthBuffer?P.Y.TEXTUREFORMAT_DEPTH32_FLOAT:P.Y.TEXTUREFORMAT_DEPTH16,r.GeometryBufferTextureTypesAndFormats);if(!a)throw new Error("Geometry buffer renderer is not supported but is required for GIRSMManager.");a.enablePosition=!0,this._geomBufferEnabled||(a.generateNormalsInWorldSpace=!0);var s=a.normalsAreUnsigned,l=a.generateNormalsInWorldSpace;this._counters.push({name:"Geometry buffer renderer",value:0}),this._countersRTW.push([this._scene.geometryBufferRenderer.getGBuffer().renderTarget]);var c="";s&&(c+=`#define DECODE_NORMAL
|
||
`),l||(c+=`#define TRANSFORM_NORMAL
|
||
`);for(var u=function(T){var f=d._giRSM[T],g=f.rsm,S=new _t.w("RSMGlobalIllumination"+T,f.useFullTexture?"rsmFullGlobalIllumination":"rsmGlobalIllumination",(0,A.Cl)((0,A.Cl)({},d._giTextureDimensions),{uniforms:["rsmLightMatrix","rsmInfo","rsmInfo2","invView"],samplers:["normalSampler","rsmPositionW","rsmNormalW","rsmFlux","rsmSamples"],defines:c,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,engine:d._engine,textureType:d._giTextureType,textureFormat:o,shaderLanguage:d._shaderLanguage}));d._ppGlobalIllumination.push(S),T!==0&&(S.shareOutputWith(d._ppGlobalIllumination[0]),S.alphaMode=P.Y.ALPHA_ADD),S.autoClear=!1,S.externalTextureSamplerBinding=!0,S.onApplyObservable.add(function(y){y.setTexture("textureSampler",a.getGBuffer().textures[a.getTextureIndex(zn.POSITION_TEXTURE_TYPE)]),y.setTexture("normalSampler",a.getGBuffer().textures[a.getTextureIndex(zn.NORMAL_TEXTURE_TYPE)]),y.setTexture("rsmPositionW",g.positionWorldTexture),y.setTexture("rsmNormalW",g.normalWorldTexture),y.setTexture("rsmFlux",g.fluxTexture),y.setMatrix("rsmLightMatrix",g.lightTransformationMatrix),f.useFullTexture?y.setFloat4("rsmInfo",g.fluxTexture.getInternalTexture().width,g.fluxTexture.getInternalTexture().height,f.intensity,f.edgeArtifactCorrection):(y.setTexture("rsmSamples",i._sampleTexture),y.setFloat4("rsmInfo",f.numSamples,f.radius,f.intensity,f.edgeArtifactCorrection),y.setFloat4("rsmInfo2",f.noiseFactor,f.rotateSample?1:0,g.fluxTexture.getInternalTexture().width,g.fluxTexture.getInternalTexture().height)),l||(i._tempMatrix.copyFrom(i._scene.activeCamera.getViewMatrix()),i._tempMatrix.invert(),y.setMatrix("invView",i._tempMatrix))})},d=this,h=0;h<this._giRSM.length;++h)u(h);for(var p=0,m=this._ppGlobalIllumination;p<m.length;p++){var v=m[p];v.inputTexture||v.resize(this._giTextureDimensions.width,this._giTextureDimensions.height)}if(this._counters.push({name:"GI generation",value:0}),this._countersRTW.push([this._ppGlobalIllumination[0].inputTexture]),this._enableBlur){var b=this._forceFullSizeBlur?this._outputDimensions:this._giTextureDimensions;this._blurRTT=new un.$("GIRSMContribution",this._outputDimensions,this._scene,{type:this._giTextureType,format:o,generateDepthBuffer:!1}),this._blurRTT.wrapU=P.Y.TEXTURE_CLAMP_ADDRESSMODE,this._blurRTT.wrapV=P.Y.TEXTURE_CLAMP_ADDRESSMODE,this._blurRTT.updateSamplingMode(P.Y.TEXTURE_NEAREST_SAMPLINGMODE),this._blurRTT.skipInitialClear=!0;var E=[];if(this._counters.push({name:"GI blur",value:0}),this._countersRTW.push(E),this._blurXPostprocess=new _t.w(this._useQualityBlur?"BilateralBlur":"BilateralBlurX",this._useQualityBlur?"bilateralBlurQuality":"bilateralBlur",{uniforms:["filterSize","blurDir","depthThreshold","normalThreshold"],samplers:["depthSampler","normalSampler"],defines:s?"#define DECODE_NORMAL":void 0,size:b,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,engine:this._engine,textureType:this._giTextureType,textureFormat:o,shaderLanguage:this._shaderLanguage}),this._blurXPostprocess.onApplyObservable.add(function(T){T._bindTexture("textureSampler",i._ppGlobalIllumination[0].inputTexture.texture),T.setTexture("depthSampler",a.getGBuffer().textures[a.getTextureIndex(zn.DEPTH_TEXTURE_TYPE)]),T.setTexture("normalSampler",a.getGBuffer().textures[a.getTextureIndex(zn.NORMAL_TEXTURE_TYPE)]),T.setInt("filterSize",i.blurKernel),T.setFloat2("blurDir",1/i._giTextureDimensions.width,i._useQualityBlur?1/i._giTextureDimensions.height:0),T.setFloat("depthThreshold",i.blurDepthThreshold),T.setFloat("normalThreshold",i.blurNormalThreshold)}),this._blurXPostprocess.externalTextureSamplerBinding=!0,this._blurXPostprocess.autoClear=!1,this._useQualityBlur||(this._blurYPostprocess=new _t.w("BilateralBlurY","bilateralBlur",{uniforms:["filterSize","blurDir","depthThreshold","normalThreshold"],samplers:["depthSampler","normalSampler"],defines:s?"#define DECODE_NORMAL":void 0,size:b,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,engine:this._engine,textureType:this._giTextureType,textureFormat:o,shaderLanguage:this._shaderLanguage}),this._blurYPostprocess.autoClear=!1,this._blurYPostprocess.onApplyObservable.add(function(T){T.setTexture("depthSampler",a.getGBuffer().textures[a.getTextureIndex(zn.DEPTH_TEXTURE_TYPE)]),T.setTexture("normalSampler",a.getGBuffer().textures[a.getTextureIndex(zn.NORMAL_TEXTURE_TYPE)]),T.setInt("filterSize",i.blurKernel),T.setFloat2("blurDir",0,1/i._giTextureDimensions.height),T.setFloat("depthThreshold",i.blurDepthThreshold),T.setFloat("normalThreshold",i.blurNormalThreshold)}),this._blurYPostprocess.resize(b.width,b.height),E.push(this._blurYPostprocess.inputTexture)),this._blurPostProcesses=[this._blurXPostprocess],this._blurYPostprocess&&this._blurPostProcesses.push(this._blurYPostprocess),this._giTextureDimensions.width>=this._outputDimensions.width&&this._giTextureDimensions.height>=this._outputDimensions.height||this._forceFullSizeBlur)E.push(this._blurRTT.renderTarget);else{var C=[];this._counters.push({name:"GI upsampling",value:0}),this._countersRTW.push(C),this._upsamplingXPostprocess=new _t.w(this._useQualityUpsampling?"BilateralUpsampling":"BilateralUpsamplingX",this._useQualityUpsampling?"bilateralBlurQuality":"bilateralBlur",{uniforms:["filterSize","blurDir","depthThreshold","normalThreshold"],samplers:["depthSampler","normalSampler"],defines:s?"#define DECODE_NORMAL":void 0,size:b,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,engine:this._engine,textureType:this._giTextureType,textureFormat:o,shaderLanguage:this._shaderLanguage}),this._upsamplingXPostprocess.autoClear=!1,this._upsamplingXPostprocess.onApplyObservable.add(function(T){T.setTexture("depthSampler",a.getGBuffer().textures[a.getTextureIndex(zn.DEPTH_TEXTURE_TYPE)]),T.setTexture("normalSampler",a.getGBuffer().textures[a.getTextureIndex(zn.NORMAL_TEXTURE_TYPE)]),T.setInt("filterSize",i.upsamplerKernel),T.setFloat2("blurDir",1/i._outputDimensions.width,i._useQualityUpsampling?1/i._outputDimensions.height:0),T.setFloat("depthThreshold",i.blurDepthThreshold),T.setFloat("normalThreshold",i.blurNormalThreshold)}),this._upsamplingXPostprocess.resize(b.width,b.height),E.push(this._upsamplingXPostprocess.inputTexture),this.useQualityUpsampling||(this._upsamplingYPostprocess=new _t.w("BilateralUpsamplingY","bilateralBlur",{uniforms:["filterSize","blurDir","depthThreshold","normalThreshold"],samplers:["depthSampler","normalSampler"],defines:s?"#define DECODE_NORMAL":void 0,size:this._outputDimensions,samplingMode:P.Y.TEXTURE_BILINEAR_SAMPLINGMODE,engine:this._engine,textureType:this._giTextureType,textureFormat:o,shaderLanguage:this._shaderLanguage}),this._upsamplingYPostprocess.autoClear=!1,this._upsamplingYPostprocess.onApplyObservable.add(function(T){T.setTexture("depthSampler",a.getGBuffer().textures[a.getTextureIndex(zn.DEPTH_TEXTURE_TYPE)]),T.setTexture("normalSampler",a.getGBuffer().textures[a.getTextureIndex(zn.NORMAL_TEXTURE_TYPE)]),T.setInt("filterSize",i.upsamplerKernel),T.setFloat2("blurDir",0,1/i._outputDimensions.height),T.setFloat("depthThreshold",i.blurDepthThreshold),T.setFloat("normalThreshold",i.blurNormalThreshold)}),this._upsamplingYPostprocess.resize(this._outputDimensions.width,this._outputDimensions.height),C.push(this._upsamplingYPostprocess.inputTexture)),C.push(this._blurRTT.renderTarget),this._blurPostProcesses.push(this._upsamplingXPostprocess),this._upsamplingYPostprocess&&this._blurPostProcesses.push(this._upsamplingYPostprocess)}}(n=this._debugLayer.texture)===null||n===void 0||n.dispose(),this._debugLayer.texture=new Ki.t(this._scene,this._enableBlur?this._blurRTT.renderTarget.texture:this._ppGlobalIllumination[0].inputTexture.texture)}},r.prototype._addGISupportToMaterial=function(t){var e;if(!(!((e=t.pluginManager)===null||e===void 0)&&e.getPlugin(ma.Name))){var n=new ma(t);this._enable&&this._ppGlobalIllumination.length>0&&(n.textureGIContrib=this._ppGlobalIllumination[0].inputTexture.texture,n.outputTextureWidth=this._outputDimensions.width,n.outputTextureHeight=this._outputDimensions.height),n.isEnabled=this._enable,this._materialsWithRenderPlugin.push(t)}},r.GeometryBufferTextureTypesAndFormats={0:{textureType:P.Y.TEXTURETYPE_HALF_FLOAT,textureFormat:P.Y.TEXTUREFORMAT_R},1:{textureType:P.Y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,textureFormat:P.Y.TEXTUREFORMAT_RGBA},2:{textureType:P.Y.TEXTURETYPE_HALF_FLOAT,textureFormat:P.Y.TEXTUREFORMAT_RGBA}},r}(),HN=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.RENDER_WITH_GIRSM=!1,e.RSMCREATE_PROJTEXTURE=!1,e}return(0,A.C6)(t,r),t}(si),ma=function(r){function t(e){var n=r.call(this,e,t.Name,310,new HN)||this;return n._isEnabled=!1,n.isEnabled=!1,n._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[P.Y.MATERIAL_TextureDirtyFlag],n._isPBR=e instanceof Tn,n}return(0,A.C6)(t,r),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isCompatible=function(){return!0},t.prototype.prepareDefines=function(e){e.RENDER_WITH_GIRSM=this._isEnabled},t.prototype.getClassName=function(){return"GIRSMRenderPluginMaterial"},t.prototype.getUniforms=function(){return{ubo:[{name:"girsmTextureOutputSize",size:2,type:"vec2"}],fragment:`#ifdef RENDER_WITH_GIRSM
|
||
uniform vec2 girsmTextureOutputSize;
|
||
#endif`}},t.prototype.getSamplers=function(e){e.push("girsmTextureGIContrib")},t.prototype.bindForSubMesh=function(e){this._isEnabled&&(e.bindTexture("girsmTextureGIContrib",this.textureGIContrib),e.updateFloat2("girsmTextureOutputSize",this.outputTextureWidth,this.outputTextureHeight))},t.prototype.getCustomCode=function(e,n){var i;return n===1?(i={CUSTOM_FRAGMENT_DEFINITIONS:`
|
||
#ifdef RENDER_WITH_GIRSM
|
||
var girsmTextureGIContribSampler: sampler;
|
||
var girsmTextureGIContrib: texture_2d<f32>;
|
||
|
||
fn computeIndirect() -> vec3f {
|
||
var uv = fragmentInputs.position.xy / uniforms.girsmTextureOutputSize;
|
||
return textureSample(girsmTextureGIContrib, girsmTextureGIContribSampler, uv).rgb;
|
||
}
|
||
#endif
|
||
`,CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION:`
|
||
#ifdef RENDER_WITH_GIRSM
|
||
finalDiffuse += computeIndirect() * surfaceAlbedo.rgb;
|
||
#endif
|
||
`},this._isPBR||(i.CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR=`
|
||
#ifdef RENDER_WITH_GIRSM
|
||
color = vec4f(color.rgb + computeIndirect() * baseColor.rgb, color.a);
|
||
#endif
|
||
`)):(i={CUSTOM_FRAGMENT_DEFINITIONS:`
|
||
#ifdef RENDER_WITH_GIRSM
|
||
uniform sampler2D girsmTextureGIContrib;
|
||
|
||
vec3 computeIndirect() {
|
||
vec2 uv = gl_FragCoord.xy / girsmTextureOutputSize;
|
||
return texture2D(girsmTextureGIContrib, uv).rgb;
|
||
}
|
||
#endif
|
||
`,CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION:`
|
||
#ifdef RENDER_WITH_GIRSM
|
||
finalDiffuse += computeIndirect() * surfaceAlbedo.rgb;
|
||
#endif
|
||
`},this._isPBR||(i.CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR=`
|
||
#ifdef RENDER_WITH_GIRSM
|
||
color.rgb += computeIndirect() * baseColor.rgb;
|
||
#endif
|
||
`)),e==="vertex"?null:i},t.Name="GIRSMRender",(0,A.Cg)([(0,V.lK)()],t.prototype,"textureGIContrib",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"outputTextureWidth",void 0),(0,A.Cg)([(0,V.lK)()],t.prototype,"outputTextureHeight",void 0),(0,A.Cg)([(0,V.lK)(),(0,V.$z)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),t}(qi);(0,j.Y5)("BABYLON.GIRSMRenderPluginMaterial",ma);var SM=L(87851),EM=L(12132),xM=L(76526),PM=L(91209),AM=L(38884),CM=L(15229),RM=L(47257),IM=L(97666),MM=L(62004),OM=L(31086),DM=L(51319),NM=L(40877),LM=L(72627),FM=L(67569),wM=L(30025),BM=L(34063),VM=L(97468),UM=L(60738),GM=L(34873),kM=L(63327),zM=L(23338),WM=L(18924),HM=L(61189),YM=L(27179),XM=L(37592),jM=L(79147),qM=L(53365),KM=L(75626),ZM=L(45310),QM=L(35139),JM=L(79401),$M=L(31984),eO=L(21181),tO=L(84586),nO=L(41037),iO=L(83898),rO=L(8866),oO=L(82911),aO=L(92228),sO=L(52651),lO=L(41745),cO=L(75866),uO=L(24726),dO=L(12191),hO=L(23387),fO=L(31898),pO=L(84659),_O=L(41888),mO=L(37326),gO=L(99381),vO=L(55627),yO=L(54428),bO=L(76933),TO=L(39768),SO=L(81487),EO=L(90453),xO=L(30738),PO=L(90564),AO=L(48533),CO=L(42362),RO=L(99032),IO=L(77142),MO=L(64015),OO=L(56809),DO=L(37624),NO=L(73758),LO=L(27993),FO=L(5519);Gt.l.ShadersStore.spriteMapPixelShader=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
||
#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
|
||
#else
|
||
#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
|
||
#endif
|
||
precision highp float;varying vec3 vPosition;varying vec2 vUV;varying vec2 tUV;uniform float time;uniform float spriteCount;uniform sampler2D spriteSheet;uniform vec2 spriteMapSize;uniform vec2 outputSize;uniform vec2 stageSize;uniform sampler2D frameMap;uniform sampler2D tileMaps[LAYERS];uniform sampler2D animationMap;uniform vec3 colorMul;float mt;const float fdStep=1./4.;const float aFrameSteps=MAX_ANIMATION_FRAMES==0. ? 0. : 1./MAX_ANIMATION_FRAMES;mat4 getFrameData(float frameID){float fX=frameID/spriteCount;return mat4(
|
||
texture2D(frameMap,vec2(fX,0.),0.),
|
||
texture2D(frameMap,vec2(fX,fdStep*1.),0.),
|
||
texture2D(frameMap,vec2(fX,fdStep*2.),0.),
|
||
vec4(0.)
|
||
);}
|
||
void main(){vec4 color=vec4(0.);vec2 tileUV=fract(tUV);
|
||
#ifdef FLIPU
|
||
tileUV.y=1.0-tileUV.y;
|
||
#endif
|
||
vec2 tileID=floor(tUV);vec2 sheetUnits=1./spriteMapSize;float spriteUnits=1./spriteCount;vec2 stageUnits=1./stageSize;for(int i=0; i<LAYERS; i++) {float frameID;
|
||
#define LAYER_ID_SWITCH
|
||
vec4 animationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.);if(animationData.y>0.) {mt=mod(time*animationData.z,1.0);for(float f=0.; f<MAX_ANIMATION_FRAMES; f++){if(animationData.y>mt){frameID=animationData.x;break;}
|
||
animationData=TEXTUREFUNC(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);}}
|
||
mat4 frameData=getFrameData(frameID+0.5);vec2 frameSize=(frameData[0].zw)/spriteMapSize;vec2 offset=frameData[0].xy*sheetUnits;vec2 ratio=frameData[2].xy/frameData[0].zw;if (frameData[2].z==1.){tileUV.xy=tileUV.yx;}
|
||
vec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);if (i==0){color=nc;} else {float alpha=min(color.a+nc.a,1.0);vec3 mixed=mix(color.xyz,nc.xyz,nc.a);color=vec4(mixed,alpha);}}
|
||
color.xyz*=colorMul;gl_FragColor=color;}
|
||
`,Gt.l.ShadersStore.spriteMapVertexShader=`precision highp float;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;varying vec3 vPosition;varying vec2 vUV;varying vec2 tUV;varying vec2 stageUnits;varying vec2 levelUnits;varying vec2 tileID;uniform float time;uniform mat4 worldViewProjection;uniform vec2 outputSize;uniform vec2 stageSize;uniform vec2 spriteMapSize;uniform float stageScale;void main() {vec4 p=vec4( position,1. );vPosition=p.xyz;vUV=uv;tUV=uv*stageSize;
|
||
gl_Position=worldViewProjection*p;}`;var Qf,wO=function(){function r(t,e,n,i,o){var a=this;this.name=t,this.sprites=[],this.atlasJSON=e,this.sprites=this.atlasJSON.frames,this.spriteSheet=n,this.options=i,i.stageSize=i.stageSize||new _.I9(1,1),i.outputSize=i.outputSize||i.stageSize,i.outputPosition=i.outputPosition||_.Pq.Zero(),i.outputRotation=i.outputRotation||_.Pq.Zero(),i.layerCount=i.layerCount||1,i.maxAnimationFrames=i.maxAnimationFrames||0,i.baseTile=i.baseTile||0,i.flipU=i.flipU||!1,i.colorMultiply=i.colorMultiply||new _.Pq(1,1,1),this._scene=o,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var s=0;s<i.layerCount;s++)this._tileMaps.push(this._createTileBuffer(null,s));this._animationMap=this._createTileAnimationBuffer(null);var l=[];l.push("#define LAYERS "+i.layerCount),i.flipU&&l.push("#define FLIPU"),l.push("#define MAX_ANIMATION_FRAMES ".concat(i.maxAnimationFrames,".0"));var c,u=ti.M.ShadersStore.spriteMapPixelShader;if(o.getEngine()._features.supportSwitchCaseInShader){for(c="switch(i) {",s=0;s<i.layerCount;s++)c+="case "+s+" : frameID = texture(tileMaps["+s+"], (tileID + 0.5) / stageSize, 0.).x;",c+="break;";c+="}"}else for(c="",s=0;s<i.layerCount;s++)c+="if (".concat(s," == i) { frameID = texture2D(tileMaps[").concat(s,"], (tileID + 0.5) / stageSize, 0.).x; }");ti.M.ShadersStore["spriteMap"+this.name+"PixelShader"]=u.replace("#define LAYER_ID_SWITCH",c),this._material=new pi("spriteMap:"+this.name,this._scene,{vertex:"spriteMap",fragment:"spriteMap"+this.name},{defines:l,attributes:["position","normal","uv"],uniforms:["worldViewProjection","time","stageSize","outputSize","spriteMapSize","spriteCount","time","colorMul","mousePosition","curTile","flipU"],samplers:["spriteSheet","frameMap","tileMaps","animationMap"],needAlphaBlending:!0}),this._time=0,this._material.setFloat("spriteCount",this.spriteCount),this._material.setVector2("stageSize",i.stageSize),this._material.setVector2("outputSize",i.outputSize),this._material.setTexture("spriteSheet",this.spriteSheet),this._material.setVector2("spriteMapSize",new _.I9(1,1)),this._material.setVector3("colorMul",i.colorMultiply);var d=0,h=function(){a.spriteSheet&&a.spriteSheet.isReady()&&a.spriteSheet._texture?a._material.setVector2("spriteMapSize",new _.I9(a.spriteSheet._texture.baseWidth||1,a.spriteSheet._texture.baseHeight||1)):d<100&&setTimeout(function(){d++,h()},100)};h(),this._material.setVector3("colorMul",i.colorMultiply),this._material.setTexture("frameMap",this._frameMap),this._material.setTextureArray("tileMaps",this._tileMaps),this._material.setTexture("animationMap",this._animationMap),this._material.setFloat("time",this._time),this._output=Ur(t+":output",{size:1,updatable:!0},o),this._output.scaling.x=i.outputSize.x,this._output.scaling.y=i.outputSize.y,this.position=i.outputPosition,this.rotation=i.outputRotation,this._scene.onBeforeRenderObservable.add(function(){a._time+=a._scene.getEngine().getDeltaTime(),a._material.setFloat("time",a._time)}),this._output.material=this._material}return Object.defineProperty(r.prototype,"spriteCount",{get:function(){return this.sprites.length},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"position",{get:function(){return this._output.position},set:function(t){this._output.position=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"rotation",{get:function(){return this._output.rotation},set:function(t){this._output.rotation=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"animationMap",{get:function(){return this._animationMap},set:function(t){var e=t._texture._bufferView,n=this._createTileAnimationBuffer(e);this._animationMap.dispose(),this._animationMap=n,this._material.setTexture("animationMap",this._animationMap)},enumerable:!1,configurable:!0}),r.prototype.getTileID=function(){var t=this.getMousePosition();return t.multiplyInPlace(this.options.stageSize||_.I9.Zero()),t.x=Math.floor(t.x),t.y=Math.floor(t.y),t},r.prototype.getMousePosition=function(){var t=this._output,e=this._scene.pick(this._scene.pointerX,this._scene.pointerY,function(n){return n===t});return e&&e.hit&&e.getTextureCoordinates&&e.getTextureCoordinates()||new _.I9(-1,-1)},r.prototype._createFrameBuffer=function(){for(var t=[],e=0;e<this.spriteCount;e++)t.push(0,0,0,0),t.push(0,0,0,0),t.push(0,0,0,0),t.push(0,0,0,0);for(e=0;e<this.spriteCount;e++){var n=this.sprites[e].frame,i=this.sprites[e].spriteSourceSize,o=this.sprites[e].sourceSize,a=this.sprites[e].rotated?1:0,s=this.sprites[e].trimmed?1:0;t[4*e]=n.x,t[4*e+1]=n.y,t[4*e+2]=n.w,t[4*e+3]=n.h,t[4*e+4*this.spriteCount]=i.x,t[4*e+1+4*this.spriteCount]=i.y,t[4*e+3+4*this.spriteCount]=i.h,t[4*e+8*this.spriteCount]=o.w,t[4*e+1+8*this.spriteCount]=o.h,t[4*e+2+8*this.spriteCount]=a,t[4*e+3+8*this.spriteCount]=s}var l=new Float32Array(t);return Ln.CreateRGBATexture(l,this.spriteCount,4,this._scene,!1,!1,Ie.g.NEAREST_NEAREST,P.Y.TEXTURETYPE_FLOAT)},r.prototype._createTileBuffer=function(t,e){e===void 0&&(e=0);var n=[],i=this.options.stageSize.y||0,o=this.options.stageSize.x||0;if(t)n=t;else{var a=this.options.baseTile;e!=0&&(a=0);for(var s=0;s<i;s++)for(var l=0;l<4*o;l+=4)n.push(a,0,0,0)}var c=new Float32Array(n);return Ln.CreateRGBATexture(c,o,i,this._scene,!1,!1,Ie.g.NEAREST_NEAREST,P.Y.TEXTURETYPE_FLOAT)},r.prototype.changeTiles=function(t,e,n){t===void 0&&(t=0),n===void 0&&(n=0);var i=this._tileMaps[t]._texture._bufferView;if(i!==null){var o=[];e instanceof _.I9?o.push(e):o=e;for(var a=this.options.stageSize.x||0,s=0;s<o.length;s++){var l=o[s];l.x=Math.floor(l.x),l.y=Math.floor(l.y),i[4*l.x+l.y*(4*a)]=n}var c=this._createTileBuffer(i);this._tileMaps[t].dispose(),this._tileMaps[t]=c,this._material.setTextureArray("tileMap",this._tileMaps)}},r.prototype._createTileAnimationBuffer=function(t){var e,n=[];if(t)e=t;else{for(var i=0;i<this.spriteCount;i++){n.push(0,0,0,0);for(var o=1;o<(this.options.maxAnimationFrames||4);)n.push(0,0,0,0),o++}e=new Float32Array(n)}return Ln.CreateRGBATexture(e,this.spriteCount,this.options.maxAnimationFrames||4,this._scene,!1,!1,Ie.g.NEAREST_NEAREST,P.Y.TEXTURETYPE_FLOAT)},r.prototype.addAnimationToTile=function(t,e,n,i,o){t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=0),i===void 0&&(i=0),o===void 0&&(o=1);var a=this._animationMap._texture._bufferView,s=4*t+4*this.spriteCount*e;if(a){a[s]=n,a[s+1]=i,a[s+2]=o;var l=this._createTileAnimationBuffer(a);this._animationMap.dispose(),this._animationMap=l,this._material.setTexture("animationMap",this._animationMap)}},r.prototype.saveTileMaps=function(){for(var t="",e=0;e<this._tileMaps.length;e++)e>0&&(t+=`
|
||
\r`),t+=this._tileMaps[e]._texture._bufferView.toString();var n=document.createElement("a");n.href="data:octet/stream;charset=utf-8,"+encodeURI(t),n.target="_blank",n.download=this.name+".tilemaps",n.click(),n.remove()},r.prototype.loadTileMaps=function(t){var e=this,n=new XMLHttpRequest;n.open("GET",t);var i=this.options.layerCount||0;n.onload=function(){for(var o=n.response.split(`
|
||
\r`),a=0;a<i;a++){var s=o[a].split(",").map(Number),l=e._createTileBuffer(s);e._tileMaps[a].dispose(),e._tileMaps[a]=l}e._material.setTextureArray("tileMap",e._tileMaps)},n.send()},r.prototype.dispose=function(){this._output.dispose(),this._material.dispose(),this._animationMap.dispose(),this._tileMaps.forEach(function(t){t.dispose()}),this._frameMap.dispose()},r}(),BO=function(r){function t(e,n,i,o,a,s,l){a===void 0&&(a=null),s===void 0&&(s=.01),l===void 0&&(l=Ie.g.TRILINEAR_SAMPLINGMODE);var c=r.call(this,e,n,i,64,o,s,l,!0,a)||this;return c.name=e,c}return(0,A.C6)(t,r),t}(yh),VO=L(22088),UO=L(25792),GO=L(89493),kO=L(98179),zO=L(69329),WO=L(3911),HO=L(92548);(function(r){r[r.INIT=0]="INIT",r[r.RUNNING=1]="RUNNING",r[r.DONE=2]="DONE",r[r.ERROR=3]="ERROR"})(Qf||(Qf={}));var Rr=function(){function r(t){this.name=t,this._isCompleted=!1,this._taskState=0}return Object.defineProperty(r.prototype,"isCompleted",{get:function(){return this._isCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"taskState",{get:function(){return this._taskState},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!1,configurable:!0}),r.prototype._setErrorObject=function(t,e){this._errorObject||(this._errorObject={message:t,exception:e})},r.prototype.run=function(t,e,n){var i=this;this._taskState=1,this.runTask(t,function(){i._onDoneCallback(e,n)},function(o,a){i._onErrorCallback(n,o,a)})},r.prototype.runTask=function(t,e,n){throw new Error("runTask is not implemented")},r.prototype.reset=function(){this._taskState=0},r.prototype._onErrorCallback=function(t,e,n){this._taskState=3,this._errorObject={message:e,exception:n},this.onError&&this.onError(this,e,n),t()},r.prototype._onDoneCallback=function(t,e){try{this._taskState=2,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),t()}catch(n){this._onErrorCallback(e,"Task is done, error executing success callback(s)",n)}},r}(),OT=function(r,t,e){this.remainingCount=r,this.totalCount=t,this.task=e},DT=function(r){function t(e,n,i,o,a){var s=r.call(this,e)||this;return s.name=e,s.meshesNames=n,s.rootUrl=i,s.sceneFilename=o,s.extension=a,s}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){var o=this;yn.LoadAssetContainer(this.rootUrl,this.sceneFilename,e,function(a){o.loadedContainer=a,o.loadedMeshes=a.meshes,o.loadedTransformNodes=a.transformNodes,o.loadedParticleSystems=a.particleSystems,o.loadedSkeletons=a.skeletons,o.loadedAnimationGroups=a.animationGroups,n()},null,function(a,s,l){i(s,l)},this.extension)},t}(Rr),NT=function(r){function t(e,n,i,o,a){var s=r.call(this,e)||this;return s.name=e,s.meshesNames=n,s.rootUrl=i,s.sceneFilename=o,s.extension=a,s}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){var o=this;yn.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,function(a,s,l,c,u){o.loadedMeshes=a,o.loadedTransformNodes=u,o.loadedParticleSystems=s,o.loadedSkeletons=l,o.loadedAnimationGroups=c,n()},null,function(a,s,l){i(s,l)},this.extension)},t}(Rr),YO=function(r){function t(e,n,i,o,a){var s=r.call(this,e)||this;return s.name=e,s.rootUrl=n,s.filename=i,s.targetConverter=o,s.extension=a,s}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){var o=this,a=e.animatables.length,s=e.animationGroups.length;this.loadedAnimatables=[],this.loadedAnimationGroups=[],yn.ImportAnimations(this.rootUrl,this.filename,e,!1,3,this.targetConverter,function(){o.loadedAnimatables=e.animatables.slice(a),o.loadedAnimationGroups=e.animationGroups.slice(s),n()},null,function(l,c,u){i(c,u)},this.extension)},t}(Rr),LT=function(r){function t(e,n){var i=r.call(this,e)||this;return i.name=e,i.url=n,i}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){var o=this;e._loadFile(this.url,function(a){o.text=a,n()},void 0,!1,!1,function(a,s){a&&i(a.status+" "+a.statusText,s)})},t}(Rr),FT=function(r){function t(e,n){var i=r.call(this,e)||this;return i.name=e,i.url=n,i}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){var o=this;e._loadFile(this.url,function(a){o.data=a,n()},void 0,!0,!0,function(a,s){a&&i(a.status+" "+a.statusText,s)})},t}(Rr),wT=function(r){function t(e,n){var i=r.call(this,e)||this;return i.name=e,i.url=n,i}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){var o=this,a=new Image;ze.S0.SetCorsBehavior(this.url,a),a.onload=function(){o.image=a,n()},a.onerror=function(s){i("Error loading image",s)},a.src=this.url},t}(Rr),BT=function(r){function t(e,n,i,o,a){o===void 0&&(o=!0),a===void 0&&(a=Ie.g.TRILINEAR_SAMPLINGMODE);var s=r.call(this,e)||this;return s.name=e,s.url=n,s.noMipmap=i,s.invertY=o,s.samplingMode=a,s}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new Ie.g(this.url,e,this.noMipmap,this.invertY,this.samplingMode,function(){n()},function(o,a){i(o,a)})},t}(Rr),VT=function(r){function t(e,n,i,o,a,s){var l=r.call(this,e)||this;return l.name=e,l.url=n,l.extensions=i,l.noMipmap=o,l.files=a,l.prefiltered=s,l}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new mr(this.url,e,this.extensions,this.noMipmap,this.files,function(){n()},function(o,a){i(o,a)},void 0,this.prefiltered)},t}(Rr),UT=function(r){function t(e,n,i,o,a,s,l){o===void 0&&(o=!1),a===void 0&&(a=!0),s===void 0&&(s=!1),l===void 0&&(l=!1);var c=r.call(this,e)||this;return c.name=e,c.url=n,c.size=i,c.noMipmap=o,c.generateHarmonics=a,c.gammaSpace=s,c.reserved=l,c}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new bl(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,function(){n()},function(o,a){i(o,a)})},t}(Rr),GT=function(r){function t(e,n,i,o,a){o===void 0&&(o=!1),a===void 0&&(a=!0);var s=r.call(this,e)||this;return s.name=e,s.url=n,s.size=i,s.noMipmap=o,s.gammaSpace=a,s}return(0,A.C6)(t,r),t.prototype.runTask=function(e,n,i){this.texture=new Bv(this.url,e,this.size,this.noMipmap,this.gammaSpace,function(){n()},function(o,a){i(o,a)})},t}(Rr),XO=function(){function r(t){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new K.cP,this.onTaskErrorObservable=new K.cP,this.onTasksDoneObservable=new K.cP,this.onProgressObservable=new K.cP,this.useDefaultLoadingScreen=!0,this.autoHideLoadingUI=!0,this._scene=t||Ve.q.LastCreatedScene}return r.prototype.addContainerTask=function(t,e,n,i,o){var a=new DT(t,e,n,i,o);return this._tasks.push(a),a},r.prototype.addMeshTask=function(t,e,n,i,o){var a=new NT(t,e,n,i,o);return this._tasks.push(a),a},r.prototype.addTextFileTask=function(t,e){var n=new LT(t,e);return this._tasks.push(n),n},r.prototype.addBinaryFileTask=function(t,e){var n=new FT(t,e);return this._tasks.push(n),n},r.prototype.addImageTask=function(t,e){var n=new wT(t,e);return this._tasks.push(n),n},r.prototype.addTextureTask=function(t,e,n,i,o){o===void 0&&(o=Ie.g.TRILINEAR_SAMPLINGMODE);var a=new BT(t,e,n,i,o);return this._tasks.push(a),a},r.prototype.addCubeTextureTask=function(t,e,n,i,o,a){var s=new VT(t,e,n,i,o,a);return this._tasks.push(s),s},r.prototype.addHDRCubeTextureTask=function(t,e,n,i,o,a,s){i===void 0&&(i=!1),o===void 0&&(o=!0),a===void 0&&(a=!1),s===void 0&&(s=!1);var l=new UT(t,e,n,i,o,a,s);return this._tasks.push(l),l},r.prototype.addEquiRectangularCubeTextureAssetTask=function(t,e,n,i,o){i===void 0&&(i=!1),o===void 0&&(o=!0);var a=new GT(t,e,n,i,o);return this._tasks.push(a),a},r.prototype.removeTask=function(t){var e=this._tasks.indexOf(t);e>-1&&this._tasks.splice(e,1)},r.prototype._decreaseWaitingTasksCount=function(t){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,t),this.onProgressObservable.notifyObservers(new OT(this._waitingTasksCount,this._totalTasksCount,t))}catch(s){O.V.Error("Error running progress callbacks."),O.V.Log(s)}if(this._waitingTasksCount===0){try{var e=this._tasks.slice();this.onFinish&&this.onFinish(e);for(var n=0,i=e;n<i.length;n++){var o=i[n];if(o.taskState===2){var a=this._tasks.indexOf(o);a>-1&&this._tasks.splice(a,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(s){O.V.Error("Error running tasks-done callbacks."),O.V.Log(s)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},r.prototype._runTask=function(t){var e=this,n=function(i,o){t._setErrorObject(i,o),e.onTaskError?e.onTaskError(t):t.onError||O.V.Error(e._formatTaskErrorMessage(t)),e.onTaskErrorObservable.notifyObservers(t),e._decreaseWaitingTasksCount(t)};t.run(this._scene,function(){try{e.onTaskSuccess&&e.onTaskSuccess(t),e.onTaskSuccessObservable.notifyObservers(t),e._decreaseWaitingTasksCount(t)}catch(i){n("Error executing task success callbacks",i)}},n)},r.prototype._formatTaskErrorMessage=function(t){var e="Unable to complete task "+t.name;return t.errorObject.message&&(e+=": ".concat(t.errorObject.message)),t.errorObject.exception&&(e+=": ".concat(t.errorObject.exception)),e},r.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},r.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,this._waitingTasksCount===0)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var t=0;t<this._tasks.length;t++){var e=this._tasks[t];e.taskState===0&&this._runTask(e)}return this},r.prototype.loadAsync=function(){var t=this;return new Promise(function(e,n){t._isLoading?e():(t.onTasksDoneObservable.addOnce(function(i){i&&i.length?n(i):e()}),t.load())})},r}(),Hi=L(82941),kT=function(){function r(){var t=this;this.promise=new Promise(function(e,n){t._resolve=e,t._reject=n})}return Object.defineProperty(r.prototype,"resolve",{get:function(){return this._resolve},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),r}(),jO=function(){function r(t,e){this._meshesOrigins=[],this._toCenterVectors=[],this._scaledDirection=new _.Pq(1,1,1),this._newPosition=_.Pq.Zero(),this._centerPosition=_.Pq.Zero(),this._meshes=t.slice(),e?this._centerMesh=e:this._setCenterMesh(),this._centerMesh.computeWorldMatrix(!0);var n=this._meshes.indexOf(this._centerMesh);n>=0&&this._meshes.splice(n,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var i=0;i<this._meshes.length;i++)if(this._meshes[i]){var o=this._meshes[i];this._meshesOrigins[i]=o.getAbsolutePosition().clone(),this._toCenterVectors[i]=_.Pq.Zero(),o.hasBoundingInfo&&this._centerMesh.hasBoundingInfo&&(o.computeWorldMatrix(!0),o.getBoundingInfo().boundingBox.centerWorld.subtractToRef(this._centerMesh.getBoundingInfo().boundingBox.centerWorld,this._toCenterVectors[i]))}}return r.prototype._setCenterMesh=function(){for(var t=_.Pq.Zero(),e=_.Pq.Zero(),n=Number.MAX_VALUE,i=0;i<this._meshes.length;i++)this._meshes[i]&&(a=(o=this._meshes[i]).getBoundingInfo())&&e.addInPlace(a.boundingBox.centerWorld);for(t=e.scale(1/this._meshes.length),i=0;i<this._meshes.length;i++){var o,a;if(this._meshes[i]&&(a=(o=this._meshes[i]).getBoundingInfo())){var s=a.boundingBox.centerWorld.subtract(t).lengthSquared();s<n&&(this._centerMesh=o,n=s)}}},r.prototype.getClassName=function(){return"MeshExploder"},r.prototype.getMeshes=function(){var t=this._meshes.slice();return t.unshift(this._centerMesh),t},r.prototype.explode=function(t){t===void 0&&(t=1);for(var e=0;e<this._meshes.length;e++)this._meshes[e]&&this._meshesOrigins[e]&&this._toCenterVectors[e]&&(this._toCenterVectors[e].scaleToRef(t,this._scaledDirection),this._meshesOrigins[e].addToRef(this._scaledDirection,this._newPosition),this._meshes[e].setAbsolutePosition(this._newPosition));this._centerMesh.setAbsolutePosition(this._centerPosition)},r}(),zT=L(23148),qO=function(){function r(t,e,n,i,o,a,s,l,c,u){u===void 0&&(u=!1);var d=this;this.useAppend=u,this.onProcessFileCallback=function(){return!0},this.displayLoadingUI=!0,this.loadAsync=function(h,p){return d.useAppend?yn.AppendAsync("file:",h,d._currentScene,p):yn.LoadAsync("file:",h,d._engine,p)},this._engine=t,this._currentScene=e,this._sceneLoadedCallback=n,this._progressCallback=i,this._additionalRenderLoopLogicCallback=o,this._textureLoadingCallback=a,this._startingProcessingFilesCallback=s,this._onReloadCallback=l,this._errorCallback=c}return Object.defineProperty(r,"FilesToLoad",{get:function(){return zT.T.FilesToLoad},enumerable:!1,configurable:!0}),r.prototype.monitorElementForDragNDrop=function(t){var e=this;t&&(this._elementToMonitor=t,this._dragEnterHandler=function(n){e._drag(n)},this._dragOverHandler=function(n){e._drag(n)},this._dropHandler=function(n){e._drop(n)},this._elementToMonitor.addEventListener("dragenter",this._dragEnterHandler,!1),this._elementToMonitor.addEventListener("dragover",this._dragOverHandler,!1),this._elementToMonitor.addEventListener("drop",this._dropHandler,!1))},Object.defineProperty(r.prototype,"filesToLoad",{get:function(){return this._filesToLoad},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._elementToMonitor&&(this._elementToMonitor.removeEventListener("dragenter",this._dragEnterHandler),this._elementToMonitor.removeEventListener("dragover",this._dragOverHandler),this._elementToMonitor.removeEventListener("drop",this._dropHandler))},r.prototype._renderFunction=function(){if(this._additionalRenderLoopLogicCallback&&this._additionalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var t=this._currentScene.getWaitingItemsCount();t>0&&this._textureLoadingCallback(t)}this._currentScene.render()}},r.prototype._drag=function(t){t.stopPropagation(),t.preventDefault()},r.prototype._drop=function(t){t.stopPropagation(),t.preventDefault(),this.loadFiles(t)},r.prototype._traverseFolder=function(t,e,n,i){var o=this,a=t.createReader(),s=t.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");a.readEntries(function(l){n.count+=l.length;for(var c=0,u=l;c<u.length;c++){var d=u[c];d.isFile?d.file(function(h){h.correctName=s+h.name,e.push(h),--n.count==0&&i()}):d.isDirectory&&o._traverseFolder(d,e,n,i)}--n.count==0&&i()})},r.prototype._processFiles=function(t){for(var e=this,n=0;n<t.length;n++){var i=t[n].correctName.toLowerCase(),o=i.split(".").pop();this.onProcessFileCallback(t[n],i,o,function(a){return e._sceneFileToLoad=a})&&(yn.IsPluginForExtensionAvailable("."+o)&&(this._sceneFileToLoad=t[n]),r.FilesToLoad[i]=t[n])}},r.prototype.loadFiles=function(t){var e=this;if(t&&t.dataTransfer&&t.dataTransfer.files&&(this._filesToLoad=t.dataTransfer.files),t&&t.target&&t.target.files&&(this._filesToLoad=t.target.files),this._filesToLoad&&this._filesToLoad.length!==0&&(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(this._filesToLoad),this._filesToLoad&&this._filesToLoad.length>0)){for(var n=[],i=[],o=t.dataTransfer?t.dataTransfer.items:null,a=0;a<this._filesToLoad.length;a++){var s=this._filesToLoad[a],l=s.name.toLowerCase(),c=void 0;if(s.correctName=l,o){var u=o[a];u.getAsEntry?c=u.getAsEntry():u.webkitGetAsEntry&&(c=u.webkitGetAsEntry())}c&&c.isDirectory?i.push(c):n.push(s)}if(i.length===0)this._processFiles(n),this._processReload();else for(var d={count:i.length},h=0,p=i;h<p.length;h++){var m=p[h];this._traverseFolder(m,n,d,function(){e._processFiles(n),d.count===0&&e._processReload()})}}},r.prototype._processReload=function(){this._onReloadCallback?this._onReloadCallback(this._sceneFileToLoad):this.reload()},r.prototype.reload=function(){var t=this;if(this._sceneFileToLoad)this.useAppend||this._currentScene&&(O.V.errorsCount>0&&O.V.ClearLogCache(),this._engine.stopRenderLoop()),yn.ShowLoadingScreen=!1,this.displayLoadingUI&&this._engine.displayLoadingUI(),this.loadAsync(this._sceneFileToLoad,this._progressCallback).then(function(n){t.useAppend?t.displayLoadingUI&&t._engine.hideLoadingUI():(t._currentScene&&t._currentScene.dispose(),t._currentScene=n,t._currentScene.executeWhenReady(function(){t.displayLoadingUI&&t._engine.hideLoadingUI(),t._engine.runRenderLoop(function(){t._renderFunction()})})),t._sceneLoadedCallback&&t._currentScene&&t._sceneLoadedCallback(t._sceneFileToLoad,t._currentScene)}).catch(function(n){t.displayLoadingUI&&t._engine.hideLoadingUI(),t._errorCallback&&t._errorCallback(t._sceneFileToLoad,t._currentScene,n.message)});else{if(this._filesToLoad.length===1){var e=this._filesToLoad[0].name.toLowerCase().split(".").pop();if(e)switch(e.toLowerCase()){case"dds":case"env":case"hdr":return}}O.V.Error("Please provide a valid .babylon file.")}},r}(),KO=L(88188),ZO=function(){function r(){}return r.prototype.dispose=function(){if(this._observers&&this._observables)for(var t=0;t<this._observers.length;t++)this._observables[t].remove(this._observers[t]);this._observers=null,this._observables=null},r.Watch=function(t,e,n,i){n===void 0&&(n=-1),i===void 0&&(i=null);var o=new r;o._observers=new Array,o._observables=t;for(var a=0,s=t;a<s.length;a++){var l=s[a].add(e,n,!1,i);l&&o._observers.push(l)}return o},r}();K.cP.prototype.notifyObserversWithPromise=function(r,t,e,n,i){return t===void 0&&(t=-1),(0,A.sH)(this,void 0,void 0,function(){var o,a,s=this;return(0,A.YH)(this,function(l){switch(l.label){case 0:return o=Promise.resolve(r),this.observers.length?((a=this._eventState).mask=t,a.target=e,a.currentTarget=n,a.skipNextObservers=!1,a.userInfo=i,this.observers.forEach(function(c){a.skipNextObservers||c._willBeUnregistered||c.mask&t&&(o=c.scope?o.then(function(u){return a.lastReturnValue=u,c.callback.apply(c.scope,[r,a])}):o.then(function(u){return a.lastReturnValue=u,c.callback(r,a)}),c.unregisterOnNextCall&&s._deferUnregister(c))}),[4,o]):[2,o];case 1:return l.sent(),[2,r]}})})};var Qr=function(){function r(t){t===void 0&&(t=0),this.priority=t}return r.prototype.getDescription=function(){return""},r.prototype.apply=function(t,e){return!0},r}(),Bl=function(r){function t(e,n,i){e===void 0&&(e=0),n===void 0&&(n=1024),i===void 0&&(i=.5);var o=r.call(this,e)||this;return o.priority=e,o.maximumSize=n,o.step=i,o}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,n){for(var i=!0,o=0;o<e.textures.length;o++){var a=e.textures[o];if(a.canRescale&&!a.getContext){var s=a.getSize();Math.max(s.width,s.height)>this.maximumSize&&(a.scale(this.step),i=!1)}}return i},t}(Qr),Jf=function(r){function t(e,n,i){e===void 0&&(e=0),n===void 0&&(n=2),i===void 0&&(i=.25);var o=r.call(this,e)||this;return o.priority=e,o.maximumScale=n,o.step=i,o._currentScale=-1,o._directionOffset=1,o}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,n){return this._currentScale===-1&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),this._directionOffset===1?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(Qr),Vl=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,n){return e.shadowsEnabled=n.isInImprovementMode,!0},t}(Qr),Ul=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,n){return e.postProcessesEnabled=n.isInImprovementMode,!0},t}(Qr),Gl=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,n){return e.lensFlaresEnabled=n.isInImprovementMode,!0},t}(Qr),WT=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,n){return!this.onApply||this.onApply(e,n)},t}(Qr),kl=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,n){return e.particlesEnabled=n.isInImprovementMode,!0},t}(Qr),$f=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,n){return e.renderTargetsEnabled=n.isInImprovementMode,!0},t}(Qr),zl=function(r){function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._canBeMerged=function(n){if(!(n instanceof xe))return!1;var i=n;return!(i.isDisposed()||!i.isVisible||!i.isEnabled()||i.instances.length>0||i.skeleton||i.hasLODLevels||i.getTotalVertices()===0)},e}return(0,A.C6)(t,r),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,n,i){for(var o=e.meshes.slice(0),a=o.length,s=0;s<a;s++){var l=[],c=o[s];if(this._canBeMerged(c)){l.push(c);for(var u=s+1;u<a;u++){var d=o[u];this._canBeMerged(d)&&d.material===c.material&&d.checkCollisions===c.checkCollisions&&(l.push(d),a--,o.splice(u,1),u--)}l.length<2||xe.MergeMeshes(l,void 0,!0)}}var h=e;return h.createOrUpdateSelectionOctree&&(i!=null?i&&h.createOrUpdateSelectionOctree():t.UpdateSelectionTree&&h.createOrUpdateSelectionOctree()),!0},t._UpdateSelectionTree=!1,t}(Qr),ep=function(){function r(t,e){t===void 0&&(t=60),e===void 0&&(e=2e3),this.targetFrameRate=t,this.trackerDuration=e,this.optimizations=[]}return r.prototype.addOptimization=function(t){return this.optimizations.push(t),this},r.prototype.addCustomOptimization=function(t,e,n){n===void 0&&(n=0);var i=new WT(n);return i.onApply=t,i.onGetDescription=e,this.optimizations.push(i),this},r.LowDegradationAllowed=function(t){var e=new r(t),n=0;return e.addOptimization(new zl(n)),e.addOptimization(new Vl(n)),e.addOptimization(new Gl(n)),n++,e.addOptimization(new Ul(n)),e.addOptimization(new kl(n)),n++,e.addOptimization(new Bl(n,1024)),e},r.ModerateDegradationAllowed=function(t){var e=new r(t),n=0;return e.addOptimization(new zl(n)),e.addOptimization(new Vl(n)),e.addOptimization(new Gl(n)),n++,e.addOptimization(new Ul(n)),e.addOptimization(new kl(n)),n++,e.addOptimization(new Bl(n,512)),n++,e.addOptimization(new $f(n)),n++,e.addOptimization(new Jf(n,2)),e},r.HighDegradationAllowed=function(t){var e=new r(t),n=0;return e.addOptimization(new zl(n)),e.addOptimization(new Vl(n)),e.addOptimization(new Gl(n)),n++,e.addOptimization(new Ul(n)),e.addOptimization(new kl(n)),n++,e.addOptimization(new Bl(n,256)),n++,e.addOptimization(new $f(n)),n++,e.addOptimization(new Jf(n,4)),e},r}(),QO=function(){function r(t,e,n,i){n===void 0&&(n=!0),i===void 0&&(i=!1);var o=this;if(this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new K.cP,this.onNewOptimizationAppliedObservable=new K.cP,this.onFailureObservable=new K.cP,this._options=e||new ep,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),n)for(var a=0,s=0,l=this._options.optimizations;s<l.length;s++)l[s].priority=a++;this._improvementMode=i,this._scene=t||Ve.q.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(function(){o._sceneDisposeObserver=null,o.dispose()})}return Object.defineProperty(r.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},set:function(t){this._improvementMode=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(t){this._targetFrameRate=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(t){this._trackerDuration=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!1,configurable:!0}),r.prototype.stop=function(){this._isRunning=!1},r.prototype.reset=function(){this._currentPriorityLevel=0},r.prototype.start=function(){var t=this;this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)}))},r.prototype._checkCurrentState=function(){var t=this;if(this._isRunning){var e=this._scene,n=this._options;if(this._currentFrameRate=Math.round(e.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var i=!0,o=!0,a=0;a<n.optimizations.length;a++){var s=n.optimizations[a];s.priority===this._currentPriorityLevel&&(o=!1,i=i&&s.apply(e,this),this.onNewOptimizationAppliedObservable.notifyObservers(s))}if(o)return this._isRunning=!1,void this.onFailureObservable.notifyObservers(this);i&&this._currentPriorityLevel++,e.executeWhenReady(function(){setTimeout(function(){t._checkCurrentState()},t._trackerDuration)})}},r.prototype.dispose=function(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)},r.OptimizeAsync=function(t,e,n,i){var o=new r(t,e||ep.ModerateDegradationAllowed(),!1);return n&&o.onSuccessObservable.add(function(){n()}),i&&o.onFailureObservable.add(function(){i()}),o.start(),o},r}(),HT=[],YT=function(r,t){r.doNotSerialize||(t.vertexData.push(r.serializeVerticeData()),HT[r.id]=!0)},JO=function(r,t){var e={},n=r._geometry;return n&&(r.getScene().getGeometryById(n.id)||YT(n,t.geometries)),r.serialize&&r.serialize(e),e},Wl=function(){function r(){}return r.ClearCache=function(){HT=[]},r.Serialize=function(t){return r._Serialize(t)},r._Serialize=function(t,e){e===void 0&&(e=!0);var n,i,o,a={};if(e&&!t.getEngine()._features.supportSyncTextureRead&&Ie.g.ForceSerializeBuffers&&O.V.Warn("The serialization object may not contain the proper base64 encoded texture data! You should use the SerializeAsync method instead."),r.ClearCache(),a.useDelayedTextureLoading=t.useDelayedTextureLoading,a.autoClear=t.autoClear,a.clearColor=t.clearColor.asArray(),a.ambientColor=t.ambientColor.asArray(),a.gravity=t.gravity.asArray(),a.collisionsEnabled=t.collisionsEnabled,a.useRightHandedSystem=t.useRightHandedSystem,t.fogMode!==void 0&&t.fogMode!==null&&(a.fogMode=t.fogMode),t.fogColor!==void 0&&t.fogColor!==null&&(a.fogColor=t.fogColor.asArray()),t.fogStart!==void 0&&t.fogStart!==null&&(a.fogStart=t.fogStart),t.fogEnd!==void 0&&t.fogEnd!==null&&(a.fogEnd=t.fogEnd),t.fogDensity!==void 0&&t.fogDensity!==null&&(a.fogDensity=t.fogDensity),t.isPhysicsEnabled&&t.isPhysicsEnabled()){var s=t.getPhysicsEngine();s&&(a.physicsEnabled=!0,a.physicsGravity=s.gravity.asArray(),a.physicsEngine=s.getPhysicsPluginName())}t.metadata&&(a.metadata=t.metadata),a.morphTargetManagers=[];for(var l=0,c=t.meshes;l<c.length;l++){var u=(T=c[l]).morphTargetManager;u&&a.morphTargetManagers.push(u.serialize())}for(a.lights=[],n=0;n<t.lights.length;n++)(i=t.lights[n]).doNotSerialize||a.lights.push(i.serialize());for(a.cameras=[],n=0;n<t.cameras.length;n++){var d=t.cameras[n];d.doNotSerialize||a.cameras.push(d.serialize())}if(t.activeCamera&&(a.activeCameraID=t.activeCamera.id),tt.p.AppendSerializedAnimations(t,a),t.animationGroups&&t.animationGroups.length>0){a.animationGroups=[];for(var h=0;h<t.animationGroups.length;h++){var p=t.animationGroups[h];a.animationGroups.push(p.serialize())}}if(t.reflectionProbes&&t.reflectionProbes.length>0)for(a.reflectionProbes=[],n=0;n<t.reflectionProbes.length;n++){var m=t.reflectionProbes[n];a.reflectionProbes.push(m.serialize())}for(a.materials=[],a.multiMaterials=[],n=0;n<t.materials.length;n++)(o=t.materials[n]).doNotSerialize||a.materials.push(o.serialize());for(a.multiMaterials=[],n=0;n<t.multiMaterials.length;n++){var v=t.multiMaterials[n];a.multiMaterials.push(v.serialize())}for(t.environmentTexture&&(t.environmentTexture._files?a.environmentTexture=t.environmentTexture.serialize():(a.environmentTexture=t.environmentTexture.name,a.environmentTextureRotationY=t.environmentTexture.rotationY)),a.environmentIntensity=t.environmentIntensity,a.skeletons=[],n=0;n<t.skeletons.length;n++){var b=t.skeletons[n];b.doNotSerialize||a.skeletons.push(b.serialize())}for(a.transformNodes=[],n=0;n<t.transformNodes.length;n++)t.transformNodes[n].doNotSerialize||a.transformNodes.push(t.transformNodes[n].serialize());a.geometries={},a.geometries.boxes=[],a.geometries.spheres=[],a.geometries.cylinders=[],a.geometries.toruses=[],a.geometries.grounds=[],a.geometries.planes=[],a.geometries.torusKnots=[],a.geometries.vertexData=[],HT=[];var E=t.getGeometries();for(n=0;n<E.length;n++){var C=E[n];C.isReady()&&YT(C,a.geometries)}for(a.meshes=[],n=0;n<t.meshes.length;n++){var T;if((T=t.meshes[n])instanceof xe){var f=T;f.doNotSerialize||f.delayLoadState!==P.Y.DELAYLOADSTATE_LOADED&&f.delayLoadState!==P.Y.DELAYLOADSTATE_NONE||a.meshes.push(JO(f,a))}}for(a.particleSystems=[],n=0;n<t.particleSystems.length;n++)a.particleSystems.push(t.particleSystems[n].serialize(!1));for(a.postProcesses=[],n=0;n<t.postProcesses.length;n++)a.postProcesses.push(t.postProcesses[n].serialize());t.actionManager&&(a.actions=t.actionManager.serialize("scene"));for(var g=0,S=t._serializableComponents;g<S.length;g++)S[g].serialize(a);if(t.spriteManagers)for(a.spriteManagers=[],n=0;n<t.spriteManagers.length;n++)a.spriteManagers.push(t.spriteManagers[n].serialize(!0));return a},r.SerializeAsync=function(t){var e=r._Serialize(t,!1),n=[];return this._CollectPromises(e,n),Promise.all(n).then(function(){return e})},r._CollectPromises=function(t,e){if(Array.isArray(t))for(var n=function(c){var u=t[c];u instanceof Promise?e.push(u.then(function(d){return t[c]=d})):(u instanceof Object||Array.isArray(u))&&i._CollectPromises(u,e)},i=this,o=0;o<t.length;++o)n(o);else if(t instanceof Object){var a=function(c){if(Object.prototype.hasOwnProperty.call(t,c)){var u=t[c];u instanceof Promise?e.push(u.then(function(d){return t[c]=d})):(u instanceof Object||Array.isArray(u))&&s._CollectPromises(u,e)}},s=this;for(var l in t)a(l)}},r.SerializeMesh=function(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var i={meshes:[],transformNodes:[],cameras:[],lights:[]};if(r.ClearCache(),t=t instanceof Array?t:[t],e||n)for(var o=0;o<t.length;++o)n&&t[o].getDescendants().forEach(function(a){t.indexOf(a)<0&&!a.doNotSerialize&&t.push(a)}),e&&t[o].parent&&t.indexOf(t[o].parent)<0&&!t[o].parent.doNotSerialize&&t.push(t[o].parent);return t.forEach(function(a){(function(s,l){if(s._isMesh){var c=s;if(c.delayLoadState===P.Y.DELAYLOADSTATE_LOADED||c.delayLoadState===P.Y.DELAYLOADSTATE_NONE){var u=function(C){l.materials=l.materials||[],c.material&&!l.materials.some(function(T){return T.id===c.material.id})&&l.materials.push(C.serialize())};if(c.material&&!c.material.doNotSerialize)if(c.material instanceof Vr){if(l.multiMaterials=l.multiMaterials||[],!l.multiMaterials.some(function(C){return C.id===c.material.id})){l.multiMaterials.push(c.material.serialize());for(var d=0,h=c.material.subMaterials;d<h.length;d++){var p=h[d];p&&u(p)}}}else u(c.material);else c.material||u(c.getScene().defaultMaterial);var m=c._geometry;m&&(l.geometries||(l.geometries={},l.geometries.boxes=[],l.geometries.spheres=[],l.geometries.cylinders=[],l.geometries.toruses=[],l.geometries.grounds=[],l.geometries.planes=[],l.geometries.torusKnots=[],l.geometries.vertexData=[]),YT(m,l.geometries)),c.skeleton&&!c.skeleton.doNotSerialize&&(l.skeletons=l.skeletons||[],l.skeletons.push(c.skeleton.serialize())),l.meshes=l.meshes||[],l.meshes.push(JO(c,l))}}else if(s.getClassName()==="TransformNode"){var v=s;l.transformNodes.push(v.serialize())}else if(s.getClassName().indexOf("Camera")!==-1){var b=s;l.cameras.push(b.serialize())}else if(s.getClassName().indexOf("Light")!==-1){var E=s;l.lights.push(E.serialize())}})(a,i)}),i},r}(),$O=function(){function r(t,e){e===void 0&&(e={});var n,i=this;if(!r.IsSupported(t,e.canvas))throw"Your browser does not support recording so far.";var o=(n=e.canvas)!==null&&n!==void 0?n:t.getRenderingCanvas();if(!o)throw"The babylon engine must have a canvas to be recorded";this._canvas=o,this._canvas.isRecording=!1,this._options=(0,A.Cl)((0,A.Cl)({},r._DefaultOptions),e);var a=this._canvas.captureStream(this._options.fps);if(this._options.audioTracks)for(var s=0,l=this._options.audioTracks;s<l.length;s++){var c=l[s];a.addTrack(c)}this._mediaRecorder=new MediaRecorder(a,{mimeType:this._options.mimeType}),this._mediaRecorder.ondataavailable=function(u){return i._handleDataAvailable(u)},this._mediaRecorder.onerror=function(u){return i._handleError(u)},this._mediaRecorder.onstop=function(){return i._handleStop()}}return r.IsSupported=function(t,e){var n=e??t.getRenderingCanvas();return!!n&&typeof n.captureStream=="function"},Object.defineProperty(r.prototype,"isRecording",{get:function(){return!!this._canvas&&this._canvas.isRecording},enumerable:!1,configurable:!0}),r.prototype.stopRecording=function(){this._canvas&&this._mediaRecorder&&this.isRecording&&(this._canvas.isRecording=!1,this._mediaRecorder.stop())},r.prototype.startRecording=function(t,e){var n=this;if(t===void 0&&(t="babylonjs.webm"),e===void 0&&(e=7),!this._canvas||!this._mediaRecorder)throw"Recorder has already been disposed";if(this.isRecording)throw"Recording already in progress";return e>0&&setTimeout(function(){n.stopRecording()},1e3*e),this._fileName=t,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise(function(i,o){n._resolve=i,n._reject=o})},r.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},r.prototype._handleDataAvailable=function(t){t.data.size>0&&this._recordedChunks.push(t.data)},r.prototype._handleError=function(t){if(this.stopRecording(),!this._reject)throw new t.error;this._reject(t.error)},r.prototype._handleStop=function(){this.stopRecording();var t=new Blob(this._recordedChunks);this._resolve&&this._resolve(t),window.URL.createObjectURL(t),this._fileName&&ze.S0.Download(t,this._fileName)},r._DefaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},r}(),Hl=L(24687),Wo=null;function vs(r,t,e,n,i,o,a){i===void 0&&(i="image/png"),o===void 0&&(o=!1);var s=e1(r,t,e),l=s.height,c=s.width;if(l&&c){Wo||(Wo=document.createElement("canvas")),Wo.width=c,Wo.height=l;var u=Wo.getContext("2d"),d=r.getRenderWidth()/r.getRenderHeight(),h=c,p=h/d;p>l&&(h=(p=l)*d);var m=Math.max(0,c-h)/2,v=Math.max(0,l-p)/2;t.getScene().activeCamera!==t?ys(r,t,e,function(b){if(o){var E=new Blob([b]);ze.S0.DownloadBlob(E),n&&n("")}else n&&n(b)},i,1,r.getCreationOptions().antialias,void 0,void 0,void 0,void 0,a):r.onEndFrameObservable.addOnce(function(){var b=r.getRenderingCanvas();u&&b&&u.drawImage(b,m,v,h,p),Wo&&(o?(ze.S0.EncodeScreenshotCanvasData(Wo,void 0,i,void 0,a),n&&n("")):ze.S0.EncodeScreenshotCanvasData(Wo,n,i,void 0,a))})}else O.V.Error("Invalid 'size' parameter !")}function tp(r,t,e,n,i){return n===void 0&&(n="image/png"),new Promise(function(o,a){vs(r,t,e,function(s){s!==void 0?o(s):a(new Error("Data is undefined"))},n,void 0,i)})}function XT(r,t,e,n,i,o){return i===void 0&&(i="image/png"),new Promise(function(a){vs(r,t,{width:e,height:n},function(){a()},i,!0,o)})}function ys(r,t,e,n,i,o,a,s,l,c,u,d,h){i===void 0&&(i="image/png"),o===void 0&&(o=1),a===void 0&&(a=!1),l===void 0&&(l=!1),c===void 0&&(c=!1),u===void 0&&(u=!0);var p=e1(r,t,e),m=p.height,v=p.width,b=p.finalWidth,E=p.finalHeight,C={width:v,height:m};if(m&&v){var T={width:r.getRenderWidth(),height:r.getRenderHeight()};r.setSize(v,m);var f=t.getScene(),g=new un.$("screenShot",C,f,!1,!1,P.Y.TEXTURETYPE_UNSIGNED_INT,!1,Ie.g.BILINEAR_SAMPLINGMODE,void 0,c,void 0,void 0,void 0,o);g.renderList=f.meshes.slice(),g.samples=o,g.renderSprites=l,g.activeCamera=t,g.forceLayerMaskCheck=u,h?.(g);var S=function(){g.isReadyForRendering()&&t.isReady(!0)?(r.onEndFrameObservable.addOnce(function(){b===v&&E===m?g.readPixels(void 0,void 0,void 0,!1).then(function(R){(0,Hl.RJ)(v,m,R,n,i,s,!0,void 0,d),g.dispose()}):(0,Si.Qs)("pass",g.getInternalTexture(),f,void 0,void 0,void 0,b,E).then(function(R){r._readTexturePixels(R,b,E,-1,0,null,!0,!1,0,0).then(function(I){(0,Hl.RJ)(b,E,I,n,i,s,!0,void 0,d),R.dispose()})})}),f.incrementRenderId(),f.resetCachedMaterial(),g.render(!0),r.setSize(T.width,T.height),t.getProjectionMatrix(!0),f.render()):setTimeout(S,16)},y=function(){f.incrementRenderId(),f.resetCachedMaterial(),S()};if(a){var x=new ms("antialiasing",1,f.activeCamera);g.addPostProcess(x),x.onEffectCreatedObservable.addOnce(function(R){R.isReady()?y():R.onCompiled=function(){y()}})}else y()}else O.V.Error("Invalid 'size' parameter !")}function np(r,t,e,n,i,o,a,s,l,c,u,d){return n===void 0&&(n="image/png"),i===void 0&&(i=1),o===void 0&&(o=!1),s===void 0&&(s=!1),l===void 0&&(l=!1),c===void 0&&(c=!0),new Promise(function(h,p){ys(r,t,e,function(m){m!==void 0?h(m):p(new Error("Data is undefined"))},n,i,o,a,s,l,c,u,d)})}function e1(r,t,e){var n=0,i=0,o=0,a=0;if(typeof e=="object"){var s=e.precision?Math.abs(e.precision):1;e.width&&e.height?(n=e.height*s,i=e.width*s):e.width&&!e.height?(i=e.width*s,n=Math.round(i/r.getAspectRatio(t))):e.height&&!e.width?(n=e.height*s,i=Math.round(n*r.getAspectRatio(t))):(i=Math.round(r.getRenderWidth()*s),n=Math.round(i/r.getAspectRatio(t))),e.finalWidth&&e.finalHeight?(a=e.finalHeight,o=e.finalWidth):e.finalWidth&&!e.finalHeight?(o=e.finalWidth,a=Math.round(o/r.getAspectRatio(t))):e.finalHeight&&!e.finalWidth?(a=e.finalHeight,o=Math.round(a*r.getAspectRatio(t))):(o=i,a=n)}else isNaN(e)||(n=e,i=e,o=e,a=e);return i&&(i=Math.floor(i)),n&&(n=Math.floor(n)),o&&(o=Math.floor(o)),a&&(a=Math.floor(a)),{height:0|n,width:0|i,finalWidth:0|o,finalHeight:0|a}}var ip,t1={CreateScreenshot:vs,CreateScreenshotAsync:tp,CreateScreenshotWithResizeAsync:XT,CreateScreenshotUsingRenderTarget:ys,CreateScreenshotUsingRenderTargetAsync:np};ze.S0.CreateScreenshot=vs,ze.S0.CreateScreenshotAsync=tp,ze.S0.CreateScreenshotUsingRenderTarget=ys,ze.S0.CreateScreenshotUsingRenderTargetAsync=np,function(r){r[r.Checkbox=0]="Checkbox",r[r.Slider=1]="Slider",r[r.Vector3=2]="Vector3",r[r.Quaternion=3]="Quaternion",r[r.Color3=4]="Color3",r[r.String=5]="String",r[r.Button=6]="Button",r[r.Options=7]="Options",r[r.Tab=8]="Tab",r[r.FileButton=9]="FileButton",r[r.Vector2=10]="Vector2"}(ip||(ip={}));var bs,n1=L(49449),i1=function(){function r(t){this.byteOffset=0,this.buffer=t}return r.prototype.loadAsync=function(t){var e=this;return this.buffer.readAsync(this.byteOffset,t).then(function(n){e._dataView=new DataView(n.buffer,n.byteOffset,n.byteLength),e._dataByteOffset=0})},r.prototype.readUint32=function(){var t=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,t},r.prototype.readUint8Array=function(t){var e=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,t);return this._dataByteOffset+=t,this.byteOffset+=t,e},r.prototype.readString=function(t){return(0,fi.Tq)(this.readUint8Array(t))},r.prototype.skipBytes=function(t){this._dataByteOffset+=t,this.byteOffset+=t},r}(),r1=function(){function r(){}return r._GetStorage=function(){try{return localStorage.setItem("test",""),localStorage.removeItem("test"),localStorage}catch{var t={};return{getItem:function(n){var i=t[n];return i===void 0?null:i},setItem:function(n,i){t[n]=i}}}},r.ReadString=function(t,e){var n=this._Storage.getItem(t);return n!==null?n:e},r.WriteString=function(t,e){this._Storage.setItem(t,e)},r.ReadBoolean=function(t,e){var n=this._Storage.getItem(t);return n!==null?n==="true":e},r.WriteBoolean=function(t,e){this._Storage.setItem(t,e?"true":"false")},r.ReadNumber=function(t,e){var n=this._Storage.getItem(t);return n!==null?parseFloat(n):e},r.WriteNumber=function(t,e){this._Storage.setItem(t,e.toString())},r._Storage=r._GetStorage(),r}(),o1=function(){function r(){this._trackedScene=null}return r.prototype.track=function(t){this._trackedScene=t,tt.p.AllowLoadingUniqueId=!0,this._savedJSON=Wl.Serialize(t),tt.p.AllowLoadingUniqueId=!1},r.prototype.getDelta=function(){if(!this._trackedScene)return null;var t=Ie.g.ForceSerializeBuffers;Ie.g.ForceSerializeBuffers=!1,tt.p.AllowLoadingUniqueId=!0;var e=Wl.Serialize(this._trackedScene);tt.p.AllowLoadingUniqueId=!1;var n={};for(var i in e)this._compareCollections(i,this._savedJSON[i],e[i],n);return Ie.g.ForceSerializeBuffers=t,n},r.prototype._compareArray=function(t,e,n,i){if(e.length===0&&n.length===0)return!0;if(e.length&&!isNaN(e[0])||n.length&&!isNaN(n[0])){if(e.length!==n.length)return!1;if(e.length===0)return!0;for(var o=0;o<e.length;o++)if(e[o]!==n[o])return i[t]=n,!1;return!0}var a=[],s=function(d){var h=e[d],p=h.uniqueId;a.push(p);var m=n.filter(function(E){return E.uniqueId===p});if(m.length){var v=m[0],b={};l._compareObjects(h,v,b)||(i[t]||(i[t]=[]),b.__state={id:v.id||v.name},i[t].push(b))}else b={__state:{deleteId:h.id||h.name}},i[t]||(i[t]=[]),i[t].push(b)},l=this;for(o=0;o<e.length;o++)s(o);for(o=0;o<n.length;o++){var c=n[o],u=c.uniqueId;a.indexOf(u)===-1&&(i[t]||(i[t]=[]),i[t].push(c))}return!0},r.prototype._compareObjects=function(t,e,n){var i=!1;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var a=t[o],s=e[o],l=!1;if(Array.isArray(a))l=JSON.stringify(a)!==JSON.stringify(s);else if(isNaN(a)&&Object.prototype.toString.call(a)!="[object String]"){if(typeof a=="object"&&typeof s=="object"){var c={};this._compareObjects(a,s,c)||(n[o]=c,i=!0)}}else l=a!==s;l&&(i=!0,n[o]=s)}return!i},r.prototype._compareCollections=function(t,e,n,i){if(e!==n&&e&&n){if(Array.isArray(e)&&Array.isArray(n)){if(this._compareArray(t,e,n,i))return}else if(typeof e=="object"&&typeof n=="object"){var o={};return void(this._compareObjects(e,n,o)||(i[t]=o))}}},r.GetShadowGeneratorById=function(t,e){for(var n=0,i=t.lights.map(function(c){return c.getShadowGenerators()});n<i.length;n++){var o=i[n];if(o)for(var a=o.values(),s=a.next();s.done!==!0;s=a.next()){var l=s.value;if(l&&l.id===e)return l}}return null},r.ApplyDelta=function(t,e){var n=this;typeof t=="string"&&(t=JSON.parse(t));var i=e;for(var o in t){var a=t[o],s=i[o];if(Array.isArray(s)||o==="shadowGenerators")switch(o){case"cameras":this._ApplyDeltaForEntity(a,e,e.getCameraById.bind(e),function(l){return Pt.Parse(l,e)});break;case"lights":this._ApplyDeltaForEntity(a,e,e.getLightById.bind(e),function(l){return hi.Parse(l,e)});break;case"shadowGenerators":this._ApplyDeltaForEntity(a,e,function(l){return n.GetShadowGeneratorById(e,l)},function(l){return zi.Parse(l,e)});break;case"meshes":this._ApplyDeltaForEntity(a,e,e.getMeshById.bind(e),function(l){return xe.Parse(l,e,"")});break;case"skeletons":this._ApplyDeltaForEntity(a,e,e.getSkeletonById.bind(e),function(l){return xa.Parse(l,e)});break;case"materials":this._ApplyDeltaForEntity(a,e,e.getMaterialById.bind(e),function(l){return Lt.Parse(l,e,"")});break;case"multiMaterials":this._ApplyDeltaForEntity(a,e,e.getMaterialById.bind(e),function(l){return Vr.Parse(l,e,"")});break;case"transformNodes":this._ApplyDeltaForEntity(a,e,e.getTransformNodeById.bind(e),function(l){return jt.Parse(l,e,"")});break;case"particleSystems":this._ApplyDeltaForEntity(a,e,e.getParticleSystemById.bind(e),function(l){return Pn.Parse(l,e,"")});break;case"morphTargetManagers":this._ApplyDeltaForEntity(a,e,e.getMorphTargetById.bind(e),function(l){return Tl.Parse(l,e)});break;case"postProcesses":this._ApplyDeltaForEntity(a,e,e.getPostProcessByName.bind(e),function(l){return _t.w.Parse(l,e,"")})}else isNaN(s)?s.fromArray&&s.fromArray(a):i[o]=a}},r._ApplyPropertiesToEntity=function(t,e){for(var n in t){var i=t[n],o=e[n];o!==void 0&&(!isNaN(o)||Array.isArray(o)?e[n]=i:o.fromArray?o.fromArray(i):typeof o=="object"&&o!==null&&this._ApplyPropertiesToEntity(i,o))}},r._ApplyDeltaForEntity=function(t,e,n,i){for(var o=0,a=t;o<a.length;o++){var s=a[o];if(s.__state&&s.__state.id!==void 0){var l=n(s.__state.id);l&&(this._ApplyPropertiesToEntity(s,l),tt.p.ParseProperties(s,l,e,null))}else if(s.__state&&s.__state.deleteId!==void 0){var c=n(s.__state.deleteId);c?.dispose()}else i(s)}},r}(),rp=L(47347);(function(r){var t=function(){function n(i,o,a,s){var l;o===void 0&&(o=null),a===void 0&&(a=null),s===void 0&&(s=null),o=o??function(){return 1},a=a??function(){return 1},s=s??function(d,h){return d===h?0:1},this._characterToIdx=new Map,this._insertionCosts=new Array(i.length),this._deletionCosts=new Array(i.length),this._substitutionCosts=new Array(i.length);for(var c=0;c<i.length;++c){l=i[c],this._characterToIdx.set(l,c),this._insertionCosts[c]=o(l),this._deletionCosts[c]=a(l),this._substitutionCosts[c]=new Array(i.length);for(var u=c;u<i.length;++u)this._substitutionCosts[c][u]=s(l,i[u])}}return n.prototype.serialize=function(){var i={},o=new Array(this._characterToIdx.size);return this._characterToIdx.forEach(function(a,s){o[a]=s}),i.characters=o,i.insertionCosts=this._insertionCosts,i.deletionCosts=this._deletionCosts,i.substitutionCosts=this._substitutionCosts,JSON.stringify(i)},n.Deserialize=function(i){var o=JSON.parse(i),a=new n(o.characters);return a._insertionCosts=o.insertionCosts,a._deletionCosts=o.deletionCosts,a._substitutionCosts=o.substitutionCosts,a},n.prototype.getCharacterIdx=function(i){return this._characterToIdx.get(i)},n.prototype.getInsertionCost=function(i){return this._insertionCosts[i]},n.prototype.getDeletionCost=function(i){return this._deletionCosts[i]},n.prototype.getSubstitutionCost=function(i,o){var a=Math.min(i,o),s=Math.max(i,o);return this._substitutionCosts[a][s]},n}();r.Alphabet=t;var e=function(){function n(i,o){var a=this;if(i.length>n._MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+n._MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=o,this._characters=i.map(function(s){return a._alphabet.getCharacterIdx(s)})}return n.prototype.serialize=function(){return JSON.stringify(this._characters)},n.Deserialize=function(i,o){var a=new n([],o);return a._characters=JSON.parse(i),a},n.prototype.distance=function(i){return n._Distance(this,i)},n._Distance=function(i,o){var a=i._alphabet;if(a!==o._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var s=i._characters,l=o._characters,c=s.length,u=l.length,d=n._CostMatrix;d[0][0]=0;for(var h=0;h<c;++h)d[h+1][0]=d[h][0]+a.getInsertionCost(s[h]);for(h=0;h<u;++h)d[0][h+1]=d[0][h]+a.getInsertionCost(l[h]);for(var p=0;p<c;++p)for(var m=0;m<u;++m)n._InsertionCost=d[p+1][m]+a.getInsertionCost(l[m]),n._DeletionCost=d[p][m+1]+a.getDeletionCost(s[p]),n._SubstitutionCost=d[p][m]+a.getSubstitutionCost(s[p],l[m]),d[p+1][m+1]=Math.min(n._InsertionCost,n._DeletionCost,n._SubstitutionCost);return d[c][u]},n._MAX_SEQUENCE_LENGTH=256,n._CostMatrix=(0,A.fX)([],Array(n._MAX_SEQUENCE_LENGTH+1),!0).map(function(){return new Array(n._MAX_SEQUENCE_LENGTH+1)}),n}();r.Sequence=e})(bs||(bs={}));var a1=function(){function r(t){t===void 0&&(t=.01),this._points=[],this._segmentLength=t}return r.prototype.serialize=function(){return JSON.stringify(this)},r.Deserialize=function(t){var e=JSON.parse(t),n=new r(e._segmentLength);return n._points=e._points.map(function(i){return new _.Pq(i._x,i._y,i._z)}),n},r.prototype.getLength=function(){return this._points.length*this._segmentLength},r.prototype.add=function(t){var e=this,n=this._points.length;if(n===0)this._points.push(t.clone());else for(var i=function(){return e._segmentLength/_.Pq.Distance(e._points[n-1],t)},o=i();o<=1;o=i()){var a=this._points[n-1].scale(1-o);t.scaleAndAddToRef(o,a),this._points.push(a),++n}},r.prototype.resampleAtTargetResolution=function(t){var e=new r(this.getLength()/t);return this._points.forEach(function(n){e.add(n)}),e},r.prototype.tokenize=function(t){for(var e=[],n=new _.Pq,i=2;i<this._points.length;++i)r._TransformSegmentDirToRef(this._points[i-2],this._points[i-1],this._points[i],n)&&e.push(r._TokenizeSegment(n,t));return e},r._TransformSegmentDirToRef=function(t,e,n,i){return e.subtractToRef(t,r._ForwardDir),r._ForwardDir.normalize(),e.scaleToRef(-1,r._InverseFromVec),r._InverseFromVec.normalize(),!(Math.abs(_.Pq.Dot(r._ForwardDir,r._InverseFromVec))>.98||(_.Pq.CrossToRef(r._ForwardDir,r._InverseFromVec,r._UpDir),r._UpDir.normalize(),_.uq.LookAtLHToRef(t,e,r._UpDir,r._LookMatrix),n.subtractToRef(e,r._FromToVec),r._FromToVec.normalize(),_.Pq.TransformNormalToRef(r._FromToVec,r._LookMatrix,i),0))},r._TokenizeSegment=function(t,e){r._BestMatch=0,r._Score=_.Pq.Dot(t,e[0]),r._BestScore=r._Score;for(var n=1;n<e.length;++n)r._Score=_.Pq.Dot(t,e[n]),r._Score>r._BestScore&&(r._BestMatch=n,r._BestScore=r._Score);return r._BestMatch},r._ForwardDir=new _.Pq,r._InverseFromVec=new _.Pq,r._UpDir=new _.Pq,r._FromToVec=new _.Pq,r._LookMatrix=new _.uq,r}(),s1=function(){function r(t){this.chars=new Array(t)}return r.Generate=function(t,e,n,i,o){t===void 0&&(t=64),e===void 0&&(e=256),n===void 0&&(n=.1),i===void 0&&(i=.001),o===void 0&&(o=[]);for(var a,s,l=new r(t),c=0;c<t;++c)l.chars[c]=new _.Pq(Math.random()-.5,Math.random()-.5,Math.random()-.5),l.chars[c].normalize();for(c=0;c<o.length;++c)l.chars[c].copyFrom(o[c]);for(var u,d=new _.Pq,h=new _.Pq,p=0;p<e;++p){a=(1-(u=p/(e-1)))*n+u*i;var m=function(v){d.copyFromFloats(0,0,0),l.chars.forEach(function(b){l.chars[v].subtractToRef(b,h),(s=h.lengthSquared())>1e-6&&h.scaleAndAddToRef(1/(h.lengthSquared()*s),d)}),d.scaleInPlace(a),l.chars[v].addInPlace(d),l.chars[v].normalize()};for(c=o.length;c<l.chars.length;++c)m(c)}return l},r.prototype.serialize=function(){return JSON.stringify(this.chars)},r.Deserialize=function(t){for(var e=JSON.parse(t),n=new r(e.length),i=0;i<e.length;++i)n.chars[i]=new _.Pq(e[i]._x,e[i]._y,e[i]._z);return n},r}(),jT=function(){function r(){this._sequences=[]}return r.prototype.serialize=function(){return JSON.stringify(this._sequences.map(function(t){return t.serialize()}))},r.Deserialize=function(t,e){var n=new r;return n._sequences=JSON.parse(t).map(function(i){return bs.Sequence.Deserialize(i,e)}),n},r.CreateFromTrajectory=function(t,e,n){return r.CreateFromTokenizationPyramid(r._GetTokenizationPyramid(t,e),n)},r.CreateFromTokenizationPyramid=function(t,e){var n=new r;return n._sequences=t.map(function(i){return new bs.Sequence(i,e)}),n},r._GetTokenizationPyramid=function(t,e,n){n===void 0&&(n=r._FINEST_DESCRIPTOR_RESOLUTION);for(var i=[],o=n;o>4;o=Math.floor(o/2))i.push(t.resampleAtTargetResolution(o).tokenize(e.chars));return i},r.prototype.distance=function(t){for(var e=0,n=0;n<this._sequences.length;++n)e+=Math.pow(2,n)*this._sequences[n].distance(t._sequences[n]);return e},r._FINEST_DESCRIPTOR_RESOLUTION=32,r}(),l1=function(){function r(t){t===void 0&&(t=[]),this._descriptors=t,this._centroidIdx=-1,this._averageDistance=0,this._refreshDescription()}return r.prototype.serialize=function(){var t={};return t.descriptors=this._descriptors.map(function(e){return e.serialize()}),t.centroidIdx=this._centroidIdx,t.averageDistance=this._averageDistance,JSON.stringify(t)},r.Deserialize=function(t,e){var n=JSON.parse(t),i=new r;return i._descriptors=n.descriptors.map(function(o){return jT.Deserialize(o,e)}),i._centroidIdx=n.centroidIdx,i._averageDistance=n.averageDistance,i},r.prototype.add=function(t){this._descriptors.push(t),this._refreshDescription()},r.prototype.getMatchCost=function(t){return t.distance(this._descriptors[this._centroidIdx])/this._averageDistance},r.prototype.getMatchMinimumDistance=function(t){return Math.min.apply(Math,this._descriptors.map(function(e){return e.distance(t)}))},r.prototype._refreshDescription=function(){var t,e=this;this._centroidIdx=-1;for(var n=this._descriptors.map(function(o){return t=0,e._descriptors.forEach(function(a){t+=o.distance(a)}),t}),i=0;i<n.length;++i)(this._centroidIdx<0||n[i]<n[this._centroidIdx])&&(this._centroidIdx=i);this._averageDistance=0,this._descriptors.forEach(function(o){e._averageDistance+=o.distance(e._descriptors[e._centroidIdx])}),this._descriptors.length>0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,r._MIN_AVERAGE_DISTANCE))},r._MIN_AVERAGE_DISTANCE=1,r}(),c1=function(){function r(){this._maximumAllowableMatchCost=4,this._nameToDescribedTrajectory=new Map}return r.prototype.serialize=function(){var t={};return t.maximumAllowableMatchCost=this._maximumAllowableMatchCost,t.vector3Alphabet=this._vector3Alphabet.serialize(),t.levenshteinAlphabet=this._levenshteinAlphabet.serialize(),t.nameToDescribedTrajectory=[],this._nameToDescribedTrajectory.forEach(function(e,n){t.nameToDescribedTrajectory.push(n),t.nameToDescribedTrajectory.push(e.serialize())}),JSON.stringify(t)},r.Deserialize=function(t){var e=JSON.parse(t),n=new r;n._maximumAllowableMatchCost=e.maximumAllowableMatchCost,n._vector3Alphabet=s1.Deserialize(e.vector3Alphabet),n._levenshteinAlphabet=bs.Alphabet.Deserialize(e.levenshteinAlphabet);for(var i=0;i<e.nameToDescribedTrajectory.length;i+=2)n._nameToDescribedTrajectory.set(e.nameToDescribedTrajectory[i],l1.Deserialize(e.nameToDescribedTrajectory[i+1],n._levenshteinAlphabet));return n},r.Generate=function(){for(var t=s1.Generate(64,256,.1,.001,[_.Pq.Forward()]),e=new Array(t.chars.length),n=0;n<e.length;++n)e[n]=n;var i=new bs.Alphabet(e,function(a){return a===0?0:1},function(a){return a===0?0:1},function(a,s){return Math.min(1-_.Pq.Dot(t.chars[a],t.chars[s]),1)}),o=new r;return o._vector3Alphabet=t,o._levenshteinAlphabet=i,o},r.prototype.addTrajectoryToClassification=function(t,e){this._nameToDescribedTrajectory.has(e)||this._nameToDescribedTrajectory.set(e,new l1),this._nameToDescribedTrajectory.get(e).add(jT.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet))},r.prototype.deleteClassification=function(t){return this._nameToDescribedTrajectory.delete(t)},r.prototype.classifyTrajectory=function(t){var e=this,n=jT.CreateFromTrajectory(t,this._vector3Alphabet,this._levenshteinAlphabet),i=[];if(this._nameToDescribedTrajectory.forEach(function(c,u){c.getMatchCost(n)<e._maximumAllowableMatchCost&&i.push(u)}),i.length===0)return null;for(var o,a=0,s=this._nameToDescribedTrajectory.get(i[a]).getMatchMinimumDistance(n),l=0;l<i.length;++l)(o=this._nameToDescribedTrajectory.get(i[l]).getMatchMinimumDistance(n))<s&&(s=o,a=l);return i[a]},r}(),Ho=L(75838),u1=function(){function r(t,e,n){var i=this;this._scene=t,O.V.Log("[Reflector] Connecting to ws://".concat(e,":").concat(n)),this._webSocket=new WebSocket("ws://".concat(e,":").concat(n)),this._webSocket.onmessage=function(o){var a=o.data;if(a.startsWith(r._SERVER_PREFIX)){var s=a.substring(r._SERVER_PREFIX.length);return O.V.Log("[Reflector] Received server message: ".concat(s.substring(0,64))),void i._handleServerMessage(s)}O.V.Log("[Reflector] Received client message: ".concat(a.substring(0,64))),i._handleClientMessage()},this._webSocket.onclose=function(o){O.V.Log("[Reflector] Disconnected ".concat(o.code," ").concat(o.reason))}}return r.prototype.close=function(){this._webSocket.close()},r.prototype._handleServerMessage=function(t){var e=this;t==="connected"&&Wl.SerializeAsync(this._scene).then(function(n){e._webSocket.send("load|".concat(JSON.stringify(n)))})},r.prototype._handleClientMessage=function(){},r._SERVER_PREFIX="$$",r}(),qT=function(){function r(t){var e=this;this._observer=null,this._currentState=[],this.onPressureChanged=new K.cP,r.IsAvailable&&(this._observer=new PressureObserver(function(n){e._currentState=n,e.onPressureChanged.notifyObservers(n)},t))}return Object.defineProperty(r,"IsAvailable",{get:function(){return typeof PressureObserver<"u"&&PressureObserver.knownSources&&PressureObserver.knownSources.includes("cpu")},enumerable:!1,configurable:!0}),r.prototype.observe=function(t){var e;try{(e=this._observer)===null||e===void 0||e.observe(t),this.onPressureChanged.notifyObservers(this._currentState)}catch{}},r.prototype.unobserve=function(t){var e;try{(e=this._observer)===null||e===void 0||e.unobserve(t)}catch{}},r.prototype.dispose=function(){var t;(t=this._observer)===null||t===void 0||t.disconnect(),this._observer=null,this.onPressureChanged.clear()},r}(),ho=function(){function r(t){this._view=new Float32Array(t),this._itemLength=0}return Object.defineProperty(r.prototype,"itemLength",{get:function(){return this._itemLength},enumerable:!1,configurable:!0}),r.prototype.at=function(t){return t<0||t>=this._itemLength?NaN:this._view[t]},r.prototype.subarray=function(t,e){return t>=e||t<0?new Float32Array(0):(e>this._itemLength&&(e=this._itemLength),this._view.subarray(t,e))},r.prototype.push=function(t){this._view[this._itemLength]=t,this._itemLength++,this._itemLength>=this._view.length&&this._growArray()},r.prototype._growArray=function(){var t=Math.floor(1.5*this._view.length),e=new Float32Array(t);e.set(this._view),this._view=e},r}(),Yo=1800,d1="timestamp",h1="numPoints",YN=/\r/g,KT=function(){function r(t,e){var n=this;this._scene=t,this._collectDataAtFrame=function(){var i=et.j.Now-n._startingTimestamp,o=n.datasets.ids.length,a=n.datasets.startingIndices.itemLength,s=0;if(a>0){var l=n.datasets.startingIndices.at(a-1);s=l+n.datasets.data.at(l+r.NumberOfPointsOffset)+r.SliceDataOffset}if(n.datasets.startingIndices.push(s),n.datasets.data.push(i),n.datasets.data.push(o),n.datasets.ids.forEach(function(d){var h=n._strategies.get(d);h&&n.datasets.data.push(h.getData())}),n.datasetObservable.hasObservers()){for(var c=[i,o],u=0;u<o;u++)c.push(n.datasets.data.at(s+r.SliceDataOffset+u));n.datasetObservable.notifyObservers(c)}},this.datasets={ids:[],data:new ho(Yo),startingIndices:new ho(Yo)},this._strategies=new Map,this._datasetMeta=new Map,this._eventRestoreSet=new Set,this._customEventObservable=new K.cP,this.datasetObservable=new K.cP,this.metadataObservable=new K.cP(function(i){return i.callback(n._datasetMeta,new K.qO(0))}),e&&this.addCollectionStrategies.apply(this,e)}return Object.defineProperty(r,"SliceDataOffset",{get:function(){return 2},enumerable:!1,configurable:!0}),Object.defineProperty(r,"NumberOfPointsOffset",{get:function(){return 1},enumerable:!1,configurable:!0}),r.prototype.registerEvent=function(t,e,n){var i,o=this;if(!this._strategies.has(t)||e){this._strategies.has(t)&&e&&((i=this._strategies.get(t))===null||i===void 0||i.dispose(),this._strategies.delete(t));var a={name:t};return this._eventRestoreSet.add(t),this.addCollectionStrategies({strategyCallback:function(s){var l=0,c=0,u=s.onAfterRenderObservable.add(function(){c=l,l=0}),d=o._customEventObservable.add(function(h){t===h.name&&(h.value!==void 0?l=h.value:l++)});return{id:t,getData:function(){return c},dispose:function(){s.onAfterRenderObservable.remove(u),o._customEventObservable.remove(d)}}},category:n}),a}},r.prototype.sendEvent=function(t){this._customEventObservable.notifyObservers(t)},r.prototype._restoreStringEvents=function(){var t=this;this._eventRestoreSet.size!==this._customEventObservable.observers.length&&this._eventRestoreSet.forEach(function(e){t.registerEvent(e,!0)})},r.prototype.addCollectionStrategies=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0,i=t;n<i.length;n++){var o=i[n],a=o.strategyCallback,s=o.category,l=o.hidden,c=a(this._scene);this._strategies.has(c.id)?c.dispose():(this.datasets.ids.push(c.id),s&&(s=s.replace(new RegExp("@","g"),"")),this._datasetMeta.set(c.id,{color:this._getHexColorFromId(c.id),category:s,hidden:l}),this._strategies.set(c.id,c))}this.metadataObservable.notifyObservers(this._datasetMeta)},r.prototype._getHexColorFromId=function(t){for(var e=0,n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);var i="#";for(n=0;n<24;n+=8){var o="0"+(e>>n&255).toString(16);i+=o.substring(o.length-2)}return i},r.prototype.getCurrentSlice=function(){var t=this,e=[et.j.Now-this._startingTimestamp,this.datasets.ids.length];this.datasets.ids.forEach(function(n){var i=t._strategies.get(n);i&&t.datasetObservable.hasObservers()&&e.push(i.getData())}),this.datasetObservable.hasObservers()&&this.datasetObservable.notifyObservers(e)},r.prototype.updateMetadata=function(t,e,n){var i=this._datasetMeta.get(t);i&&(i[e]=n,this.metadataObservable.notifyObservers(this._datasetMeta))},r.prototype.clear=function(t){this.datasets.data=new ho(Yo),this.datasets.ids.length=0,this.datasets.startingIndices=new ho(Yo),this._datasetMeta.clear(),this._strategies.forEach(function(e){return e.dispose()}),this._strategies.clear(),t||this._eventRestoreSet.clear(),this._hasLoadedData=!1},Object.defineProperty(r.prototype,"hasLoadedData",{get:function(){return this._hasLoadedData},enumerable:!1,configurable:!0}),r.prototype.loadFromFileData=function(t,e){var n=t.replace(YN,"").split(`
|
||
`).map(function(S){return S.split(",").filter(function(y){return y.length>0})}).filter(function(S){return S.length>0}),i=r.NumberOfPointsOffset;if(n.length<2)return!1;var o={ids:[],data:new ho(Yo),startingIndices:new ho(Yo)},a=n[0],s=n.slice(1);if(a.length<2||a[0]!==d1||a[i]!==h1)return!1;for(var l=new Map,c=r.SliceDataOffset;c<a.length;c++){var u=a[c].split("@"),d=u[0],h=u[1];o.ids.push(d),l.set(d,h)}for(var p=0,m=0,v=s;m<v.length;m++){var b=v[m];if(b.length<2)return!1;var E=parseFloat(b[0]),C=parseInt(b[i]);if(isNaN(C)||isNaN(E)||(o.data.push(E),o.data.push(C),C+r.SliceDataOffset!==b.length))return!1;for(c=r.SliceDataOffset;c<b.length;c++){var T=parseFloat(b[c]);if(isNaN(T))return!1;o.data.push(T)}o.startingIndices.push(p),p+=b.length}if(this.datasets.ids=o.ids,this.datasets.data=o.data,this.datasets.startingIndices=o.startingIndices,e||this._datasetMeta.clear(),this._strategies.forEach(function(S){return S.dispose()}),this._strategies.clear(),!e)for(var f=0,g=this.datasets.ids;f<g.length;f++)d=g[f],h=l.get(d),this._datasetMeta.set(d,{category:h,color:this._getHexColorFromId(d)});return this.metadataObservable.notifyObservers(this._datasetMeta),this._hasLoadedData=!0,!0},r.prototype.exportDataToCsv=function(){var t="";t+="".concat(d1,",").concat(h1);for(var e=0;e<this.datasets.ids.length;e++)if(t+=",".concat(this.datasets.ids[e]),this._datasetMeta){var n=this._datasetMeta.get(this.datasets.ids[e]);n?.category&&(t+="".concat("@").concat(n.category))}for(t+=`
|
||
`,e=0;e<this.datasets.startingIndices.itemLength;e++){var i=this.datasets.startingIndices.at(e),o=this.datasets.data.at(i),a=this.datasets.data.at(i+r.NumberOfPointsOffset);t+="".concat(o,",").concat(a);for(var s=0;s<a;s++)t+=",".concat(this.datasets.data.at(i+r.SliceDataOffset+s));for(var l=0;l<this.datasets.ids.length-a;l++)t+=",";t+=`
|
||
`}var c="".concat(new Date().toISOString(),"-perfdata.csv");ze.S0.Download(new Blob([t],{type:"text/csv"}),c)},r.prototype.start=function(t){t?this._startingTimestamp===void 0&&(this._startingTimestamp=et.j.Now):(this.datasets.data=new ho(Yo),this.datasets.startingIndices=new ho(Yo),this._startingTimestamp=et.j.Now),this._scene.onAfterRenderObservable.add(this._collectDataAtFrame),this._restoreStringEvents(),this._isStarted=!0},r.prototype.stop=function(){this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame),this._isStarted=!1},Object.defineProperty(r.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame),this._datasetMeta.clear(),this._strategies.forEach(function(t){t.dispose()}),this.datasetObservable.clear(),this.metadataObservable.clear(),this._isStarted=!1,this.datasets=null},r}(),Ir=function(){},f1=function(){function r(){}return r.FpsStrategy=function(){return function(t){var e=t.getEngine();return{id:"FPS",getData:function(){return e.getFps()},dispose:Ir}}},r.ThermalStrategy=function(){return this._PressureStrategy("Thermal utilization","thermal")},r.PowerSupplyStrategy=function(){return this._PressureStrategy("Power supply utilization","power-supply")},r.PressureStrategy=function(){return this._PressureStrategy("Pressure")},r._PressureStrategy=function(t,e){return e===void 0&&(e=null),function(){var n=0,i=new qT;return i.observe("cpu"),i.onPressureChanged.add(function(o){for(var a,s,l=0,c=o;l<c.length;l++){var u=c[l];if(e&&u.factors.includes(e)||!e&&((s=(a=u.factors)===null||a===void 0?void 0:a.length)!==null&&s!==void 0?s:0)===0)switch(u.state){case"nominal":n=0;break;case"fair":n=.25;break;case"serious":n=.5;break;case"critical":n=1}}}),{id:t,getData:function(){return n},dispose:function(){return i.dispose()}}}},r.TotalMeshesStrategy=function(){return function(t){return{id:"Total meshes",getData:function(){return t.meshes.length},dispose:Ir}}},r.ActiveMeshesStrategy=function(){return function(t){return{id:"Active meshes",getData:function(){return t.getActiveMeshes().length},dispose:Ir}}},r.ActiveIndicesStrategy=function(){return function(t){return{id:"Active indices",getData:function(){return t.getActiveIndices()},dispose:Ir}}},r.ActiveFacesStrategy=function(){return function(t){return{id:"Active faces",getData:function(){return t.getActiveIndices()/3},dispose:Ir}}},r.ActiveBonesStrategy=function(){return function(t){return{id:"Active bones",getData:function(){return t.getActiveBones()},dispose:Ir}}},r.ActiveParticlesStrategy=function(){return function(t){return{id:"Active particles",getData:function(){return t.getActiveParticles()},dispose:Ir}}},r.DrawCallsStrategy=function(){return function(t){var e=0,n=t.onBeforeAnimationsObservable.add(function(){t.getEngine()._drawCalls.fetchNewFrame()}),i=t.onAfterRenderObservable.add(function(){e=t.getEngine()._drawCalls.current});return{id:"Draw calls",getData:function(){return e},dispose:function(){t.onBeforeAnimationsObservable.remove(n),t.onAfterRenderObservable.remove(i)}}}},r.TotalLightsStrategy=function(){return function(t){return{id:"Total lights",getData:function(){return t.lights.length},dispose:Ir}}},r.TotalVerticesStrategy=function(){return function(t){return{id:"Total vertices",getData:function(){return t.getTotalVertices()},dispose:Ir}}},r.TotalMaterialsStrategy=function(){return function(t){return{id:"Total materials",getData:function(){return t.materials.length},dispose:Ir}}},r.TotalTexturesStrategy=function(){return function(t){return{id:"Total textures",getData:function(){return t.textures.length},dispose:Ir}}},r.AbsoluteFpsStrategy=function(){return function(t){var e=new pv(t);return e.captureFrameTime=!0,{id:"Absolute FPS",getData:function(){return 1e3/e.frameTimeCounter.lastSecAverage},dispose:Ir}}},r.MeshesSelectionStrategy=function(){return function(t){var e=et.j.Now,n=0,i=t.onBeforeActiveMeshesEvaluationObservable.add(function(){e=et.j.Now}),o=t.onAfterActiveMeshesEvaluationObservable.add(function(){n=et.j.Now-e});return{id:"Meshes Selection",getData:function(){return n},dispose:function(){t.onBeforeActiveMeshesEvaluationObservable.remove(i),t.onAfterActiveMeshesEvaluationObservable.remove(o)}}}},r.RenderTargetsStrategy=function(){return function(t){var e=et.j.Now,n=0,i=t.onBeforeRenderTargetsRenderObservable.add(function(){e=et.j.Now}),o=t.onAfterRenderTargetsRenderObservable.add(function(){n=et.j.Now-e});return{id:"Render Targets",getData:function(){return n},dispose:function(){t.onBeforeRenderTargetsRenderObservable.remove(i),t.onAfterRenderTargetsRenderObservable.remove(o)}}}},r.ParticlesStrategy=function(){return function(t){var e=et.j.Now,n=0,i=t.onBeforeParticlesRenderingObservable.add(function(){e=et.j.Now}),o=t.onAfterParticlesRenderingObservable.add(function(){n=et.j.Now-e});return{id:"Particles",getData:function(){return n},dispose:function(){t.onBeforeParticlesRenderingObservable.remove(i),t.onAfterParticlesRenderingObservable.remove(o)}}}},r.SpritesStrategy=function(){return function(t){var e,n,i=et.j.Now,o=0,a=(e=t.onBeforeSpritesRenderingObservable)===null||e===void 0?void 0:e.add(function(){i=et.j.Now}),s=(n=t.onAfterSpritesRenderingObservable)===null||n===void 0?void 0:n.add(function(){o=et.j.Now-i});return{id:"Sprites",getData:function(){return o},dispose:function(){var l,c;(l=t.onBeforeSpritesRenderingObservable)===null||l===void 0||l.remove(a),(c=t.onAfterSpritesRenderingObservable)===null||c===void 0||c.remove(s)}}}},r.AnimationsStrategy=function(){return function(t){var e=et.j.Now,n=0,i=t.onBeforeAnimationsObservable.add(function(){e=et.j.Now}),o=t.onAfterAnimationsObservable.add(function(){n=et.j.Now-e});return{id:"Animations",getData:function(){return n},dispose:function(){t.onBeforeAnimationsObservable.remove(i),t.onAfterAnimationsObservable.remove(o)}}}},r.PhysicsStrategy=function(){return function(t){var e,n,i=et.j.Now,o=0,a=(e=t.onBeforePhysicsObservable)===null||e===void 0?void 0:e.add(function(){i=et.j.Now}),s=(n=t.onAfterPhysicsObservable)===null||n===void 0?void 0:n.add(function(){o=et.j.Now-i});return{id:"Physics",getData:function(){return o},dispose:function(){var l,c;(l=t.onBeforePhysicsObservable)===null||l===void 0||l.remove(a),(c=t.onAfterPhysicsObservable)===null||c===void 0||c.remove(s)}}}},r.RenderStrategy=function(){return function(t){var e=et.j.Now,n=0,i=t.onBeforeDrawPhaseObservable.add(function(){e=et.j.Now}),o=t.onAfterDrawPhaseObservable.add(function(){n=et.j.Now-e});return{id:"Render",getData:function(){return n},dispose:function(){t.onBeforeDrawPhaseObservable.remove(i),t.onAfterDrawPhaseObservable.remove(o)}}}},r.FrameTotalStrategy=function(){return function(t){var e=et.j.Now,n=0,i=t.onBeforeAnimationsObservable.add(function(){e=et.j.Now}),o=t.onAfterRenderObservable.add(function(){n=et.j.Now-e});return{id:"Frame Total",getData:function(){return n},dispose:function(){t.onBeforeAnimationsObservable.remove(i),t.onAfterRenderObservable.remove(o)}}}},r.InterFrameStrategy=function(){return function(t){var e=et.j.Now,n=0,i=t.onBeforeAnimationsObservable.add(function(){n=et.j.Now-e}),o=t.onAfterRenderObservable.add(function(){e=et.j.Now});return{id:"Inter-frame",getData:function(){return n},dispose:function(){t.onBeforeAnimationsObservable.remove(i),t.onAfterRenderObservable.remove(o)}}}},r.GpuFrameTimeStrategy=function(){return function(t){var e=new fv(t.getEngine());return e.captureGPUFrameTime=!0,{id:"GPU frame time",getData:function(){return Math.max(1e-6*e.gpuFrameTimeCounter.current,0)},dispose:function(){e.dispose()}}}},r}();ke.Z.prototype.getPerfCollector=function(){return this._perfCollector||(this._perfCollector=new KT(this)),this._perfCollector},K.cP.prototype.runCoroutineAsync=function(r){if(!this._coroutineScheduler){var t=function(e){var n=new Array,i=new Array,o=new Array,a=e.add(function(){for(var s=n.length,l=0;l<s;l++)Sa(n.shift(),i.shift(),o.shift())});return{scheduler:function(s,l,c){n.push(s),i.push(l),o.push(c)},dispose:function(){e.remove(a)}}}(this);this._coroutineScheduler=t.scheduler,this._coroutineSchedulerDispose=t.dispose}return Cs(r,this._coroutineScheduler)},K.cP.prototype.cancelAllCoroutines=function(){this._coroutineSchedulerDispose&&this._coroutineSchedulerDispose(),this._coroutineScheduler=void 0,this._coroutineSchedulerDispose=void 0};function p1(r,t){var e,n;return(0,A.sH)(this,void 0,void 0,function(){var i,o,a,s;return(0,A.YH)(this,function(l){return i=(e=t.probe)!==null&&e!==void 0?e:new vh("tempProbe",t.size,r),(o=!!t.probe)||(t.position?i.position=t.position.clone():r.activeCamera&&(i.position=r.activeCamera.position.clone())),a=t.meshesFilter?r.meshes.filter(t.meshesFilter):r.meshes,(n=i.renderList)===null||n===void 0||n.push.apply(n,a),i.refreshRate=un.$.REFRESHRATE_RENDER_ONCE,i.cubeTexture.render(),(s=new Vv("tempProceduralTexture","equirectangularPanorama",{width:2*t.size,height:t.size},r)).setTexture("cubeMap",i.cubeTexture),[2,new Promise(function(c,u){s.onGeneratedObservable.addOnce(function(){var d=s.readPixels();if(!d)return u(new Error("No Pixel Data found on procedural texture")),s.dispose(),void(o||i.dispose());d.then(function(h){s.dispose(),o||i.dispose(),t.filename?((0,Hl.RJ)(2*t.size,t.size,h,void 0,"image/png",t.filename),c(null)):c(h)})})})]})})}Gt.l.ShadersStore.equirectangularPanoramaPixelShader=`#ifdef GL_ES
|
||
precision highp float;
|
||
#endif
|
||
#define M_PI 3.1415926535897932384626433832795
|
||
varying vec2 vUV;uniform samplerCube cubeMap;void main(void) {vec2 uv=vUV;float longitude=uv.x*2.*M_PI-M_PI+M_PI/2.;float latitude=(1.-uv.y)*M_PI;vec3 dir=vec3(
|
||
- sin( longitude )*sin( latitude ),
|
||
cos( latitude ),
|
||
- cos( longitude )*sin( latitude )
|
||
);normalize( dir );gl_FragColor=textureCube( cubeMap,dir );}`;var op,ap,_1=function(){function r(){this._currentOperation=Promise.resolve()}return r.prototype.lockAsync=function(t,e){e?.throwIfAborted();var n=e?function(){return e.throwIfAborted(),t()}:t,i=this._currentOperation.then(n);return this._currentOperation=new Promise(function(o){return i.then(function(){return o()},o)}),i},r.LockAsync=function(t,e,n){return(0,A.sH)(this,void 0,void 0,function(){var i,o,a=this;return(0,A.YH)(this,function(s){switch(s.label){case 0:return n?.throwIfAborted(),e.length!==0?[3,2]:[4,t()];case 1:return[2,s.sent()];case 2:return i=new kT,o=0,e.forEach(function(l){return l.lockAsync(function(){return(0,A.sH)(a,void 0,void 0,function(){var c,u;return(0,A.YH)(this,function(d){switch(d.label){case 0:return++o!==e.length?[3,2]:(u=(c=i).resolve,[4,t()]);case 1:u.apply(c,[d.sent()]),d.label=2;case 2:return[2,i.promise]}})})},n).catch(function(c){return i.reject(c)})}),[2,i.promise]}})})},r}(),m1=L(32407),g1=L(22955),v1=L(37494),y1=L(86558),b1=L(18778),T1=L(70051);(function(r){r[r.ENTERING_XR=0]="ENTERING_XR",r[r.EXITING_XR=1]="EXITING_XR",r[r.IN_XR=2]="IN_XR",r[r.NOT_IN_XR=3]="NOT_IN_XR"})(op||(op={})),function(r){r[r.NOT_TRACKING=0]="NOT_TRACKING",r[r.TRACKING_LOST=1]="TRACKING_LOST",r[r.TRACKING=2]="TRACKING"}(ap||(ap={}));var Yl=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i.options=n,i._direction=new _.Pq(0,0,-1),i._mat=new _.uq,i._onSelectEnabled=!1,i._origin=new _.Pq(0,0,0),i.lastNativeXRHitResults=[],i.onHitTestResultObservable=new K.cP,i._onHitTestResults=function(o){var a=o.map(function(s){var l=_.uq.FromArray(s.hitMatrix);return i._xrSessionManager.scene.useRightHandedSystem||l.toggleModelMatrixHandInPlace(),i.options.worldParentNode&&l.multiplyToRef(i.options.worldParentNode.getWorldMatrix(),l),{xrHitResult:s,transformationMatrix:l}});i.lastNativeXRHitResults=o,i.onHitTestResultObservable.notifyObservers(a)},i._onSelect=function(o){i._onSelectEnabled&&t.XRHitTestWithSelectEvent(o,i._xrSessionManager.referenceSpace)},i.xrNativeFeatureName="hit-test",ze.S0.Warn("A newer version of this plugin is available"),i}return(0,A.C6)(t,r),t.XRHitTestWithRay=function(e,n,i,o){return e.requestHitTest(n,i).then(function(a){var s=o||function(l){return!!l.hitMatrix};return a.filter(s)})},t.XRHitTestWithSelectEvent=function(e,n){var i=e.frame.getPose(e.inputSource.targetRaySpace,n);if(!i)return Promise.resolve([]);var o=new XRRay(i.transform);return this.XRHitTestWithRay(e.frame.session,o,n)},t.prototype.attach=function(){return!!r.prototype.attach.call(this)&&(this.options.testOnPointerDownOnly&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0)},t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this._onSelectEnabled=!1,this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&!this.options.testOnPointerDownOnly){var n=e.getViewerPose(this._xrSessionManager.referenceSpace);if(n){_.uq.FromArrayToRef(n.transform.matrix,0,this._mat),_.Pq.TransformCoordinatesFromFloatsToRef(0,0,0,this._mat,this._origin),_.Pq.TransformCoordinatesFromFloatsToRef(0,0,-1,this._mat,this._direction),this._direction.subtractInPlace(this._origin),this._direction.normalize();var i=new XRRay({x:this._origin.x,y:this._origin.y,z:this._origin.z,w:0},{x:this._direction.x,y:this._direction.y,z:this._direction.z,w:0});t.XRHitTestWithRay(this._xrSessionManager.session,i,this._xrSessionManager.referenceSpace).then(this._onHitTestResults)}}},t.Name=vn.HIT_TEST,t.Version=1,t}(qn);kn.AddWebXRFeature(Yl.Name,function(r,t){return function(){return new Yl(r,t)}},Yl.Version,!1);var XN=0,Xl=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i._options=n,i._lastFrameDetected=new Set,i._trackedAnchors=[],i._futureAnchors=[],i.onAnchorAddedObservable=new K.cP,i.onAnchorRemovedObservable=new K.cP,i.onAnchorUpdatedObservable=new K.cP,i._tmpVector=new _.Pq,i._tmpQuaternion=new _.PT,i.xrNativeFeatureName="anchors",i._options.clearAnchorsOnSessionInit&&i._xrSessionManager.onXRSessionInit.add(function(){i._trackedAnchors.length=0,i._futureAnchors.length=0,i._lastFrameDetected.clear()}),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"referenceSpaceForFrameAnchors",{set:function(e){this._referenceSpaceForFrameAnchors=e},enumerable:!1,configurable:!0}),t.prototype._populateTmpTransformation=function(e,n){return this._tmpVector.copyFrom(e),this._tmpQuaternion.copyFrom(n),this._xrSessionManager.scene.useRightHandedSystem||(this._tmpVector.z*=-1,this._tmpQuaternion.z*=-1,this._tmpQuaternion.w*=-1),{position:this._tmpVector,rotationQuaternion:this._tmpQuaternion}},t.prototype.addAnchorPointUsingHitTestResultAsync=function(e,n,i){return n===void 0&&(n=new _.Pq),i===void 0&&(i=new _.PT),(0,A.sH)(this,void 0,void 0,function(){var o,a,s,l=this;return(0,A.YH)(this,function(c){switch(c.label){case 0:if(this._populateTmpTransformation(n,i),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),e.xrHitResult.createAnchor)return[3,1];throw this.detach(),new Error("Anchors not enabled in this environment/browser");case 1:return c.trys.push([1,3,,4]),[4,e.xrHitResult.createAnchor(o)];case 2:return a=c.sent(),[2,new Promise(function(u,d){l._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!0,xrTransformation:o,resolve:u,reject:d})})];case 3:throw s=c.sent(),new Error(s);case 4:return[2]}})})},t.prototype.addAnchorAtPositionAndRotationAsync=function(e,n,i){return n===void 0&&(n=new _.PT),i===void 0&&(i=!1),(0,A.sH)(this,void 0,void 0,function(){var o,a,s,l=this;return(0,A.YH)(this,function(c){switch(c.label){case 0:return this._populateTmpTransformation(e,n),o=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),i&&this.attached&&this._xrSessionManager.currentFrame?[4,this._createAnchorAtTransformation(o,this._xrSessionManager.currentFrame)]:[3,2];case 1:return s=c.sent(),[3,3];case 2:s=void 0,c.label=3;case 3:return a=s,[2,new Promise(function(u,d){l._futureAnchors.push({nativeAnchor:a,resolved:!1,submitted:!1,xrTransformation:o,resolve:u,reject:d})})]}})})},Object.defineProperty(t.prototype,"anchors",{get:function(){return this._trackedAnchors},enumerable:!1,configurable:!0}),t.prototype.detach=function(){if(!r.prototype.detach.call(this))return!1;if(!this._options.doNotRemoveAnchorsOnSessionEnded)for(;this._trackedAnchors.length;){var e=this._trackedAnchors.pop();e&&this.onAnchorRemovedObservable.notifyObservers(e)}return!0},t.prototype.dispose=function(){this._futureAnchors.length=0,r.prototype.dispose.call(this),this.onAnchorAddedObservable.clear(),this.onAnchorRemovedObservable.clear(),this.onAnchorUpdatedObservable.clear()},t.prototype._onXRFrame=function(e){var n=this;if(this.attached&&e){var i=e.trackedAnchors;if(i){var o=this._trackedAnchors.filter(function(s){return!i.has(s.xrAnchor)}).map(function(s){return n._trackedAnchors.indexOf(s)}),a=0;o.forEach(function(s){var l=n._trackedAnchors.splice(s-a,1)[0];n.onAnchorRemovedObservable.notifyObservers(l),a++}),i.forEach(function(s){if(n._lastFrameDetected.has(s)){var l=n._findIndexInAnchorArray(s);u=n._trackedAnchors[l];try{n._updateAnchorWithXRFrame(s,u,e),u.attachedNode&&(u.attachedNode.rotationQuaternion=u.attachedNode.rotationQuaternion||new _.PT,u.transformationMatrix.decompose(u.attachedNode.scaling,u.attachedNode.rotationQuaternion,u.attachedNode.position)),n.onAnchorUpdatedObservable.notifyObservers(u)}catch{ze.S0.Warn("Anchor could not be updated")}}else{var c={id:XN++,xrAnchor:s,remove:function(){return s.delete()}},u=n._updateAnchorWithXRFrame(s,c,e);n._trackedAnchors.push(u),n.onAnchorAddedObservable.notifyObservers(u);var d=n._futureAnchors.filter(function(h){return h.nativeAnchor===s})[0];d&&(d.resolve(u),d.resolved=!0)}}),this._lastFrameDetected=i}this._futureAnchors.forEach(function(s){s.resolved||s.submitted||(n._createAnchorAtTransformation(s.xrTransformation,e).then(function(l){s.nativeAnchor=l},function(l){s.resolved=!0,s.reject(l)}),s.submitted=!0)})}},t.prototype._findIndexInAnchorArray=function(e){for(var n=0;n<this._trackedAnchors.length;++n)if(this._trackedAnchors[n].xrAnchor===e)return n;return-1},t.prototype._updateAnchorWithXRFrame=function(e,n,i){var o=i.getPose(e.anchorSpace,this._xrSessionManager.referenceSpace);if(o){var a=n.transformationMatrix||new _.uq;_.uq.FromArrayToRef(o.transform.matrix,0,a),this._xrSessionManager.scene.useRightHandedSystem||a.toggleModelMatrixHandInPlace(),n.transformationMatrix=a,this._options.worldParentNode&&a.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),a)}return n},t.prototype._createAnchorAtTransformation=function(e,n){var i;return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(o){if(!n.createAnchor)throw this.detach(),new Error("Anchors are not enabled in your browser");try{return[2,n.createAnchor(e,(i=this._referenceSpaceForFrameAnchors)!==null&&i!==void 0?i:this._xrSessionManager.referenceSpace)]}catch(a){throw new Error(a)}return[2]})})},t.Name=vn.ANCHOR_SYSTEM,t.Version=1,t}(qn);kn.AddWebXRFeature(Xl.Name,function(r,t){return function(){return new Xl(r,t)}},Xl.Version);var jN=0,jl=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i._options=n,i._detectedPlanes=[],i._enabled=!1,i._lastFrameDetected=new Set,i.onPlaneAddedObservable=new K.cP,i.onPlaneRemovedObservable=new K.cP,i.onPlaneUpdatedObservable=new K.cP,i.xrNativeFeatureName="plane-detection",i._xrSessionManager.session?i._init():i._xrSessionManager.onXRSessionInit.addOnce(function(){i._init()}),i}return(0,A.C6)(t,r),t.prototype.detach=function(){if(!r.prototype.detach.call(this))return!1;if(!this._options.doNotRemovePlanesOnSessionEnded)for(;this._detectedPlanes.length;){var e=this._detectedPlanes.pop();e&&this.onPlaneRemovedObservable.notifyObservers(e)}return!0},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onPlaneAddedObservable.clear(),this.onPlaneRemovedObservable.clear(),this.onPlaneUpdatedObservable.clear()},t.prototype.isCompatible=function(){return typeof XRPlane<"u"},t.prototype.initiateRoomCapture=function(){return(0,A.sH)(this,void 0,void 0,function(){return(0,A.YH)(this,function(e){return this._xrSessionManager.session.initiateRoomCapture?[2,this._xrSessionManager.session.initiateRoomCapture()]:[2,Promise.reject("initiateRoomCapture is not supported on this session")]})})},t.prototype._onXRFrame=function(e){var n,i=this;if(this.attached&&this._enabled&&e){var o=e.detectedPlanes||((n=e.worldInformation)===null||n===void 0?void 0:n.detectedPlanes);if(o){for(var a=0;a<this._detectedPlanes.length;a++){var s=this._detectedPlanes[a];o.has(s.xrPlane)||(this._detectedPlanes.splice(a--,1),this.onPlaneRemovedObservable.notifyObservers(s))}o.forEach(function(l){if(i._lastFrameDetected.has(l)){if(l.lastChangedTime===i._xrSessionManager.currentTimestamp){var c=i._findIndexInPlaneArray(l);d=i._detectedPlanes[c],i._updatePlaneWithXRPlane(l,d,e),i.onPlaneUpdatedObservable.notifyObservers(d)}}else{var u={id:jN++,xrPlane:l,polygonDefinition:[]},d=i._updatePlaneWithXRPlane(l,u,e);i._detectedPlanes.push(d),i.onPlaneAddedObservable.notifyObservers(d)}}),this._lastFrameDetected=o}}},t.prototype._init=function(){var e=this,n=function(){e._enabled=!0,e._detectedPlanes.length&&(e._detectedPlanes.length=0)};this._xrSessionManager.isNative&&this._options.preferredDetectorOptions&&this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions&&this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions(this._options.preferredDetectorOptions),this._xrSessionManager.session.updateWorldTrackingState&&this._xrSessionManager.session.updateWorldTrackingState({planeDetectionState:{enabled:!0}}),n()},t.prototype._updatePlaneWithXRPlane=function(e,n,i){var o=this;n.polygonDefinition=e.polygon.map(function(l){var c=o._xrSessionManager.scene.useRightHandedSystem?1:-1;return new _.Pq(l.x,l.y,l.z*c)});var a=i.getPose(e.planeSpace,this._xrSessionManager.referenceSpace);if(a){var s=n.transformationMatrix||new _.uq;_.uq.FromArrayToRef(a.transform.matrix,0,s),this._xrSessionManager.scene.useRightHandedSystem||s.toggleModelMatrixHandInPlace(),n.transformationMatrix=s,this._options.worldParentNode&&s.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),s)}return n},t.prototype._findIndexInPlaneArray=function(e){for(var n=0;n<this._detectedPlanes.length;++n)if(this._detectedPlanes[n].xrPlane===e)return n;return-1},t.Name=vn.PLANE_DETECTION,t.Version=1,t}(qn);kn.AddWebXRFeature(jl.Name,function(r,t){return function(){return new jl(r,t)}},jl.Version);var ql=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i.options=n,i.onBackgroundStateChangedObservable=new K.cP,i}return(0,A.C6)(t,r),t.prototype.attach=function(){return this._setBackgroundState(!1),r.prototype.attach.call(this)},t.prototype.detach=function(){return this._setBackgroundState(!0),r.prototype.detach.call(this)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onBackgroundStateChangedObservable.clear()},t.prototype._onXRFrame=function(e){},t.prototype._setBackgroundState=function(e){var n=this._xrSessionManager.scene;if(!this.options.ignoreEnvironmentHelper)if(this.options.environmentHelperRemovalFlags){if(this.options.environmentHelperRemovalFlags.skyBox){var i=n.getMeshByName("BackgroundSkybox");i&&i.setEnabled(e)}if(this.options.environmentHelperRemovalFlags.ground){var o=n.getMeshByName("BackgroundPlane");o&&o.setEnabled(e)}}else{var a=n.getMeshByName("BackgroundHelper");a&&a.setEnabled(e)}this.options.backgroundMeshes&&this.options.backgroundMeshes.forEach(function(s){return s.setEnabled(e)}),this.onBackgroundStateChangedObservable.notifyObservers(e)},t.Name=vn.BACKGROUND_REMOVER,t.Version=1,t}(qn);kn.AddWebXRFeature(ql.Name,function(r,t){return function(){return new ql(r,t)}},ql.Version,!0);var S1=function(){},Kl=function(r){function t(e,n){var i=r.call(this,e)||this;return i._options=n,i._attachController=function(o){i._controllers[o.uniqueId]||(i._xrSessionManager.scene.isPhysicsEnabled()||O.V.Warn("physics engine not enabled, skipped. Please add this controller manually."),i._options.physicsProperties.useControllerMesh&&o.inputSource.gamepad?o.onMotionControllerInitObservable.addOnce(function(a){a._doNotLoadControllerMesh?i._createPhysicsImpostor(o):a.onModelLoadedObservable.addOnce(function(){var s=new Dt(a.rootMesh,Dt.MeshImpostor,(0,A.Cl)({mass:0},i._options.physicsProperties)),l=o.grip||o.pointer;i._controllers[o.uniqueId]={xrController:o,impostor:s,oldPos:l.position.clone(),oldRotation:l.rotationQuaternion.clone()}})}):i._createPhysicsImpostor(o))},i._controllers={},i._debugMode=!1,i._delta=0,i._lastTimestamp=0,i._tmpQuaternion=new _.PT,i._tmpVector=new _.Pq,i._options.physicsProperties||(i._options.physicsProperties={}),i}return(0,A.C6)(t,r),t.prototype._createPhysicsImpostor=function(e){var n=this._options.physicsProperties.impostorType||Dt.SphereImpostor,i=this._options.physicsProperties.impostorSize||.1,o=li("impostor-mesh-"+e.uniqueId,{diameterX:typeof i=="number"?i:i.width,diameterY:typeof i=="number"?i:i.height,diameterZ:typeof i=="number"?i:i.depth});o.isVisible=this._debugMode,o.isPickable=!1,o.rotationQuaternion=new _.PT;var a=e.grip||e.pointer;o.position.copyFrom(a.position),o.rotationQuaternion.copyFrom(a.rotationQuaternion);var s=new Dt(o,n,(0,A.Cl)({mass:0},this._options.physicsProperties));this._controllers[e.uniqueId]={xrController:e,impostor:s,impostorMesh:o}},t.prototype._enablePhysicsDebug=function(){var e=this;this._debugMode=!0,Object.keys(this._controllers).forEach(function(n){var i=e._controllers[n];i.impostorMesh&&(i.impostorMesh.isVisible=!0)})},t.prototype.addController=function(e){this._attachController(e)},t.prototype.attach=function(){var e=this;if(!r.prototype.attach.call(this))return!1;if(!this._options.xrInput)return!0;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,function(o){e._detachController(o.uniqueId)}),this._options.enableHeadsetImpostor){var n=this._options.headsetImpostorParams||{impostorType:Dt.SphereImpostor,restitution:.8,impostorSize:.3},i=n.impostorSize||.3;this._headsetMesh=li("headset-mesh",{diameterX:typeof i=="number"?i:i.width,diameterY:typeof i=="number"?i:i.height,diameterZ:typeof i=="number"?i:i.depth}),this._headsetMesh.rotationQuaternion=new _.PT,this._headsetMesh.isVisible=!1,this._headsetImpostor=new Dt(this._headsetMesh,n.impostorType,(0,A.Cl)({mass:0},n))}return!0},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach(function(n){e._detachController(n)}),this._headsetMesh&&this._headsetMesh.dispose(),!0)},t.prototype.getHeadsetImpostor=function(){return this._headsetImpostor},t.prototype.getImpostorForController=function(e){var n=typeof e=="string"?e:e.uniqueId;return this._controllers[n]?this._controllers[n].impostor:null},t.prototype.setPhysicsProperties=function(e){this._options.physicsProperties=(0,A.Cl)((0,A.Cl)({},this._options.physicsProperties),e)},t.prototype._onXRFrame=function(e){var n,i,o=this;if(this._delta=this._xrSessionManager.currentTimestamp-this._lastTimestamp,this._lastTimestamp=this._xrSessionManager.currentTimestamp,this._headsetMesh&&this._headsetImpostor){if(this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.globalPosition),this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.absoluteRotation),(n=this._options.xrInput.xrCamera._lastXRViewerPose)===null||n===void 0?void 0:n.linearVelocity){var a=this._options.xrInput.xrCamera._lastXRViewerPose.linearVelocity;this._tmpVector.set(a.x,a.y,a.z),this._headsetImpostor.setLinearVelocity(this._tmpVector)}if(!((i=this._options.xrInput.xrCamera._lastXRViewerPose)===null||i===void 0)&&i.angularVelocity){var s=this._options.xrInput.xrCamera._lastXRViewerPose.angularVelocity;this._tmpVector.set(s.x,s.y,s.z),this._headsetImpostor.setAngularVelocity(this._tmpVector)}}Object.keys(this._controllers).forEach(function(l){var c,u,d=o._controllers[l],h=d.xrController.grip||d.xrController.pointer,p=d.oldPos||d.impostorMesh.position;if(!((c=d.xrController._lastXRPose)===null||c===void 0)&&c.linearVelocity){var m=d.xrController._lastXRPose.linearVelocity;o._tmpVector.set(m.x,m.y,m.z),d.impostor.setLinearVelocity(o._tmpVector)}else h.position.subtractToRef(p,o._tmpVector),o._tmpVector.scaleInPlace(1e3/o._delta),d.impostor.setLinearVelocity(o._tmpVector);p.copyFrom(h.position),o._debugMode&&O.V.Log([o._tmpVector,"linear"]);var v=d.oldRotation||d.impostorMesh.rotationQuaternion;if(!((u=d.xrController._lastXRPose)===null||u===void 0)&&u.angularVelocity){var b=d.xrController._lastXRPose.angularVelocity;o._tmpVector.set(b.x,b.y,b.z),d.impostor.setAngularVelocity(o._tmpVector)}else if(!v.equalsWithEpsilon(h.rotationQuaternion)){v.conjugateInPlace().multiplyToRef(h.rotationQuaternion,o._tmpQuaternion);var E=Math.sqrt(o._tmpQuaternion.x*o._tmpQuaternion.x+o._tmpQuaternion.y*o._tmpQuaternion.y+o._tmpQuaternion.z*o._tmpQuaternion.z);if(o._tmpVector.set(o._tmpQuaternion.x,o._tmpQuaternion.y,o._tmpQuaternion.z),E<.001)o._tmpVector.scaleInPlace(2);else{var C=2*Math.atan2(E,o._tmpQuaternion.w);o._tmpVector.scaleInPlace(C/(E*(o._delta/1e3)))}d.impostor.setAngularVelocity(o._tmpVector)}v.copyFrom(h.rotationQuaternion),o._debugMode&&O.V.Log([o._tmpVector,o._tmpQuaternion,"angular"])})},t.prototype._detachController=function(e){var n=this._controllers[e];n&&(n.impostorMesh&&n.impostorMesh.dispose(),delete this._controllers[e])},t.Name=vn.PHYSICS_CONTROLLERS,t.Version=1,t}(qn);kn.AddWebXRFeature(Kl.Name,function(r,t){return function(){return new Kl(r,t)}},Kl.Version,!0);var Zl=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i.options=n,i._tmpMat=new _.uq,i._tmpPos=new _.Pq,i._tmpQuat=new _.PT,i._initHitTestSource=function(o){if(o){var a=new XRRay(i.options.offsetRay||{}),s={space:i.options.useReferenceSpace?o:i._xrSessionManager.viewerReferenceSpace,offsetRay:a};i.options.entityTypes&&(s.entityTypes=i.options.entityTypes),s.space?i._xrSessionManager.session.requestHitTestSource(s).then(function(l){i._xrHitTestSource&&i._xrHitTestSource.cancel(),i._xrHitTestSource=l}):ze.S0.Warn("waiting for viewer reference space to initialize")}},i.autoCloneTransformation=!1,i.onHitTestResultObservable=new K.cP,i.paused=!1,i.xrNativeFeatureName="hit-test",ze.S0.Warn("Hit test is an experimental and unstable feature."),i}return(0,A.C6)(t,r),t.prototype.attach=function(){var e=this;if(!r.prototype.attach.call(this)||!this._xrSessionManager.session.requestHitTestSource)return!1;if(this.options.disablePermanentHitTest||(this._xrSessionManager.referenceSpace&&this._initHitTestSource(this._xrSessionManager.referenceSpace),this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource)),this.options.enableTransientHitTest){var n=new XRRay(this.options.transientOffsetRay||{});this._xrSessionManager.session.requestHitTestSourceForTransientInput({profile:this.options.transientHitTestProfile||"generic-touchscreen",offsetRay:n,entityTypes:this.options.entityTypes}).then(function(i){e._transientXrHitTestSource=i})}return!0},t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this._xrHitTestSource&&(this._xrHitTestSource.cancel(),this._xrHitTestSource=null),this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource),this._transientXrHitTestSource&&(this._transientXrHitTestSource.cancel(),this._transientXrHitTestSource=null),!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){var n=this;if(this.attached&&!this.paused){if(this._xrHitTestSource){var i=e.getHitTestResults(this._xrHitTestSource);this._processWebXRHitTestResult(i)}this._transientXrHitTestSource&&e.getHitTestResultsForTransientInput(this._transientXrHitTestSource).forEach(function(o){n._processWebXRHitTestResult(o.results,o.inputSource)})}},t.prototype._processWebXRHitTestResult=function(e,n){var i=this,o=[];e.forEach(function(a){var s=a.getPose(i._xrSessionManager.referenceSpace);if(s){var l=s.transform.position,c=s.transform.orientation;i._tmpPos.set(l.x,l.y,l.z).scaleInPlace(i._xrSessionManager.worldScalingFactor),i._tmpQuat.set(c.x,c.y,c.z,c.w),_.uq.FromFloat32ArrayToRefScaled(s.transform.matrix,0,1,i._tmpMat),i._xrSessionManager.scene.useRightHandedSystem||(i._tmpPos.z*=-1,i._tmpQuat.z*=-1,i._tmpQuat.w*=-1,i._tmpMat.toggleModelMatrixHandInPlace());var u={position:i.autoCloneTransformation?i._tmpPos.clone():i._tmpPos,rotationQuaternion:i.autoCloneTransformation?i._tmpQuat.clone():i._tmpQuat,transformationMatrix:i.autoCloneTransformation?i._tmpMat.clone():i._tmpMat,inputSource:n,isTransient:!!n,xrHitResult:a};o.push(u)}}),this.onHitTestResultObservable.notifyObservers(o)},t.Name=vn.HIT_TEST,t.Version=2,t}(qn);kn.AddWebXRFeature(Zl.Name,function(r,t){return function(){return new Zl(r,t)}},Zl.Version,!1);var Ql=function(r){function t(e){var n=r.call(this,e)||this;return n._enabled=!1,n._featurePointCloud=[],n.onFeaturePointsAddedObservable=new K.cP,n.onFeaturePointsUpdatedObservable=new K.cP,n.xrNativeFeatureName="bjsfeature-points",n._xrSessionManager.session?n._init():n._xrSessionManager.onXRSessionInit.addOnce(function(){n._init()}),n}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"featurePointCloud",{get:function(){return this._featurePointCloud},enumerable:!1,configurable:!0}),t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this.featurePointCloud.length=0,!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._featurePointCloud.length=0,this.onFeaturePointsUpdatedObservable.clear(),this.onFeaturePointsAddedObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&this._enabled&&e){var n=e.featurePointCloud;if(n&&n.length!==0){if(n.length%5!=0)throw new Error("Received malformed feature point cloud of length: "+n.length);for(var i=n.length/5,o=[],a=[],s=0;s<i;s++){var l=5*s,c=n[l+4];this._featurePointCloud[c]?o.push(c):(this._featurePointCloud[c]={position:new _.Pq,confidenceValue:0},a.push(c)),this._featurePointCloud[c].position.x=n[l],this._featurePointCloud[c].position.y=n[l+1],this._featurePointCloud[c].position.z=n[l+2],this._featurePointCloud[c].confidenceValue=n[l+3]}a.length>0&&this.onFeaturePointsAddedObservable.notifyObservers(a),o.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(o)}}},t.prototype._init=function(){this._xrSessionManager.session.trySetFeaturePointCloudEnabled&&this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)&&(this._enabled=!0)},t.Name=vn.FEATURE_POINTS,t.Version=1,t}(qn);kn.AddWebXRFeature(Ql.Name,function(r){return function(){return new Ql(r)}},Ql.Version);var fo,qN=0,Jl=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i._options=n,i._detectedMeshes=new Map,i.onMeshAddedObservable=new K.cP,i.onMeshRemovedObservable=new K.cP,i.onMeshUpdatedObservable=new K.cP,i.xrNativeFeatureName="mesh-detection",i._options.generateMeshes&&(i._options.convertCoordinateSystems=!0),i._xrSessionManager.session?i._init():i._xrSessionManager.onXRSessionInit.addOnce(function(){i._init()}),i}return(0,A.C6)(t,r),t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(this._xrSessionManager.isNative&&this._xrSessionManager.session.trySetMeshDetectorEnabled&&this._xrSessionManager.session.trySetMeshDetectorEnabled(!1),this._options.doNotRemoveMeshesOnSessionEnded||(this._detectedMeshes.forEach(function(n){e.onMeshRemovedObservable.notifyObservers(n)}),this._detectedMeshes.clear()),!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onMeshUpdatedObservable.clear()},t.prototype._onXRFrame=function(e){var n,i=this;try{if(!this.attached||!e)return;var o=e.detectedMeshes||((n=e.worldInformation)===null||n===void 0?void 0:n.detectedMeshes);if(o){var a=new Set;this._detectedMeshes.forEach(function(s,l){o.has(l)||a.add(l)}),a.forEach(function(s){var l=i._detectedMeshes.get(s);l&&(i.onMeshRemovedObservable.notifyObservers(l),i._detectedMeshes.delete(s))}),o.forEach(function(s){if(i._detectedMeshes.has(s))s.lastChangedTime===i._xrSessionManager.currentTimestamp&&(c=i._detectedMeshes.get(s))&&(i._updateVertexDataWithXRMesh(s,c,e),i.onMeshUpdatedObservable.notifyObservers(c));else{var l={id:qN++,xrMesh:s},c=i._updateVertexDataWithXRMesh(s,l,e);i._detectedMeshes.set(s,c),i.onMeshAddedObservable.notifyObservers(c)}})}}catch(s){O.V.Log(s.stack)}},t.prototype._init=function(){this._xrSessionManager.isNative&&(this._xrSessionManager.session.trySetMeshDetectorEnabled&&this._xrSessionManager.session.trySetMeshDetectorEnabled(!0),this._options.preferredDetectorOptions&&this._xrSessionManager.session.trySetPreferredMeshDetectorOptions&&this._xrSessionManager.session.trySetPreferredMeshDetectorOptions(this._options.preferredDetectorOptions))},t.prototype._updateVertexDataWithXRMesh=function(e,n,i){var o;n.xrMesh=e,n.worldParentNode=this._options.worldParentNode;var a=e.vertices||e.positions;if(this._options.convertCoordinateSystems){if(this._xrSessionManager.scene.useRightHandedSystem)n.positions=a,n.normals=e.normals;else{n.positions=new Float32Array(a.length);for(var s=0;s<a.length;s+=3)n.positions[s]=a[s],n.positions[s+1]=a[s+1],n.positions[s+2]=-1*a[s+2];if(e.normals)for(n.normals=new Float32Array(e.normals.length),s=0;s<e.normals.length;s+=3)n.normals[s]=e.normals[s],n.normals[s+1]=e.normals[s+1],n.normals[s+2]=-1*e.normals[s+2]}n.indices=e.indices;var l,c=i.getPose(e.meshSpace,this._xrSessionManager.referenceSpace);if(c){var u=n.transformationMatrix||new Ge.uq;Ge.uq.FromArrayToRef(c.transform.matrix,0,u),this._xrSessionManager.scene.useRightHandedSystem||u.toggleModelMatrixHandInPlace(),n.transformationMatrix=u,this._options.worldParentNode&&u.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),u)}this._options.generateMeshes&&(n.mesh?((l=n.mesh).updateVerticesData(Y.R.PositionKind,n.positions),n.normals?l.updateVerticesData(Y.R.NormalKind,n.normals):l.createNormals(!0),l.updateIndices(n.indices)):((l=new xe("xr mesh "+n.id,this._xrSessionManager.scene)).rotationQuaternion=new Ge.PT,l.setVerticesData(Y.R.PositionKind,n.positions),n.normals?l.setVerticesData(Y.R.NormalKind,n.normals):l.createNormals(!0),l.setIndices(n.indices,void 0,!0),n.mesh=l),(o=n.transformationMatrix)===null||o===void 0||o.decompose(n.mesh.scaling,n.mesh.rotationQuaternion,n.mesh.position))}return n},t.Name=vn.MESH_DETECTION,t.Version=1,t}(qn);kn.AddWebXRFeature(Jl.Name,function(r,t){return function(){return new Jl(r,t)}},Jl.Version,!1),function(r){r[r.NotReceived=0]="NotReceived",r[r.Waiting=1]="Waiting",r[r.Received=2]="Received"}(fo||(fo={}));var $l=function(r){function t(e,n){var i=r.call(this,e)||this;return i.options=n,i.onUntrackableImageFoundObservable=new K.cP,i.onTrackableImageFoundObservable=new K.cP,i.onTrackedImageUpdatedObservable=new K.cP,i._trackableScoreStatus=fo.NotReceived,i._trackedImages=[],i.xrNativeFeatureName="image-tracking",i}return(0,A.C6)(t,r),t.prototype.attach=function(){return r.prototype.attach.call(this)},t.prototype.detach=function(){return r.prototype.detach.call(this)},t.prototype.getTrackedImageById=function(e){return this._trackedImages[e]||null},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._trackedImages.forEach(function(e){e.originalBitmap.close()}),this._trackedImages.length=0,this.onTrackableImageFoundObservable.clear(),this.onUntrackableImageFoundObservable.clear(),this.onTrackedImageUpdatedObservable.clear()},t.prototype.getXRSessionInitExtension=function(){return(0,A.sH)(this,void 0,void 0,function(){var e,n,i=this;return(0,A.YH)(this,function(o){switch(o.label){case 0:if(!this.options.images||!this.options.images.length)return[2,{}];e=this.options.images.map(function(a){return typeof a.src=="string"?i._xrSessionManager.scene.getEngine()._createImageBitmapFromSource(a.src):Promise.resolve(a.src)}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,Promise.all(e)];case 2:return n=o.sent(),this._originalTrackingRequest=n.map(function(a,s){return{image:a,widthInMeters:i.options.images[s].estimatedRealWorldWidth}}),[2,{trackedImages:this._originalTrackingRequest}];case 3:return o.sent(),ze.S0.Error("Error loading images for tracking, WebXRImageTracking disabled for this session."),[2,{}];case 4:return[2]}})})},t.prototype._onXRFrame=function(e){if(e.getImageTrackingResults&&this._trackableScoreStatus!==fo.Waiting)if(this._trackableScoreStatus!==fo.NotReceived)for(var n=0,i=e.getImageTrackingResults();n<i.length;n++){var o=i[n],a=!1,s=o.index,l=this._trackedImages[s];if(l){l.xrTrackingResult=o,l.realWorldWidth!==o.measuredWidthInMeters&&(l.realWorldWidth=o.measuredWidthInMeters,a=!0);var c=e.getPose(o.imageSpace,this._xrSessionManager.referenceSpace);if(c){var u=l.transformationMatrix;_.uq.FromArrayToRef(c.transform.matrix,0,u),this._xrSessionManager.scene.useRightHandedSystem||u.toggleModelMatrixHandInPlace(),a=!0}var d=o.trackingState==="emulated";l.emulated!==d&&(l.emulated=d,a=!0),a&&this.onTrackedImageUpdatedObservable.notifyObservers(l)}}else this._checkScoresAsync()},t.prototype._checkScoresAsync=function(){return(0,A.sH)(this,void 0,void 0,function(){var e,n,i,o;return(0,A.YH)(this,function(a){switch(a.label){case 0:return this._xrSessionManager.session.getTrackedImageScores&&this._trackableScoreStatus===fo.NotReceived?(this._trackableScoreStatus=fo.Waiting,[4,this._xrSessionManager.session.getTrackedImageScores()]):[2];case 1:if(!(e=a.sent())||e.length===0)return this._trackableScoreStatus=fo.NotReceived,[2];for(n=0;n<e.length;++n)e[n]=="untrackable"?this.onUntrackableImageFoundObservable.notifyObservers(n):(i=this._originalTrackingRequest[n].image,o={id:n,originalBitmap:i,transformationMatrix:new _.uq,ratio:i.width/i.height},this._trackedImages[n]=o,this.onTrackableImageFoundObservable.notifyObservers(o));return this._trackableScoreStatus=e.length>0?fo.Received:fo.NotReceived,[2]}})})},t.Name=vn.IMAGE_TRACKING,t.Version=1,t}(qn);kn.AddWebXRFeature($l.Name,function(r,t){return function(){return new $l(r,t)}},$l.Version,!1);var ec=function(r){function t(e,n){var i=r.call(this,e)||this;return i.options=n,i._domOverlayType=null,i._beforeXRSelectListener=null,i._element=null,i.xrNativeFeatureName="dom-overlay",ze.S0.Warn("dom-overlay is an experimental and unstable feature."),i}return(0,A.C6)(t,r),t.prototype.attach=function(){return!(!r.prototype.attach.call(this)||!this._xrSessionManager.session.domOverlayState||this._xrSessionManager.session.domOverlayState.type===null||(this._domOverlayType=this._xrSessionManager.session.domOverlayState.type,this._element!==null&&this.options.supressXRSelectEvents===!0&&(this._beforeXRSelectListener=function(e){e.preventDefault()},this._element.addEventListener("beforexrselect",this._beforeXRSelectListener)),0))},Object.defineProperty(t.prototype,"domOverlayType",{get:function(){return this._domOverlayType},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){r.prototype.dispose.call(this),this._element!==null&&this._beforeXRSelectListener&&this._element.removeEventListener("beforexrselect",this._beforeXRSelectListener)},t.prototype._onXRFrame=function(e){},t.prototype.getXRSessionInitExtension=function(){return(0,A.sH)(this,void 0,void 0,function(){var e;return(0,A.YH)(this,function(n){if(this.options.element===void 0)return ze.S0.Warn('"element" option must be provided to attach xr-dom-overlay feature.'),[2,{}];if(typeof this.options.element=="string"){if((e=document.querySelector(this.options.element))===null)return ze.S0.Warn("element not found '".concat(this.options.element,"' (not requesting xr-dom-overlay)")),[2,{}];this._element=e}else this._element=this.options.element;return[2,{domOverlay:{root:this._element}}]})})},t.Name=vn.DOM_OVERLAY,t.Version=1,t}(qn);kn.AddWebXRFeature(ec.Name,function(r,t){return function(){return new ec(r,t)}},ec.Version,!1);var tc=function(r){function t(e,n){var i,o,a,s,l,c,u,d=this;return(d=r.call(this,e)||this)._controllers={},d._currentRegistrationConfigurations=[],d._movementDirection=new _.PT,d._tmpRotationMatrix=_.uq.Identity(),d._tmpTranslationDirection=new _.Pq,d._tmpMovementTranslation=new _.Pq,d._tempCacheQuaternion=new _.PT,d._attachController=function(h){if(!d._controllers[h.uniqueId]){d._controllers[h.uniqueId]={xrController:h,registeredComponents:[]};var p=d._controllers[h.uniqueId];if(p.xrController.inputSource.targetRayMode==="tracked-pointer"&&p.xrController.inputSource.gamepad){var m=function(){if(h.motionController)for(var v=function(C){var T=null;if(C.allowedComponentTypes)for(var f=0,g=C.allowedComponentTypes;f<g.length;f++){var S=g[f],y=h.motionController.getComponentOfType(S);if(y!==null){T=y;break}}if(C.mainComponentOnly){var x=h.motionController.getMainComponent();if(x===null)return"continue";T=x}if(typeof C.componentSelectionPredicate=="function"&&(T=C.componentSelectionPredicate(h)),T&&C.forceHandedness&&h.inputSource.handedness!==C.forceHandedness||T===null)return"continue";var R={registrationConfiguration:C,component:T};p.registeredComponents.push(R),"axisChangedHandler"in C&&(R.onAxisChangedObserver=T.onAxisValueChangedObservable.add(function(I){C.axisChangedHandler(I,d._movementState,d._featureContext,d._xrInput)})),"buttonChangedHandler"in C&&(R.onButtonChangedObserver=T.onButtonStateChangedObservable.add(function(I){I.changes.pressed&&C.buttonChangedHandler(I.changes.pressed,d._movementState,d._featureContext,d._xrInput)}))},b=0,E=d._currentRegistrationConfigurations;b<E.length;b++)v(E[b])};h.motionController?m():h.onMotionControllerInitObservable.addOnce(function(){m()})}}},n&&n.xrInput!==void 0?(Array.isArray(n.customRegistrationConfigurations)?d._currentRegistrationConfigurations=n.customRegistrationConfigurations:d._currentRegistrationConfigurations=t.REGISTRATIONS.default,d._featureContext={movementEnabled:n.movementEnabled||!0,movementOrientationFollowsViewerPose:(i=n.movementOrientationFollowsViewerPose)===null||i===void 0||i,movementOrientationFollowsController:(o=n.movementOrientationFollowsController)!==null&&o!==void 0&&o,orientationPreferredHandedness:n.orientationPreferredHandedness,movementSpeed:(a=n.movementSpeed)!==null&&a!==void 0?a:1,movementThreshold:(s=n.movementThreshold)!==null&&s!==void 0?s:.25,rotationEnabled:(l=n.rotationEnabled)===null||l===void 0||l,rotationSpeed:(c=n.rotationSpeed)!==null&&c!==void 0?c:1,rotationThreshold:(u=n.rotationThreshold)!==null&&u!==void 0?u:.25},d._movementState={moveX:0,moveY:0,rotateX:0,rotateY:0},d._xrInput=n.xrInput,d):(ze.S0.Error('WebXRControllerMovement feature requires "xrInput" option.'),d)}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"movementDirection",{get:function(){return this._movementDirection},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"movementEnabled",{get:function(){return this._featureContext.movementEnabled},set:function(e){this._featureContext.movementEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"movementOrientationFollowsViewerPose",{get:function(){return this._featureContext.movementOrientationFollowsViewerPose},set:function(e){this._featureContext.movementOrientationFollowsViewerPose=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"movementSpeed",{get:function(){return this._featureContext.movementSpeed},set:function(e){this._featureContext.movementSpeed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"movementThreshold",{get:function(){return this._featureContext.movementThreshold},set:function(e){this._featureContext.movementThreshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationEnabled",{get:function(){return this._featureContext.rotationEnabled},set:function(e){this._featureContext.rotationEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationSpeed",{get:function(){return this._featureContext.rotationSpeed},set:function(e){this._featureContext.rotationSpeed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationThreshold",{get:function(){return this._featureContext.rotationThreshold},set:function(e){this._featureContext.rotationThreshold=e},enumerable:!1,configurable:!0}),t.prototype.attach=function(){var e=this;return!!r.prototype.attach.call(this)&&(this._xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._xrInput.onControllerRemovedObservable,function(n){e._detachController(n.uniqueId)}),!0)},t.prototype.detach=function(){var e=this;return!!r.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach(function(n){e._detachController(n)}),this._controllers={},!0)},t.prototype._onXRFrame=function(e){var n=this;if(this.attached){if(this._movementState.rotateX!==0&&this._featureContext.rotationEnabled){var i=.001*this._xrSessionManager.scene.getEngine().getDeltaTime()*this._featureContext.rotationSpeed*this._movementState.rotateX*(this._xrSessionManager.scene.useRightHandedSystem?-1:1);if(this._featureContext.movementOrientationFollowsViewerPose)this._xrInput.xrCamera.cameraRotation.y+=i,_.PT.RotationYawPitchRollToRef(i,0,0,this._tempCacheQuaternion),this._xrInput.xrCamera.rotationQuaternion.multiplyToRef(this._tempCacheQuaternion,this._movementDirection);else if(this._featureContext.movementOrientationFollowsController){this._xrInput.xrCamera.cameraRotation.y+=i;var o=this._featureContext.orientationPreferredHandedness||"right",a=Object.keys(this._controllers).find(function(c){var u,d;return((d=(u=n._controllers[c])===null||u===void 0?void 0:u.xrController)===null||d===void 0?void 0:d.inputSource.handedness)===o})||Object.keys(this._controllers)[0],s=this._controllers[a];_.PT.RotationYawPitchRollToRef(i,0,0,this._tempCacheQuaternion),(s?.xrController.pointer.rotationQuaternion||_.PT.Identity()).multiplyToRef(this._tempCacheQuaternion,this._movementDirection)}else _.PT.RotationYawPitchRollToRef(3*i,0,0,this._tempCacheQuaternion),this._movementDirection.multiplyInPlace(this._tempCacheQuaternion)}else if(this._featureContext.movementOrientationFollowsViewerPose)this._movementDirection.copyFrom(this._xrInput.xrCamera.rotationQuaternion);else if(this._featureContext.movementOrientationFollowsController){var l=this._featureContext.orientationPreferredHandedness||"right";a=Object.keys(this._controllers).find(function(c){var u;return((u=n._controllers[c])===null||u===void 0?void 0:u.xrController.inputSource.handedness)===l})||Object.keys(this._controllers)[0],s=this._controllers[a],this._movementDirection.copyFrom(s?.xrController.pointer.rotationQuaternion||_.PT.Identity())}(this._movementState.moveX||this._movementState.moveY)&&this._featureContext.movementEnabled&&(_.uq.FromQuaternionToRef(this._movementDirection,this._tmpRotationMatrix),this._tmpTranslationDirection.set(this._movementState.moveX,0,this._movementState.moveY*(this._xrSessionManager.scene.useRightHandedSystem?1:-1)),_.Pq.TransformCoordinatesToRef(this._tmpTranslationDirection,this._tmpRotationMatrix,this._tmpMovementTranslation),this._tmpMovementTranslation.scaleInPlace(this._xrInput.xrCamera._computeLocalCameraSpeed()*this._featureContext.movementSpeed),this._xrInput.xrCamera.cameraDirection.addInPlace(this._tmpMovementTranslation))}},t.prototype._detachController=function(e){var n=this._controllers[e];if(n){for(var i=0,o=n.registeredComponents;i<o.length;i++){var a=o[i];a.onAxisChangedObserver&&a.component.onAxisValueChangedObservable.remove(a.onAxisChangedObserver),a.onButtonChangedObserver&&a.component.onButtonStateChangedObservable.remove(a.onButtonChangedObserver)}delete this._controllers[e]}},t.Name=vn.MOVEMENT,t.REGISTRATIONS={default:[{allowedComponentTypes:[Xr.THUMBSTICK_TYPE,Xr.TOUCHPAD_TYPE],forceHandedness:"left",axisChangedHandler:function(e,n,i){n.rotateX=Math.abs(e.x)>i.rotationThreshold?e.x:0,n.rotateY=Math.abs(e.y)>i.rotationThreshold?e.y:0}},{allowedComponentTypes:[Xr.THUMBSTICK_TYPE,Xr.TOUCHPAD_TYPE],forceHandedness:"right",axisChangedHandler:function(e,n,i){n.moveX=Math.abs(e.x)>i.movementThreshold?e.x:0,n.moveY=Math.abs(e.y)>i.movementThreshold?e.y:0}}]},t.Version=1,t}(qn);kn.AddWebXRFeature(tc.Name,function(r,t){return function(){return new tc(r,t)}},tc.Version,!0);var nc=function(r){function t(e,n){var i=r.call(this,e)||this;return i.options=n,i._canvasContext=null,i._reflectionCubeMap=null,i._xrLightEstimate=null,i._xrLightProbe=null,i._xrWebGLBinding=null,i._lightDirection=_.Pq.Up().negateInPlace(),i._lightColor=z.v9.White(),i._intensity=1,i._sphericalHarmonics=new Lo.O,i._cubeMapPollTime=Date.now(),i._lightEstimationPollTime=Date.now(),i._reflectionCubeMapTextureSize=16,i.directionalLight=null,i.onReflectionCubeMapUpdatedObservable=new K.cP,i._updateReflectionCubeMap=function(){var o;if(i._xrLightProbe){if(i.options.cubeMapPollInterval){var a=Date.now();if(a-i._cubeMapPollTime<i.options.cubeMapPollInterval)return;i._cubeMapPollTime=a}var s=i._getXRGLBinding().getReflectionCubeMap(i._xrLightProbe);if(s&&i._reflectionCubeMap){if(i._reflectionCubeMap._texture)(o=i._reflectionCubeMap._texture._hardwareTexture)===null||o===void 0||o.set(s),i._reflectionCubeMap._texture.getEngine().resetTextureCache();else{var l=new rn.h(i._xrSessionManager.scene.getEngine(),0);l.isCube=!0,l.invertY=!1,l._useSRGBBuffer=i.options.reflectionFormat==="srgba8",l.format=P.Y.TEXTUREFORMAT_RGBA,l.generateMipMaps=!0,l.type=i.options.reflectionFormat!=="srgba8"?P.Y.TEXTURETYPE_HALF_FLOAT:P.Y.TEXTURETYPE_UNSIGNED_BYTE,l.samplingMode=P.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR,l.width=i._reflectionCubeMapTextureSize,l.height=i._reflectionCubeMapTextureSize,l._cachedWrapU=P.Y.TEXTURE_WRAP_ADDRESSMODE,l._cachedWrapV=P.Y.TEXTURE_WRAP_ADDRESSMODE,l._hardwareTexture=new ea.d(s,i._getCanvasContext()),i._reflectionCubeMap._texture=l}i._reflectionCubeMap._texture.isReady=!0,i.options.disablePreFiltering?(i._xrSessionManager.scene.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag),i.onReflectionCubeMapUpdatedObservable.notifyObservers(i._reflectionCubeMap)):(i._xrLightProbe.removeEventListener("reflectionchange",i._updateReflectionCubeMap),i._hdrFilter.prefilter(i._reflectionCubeMap).then(function(){i._xrSessionManager.scene.markAllMaterialsAsDirty(P.Y.MATERIAL_TextureDirtyFlag),i.onReflectionCubeMapUpdatedObservable.notifyObservers(i._reflectionCubeMap),i._xrLightProbe.addEventListener("reflectionchange",i._updateReflectionCubeMap)}))}}},i.xrNativeFeatureName="light-estimation",i.options.createDirectionalLightSource&&(i.directionalLight=new Ya("light estimation directional",i._lightDirection,i._xrSessionManager.scene),i.directionalLight.position=new _.Pq(0,8,0),i.directionalLight.intensity=0,i.directionalLight.falloffType=Ri.c.FALLOFF_GLTF),i._hdrFilter=new ph(i._xrSessionManager.scene.getEngine()),ze.S0.Warn("light-estimation is an experimental and unstable feature."),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"reflectionCubeMapTexture",{get:function(){return this._reflectionCubeMap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xrLightingEstimate",{get:function(){return this._xrLightEstimate?{lightColor:this._lightColor,lightDirection:this._lightDirection,lightIntensity:this._intensity,sphericalHarmonics:this._sphericalHarmonics}:this._xrLightEstimate},enumerable:!1,configurable:!0}),t.prototype._getCanvasContext=function(){return this._canvasContext===null&&(this._canvasContext=this._xrSessionManager.scene.getEngine()._gl),this._canvasContext},t.prototype._getXRGLBinding=function(){if(this._xrWebGLBinding===null){var e=this._getCanvasContext();this._xrWebGLBinding=new XRWebGLBinding(this._xrSessionManager.session,e)}return this._xrWebGLBinding},t.prototype.attach=function(){var e,n=this;if(!r.prototype.attach.call(this))return!1;var i=(e=this.options.reflectionFormat)!==null&&e!==void 0?e:this._xrSessionManager.session.preferredReflectionFormat||"srgba8";return this.options.reflectionFormat=i,this._xrSessionManager.session.requestLightProbe({reflectionFormat:i}).then(function(o){n._xrLightProbe=o,n.options.disableCubeMapReflection||(n._reflectionCubeMap||(n._reflectionCubeMap=new Ki.t(n._xrSessionManager.scene),n._reflectionCubeMap._isCube=!0,n._reflectionCubeMap.coordinatesMode=P.Y.TEXTURE_CUBIC_MODE,n.options.setSceneEnvironmentTexture&&(n._xrSessionManager.scene.environmentTexture=n._reflectionCubeMap)),n._xrLightProbe.addEventListener("reflectionchange",n._updateReflectionCubeMap))}),!0},t.prototype.detach=function(){var e=r.prototype.detach.call(this);return this._xrLightProbe===null||this.options.disableCubeMapReflection||(this._xrLightProbe.removeEventListener("reflectionchange",this._updateReflectionCubeMap),this._xrLightProbe=null),this._canvasContext=null,this._xrLightEstimate=null,this._xrWebGLBinding=null,e},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onReflectionCubeMapUpdatedObservable.clear(),this.directionalLight&&(this.directionalLight.dispose(),this.directionalLight=null),this._reflectionCubeMap!==null&&(this._reflectionCubeMap._texture&&this._reflectionCubeMap._texture.dispose(),this._reflectionCubeMap.dispose(),this._reflectionCubeMap=null)},t.prototype._onXRFrame=function(e){var n;if(this._xrLightProbe!==null){if(this.options.lightEstimationPollInterval){var i=Date.now();if(i-this._lightEstimationPollTime<this.options.lightEstimationPollInterval)return;this._lightEstimationPollTime=i}if(this._xrLightEstimate=e.getLightEstimate(this._xrLightProbe),this._xrLightEstimate){this._intensity=Math.max(1,this._xrLightEstimate.primaryLightIntensity.x,this._xrLightEstimate.primaryLightIntensity.y,this._xrLightEstimate.primaryLightIntensity.z);var o=this._xrSessionManager.scene.useRightHandedSystem?1:-1;this.options.disableVectorReuse&&(this._lightDirection=new _.Pq,this._lightColor=new z.v9,this.directionalLight&&(this.directionalLight.direction=this._lightDirection,this.directionalLight.diffuse=this._lightColor)),this._lightDirection.copyFromFloats(this._xrLightEstimate.primaryLightDirection.x,this._xrLightEstimate.primaryLightDirection.y,this._xrLightEstimate.primaryLightDirection.z*o),this._lightColor.copyFromFloats(this._xrLightEstimate.primaryLightIntensity.x/this._intensity,this._xrLightEstimate.primaryLightIntensity.y/this._intensity,this._xrLightEstimate.primaryLightIntensity.z/this._intensity),this._sphericalHarmonics.updateFromFloatsArray(this._xrLightEstimate.sphericalHarmonicsCoefficients),this._reflectionCubeMap&&!this.options.disableSphericalPolynomial&&(this._reflectionCubeMap.sphericalPolynomial=this._reflectionCubeMap.sphericalPolynomial||new Lo.Q,(n=this._reflectionCubeMap.sphericalPolynomial)===null||n===void 0||n.updateFromHarmonics(this._sphericalHarmonics)),this._lightDirection.negateInPlace(),this.directionalLight&&(this.directionalLight.direction.copyFrom(this._lightDirection),this.directionalLight.intensity=Math.min(this._intensity,1),this.directionalLight.diffuse.copyFrom(this._lightColor))}}},t.Name=vn.LIGHT_ESTIMATION,t.Version=1,t}(qn);kn.AddWebXRFeature(nc.Name,function(r,t){return function(){return new nc(r,t)}},nc.Version,!1);var ic=function(r){function t(e){var n=r.call(this,e)||this;return n.onEyeTrackingStartedObservable=new K.cP,n.onEyeTrackingEndedObservable=new K.cP,n.onEyeTrackingFrameUpdateObservable=new K.cP,n._eyeTrackingStartListener=function(i){n._latestEyeSpace=i.gazeSpace,n._gazeRay=new fn(_.Pq.Zero(),_.Pq.Forward()),n.onEyeTrackingStartedObservable.notifyObservers(n._gazeRay)},n._eyeTrackingEndListener=function(){n._latestEyeSpace=null,n._gazeRay=null,n.onEyeTrackingEndedObservable.notifyObservers()},n.xrNativeFeatureName="eye-tracking",n._xrSessionManager.session?n._init():n._xrSessionManager.onXRSessionInit.addOnce(function(){n._init()}),n}return(0,A.C6)(t,r),t.prototype.dispose=function(){r.prototype.dispose.call(this),this._xrSessionManager.session.removeEventListener("eyetrackingstart",this._eyeTrackingStartListener),this._xrSessionManager.session.removeEventListener("eyetrackingend",this._eyeTrackingEndListener),this.onEyeTrackingStartedObservable.clear(),this.onEyeTrackingEndedObservable.clear(),this.onEyeTrackingFrameUpdateObservable.clear()},Object.defineProperty(t.prototype,"isEyeGazeValid",{get:function(){return!!this._gazeRay},enumerable:!1,configurable:!0}),t.prototype.getEyeGaze=function(){return this._gazeRay},t.prototype._onXRFrame=function(e){if(this.attached&&e&&this._latestEyeSpace&&this._gazeRay){var n=e.getPose(this._latestEyeSpace,this._xrSessionManager.referenceSpace);if(n){this._gazeRay.origin.set(n.transform.position.x,n.transform.position.y,n.transform.position.z).scaleInPlace(this._xrSessionManager.worldScalingFactor);var i=n.transform.orientation;_.AA.Quaternion[0].set(i.x,i.y,i.z,i.w),this._xrSessionManager.scene.useRightHandedSystem?_.Pq.RightHandedForwardReadOnly.rotateByQuaternionToRef(_.AA.Quaternion[0],this._gazeRay.direction):(this._gazeRay.origin.z*=-1,_.AA.Quaternion[0].z*=-1,_.AA.Quaternion[0].w*=-1,_.Pq.LeftHandedForwardReadOnly.rotateByQuaternionToRef(_.AA.Quaternion[0],this._gazeRay.direction)),this.onEyeTrackingFrameUpdateObservable.notifyObservers(this._gazeRay)}}},t.prototype._init=function(){this._xrSessionManager.isNative&&(this._xrSessionManager.session.addEventListener("eyetrackingstart",this._eyeTrackingStartListener),this._xrSessionManager.session.addEventListener("eyetrackingend",this._eyeTrackingEndListener))},t.Name=vn.EYE_TRACKING,t.Version=1,t}(qn);kn.AddWebXRFeature(ic.Name,function(r){return function(){return new ic(r)}},ic.Version,!1);var KN=function(){function r(t,e){this._samples=[],this._idx=0;for(var n=0;n<t;++n)this._samples.push(e?e():_.I9.Zero())}return Object.defineProperty(r.prototype,"length",{get:function(){return this._samples.length},enumerable:!1,configurable:!0}),r.prototype.push=function(t,e){this._idx=(this._idx+this._samples.length-1)%this._samples.length,this.at(0).copyFromFloats(t,e)},r.prototype.at=function(t){if(t>=this._samples.length)throw new Error("Index out of bounds");return this._samples[(this._idx+t)%this._samples.length]},r}(),ZN=function(){function r(){this._samples=new KN(20),this._entropy=0,this.onFirstStepDetected=new K.cP}return r.prototype.update=function(t,e,n,i){this._samples.push(t,e);var o=this._samples.at(0);if(this._entropy*=this._entropyDecayFactor,this._entropy+=_.I9.Distance(o,this._samples.at(1)),!(this._entropy>this._entropyThreshold)){var a;for(a=this._samePointCheckStartIdx;a<this._samples.length&&!(_.I9.DistanceSquared(o,this._samples.at(a))<this._samePointSquaredDistanceThreshold);++a);if(a!==this._samples.length){for(var s=-1,l=0,c=void 0,u=1;u<a;++u)(c=_.I9.DistanceSquared(o,this._samples.at(u)))>s&&(l=u,s=c);if(!(s<this._apexSquaredDistanceThreshold)){var d=this._samples.at(l),h=d.subtract(o);h.normalize();var p,m=_.AA.Vector2[0],v=0;for(u=1;u<a;++u)this._samples.at(u).subtractToRef(o,m),p=_.I9.Dot(h,m),v+=m.lengthSquared()-p*p;if(!(v>a*this._squaredProjectionDistanceThreshold)){var b=_.AA.Vector3[0];b.set(n,i,0);var E=_.AA.Vector3[1];E.set(h.x,h.y,0);var C=_.Pq.Cross(b,E).z>0,T=o.clone(),f=o.clone();d.subtractToRef(o,h),C?(h.scaleAndAddToRef(this._axisToApexShrinkFactor,T),h.scaleAndAddToRef(this._axisToApexExtendFactor,f)):(h.scaleAndAddToRef(this._axisToApexExtendFactor,T),h.scaleAndAddToRef(this._axisToApexShrinkFactor,f)),this.onFirstStepDetected.notifyObservers({leftApex:T,rightApex:f,currentPosition:o,currentStepDirection:C?"right":"left"})}}}}},r.prototype.reset=function(){for(var t=0;t<this._samples.length;++t)this._samples.at(t).copyFromFloats(0,0)},Object.defineProperty(r.prototype,"_samePointCheckStartIdx",{get:function(){return Math.floor(this._samples.length/3)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_samePointSquaredDistanceThreshold",{get:function(){return 9e-4},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_apexSquaredDistanceThreshold",{get:function(){return .0081},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_squaredProjectionDistanceThreshold",{get:function(){return 9e-4},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_axisToApexShrinkFactor",{get:function(){return .8},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_axisToApexExtendFactor",{get:function(){return-1.6},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_entropyDecayFactor",{get:function(){return .93},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"_entropyThreshold",{get:function(){return .4},enumerable:!1,configurable:!0}),r}(),QN=function(){function r(t,e,n,i){this._leftApex=new _.I9,this._rightApex=new _.I9,this._currentPosition=new _.I9,this._axis=new _.I9,this._axisLength=-1,this._forward=new _.I9,this._steppingLeft=!1,this._t=-1,this._maxT=-1,this._maxTPosition=new _.I9,this._vitality=0,this.onMovement=new K.cP,this.onFootfall=new K.cP,this._reset(t,e,n,i==="left")}return r.prototype._reset=function(t,e,n,i){this._leftApex.copyFrom(t),this._rightApex.copyFrom(e),this._steppingLeft=i,this._steppingLeft?(this._leftApex.subtractToRef(this._rightApex,this._axis),this._forward.copyFromFloats(-this._axis.y,this._axis.x)):(this._rightApex.subtractToRef(this._leftApex,this._axis),this._forward.copyFromFloats(this._axis.y,-this._axis.x)),this._axisLength=this._axis.length(),this._forward.scaleInPlace(1/this._axisLength),this._updateTAndVitality(n.x,n.y),this._maxT=this._t,this._maxTPosition.copyFrom(n),this._vitality=1},r.prototype._updateTAndVitality=function(t,e){this._currentPosition.copyFromFloats(t,e),this._steppingLeft?this._currentPosition.subtractInPlace(this._rightApex):this._currentPosition.subtractInPlace(this._leftApex);var n=this._t,i=_.I9.Dot(this._currentPosition,this._axis);this._t=i/(this._axisLength*this._axisLength);var o=this._currentPosition.lengthSquared()-i/this._axisLength*(i/this._axisLength);this._vitality*=.92-100*Math.max(o-.0016,0)+Math.max(this._t-n,0)},r.prototype.update=function(t,e){if(this._vitality<this._vitalityThreshold)return!1;var n=this._t;return this._updateTAndVitality(t,e),this._t>this._maxT&&(this._maxT=this._t,this._maxTPosition.copyFromFloats(t,e)),!(this._vitality<this._vitalityThreshold||(this._t>n&&(this.onMovement.notifyObservers({deltaT:this._t-n}),n<.5&&this._t>=.5&&this.onFootfall.notifyObservers({foot:this._steppingLeft?"left":"right"})),this._t<.95*this._maxT&&(this._currentPosition.copyFromFloats(t,e),this._steppingLeft?this._leftApex.copyFrom(this._maxTPosition):this._rightApex.copyFrom(this._maxTPosition),this._reset(this._leftApex,this._rightApex,this._currentPosition,!this._steppingLeft)),this._axisLength<.03))},Object.defineProperty(r.prototype,"_vitalityThreshold",{get:function(){return .1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"forward",{get:function(){return this._forward},enumerable:!1,configurable:!0}),r}(),JN=function(){function r(t){var e=this;this._detector=new ZN,this._walker=null,this._movement=new _.I9,this._millisecondsSinceLastUpdate=r._MillisecondsPerUpdate,this.movementThisFrame=_.Pq.Zero(),this._engine=t,this._detector.onFirstStepDetected.add(function(n){e._walker||(e._walker=new QN(n.leftApex,n.rightApex,n.currentPosition,n.currentStepDirection),e._walker.onFootfall.add(function(){O.V.Log("Footfall!")}),e._walker.onMovement.add(function(i){e._walker.forward.scaleAndAddToRef(.024*i.deltaT,e._movement)}))})}return Object.defineProperty(r,"_MillisecondsPerUpdate",{get:function(){return 1e3/15},enumerable:!1,configurable:!0}),r.prototype.update=function(t,e){e.y=0,e.normalize(),this._millisecondsSinceLastUpdate+=this._engine.getDeltaTime(),this._millisecondsSinceLastUpdate>=r._MillisecondsPerUpdate&&(this._millisecondsSinceLastUpdate-=r._MillisecondsPerUpdate,this._detector.update(t.x,t.z,e.x,e.z),this._walker&&(this._walker.update(t.x,t.z)||(this._walker=null)),this._movement.scaleInPlace(.85)),this.movementThisFrame.set(this._movement.x,0,this._movement.y)},r}(),rc=function(r){function t(e,n){var i=r.call(this,e)||this;return i._up=new _.Pq,i._forward=new _.Pq,i._position=new _.Pq,i._movement=new _.Pq,i._sessionManager=e,i.locomotionTarget=n.locomotionTarget,i._isLocomotionTargetWebXRCamera&&O.V.Warn("Using walking locomotion directly on a WebXRCamera may have unintended interactions with other XR techniques. Using an XR space parent is highly recommended"),i}return(0,A.C6)(t,r),Object.defineProperty(t,"Name",{get:function(){return vn.WALKING_LOCOMOTION},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Version",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"locomotionTarget",{get:function(){return this._locomotionTarget},set:function(e){this._locomotionTarget=e,this._isLocomotionTargetWebXRCamera=this._locomotionTarget.getClassName()==="WebXRCamera"},enumerable:!1,configurable:!0}),t.prototype.isCompatible=function(){return this._sessionManager.sessionMode===void 0||this._sessionManager.sessionMode==="immersive-vr"},t.prototype.attach=function(){return!(!this.isCompatible||!r.prototype.attach.call(this)||(this._walker=new JN(this._sessionManager.scene.getEngine()),0))},t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this._walker=null,!0)},t.prototype._onXRFrame=function(e){var n=e.getViewerPose(this._sessionManager.baseReferenceSpace);if(n){var i=this.locomotionTarget.getScene().useRightHandedSystem?1:-1,o=n.transform.matrix;this._up.copyFromFloats(o[4],o[5],i*o[6]),this._forward.copyFromFloats(o[8],o[9],i*o[10]),this._position.copyFromFloats(o[12],o[13],i*o[14]),this._forward.scaleAndAddToRef(.05,this._position),this._up.scaleAndAddToRef(-.05,this._position),this._walker.update(this._position,this._forward),this._movement.copyFrom(this._walker.movementThisFrame),this._isLocomotionTargetWebXRCamera||_.Pq.TransformNormalToRef(this._movement,this.locomotionTarget.getWorldMatrix(),this._movement),this.locomotionTarget.position.addInPlace(this._movement)}},t}(qn);kn.AddWebXRFeature(rc.Name,function(r,t){return function(){return new rc(r,t)}},rc.Version,!1);var E1=function(r){function t(e,n,i,o,a,s,l){l===void 0&&(l=null);var c=r.call(this,e,n,i,o,s)||this;return c.getWidth=e,c.getHeight=n,c.layer=i,c.layerType=o,c.isMultiview=a,c.createRTTProvider=s,c._originalInternalTexture=l,c}return(0,A.C6)(t,r),t}(Wm),x1=function(r){function t(e,n,i){var o=r.call(this,e.scene,i)||this;return o._xrSessionManager=e,o._xrWebGLBinding=n,o.layerWrapper=i,o._lastSubImages=new Map,o.onRenderTargetTextureCreatedObservable=new K.cP,o._compositionLayer=i.layer,o}return(0,A.C6)(t,r),t.prototype._getRenderTargetForSubImage=function(e,n){var i,o,a,s;n===void 0&&(n="none");var l=this._lastSubImages.get(n),c=n=="right"?1:0,u=(i=e.colorTextureWidth)!==null&&i!==void 0?i:e.textureWidth,d=(o=e.colorTextureHeight)!==null&&o!==void 0?o:e.textureHeight;if(!this._renderTargetTextures[c]||l?.textureWidth!==u||l?.textureHeight!==d){var h=void 0,p=(a=e.depthStencilTextureWidth)!==null&&a!==void 0?a:u,m=(s=e.depthStencilTextureHeight)!==null&&s!==void 0?s:d;u!==p&&d!==m||(h=e.depthStencilTexture),this._renderTargetTextures[c]=this._createRenderTargetTexture(u,d,null,e.colorTexture,h,this.layerWrapper.isMultiview),this._framebufferDimensions={framebufferWidth:u,framebufferHeight:d},this.onRenderTargetTextureCreatedObservable.notifyObservers({texture:this._renderTargetTextures[c],eye:n})}return this._lastSubImages.set(n,e),this._renderTargetTextures[c]},t.prototype._getSubImageForEye=function(e){var n=this._xrSessionManager.currentFrame;return n?this._xrWebGLBinding.getSubImage(this._compositionLayer,n,e):null},t.prototype.getRenderTargetTextureForEye=function(e){var n=this._getSubImageForEye(e);return n?this._getRenderTargetForSubImage(n,e):null},t.prototype.getRenderTargetTextureForView=function(e){return this.getRenderTargetTextureForEye(e?.eye)},t.prototype._setViewportForSubImage=function(e,n){var i,o,a=(i=n.colorTextureWidth)!==null&&i!==void 0?i:n.textureWidth,s=(o=n.colorTextureHeight)!==null&&o!==void 0?o:n.textureHeight,l=n.viewport;e.x=l.x/a,e.y=l.y/s,e.width=l.width/a,e.height=l.height/s},t.prototype.trySetViewportForView=function(e,n){var i=this._lastSubImages.get(n.eye)||this._getSubImageForEye(n.eye);return!!i&&(this._setViewportForSubImage(e,i),!0)},t}(Vs),$N=function(r){function t(e,n,i){var o=r.call(this,function(){return e.textureWidth},function(){return e.textureHeight},e,"XRProjectionLayer",n,function(a){return new eL(a,i,o)})||this;return o.layer=e,o}return(0,A.C6)(t,r),t}(E1),eL=function(r){function t(e,n,i){var o=r.call(this,e,n,i)||this;return o.layerWrapper=i,o._projectionLayer=i.layer,o}return(0,A.C6)(t,r),t.prototype._getSubImageForView=function(e){return this._xrWebGLBinding.getViewSubImage(this._projectionLayer,e)},t.prototype.getRenderTargetTextureForView=function(e){return this._getRenderTargetForSubImage(this._getSubImageForView(e),e.eye)},t.prototype.getRenderTargetTextureForEye=function(e){var n=this._lastSubImages.get(e);return n?this._getRenderTargetForSubImage(n,e):null},t.prototype.trySetViewportForView=function(e,n){var i=this._lastSubImages.get(n.eye)||this._getSubImageForView(n);return!!i&&(this._setViewportForSubImage(e,i),!0)},t}(x1),P1={textureType:"texture",colorFormat:6408,depthFormat:35056,scaleFactor:1,clearOnAccess:!1},tL={},oc=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i._options=n,i._existingLayers=[],i._isMultiviewEnabled=!1,i._projectionLayerInitialized=!1,i._compositionLayerTextureMapping=new WeakMap,i._layerToRTTProviderMapping=new WeakMap,i.xrNativeFeatureName="layers",i}return(0,A.C6)(t,r),t.prototype.attach=function(){if(!r.prototype.attach.call(this))return!1;var e=this._xrSessionManager.scene.getEngine();this._glContext=e._gl,this._xrWebGLBinding=new XRWebGLBinding(this._xrSessionManager.session,this._glContext),this._existingLayers.length=0;var n=(0,A.Cl)((0,A.Cl)({},P1),this._options.projectionLayerInit);return this._isMultiviewEnabled=this._options.preferMultiviewOnInit&&e.getCaps().multiview,this.createProjectionLayer(n),this._projectionLayerInitialized=!0,!0},t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this._existingLayers.forEach(function(e){e.dispose()}),this._existingLayers.length=0,this._projectionLayerInitialized=!1,!0)},t.prototype.createXRWebGLLayer=function(e){e===void 0&&(e=tL);var n=new XRWebGLLayer(this._xrSessionManager.session,this._glContext,e);return new Hm(n)},t.prototype._validateLayerInit=function(e,n){if(n===void 0&&(n=this._isMultiviewEnabled),!this._xrSessionManager.inXRSession)throw new Error("Cannot create a layer outside of a WebXR session. Make sure the session has started before creating layers.");if(n&&e.textureType!=="texture-array")throw new Error("Projection layers can only be made multiview if they use texture arrays. Set the textureType parameter to 'texture-array'.");if(!n&&e.textureType==="texture-array")throw new Error("We currently only support multiview rendering when the textureType parameter is set to 'texture-array'.")},t.prototype._extendXRLayerInit=function(e,n){return n===void 0&&(n=this._isMultiviewEnabled),n&&(e.textureType="texture-array"),e},t.prototype.createProjectionLayer=function(e,n){e===void 0&&(e=P1),n===void 0&&(n=this._isMultiviewEnabled),this._extendXRLayerInit(e,n),this._validateLayerInit(e,n);var i=this._xrWebGLBinding.createProjectionLayer(e),o=new $N(i,n,this._xrWebGLBinding);return this.addXRSessionLayer(o),o},t.prototype._createQuadLayer=function(e,n){var i=this;e===void 0&&(e={params:{}}),this._extendXRLayerInit(e.params,!1);var o=this._existingLayers[0].layer.textureWidth,a=this._existingLayers[0].layer.textureHeight,s=(0,A.Cl)({space:this._xrSessionManager.referenceSpace,viewPixelWidth:o,viewPixelHeight:a,clearOnAccess:!0},e.params);this._validateLayerInit(s,!1);var l=this._xrWebGLBinding.createQuadLayer(s);l.width=this._isMultiviewEnabled?1:2,l.height=1;var c=new E1(function(){return l.width},function(){return l.height},l,"XRQuadLayer",!1,function(d){return new x1(d,i._xrWebGLBinding,c)});n&&this._compositionLayerTextureMapping.set(l,n);var u=c.createRenderTargetTextureProvider(this._xrSessionManager);return this._layerToRTTProviderMapping.set(l,u),this.addXRSessionLayer(c),c},t.prototype.addFullscreenAdvancedDynamicTexture=function(e,n){var i=this;n===void 0&&(n={distanceFromHeadset:1.5});var o=this._createQuadLayer({params:{space:this._xrSessionManager.viewerReferenceSpace,textureType:"texture",layout:"mono"}},e),a=o.layer,s={x:0,y:0,z:-Math.max(.1,n.distanceFromHeadset)};a.transform=new XRRigidTransform(s,{x:0,y:0,z:0,w:1});var l=this._layerToRTTProviderMapping.get(a);if(!l)throw new Error("Could not find the RTT provider for the layer");var c=this._xrSessionManager.scene.layers.find(function(u){return u.texture===e});if(!c)throw new Error("Could not find the babylon layer for the texture");return l.onRenderTargetTextureCreatedObservable.add(function(u){u.eye&&u.eye==="right"||(u.texture.clearColor=new z.ov(0,0,0,0),c.renderTargetTextures.push(u.texture),c.renderOnlyInRenderTargetTextures=!0,i._xrSessionManager.scene.onBeforeRenderObservable.add(function(){u.texture.render()}),c.renderTargetTextures.push(u.texture),c.renderOnlyInRenderTargetTextures=!0,i._xrSessionManager.onXRSessionEnded.addOnce(function(){c.renderTargetTextures.splice(c.renderTargetTextures.indexOf(u.texture),1),c.renderOnlyInRenderTargetTextures=!1}))}),o},t.prototype._addLensFlareSystem=function(e){var n=this,i=this._createQuadLayer({params:{space:this._xrSessionManager.viewerReferenceSpace,textureType:"texture",layout:"mono"}}),o=i.layer;o.width=2,o.height=1,o.transform=new XRRigidTransform({x:0,y:0,z:-10},{x:0,y:0,z:0,w:1});var a=this._layerToRTTProviderMapping.get(o);if(!a)throw new Error("Could not find the RTT provider for the layer");return a.onRenderTargetTextureCreatedObservable.add(function(s){s.texture.clearColor=new z.ov(0,0,0,0),s.texture.customRenderFunction=function(){e.render()}}),this._xrSessionManager.onXRSessionInit.add(function(){n._xrSessionManager.scene.lensFlareSystems.splice(n._xrSessionManager.scene.lensFlareSystems.indexOf(e),1)}),this._xrSessionManager.onXRSessionEnded.add(function(){n._xrSessionManager.scene.lensFlareSystems.push(e)}),i},t.prototype.addXRSessionLayer=function(e){this._existingLayers.push(e),this.setXRSessionLayers(this._existingLayers)},t.prototype.setXRSessionLayers=function(e){e===void 0&&(e=this._existingLayers);var n=(0,A.Cl)({},this._xrSessionManager.session.renderState);n.baseLayer=void 0,n.layers=e.map(function(i){return i.layer}),this._xrSessionManager.updateRenderState(n),this._projectionLayerInitialized||this._xrSessionManager._setBaseLayerWrapper(e.length>0?e.at(0):null)},t.prototype.isCompatible=function(){return!this._xrSessionManager.isNative&&typeof XRWebGLBinding<"u"&&!!XRWebGLBinding.prototype.createProjectionLayer},t.prototype.dispose=function(){r.prototype.dispose.call(this)},t.prototype._onXRFrame=function(e){for(var n=this._existingLayers,i=0;i<n.length;++i){var o=n[i];if(o.layerType!=="XRProjectionLayer"){var a=this._layerToRTTProviderMapping.get(o.layer);if(!a)continue;if(a.layerWrapper.isMultiview){var s=e.getViewerPose(this._xrSessionManager.referenceSpace);if(s)for(var l=s.views,c=0;c<l.length;++c){var u=l[c];a.getRenderTargetTextureForView(u)}}else a.getRenderTargetTextureForView()}}},t.Name=vn.LAYERS,t.Version=1,t}(qn);kn.AddWebXRFeature(oc.Name,function(r,t){return function(){return new oc(r,t)}},oc.Version,!1);var ac=function(r){function t(e,n){var i=r.call(this,e)||this;return i.options=n,i._width=null,i._height=null,i._rawValueToMeters=null,i._normDepthBufferFromNormView=null,i._cachedDepthBuffer=null,i._cachedWebGLTexture=null,i._cachedDepthImageTexture=null,i.onGetDepthInMetersAvailable=new K.cP,i.xrNativeFeatureName="depth-sensing",ze.S0.Warn("depth-sensing is an experimental and unstable feature."),i}return(0,A.C6)(t,r),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rawValueToMeters",{get:function(){return this._rawValueToMeters},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normDepthBufferFromNormView",{get:function(){return this._normDepthBufferFromNormView},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthUsage",{get:function(){switch(this._xrSessionManager.session.depthUsage){case"cpu-optimized":return"cpu";case"gpu-optimized":return"gpu"}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthDataFormat",{get:function(){switch(this._xrSessionManager.session.depthDataFormat){case"luminance-alpha":return"ushort";case"float32":return"float"}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"latestInternalTexture",{get:function(){var e,n;if(!this._cachedWebGLTexture)return null;var i=this._xrSessionManager.scene.getEngine(),o=new rn.h(i,0);return o.isCube=!1,o.invertY=!1,o._useSRGBBuffer=!1,o.format=this.depthDataFormat==="ushort"?P.Y.TEXTUREFORMAT_LUMINANCE_ALPHA:P.Y.TEXTUREFORMAT_RGBA,o.generateMipMaps=!1,o.type=this.depthDataFormat==="ushort"?P.Y.TEXTURETYPE_UNSIGNED_SHORT:P.Y.TEXTURETYPE_FLOAT,o.samplingMode=P.Y.TEXTURE_NEAREST_LINEAR,o.width=(e=this.width)!==null&&e!==void 0?e:0,o.height=(n=this.height)!==null&&n!==void 0?n:0,o._cachedWrapU=P.Y.TEXTURE_WRAP_ADDRESSMODE,o._cachedWrapV=P.Y.TEXTURE_WRAP_ADDRESSMODE,o._hardwareTexture=new ea.d(this._cachedWebGLTexture,i._gl),o},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"latestDepthBuffer",{get:function(){return this._cachedDepthBuffer?this.depthDataFormat==="ushort"?new Uint16Array(this._cachedDepthBuffer):new Float32Array(this._cachedDepthBuffer):null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"latestDepthImageTexture",{get:function(){return this._cachedDepthImageTexture},enumerable:!1,configurable:!0}),t.prototype.attach=function(e){return!!r.prototype.attach.call(this,e)&&this._xrSessionManager.session.depthDataFormat!=null&&this._xrSessionManager.session.depthUsage!=null&&(this._glBinding=new XRWebGLBinding(this._xrSessionManager.session,this._xrSessionManager.scene.getEngine()._gl),!0)},t.prototype.dispose=function(){var e;(e=this._cachedDepthImageTexture)===null||e===void 0||e.dispose()},t.prototype._onXRFrame=function(e){var n=this._xrSessionManager.referenceSpace,i=e.getViewerPose(n);if(i!=null)for(var o=0,a=i.views;o<a.length;o++){var s=a[o];switch(this.depthUsage){case"cpu":this._updateDepthInformationAndTextureCPUDepthUsage(e,s,this.depthDataFormat);break;case"gpu":if(!this._glBinding)break;this._updateDepthInformationAndTextureWebGLDepthUsage(this._glBinding,s,this.depthDataFormat);break;default:ze.S0.Error("Unknown depth usage"),this.detach()}}},t.prototype._updateDepthInformationAndTextureCPUDepthUsage=function(e,n,i){var o,a=e.getDepthInformation(n);if(a!==null){var s=(o=a).data,l=o.width,c=o.height,u=o.rawValueToMeters,d=o.getDepthInMeters;switch(this._width=l,this._height=c,this._rawValueToMeters=u,this._cachedDepthBuffer=s,this.onGetDepthInMetersAvailable.notifyObservers(d.bind(a)),this._cachedDepthImageTexture||(this._cachedDepthImageTexture=Ln.CreateRTexture(null,l,c,this._xrSessionManager.scene,!1,!0,Ie.g.NEAREST_SAMPLINGMODE,P.Y.TEXTURETYPE_FLOAT)),i){case"ushort":this._cachedDepthImageTexture.update(Float32Array.from(new Uint16Array(s)).map(function(h){return h*u}));break;case"float":this._cachedDepthImageTexture.update(new Float32Array(s).map(function(h){return h*u}))}}},t.prototype._updateDepthInformationAndTextureWebGLDepthUsage=function(e,n,i){var o,a=e.getDepthInformation(n);if(a!==null){var s=(o=a).texture,l=o.width,c=o.height;this._width=l,this._height=c,this._cachedWebGLTexture=s;var u=this._xrSessionManager.scene,d=u.getEngine().wrapWebGLTexture(s);this._cachedDepthImageTexture||(this._cachedDepthImageTexture=Ln.CreateRTexture(null,l,c,u,!1,!0,Ie.g.NEAREST_SAMPLINGMODE,i==="ushort"?P.Y.TEXTURETYPE_UNSIGNED_BYTE:P.Y.TEXTURETYPE_FLOAT)),this._cachedDepthImageTexture._texture=d}},t.prototype.getXRSessionInitExtension=function(){var e=this,n=this.options.usagePreference!=null&&this.options.usagePreference.length!==0,i=this.options.dataFormatPreference!=null&&this.options.dataFormatPreference.length!==0;return new Promise(function(o){o(n&&i?{depthSensing:{usagePreference:e.options.usagePreference.map(function(a){switch(a){case"cpu":return"cpu-optimized";case"gpu":return"gpu-optimized"}}),dataFormatPreference:e.options.dataFormatPreference.map(function(a){switch(a){case"ushort":return"luminance-alpha";case"float":return"float32"}})}}:{})})},t.Name=vn.DEPTH_SENSING,t.Version=1,t}(qn);kn.AddWebXRFeature(ac.Name,function(r,t){return function(){return new ac(r,t)}},ac.Version,!1),Gt.l.ShadersStore.velocityPixelShader=`precision highp float;
|
||
#define CUSTOM_FRAGMENT_BEGIN
|
||
varying vec4 clipPos;varying vec4 previousClipPos;
|
||
#define CUSTOM_FRAGMENT_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
||
highp vec4 motionVector=( clipPos/clipPos.w-previousClipPos/previousClipPos.w );gl_FragColor=motionVector;
|
||
#define CUSTOM_FRAGMENT_MAIN_END
|
||
}`,Gt.l.ShadersStore.velocityVertexShader=`#define CUSTOM_VERTEX_BEGIN
|
||
#define VELOCITY
|
||
attribute vec3 position;
|
||
#include<instancesDeclaration>
|
||
uniform mat4 viewProjection;uniform mat4 previousViewProjection;
|
||
#ifdef MULTIVIEW
|
||
uniform mat4 viewProjectionR;uniform mat4 previousViewProjectionR;
|
||
#endif
|
||
varying vec4 clipPos;varying vec4 previousClipPos;
|
||
#define CUSTOM_VERTEX_DEFINITIONS
|
||
void main(void) {
|
||
#define CUSTOM_VERTEX_MAIN_BEGIN
|
||
vec3 positionUpdated=position;
|
||
#include<instancesVertex>
|
||
vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vec4 previousWorldPos=finalPreviousWorld*vec4(positionUpdated,1.0);
|
||
#ifdef MULTIVIEW
|
||
if (gl_ViewID_OVR==0u) {clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousWorldPos;gl_Position=clipPos;} else {clipPos=viewProjectionR*worldPos;previousClipPos=previousViewProjectionR*previousWorldPos;gl_Position=clipPos;}
|
||
#elif
|
||
clipPos=viewProjection*worldPos;previousClipPos=previousViewProjection*previousWorldPos;gl_Position=clipPos;
|
||
#endif
|
||
#define CUSTOM_VERTEX_MAIN_END
|
||
}`;var ZT=function(r){function t(e,n,i,o){o===void 0&&(o=512);var a=r.call(this,"spacewarp rtt",o,i,!1,!0,P.Y.TEXTURETYPE_HALF_FLOAT,!1,void 0,!1,!1,!0,void 0,!0)||this;return a._originalPairing=[],a._previousWorldMatrices=[],a._previousTransforms=[_.uq.Identity(),_.uq.Identity()],a._renderTarget=a.getScene().getEngine().createMultiviewRenderTargetTexture(a.getRenderWidth(),a.getRenderHeight(),e,n),a._renderTarget._disposeOnlyFramebuffers=!0,a._texture=a._renderTarget.texture,a._texture.isMultiview=!0,a._texture.format=P.Y.TEXTUREFORMAT_RGBA,i&&(a._velocityMaterial=new pi("velocity shader material",i,{vertex:"velocity",fragment:"velocity"},{uniforms:["world","previousWorld","viewProjection","viewProjectionR","previousViewProjection","previousViewProjectionR"]}),a._velocityMaterial._materialHelperNeedsPreviousMatrices=!0,a._velocityMaterial.onBindObservable.add(function(s){a._previousWorldMatrices[s.uniqueId]=a._previousWorldMatrices[s.uniqueId]||s.getWorldMatrix(),a._velocityMaterial.getEffect().setMatrix("previousWorld",a._previousWorldMatrices[s.uniqueId]),a._previousWorldMatrices[s.uniqueId]=s.getWorldMatrix(),a._velocityMaterial.getEffect().setMatrix("previousViewProjection",a._previousTransforms[0]),a._velocityMaterial.getEffect().setMatrix("previousViewProjectionR",a._previousTransforms[1]),a._previousTransforms[0].copyFrom(i.getTransformMatrix()),a._previousTransforms[1].copyFrom(i._transformMatrixR)}),a._velocityMaterial.freeze()),a}return(0,A.C6)(t,r),t.prototype.render=function(e,n){var i=this;e===void 0&&(e=!1),n===void 0&&(n=!1),this._originalPairing.length=0;var o=this.getScene();o&&this._velocityMaterial&&o.getActiveMeshes().forEach(function(a){i._originalPairing.push([a,a.material]),a.material=i._velocityMaterial}),r.prototype.render.call(this,e,n),this._originalPairing.forEach(function(a){a[0].material=a[1]})},t.prototype._bindFrameBuffer=function(){this._renderTarget&&this.getScene().getEngine().bindSpaceWarpFramebuffer(this._renderTarget)},t.prototype.getViewCount=function(){return 2},t.prototype.dispose=function(){r.prototype.dispose.call(this),this._velocityMaterial.dispose(),this._previousTransforms.length=0,this._previousWorldMatrices.length=0,this._originalPairing.length=0},t}(un.$),QT=function(){function r(t,e,n){this._scene=t,this._xrSessionManager=e,this._xrWebGLBinding=n,this._lastSubImages=new Map,this._renderTargetTextures=new Map,this._engine=t.getEngine()}return r.prototype._getSubImageForView=function(t){var e=this._xrSessionManager._getBaseLayerWrapper();if(!e)throw new Error("For Space Warp, the base layer should be a WebXR Projection Layer.");if(e.layerType!=="XRProjectionLayer")throw new Error('For Space Warp, the base layer type should "XRProjectionLayer".');var n=e.layer;return this._xrWebGLBinding.getViewSubImage(n,t)},r.prototype._setViewportForSubImage=function(t,e){t.x=0,t.y=0,t.width=e.motionVectorTextureWidth,t.height=e.motionVectorTextureHeight},r.prototype._createRenderTargetTexture=function(t,e,n,i,o){if(!this._engine)throw new Error("Engine is disposed");var a={width:t,height:e},s=new ZT(i,o,this._scene,a),l=s.renderTarget;return n&&(l._framebuffer=n),l._colorTextureArray=i,l._depthStencilTextureArray=o,s.disableRescaling(),s.renderListPredicate=function(){return!0},s},r.prototype._getRenderTargetForSubImage=function(t,e){var n=this._lastSubImages.get(e),i=this._renderTargetTextures.get(e.eye),o=t.motionVectorTextureWidth,a=t.motionVectorTextureHeight;return i&&n?.textureWidth===o&&n?.textureHeight==a||(i=this._createRenderTargetTexture(o,a,null,t.motionVectorTexture,t.depthStencilTexture),this._renderTargetTextures.set(e.eye,i),this._framebufferDimensions={framebufferWidth:o,framebufferHeight:a}),this._lastSubImages.set(e,t),i},r.prototype.trySetViewportForView=function(t,e){var n=this._lastSubImages.get(e)||this._getSubImageForView(e);return!!n&&(this._setViewportForSubImage(t,n),!0)},r.prototype.accessMotionVector=function(t){var e=this._getSubImageForView(t);e&&(e.motionVectorTexture,e.depthStencilTexture)},r.prototype.getRenderTargetTextureForEye=function(t){return null},r.prototype.getRenderTargetTextureForView=function(t){var e=this._getSubImageForView(t);return e?this._getRenderTargetForSubImage(e,t):null},r.prototype.dispose=function(){this._renderTargetTextures.forEach(function(t){return t.dispose()}),this._renderTargetTextures.clear()},r}(),sc=function(r){function t(e){var n=r.call(this,e)||this;return n._onAfterRenderObserver=null,n.dependsOn=[vn.LAYERS],n.xrNativeFeatureName="space-warp",n._xrSessionManager.scene.needsPreviousWorldMatrices=!0,n}return(0,A.C6)(t,r),t.prototype.attach=function(){var e=this;if(!r.prototype.attach.call(this))return!1;var n=this._xrSessionManager.scene.getEngine();return this._glContext=n._gl,this._xrWebGLBinding=new XRWebGLBinding(this._xrSessionManager.session,this._glContext),this.spaceWarpRTTProvider=new QT(this._xrSessionManager.scene,this._xrSessionManager,this._xrWebGLBinding),this._onAfterRenderObserver=this._xrSessionManager.scene.onAfterRenderObservable.add(function(){return e._onAfterRender()}),!0},t.prototype.detach=function(){return this._xrSessionManager.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),r.prototype.detach.call(this)},t.prototype._onAfterRender=function(){this.attached&&this._renderTargetTexture&&this._renderTargetTexture.render(!1,!1)},t.prototype.isCompatible=function(){return this._xrSessionManager.scene.getEngine().getCaps().colorBufferHalfFloat||!1},t.prototype.dispose=function(){r.prototype.dispose.call(this)},t.prototype._onXRFrame=function(e){var n=e.getViewerPose(this._xrSessionManager.referenceSpace);if(n){var i=n.views[0];this._renderTargetTexture=this._renderTargetTexture||this.spaceWarpRTTProvider.getRenderTargetTextureForView(i),this.spaceWarpRTTProvider.accessMotionVector(i)}},t.Name=vn.SPACE_WARP,t.Version=1,t}(qn);kn.AddWebXRFeature(sc.Name,function(r){return function(){return new sc(r)}},sc.Version,!1);var lc=function(r){function t(e,n){n===void 0&&(n={});var i=r.call(this,e)||this;return i.options=n,i._cachedInternalTextures=[],i.texturesData=[],i.viewIndex=[],i.cameraIntrinsics=[],i.onTexturesUpdatedObservable=new K.cP,i.xrNativeFeatureName="camera-access",i}return(0,A.C6)(t,r),t.prototype.attach=function(e){return!!r.prototype.attach.call(this,e)&&(this._glContext=this._xrSessionManager.scene.getEngine()._gl,this._glBinding=new XRWebGLBinding(this._xrSessionManager.session,this._glContext),!0)},t.prototype.detach=function(){return!!r.prototype.detach.call(this)&&(this._glBinding=void 0,this.options.doNotDisposeOnDetach||(this._cachedInternalTextures.forEach(function(e){return e.dispose()}),this.texturesData.forEach(function(e){return e.dispose()}),this._cachedInternalTextures.length=0,this.texturesData.length=0,this.cameraIntrinsics.length=0),!0)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.onTexturesUpdatedObservable.clear()},t.prototype._updateCameraIntrinsics=function(e,n){var i={width:e.camera.width,height:e.camera.height,x:0,y:0},o=e.projectionMatrix,a=(1-o[8])*i.width/2+i.x,s=(1-o[9])*i.height/2+i.y,l=i.width/2*o[0],c=i.height/2*o[5],u=i.width/2*o[4];this.cameraIntrinsics[n]={u0:a,v0:s,ax:l,ay:c,gamma:u,width:i.width,height:i.height,viewportX:i.x,viewportY:i.y}},t.prototype._updateInternalTextures=function(e,n){var i,o;if(n===void 0&&(n=0),!e.camera)return!1;this.viewIndex[n]=e.eye;var a=(i=this._glBinding)===null||i===void 0?void 0:i.getCameraImage(e.camera);if(this._cachedInternalTextures[n])(o=this._cachedInternalTextures[n]._hardwareTexture)===null||o===void 0||o.set(a);else{var s=new rn.h(this._xrSessionManager.scene.getEngine(),0,!0);s.invertY=!1,s.format=P.Y.TEXTUREFORMAT_RGBA,s.generateMipMaps=!0,s.type=P.Y.TEXTURETYPE_FLOAT,s.samplingMode=P.Y.TEXTURE_LINEAR_LINEAR_MIPLINEAR,s.width=e.camera.width,s.height=e.camera.height,s._cachedWrapU=P.Y.TEXTURE_WRAP_ADDRESSMODE,s._cachedWrapV=P.Y.TEXTURE_WRAP_ADDRESSMODE,s._hardwareTexture=new ea.d(a,this._glContext),this._cachedInternalTextures[n]=s;var l=new Ki.t(this._xrSessionManager.scene);l.name="WebXR Raw Camera Access (".concat(n,")"),l._texture=this._cachedInternalTextures[n],this.texturesData[n]=l,this._updateCameraIntrinsics(e,n)}return this._cachedInternalTextures[n].isReady=!0,!0},t.prototype._onXRFrame=function(e){var n=this,i=this._xrSessionManager.referenceSpace,o=e.getViewerPose(i);if(o&&o.views){var a=!0;o.views.forEach(function(s,l){a=a&&n._updateInternalTextures(s,l)}),a&&this.onTexturesUpdatedObservable.notifyObservers(this.texturesData)}},t.Name=vn.RAW_CAMERA_ACCESS,t.Version=1,t}(qn);kn.AddWebXRFeature(lc.Name,function(r,t){return function(){return new lc(r,t)}},lc.Version,!1);var JT=function(r){function t(e,n,i){var o=r.call(this,e,nL[i],n,i,!0)||this;return o.profileId="generic-hand-select-grasp",o}return(0,A.C6)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){},t.prototype._setRootMesh=function(e){},t.prototype._updateModel=function(){},t}(Bo);Di.RegisterController("generic-hand-select-grasp",function(r,t){return new JT(t,r.gamepad,r.handedness)});var nL={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr-standard-trigger",visualResponses:{}},grasp:{type:"trigger",gamepadIndices:{button:4},rootNodeName:"grasp",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-hand-select-grasp-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr-standard-trigger",visualResponses:{}},grasp:{type:"trigger",gamepadIndices:{button:4},rootNodeName:"grasp",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-hand-select-grasp-right",assetPath:"right.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr-standard-trigger",visualResponses:{}},grasp:{type:"trigger",gamepadIndices:{button:4},rootNodeName:"grasp",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-hand-select-grasp-none",assetPath:"none.glb"}},$T=function(r){function t(e,n,i){var o=r.call(this,e,iL["left-right"],n,i)||this;return o._mapping={defaultButton:{valueNodeName:"VALUE",unpressedNodeName:"UNPRESSED",pressedNodeName:"PRESSED"},defaultAxis:{valueNodeName:"VALUE",minNodeName:"MIN",maxNodeName:"MAX"},buttons:{"xr-standard-trigger":{rootNodeName:"SELECT",componentProperty:"button",states:["default","touched","pressed"]},"xr-standard-squeeze":{rootNodeName:"GRASP",componentProperty:"state",states:["pressed"]},"xr-standard-touchpad":{rootNodeName:"TOUCHPAD_PRESS",labelAnchorNodeName:"squeeze-label",touchPointNodeName:"TOUCH"},"xr-standard-thumbstick":{rootNodeName:"THUMBSTICK_PRESS",componentProperty:"state",states:["pressed"]}},axes:{"xr-standard-touchpad":{"x-axis":{rootNodeName:"TOUCHPAD_TOUCH_X"},"y-axis":{rootNodeName:"TOUCHPAD_TOUCH_Y"}},"xr-standard-thumbstick":{"x-axis":{rootNodeName:"THUMBSTICK_X"},"y-axis":{rootNodeName:"THUMBSTICK_Y"}}}},o.profileId="microsoft-mixed-reality",o}return(0,A.C6)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:this.handedness==="left"?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,path:t.MODEL_BASE_URL+"default/"}},t.prototype._getModelLoadingConstraints=function(){var e=yn.IsPluginForExtensionAvailable(".glb");return e||O.V.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var n=this;this.rootMesh&&(this.getComponentIds().forEach(function(i,o){if(!n.disableAnimation&&i&&n.rootMesh){var a=n._mapping.buttons[i],s=a.rootNodeName;if(!s)return void O.V.Log("Skipping unknown button at index: "+o+" with mapped name: "+i);var l=n._getChildByName(n.rootMesh,s);if(!l)return void O.V.Warn("Missing button mesh with name: "+s);if(a.valueMesh=n._getImmediateChildByName(l,n._mapping.defaultButton.valueNodeName),a.pressedMesh=n._getImmediateChildByName(l,n._mapping.defaultButton.pressedNodeName),a.unpressedMesh=n._getImmediateChildByName(l,n._mapping.defaultButton.unpressedNodeName),a.valueMesh&&a.pressedMesh&&a.unpressedMesh){var c=n.getComponent(i);c&&c.onButtonStateChangedObservable.add(function(u){n._lerpTransform(a,u.value)},void 0,!0)}else O.V.Warn("Missing button submesh under mesh with name: "+s)}}),this.getComponentIds().forEach(function(i){var o=n.getComponent(i);o.isAxes()&&["x-axis","y-axis"].forEach(function(a){if(n.rootMesh){var s=n._mapping.axes[i][a],l=n._getChildByName(n.rootMesh,s.rootNodeName);l?(s.valueMesh=n._getImmediateChildByName(l,n._mapping.defaultAxis.valueNodeName),s.minMesh=n._getImmediateChildByName(l,n._mapping.defaultAxis.minNodeName),s.maxMesh=n._getImmediateChildByName(l,n._mapping.defaultAxis.maxNodeName),s.valueMesh&&s.minMesh&&s.maxMesh?o&&o.onAxisValueChangedObservable.add(function(c){var u=a==="x-axis"?c.x:c.y;n._lerpTransform(s,u,!0)},void 0,!0):O.V.Warn("Missing axis submesh under mesh with name: "+s.rootNodeName)):O.V.Warn("Missing axis mesh with name: "+s.rootNodeName)}})}))},t.prototype._setRootMesh=function(e){var n;this.rootMesh=new xe(this.profileId+" "+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i<e.length;i++){var o=e[i];o.isPickable=!1,o.parent||(n=o)}n&&n.setParent(this.rootMesh),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=_.PT.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",t.MODEL_LEFT_FILENAME="left.glb",t.MODEL_RIGHT_FILENAME="right.glb",t}(Bo);Di.RegisterController("windows-mixed-reality",function(r,t){return new $T(t,r.gamepad,r.handedness)});var iL={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{xr_standard_trigger_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_trigger_pressed_value",minNodeName:"xr_standard_trigger_pressed_min",maxNodeName:"xr_standard_trigger_pressed_max"}}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{xr_standard_squeeze_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_squeeze_pressed_value",minNodeName:"xr_standard_squeeze_pressed_min",maxNodeName:"xr_standard_squeeze_pressed_max"}}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{xr_standard_touchpad_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_pressed_value",minNodeName:"xr_standard_touchpad_pressed_min",maxNodeName:"xr_standard_touchpad_pressed_max"},xr_standard_touchpad_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_pressed_value",minNodeName:"xr_standard_touchpad_xaxis_pressed_min",maxNodeName:"xr_standard_touchpad_xaxis_pressed_max"},xr_standard_touchpad_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_pressed_value",minNodeName:"xr_standard_touchpad_yaxis_pressed_min",maxNodeName:"xr_standard_touchpad_yaxis_pressed_max"},xr_standard_touchpad_xaxis_touched:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_touched_value",minNodeName:"xr_standard_touchpad_xaxis_touched_min",maxNodeName:"xr_standard_touchpad_xaxis_touched_max"},xr_standard_touchpad_yaxis_touched:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_touched_value",minNodeName:"xr_standard_touchpad_yaxis_touched_min",maxNodeName:"xr_standard_touchpad_yaxis_touched_max"},xr_standard_touchpad_axes_touched:{componentProperty:"state",states:["touched","pressed"],valueNodeProperty:"visibility",valueNodeName:"xr_standard_touchpad_axes_touched_value"}},touchPointNodeName:"xr_standard_touchpad_axes_touched_value"},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{xr_standard_thumbstick_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_pressed_value",minNodeName:"xr_standard_thumbstick_pressed_min",maxNodeName:"xr_standard_thumbstick_pressed_max"},xr_standard_thumbstick_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_xaxis_pressed_value",minNodeName:"xr_standard_thumbstick_xaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_xaxis_pressed_max"},xr_standard_thumbstick_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_yaxis_pressed_value",minNodeName:"xr_standard_thumbstick_yaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_yaxis_pressed_max"}}}},gamepadMapping:"xr-standard",rootNodeName:"microsoft-mixed-reality-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{xr_standard_trigger_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_trigger_pressed_value",minNodeName:"xr_standard_trigger_pressed_min",maxNodeName:"xr_standard_trigger_pressed_max"}}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{xr_standard_squeeze_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_squeeze_pressed_value",minNodeName:"xr_standard_squeeze_pressed_min",maxNodeName:"xr_standard_squeeze_pressed_max"}}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{xr_standard_touchpad_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_pressed_value",minNodeName:"xr_standard_touchpad_pressed_min",maxNodeName:"xr_standard_touchpad_pressed_max"},xr_standard_touchpad_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_pressed_value",minNodeName:"xr_standard_touchpad_xaxis_pressed_min",maxNodeName:"xr_standard_touchpad_xaxis_pressed_max"},xr_standard_touchpad_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_pressed_value",minNodeName:"xr_standard_touchpad_yaxis_pressed_min",maxNodeName:"xr_standard_touchpad_yaxis_pressed_max"},xr_standard_touchpad_xaxis_touched:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_touched_value",minNodeName:"xr_standard_touchpad_xaxis_touched_min",maxNodeName:"xr_standard_touchpad_xaxis_touched_max"},xr_standard_touchpad_yaxis_touched:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_touched_value",minNodeName:"xr_standard_touchpad_yaxis_touched_min",maxNodeName:"xr_standard_touchpad_yaxis_touched_max"},xr_standard_touchpad_axes_touched:{componentProperty:"state",states:["touched","pressed"],valueNodeProperty:"visibility",valueNodeName:"xr_standard_touchpad_axes_touched_value"}},touchPointNodeName:"xr_standard_touchpad_axes_touched_value"},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{xr_standard_thumbstick_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_pressed_value",minNodeName:"xr_standard_thumbstick_pressed_min",maxNodeName:"xr_standard_thumbstick_pressed_max"},xr_standard_thumbstick_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_xaxis_pressed_value",minNodeName:"xr_standard_thumbstick_xaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_xaxis_pressed_max"},xr_standard_thumbstick_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_yaxis_pressed_value",minNodeName:"xr_standard_thumbstick_yaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_yaxis_pressed_max"}}}},gamepadMapping:"xr-standard",rootNodeName:"microsoft-mixed-reality-right",assetPath:"right.glb"}},sp=function(r){function t(e,n,i,o,a){a===void 0&&(a=!1);var s=r.call(this,e,rL[i],n,i)||this;return s._forceLegacyControllers=a,s.profileId="oculus-touch",s}return(0,A.C6)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:this.handedness==="left"?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,path:this._isQuest()?t.QUEST_MODEL_BASE_URL:t.MODEL_BASE_URL}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var n=this,i=this._isQuest(),o=this.handedness==="right"?-1:1;this.getComponentIds().forEach(function(a){var s=a&&n.getComponent(a);s&&s.onButtonStateChangedObservable.add(function(l){if(n.rootMesh&&!n.disableAnimation)switch(a){case"xr-standard-trigger":return void(i||(n._modelRootNode.getChildren()[3].rotation.x=.2*-l.value,n._modelRootNode.getChildren()[3].position.y=.005*-l.value,n._modelRootNode.getChildren()[3].position.z=.005*-l.value));case"xr-standard-squeeze":return void(i||(n._modelRootNode.getChildren()[4].position.x=o*l.value*.0035));case"xr-standard-thumbstick":return;case"a-button":case"x-button":return void(i||(l.pressed?n._modelRootNode.getChildren()[1].position.y=-.001:n._modelRootNode.getChildren()[1].position.y=0));case"b-button":case"y-button":return void(i||(l.pressed?n._modelRootNode.getChildren()[2].position.y=-.001:n._modelRootNode.getChildren()[2].position.y=0))}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new xe(this.profileId+" "+this.handedness,this.scene),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=_.PT.FromEulerAngles(0,Math.PI,0)),e.forEach(function(n){n.isPickable=!1}),this._isQuest()?this._modelRootNode=e[0]:(this._modelRootNode=e[1],this.rootMesh.position.y=.034,this.rootMesh.position.z=.052),this._modelRootNode.parent=this.rootMesh},t.prototype._updateModel=function(){},t.prototype._isQuest=function(){return!!navigator.userAgent.match(/Quest/gi)&&!this._forceLegacyControllers},t.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",t.MODEL_LEFT_FILENAME="left.babylon",t.MODEL_RIGHT_FILENAME="right.babylon",t.QUEST_MODEL_BASE_URL="https://controllers.babylonjs.com/oculusQuest/",t}(Bo);Di.RegisterController("oculus-touch",function(r,t){return new sp(t,r.gamepad,r.handedness)}),Di.RegisterController("oculus-touch-legacy",function(r,t){return new sp(t,r.gamepad,r.handedness,!0)});var rL={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"x-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"x_button",visualResponses:{}},"y-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"y_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"a-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"a_button",visualResponses:{}},"b-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"b_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-right",assetPath:"right.glb"}},eS=function(r){function t(e,n,i){var o=r.call(this,e,oL[i],n,i)||this;return o.profileId="htc-vive",o}return(0,A.C6)(t,r),t.prototype._getFilenameAndPath=function(){return{filename:t.MODEL_FILENAME,path:t.MODEL_BASE_URL}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var n=this;this.getComponentIds().forEach(function(i){var o=i&&n.getComponent(i);o&&o.onButtonStateChangedObservable.add(function(a){if(n.rootMesh&&!n.disableAnimation)switch(i){case"xr-standard-trigger":return void(n._modelRootNode.getChildren()[6].rotation.x=.15*-a.value);case"xr-standard-touchpad":case"xr-standard-squeeze":return}},void 0,!0)})},t.prototype._setRootMesh=function(e){this.rootMesh=new xe(this.profileId+" "+this.handedness,this.scene),e.forEach(function(n){n.isPickable=!1}),this._modelRootNode=e[1],this._modelRootNode.parent=this.rootMesh,this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=_.PT.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(Bo);Di.RegisterController("htc-vive",function(r,t){return new eS(t,r.gamepad,r.handedness)});var lp,oL={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc-vive-none",assetPath:"none.glb"}},tS=function(){function r(t){var e=this;this._nativeImpl=t,this._xrTransform=new XRRigidTransform,this._xrPose={transform:this._xrTransform,emulatedPosition:!1},this._xrPoseVectorData=new Float32Array(8),this.fillPoses=this._nativeImpl.fillPoses.bind(this._nativeImpl),this.getViewerPose=this._nativeImpl.getViewerPose.bind(this._nativeImpl),this.getHitTestResults=this._nativeImpl.getHitTestResults.bind(this._nativeImpl),this.getHitTestResultsForTransientInput=function(){throw new Error("XRFrame.getHitTestResultsForTransientInput not supported on native.")},this.createAnchor=this._nativeImpl.createAnchor.bind(this._nativeImpl),this.getJointPose=this._nativeImpl.getJointPose.bind(this._nativeImpl),this.fillJointRadii=this._nativeImpl.fillJointRadii.bind(this._nativeImpl),this.getLightEstimate=function(){throw new Error("XRFrame.getLightEstimate not supported on native.")},this.getImageTrackingResults=function(){var n;return(n=e._nativeImpl._imageTrackingResults)!==null&&n!==void 0?n:[]}}return Object.defineProperty(r.prototype,"session",{get:function(){return this._nativeImpl.session},enumerable:!1,configurable:!0}),r.prototype.getPose=function(t,e){if(this._nativeImpl.getPoseData(t,e,this._xrPoseVectorData.buffer,this._xrTransform.matrix.buffer)){var n=this._xrTransform.position;n.x=this._xrPoseVectorData[0],n.y=this._xrPoseVectorData[1],n.z=this._xrPoseVectorData[2],n.w=this._xrPoseVectorData[3];var i=this._xrTransform.orientation;return i.x=this._xrPoseVectorData[4],i.y=this._xrPoseVectorData[5],i.z=this._xrPoseVectorData[6],i.w=this._xrPoseVectorData[7],this._xrPose}},Object.defineProperty(r.prototype,"trackedAnchors",{get:function(){return this._nativeImpl.trackedAnchors},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"worldInformation",{get:function(){return this._nativeImpl.worldInformation},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"detectedPlanes",{get:function(){return this._nativeImpl.detectedPlanes},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"featurePointCloud",{get:function(){return this._nativeImpl.featurePointCloud},enumerable:!1,configurable:!0}),r.prototype.getDepthInformation=function(t){throw new Error("This function is not available in Babylon Native")},r}();xg("NativeXRFrame",tS),function(r){r[r.Input=0]="Input",r[r.Output=1]="Output"}(lp||(lp={}));var cc=function(){function r(t,e,n){this._ownerBlock=n,this._connectedPoint=[],this.uniqueId=(0,Eo.z)(),this.connectedPointIds=[],this.name=t,this._connectionType=e}return Object.defineProperty(r.prototype,"connectionType",{get:function(){return this._connectionType},enumerable:!1,configurable:!0}),r.prototype._isSingularConnection=function(){return!0},r.prototype.isConnected=function(){return this._connectedPoint.length>0},r.prototype.connectTo=function(t){if(this._connectionType===t._connectionType)throw new Error("Cannot connect two points of type ".concat(this.connectionType));if(this._isSingularConnection()&&this._connectedPoint.length>0||t._isSingularConnection()&&t._connectedPoint.length>0)throw new Error("Max number of connections for point reached");this._connectedPoint.push(t),t._connectedPoint.push(this)},r.prototype.serialize=function(t){t===void 0&&(t={}),t.uniqueId=this.uniqueId,t.name=this.name,t._connectionType=this._connectionType,t.connectedPointIds=[],t.className=this.getClassName();for(var e=0,n=this._connectedPoint;e<n.length;e++){var i=n[e];t.connectedPointIds.push(i.uniqueId)}},r.prototype.getClassName=function(){return"FGConnection"},r.prototype.deserialize=function(t){this.uniqueId=t.uniqueId,this.name=t.name,this._connectionType=t._connectionType,this.connectedPointIds=t.connectedPointIds},r.Parse=function(t,e){t===void 0&&(t={});var n=new(ze.S0.Instantiate(t.className))(t.name,t._connectionType,e);return n.deserialize(t),n},r}(),gi=function(){function r(t){this.value=this._toInt(t)}return r.prototype._toInt=function(t){return 0|t},r.prototype.add=function(t){return new r(this.value+t.value)},r.prototype.subtract=function(t){return new r(this.value-t.value)},r.prototype.multiply=function(t){return new r(Math.imul(this.value,t.value))},r.prototype.divide=function(t){return new r(this.value/t.value)},r.prototype.getClassName=function(){return r.ClassName},r.prototype.equals=function(t){return this.value===t.value},r.Parse=function(t){return new r(t.value)},r.ClassName="FlowGraphInteger",r}();(0,j.Y5)("FlowGraphInteger",gi);var Ji=function(){function r(t,e){this.typeName=t,this.defaultValue=e}return r.prototype.serialize=function(t){t.typeName=this.typeName,t.defaultValue=this.defaultValue},r.Parse=function(t){return new r(t.typeName,t.defaultValue)},r}(),at=new Ji("any",void 0),nS=new Ji("string",""),sn=new Ji("number",0),ei=new Ji("boolean",!1),uc=new Ji("Vector2",_.I9.Zero()),Jr=new Ji("Vector3",_.Pq.Zero()),iS=new Ji("Vector4",_.IU.Zero()),po=new Ji("Matrix",_.uq.Identity()),rS=new Ji("Color3",z.v9.Black()),oS=new Ji("Color4",new z.ov(0,0,0,0)),aS=new Ji("Quaternion",_.PT.Identity()),An=new Ji("FlowGraphInteger",new gi(0));function sS(r){switch(typeof r){case"string":return nS;case"number":return sn;case"boolean":return ei;case"object":return r instanceof _.I9?uc:r instanceof _.Pq?Jr:r instanceof _.IU?iS:r instanceof z.v9?rS:r instanceof z.ov?oS:r instanceof _.PT?aS:r instanceof gi?An:at;default:return at}}var dc=function(r){function t(e,n,i,o){var a=r.call(this,e,n,i)||this;return a.richType=o,a}return(0,A.C6)(t,r),t.prototype._isSingularConnection=function(){return this.connectionType===0},t.prototype.setValue=function(e,n){n._setConnectionValue(this,e)},t.prototype.connectTo=function(e){r.prototype.connectTo.call(this,e)},t.prototype._getValueOrDefault=function(e){return e._hasConnectionValue(this)?e._getConnectionValue(this):this.richType.defaultValue},t.prototype.getValue=function(e){return this.connectionType===1?(e._notifyExecuteNode(this._ownerBlock),this._ownerBlock._updateOutputs(e),this._getValueOrDefault(e)):this.isConnected()?this._connectedPoint[0].getValue(e):this._getValueOrDefault(e)},t.prototype.getClassName=function(){return"FGDataConnection"},t.prototype.serialize=function(e){e===void 0&&(e={}),r.prototype.serialize.call(this,e),e.richType={},this.richType.serialize(e.richType)},t.Parse=function(e,n){var i=cc.Parse(e,n);return i.richType=Ji.Parse(e.richType),i},t}(cc);function A1(r){return r==="Mesh"||r==="AbstractMesh"||r==="GroundMesh"||r==="InstanceMesh"||r==="LinesMesh"||r==="GoldbergMesh"||r==="GreasedLineMesh"||r==="TrailMesh"}function C1(r){return r==="Vector2"||r==="Vector3"||r==="Vector4"||r==="Quaternion"||r==="Color3"||r==="Color4"}function R1(r,t,e){var n,i,o=(i=(n=t?.getClassName)===null||n===void 0?void 0:n.call(t))!==null&&i!==void 0?i:"";A1(o)?e[r]={name:t.name,className:o}:C1(o)?e[r]={value:t.asArray(),className:o}:e[r]=t}function cp(r,t,e){var n=t[r],i=n?.className;return A1(i)?e.getMeshByName(n.name):C1(i)?function(o,a){if(o==="Vector2")return _.I9.FromArray(a);if(o==="Vector3")return _.Pq.FromArray(a);if(o==="Vector4")return _.IU.FromArray(a);if(o==="Quaternion")return _.PT.FromArray(a);if(o==="Color3")return new z.v9(a[0],a[1],a[2]);if(o==="Color4")return new z.ov(a[0],a[1],a[2],a[3]);throw new Error("Unknown vector class name ".concat(o))}(i,n.value):i==="Matrix"?_.uq.FromArray(n.value):i===gi.ClassName?gi.Parse(n):n&&n.value!==void 0?n.value:n}(0,j.Y5)("FGDataConnection",dc);var _o=function(){function r(t){var e,n;this.config=t,this.uniqueId=(0,Eo.z)(),this.name=(n=(e=this.config)===null||e===void 0?void 0:e.name)!==null&&n!==void 0?n:this.getClassName(),this.dataInputs=[],this.dataOutputs=[]}return r.prototype._updateOutputs=function(t){},r.prototype.registerDataInput=function(t,e){var n=new dc(t,0,this,e);return this.dataInputs.push(n),n},r.prototype.registerDataOutput=function(t,e){var n=new dc(t,1,this,e);return this.dataOutputs.push(n),n},r.prototype.getDataInput=function(t){return this.dataInputs.find(function(e){return e.name===t})},r.prototype.getDataOutput=function(t){return this.dataOutputs.find(function(e){return e.name===t})},r.prototype.serialize=function(t,e){t===void 0&&(t={}),t.uniqueId=this.uniqueId,t.config={},this.config&&(t.config.name=this.config.name),t.dataInputs=[],t.dataOutputs=[],t.className=this.getClassName();for(var n=0,i=this.dataInputs;n<i.length;n++){var o={};i[n].serialize(o),t.dataInputs.push(o)}for(var a=0,s=this.dataOutputs;a<s.length;a++){var l={};s[a].serialize(l),t.dataOutputs.push(l)}},r.prototype.getClassName=function(){return"FGBlock"},r.Parse=function(t,e){var n,i,o=ze.S0.Instantiate(t.className),a={},s=(n=e.valueParseFunction)!==null&&n!==void 0?n:cp;if(t.config)for(var l in t.config)a[l]=s(l,t.config,e.scene);((i=t.className)==="FGSetPropertyBlock"||i==="FGGetPropertyBlock"||i==="FGPlayAnimationBlock"||i==="FGMeshPickEventBlock")&&(a.pathConverter=e.pathConverter);var c=new o(a);c.uniqueId=t.uniqueId;for(var u=0;u<t.dataInputs.length;u++){var d=c.getDataInput(t.dataInputs[u].name);if(!d)throw new Error("Could not find data input with name "+t.dataInputs[u].name+" in block "+t.className);d.deserialize(t.dataInputs[u])}for(u=0;u<t.dataOutputs.length;u++){var h=c.getDataOutput(t.dataOutputs[u].name);if(!h)throw new Error("Could not find data output with name "+t.dataOutputs[u].name+" in block "+t.className);h.deserialize(t.dataOutputs[u])}return c.metadata=t.metadata,c.deserialize&&c.deserialize(t),c},r}(),hc=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype._isSingularConnection=function(){return this.connectionType===1},t.prototype._activateSignal=function(e){var n;this.connectionType===0?(e._notifyExecuteNode(this._ownerBlock),this._ownerBlock._execute(e,this),e._increaseExecutionId()):(n=this._connectedPoint[0])===null||n===void 0||n._activateSignal(e)},t}(cc);(0,j.Y5)("FlowGraphSignalConnection",hc);var Mr=function(r){function t(e){var n=r.call(this,e)||this;return n.signalInputs=[],n.signalOutputs=[],n.in=n._registerSignalInput("in"),n}return(0,A.C6)(t,r),t.prototype._registerSignalInput=function(e){var n=new hc(e,0,this);return this.signalInputs.push(n),n},t.prototype._registerSignalOutput=function(e){var n=new hc(e,1,this);return this.signalOutputs.push(n),n},t.prototype.getSignalInput=function(e){return this.signalInputs.find(function(n){return n.name===e})},t.prototype.getSignalOutput=function(e){return this.signalOutputs.find(function(n){return n.name===e})},t.prototype.serialize=function(e){e===void 0&&(e={}),r.prototype.serialize.call(this,e),e.signalInputs=[],e.signalOutputs=[];for(var n=0,i=this.signalInputs;n<i.length;n++){var o={};i[n].serialize(o),e.signalInputs.push(o)}for(var a=0,s=this.signalOutputs;a<s.length;a++){var l={};s[a].serialize(l),e.signalOutputs.push(l)}},t.prototype.deserialize=function(e){for(var n=0;n<e.signalInputs.length;n++){var i=this.getSignalInput(e.signalInputs[n].name);if(!i)throw new Error("Could not find signal input with name "+e.signalInputs[n].name+" in block "+e.className);i.deserialize(e.signalInputs[n])}for(n=0;n<e.signalOutputs.length;n++){var o=this.getSignalOutput(e.signalOutputs[n].name);if(!o)throw new Error("Could not find signal output with name "+e.signalOutputs[n].name+" in block "+e.className);o.deserialize(e.signalOutputs[n])}},t.prototype.getClassName=function(){return"FGExecutionBlock"},t}(_o),lS=function(r){function t(e){var n=r.call(this,e)||this;return n.out=n._registerSignalOutput("out"),n.done=n._registerSignalOutput("done"),n}return(0,A.C6)(t,r),t.prototype._startPendingTasks=function(e){this._preparePendingTasks(e),e._addPendingBlock(this)},t}(Mr),ga=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype._execute=function(e){e._notifyExecuteNode(this),this.out._activateSignal(e)},t}(lS),up=function(){function r(t){this.uniqueId=(0,Eo.z)(),this._userVariables={},this._executionVariables={},this._connectionValues={},this._pendingBlocks=[],this._executionId=0,this.onNodeExecutedObservable=new K.cP,this._configuration=t}return r.prototype.hasVariable=function(t){return t in this._userVariables},r.prototype.setVariable=function(t,e){this._userVariables[t]=e},r.prototype.getVariable=function(t){return this._userVariables[t]},Object.defineProperty(r.prototype,"userVariables",{get:function(){return this._userVariables},enumerable:!1,configurable:!0}),r.prototype._getUniqueIdPrefixedName=function(t,e){return"".concat(t.uniqueId,"_").concat(e)},r.prototype._setExecutionVariable=function(t,e,n){this._executionVariables[this._getUniqueIdPrefixedName(t,e)]=n},r.prototype._getExecutionVariable=function(t,e,n){return this._hasExecutionVariable(t,e)?this._executionVariables[this._getUniqueIdPrefixedName(t,e)]:n},r.prototype._deleteExecutionVariable=function(t,e){delete this._executionVariables[this._getUniqueIdPrefixedName(t,e)]},r.prototype._hasExecutionVariable=function(t,e){return this._getUniqueIdPrefixedName(t,e)in this._executionVariables},r.prototype._hasConnectionValue=function(t){return t.uniqueId in this._connectionValues},r.prototype._setConnectionValue=function(t,e){this._connectionValues[t.uniqueId]=e},r.prototype._getConnectionValue=function(t){return this._connectionValues[t.uniqueId]},Object.defineProperty(r.prototype,"configuration",{get:function(){return this._configuration},enumerable:!1,configurable:!0}),r.prototype._addPendingBlock=function(t){this._pendingBlocks.push(t)},r.prototype._removePendingBlock=function(t){var e=this._pendingBlocks.indexOf(t);e!==-1&&this._pendingBlocks.splice(e,1)},r.prototype._clearPendingBlocks=function(){for(var t=0,e=this._pendingBlocks;t<e.length;t++)e[t]._cancelPendingTasks(this);this._pendingBlocks.length=0},r.prototype._notifyExecuteNode=function(t){this.onNodeExecutedObservable.notifyObservers(t)},r.prototype._increaseExecutionId=function(){this._executionId++},Object.defineProperty(r.prototype,"executionId",{get:function(){return this._executionId},enumerable:!1,configurable:!0}),r.prototype.serialize=function(t,e){for(var n in t===void 0&&(t={}),e===void 0&&(e=R1),t.uniqueId=this.uniqueId,t._userVariables={},this._userVariables)e(n,this._userVariables[n],t._userVariables);for(var n in t._connectionValues={},this._connectionValues)e(n,this._connectionValues[n],t._connectionValues)},r.prototype.getClassName=function(){return"FGContext"},r.Parse=function(t,e){var n,i=e.graph.createContext(),o=(n=e.valueParseFunction)!==null&&n!==void 0?n:cp;for(var a in i.uniqueId=t.uniqueId,t._userVariables){var s=o(a,t._userVariables,i._configuration.scene);i._userVariables[a]=s}for(var a in t._connectionValues)s=o(a,t._connectionValues,i._configuration.scene),i._connectionValues[a]=s;return i},(0,A.Cg)([(0,V.lK)()],r.prototype,"uniqueId",void 0),r}();function cS(r,t){return!(!r.parent||r.parent!==t&&!cS(r.parent,t))}var dp,fc=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n}return(0,A.C6)(t,r),t.prototype._getReferencedMesh=function(){var e=this.config.pathConverter.convert(this.config.path),n=e.info.getObject(e.object);if(!(n&&n instanceof cn))throw new Error("Mesh pick event block requires a valid mesh");return n},t.prototype._preparePendingTasks=function(e){var n=this,i=e._getExecutionVariable(this,"meshPickObserver");if(!i){var o=this._getReferencedMesh();e._setExecutionVariable(this,"mesh",o),i=o.getScene().onPointerObservable.add(function(s){var l,c,u;s.type===vt.Zp.POINTERPICK&&(!((l=s.pickInfo)===null||l===void 0)&&l.pickedMesh)&&(((c=s.pickInfo)===null||c===void 0?void 0:c.pickedMesh)===o||cS((u=s.pickInfo)===null||u===void 0?void 0:u.pickedMesh,o))&&n._execute(e)});var a=o.onDisposeObservable.add(function(){return n._onDispose});e._setExecutionVariable(this,"meshPickObserver",i),e._setExecutionVariable(this,"meshDisposeObserver",a)}},t.prototype._onDispose=function(e){this._cancelPendingTasks(e),e._removePendingBlock(this)},t.prototype._cancelPendingTasks=function(e){var n=e._getExecutionVariable(this,"mesh"),i=e._getExecutionVariable(this,"meshPickObserver"),o=e._getExecutionVariable(this,"meshDisposeObserver");n.getScene().onPointerObservable.remove(i),n.onDisposeObservable.remove(o),e._deleteExecutionVariable(this,"mesh"),e._deleteExecutionVariable(this,"meshPickObserver"),e._deleteExecutionVariable(this,"meshDisposeObserver")},t.prototype.getClassName=function(){return t.ClassName},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.config.path=this.config.path},t.ClassName="FGMeshPickEventBlock",t}(ga);(0,j.Y5)(fc.ClassName,fc),function(r){r[r.Stopped=0]="Stopped",r[r.Started=1]="Started"}(dp||(dp={}));var hp=function(){function r(t){var e=this;this._eventBlocks=[],this._executionContexts=[],this.state=0,this._scene=t.scene,this._coordinator=t.coordinator,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(function(){return e.dispose()})}return r.prototype.createContext=function(){var t=new up({scene:this._scene,coordinator:this._coordinator});return this._executionContexts.push(t),t},r.prototype.getContext=function(t){return this._executionContexts[t]},r.prototype.addEventBlock=function(t){this._eventBlocks.push(t)},r.prototype.start=function(){if(this.state!==1){this.state=1,this._executionContexts.length===0&&this.createContext();for(var t=0,e=this._executionContexts;t<e.length;t++)for(var n=e[t],i=0,o=this._getContextualOrder();i<o.length;i++)o[i]._startPendingTasks(n)}},r.prototype._getContextualOrder=function(){for(var t=[],e=0,n=this._eventBlocks;e<n.length;e++){var i=n[e];if(i.getClassName()===fc.ClassName){for(var o=i._getReferencedMesh(),a=0;a<t.length;a++){var s=t[a]._getReferencedMesh();if(o&&s&&cS(o,s))break}t.splice(a,0,i)}else t.push(i)}return t},r.prototype.dispose=function(){if(this.state!==0){this.state=0;for(var t=0,e=this._executionContexts;t<e.length;t++)e[t]._clearPendingBlocks();this._executionContexts.length=0,this._eventBlocks.length=0,this._scene.onDisposeObservable.remove(this._sceneDisposeObserver),this._sceneDisposeObserver=null}},r.prototype.visitAllBlocks=function(t){for(var e=[],n=new Set,i=0,o=this._eventBlocks;i<o.length;i++){var a=o[i];e.push(a),n.add(a.uniqueId)}for(;e.length>0;){t(a=e.pop());for(var s=0,l=a.dataInputs;s<l.length;s++)for(var c=0,u=l[s]._connectedPoint;c<u.length;c++){var d=u[c];n.has(d._ownerBlock.uniqueId)||(e.push(d._ownerBlock),n.add(d._ownerBlock.uniqueId))}if(a instanceof Mr)for(var h=0,p=a.signalOutputs;h<p.length;h++)for(var m=0,v=p[h]._connectedPoint;m<v.length;m++)d=v[m],n.has(d._ownerBlock.uniqueId)||(e.push(d._ownerBlock),n.add(d._ownerBlock.uniqueId))}},r.prototype.serialize=function(t,e){t===void 0&&(t={}),t.allBlocks=[],this.visitAllBlocks(function(a){var s={};a.serialize(s),t.allBlocks.push(s)}),t.executionContexts=[];for(var n=0,i=this._executionContexts;n<i.length;n++){var o={};i[n].serialize(o,e),t.executionContexts.push(o)}},r.GetDataOutConnectionByUniqueId=function(t,e){for(var n=0,i=t;n<i.length;n++)for(var o=0,a=i[n].dataOutputs;o<a.length;o++){var s=a[o];if(s.uniqueId===e)return s}throw new Error("Could not find data out connection with unique id "+e)},r.GetSignalInConnectionByUniqueId=function(t,e){for(var n=0,i=t;n<i.length;n++){var o=i[n];if(o instanceof Mr)for(var a=0,s=o.signalInputs;a<s.length;a++){var l=s[a];if(l.uniqueId===e)return l}}throw new Error("Could not find signal in connection with unique id "+e)},r.Parse=function(t,e){for(var n,i=e.coordinator.createGraph(),o=[],a=(n=e.valueParseFunction)!==null&&n!==void 0?n:cp,s=0,l=t.allBlocks;s<l.length;s++){var c=l[s],u=_o.Parse(c,{scene:e.coordinator.config.scene,pathConverter:e.pathConverter,valueParseFunction:a});o.push(u),u instanceof ga&&i.addEventBlock(u)}for(var d=0,h=o;d<h.length;d++){for(var p=0,m=(u=h[d]).dataInputs;p<m.length;p++)for(var v=m[p],b=0,E=v.connectedPointIds;b<E.length;b++){var C=E[b],T=r.GetDataOutConnectionByUniqueId(o,C);v.connectTo(T)}if(u instanceof Mr)for(var f=0,g=u.signalOutputs;f<g.length;f++)for(var S=g[f],y=0,x=S.connectedPointIds;y<x.length;y++)C=x[y],T=r.GetSignalInConnectionByUniqueId(o,C),S.connectTo(T)}for(var R=0,I=t.executionContexts;R<I.length;R++){var M=I[R];up.Parse(M,{graph:i,valueParseFunction:a})}return i},r}(),I1=function(){function r(t){var e,n=this;this.config=t,this._flowGraphs=[],this._customEventsMap=new Map,this.config.scene.onDisposeObservable.add(function(){n.dispose()}),((e=r.SceneCoordinators.get(this.config.scene))!==null&&e!==void 0?e:[]).push(this)}return r.prototype.createGraph=function(){var t=new hp({scene:this.config.scene,coordinator:this});return this._flowGraphs.push(t),t},r.prototype.removeGraph=function(t){var e=this._flowGraphs.indexOf(t);e!==-1&&(t.dispose(),this._flowGraphs.splice(e,1))},r.prototype.start=function(){this._flowGraphs.forEach(function(t){return t.start()})},r.prototype.dispose=function(){var t;this._flowGraphs.forEach(function(i){return i.dispose()}),this._flowGraphs.length=0;var e=(t=r.SceneCoordinators.get(this.config.scene))!==null&&t!==void 0?t:[],n=e.indexOf(this);n!==-1&&e.splice(n,1)},r.prototype.serialize=function(t,e){t._flowGraphs=[],this._flowGraphs.forEach(function(n){var i={};n.serialize(i,e),t._flowGraphs.push(i)})},r.Parse=function(t,e){var n,i,o=(n=e.valueParseFunction)!==null&&n!==void 0?n:cp,a=new r({scene:e.scene});return(i=t._flowGraphs)===null||i===void 0||i.forEach(function(s){hp.Parse(s,{coordinator:a,valueParseFunction:o,pathConverter:e.pathConverter})}),a},Object.defineProperty(r.prototype,"flowGraphs",{get:function(){return this._flowGraphs},enumerable:!1,configurable:!0}),r.prototype.getCustomEventObservable=function(t){var e=this._customEventsMap.get(t);return e||(e=new K.cP,this._customEventsMap.set(t,e)),e},r.prototype.notifyCustomEvent=function(t,e){var n=this._customEventsMap.get(t);n&&n.notifyObservers(e)},r.SceneCoordinators=new Map,r}(),M1=function(r){this._context=r,this._context.onNodeExecutedObservable.add(function(t){ze.S0.Log("Node executed: ".concat(t.getClassName()))})},vr=function(r){function t(e){var n=r.call(this,e)||this;return n.out=n._registerSignalOutput("out"),n}return(0,A.C6)(t,r),t}(Mr),fp=function(r){function t(e){var n=r.call(this,e)||this;return n.message=n.registerDataInput("message",at),n}return(0,A.C6)(t,r),t.prototype._execute=function(e){var n=this.message.getValue(e);O.V.Log(n),this.out._activateSignal(e)},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGConsoleLogBlock",t}(vr);(0,j.Y5)(fp.ClassName,fp);var pp=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n.input=n.registerDataInput(e.variableName,at),n}return(0,A.C6)(t,r),t.prototype._execute=function(e){var n=this.config.variableName,i=this.input.getValue(e);e.setVariable(n,i),this.out._activateSignal(e)},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGSetVariableBlock",t}(vr);(0,j.Y5)(pp.ClassName,pp);var O1=new RegExp(/\{(\w+)\}/g),_p=function(){function r(t,e){this.path=t,this.ownerBlock=e,this.templatedInputs=[];for(var n=O1.exec(t);n;){var i=n[1];this.templatedInputs.push(e.registerDataInput(i,An)),n=O1.exec(t)}}return r.prototype.getAccessor=function(t,e){for(var n=this.path,i=0,o=this.templatedInputs;i<o.length;i++){var a=o[i],s=a.getValue(e).value;n=n.replace("{".concat(a.name,"}"),s.toString())}return t.convert(n)},r}(),uS=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n.a=n.registerDataInput("a",at),n.templateComponent=new _p(e.path,n),n}return(0,A.C6)(t,r),t.prototype._execute=function(e){var n=this.a.getValue(e),i=this.templateComponent.getAccessor(this.config.pathConverter,e);i.info.set(n,i.object),this.out._activateSignal(e)},t.prototype.serialize=function(e){e===void 0&&(e={}),r.prototype.serialize.call(this,e),e.config.path=this.config.path},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGSetPropertyBlock",t}(vr);(0,j.Y5)("FGSetPropertyBlock",uS);var dS=function(r){function t(e){var n=r.call(this,e)||this;n.config=e;for(var i=0;i<n.config.eventData.length;i++){var o=n.config.eventData[i];n.registerDataInput(o,at)}return n}return(0,A.C6)(t,r),t.prototype._execute=function(e){var n=this.config.eventId,i=this.dataInputs.map(function(o){return o.getValue(e)});e.configuration.coordinator.notifyCustomEvent(n,i),this.out._activateSignal(e)},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGSendCustomEventBlock",t}(vr);(0,j.Y5)("FGSendCustomEventBlock",dS);var hS=function(r){function t(e){var n=r.call(this,e)||this;return n.condition=n.registerDataInput("condition",ei),n.onTrue=n._registerSignalOutput("onTrue"),n.onFalse=n._registerSignalOutput("onFalse"),n}return(0,A.C6)(t,r),t.prototype._execute=function(e){this.condition.getValue(e)?this.onTrue._activateSignal(e):this.onFalse._activateSignal(e)},t.prototype.getClassName=function(){return"FGBranchBlock"},t}(Mr);(0,j.Y5)("FGBranchBlock",hS);var mp=function(r){function t(e){e===void 0&&(e={startIndex:new gi(0)});var n=r.call(this,e)||this;return n.config=e,n.reset=n._registerSignalInput("reset"),n.n=n.registerDataInput("n",An),n.value=n.registerDataOutput("value",An),n}return(0,A.C6)(t,r),t.prototype._execute=function(e,n){if(n===this.reset)this.value.setValue(this.config.startIndex,e);else{var i=this.value.getValue(e);i.value<this.n.getValue(e).value&&(this.value.setValue(new gi(i.value+1),e),this.out._activateSignal(e))}},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGDoNBlock",t}(vr);(0,j.Y5)(mp.ClassName,mp);var fS=function(r){function t(e){var n=r.call(this,e)||this;return n.startIndex=n.registerDataInput("startIndex",sn),n.endIndex=n.registerDataInput("endIndex",sn),n.step=n.registerDataInput("step",sn),n.index=n.registerDataOutput("index",sn),n.onLoop=n._registerSignalOutput("onLoop"),n}return(0,A.C6)(t,r),t.prototype._executeLoop=function(e){var n=e._getExecutionVariable(this,"index");n<e._getExecutionVariable(this,"endIndex")?(this.index.setValue(n,e),this.onLoop._activateSignal(e),n+=e._getExecutionVariable(this,"step",1),e._setExecutionVariable(this,"index",n),this._executeLoop(e)):this.out._activateSignal(e)},t.prototype._execute=function(e){var n=this.startIndex.getValue(e),i=this.endIndex.getValue(e),o=this.step.getValue(e);e._setExecutionVariable(this,"index",n),e._setExecutionVariable(this,"endIndex",i),e._setExecutionVariable(this,"step",o),this._executeLoop(e)},t.prototype.getClassName=function(){return"FGForLoopBlock"},t}(vr);(0,j.Y5)("FGForLoopBlock",fS);var pS=function(r){function t(e){var n=r.call(this,e)||this;return n.reset=n._registerSignalInput("reset"),n.duration=n.registerDataInput("duration",sn),n.timeRemaining=n.registerDataOutput("timeRemaining",sn),n}return(0,A.C6)(t,r),t.prototype._execute=function(e,n){var i=e._getExecutionVariable(this,"lastExecutedTime"),o=this.duration.getValue(e),a=Date.now();if(n===this.reset||i===void 0||a-i>o)this.timeRemaining.setValue(0,e),this.out._activateSignal(e),e._setExecutionVariable(this,"lastExecutedTime",a);else{var s=o-(a-i);this.timeRemaining.setValue(s,e)}},t.prototype.getClassName=function(){return"FGThrottleBlock"},t}(vr);(0,j.Y5)("FGThrottleBlock",pS);var _S=function(r){function t(e){var n=r.call(this,e)||this;return n.timeout=n.registerDataInput("timeout",sn),n}return(0,A.C6)(t,r),t.prototype._preparePendingTasks=function(e){var n=this,i=this.timeout.getValue(e);if(i!==void 0&&i>=0){var o=e._getExecutionVariable(this,"runningTimers")||[],a=e.configuration.scene,s=new dv({timeout:i,contextObservable:a.onBeforeRenderObservable,onEnded:function(){return n._onEnded(s,e)}});s.start(),o.push(s),e._setExecutionVariable(this,"runningTimers",o)}},t.prototype._execute=function(e){this._startPendingTasks(e),this.out._activateSignal(e)},t.prototype._onEnded=function(e,n){var i=n._getExecutionVariable(this,"runningTimers")||[],o=i.indexOf(e);o!==-1?i.splice(o,1):ze.S0.Warn("FlowGraphTimerBlock: Timer ended but was not found in the running timers list"),n._removePendingBlock(this),this.done._activateSignal(n)},t.prototype._cancelPendingTasks=function(e){for(var n=0,i=e._getExecutionVariable(this,"runningTimers")||[];n<i.length;n++)i[n].dispose();e._deleteExecutionVariable(this,"runningTimers")},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGTimerBlock",t}(lS);(0,j.Y5)("FGTimerBlock",_S);var mS=function(r){function t(e){var n=r.call(this,e)||this;n.config=e,n._cachedUnusedIndexes=[],n.reset=n._registerSignalInput("reset"),n.currentIndex=n.registerDataOutput("currentIndex",sn),n.config.startIndex=n.config.startIndex!==void 0?n.config.startIndex:0,n.config.startIndex=Math.max(0,Math.min(n.config.startIndex,n.config.numberOutputFlows-1)),n.outFlows=[];for(var i=0;i<n.config.numberOutputFlows;i++)n.outFlows.push(n._registerSignalOutput("out".concat(i)));return n}return(0,A.C6)(t,r),t.prototype._getUnusedIndexes=function(e){var n=this._cachedUnusedIndexes;if(n.length=0,e._hasExecutionVariable(this,"unusedIndexes")){var i=e._getExecutionVariable(this,"unusedIndexes");for(o=0;o<i.length;o++)n.push(i[o])}else for(var o=0;o<this.config.numberOutputFlows;o++)n.push(o);return n},t.prototype._getNextOutput=function(e,n){return this.config.isRandom?n[Math.floor(Math.random()*n.length)]:e+1},t.prototype._execute=function(e,n){var i,o=(i=e._getExecutionVariable(this,"currentIndex"))!==null&&i!==void 0?i:this.config.startIndex-1,a=this._getUnusedIndexes(e);if(n===this.reset)return e._deleteExecutionVariable(this,"currentIndex"),void e._deleteExecutionVariable(this,"unusedIndexes");var s=this._getNextOutput(o,a);if(s>=this.config.numberOutputFlows&&this.config.loop)s=0;else if(s>=this.config.numberOutputFlows&&!this.config.loop)return;if(a=a.filter(function(c){return c!==s}),a.length===0)for(var l=0;l<this.config.numberOutputFlows;l++)a.push(l);e._setExecutionVariable(this,"unusedIndexes",a),e._setExecutionVariable(this,"currentIndex",s),this.currentIndex.setValue(s,e),this.outFlows[s]._activateSignal(e)},t.prototype.getClassName=function(){return"FGMultiGateBlock"},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.config.numberOutputFlows=this.config.numberOutputFlows,e.config.isRandom=this.config.isRandom,e.config.loop=this.config.loop,e.config.startIndex=this.config.startIndex},t}(Mr);(0,j.Y5)("FGMultiGateBlock",mS);var gS=function(r){function t(e){var n=r.call(this,e)||this;n.config=e,n.selection=n.registerDataInput("selection",at),n.outputFlows=[];for(var i=0;i<=n.config.cases.length;i++)n.outputFlows.push(n._registerSignalOutput("out".concat(i)));return n}return(0,A.C6)(t,r),t.prototype._execute=function(e,n){for(var i=this.selection.getValue(e),o=0;o<this.config.cases.length;o++)if(i===this.config.cases[o])return void this.outputFlows[o]._activateSignal(e);this.outputFlows[this.outputFlows.length-1]._activateSignal(e)},t.prototype.getClassName=function(){return"FGSwitchBlock"},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.cases=this.config.cases},t}(Mr);(0,j.Y5)("FGSwitchBlock",gS);var vS=function(r){function t(e){var n=r.call(this,e)||this;n.config=e,n.inFlows=[],n._cachedActivationState=[],n.reset=n._registerSignalInput("reset");for(var i=1;i<n.config.numberInputFlows;i++)n.inFlows.push(n._registerSignalInput("in".concat(i)));return n}return(0,A.C6)(t,r),t.prototype._getCurrentActivationState=function(e){var n=this._cachedActivationState;if(n.length=0,e._hasExecutionVariable(this,"activationState")){var i=e._getExecutionVariable(this,"activationState");for(o=0;o<i.length;o++)n.push(i[o])}else for(var o=0;o<this.config.numberInputFlows;o++)n.push(!1);return n},t.prototype._execute=function(e,n){var i=this._getCurrentActivationState(e);if(n===this.reset)for(var o=0;o<this.config.numberInputFlows;o++)i[o]=!1;else if(n===this.in)i[0]=!0;else{var a=this.inFlows.indexOf(n);a>=0&&(i[a+1]=!0)}if(e._setExecutionVariable(this,"activationState",i.slice()),i.every(function(s){return s}))for(this.out._activateSignal(e),o=0;o<this.config.numberInputFlows;o++)i[o]=!1},t.prototype.getClassName=function(){return"FGWaitAllBlock"},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.config.numberInputFlows=this.config.numberInputFlows},t}(vr);(0,j.Y5)("FGWaitAllBlock",vS);var yS=function(r){function t(e){var n=r.call(this,e)||this;return n.count=n.registerDataOutput("count",sn),n.reset=n._registerSignalInput("reset"),n}return(0,A.C6)(t,r),t.prototype._execute=function(e,n){var i;if(n===this.reset)return e._setExecutionVariable(this,"count",0),void this.count.setValue(0,e);var o=((i=e._getExecutionVariable(this,"count"))!==null&&i!==void 0?i:0)+1;e._setExecutionVariable(this,"count",o),this.count.setValue(o,e),this.out._activateSignal(e)},t.prototype.getClassName=function(){return"FGCounterBlock"},t}(vr);(0,j.Y5)("FGCounterBlock",yS);var gp=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n.condition=n.registerDataInput("condition",ei),n.loopBody=n._registerSignalOutput("loopBody"),n}return(0,A.C6)(t,r),t.prototype._execute=function(e,n){var i,o=this.condition.getValue(e);for(((i=this.config)===null||i===void 0?void 0:i.isDo)&&!o&&this.loopBody._activateSignal(e);o;)this.loopBody._activateSignal(e),o=this.condition.getValue(e);this.out._activateSignal(e)},t.prototype.getClassName=function(){return t.ClassName},t.prototype.serialize=function(e){var n;r.prototype.serialize.call(this,e),e.isDo=(n=this.config)===null||n===void 0?void 0:n.isDo},t.ClassName="FGWhileLoopBlock",t}(vr);(0,j.Y5)(gp.ClassName,gp);var bS=function(r){function t(e){var n=r.call(this,e)||this;return n.count=n.registerDataInput("count",sn),n.reset=n._registerSignalInput("reset"),n.currentCount=n.registerDataOutput("currentCount",sn),n}return(0,A.C6)(t,r),t.prototype._execute=function(e,n){if(n!==this.reset){var i=this.count.getValue(e),o=e._getExecutionVariable(this,"debounceCount",0)+1;this.currentCount.setValue(o,e),e._setExecutionVariable(this,"debounceCount",o),o>=i&&(this.out._activateSignal(e),e._setExecutionVariable(this,"debounceCount",0))}else e._setExecutionVariable(this,"debounceCount",0)},t.prototype.getClassName=function(){return"FGDebounceBlock"},t}(vr);(0,j.Y5)("FGDebounceBlock",bS);var TS=function(r){function t(e){var n=r.call(this,e)||this;return n.onOn=n._registerSignalOutput("onOn"),n.onOff=n._registerSignalOutput("onOff"),n.isOn=n.registerDataOutput("isOn",ei),n}return(0,A.C6)(t,r),t.prototype._execute=function(e,n){var i=e._getExecutionVariable(this,"value",!1);i=!i,e._setExecutionVariable(this,"value",i),this.isOn.setValue(i,e),i?this.onOn._activateSignal(e):this.onOff._activateSignal(e)},t.prototype.getClassName=function(){return"FGFlipFlopBlock"},t}(Mr);(0,j.Y5)("FGFlipFlopBlock",TS);var vp=function(r){function t(e){var n=r.call(this,e)||this;n.config=e,n.outFlows=[];for(var i=0;i<n.config.numberOutputFlows;i++)n.outFlows.push(n._registerSignalOutput("".concat(i)));return n}return(0,A.C6)(t,r),t.prototype._execute=function(e){for(var n=0;n<this.config.numberOutputFlows;n++)this.outFlows[n]._activateSignal(e)},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGSequenceBlock",t}(Mr);(0,j.Y5)(vp.ClassName,vp);var yp=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n.templateTargetComponent=new _p(e.targetPath,n),n.templateAnimationComponent=new _p(e.animationPath,n),n.speed=n.registerDataInput("speed",sn),n.loop=n.registerDataInput("loop",ei),n.from=n.registerDataInput("from",sn),n.to=n.registerDataInput("to",sn),n.runningAnimatable=n.registerDataOutput("runningAnimatable",at),n}return(0,A.C6)(t,r),t.prototype._preparePendingTasks=function(e){var n,i=this,o=this.templateTargetComponent.getAccessor(this.config.pathConverter,e),a=o.info.getObject(o.object),s=this.templateAnimationComponent.getAccessor(this.config.pathConverter,e),l=s.info.get(s.object);if(!a||!l)throw new Error("Cannot play animation without target or animation");var c=(n=e._getExecutionVariable(this,"runningAnimatables"))!==null&&n!==void 0?n:[],u=this.runningAnimatable.getValue(e);if(u&&u.paused)u.restart();else{var d=e.configuration.scene.beginDirectAnimation(a,[l],this.from.getValue(e),this.to.getValue(e),this.loop.getValue(e),this.speed.getValue(e),function(){return i._onAnimationEnd(d,e)});this.runningAnimatable.setValue(d,e),c.push(d)}e._setExecutionVariable(this,"runningAnimatables",c)},t.prototype._execute=function(e){this._startPendingTasks(e),this.out._activateSignal(e)},t.prototype._onAnimationEnd=function(e,n){var i,o=(i=n._getExecutionVariable(this,"runningAnimatables"))!==null&&i!==void 0?i:[],a=o.indexOf(e);a!==-1&&o.splice(a,1),n._removePendingBlock(this),this.done._activateSignal(n)},t.prototype._cancelPendingTasks=function(e){for(var n,i=0,o=(n=e._getExecutionVariable(this,"runningAnimatables"))!==null&&n!==void 0?n:[];i<o.length;i++)o[i].stop();e._deleteExecutionVariable(this,"runningAnimatables")},t.prototype.getClassName=function(){return t.ClassName},t.prototype.serialize=function(e){e===void 0&&(e={}),r.prototype.serialize.call(this,e),e.config.targetPath=this.config.targetPath,e.config.animationPath=this.config.animationPath},t.ClassName="FGPlayAnimationBlock",t}(lS);(0,j.Y5)(yp.ClassName,yp);var SS=function(r){function t(e){var n=r.call(this,e)||this;return n.animationToStop=n.registerDataInput("animationToStop",at),n}return(0,A.C6)(t,r),t.prototype._execute=function(e){this.animationToStop.getValue(e).stop(),this.out._activateSignal(e)},t.prototype.getClassName=function(){return"FGStopAnimationBlock"},t}(vr);(0,j.Y5)("FGStopAnimationBlock",SS);var ES=function(r){function t(e){var n=r.call(this,e)||this;return n.animationToPause=n.registerDataInput("animationToPause",at),n}return(0,A.C6)(t,r),t.prototype._execute=function(e){this.animationToPause.getValue(e).pause(),this.out._activateSignal(e)},t.prototype.getClassName=function(){return"FGPauseAnimationBlock"},t}(vr);(0,j.Y5)("FGPauseAnimationBlock",ES);var xS=function(r){function t(e){var n=r.call(this,e)||this;return n.condition=n.registerDataInput("condition",ei),n.trueValue=n.registerDataInput("trueValue",at),n.falseValue=n.registerDataInput("falseValue",at),n.output=n.registerDataOutput("output",at),n}return(0,A.C6)(t,r),t.prototype._updateOutputs=function(e){this.output.setValue(this.condition.getValue(e)?this.trueValue.getValue(e):this.falseValue.getValue(e),e)},t.prototype.getClassName=function(){return"FGConditionalDataBlock"},t}(_o);(0,j.Y5)("FGConditionalDataBlock",xS);var bp=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n.output=n.registerDataOutput(e.variableName,at),n}return(0,A.C6)(t,r),t.prototype._updateOutputs=function(e){var n=this.config.variableName;e.hasVariable(n)&&this.output.setValue(e.getVariable(n),e)},t.prototype.getClassName=function(){return t.ClassName},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.config.variableName=this.config.variableName},t.ClassName="FGGetVariableBlock",t}(_o);(0,j.Y5)(bp.ClassName,bp);var PS=function(r){function t(e){var n=r.call(this,e)||this;return n.sourceSystem=n.registerDataInput("sourceSystem",at),n.destinationSystem=n.registerDataInput("destinationSystem",at),n.inputCoordinates=n.registerDataInput("inputCoordinates",Jr),n.outputCoordinates=n.registerDataOutput("outputCoordinates",Jr),n}return(0,A.C6)(t,r),t.prototype._updateOutputs=function(e){var n=this.sourceSystem.getValue(e),i=this.destinationSystem.getValue(e),o=this.inputCoordinates.getValue(e),a=n.getWorldMatrix(),s=i.getWorldMatrix(),l=_.AA.Matrix[0].copyFrom(s);l.invert();var c=_.AA.Matrix[1];l.multiplyToRef(a,c);var u=this.outputCoordinates.getValue(e);_.Pq.TransformCoordinatesToRef(o,c,u)},t.prototype.getClassName=function(){return"FGCoordinateTransformBlock"},t}(_o);(0,j.Y5)("FGCoordinateTransformBlock",PS);var AS=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n.output=n.registerDataOutput("output",sS(e.value)),n}return(0,A.C6)(t,r),t.prototype._updateOutputs=function(e){this.output.setValue(this.config.value,e)},t.prototype.getClassName=function(){return"FGConstantBlock"},t.prototype.serialize=function(e,n){e===void 0&&(e={}),n===void 0&&(n=R1),r.prototype.serialize.call(this,e),n("value",this.config.value,e.config)},t}(_o);(0,j.Y5)("FGConstantBlock",AS);var Tp=function(r){function t(e){var n=r.call(this,e)||this;return n.config=e,n.value=n.registerDataOutput("value",at),n.templateComponent=new _p(e.path,n),n}return(0,A.C6)(t,r),t.prototype._updateOutputs=function(e){var n=this.templateComponent.getAccessor(this.config.pathConverter,e),i=n.info.get(n.object);this.value.setValue(i,e)},t.prototype.getClassName=function(){return t.ClassName},t.prototype.serialize=function(e){e===void 0&&(e={}),r.prototype.serialize.call(this,e),e.config.path=this.config.path},t.ClassName="FGGetPropertyBlock",t}(_o);(0,j.Y5)(Tp.ClassName,Tp);var D1="cachedOperationValue",N1="cachedExecutionId",Sp=function(r){function t(e,n){var i=r.call(this,n)||this;return i.value=i.registerDataOutput("value",e),i}return(0,A.C6)(t,r),t.prototype._updateOutputs=function(e){var n=e._getExecutionVariable(this,N1),i=e._getExecutionVariable(this,D1);if(i!==void 0&&n===e.executionId)this.value.setValue(i,e);else{var o=this._doOperation(e);e._setExecutionVariable(this,D1,o),e._setExecutionVariable(this,N1,e.executionId),this.value.setValue(o,e)}},t}(_o),Wn=function(r){function t(e,n,i,o,a,s){var l=r.call(this,i,s)||this;return l._operation=o,l._className=a,l.a=l.registerDataInput("a",e),l.b=l.registerDataInput("b",n),l}return(0,A.C6)(t,r),t.prototype._doOperation=function(e){return this._operation(this.a.getValue(e),this.b.getValue(e))},t.prototype.getClassName=function(){return this._className},t}(Sp),on=function(r){function t(e,n,i,o,a){var s=r.call(this,n,a)||this;return s._operation=i,s._className=o,s.a=s.registerDataInput("a",e),s}return(0,A.C6)(t,r),t.prototype._doOperation=function(e){return this._operation(this.a.getValue(e))},t.prototype.getClassName=function(){return this._className},t}(Sp),Ts="FGLogic",L1="AndBlock",F1="OrBlock",w1="NotBlock",CS=function(r){function t(e){return r.call(this,ei,ei,ei,function(n,i){return n&&i},"".concat(Ts).concat(L1),e)||this}return(0,A.C6)(t,r),t}(Wn);(0,j.Y5)("".concat(Ts).concat(L1),CS);var RS=function(r){function t(e){return r.call(this,ei,ei,ei,function(n,i){return n||i},"".concat(Ts).concat(F1),e)||this}return(0,A.C6)(t,r),t}(Wn);(0,j.Y5)("".concat(Ts).concat(F1),RS);var IS=function(r){function t(e){return r.call(this,ei,ei,function(n){return!n},"".concat(Ts).concat(w1),e)||this}return(0,A.C6)(t,r),t}(on);(0,j.Y5)("".concat(Ts).concat(w1),IS);var pc=function(r){function t(e,n,i,o){var a=r.call(this,e,o)||this;return a._operation=n,a._className=i,a}return(0,A.C6)(t,r),t.prototype._doOperation=function(e){return this._operation()},t.prototype.getClassName=function(){return this._className},t}(Sp),MS=function(r){function t(e,n,i,o,a,s,l){var c=r.call(this,o,l)||this;return c._operation=a,c._className=s,c.a=c.registerDataInput("a",e),c.b=c.registerDataInput("b",n),c.c=c.registerDataInput("c",i),c}return(0,A.C6)(t,r),t.prototype._doOperation=function(e){return this._operation(this.a.getValue(e),this.b.getValue(e),this.c.getValue(e))},t.prototype.getClassName=function(){return this._className},t}(Sp);function di(r){return r.getClassName?r.getClassName():""}function _c(r,t){return r==="Vector2"&&t==="Vector2"||r==="Vector3"&&t==="Vector3"||r==="Vector4"&&t==="Vector4"}function mc(r,t){return r==="Matrix"&&t==="Matrix"}function gc(r,t){return r==="FlowGraphInteger"&&t==="FlowGraphInteger"}var Ep=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicAdd(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAdd=function(e,n){var i=di(e),o=di(n);return _c(i,o)||mc(i,o)||gc(i,o)?e.add(n):e+n},t.ClassName="FGAddBlock",t}(Wn);(0,j.Y5)(Ep.ClassName,Ep);var xp=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicAdd(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAdd=function(e,n){var i=di(e),o=di(n);return _c(i,o)||gc(i,o)?e.subtract(n):mc(i,o)?e.add(n.scale(-1)):e-n},t.ClassName="FGSubBlock",t}(Wn);(0,j.Y5)(xp.ClassName,xp);var Pp=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicMultiply(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicMultiply=function(e,n){var i=di(e),o=di(n);return _c(i,o)||gc(i,o)?e.multiply(n):mc(i,o)?_.uq.FromValues(e.m[0]*n.m[0],e.m[4]*n.m[4],e.m[8]*n.m[8],e.m[12]*n.m[12],e.m[1]*n.m[1],e.m[5]*n.m[5],e.m[9]*n.m[9],e.m[13]*n.m[13],e.m[2]*n.m[2],e.m[6]*n.m[6],e.m[10]*n.m[10],e.m[14]*n.m[14],e.m[3]*n.m[3],e.m[7]*n.m[7],e.m[11]*n.m[11],e.m[15]*n.m[15]):e*n},t.ClassName="FGMultiplyBlock",t}(Wn);(0,j.Y5)(Pp.ClassName,Pp);var Ap=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicDivide(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicDivide=function(e,n){var i=di(e),o=di(n);return _c(i,o)||gc(i,o)?e.divide(n):mc(i,o)?_.uq.FromValues(e.m[0]/n.m[0],e.m[4]/n.m[4],e.m[8]/n.m[8],e.m[12]/n.m[12],e.m[1]/n.m[1],e.m[5]/n.m[5],e.m[9]/n.m[9],e.m[13]/n.m[13],e.m[2]/n.m[2],e.m[6]/n.m[6],e.m[10]/n.m[10],e.m[14]/n.m[14],e.m[3]/n.m[3],e.m[7]/n.m[7],e.m[11]/n.m[11],e.m[15]/n.m[15]):e/n},t.ClassName="FGDivideBlock",t}(Wn);(0,j.Y5)(Ap.ClassName,Ap);var Cp=function(r){function t(e){return r.call(this,sn,function(){return Math.random()},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGRandomBlock",t}(pc);(0,j.Y5)(Cp.ClassName,Cp);var Rp=function(r){function t(e){var n=r.call(this,at,at,sn,function(i,o){return n._polymorphicDot(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicDot=function(e,n){switch(di(e)){case"Vector2":return _.I9.Dot(e,n);case"Vector3":return _.Pq.Dot(e,n);case"Vector4":return _.IU.Dot(e,n);default:throw new Error("Cannot get dot product of ".concat(e," and ").concat(n))}},t.ClassName="FGDotBlock",t}(Wn);(0,j.Y5)(Rp.ClassName,Rp);var Ip=function(r){function t(e){return r.call(this,sn,function(){return Math.E},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGEBlock",t}(pc);(0,j.Y5)(Ip.ClassName,Ip);var Mp=function(r){function t(e){return r.call(this,sn,function(){return Math.PI},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGPIBlock",t}(pc);(0,j.Y5)(Mp.ClassName,Mp);var Op=function(r){function t(e){return r.call(this,sn,function(){return Number.POSITIVE_INFINITY},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGInfBlock",t}(pc);(0,j.Y5)(Op.ClassName,Op);var Dp=function(r){function t(e){return r.call(this,sn,function(){return Number.NaN},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGNaNBlock",t}(pc);function Dn(r,t){switch(di(r)){case"FlowGraphInteger":return new gi(t(r.value));case"Vector2":return new _.I9(t(r.x),t(r.y));case"Vector3":return new _.Pq(t(r.x),t(r.y),t(r.z));case"Vector4":return new _.IU(t(r.x),t(r.y),t(r.z),t(r.w));case"Matrix":return _.uq.FromValues(t(r.m[0]),t(r.m[4]),t(r.m[8]),t(r.m[12]),t(r.m[1]),t(r.m[5]),t(r.m[9]),t(r.m[13]),t(r.m[2]),t(r.m[6]),t(r.m[10]),t(r.m[14]),t(r.m[3]),t(r.m[7]),t(r.m[11]),t(r.m[15]));default:return t(r)}}(0,j.Y5)(Dp.ClassName,Dp);var Np=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicAbs(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAbs=function(e){return Dn(e,Math.abs)},t.ClassName="FGAbsBlock",t}(on);(0,j.Y5)(Np.ClassName,Np);var Lp=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicSign(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicSign=function(e){return Dn(e,Math.sign)},t.ClassName="FGSignBlock",t}(on);(0,j.Y5)(Lp.ClassName,Lp);var Fp=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicTrunc(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicTrunc=function(e){return Dn(e,Math.trunc)},t.ClassName="FGTruncBlock",t}(on);(0,j.Y5)(Fp.ClassName,Fp);var wp=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicFloor(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicFloor=function(e){return Dn(e,Math.floor)},t.ClassName="FGFloorBlock",t}(on);(0,j.Y5)(wp.ClassName,wp);var Bp=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicCeiling(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicCeiling=function(e){return Dn(e,Math.ceil)},t.ClassName="FGCeilBlock",t}(on);(0,j.Y5)(Bp.ClassName,Bp);var Vp=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicFract(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicFract=function(e){return Dn(e,function(n){return n-Math.floor(n)})},t.ClassName="FGFractBlock",t}(on);(0,j.Y5)(Vp.ClassName,Vp);var Up=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicNeg(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicNeg=function(e){return Dn(e,function(n){return-n})},t.ClassName="FGNegBlock",t}(on);function vc(r,t,e){switch(di(r)){case"FlowGraphInteger":return new gi(e(r.value,t.value));case"Vector2":return new _.I9(e(r.x,t.x),e(r.y,t.y));case"Vector3":return new _.Pq(e(r.x,t.x),e(r.y,t.y),e(r.z,t.z));case"Vector4":return new _.IU(e(r.x,t.x),e(r.y,t.y),e(r.z,t.z),e(r.w,t.w));case"Matrix":return _.uq.FromValues(e(r.m[0],t.m[0]),e(r.m[4],t.m[4]),e(r.m[8],t.m[8]),e(r.m[12],t.m[12]),e(r.m[1],t.m[1]),e(r.m[5],t.m[5]),e(r.m[9],t.m[9]),e(r.m[13],t.m[13]),e(r.m[2],t.m[2]),e(r.m[6],t.m[6]),e(r.m[10],t.m[10]),e(r.m[14],t.m[14]),e(r.m[3],t.m[3]),e(r.m[7],t.m[7]),e(r.m[11],t.m[11]),e(r.m[15],t.m[15]));default:return e(r,t)}}(0,j.Y5)(Up.ClassName,Up);var Gp=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicRemainder(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicRemainder=function(e,n){return vc(e,n,function(i,o){return i%o})},t.ClassName="FGRemainderBlock",t}(Wn);(0,j.Y5)(Gp.ClassName,Gp);var kp=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicMin(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicMin=function(e,n){return vc(e,n,Math.min)},t.ClassName="FGMinBlock",t}(Wn);(0,j.Y5)(kp.ClassName,kp);var zp=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicMax(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicMax=function(e,n){return vc(e,n,Math.max)},t.ClassName="FGMaxBlock",t}(Wn);function aL(r,t,e){return Math.min(Math.max(r,Math.min(t,e)),Math.max(t,e))}function B1(r,t,e,n){switch(di(r)){case"FlowGraphInteger":return new gi(n(r.value,t.value,e.value));case"Vector2":return new _.I9(n(r.x,t.x,e.x),n(r.y,t.y,e.y));case"Vector3":return new _.Pq(n(r.x,t.x,e.x),n(r.y,t.y,e.y),n(r.z,t.z,e.z));case"Vector4":return new _.IU(n(r.x,t.x,e.x),n(r.y,t.y,e.y),n(r.z,t.z,e.z),n(r.w,t.w,e.w));case"Matrix":return _.uq.FromValues(n(r.m[0],t.m[0],e.m[0]),n(r.m[4],t.m[4],e.m[4]),n(r.m[8],t.m[8],e.m[8]),n(r.m[12],t.m[12],e.m[12]),n(r.m[1],t.m[1],e.m[1]),n(r.m[5],t.m[5],e.m[5]),n(r.m[9],t.m[9],e.m[9]),n(r.m[13],t.m[13],e.m[13]),n(r.m[2],t.m[2],e.m[2]),n(r.m[6],t.m[6],e.m[6]),n(r.m[10],t.m[10],e.m[10]),n(r.m[14],t.m[14],e.m[14]),n(r.m[3],t.m[3],e.m[3]),n(r.m[7],t.m[7],e.m[7]),n(r.m[11],t.m[11],e.m[11]),n(r.m[15],t.m[15],e.m[15]));default:return n(r,t,e)}}(0,j.Y5)(zp.ClassName,zp);var Wp=function(r){function t(e){var n=r.call(this,at,at,at,at,function(i,o,a){return n._polymorphicClamp(i,o,a)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicClamp=function(e,n,i){return B1(e,n,i,aL)},t.ClassName="FGClampBlock",t}(MS);function sL(r){return Math.min(Math.max(r,0),1)}(0,j.Y5)(Wp.ClassName,Wp);var Hp=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicSaturate(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicSaturate=function(e){return Dn(e,sL)},t.ClassName="FGSaturateBlock",t}(on);(0,j.Y5)(Hp.ClassName,Hp);var Yp=function(r){function t(e){var n=r.call(this,at,at,at,at,function(i,o,a){return n._polymorphicInterpolate(i,o,a)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._interpolate=function(e,n,i){return(1-i)*e+i*n},t.prototype._polymorphicInterpolate=function(e,n,i){return B1(e,n,i,this._interpolate)},t.ClassName="FGInterpolateBlock",t}(MS);(0,j.Y5)(Yp.ClassName,Yp);var Xp=function(r){function t(e){var n=r.call(this,at,at,ei,function(i,o){return n._polymorphicEq(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicEq=function(e,n){var i=di(e),o=di(n);return _c(i,o)||mc(i,o)||gc(i,o)?e.equals(n):e===n},t.ClassName="FGEqBlock",t}(Wn);function jp(r,t,e){var n=di(r);if(n===di(t)){if(n==="")return e(r,t);if(n==="FlowGraphInteger")return e(r.value,t.value);throw new Error("Cannot compare ".concat(r," and ").concat(t))}throw new Error("".concat(r," and ").concat(t," are of different types."))}(0,j.Y5)(Xp.ClassName,Xp);var qp=function(r){function t(e){var n=r.call(this,at,at,ei,function(i,o){return n._polymorphicLessThan(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicLessThan=function(e,n){return jp(e,n,function(i,o){return i<o})},t.ClassName="FGLessThanBlock",t}(Wn);(0,j.Y5)(qp.ClassName,qp);var V1=function(r){function t(e){var n=r.call(this,at,at,ei,function(i,o){return n._polymorphicLessThanOrEqual(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicLessThanOrEqual=function(e,n){return jp(e,n,function(i,o){return i<=o})},t.ClassName="FGLessThanOrEqualBlock",t}(Wn),Kp=function(r){function t(e){var n=r.call(this,at,at,ei,function(i,o){return n._polymorphicGreaterThan(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicGreaterThan=function(e,n){return jp(e,n,function(i,o){return i>o})},t.ClassName="FGGreaterThanBlock",t}(Wn);(0,j.Y5)(Kp.ClassName,Kp);var Zp=function(r){function t(e){var n=r.call(this,at,at,ei,function(i,o){return n._polymorphicGreaterThanOrEqual(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicGreaterThanOrEqual=function(e,n){return jp(e,n,function(i,o){return i>=o})},t.ClassName="FGGreaterThanOrEqualBlock",t}(Wn);(0,j.Y5)(Zp.ClassName,Zp);var Qp=function(r){function t(e){var n=r.call(this,at,ei,function(i){return n._polymorphicIsNan(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicIsNan=function(e){var n=di(e);if(n==="")return isNaN(e);if(n==="FlowGraphInteger")return isNaN(e.value);throw new Error("Cannot get NaN of ".concat(e))},t.ClassName="FGIsNanBlock",t}(on);(0,j.Y5)(Qp.ClassName,Qp);var U1=function(r){function t(e){var n=r.call(this,at,ei,function(i){return n._polymorphicIsInf(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicIsInf=function(e){var n=di(e);if(n==="")return!isFinite(e);if(n==="FlowGraphInteger")return!isFinite(e.value);throw new Error("Cannot get isInf of ".concat(e))},t.ClassName="FGIsInfBlock",t}(on),Jp=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicDegToRad(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._degToRad=function(e){return e*Math.PI/180},t.prototype._polymorphicDegToRad=function(e){return Dn(e,this._degToRad)},t.ClassName="FGDegToRadBlock",t}(on);(0,j.Y5)(Jp.ClassName,Jp);var $p=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicRadToDeg(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._radToDeg=function(e){return 180*e/Math.PI},t.prototype._polymorphicRadToDeg=function(e){return Dn(e,this._radToDeg)},t.ClassName="FGRadToDegBlock",t}(on);(0,j.Y5)($p.ClassName,$p);var e_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicSin(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicSin=function(e){return Dn(e,Math.sin)},t.ClassName="FGSinBlock",t}(on);(0,j.Y5)(e_.ClassName,e_);var t_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicCos(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicCos=function(e){return Dn(e,Math.cos)},t.ClassName="FGCosBlock",t}(on);(0,j.Y5)(t_.ClassName,t_);var n_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicTan(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicTan=function(e){return Dn(e,Math.tan)},t.ClassName="FGTanBlock",t}(on);(0,j.Y5)(n_.ClassName,n_);var i_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicAsin(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAsin=function(e){return Dn(e,Math.asin)},t.ClassName="FGAsinBlock",t}(on);(0,j.Y5)(i_.ClassName,i_);var r_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicAcos(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAcos=function(e){return Dn(e,Math.acos)},t.ClassName="FGAcosBlock",t}(on);(0,j.Y5)(r_.ClassName,r_);var o_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicAtan(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAtan=function(e){return Dn(e,Math.atan)},t.ClassName="FGAtanBlock",t}(on);(0,j.Y5)(o_.ClassName,o_);var a_=function(r){function t(e){var n=r.call(this,at,at,at,function(i,o){return n._polymorphicAtan2(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAtan2=function(e,n){return vc(e,n,Math.atan2)},t.ClassName="FGAtan2Block",t}(Wn);(0,j.Y5)(a_.ClassName,a_);var s_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicSinh(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicSinh=function(e){return Dn(e,Math.sinh)},t.ClassName="FGSinhBlock",t}(on);(0,j.Y5)(s_.ClassName,s_);var l_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicCosh(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicCosh=function(e){return Dn(e,Math.cosh)},t.ClassName="FGCoshBlock",t}(on);(0,j.Y5)(l_.ClassName,l_);var c_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicTanh(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicTanh=function(e){return Dn(e,Math.tanh)},t.ClassName="FGTanhBlock",t}(on);(0,j.Y5)(c_.ClassName,c_);var u_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicAsinh(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAsinh=function(e){return Dn(e,Math.asinh)},t.ClassName="FGAsinhBlock",t}(on);(0,j.Y5)(u_.ClassName,u_);var d_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicAcosh(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAcosh=function(e){return Dn(e,Math.acosh)},t.ClassName="FGAcoshBlock",t}(on);(0,j.Y5)(d_.ClassName,d_);var h_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicAtanh(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicAtanh=function(e){return Dn(e,Math.atanh)},t.ClassName="FGAtanhBlock",t}(on);(0,j.Y5)(h_.ClassName,h_);var f_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicExp(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicExp=function(e){return Dn(e,Math.exp)},t.ClassName="FGExpBlock",t}(on);(0,j.Y5)(f_.ClassName,f_);var p_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicLog(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicLog=function(e){return Dn(e,Math.log)},t.ClassName="FGLogBlock",t}(on);(0,j.Y5)(p_.ClassName,p_);var __=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicLog2(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicLog2=function(e){return Dn(e,Math.log2)},t.ClassName="FGLog2Block",t}(on);(0,j.Y5)(__.ClassName,__);var m_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicLog10(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicLog10=function(e){return Dn(e,Math.log10)},t.ClassName="FGLog10Block",t}(on);(0,j.Y5)(m_.ClassName,m_);var g_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicSqrt(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicSqrt=function(e){return Dn(e,Math.sqrt)},t.ClassName="FGSqrtBlock",t}(on);(0,j.Y5)(g_.ClassName,g_);var v_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicCubeRoot(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicCubeRoot=function(e){return Dn(e,Math.cbrt)},t.ClassName="FGCubeRootBlock",t}(on);(0,j.Y5)(v_.ClassName,v_);var y_=function(r){function t(e){var n=r.call(this,at,sn,sn,function(i,o){return n._polymorphicPow(i,o)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicPow=function(e,n){return vc(e,n,Math.pow)},t.ClassName="FGPowBlock",t}(Wn);(0,j.Y5)(y_.ClassName,y_);var b_=function(r){function t(e){var n=r.call(this,at,sn,function(i){return n._polymorphicLength(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicLength=function(e){switch(di(e)){case"Vector2":case"Vector3":case"Vector4":return e.length();default:throw new Error("Cannot compute length of value ".concat(e))}},t.ClassName="FGLengthBlock",t}(on);(0,j.Y5)(b_.ClassName,b_);var T_=function(r){function t(e){var n=r.call(this,at,at,function(i){return n._polymorphicNormalize(i)},t.ClassName,e)||this;return n}return(0,A.C6)(t,r),t.prototype._polymorphicNormalize=function(e){switch(di(e)){case"Vector2":case"Vector3":case"Vector4":return e.normalize();default:throw new Error("Cannot normalize value ".concat(e))}},t.ClassName="FGNormalizeBlock",t}(on);(0,j.Y5)(T_.ClassName,T_);var S_=function(r){function t(e){return r.call(this,Jr,Jr,Jr,function(n,i){return _.Pq.Cross(n,i)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGCrossBlock",t}(Wn);(0,j.Y5)(S_.ClassName,S_);var E_=function(r){function t(e){return r.call(this,uc,sn,uc,function(n,i){return _.I9.Transform(n,_.uq.RotationZ(i))},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGRotate2DBlock",t}(Wn);(0,j.Y5)(E_.ClassName,E_);var x_=function(r){function t(e){return r.call(this,Jr,Jr,sn,Jr,function(n,i,o){return _.Pq.TransformCoordinates(n,_.uq.RotationAxis(i,o))},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGRotate3DBlock",t}(MS);(0,j.Y5)(x_.ClassName,x_);var P_=function(r){function t(e){return r.call(this,po,po,function(n){return _.uq.Transpose(n)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGTransposeBlock",t}(on);(0,j.Y5)(P_.ClassName,P_);var A_=function(r){function t(e){return r.call(this,po,sn,function(n){return n.determinant()},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGDeterminantBlock",t}(on);(0,j.Y5)(A_.ClassName,A_);var C_=function(r){function t(e){return r.call(this,po,po,function(n){return _.uq.Invert(n)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGInvertMatrixBlock",t}(on);(0,j.Y5)(C_.ClassName,C_);var R_=function(r){function t(e){return r.call(this,po,po,po,function(n,i){return i.multiply(n)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGMatMulBlock",t}(Wn);(0,j.Y5)(R_.ClassName,R_);var I_=function(r){function t(e){return r.call(this,An,An,function(n){return new gi(~n.value)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGBitwiseNotBlock",t}(on);(0,j.Y5)(I_.ClassName,I_);var M_=function(r){function t(e){return r.call(this,An,An,An,function(n,i){return new gi(n.value&i.value)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGBitwiseAndBlock",t}(Wn);(0,j.Y5)(M_.ClassName,M_);var O_=function(r){function t(e){return r.call(this,An,An,An,function(n,i){return new gi(n.value|i.value)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGBitwiseOrBlock",t}(Wn);(0,j.Y5)(O_.ClassName,O_);var D_=function(r){function t(e){return r.call(this,An,An,An,function(n,i){return new gi(n.value^i.value)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGBitwiseXorBlock",t}(Wn);(0,j.Y5)(D_.ClassName,D_);var N_=function(r){function t(e){return r.call(this,An,An,An,function(n,i){return new gi(n.value<<i.value)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGBitwiseLeftShiftBlock",t}(Wn);(0,j.Y5)(N_.ClassName,N_);var L_=function(r){function t(e){return r.call(this,An,An,An,function(n,i){return new gi(n.value>>i.value)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGBitwiseRightShiftBlock",t}(Wn);(0,j.Y5)(L_.ClassName,L_);var F_=function(r){function t(e){return r.call(this,An,An,function(n){return new gi(Math.clz32(n.value))},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGCountLeadingZerosBlock",t}(on);(0,j.Y5)(F_.ClassName,F_);var w_=function(r){function t(e){return r.call(this,An,An,function(n){return new gi(n.value?31-Math.clz32(n.value&-n.value):32)},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGCountTrailingZerosBlock",t}(on);(0,j.Y5)(w_.ClassName,w_);var B_=function(r){function t(e){return r.call(this,An,An,function(n){return new gi(function(i){for(var o=0;i;)o+=1&i,i>>=1;return o}(n.value))},t.ClassName,e)||this}return(0,A.C6)(t,r),t.ClassName="FGCountOneBitsBlock",t}(on);(0,j.Y5)(B_.ClassName,B_);var OS=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype._preparePendingTasks=function(e){var n=this;if(!e._getExecutionVariable(this,"sceneReadyObserver")){var i=e.configuration.scene.onReadyObservable.add(function(){n._execute(e)});e._setExecutionVariable(this,"sceneReadyObserver",i)}},t.prototype._cancelPendingTasks=function(e){var n=e._getExecutionVariable(this,"sceneReadyObserver");e.configuration.scene.onReadyObservable.remove(n),e._deleteExecutionVariable(this,"sceneReadyObserver")},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGSceneReadyEventBlock",t}(ga);(0,j.Y5)("FGSceneReadyEventBlock",OS);var V_=function(r){function t(e){var n=r.call(this,e)||this;n.config=e;for(var i=0;i<n.config.eventData.length;i++){var o=n.config.eventData[i];n.registerDataOutput(o,at)}return n}return(0,A.C6)(t,r),t.prototype._preparePendingTasks=function(e){var n=this,i=e.configuration.coordinator.getCustomEventObservable(this.config.eventId);this._eventObserver=i.add(function(o){for(var a=0;a<o.length;a++)n.dataOutputs[a].setValue(o[a],e);n._execute(e)})},t.prototype._cancelPendingTasks=function(e){var n=e.configuration.coordinator.getCustomEventObservable(this.config.eventId);n?n.remove(this._eventObserver):ze.S0.Warn("FlowGraphReceiveCustomEventBlock: Missing observable for event ".concat(this.config.eventId))},t.prototype.getClassName=function(){return t.ClassName},t.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.eventId=this.config.eventId,e.eventData=this.config.eventData},t.ClassName="FGReceiveCustomEventBlock",t}(ga);(0,j.Y5)(V_.ClassName,V_);var U_=function(r){function t(){return r!==null&&r.apply(this,arguments)||this}return(0,A.C6)(t,r),t.prototype._preparePendingTasks=function(e){var n=this;if(!e._getExecutionVariable(this,"sceneBeforeRender")){var i=e.configuration.scene.onBeforeRenderObservable.add(function(){n._execute(e)});e._setExecutionVariable(this,"sceneBeforeRender",i)}},t.prototype._cancelPendingTasks=function(e){var n=e._getExecutionVariable(this,"sceneBeforeRender");e.configuration.scene.onBeforeRenderObservable.remove(n),e._deleteExecutionVariable(this,"sceneBeforeRender")},t.prototype.getClassName=function(){return t.ClassName},t.ClassName="FGSceneTickEventBlock",t}(ga);(0,j.Y5)(U_.ClassName,U_);var G_=L.g!==void 0?L.g:typeof window<"u"?window:void 0;if(G_!==void 0){G_.BABYLON=G_.BABYLON||{};var va=G_.BABYLON;if(!va.Debug)for(var ya in va.Debug=va.Debug||{},$i)va.Debug[ya]||(va.Debug[ya]=$i[ya]);for(var ya in dr)va[ya]||(va[ya]=dr[ya])}var lL={AxesViewer:ia,BoneAxesViewer:Au,PhysicsViewer:Wu,SkeletonViewer:Hu};const cL=wr;return Hn.default})())}(DS)),DS.exports}var ur=z1(),W1={exports:{}};(function(vi,mn){(function(Zn,L){vi.exports=L(z1())})(typeof self<"u"?self:typeof Es<"u"?Es:Es,Cn=>(()=>{var Zn={"../../../dev/loaders/src/OBJ/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{MTLFileLoader:()=>_.MTLFileLoader,OBJFileLoader:()=>j.OBJFileLoader,SolidParser:()=>z.SolidParser});var _=K("../../../dev/loaders/src/OBJ/mtlFileLoader.ts");K("../../../dev/loaders/src/OBJ/objLoadingOptions.ts");var z=K("../../../dev/loaders/src/OBJ/solidParser.ts"),j=K("../../../dev/loaders/src/OBJ/objFileLoader.ts")},"../../../dev/loaders/src/OBJ/mtlFileLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{MTLFileLoader:()=>z});var _=K("babylonjs/Misc/tools"),z=function(){function j(){this.materials=[]}return j.prototype.parseMTL=function(me,Se,A,ne){if(!(Se instanceof ArrayBuffer)){for(var ae=Se.split(`
|
||
`),H=/\s+/,W,O=null,P=0;P<ae.length;P++){var Z=ae[P].trim();if(!(Z.length===0||Z.charAt(0)==="#")){var re=Z.indexOf(" "),oe=re>=0?Z.substring(0,re):Z;oe=oe.toLowerCase();var he=re>=0?Z.substring(re+1).trim():"";if(oe==="newmtl")O&&this.materials.push(O),me._blockEntityCollection=!!ne,O=new _.StandardMaterial(he,me),O._parentContainer=ne,me._blockEntityCollection=!1;else if(oe==="kd"&&O)W=he.split(H,3).map(parseFloat),O.diffuseColor=_.Color3.FromArray(W);else if(oe==="ka"&&O)W=he.split(H,3).map(parseFloat),O.ambientColor=_.Color3.FromArray(W);else if(oe==="ks"&&O)W=he.split(H,3).map(parseFloat),O.specularColor=_.Color3.FromArray(W);else if(oe==="ke"&&O)W=he.split(H,3).map(parseFloat),O.emissiveColor=_.Color3.FromArray(W);else if(oe==="ns"&&O)O.specularPower=parseFloat(he);else if(oe==="d"&&O)O.alpha=parseFloat(he);else if(oe==="map_ka"&&O)O.ambientTexture=j._GetTexture(A,he,me);else if(oe==="map_kd"&&O)O.diffuseTexture=j._GetTexture(A,he,me);else if(oe==="map_ks"&&O)O.specularTexture=j._GetTexture(A,he,me);else if(oe!=="map_ns")if(oe==="map_bump"&&O){var Ee=he.split(H),Oe=Ee.indexOf("-bm"),Pe=null;Oe>=0&&(Pe=Ee[Oe+1],Ee.splice(Oe,2)),O.bumpTexture=j._GetTexture(A,Ee.join(" "),me),O.bumpTexture&&Pe!==null&&(O.bumpTexture.level=parseFloat(Pe))}else oe==="map_d"&&O&&(O.opacityTexture=j._GetTexture(A,he,me))}}O&&this.materials.push(O)}},j._GetTexture=function(me,Se,A){if(!Se)return null;var ne=me;if(me==="file:"){var ae=Se.lastIndexOf("\\");ae===-1&&(ae=Se.lastIndexOf("/")),ae>-1?ne+=Se.substring(ae+1):ne+=Se}else ne+=Se;return new _.Texture(ne,A,!1,j.INVERT_TEXTURE_Y)},j.INVERT_TEXTURE_Y=!0,j}()},"../../../dev/loaders/src/OBJ/objFileLoader.metadata.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{OBJFileLoaderMetadata:()=>_});var _={name:"obj",extensions:".obj"}},"../../../dev/loaders/src/OBJ/objFileLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{OBJFileLoader:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/OBJ/objFileLoader.metadata.ts"),j=K("../../../dev/loaders/src/OBJ/mtlFileLoader.ts"),me=K("../../../dev/loaders/src/OBJ/solidParser.ts"),Se=function(){function A(ne){this.name=z.OBJFileLoaderMetadata.name,this.extensions=z.OBJFileLoaderMetadata.extensions,this._assetContainer=null,this._loadingOptions=ne||A._DefaultLoadingOptions}return Object.defineProperty(A,"INVERT_TEXTURE_Y",{get:function(){return j.MTLFileLoader.INVERT_TEXTURE_Y},set:function(ne){j.MTLFileLoader.INVERT_TEXTURE_Y=ne},enumerable:!1,configurable:!0}),Object.defineProperty(A,"_DefaultLoadingOptions",{get:function(){return{computeNormals:A.COMPUTE_NORMALS,optimizeNormals:A.OPTIMIZE_NORMALS,importVertexColors:A.IMPORT_VERTEX_COLORS,invertY:A.INVERT_Y,invertTextureY:A.INVERT_TEXTURE_Y,UVScaling:A.UV_SCALING,materialLoadingFailsSilently:A.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:A.OPTIMIZE_WITH_UV,skipMaterials:A.SKIP_MATERIALS,useLegacyBehavior:A.USE_LEGACY_BEHAVIOR}},enumerable:!1,configurable:!0}),A.prototype._loadMTL=function(ne,ae,H,W){var O=ae+ne;_.Tools.LoadFile(O,H,void 0,void 0,!1,function(P,Z){W(O,Z)})},A.prototype.createPlugin=function(){return new A(A._DefaultLoadingOptions)},A.prototype.canDirectLoad=function(){return!1},A.prototype.importMeshAsync=function(ne,ae,H,W){return this._parseSolid(ne,ae,H,W).then(function(O){return{meshes:O,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}})},A.prototype.loadAsync=function(ne,ae,H){return this.importMeshAsync(null,ne,ae,H).then(function(){})},A.prototype.loadAssetContainerAsync=function(ne,ae,H){var W=this,O=new _.AssetContainer(ne);return this._assetContainer=O,this.importMeshAsync(null,ne,ae,H).then(function(P){return P.meshes.forEach(function(Z){return O.meshes.push(Z)}),P.meshes.forEach(function(Z){var re=Z.material;if(re&&O.materials.indexOf(re)==-1){O.materials.push(re);var oe=re.getActiveTextures();oe.forEach(function(he){O.textures.indexOf(he)==-1&&O.textures.push(he)})}}),W._assetContainer=null,O}).catch(function(P){throw W._assetContainer=null,P})},A.prototype._parseSolid=function(ne,ae,H,W){var O=this,P="",Z=new j.MTLFileLoader,re=[],oe=[];H=H.replace(/#.*$/gm,"").trim();var he=new me.SolidParser(re,oe,this._loadingOptions);he.parse(ne,H,ae,this._assetContainer,function(Oe){P=Oe});var Ee=[];return P!==""&&!this._loadingOptions.skipMaterials&&Ee.push(new Promise(function(Oe,Pe){O._loadMTL(P,W,function(Ae){try{Z.parseMTL(ae,Ae,W,O._assetContainer);for(var Ue=0;Ue<Z.materials.length;Ue++){for(var je=0,Ve=[],ot=void 0;(ot=re.indexOf(Z.materials[Ue].name,je))>-1;)Ve.push(ot),je=ot+1;if(ot===-1&&Ve.length===0)Z.materials[Ue].dispose();else for(var it=0;it<Ve.length;it++){var ft=oe[Ve[it]],xt=Z.materials[Ue];ft.material=xt,ft.getTotalIndices()||(xt.pointsCloud=!0)}}Oe()}catch(qe){_.Tools.Warn("Error processing MTL file: '".concat(P,"'")),O._loadingOptions.materialLoadingFailsSilently?Oe():Pe(qe)}},function(Ae,Ue){_.Tools.Warn("Error downloading MTL file: '".concat(P,"'")),O._loadingOptions.materialLoadingFailsSilently?Oe():Pe(Ue)})})),Promise.all(Ee).then(function(){var Oe=function(Pe){var Ae,Ue;return!!((Ue=(Ae=Pe._internalMetadata)===null||Ae===void 0?void 0:Ae._isLine)!==null&&Ue!==void 0&&Ue)};return oe.forEach(function(Pe){var Ae,Ue;if(Oe(Pe)){var je=(Ae=Pe.material)!==null&&Ae!==void 0?Ae:new _.StandardMaterial(Pe.name+"_line",ae),Ve=je.getBindedMeshes().filter(function(ot){return!Oe(ot)}).length>0;Ve&&(je=(Ue=je.clone(je.name+"_line"))!==null&&Ue!==void 0?Ue:je),je.wireframe=!0,Pe.material=je,Pe._internalMetadata&&(Pe._internalMetadata._isLine=void 0)}}),oe})},A.OPTIMIZE_WITH_UV=!0,A.INVERT_Y=!1,A.IMPORT_VERTEX_COLORS=!1,A.COMPUTE_NORMALS=!1,A.OPTIMIZE_NORMALS=!1,A.UV_SCALING=new _.Vector2(1,1),A.SKIP_MATERIALS=!1,A.MATERIAL_LOADING_FAILS_SILENTLY=!0,A.USE_LEGACY_BEHAVIOR=!1,A}();(0,_.registerSceneLoaderPlugin)(new Se)},"../../../dev/loaders/src/OBJ/objLoadingOptions.ts":(nt,Ne,K)=>{K.r(Ne)},"../../../dev/loaders/src/OBJ/solidParser.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{SolidParser:()=>z});var _=K("babylonjs/Misc/tools"),z=function(){function j(me,Se,A){this._positions=[],this._normals=[],this._uvs=[],this._colors=[],this._meshesFromObj=[],this._indicesForBabylon=[],this._wrappedPositionForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._wrappedNormalsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0,this._hasMeshes=!1,this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[],this._triangles=[],this._materialNameFromObj="",this._objMeshName="",this._increment=1,this._isFirstMaterial=!0,this._grayColor=new _.Color4(.5,.5,.5,1),this._hasLineData=!1,this._materialToUse=me,this._babylonMeshesArray=Se,this._loadingOptions=A}return j.prototype._isInArray=function(me,Se){me[Se[0]]||(me[Se[0]]={normals:[],idx:[]});var A=me[Se[0]].normals.indexOf(Se[1]);return A===-1?-1:me[Se[0]].idx[A]},j.prototype._isInArrayUV=function(me,Se){me[Se[0]]||(me[Se[0]]={normals:[],idx:[],uv:[]});var A=me[Se[0]].normals.indexOf(Se[1]);return A!=1&&Se[2]===me[Se[0]].uv[A]?me[Se[0]].idx[A]:-1},j.prototype._setData=function(me,Se,A,ne,ae,H,W){var O;this._loadingOptions.optimizeWithUV?O=this._isInArrayUV(this._tuplePosNorm,[me,A,Se]):O=this._isInArray(this._tuplePosNorm,[me,A]),O===-1?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(ne),ae=ae??new _.Vector2(0,0),this._wrappedUvsForBabylon.push(ae),this._wrappedNormalsForBabylon.push(H),W!==void 0&&this._wrappedColorsForBabylon.push(W),this._tuplePosNorm[me].normals.push(A),this._tuplePosNorm[me].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[me].uv.push(Se)):this._indicesForBabylon.push(O)},j.prototype._unwrapData=function(){for(var me=0;me<this._wrappedPositionForBabylon.length;me++)this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[me].x*this._handednessSign,this._wrappedPositionForBabylon[me].y,this._wrappedPositionForBabylon[me].z),this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[me].x*this._handednessSign,this._wrappedNormalsForBabylon[me].y,this._wrappedNormalsForBabylon[me].z),this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[me].x,this._wrappedUvsForBabylon[me].y),this._loadingOptions.importVertexColors&&this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[me].r,this._wrappedColorsForBabylon[me].g,this._wrappedColorsForBabylon[me].b,this._wrappedColorsForBabylon[me].a);this._wrappedPositionForBabylon.length=0,this._wrappedNormalsForBabylon.length=0,this._wrappedUvsForBabylon.length=0,this._wrappedColorsForBabylon.length=0,this._tuplePosNorm.length=0,this._curPositionInIndices=0},j.prototype._getTriangles=function(me,Se){for(var A=Se;A<me.length-1;A++)this._pushTriangle(me,A)},j.prototype._setDataForCurrentFaceWithPattern1=function(me,Se){this._getTriangles(me,Se);for(var A=0;A<this._triangles.length;A++){var ne=parseInt(this._triangles[A])-1;this._setData(ne,0,0,this._positions[ne],_.Vector2.Zero(),_.Vector3.Up(),this._loadingOptions.importVertexColors?this._colors[ne]:void 0)}this._triangles.length=0},j.prototype._setDataForCurrentFaceWithPattern2=function(me,Se){var A;this._getTriangles(me,Se);for(var ne=0;ne<this._triangles.length;ne++){var ae=this._triangles[ne].split("/"),H=parseInt(ae[0])-1,W=parseInt(ae[1])-1;this._setData(H,W,0,this._positions[H],(A=this._uvs[W])!==null&&A!==void 0?A:_.Vector2.Zero(),_.Vector3.Up(),this._loadingOptions.importVertexColors?this._colors[H]:void 0)}this._triangles.length=0},j.prototype._setDataForCurrentFaceWithPattern3=function(me,Se){var A,ne;this._getTriangles(me,Se);for(var ae=0;ae<this._triangles.length;ae++){var H=this._triangles[ae].split("/"),W=parseInt(H[0])-1,O=parseInt(H[1])-1,P=parseInt(H[2])-1;this._setData(W,O,P,this._positions[W],(A=this._uvs[O])!==null&&A!==void 0?A:_.Vector2.Zero(),(ne=this._normals[P])!==null&&ne!==void 0?ne:_.Vector3.Up())}this._triangles.length=0},j.prototype._setDataForCurrentFaceWithPattern4=function(me,Se){this._getTriangles(me,Se);for(var A=0;A<this._triangles.length;A++){var ne=this._triangles[A].split("//"),ae=parseInt(ne[0])-1,H=parseInt(ne[1])-1;this._setData(ae,1,H,this._positions[ae],_.Vector2.Zero(),this._normals[H],this._loadingOptions.importVertexColors?this._colors[ae]:void 0)}this._triangles.length=0},j.prototype._setDataForCurrentFaceWithPattern5=function(me,Se){this._getTriangles(me,Se);for(var A=0;A<this._triangles.length;A++){var ne=this._triangles[A].split("/"),ae=this._positions.length+parseInt(ne[0]),H=this._uvs.length+parseInt(ne[1]),W=this._normals.length+parseInt(ne[2]);this._setData(ae,H,W,this._positions[ae],this._uvs[H],this._normals[W],this._loadingOptions.importVertexColors?this._colors[ae]:void 0)}this._triangles.length=0},j.prototype._addPreviousObjMesh=function(){this._meshesFromObj.length>0&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._unwrapData(),this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._handledMesh.indices=this._indicesForBabylon.slice(),this._handledMesh.positions=this._unwrappedPositionsForBabylon.slice(),this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice(),this._handledMesh.uvs=this._unwrappedUVForBabylon.slice(),this._handledMesh.hasLines=this._hasLineData,this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._indicesForBabylon.length=0,this._unwrappedPositionsForBabylon.length=0,this._unwrappedColorsForBabylon.length=0,this._unwrappedNormalsForBabylon.length=0,this._unwrappedUVForBabylon.length=0,this._hasLineData=!1)},j.prototype._optimizeNormals=function(me){var Se=me.getVerticesData(_.VertexBuffer.PositionKind),A=me.getVerticesData(_.VertexBuffer.NormalKind),ne={};if(!(!Se||!A)){for(var ae=0;ae<Se.length/3;ae++){var H=Se[ae*3+0],W=Se[ae*3+1],O=Se[ae*3+2],P=H+"_"+W+"_"+O,Z=ne[P];Z||(Z=[],ne[P]=Z),Z.push(ae)}var re=new _.Vector3;for(var P in ne){var Z=ne[P];if(!(Z.length<2)){for(var oe=Z[0],ae=1;ae<Z.length;++ae){var he=Z[ae];A[oe*3+0]+=A[he*3+0],A[oe*3+1]+=A[he*3+1],A[oe*3+2]+=A[he*3+2]}re.copyFromFloats(A[oe*3+0],A[oe*3+1],A[oe*3+2]),re.normalize();for(var ae=0;ae<Z.length;++ae){var he=Z[ae];A[he*3+0]=re.x,A[he*3+1]=re.y,A[he*3+2]=re.z}}}me.setVerticesData(_.VertexBuffer.NormalKind,A)}},j._IsLineElement=function(me){return me.startsWith("l")},j._IsObjectElement=function(me){return me.startsWith("o")},j._IsGroupElement=function(me){return me.startsWith("g")},j.prototype.parse=function(me,Se,A,ne,ae){var H=this,W,O;this._loadingOptions.useLegacyBehavior?(this._pushTriangle=function(Fe,Le){return H._triangles.push(Fe[0],Fe[Le],Fe[Le+1])},this._handednessSign=1):A.useRightHandedSystem?(this._pushTriangle=function(Fe,Le){return H._triangles.push(Fe[0],Fe[Le+1],Fe[Le])},this._handednessSign=1):(this._pushTriangle=function(Fe,Le){return H._triangles.push(Fe[0],Fe[Le],Fe[Le+1])},this._handednessSign=-1);var P=Se.split(`
|
||
`),Z=[],re=[];Z.push(re);for(var oe=0;oe<P.length;oe++){var he=P[oe].trim().replace(/\s\s/g," ");if(!(he.length===0||he.charAt(0)==="#"))if((j._IsGroupElement(he)||j._IsObjectElement(he))&&(re=[],Z.push(re)),j._IsLineElement(he))for(var Ee=he.split(" "),Oe=1;Oe<Ee.length-1;Oe++)re.push("l ".concat(Ee[Oe]," ").concat(Ee[Oe+1]));else re.push(he)}for(var Pe=Z.flat(),oe=0;oe<Pe.length;oe++){var he=Pe[oe].trim().replace(/\s\s/g," "),Ae=void 0;if(!(he.length===0||he.charAt(0)==="#"))if(j.VertexPattern.test(he)){if(Ae=he.match(/[^ ]+/g),this._positions.push(new _.Vector3(parseFloat(Ae[1]),parseFloat(Ae[2]),parseFloat(Ae[3]))),this._loadingOptions.importVertexColors)if(Ae.length>=7){var Ue=parseFloat(Ae[4]),je=parseFloat(Ae[5]),Ve=parseFloat(Ae[6]);this._colors.push(new _.Color4(Ue>1?Ue/255:Ue,je>1?je/255:je,Ve>1?Ve/255:Ve,Ae.length===7||Ae[7]===void 0?1:parseFloat(Ae[7])))}else this._colors.push(this._grayColor)}else if((Ae=j.NormalPattern.exec(he))!==null)this._normals.push(new _.Vector3(parseFloat(Ae[1]),parseFloat(Ae[2]),parseFloat(Ae[3])));else if((Ae=j.UVPattern.exec(he))!==null)this._uvs.push(new _.Vector2(parseFloat(Ae[1])*this._loadingOptions.UVScaling.x,parseFloat(Ae[2])*this._loadingOptions.UVScaling.y));else if((Ae=j.FacePattern3.exec(he))!==null)this._setDataForCurrentFaceWithPattern3(Ae[1].trim().split(" "),1);else if((Ae=j.FacePattern4.exec(he))!==null)this._setDataForCurrentFaceWithPattern4(Ae[1].trim().split(" "),1);else if((Ae=j.FacePattern5.exec(he))!==null)this._setDataForCurrentFaceWithPattern5(Ae[1].trim().split(" "),1);else if((Ae=j.FacePattern2.exec(he))!==null)this._setDataForCurrentFaceWithPattern2(Ae[1].trim().split(" "),1);else if((Ae=j.FacePattern1.exec(he))!==null)this._setDataForCurrentFaceWithPattern1(Ae[1].trim().split(" "),1);else if((Ae=j.LinePattern1.exec(he))!==null)this._setDataForCurrentFaceWithPattern1(Ae[1].trim().split(" "),0),this._hasLineData=!0;else if((Ae=j.LinePattern2.exec(he))!==null)this._setDataForCurrentFaceWithPattern2(Ae[1].trim().split(" "),0),this._hasLineData=!0;else if((Ae=j.LinePattern3.exec(he))!==null)this._setDataForCurrentFaceWithPattern3(Ae[1].trim().split(" "),0),this._hasLineData=!0;else if(j.GroupDescriptor.test(he)||j.ObjectDescriptor.test(he)){var ot={name:he.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:j.ObjectDescriptor.test(he)};this._addPreviousObjMesh(),this._meshesFromObj.push(ot),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else if(j.UseMtlDescriptor.test(he)){if(this._materialNameFromObj=he.substring(7).trim(),!this._isFirstMaterial||!this._hasMeshes){this._addPreviousObjMesh();var ot={name:(this._objMeshName||"mesh")+"_mm"+this._increment.toString(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:!1};this._increment++,this._meshesFromObj.push(ot),this._hasMeshes=!0}this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)}else j.MtlLibGroupDescriptor.test(he)?ae(he.substring(7).trim()):j.SmoothDescriptor.test(he)||_.Logger.Log("Unhandled expression at line : "+he)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._handledMesh.normals=this._unwrappedNormalsForBabylon,this._handledMesh.uvs=this._unwrappedUVForBabylon,this._handledMesh.hasLines=this._hasLineData,this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon)),!this._hasMeshes){var it=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(var ft=0,xt=this._positions;ft<xt.length;ft++){var qe=xt[ft];this._unwrappedPositionsForBabylon.push(qe.x,qe.y,qe.z)}if(this._normals.length)for(var kt=0,V=this._normals;kt<V.length;kt++){var gt=V[kt];this._unwrappedNormalsForBabylon.push(gt.x,gt.y,gt.z)}if(this._uvs.length)for(var tt=0,Jt=this._uvs;tt<Jt.length;tt++){var At=Jt[tt];this._unwrappedUVForBabylon.push(At.x,At.y)}if(this._colors.length)for(var gn=0,We=this._colors;gn<We.length;gn++){var Xe=We[gn];this._unwrappedColorsForBabylon.push(Xe.r,Xe.g,Xe.b,Xe.a)}this._materialNameFromObj||(it=new _.StandardMaterial(_.Geometry.RandomId(),A),it.pointsCloud=!0,this._materialNameFromObj=it.name,this._normals.length||(it.disableLighting=!0,it.emissiveColor=_.Color3.White()))}this._meshesFromObj.push({name:_.Geometry.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:it,isObject:!0,hasLines:this._hasLineData})}for(var Ze=0;Ze<this._meshesFromObj.length;Ze++){if(me&&this._meshesFromObj[Ze].name){if(me instanceof Array){if(me.indexOf(this._meshesFromObj[Ze].name)===-1)continue}else if(this._meshesFromObj[Ze].name!==me)continue}this._handledMesh=this._meshesFromObj[Ze],A._blockEntityCollection=!!ne;var ge=new _.Mesh(this._meshesFromObj[Ze].name,A);if(ge._parentContainer=ne,A._blockEntityCollection=!1,this._handledMesh._babylonMesh=ge,!this._handledMesh.isObject){for(var pe=Ze-1;pe>=0;--pe)if(this._meshesFromObj[pe].isObject&&this._meshesFromObj[pe]._babylonMesh){ge.parent=this._meshesFromObj[pe]._babylonMesh;break}}if(this._materialToUse.push(this._meshesFromObj[Ze].materialName),this._handledMesh.hasLines&&((W=ge._internalMetadata)!==null&&W!==void 0||(ge._internalMetadata={}),ge._internalMetadata._isLine=!0),((O=this._handledMesh.positions)===null||O===void 0?void 0:O.length)===0){this._babylonMeshesArray.push(ge);continue}var Ce=new _.VertexData;if(Ce.uvs=this._handledMesh.uvs,Ce.indices=this._handledMesh.indices,Ce.positions=this._handledMesh.positions,this._loadingOptions.computeNormals){var De=new Array;_.VertexData.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,De),Ce.normals=De}else Ce.normals=this._handledMesh.normals;this._loadingOptions.importVertexColors&&(Ce.colors=this._handledMesh.colors),Ce.applyToMesh(ge),this._loadingOptions.invertY&&(ge.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(ge),this._babylonMeshesArray.push(ge),this._handledMesh.directMaterial&&(ge.material=this._handledMesh.directMaterial)}},j.ObjectDescriptor=/^o/,j.GroupDescriptor=/^g/,j.MtlLibGroupDescriptor=/^mtllib /,j.UseMtlDescriptor=/^usemtl /,j.SmoothDescriptor=/^s /,j.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/,j.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,j.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,j.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/,j.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,j.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,j.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,j.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,j.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/,j.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,j.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,j}()},"../../../dev/loaders/src/SPLAT/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{SPLATFileLoader:()=>_.SPLATFileLoader}),K("../../../dev/loaders/src/SPLAT/splatLoadingOptions.ts");var _=K("../../../dev/loaders/src/SPLAT/splatFileLoader.ts")},"../../../dev/loaders/src/SPLAT/splatFileLoader.metadata.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{SPLATFileLoaderMetadata:()=>_});var _={name:"splat",extensions:{".splat":{isBinary:!0},".ply":{isBinary:!0}}}},"../../../dev/loaders/src/SPLAT/splatFileLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{SPLATFileLoader:()=>Se});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/SPLAT/splatFileLoader.metadata.ts"),me;(function(A){A[A.Splat=0]="Splat",A[A.PointCloud=1]="PointCloud",A[A.Mesh=2]="Mesh"})(me||(me={}));var Se=function(){function A(ne){ne===void 0&&(ne=A._DefaultLoadingOptions),this.name=j.SPLATFileLoaderMetadata.name,this._assetContainer=null,this.extensions=j.SPLATFileLoaderMetadata.extensions,this._loadingOptions=ne}return A.prototype.createPlugin=function(ne){return new A(ne[j.SPLATFileLoaderMetadata.name])},A.prototype.importMeshAsync=function(ne,ae,H,W,O,P){return(0,_.__awaiter)(this,void 0,void 0,function(){return(0,_.__generator)(this,function(Z){return[2,this._parse(ne,ae,H,W).then(function(re){return{meshes:re,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}})]})})},A._BuildPointCloud=function(ne,ae){if(!ae.byteLength)return!1;var H=new Uint8Array(ae),W=new Float32Array(ae),O=3*4+3*4+4+4,P=H.length/O,Z=function(re,oe){var he=W[8*oe+0],Ee=W[8*oe+1],Oe=W[8*oe+2];re.position=new z.Vector3(he,Ee,Oe);var Pe=H[O*oe+24+0]/255,Ae=H[O*oe+24+1]/255,Ue=H[O*oe+24+2]/255;re.color=new z.Color4(Pe,Ae,Ue,1)};return ne.addPoints(P,Z),!0},A._BuildMesh=function(ne,ae){for(var H=new z.Mesh("PLYMesh",ne),W=new Uint8Array(ae.data),O=new Float32Array(ae.data),P=3*4+3*4+4+4,Z=W.length/P,re=[],oe=new z.VertexData,he=0;he<Z;he++){var Ee=O[8*he+0],Oe=O[8*he+1],Pe=O[8*he+2];re.push(Ee,Oe,Pe)}if(ae.hasVertexColors){for(var Ae=new Float32Array(Z*4),he=0;he<Z;he++){var Ue=W[P*he+24+0]/255,je=W[P*he+24+1]/255,Ve=W[P*he+24+2]/255;Ae[he*4+0]=Ue,Ae[he*4+1]=je,Ae[he*4+2]=Ve,Ae[he*4+3]=1}oe.colors=Ae}return oe.positions=re,oe.indices=ae.faces,oe.applyToMesh(H),H},A.prototype._parse=function(ne,ae,H,W){var O=[],P=A._ConvertPLYToSplat(H);switch(P.mode){case 0:{var Z=new z.GaussianSplattingMesh("GaussianSplatting",null,ae,this._loadingOptions.keepInRam);Z._parentContainer=this._assetContainer,O.push(Z),Z.loadDataAsync(P.data)}break;case 1:{var re=new z.PointsCloudSystem("PointCloud",1,ae);if(A._BuildPointCloud(re,P.data))return Promise.all([re.buildMeshAsync()]).then(function(oe){return O.push(oe[0]),O});re.dispose()}break;case 2:if(P.faces)O.push(A._BuildMesh(ae,P));else throw new Error("PLY mesh doesn't contain face informations.");break;default:throw new Error("Unsupported Splat mode")}return Promise.resolve(O)},A.prototype.loadAssetContainerAsync=function(ne,ae,H){var W=this,O=new z.AssetContainer(ne);return this._assetContainer=O,this.importMeshAsync(null,ne,ae,H).then(function(P){return P.meshes.forEach(function(Z){return O.meshes.push(Z)}),W._assetContainer=null,O}).catch(function(P){throw W._assetContainer=null,P})},A.prototype.loadAsync=function(ne,ae,H){return this.importMeshAsync(null,ne,ae,H).then(function(){})},A._ConvertPLYToSplat=function(ne){var ae,H=new Uint8Array(ne),W=new TextDecoder().decode(H.slice(0,1024*10)),O=`end_header
|
||
`,P=W.indexOf(O);if(P<0||!W)return{mode:0,data:ne};var Z=parseInt(/element vertex (\d+)\n/.exec(W)[1]),re=/element face (\d+)\n/.exec(W),oe=0;re&&(oe=parseInt(re[1]));for(var he=0,Ee={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1,list:0},Oe=[],Pe=W.slice(0,P).split(`
|
||
`).filter(function(wt){return wt.startsWith("property ")}),Ae=0,Ue=Pe;Ae<Ue.length;Ae++){var je=Ue[Ae],Ve=(ae=je.split(" "),ae[1]),ot=ae[2];Oe.push({name:ot,type:Ve,offset:he}),Ee[Ve]?he+=Ee[Ve]:z.Logger.Warn("Unsupported property type: ".concat(Ve,"."))}for(var it=3*4+3*4+4+4,ft=.28209479177387814,xt=new DataView(ne,P+O.length),qe=new ArrayBuffer(it*Z),kt=new z.Quaternion,V=0;V<Z;V++){for(var gt=new Float32Array(qe,V*it,3),tt=new Float32Array(qe,V*it+12,3),Jt=new Uint8ClampedArray(qe,V*it+24,4),At=new Uint8ClampedArray(qe,V*it+28,4),gn=255,We=0,Xe=0,Ze=0,ge=0;ge<Oe.length;ge++){var pe=Oe[ge],Ce=void 0;switch(pe.type){case"float":Ce=xt.getFloat32(pe.offset+V*he,!0);break;case"int":Ce=xt.getInt32(pe.offset+V*he,!0);break;case"uint":Ce=xt.getUint32(pe.offset+V*he,!0);break;case"double":Ce=xt.getFloat64(pe.offset+V*he,!0);break;case"uchar":Ce=xt.getUint8(pe.offset+V*he);break;default:continue}switch(pe.name){case"x":gt[0]=Ce;break;case"y":gt[1]=Ce;break;case"z":gt[2]=Ce;break;case"scale_0":tt[0]=Math.exp(Ce);break;case"scale_1":tt[1]=Math.exp(Ce);break;case"scale_2":tt[2]=Math.exp(Ce);break;case"diffuse_red":case"red":Jt[0]=Ce;break;case"diffuse_green":case"green":Jt[1]=Ce;break;case"diffuse_blue":case"blue":Jt[2]=Ce;break;case"f_dc_0":Jt[0]=(.5+ft*Ce)*255;break;case"f_dc_1":Jt[1]=(.5+ft*Ce)*255;break;case"f_dc_2":Jt[2]=(.5+ft*Ce)*255;break;case"f_dc_3":Jt[3]=(.5+ft*Ce)*255;break;case"opacity":Jt[3]=1/(1+Math.exp(-Ce))*255;break;case"rot_0":gn=Ce;break;case"rot_1":We=Ce;break;case"rot_2":Xe=Ce;break;case"rot_3":Ze=Ce;break}}kt.set(We,Xe,Ze,gn),kt.normalize(),At[0]=kt.w*128+128,At[1]=kt.x*128+128,At[2]=kt.y*128+128,At[3]=kt.z*128+128}var De=[];if(oe)for(var Fe=he*Z,V=0;V<oe;V++){var Le=xt.getUint8(Fe);if(Le==3){Fe+=1;for(var Ye=0;Ye<Le;Ye++){var ct=xt.getUint32(Fe+(2-Ye)*4,!0);De.push(ct)}Fe+=12}}for(var ke=0,et=0,st=["x","y","z","scale_0","scale_1","scale_2","opacity","rot_0","rot_1","rot_2","rot_3"],Ct=["red","green","blue","f_dc_0","f_dc_1","f_dc_2"],ge=0;ge<Oe.length;ge++){var pe=Oe[ge];st.includes(pe.name)&&ke++,Ct.includes(pe.name)&&et++}var bt=ke==st.length&&et==3,Rt=oe?2:bt?0:1;return{mode:Rt,data:qe,faces:De,hasVertexColors:!!et}},A._DefaultLoadingOptions={keepInRam:!1},A}();(0,z.registerSceneLoaderPlugin)(new Se)},"../../../dev/loaders/src/SPLAT/splatLoadingOptions.ts":(nt,Ne,K)=>{K.r(Ne)},"../../../dev/loaders/src/STL/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{STLFileLoader:()=>_.STLFileLoader});var _=K("../../../dev/loaders/src/STL/stlFileLoader.ts")},"../../../dev/loaders/src/STL/stlFileLoader.metadata.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{STLFileLoaderMetadata:()=>_});var _={name:"stl",extensions:{".stl":{isBinary:!0}}}},"../../../dev/loaders/src/STL/stlFileLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{STLFileLoader:()=>j});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/STL/stlFileLoader.metadata.ts"),j=function(){function me(){this.solidPattern=/solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.name=z.STLFileLoaderMetadata.name,this.extensions=z.STLFileLoaderMetadata.extensions}return me.prototype.importMesh=function(Se,A,ne,ae,H){var W;if(typeof ne!="string"){if(this._isBinary(ne)){var O=new _.Mesh("stlmesh",A);return this._parseBinary(O,ne),H&&H.push(O),!0}ne=new TextDecoder().decode(new Uint8Array(ne))}for(;W=this.solidPattern.exec(ne);){var P=W[1],Z=W[3];if(Z&&P!=Z)return _.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(Se&&P){if(Se instanceof Array){if(!Se.indexOf(P))continue}else if(P!==Se)continue}P=P||"stlmesh";var O=new _.Mesh(P,A);this._parseASCII(O,W[2]),H&&H.push(O)}return!0},me.prototype.load=function(Se,A,ne){var ae=this.importMesh(null,Se,A,ne,null);return ae},me.prototype.loadAssetContainer=function(Se,A,ne){var ae=new _.AssetContainer(Se);return Se._blockEntityCollection=!0,this.importMesh(null,Se,A,ne,ae.meshes),Se._blockEntityCollection=!1,ae},me.prototype._isBinary=function(Se){var A=new DataView(Se);if(A.byteLength<=80)return!1;var ne=32/8*3+32/8*3*3+16/8,ae=A.getUint32(80,!0);if(80+32/8+ae*ne===A.byteLength)return!0;for(var H=[115,111,108,105,100],W=0;W<5;W++)if(A.getUint8(W)!==H[W])return!0;return!1},me.prototype._parseBinary=function(Se,A){for(var ne=new DataView(A),ae=ne.getUint32(80,!0),H=84,W=12*4+2,O=0,P=new Float32Array(ae*3*3),Z=new Float32Array(ae*3*3),re=new Uint32Array(ae*3),oe=0,he=0;he<ae;he++){for(var Ee=H+he*W,Oe=ne.getFloat32(Ee,!0),Pe=ne.getFloat32(Ee+4,!0),Ae=ne.getFloat32(Ee+8,!0),Ue=1;Ue<=3;Ue++){var je=Ee+Ue*12;P[O]=ne.getFloat32(je,!0),Z[O]=Oe,me.DO_NOT_ALTER_FILE_COORDINATES?(P[O+1]=ne.getFloat32(je+4,!0),P[O+2]=ne.getFloat32(je+8,!0),Z[O+1]=Pe,Z[O+2]=Ae):(P[O+2]=ne.getFloat32(je+4,!0),P[O+1]=ne.getFloat32(je+8,!0),Z[O+2]=Pe,Z[O+1]=Ae),O+=3}me.DO_NOT_ALTER_FILE_COORDINATES?(re[oe]=oe,re[oe+1]=oe+2,re[oe+2]=oe+1,oe+=3):(re[oe]=oe++,re[oe]=oe++,re[oe]=oe++)}Se.setVerticesData(_.VertexBuffer.PositionKind,P),Se.setVerticesData(_.VertexBuffer.NormalKind,Z),Se.setIndices(re),Se.computeWorldMatrix(!0)},me.prototype._parseASCII=function(Se,A){for(var ne=[],ae=[],H=[],W=0,O;O=this.facetsPattern.exec(A);){var P=O[1],Z=this.normalPattern.exec(P);if(this.normalPattern.lastIndex=0,!!Z){for(var re=[Number(Z[1]),Number(Z[5]),Number(Z[3])],oe=void 0;oe=this.vertexPattern.exec(P);)me.DO_NOT_ALTER_FILE_COORDINATES?(ne.push(Number(oe[1]),Number(oe[3]),Number(oe[5])),ae.push(re[0],re[2],re[1])):(ne.push(Number(oe[1]),Number(oe[5]),Number(oe[3])),ae.push(re[0],re[1],re[2]));me.DO_NOT_ALTER_FILE_COORDINATES?(H.push(W,W+2,W+1),W+=3):H.push(W++,W++,W++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,Se.setVerticesData(_.VertexBuffer.PositionKind,ne),Se.setVerticesData(_.VertexBuffer.NormalKind,ae),Se.setIndices(H),Se.computeWorldMatrix(!0)},me.DO_NOT_ALTER_FILE_COORDINATES=!1,me}();(0,_.registerSceneLoaderPlugin)(new j)},"../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFBinaryExtension:()=>A});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"),me=K("../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"),Se="binary_glTF",A=function(ne){(0,_.__extends)(ae,ne);function ae(){return ne.call(this,"KHR_binary_glTF")||this}return ae.prototype.loadRuntimeAsync=function(H,W,O,P){var Z=W.json.extensionsUsed;return!Z||Z.indexOf(this.name)===-1||!W.bin?!1:(this._bin=W.bin,P(z.GLTFLoaderBase.CreateRuntime(W.json,H,O)),!0)},ae.prototype.loadBufferAsync=function(H,W,O,P){return H.extensionsUsed.indexOf(this.name)===-1||W!==Se?!1:(this._bin.readAsync(0,this._bin.byteLength).then(O,function(Z){return P(Z.message)}),!0)},ae.prototype.loadTextureBufferAsync=function(H,W,O){var P=H.textures[W],Z=H.images[P.source];if(!Z.extensions||!(this.name in Z.extensions))return!1;var re=Z.extensions[this.name],oe=H.bufferViews[re.bufferView],he=j.GLTFUtils.GetBufferFromBufferView(H,oe,0,oe.byteLength,me.EComponentType.UNSIGNED_BYTE);return O(he),!0},ae.prototype.loadShaderStringAsync=function(H,W,O){var P=H.shaders[W];if(!P.extensions||!(this.name in P.extensions))return!1;var Z=P.extensions[this.name],re=H.bufferViews[Z.bufferView],oe=j.GLTFUtils.GetBufferFromBufferView(H,re,0,re.byteLength,me.EComponentType.UNSIGNED_BYTE);return setTimeout(function(){var he=j.GLTFUtils.DecodeBufferToText(oe);O(he)}),!0},ae}(z.GLTFLoaderExtension);z.GLTFLoader.RegisterExtension(new A)},"../../../dev/loaders/src/glTF/1.0/glTFLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFLoader:()=>Xe,GLTFLoaderBase:()=>We,GLTFLoaderExtension:()=>Ze});var _=K("../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"),me=K("../../../dev/loaders/src/glTF/glTFFileLoader.ts"),Se;(function(ge){ge[ge.IDENTIFIER=1]="IDENTIFIER",ge[ge.UNKNOWN=2]="UNKNOWN",ge[ge.END_OF_INPUT=3]="END_OF_INPUT"})(Se||(Se={}));var A=function(){function ge(pe){this._pos=0,this.currentToken=Se.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=pe,this._maxPos=pe.length}return ge.prototype.getNextToken=function(){if(this.isEnd())return Se.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=Se.UNKNOWN,this.currentString==="_"||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=Se.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||this.currentString==="_");)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},ge.prototype.peek=function(){return this._toParse[this._pos]},ge.prototype.read=function(){return this._toParse[this._pos++]},ge.prototype.forward=function(){this._pos++},ge.prototype.isEnd=function(){return this._pos>=this._maxPos},ge}(),ne=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],ae=["world","view","projection","worldView","worldViewProjection","mBones"],H=["translation","rotation","scale"],W=["position","rotationQuaternion","scaling"],O=function(ge,pe){for(var Ce in ge){var De=ge[Ce];pe.buffers[Ce]=De,pe.buffersCount++}},P=function(ge,pe){for(var Ce in ge){var De=ge[Ce];pe.shaders[Ce]=De,pe.shaderscount++}},Z=function(ge,pe,Ce){for(var De in ge){var Fe=ge[De];Ce[pe][De]=Fe}},re=function(ge){if(ge)for(var pe=0;pe<ge.length/2;pe++)ge[pe*2+1]=1-ge[pe*2+1]},oe=function(ge){if(ge.semantic==="NORMAL")return"normal";if(ge.semantic==="POSITION")return"position";if(ge.semantic==="JOINT")return"matricesIndices";if(ge.semantic==="WEIGHT")return"matricesWeights";if(ge.semantic==="COLOR")return"color";if(ge.semantic&&ge.semantic.indexOf("TEXCOORD_")!==-1){var pe=Number(ge.semantic.split("_")[1]);return"uv"+(pe===0?"":pe+1)}return null},he=function(ge){for(var pe in ge.animations){var Ce=ge.animations[pe];if(!(!Ce.channels||!Ce.samplers))for(var De=null,Fe=0;Fe<Ce.channels.length;Fe++){var Le=Ce.channels[Fe],Ye=Ce.samplers[Le.sampler];if(Ye){var ct=null,ke=null;Ce.parameters?(ct=Ce.parameters[Ye.input],ke=Ce.parameters[Ye.output]):(ct=Ye.input,ke=Ye.output);var et=j.GLTFUtils.GetBufferFromAccessor(ge,ge.accessors[ct]),st=j.GLTFUtils.GetBufferFromAccessor(ge,ge.accessors[ke]),Ct=Le.target.id,bt=ge.scene.getNodeById(Ct);if(bt===null&&(bt=ge.scene.getNodeByName(Ct)),bt===null){z.Tools.Warn("Creating animation named "+pe+". But cannot find node named "+Ct+" to attach to");continue}var Rt=bt instanceof z.Bone,wt=Le.target.path,Bt=H.indexOf(wt);Bt!==-1&&(wt=W[Bt]);var Wt=z.Animation.ANIMATIONTYPE_MATRIX;Rt||(wt==="rotationQuaternion"?(Wt=z.Animation.ANIMATIONTYPE_QUATERNION,bt.rotationQuaternion=new z.Quaternion):Wt=z.Animation.ANIMATIONTYPE_VECTOR3);var xn=null,Yn=[],Kt=0,Sn=!1;Rt&&De&&De.getKeys().length===et.length&&(xn=De,Sn=!0),Sn||(ge.scene._blockEntityCollection=!!ge.assetContainer,xn=new z.Animation(pe,Rt?"_matrix":wt,1,Wt,z.Animation.ANIMATIONLOOPMODE_CYCLE),ge.scene._blockEntityCollection=!1);for(var Gn=0;Gn<et.length;Gn++){var Xn=null;if(wt==="rotationQuaternion"?(Xn=z.Quaternion.FromArray([st[Kt],st[Kt+1],st[Kt+2],st[Kt+3]]),Kt+=4):(Xn=z.Vector3.FromArray([st[Kt],st[Kt+1],st[Kt+2]]),Kt+=3),Rt){var bo=bt,Fi=z.Vector3.Zero(),hr=new z.Quaternion,Xi=z.Vector3.Zero(),Ci=bo.getBaseMatrix();Sn&&De&&(Ci=De.getKeys()[Gn].value),Ci.decompose(Xi,hr,Fi),wt==="position"?Fi=Xn:wt==="rotationQuaternion"?hr=Xn:Xi=Xn,Xn=z.Matrix.Compose(Xi,hr,Fi)}Sn?De&&(De.getKeys()[Gn].value=Xn):Yn.push({frame:et[Gn],value:Xn})}!Sn&&xn&&(xn.setKeys(Yn),bt.animations.push(xn)),De=xn,ge.scene.stopAnimation(bt),ge.scene.beginAnimation(bt,0,et[et.length-1],!0,1)}}}},Ee=function(ge){var pe=null;if(ge.translation||ge.rotation||ge.scale){var Ce=z.Vector3.FromArray(ge.scale||[1,1,1]),De=z.Quaternion.FromArray(ge.rotation||[0,0,0,1]),Fe=z.Vector3.FromArray(ge.translation||[0,0,0]);pe=z.Matrix.Compose(Ce,De,Fe)}else pe=z.Matrix.FromArray(ge.matrix);return pe},Oe=function(ge,pe,Ce,De){for(var Fe=0;Fe<De.bones.length;Fe++)if(De.bones[Fe].name===Ce)return De.bones[Fe];var Le=ge.nodes;for(var Ye in Le){var ct=Le[Ye];if(ct.jointName)for(var ke=ct.children,Fe=0;Fe<ke.length;Fe++){var et=ge.nodes[ke[Fe]];if(et.jointName&&et.jointName===Ce){var st=Ee(ct),Ct=new z.Bone(ct.name||"",De,Oe(ge,pe,ct.jointName,De),st);return Ct.id=Ye,Ct}}}return null},Pe=function(ge,pe){for(var Ce=0;Ce<ge.length;Ce++)for(var De=ge[Ce],Fe=0;Fe<De.node.children.length;Fe++){var Le=De.node.children[Fe];if(Le===pe)return De.bone}return null},Ae=function(ge,pe){var Ce=ge.nodes,De=Ce[pe];if(De)return{node:De,id:pe};for(var Fe in Ce)if(De=Ce[Fe],De.jointName===pe)return{node:De,id:Fe};return null},Ue=function(ge,pe){for(var Ce=0;Ce<ge.jointNames.length;Ce++)if(ge.jointNames[Ce]===pe)return!0;return!1},je=function(ge,pe,Ce,De){for(var Fe in ge.nodes){var Le=ge.nodes[Fe],Ye=Fe;if(!(!Le.jointName||Ue(Ce,Le.jointName))){var ct=Ee(Le),ke=new z.Bone(Le.name||"",pe,null,ct);ke.id=Ye,De.push({bone:ke,node:Le,id:Ye})}}for(var et=0;et<De.length;et++)for(var st=De[et],Ct=st.node.children,bt=0;bt<Ct.length;bt++){for(var Rt=null,wt=0;wt<De.length;wt++)if(De[wt].id===Ct[bt]){Rt=De[wt];break}Rt&&(Rt.bone._parent=st.bone,st.bone.children.push(Rt.bone))}},Ve=function(ge,pe,Ce,De){if(De||(De=new z.Skeleton(pe.name||"","",ge.scene)),!pe.babylonSkeleton)return De;var Fe=[],Le=[];je(ge,De,pe,Fe),De.bones=[];for(var Ye=0;Ye<pe.jointNames.length;Ye++){var ct=Ae(ge,pe.jointNames[Ye]);if(ct){var ke=ct.node;if(!ke){z.Tools.Warn("Joint named "+pe.jointNames[Ye]+" does not exist");continue}var et=ct.id,st=ge.scene.getBoneById(et);if(st){De.bones.push(st);continue}for(var Ct=!1,bt=null,Rt=0;Rt<Ye;Rt++){var wt=Ae(ge,pe.jointNames[Rt]);if(wt){var Bt=wt.node;if(!Bt){z.Tools.Warn("Joint named "+pe.jointNames[Rt]+" does not exist when looking for parent");continue}var Wt=Bt.children;if(Wt){Ct=!1;for(var xn=0;xn<Wt.length;xn++)if(Wt[xn]===et){bt=Oe(ge,pe,pe.jointNames[Rt],De),Ct=!0;break}if(Ct)break}}}var Yn=Ee(ke);!bt&&Fe.length>0&&(bt=Pe(Fe,et),bt&&Le.indexOf(bt)===-1&&Le.push(bt));var Kt=new z.Bone(ke.jointName||"",De,bt,Yn);Kt.id=et}}var Sn=De.bones;De.bones=[];for(var Ye=0;Ye<pe.jointNames.length;Ye++){var ct=Ae(ge,pe.jointNames[Ye]);if(ct){for(var Rt=0;Rt<Sn.length;Rt++)if(Sn[Rt].id===ct.id){De.bones.push(Sn[Rt]);break}}}De.prepare();for(var Ye=0;Ye<Le.length;Ye++)De.bones.push(Le[Ye]);return De},ot=function(ge,pe,Ce,De,Fe){if(Fe||(ge.scene._blockEntityCollection=!!ge.assetContainer,Fe=new z.Mesh(pe.name||"",ge.scene),Fe._parentContainer=ge.assetContainer,ge.scene._blockEntityCollection=!1,Fe.id=De),!pe.babylonNode)return Fe;for(var Le=[],Ye=null,ct=[],ke=[],et=[],st=[],Ct=0;Ct<Ce.length;Ct++){var bt=Ce[Ct],Rt=ge.meshes[bt];if(Rt)for(var wt=0;wt<Rt.primitives.length;wt++){var Bt=new z.VertexData,Wt=Rt.primitives[wt];Wt.mode;var xn=Wt.attributes,Yn=null,Kt=null;for(var Sn in xn)if(Yn=ge.accessors[xn[Sn]],Kt=j.GLTFUtils.GetBufferFromAccessor(ge,Yn),Sn==="NORMAL")Bt.normals=new Float32Array(Kt.length),Bt.normals.set(Kt);else if(Sn==="POSITION"){if(me.GLTFFileLoader.HomogeneousCoordinates){Bt.positions=new Float32Array(Kt.length-Kt.length/4);for(var Gn=0;Gn<Kt.length;Gn+=4)Bt.positions[Gn]=Kt[Gn],Bt.positions[Gn+1]=Kt[Gn+1],Bt.positions[Gn+2]=Kt[Gn+2]}else Bt.positions=new Float32Array(Kt.length),Bt.positions.set(Kt);ke.push(Bt.positions.length)}else if(Sn.indexOf("TEXCOORD_")!==-1){var Xn=Number(Sn.split("_")[1]),bo=z.VertexBuffer.UVKind+(Xn===0?"":Xn+1),Fi=new Float32Array(Kt.length);Fi.set(Kt),re(Fi),Bt.set(Fi,bo)}else Sn==="JOINT"?(Bt.matricesIndices=new Float32Array(Kt.length),Bt.matricesIndices.set(Kt)):Sn==="WEIGHT"?(Bt.matricesWeights=new Float32Array(Kt.length),Bt.matricesWeights.set(Kt)):Sn==="COLOR"&&(Bt.colors=new Float32Array(Kt.length),Bt.colors.set(Kt));if(Yn=ge.accessors[Wt.indices],Yn)Kt=j.GLTFUtils.GetBufferFromAccessor(ge,Yn),Bt.indices=new Int32Array(Kt.length),Bt.indices.set(Kt),st.push(Bt.indices.length);else{for(var hr=[],Gn=0;Gn<Bt.positions.length/3;Gn++)hr.push(Gn);Bt.indices=new Int32Array(hr),st.push(Bt.indices.length)}Ye?Ye.merge(Bt):Ye=Bt;var Xi=ge.scene.getMaterialById(Wt.material);Le.push(Xi===null?j.GLTFUtils.GetDefaultMaterial(ge.scene):Xi),ct.push(ct.length===0?0:ct[ct.length-1]+ke[ke.length-2]),et.push(et.length===0?0:et[et.length-1]+st[st.length-2])}}var Ci;ge.scene._blockEntityCollection=!!ge.assetContainer,Le.length>1?(Ci=new z.MultiMaterial("multimat"+De,ge.scene),Ci.subMaterials=Le):Ci=new z.StandardMaterial("multimat"+De,ge.scene),Le.length===1&&(Ci=Le[0]),Ci._parentContainer=ge.assetContainer,Fe.material||(Fe.material=Ci),new z.Geometry(De,ge.scene,Ye,!1,Fe),Fe.computeWorldMatrix(!0),ge.scene._blockEntityCollection=!1,Fe.subMeshes=[];for(var fr=0,Ct=0;Ct<Ce.length;Ct++){var bt=Ce[Ct],Rt=ge.meshes[bt];if(Rt)for(var wt=0;wt<Rt.primitives.length;wt++)Rt.primitives[wt].mode,z.SubMesh.AddToMesh(fr,ct[fr],ke[fr],et[fr],st[fr],Fe,Fe,!0),fr++}return Fe},it=function(ge,pe,Ce,De){ge.position&&(ge.position=pe),(ge.rotationQuaternion||ge.rotation)&&(ge.rotationQuaternion=Ce),ge.scaling&&(ge.scaling=De)},ft=function(ge,pe){if(pe.matrix){var Ce=new z.Vector3(0,0,0),De=new z.Quaternion,Fe=new z.Vector3(0,0,0),Le=z.Matrix.FromArray(pe.matrix);Le.decompose(Fe,De,Ce),it(ge,Ce,De,Fe)}else pe.translation&&pe.rotation&&pe.scale&&it(ge,z.Vector3.FromArray(pe.translation),z.Quaternion.FromArray(pe.rotation),z.Vector3.FromArray(pe.scale));ge.computeWorldMatrix(!0)},xt=function(ge,pe,Ce){var De=null;if(ge.importOnlyMeshes&&(pe.skin||pe.meshes)&&ge.importMeshesNames&&ge.importMeshesNames.length>0&&ge.importMeshesNames.indexOf(pe.name||"")===-1)return null;if(pe.skin){if(pe.meshes){var Fe=ge.skins[pe.skin],Le=ot(ge,pe,pe.meshes,Ce,pe.babylonNode);Le.skeleton=ge.scene.getLastSkeletonById(pe.skin),Le.skeleton===null&&(Le.skeleton=Ve(ge,Fe,Le,Fe.babylonSkeleton),Fe.babylonSkeleton||(Fe.babylonSkeleton=Le.skeleton)),De=Le}}else if(pe.meshes){var Le=ot(ge,pe,pe.mesh?[pe.mesh]:pe.meshes,Ce,pe.babylonNode);De=Le}else if(pe.light&&!pe.babylonNode&&!ge.importOnlyMeshes){var Ye=ge.lights[pe.light];if(Ye){if(Ye.type==="ambient"){var ct=Ye[Ye.type],ke=new z.HemisphericLight(pe.light,z.Vector3.Zero(),ge.scene);ke.name=pe.name||"",ct.color&&(ke.diffuse=z.Color3.FromArray(ct.color)),De=ke}else if(Ye.type==="directional"){var et=Ye[Ye.type],st=new z.DirectionalLight(pe.light,z.Vector3.Zero(),ge.scene);st.name=pe.name||"",et.color&&(st.diffuse=z.Color3.FromArray(et.color)),De=st}else if(Ye.type==="point"){var Ct=Ye[Ye.type],bt=new z.PointLight(pe.light,z.Vector3.Zero(),ge.scene);bt.name=pe.name||"",Ct.color&&(bt.diffuse=z.Color3.FromArray(Ct.color)),De=bt}else if(Ye.type==="spot"){var Rt=Ye[Ye.type],wt=new z.SpotLight(pe.light,z.Vector3.Zero(),z.Vector3.Zero(),0,0,ge.scene);wt.name=pe.name||"",Rt.color&&(wt.diffuse=z.Color3.FromArray(Rt.color)),Rt.fallOfAngle&&(wt.angle=Rt.fallOfAngle),Rt.fallOffExponent&&(wt.exponent=Rt.fallOffExponent),De=wt}}}else if(pe.camera&&!pe.babylonNode&&!ge.importOnlyMeshes){var Bt=ge.cameras[pe.camera];if(Bt){if(ge.scene._blockEntityCollection=!!ge.assetContainer,Bt.type==="orthographic"){var Wt=new z.FreeCamera(pe.camera,z.Vector3.Zero(),ge.scene,!1);Wt.name=pe.name||"",Wt.mode=z.Camera.ORTHOGRAPHIC_CAMERA,Wt.attachControl(),De=Wt,Wt._parentContainer=ge.assetContainer}else if(Bt.type==="perspective"){var xn=Bt[Bt.type],Yn=new z.FreeCamera(pe.camera,z.Vector3.Zero(),ge.scene,!1);Yn.name=pe.name||"",Yn.attachControl(),xn.aspectRatio||(xn.aspectRatio=ge.scene.getEngine().getRenderWidth()/ge.scene.getEngine().getRenderHeight()),xn.znear&&xn.zfar&&(Yn.maxZ=xn.zfar,Yn.minZ=xn.znear),De=Yn,Yn._parentContainer=ge.assetContainer}ge.scene._blockEntityCollection=!1}}if(!pe.jointName){if(pe.babylonNode)return pe.babylonNode;if(De===null){ge.scene._blockEntityCollection=!!ge.assetContainer;var Kt=new z.Mesh(pe.name||"",ge.scene);Kt._parentContainer=ge.assetContainer,ge.scene._blockEntityCollection=!1,pe.babylonNode=Kt,De=Kt}}if(De!==null){if(pe.matrix&&De instanceof z.Mesh)ft(De,pe);else{var Sn=pe.translation||[0,0,0],Gn=pe.rotation||[0,0,0,1],Xn=pe.scale||[1,1,1];it(De,z.Vector3.FromArray(Sn),z.Quaternion.FromArray(Gn),z.Vector3.FromArray(Xn))}De.updateCache(!0),pe.babylonNode=De}return De},qe=function(ge,pe,Ce,De){De===void 0&&(De=!1);var Fe=ge.nodes[pe],Le=null;if(ge.importOnlyMeshes&&!De&&ge.importMeshesNames?ge.importMeshesNames.indexOf(Fe.name||"")!==-1||ge.importMeshesNames.length===0?De=!0:De=!1:De=!0,!Fe.jointName&&De&&(Le=xt(ge,Fe,pe),Le!==null&&(Le.id=pe,Le.parent=Ce)),Fe.children)for(var Ye=0;Ye<Fe.children.length;Ye++)qe(ge,Fe.children[Ye],Le,De)},kt=function(ge){var pe=ge.currentScene;if(pe)for(var Ce=0;Ce<pe.nodes.length;Ce++)qe(ge,pe.nodes[Ce],null);else for(var De in ge.scenes){pe=ge.scenes[De];for(var Ce=0;Ce<pe.nodes.length;Ce++)qe(ge,pe.nodes[Ce],null)}he(ge);for(var Ce=0;Ce<ge.scene.skeletons.length;Ce++){var Fe=ge.scene.skeletons[Ce];ge.scene.beginAnimation(Fe,0,Number.MAX_VALUE,!0,1)}},V=function(ge,pe,Ce,De,Fe,Le,Ye){var ct=Le.values||Fe.parameters;for(var ke in Ce){var et=Ce[ke],st=et.type;if(st===_.EParameterType.FLOAT_MAT2||st===_.EParameterType.FLOAT_MAT3||st===_.EParameterType.FLOAT_MAT4){if(et.semantic&&!et.source&&!et.node)j.GLTFUtils.SetMatrix(pe.scene,ge,et,ke,De.getEffect());else if(et.semantic&&(et.source||et.node)){var Ct=pe.scene.getNodeByName(et.source||et.node||"");if(Ct===null&&(Ct=pe.scene.getNodeById(et.source||et.node||"")),Ct===null)continue;j.GLTFUtils.SetMatrix(pe.scene,Ct,et,ke,De.getEffect())}}else{var bt=ct[Fe.uniforms[ke]];if(!bt)continue;if(st===_.EParameterType.SAMPLER_2D){var Rt=pe.textures[Le.values?bt:et.value].babylonTexture;if(Rt==null)continue;De.getEffect().setTexture(ke,Rt)}else j.GLTFUtils.SetUniform(De.getEffect(),ke,bt,st)}}Ye(De)},gt=function(ge,pe,Ce,De,Fe){var Le=De.values||Ce.parameters,Ye=Ce.uniforms,ct=function(et){var st=Fe[et],Ct=st.type,bt=Le[Ye[et]];if(bt===void 0&&(bt=st.value),!bt)return"continue";var Rt=function(wt){return function(Bt){st.value&&wt&&(pe.setTexture(wt,Bt),delete Fe[wt])}};Ct===_.EParameterType.SAMPLER_2D?Ze.LoadTextureAsync(ge,De.values?bt:st.value,Rt(et),function(){return Rt(null)}):st.value&&j.GLTFUtils.SetUniform(pe,et,De.values?bt:st.value,Ct)&&delete Fe[et]};for(var ke in Fe)ct(ke)},tt=function(ge,pe,Ce){return function(De,Fe){pe.dispose(!0),Ce("Cannot compile program named "+ge.name+". Error: "+Fe+". Default material will be applied")}},Jt=function(ge,pe,Ce,De,Fe,Le){return function(Ye){gt(ge,pe,Ce,De,Fe),pe.onBind=function(ct){V(ct,ge,Fe,pe,Ce,De,Le)}}},At=function(ge,pe,Ce){for(var De in pe.uniforms){var Fe=pe.uniforms[De],Le=pe.parameters[Fe];if(ge.currentIdentifier===De&&Le.semantic&&!Le.source&&!Le.node){var Ye=ne.indexOf(Le.semantic);if(Ye!==-1)return delete Ce[De],ae[Ye]}}return ge.currentIdentifier},gn=function(ge){for(var pe in ge.materials)Ze.LoadMaterialAsync(ge,pe,function(){},function(){})},We=function(){function ge(){}return ge.CreateRuntime=function(pe,Ce,De){var Fe={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:Ce,rootUrl:De,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return pe.extensions&&Z(pe.extensions,"extensions",Fe),pe.extensionsUsed&&Z(pe.extensionsUsed,"extensionsUsed",Fe),pe.buffers&&O(pe.buffers,Fe),pe.bufferViews&&Z(pe.bufferViews,"bufferViews",Fe),pe.accessors&&Z(pe.accessors,"accessors",Fe),pe.meshes&&Z(pe.meshes,"meshes",Fe),pe.lights&&Z(pe.lights,"lights",Fe),pe.cameras&&Z(pe.cameras,"cameras",Fe),pe.nodes&&Z(pe.nodes,"nodes",Fe),pe.images&&Z(pe.images,"images",Fe),pe.textures&&Z(pe.textures,"textures",Fe),pe.shaders&&P(pe.shaders,Fe),pe.programs&&Z(pe.programs,"programs",Fe),pe.samplers&&Z(pe.samplers,"samplers",Fe),pe.techniques&&Z(pe.techniques,"techniques",Fe),pe.materials&&Z(pe.materials,"materials",Fe),pe.animations&&Z(pe.animations,"animations",Fe),pe.skins&&Z(pe.skins,"skins",Fe),pe.scenes&&(Fe.scenes=pe.scenes),pe.scene&&pe.scenes&&(Fe.currentScene=pe.scenes[pe.scene]),Fe},ge.LoadBufferAsync=function(pe,Ce,De,Fe,Le){var Ye=pe.buffers[Ce];z.Tools.IsBase64(Ye.uri)?setTimeout(function(){return De(new Uint8Array(z.Tools.DecodeBase64(Ye.uri)))}):z.Tools.LoadFile(pe.rootUrl+Ye.uri,function(ct){return De(new Uint8Array(ct))},Le,void 0,!0,function(ct){ct&&Fe(ct.status+" "+ct.statusText)})},ge.LoadTextureBufferAsync=function(pe,Ce,De,Fe){var Le=pe.textures[Ce];if(!Le||!Le.source){Fe("");return}if(Le.babylonTexture){De(null);return}var Ye=pe.images[Le.source];z.Tools.IsBase64(Ye.uri)?setTimeout(function(){return De(new Uint8Array(z.Tools.DecodeBase64(Ye.uri)))}):z.Tools.LoadFile(pe.rootUrl+Ye.uri,function(ct){return De(new Uint8Array(ct))},void 0,void 0,!0,function(ct){ct&&Fe(ct.status+" "+ct.statusText)})},ge.CreateTextureAsync=function(pe,Ce,De,Fe){var Le=pe.textures[Ce];if(Le.babylonTexture){Fe(Le.babylonTexture);return}var Ye=pe.samplers[Le.sampler],ct=Ye.minFilter===_.ETextureFilterType.NEAREST_MIPMAP_NEAREST||Ye.minFilter===_.ETextureFilterType.NEAREST_MIPMAP_LINEAR||Ye.minFilter===_.ETextureFilterType.LINEAR_MIPMAP_NEAREST||Ye.minFilter===_.ETextureFilterType.LINEAR_MIPMAP_LINEAR,ke=z.Texture.BILINEAR_SAMPLINGMODE,et=De==null?new Blob:new Blob([De]),st=URL.createObjectURL(et),Ct=function(){return URL.revokeObjectURL(st)},bt=new z.Texture(st,pe.scene,!ct,!0,ke,Ct,Ct);Ye.wrapS!==void 0&&(bt.wrapU=j.GLTFUtils.GetWrapMode(Ye.wrapS)),Ye.wrapT!==void 0&&(bt.wrapV=j.GLTFUtils.GetWrapMode(Ye.wrapT)),bt.name=Ce,Le.babylonTexture=bt,Fe(bt)},ge.LoadShaderStringAsync=function(pe,Ce,De,Fe){var Le=pe.shaders[Ce];if(z.Tools.IsBase64(Le.uri)){var Ye=atob(Le.uri.split(",")[1]);De&&De(Ye)}else z.Tools.LoadFile(pe.rootUrl+Le.uri,De,void 0,void 0,!1,function(ct){ct&&Fe&&Fe(ct.status+" "+ct.statusText)})},ge.LoadMaterialAsync=function(pe,Ce,De,Fe){var Le=pe.materials[Ce];if(!Le.technique){Fe&&Fe("No technique found.");return}var Ye=pe.techniques[Le.technique];if(!Ye){pe.scene._blockEntityCollection=!!pe.assetContainer;var ct=new z.StandardMaterial(Ce,pe.scene);ct._parentContainer=pe.assetContainer,pe.scene._blockEntityCollection=!1,ct.diffuseColor=new z.Color3(.5,.5,.5),ct.sideOrientation=z.Material.CounterClockWiseSideOrientation,De(ct);return}var ke=pe.programs[Ye.program],et=Ye.states,st=z.Effect.ShadersStore[ke.vertexShader+"VertexShader"],Ct=z.Effect.ShadersStore[ke.fragmentShader+"PixelShader"],bt="",Rt="",wt=new A(st),Bt=new A(Ct),Wt={},xn=[],Yn=[],Kt=[];for(var Sn in Ye.uniforms){var Gn=Ye.uniforms[Sn],Xn=Ye.parameters[Gn];if(Wt[Sn]=Xn,Xn.semantic&&!Xn.node&&!Xn.source){var bo=ne.indexOf(Xn.semantic);bo!==-1?(xn.push(ae[bo]),delete Wt[Sn]):xn.push(Sn)}else Xn.type===_.EParameterType.SAMPLER_2D?Kt.push(Sn):xn.push(Sn)}for(var Fi in Ye.attributes){var hr=Ye.attributes[Fi],Xi=Ye.parameters[hr];if(Xi.semantic){var Ci=oe(Xi);Ci&&Yn.push(Ci)}}for(;!wt.isEnd()&&wt.getNextToken();){var fr=wt.currentToken;if(fr!==Se.IDENTIFIER){bt+=wt.currentString;continue}var xs=!1;for(var Fi in Ye.attributes){var hr=Ye.attributes[Fi],Xi=Ye.parameters[hr];if(wt.currentIdentifier===Fi&&Xi.semantic){bt+=oe(Xi),xs=!0;break}}xs||(bt+=At(wt,Ye,Wt))}for(;!Bt.isEnd()&&Bt.getNextToken();){var fr=Bt.currentToken;if(fr!==Se.IDENTIFIER){Rt+=Bt.currentString;continue}Rt+=At(Bt,Ye,Wt)}var En={vertex:ke.vertexShader+Ce,fragment:ke.fragmentShader+Ce},Ps={attributes:Yn,uniforms:xn,samplers:Kt,needAlphaBlending:et&&et.enable&&et.enable.indexOf(3042)!==-1};z.Effect.ShadersStore[ke.vertexShader+Ce+"VertexShader"]=bt,z.Effect.ShadersStore[ke.fragmentShader+Ce+"PixelShader"]=Rt;var wi=new z.ShaderMaterial(Ce,pe.scene,En,Ps);if(wi.onError=tt(ke,wi,Fe),wi.onCompiled=Jt(pe,wi,Ye,Le,Wt,De),wi.sideOrientation=z.Material.CounterClockWiseSideOrientation,et&&et.functions){var Ao=et.functions;Ao.cullFace&&Ao.cullFace[0]!==_.ECullingType.BACK&&(wi.backFaceCulling=!1);var Rn=Ao.blendFuncSeparate;Rn&&(Rn[0]===_.EBlendingFunction.SRC_ALPHA&&Rn[1]===_.EBlendingFunction.ONE_MINUS_SRC_ALPHA&&Rn[2]===_.EBlendingFunction.ONE&&Rn[3]===_.EBlendingFunction.ONE?wi.alphaMode=z.Constants.ALPHA_COMBINE:Rn[0]===_.EBlendingFunction.ONE&&Rn[1]===_.EBlendingFunction.ONE&&Rn[2]===_.EBlendingFunction.ZERO&&Rn[3]===_.EBlendingFunction.ONE?wi.alphaMode=z.Constants.ALPHA_ONEONE:Rn[0]===_.EBlendingFunction.SRC_ALPHA&&Rn[1]===_.EBlendingFunction.ONE&&Rn[2]===_.EBlendingFunction.ZERO&&Rn[3]===_.EBlendingFunction.ONE?wi.alphaMode=z.Constants.ALPHA_ADD:Rn[0]===_.EBlendingFunction.ZERO&&Rn[1]===_.EBlendingFunction.ONE_MINUS_SRC_COLOR&&Rn[2]===_.EBlendingFunction.ONE&&Rn[3]===_.EBlendingFunction.ONE?wi.alphaMode=z.Constants.ALPHA_SUBTRACT:Rn[0]===_.EBlendingFunction.DST_COLOR&&Rn[1]===_.EBlendingFunction.ZERO&&Rn[2]===_.EBlendingFunction.ONE&&Rn[3]===_.EBlendingFunction.ONE?wi.alphaMode=z.Constants.ALPHA_MULTIPLY:Rn[0]===_.EBlendingFunction.SRC_ALPHA&&Rn[1]===_.EBlendingFunction.ONE_MINUS_SRC_COLOR&&Rn[2]===_.EBlendingFunction.ONE&&Rn[3]===_.EBlendingFunction.ONE&&(wi.alphaMode=z.Constants.ALPHA_MAXIMIZED))}},ge}(),Xe=function(){function ge(){}return ge.RegisterExtension=function(pe){if(ge.Extensions[pe.name]){z.Tools.Error('Tool with the same name "'+pe.name+'" already exists');return}ge.Extensions[pe.name]=pe},ge.prototype.dispose=function(){},ge.prototype._importMeshAsync=function(pe,Ce,De,Fe,Le,Ye,ct,ke){var et=this;return Ce.useRightHandedSystem=!0,Ze.LoadRuntimeAsync(Ce,De,Fe,function(st){st.assetContainer=Le,st.importOnlyMeshes=!0,pe===""?st.importMeshesNames=[]:typeof pe=="string"?st.importMeshesNames=[pe]:pe&&!(pe instanceof Array)?st.importMeshesNames=[pe]:(st.importMeshesNames=[],z.Tools.Warn("Argument meshesNames must be of type string or string[]")),et._createNodes(st);var Ct=[],bt=[];for(var Rt in st.nodes){var wt=st.nodes[Rt];wt.babylonNode instanceof z.AbstractMesh&&Ct.push(wt.babylonNode)}for(var Bt in st.skins){var Wt=st.skins[Bt];Wt.babylonSkeleton instanceof z.Skeleton&&bt.push(Wt.babylonSkeleton)}et._loadBuffersAsync(st,function(){et._loadShadersAsync(st,function(){gn(st),kt(st),!me.GLTFFileLoader.IncrementalLoading&&Ye&&Ye(Ct,bt)})}),me.GLTFFileLoader.IncrementalLoading&&Ye&&Ye(Ct,bt)},ke),!0},ge.prototype.importMeshAsync=function(pe,Ce,De,Fe,Le,Ye){var ct=this;return new Promise(function(ke,et){ct._importMeshAsync(pe,Ce,Fe,Le,De,function(st,Ct){ke({meshes:st,particleSystems:[],skeletons:Ct,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})},Ye,function(st){et(new Error(st))})})},ge.prototype._loadAsync=function(pe,Ce,De,Fe,Le,Ye){var ct=this;pe.useRightHandedSystem=!0,Ze.LoadRuntimeAsync(pe,Ce,De,function(ke){Ze.LoadRuntimeExtensionsAsync(ke,function(){ct._createNodes(ke),ct._loadBuffersAsync(ke,function(){ct._loadShadersAsync(ke,function(){gn(ke),kt(ke),me.GLTFFileLoader.IncrementalLoading||Fe()})}),me.GLTFFileLoader.IncrementalLoading&&Fe()},Ye)},Ye)},ge.prototype.loadAsync=function(pe,Ce,De,Fe){var Le=this;return new Promise(function(Ye,ct){Le._loadAsync(pe,Ce,De,function(){Ye()},Fe,function(ke){ct(new Error(ke))})})},ge.prototype._loadShadersAsync=function(pe,Ce){var De=!1,Fe=function(ct,ke){Ze.LoadShaderStringAsync(pe,ct,function(et){et instanceof ArrayBuffer||(pe.loadedShaderCount++,et&&(z.Effect.ShadersStore[ct+(ke.type===_.EShaderType.VERTEX?"VertexShader":"PixelShader")]=et),pe.loadedShaderCount===pe.shaderscount&&Ce())},function(){z.Tools.Error("Error when loading shader program named "+ct+" located at "+ke.uri)})};for(var Le in pe.shaders){De=!0;var Ye=pe.shaders[Le];Ye?Fe.bind(this,Le,Ye)():z.Tools.Error("No shader named: "+Le)}De||Ce()},ge.prototype._loadBuffersAsync=function(pe,Ce){var De=!1,Fe=function(ct,ke){Ze.LoadBufferAsync(pe,ct,function(et){pe.loadedBufferCount++,et&&(et.byteLength!=pe.buffers[ct].byteLength&&z.Tools.Error("Buffer named "+ct+" is length "+et.byteLength+". Expected: "+ke.byteLength),pe.loadedBufferViews[ct]=et),pe.loadedBufferCount===pe.buffersCount&&Ce()},function(){z.Tools.Error("Error when loading buffer named "+ct+" located at "+ke.uri)})};for(var Le in pe.buffers){De=!0;var Ye=pe.buffers[Le];Ye?Fe.bind(this,Le,Ye)():z.Tools.Error("No buffer named: "+Le)}De||Ce()},ge.prototype._createNodes=function(pe){var Ce=pe.currentScene;if(Ce)for(var De=0;De<Ce.nodes.length;De++)qe(pe,Ce.nodes[De],null);else for(var Fe in pe.scenes){Ce=pe.scenes[Fe];for(var De=0;De<Ce.nodes.length;De++)qe(pe,Ce.nodes[De],null)}},ge.Extensions={},ge}(),Ze=function(){function ge(pe){this._name=pe}return Object.defineProperty(ge.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),ge.prototype.loadRuntimeAsync=function(pe,Ce,De,Fe,Le){return!1},ge.prototype.loadRuntimeExtensionsAsync=function(pe,Ce,De){return!1},ge.prototype.loadBufferAsync=function(pe,Ce,De,Fe,Le){return!1},ge.prototype.loadTextureBufferAsync=function(pe,Ce,De,Fe){return!1},ge.prototype.createTextureAsync=function(pe,Ce,De,Fe,Le){return!1},ge.prototype.loadShaderStringAsync=function(pe,Ce,De,Fe){return!1},ge.prototype.loadMaterialAsync=function(pe,Ce,De,Fe){return!1},ge.LoadRuntimeAsync=function(pe,Ce,De,Fe,Le){ge._ApplyExtensions(function(Ye){return Ye.loadRuntimeAsync(pe,Ce,De,Fe,Le)},function(){setTimeout(function(){Fe&&Fe(We.CreateRuntime(Ce.json,pe,De))})})},ge.LoadRuntimeExtensionsAsync=function(pe,Ce,De){ge._ApplyExtensions(function(Fe){return Fe.loadRuntimeExtensionsAsync(pe,Ce,De)},function(){setTimeout(function(){Ce()})})},ge.LoadBufferAsync=function(pe,Ce,De,Fe,Le){ge._ApplyExtensions(function(Ye){return Ye.loadBufferAsync(pe,Ce,De,Fe,Le)},function(){We.LoadBufferAsync(pe,Ce,De,Fe,Le)})},ge.LoadTextureAsync=function(pe,Ce,De,Fe){ge._LoadTextureBufferAsync(pe,Ce,function(Le){Le&&ge._CreateTextureAsync(pe,Ce,Le,De,Fe)},Fe)},ge.LoadShaderStringAsync=function(pe,Ce,De,Fe){ge._ApplyExtensions(function(Le){return Le.loadShaderStringAsync(pe,Ce,De,Fe)},function(){We.LoadShaderStringAsync(pe,Ce,De,Fe)})},ge.LoadMaterialAsync=function(pe,Ce,De,Fe){ge._ApplyExtensions(function(Le){return Le.loadMaterialAsync(pe,Ce,De,Fe)},function(){We.LoadMaterialAsync(pe,Ce,De,Fe)})},ge._LoadTextureBufferAsync=function(pe,Ce,De,Fe){ge._ApplyExtensions(function(Le){return Le.loadTextureBufferAsync(pe,Ce,De,Fe)},function(){We.LoadTextureBufferAsync(pe,Ce,De,Fe)})},ge._CreateTextureAsync=function(pe,Ce,De,Fe,Le){ge._ApplyExtensions(function(Ye){return Ye.createTextureAsync(pe,Ce,De,Fe,Le)},function(){We.CreateTextureAsync(pe,Ce,De,Fe)})},ge._ApplyExtensions=function(pe,Ce){for(var De in Xe.Extensions){var Fe=Xe.Extensions[De];if(pe(Fe))return}Ce()},ge}();me.GLTFFileLoader._CreateGLTF1Loader=function(){return new Xe}},"../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EBlendingFunction:()=>ae,EComponentType:()=>_,ECullingType:()=>ne,EParameterType:()=>j,EShaderType:()=>z,ETextureFilterType:()=>Se,ETextureFormat:()=>A,ETextureWrapMode:()=>me});var _;(function(H){H[H.BYTE=5120]="BYTE",H[H.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",H[H.SHORT=5122]="SHORT",H[H.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",H[H.FLOAT=5126]="FLOAT"})(_||(_={}));var z;(function(H){H[H.FRAGMENT=35632]="FRAGMENT",H[H.VERTEX=35633]="VERTEX"})(z||(z={}));var j;(function(H){H[H.BYTE=5120]="BYTE",H[H.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",H[H.SHORT=5122]="SHORT",H[H.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",H[H.INT=5124]="INT",H[H.UNSIGNED_INT=5125]="UNSIGNED_INT",H[H.FLOAT=5126]="FLOAT",H[H.FLOAT_VEC2=35664]="FLOAT_VEC2",H[H.FLOAT_VEC3=35665]="FLOAT_VEC3",H[H.FLOAT_VEC4=35666]="FLOAT_VEC4",H[H.INT_VEC2=35667]="INT_VEC2",H[H.INT_VEC3=35668]="INT_VEC3",H[H.INT_VEC4=35669]="INT_VEC4",H[H.BOOL=35670]="BOOL",H[H.BOOL_VEC2=35671]="BOOL_VEC2",H[H.BOOL_VEC3=35672]="BOOL_VEC3",H[H.BOOL_VEC4=35673]="BOOL_VEC4",H[H.FLOAT_MAT2=35674]="FLOAT_MAT2",H[H.FLOAT_MAT3=35675]="FLOAT_MAT3",H[H.FLOAT_MAT4=35676]="FLOAT_MAT4",H[H.SAMPLER_2D=35678]="SAMPLER_2D"})(j||(j={}));var me;(function(H){H[H.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",H[H.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",H[H.REPEAT=10497]="REPEAT"})(me||(me={}));var Se;(function(H){H[H.NEAREST=9728]="NEAREST",H[H.LINEAR=9728]="LINEAR",H[H.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",H[H.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",H[H.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",H[H.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"})(Se||(Se={}));var A;(function(H){H[H.ALPHA=6406]="ALPHA",H[H.RGB=6407]="RGB",H[H.RGBA=6408]="RGBA",H[H.LUMINANCE=6409]="LUMINANCE",H[H.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"})(A||(A={}));var ne;(function(H){H[H.FRONT=1028]="FRONT",H[H.BACK=1029]="BACK",H[H.FRONT_AND_BACK=1032]="FRONT_AND_BACK"})(ne||(ne={}));var ae;(function(H){H[H.ZERO=0]="ZERO",H[H.ONE=1]="ONE",H[H.SRC_COLOR=768]="SRC_COLOR",H[H.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",H[H.DST_COLOR=774]="DST_COLOR",H[H.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",H[H.SRC_ALPHA=770]="SRC_ALPHA",H[H.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",H[H.DST_ALPHA=772]="DST_ALPHA",H[H.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",H[H.CONSTANT_COLOR=32769]="CONSTANT_COLOR",H[H.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",H[H.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",H[H.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",H[H.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"})(ae||(ae={}))},"../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFUtils:()=>j});var _=K("../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"),z=K("babylonjs/Misc/tools"),j=function(){function me(){}return me.SetMatrix=function(Se,A,ne,ae,H){var W=null;if(ne.semantic==="MODEL"?W=A.getWorldMatrix():ne.semantic==="PROJECTION"?W=Se.getProjectionMatrix():ne.semantic==="VIEW"?W=Se.getViewMatrix():ne.semantic==="MODELVIEWINVERSETRANSPOSE"?W=z.Matrix.Transpose(A.getWorldMatrix().multiply(Se.getViewMatrix()).invert()):ne.semantic==="MODELVIEW"?W=A.getWorldMatrix().multiply(Se.getViewMatrix()):ne.semantic==="MODELVIEWPROJECTION"?W=A.getWorldMatrix().multiply(Se.getTransformMatrix()):ne.semantic==="MODELINVERSE"?W=A.getWorldMatrix().invert():ne.semantic==="VIEWINVERSE"?W=Se.getViewMatrix().invert():ne.semantic==="PROJECTIONINVERSE"?W=Se.getProjectionMatrix().invert():ne.semantic==="MODELVIEWINVERSE"?W=A.getWorldMatrix().multiply(Se.getViewMatrix()).invert():ne.semantic==="MODELVIEWPROJECTIONINVERSE"?W=A.getWorldMatrix().multiply(Se.getTransformMatrix()).invert():ne.semantic==="MODELINVERSETRANSPOSE"&&(W=z.Matrix.Transpose(A.getWorldMatrix().invert())),W)switch(ne.type){case _.EParameterType.FLOAT_MAT2:H.setMatrix2x2(ae,z.Matrix.GetAsMatrix2x2(W));break;case _.EParameterType.FLOAT_MAT3:H.setMatrix3x3(ae,z.Matrix.GetAsMatrix3x3(W));break;case _.EParameterType.FLOAT_MAT4:H.setMatrix(ae,W);break}},me.SetUniform=function(Se,A,ne,ae){switch(ae){case _.EParameterType.FLOAT:return Se.setFloat(A,ne),!0;case _.EParameterType.FLOAT_VEC2:return Se.setVector2(A,z.Vector2.FromArray(ne)),!0;case _.EParameterType.FLOAT_VEC3:return Se.setVector3(A,z.Vector3.FromArray(ne)),!0;case _.EParameterType.FLOAT_VEC4:return Se.setVector4(A,z.Vector4.FromArray(ne)),!0;default:return!1}},me.GetWrapMode=function(Se){switch(Se){case _.ETextureWrapMode.CLAMP_TO_EDGE:return z.Texture.CLAMP_ADDRESSMODE;case _.ETextureWrapMode.MIRRORED_REPEAT:return z.Texture.MIRROR_ADDRESSMODE;case _.ETextureWrapMode.REPEAT:return z.Texture.WRAP_ADDRESSMODE;default:return z.Texture.WRAP_ADDRESSMODE}},me.GetByteStrideFromType=function(Se){var A=Se.type;switch(A){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4;case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},me.GetTextureFilterMode=function(Se){switch(Se){case _.ETextureFilterType.LINEAR:case _.ETextureFilterType.LINEAR_MIPMAP_NEAREST:case _.ETextureFilterType.LINEAR_MIPMAP_LINEAR:return z.Texture.TRILINEAR_SAMPLINGMODE;case _.ETextureFilterType.NEAREST:case _.ETextureFilterType.NEAREST_MIPMAP_NEAREST:return z.Texture.NEAREST_SAMPLINGMODE;default:return z.Texture.BILINEAR_SAMPLINGMODE}},me.GetBufferFromBufferView=function(Se,A,ne,ae,H){ne=A.byteOffset+ne;var W=Se.loadedBufferViews[A.buffer];if(ne+ae>W.byteLength)throw new Error("Buffer access is out of range");var O=W.buffer;switch(ne+=W.byteOffset,H){case _.EComponentType.BYTE:return new Int8Array(O,ne,ae);case _.EComponentType.UNSIGNED_BYTE:return new Uint8Array(O,ne,ae);case _.EComponentType.SHORT:return new Int16Array(O,ne,ae);case _.EComponentType.UNSIGNED_SHORT:return new Uint16Array(O,ne,ae);default:return new Float32Array(O,ne,ae)}},me.GetBufferFromAccessor=function(Se,A){var ne=Se.bufferViews[A.bufferView],ae=A.count*me.GetByteStrideFromType(A);return me.GetBufferFromBufferView(Se,ne,A.byteOffset,ae,A.componentType)},me.DecodeBufferToText=function(Se){for(var A="",ne=Se.byteLength,ae=0;ae<ne;++ae)A+=String.fromCharCode(Se[ae]);return A},me.GetDefaultMaterial=function(Se){if(!me._DefaultMaterial){z.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join(`
|
||
`),z.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join(`
|
||
`);var A={vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},ne={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};me._DefaultMaterial=new z.ShaderMaterial("GLTFDefaultMaterial",Se,A,ne),me._DefaultMaterial.setColor4("u_emission",new z.Color4(.5,.5,.5,1))}return me._DefaultMaterial},me._DefaultMaterial=null,me}()},"../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFMaterialsCommonExtension:()=>me});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"),j=K("babylonjs/Misc/tools"),me=function(Se){(0,_.__extends)(A,Se);function A(){return Se.call(this,"KHR_materials_common")||this}return A.prototype.loadRuntimeExtensionsAsync=function(ne){if(!ne.extensions)return!1;var ae=ne.extensions[this.name];if(!ae)return!1;var H=ae.lights;if(H)for(var W in H){var O=H[W];switch(O.type){case"ambient":{var P=new j.HemisphericLight(O.name,new j.Vector3(0,1,0),ne.scene),Z=O.ambient;Z&&(P.diffuse=j.Color3.FromArray(Z.color||[1,1,1]));break}case"point":{var re=new j.PointLight(O.name,new j.Vector3(10,10,10),ne.scene),oe=O.point;oe&&(re.diffuse=j.Color3.FromArray(oe.color||[1,1,1]));break}case"directional":{var he=new j.DirectionalLight(O.name,new j.Vector3(0,-1,0),ne.scene),Ee=O.directional;Ee&&(he.diffuse=j.Color3.FromArray(Ee.color||[1,1,1]));break}case"spot":{var Oe=O.spot;if(Oe){var Pe=new j.SpotLight(O.name,new j.Vector3(0,10,0),new j.Vector3(0,-1,0),Oe.fallOffAngle||Math.PI,Oe.fallOffExponent||0,ne.scene);Pe.diffuse=j.Color3.FromArray(Oe.color||[1,1,1])}break}default:j.Tools.Warn('GLTF Material Common extension: light type "'+O.type+"” not supported");break}}return!1},A.prototype.loadMaterialAsync=function(ne,ae,H,W){var O=ne.materials[ae];if(!O||!O.extensions)return!1;var P=O.extensions[this.name];if(!P)return!1;var Z=new j.StandardMaterial(ae,ne.scene);return Z.sideOrientation=j.Material.CounterClockWiseSideOrientation,P.technique==="CONSTANT"&&(Z.disableLighting=!0),Z.backFaceCulling=P.doubleSided===void 0?!1:!P.doubleSided,Z.alpha=P.values.transparency===void 0?1:P.values.transparency,Z.specularPower=P.values.shininess===void 0?0:P.values.shininess,typeof P.values.ambient=="string"?this._loadTexture(ne,P.values.ambient,Z,"ambientTexture",W):Z.ambientColor=j.Color3.FromArray(P.values.ambient||[0,0,0]),typeof P.values.diffuse=="string"?this._loadTexture(ne,P.values.diffuse,Z,"diffuseTexture",W):Z.diffuseColor=j.Color3.FromArray(P.values.diffuse||[0,0,0]),typeof P.values.emission=="string"?this._loadTexture(ne,P.values.emission,Z,"emissiveTexture",W):Z.emissiveColor=j.Color3.FromArray(P.values.emission||[0,0,0]),typeof P.values.specular=="string"?this._loadTexture(ne,P.values.specular,Z,"specularTexture",W):Z.specularColor=j.Color3.FromArray(P.values.specular||[0,0,0]),!0},A.prototype._loadTexture=function(ne,ae,H,W,O){z.GLTFLoaderBase.LoadTextureBufferAsync(ne,ae,function(P){z.GLTFLoaderBase.CreateTextureAsync(ne,ae,P,function(Z){return H[W]=Z})},O)},A}(z.GLTFLoaderExtension);z.GLTFLoader.RegisterExtension(new me)},"../../../dev/loaders/src/glTF/1.0/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EBlendingFunction:()=>j.EBlendingFunction,EComponentType:()=>j.EComponentType,ECullingType:()=>j.ECullingType,EParameterType:()=>j.EParameterType,EShaderType:()=>j.EShaderType,ETextureFilterType:()=>j.ETextureFilterType,ETextureFormat:()=>j.ETextureFormat,ETextureWrapMode:()=>j.ETextureWrapMode,GLTFBinaryExtension:()=>_.GLTFBinaryExtension,GLTFLoader:()=>z.GLTFLoader,GLTFLoaderBase:()=>z.GLTFLoaderBase,GLTFLoaderExtension:()=>z.GLTFLoaderExtension,GLTFMaterialsCommonExtension:()=>Se.GLTFMaterialsCommonExtension,GLTFUtils:()=>me.GLTFUtils});var _=K("../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts"),z=K("../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"),me=K("../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"),Se=K("../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts")},"../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EXT_lights_image_based:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="EXT_lights_image_based",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null,delete this._lights},A.prototype.onLoading=function(){var ne=this._loader.gltf.extensions;if(ne&&ne[this.name]){var ae=ne[this.name];this._lights=ae.lights}},A.prototype.loadSceneAsync=function(ne,ae){var H=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(W,O){H._loader._allMaterialsDirtyRequired=!0;var P=new Array;P.push(H._loader.loadSceneAsync(ne,ae)),H._loader.logOpen("".concat(W));var Z=z.ArrayItem.Get("".concat(W,"/light"),H._lights,O.light);return P.push(H._loadLightAsync("/extensions/".concat(H.name,"/lights/").concat(O.light),Z).then(function(re){H._loader.babylonScene.environmentTexture=re})),H._loader.logClose(),Promise.all(P).then(function(){})})},A.prototype._loadLightAsync=function(ne,ae){var H=this;if(!ae._loaded){var W=new Array;this._loader.logOpen("".concat(ne));for(var O=new Array(ae.specularImages.length),P=function(oe){var he=ae.specularImages[oe];O[oe]=new Array(he.length);for(var Ee=function(Pe){var Ae="".concat(ne,"/specularImages/").concat(oe,"/").concat(Pe);Z._loader.logOpen("".concat(Ae));var Ue=he[Pe],je=z.ArrayItem.Get(Ae,Z._loader.gltf.images,Ue);W.push(Z._loader.loadImageAsync("/images/".concat(Ue),je).then(function(Ve){O[oe][Pe]=Ve})),Z._loader.logClose()},Oe=0;Oe<he.length;Oe++)Ee(Oe)},Z=this,re=0;re<ae.specularImages.length;re++)P(re);this._loader.logClose(),ae._loaded=Promise.all(W).then(function(){var oe=new _.RawCubeTexture(H._loader.babylonScene,null,ae.specularImageSize);if(oe.name=ae.name||"environment",ae._babylonTexture=oe,ae.intensity!=null&&(oe.level=ae.intensity),ae.rotation){var he=_.Quaternion.FromArray(ae.rotation);H._loader.babylonScene.useRightHandedSystem||(he=_.Quaternion.Inverse(he)),_.Matrix.FromQuaternionToRef(he,oe.getReflectionTextureMatrix())}if(!ae.irradianceCoefficients)throw new Error("".concat(ne,": Irradiance coefficients are missing"));var Ee=_.SphericalHarmonics.FromArray(ae.irradianceCoefficients);Ee.scaleInPlace(ae.intensity),Ee.convertIrradianceToLambertianRadiance();var Oe=_.SphericalPolynomial.FromHarmonics(Ee),Pe=(O.length-1)/Math.log2(ae.specularImageSize);return oe.updateRGBDAsync(O,Oe,Pe)})}return ae._loaded.then(function(){return ae._babylonTexture})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EXT_mesh_gpu_instancing:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="EXT_mesh_gpu_instancing",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadNodeAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){W._loader._disableInstancedMesh++;var Z=W._loader.loadNodeAsync("/nodes/".concat(ae.index),ae,H);if(W._loader._disableInstancedMesh--,!ae._primitiveBabylonMeshes)return Z;var re=new Array,oe=0,he=function(Ee){if(P.attributes[Ee]==null){re.push(Promise.resolve(null));return}var Oe=z.ArrayItem.Get("".concat(O,"/attributes/").concat(Ee),W._loader.gltf.accessors,P.attributes[Ee]);if(re.push(W._loader._loadFloatAccessorAsync("/accessors/".concat(Oe.bufferView),Oe)),oe===0)oe=Oe.count;else if(oe!==Oe.count)throw new Error("".concat(O,"/attributes: Instance buffer accessors do not have the same count."))};return he("TRANSLATION"),he("ROTATION"),he("SCALE"),Z.then(function(Ee){return Promise.all(re).then(function(Oe){var Pe=Oe[0],Ae=Oe[1],Ue=Oe[2],je=new Float32Array(oe*16);_.TmpVectors.Vector3[0].copyFromFloats(0,0,0),_.TmpVectors.Quaternion[0].copyFromFloats(0,0,0,1),_.TmpVectors.Vector3[1].copyFromFloats(1,1,1);for(var Ve=0;Ve<oe;++Ve)Pe&&_.Vector3.FromArrayToRef(Pe,Ve*3,_.TmpVectors.Vector3[0]),Ae&&_.Quaternion.FromArrayToRef(Ae,Ve*4,_.TmpVectors.Quaternion[0]),Ue&&_.Vector3.FromArrayToRef(Ue,Ve*3,_.TmpVectors.Vector3[1]),_.Matrix.ComposeToRef(_.TmpVectors.Vector3[1],_.TmpVectors.Quaternion[0],_.TmpVectors.Vector3[0],_.TmpVectors.Matrix[0]),_.TmpVectors.Matrix[0].copyToArray(je,Ve*16);for(var ot=0,it=ae._primitiveBabylonMeshes;ot<it.length;ot++){var ft=it[ot];ft.thinInstanceSetBuffer("matrix",je,16,!0)}return Ee})})})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EXT_meshopt_compression:()=>Se});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="EXT_meshopt_compression",Se=function(){function A(ne){this.name=me,this.enabled=ne.isExtensionUsed(me),this._loader=ne}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadBufferViewAsync=function(ne,ae){var H=this;return _.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(W,O){var P=ae;if(P._meshOptData)return P._meshOptData;var Z=_.ArrayItem.Get("".concat(ne,"/buffer"),H._loader.gltf.buffers,O.buffer);return P._meshOptData=H._loader.loadBufferAsync("/buffers/".concat(Z.index),Z,O.byteOffset||0,O.byteLength).then(function(re){return z.MeshoptCompression.Default.decodeGltfBufferAsync(re,O.count,O.byteStride,O.mode,O.filter)}),P._meshOptData})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_avif.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EXT_texture_avif:()=>me});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),j="EXT_texture_avif",me=function(){function Se(A){this.name=j,this._loader=A,this.enabled=A.isExtensionUsed(j)}return Se.prototype.dispose=function(){this._loader=null},Se.prototype._loadTextureAsync=function(A,ne,ae){var H=this;return _.GLTFLoader.LoadExtensionAsync(A,ne,this.name,function(W,O){var P=ne.sampler==null?_.GLTFLoader.DefaultSampler:_.ArrayItem.Get("".concat(A,"/sampler"),H._loader.gltf.samplers,ne.sampler),Z=_.ArrayItem.Get("".concat(W,"/source"),H._loader.gltf.images,O.source);return H._loader._createTextureAsync(A,P,Z,function(re){ae(re)},void 0,!ne._textureInfo.nonColorData)})},Se}();(0,z.unregisterGLTFExtension)(j),(0,z.registerGLTFExtension)(j,!0,function(Se){return new me(Se)})},"../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EXT_texture_webp:()=>me});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),j="EXT_texture_webp",me=function(){function Se(A){this.name=j,this._loader=A,this.enabled=A.isExtensionUsed(j)}return Se.prototype.dispose=function(){this._loader=null},Se.prototype._loadTextureAsync=function(A,ne,ae){var H=this;return _.GLTFLoader.LoadExtensionAsync(A,ne,this.name,function(W,O){var P=ne.sampler==null?_.GLTFLoader.DefaultSampler:_.ArrayItem.Get("".concat(A,"/sampler"),H._loader.gltf.samplers,ne.sampler),Z=_.ArrayItem.Get("".concat(W,"/source"),H._loader.gltf.images,O.source);return H._loader._createTextureAsync(A,P,Z,function(re){ae(re)},void 0,!ne._textureInfo.nonColorData)})},Se}();(0,z.unregisterGLTFExtension)(j),(0,z.registerGLTFExtension)(j,!0,function(Se){return new me(Se)})},"../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{ExtrasAsMetadata:()=>j});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),z="ExtrasAsMetadata",j=function(){function me(Se){this.name=z,this.enabled=!0,this._loader=Se}return me.prototype._assignExtras=function(Se,A){if(A.extras&&Object.keys(A.extras).length>0){var ne=Se.metadata=Se.metadata||{},ae=ne.gltf=ne.gltf||{};ae.extras=A.extras}},me.prototype.dispose=function(){this._loader=null},me.prototype.loadNodeAsync=function(Se,A,ne){var ae=this;return this._loader.loadNodeAsync(Se,A,function(H){ae._assignExtras(H,A),ne(H)})},me.prototype.loadCameraAsync=function(Se,A,ne){var ae=this;return this._loader.loadCameraAsync(Se,A,function(H){ae._assignExtras(H,A),ne(H)})},me.prototype.createMaterial=function(Se,A,ne){var ae=this._loader.createMaterial(Se,A,ne);return this._assignExtras(ae,A),ae},me}();(0,_.unregisterGLTFExtension)(z),(0,_.registerGLTFExtension)(z,!1,function(me){return new j(me)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{animationPointerTree:()=>Oe});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts");function me(Pe,Ae,Ue,je){return z.Color3.FromArray(Ae,Ue).scale(je)}function Se(Pe,Ae,Ue,je){return Ae[Ue+3]*je}function A(Pe,Ae,Ue,je){return Ae[Ue]*je}function ne(Pe,Ae,Ue,je){return-Ae[Ue]*je}function ae(Pe,Ae,Ue,je){return Ae[Ue+1]*je}function H(Pe,Ae,Ue,je){return Ae[Ue]*je*2}function W(Pe){return{scale:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"".concat(Pe,".uScale"),A,function(){return 2}),new P(z.Animation.ANIMATIONTYPE_FLOAT,"".concat(Pe,".vScale"),ae,function(){return 2})],offset:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"".concat(Pe,".uOffset"),A,function(){return 2}),new P(z.Animation.ANIMATIONTYPE_FLOAT,"".concat(Pe,".vOffset"),ae,function(){return 2})],rotation:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"".concat(Pe,".wAng"),ne,function(){return 1})]}}var O=function(Pe){(0,_.__extends)(Ae,Pe);function Ae(){return Pe!==null&&Pe.apply(this,arguments)||this}return Ae.prototype.buildAnimations=function(Ue,je,Ve,ot,it){it(Ue._babylonCamera,this._buildAnimation(je,Ve,ot))},Ae}(j.AnimationPropertyInfo),P=function(Pe){(0,_.__extends)(Ae,Pe);function Ae(){return Pe!==null&&Pe.apply(this,arguments)||this}return Ae.prototype.buildAnimations=function(Ue,je,Ve,ot,it){for(var ft in Ue._data)it(Ue._data[ft].babylonMaterial,this._buildAnimation(je,Ve,ot))},Ae}(j.AnimationPropertyInfo),Z=function(Pe){(0,_.__extends)(Ae,Pe);function Ae(){return Pe!==null&&Pe.apply(this,arguments)||this}return Ae.prototype.buildAnimations=function(Ue,je,Ve,ot,it){it(Ue._babylonLight,this._buildAnimation(je,Ve,ot))},Ae}(j.AnimationPropertyInfo),re={__array__:(0,_.__assign)({__target__:!0},j.nodeAnimationData)},oe={__array__:{__target__:!0,orthographic:{xmag:[new O(z.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",ne,function(){return 1}),new O(z.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",ae,function(){return 1})],ymag:[new O(z.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",ne,function(){return 1}),new O(z.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",ae,function(){return 1})],zfar:[new O(z.Animation.ANIMATIONTYPE_FLOAT,"maxZ",A,function(){return 1})],znear:[new O(z.Animation.ANIMATIONTYPE_FLOAT,"minZ",A,function(){return 1})]},perspective:{yfov:[new O(z.Animation.ANIMATIONTYPE_FLOAT,"fov",A,function(){return 1})],zfar:[new O(z.Animation.ANIMATIONTYPE_FLOAT,"maxZ",A,function(){return 1})],znear:[new O(z.Animation.ANIMATIONTYPE_FLOAT,"minZ",A,function(){return 1})]}}},he={__array__:{__target__:!0,pbrMetallicRoughness:{baseColorFactor:[new P(z.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",me,function(){return 4}),new P(z.Animation.ANIMATIONTYPE_FLOAT,"alpha",Se,function(){return 4})],metallicFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"metallic",A,function(){return 1})],roughnessFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"roughness",A,function(){return 1})],baseColorTexture:{extensions:{KHR_texture_transform:W("albedoTexture")}},metallicRoughnessTexture:{extensions:{KHR_texture_transform:W("metallicTexture")}}},emissiveFactor:[new P(z.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",me,function(){return 3})],normalTexture:{scale:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",A,function(){return 1})],extensions:{KHR_texture_transform:W("bumpTexture")}},occlusionTexture:{strength:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",A,function(){return 1})],extensions:{KHR_texture_transform:W("ambientTexture")}},emissiveTexture:{extensions:{KHR_texture_transform:W("emissiveTexture")}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",A,function(){return 1})],anisotropyRotation:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",A,function(){return 1})],anisotropyTexture:{extensions:{KHR_texture_transform:W("anisotropy.texture")}}},KHR_materials_clearcoat:{clearcoatFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",A,function(){return 1})],clearcoatRoughnessFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",A,function(){return 1})],clearcoatTexture:{extensions:{KHR_texture_transform:W("clearCoat.texture")}},clearcoatNormalTexture:{scale:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",A,function(){return 1})],extensions:{KHR_texture_transform:W("clearCoat.bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:W("clearCoat.textureRoughness")}}},KHR_materials_dispersion:{dispersion:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",A,function(){return 1})]},KHR_materials_emissive_strength:{emissiveStrength:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",A,function(){return 1})]},KHR_materials_ior:{ior:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",A,function(){return 1})]},KHR_materials_iridescence:{iridescenceFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",A,function(){return 1})],iridescenceIor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",A,function(){return 1})],iridescenceThicknessMinimum:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",A,function(){return 1})],iridescenceThicknessMaximum:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",A,function(){return 1})],iridescenceTexture:{extensions:{KHR_texture_transform:W("iridescence.texture")}},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:W("iridescence.thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:[new P(z.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",me,function(){return 3})],sheenRoughnessFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",A,function(){return 1})],sheenColorTexture:{extensions:{KHR_texture_transform:W("sheen.texture")}},sheenRoughnessTexture:{extensions:{KHR_texture_transform:W("sheen.textureRoughness")}}},KHR_materials_specular:{specularFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",A,function(){return 1})],specularColorFactor:[new P(z.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",me,function(){return 3})],specularTexture:{extensions:{KHR_texture_transform:W("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:W("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",A,function(){return 1})],transmissionTexture:{extensions:{KHR_texture_transform:W("subSurface.refractionIntensityTexture")}}},KHR_materials_volume:{attenuationColor:[new P(z.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",me,function(){return 3})],attenuationDistance:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",A,function(){return 1})],thicknessFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",A,function(){return 1})],thicknessTexture:{extensions:{KHR_texture_transform:W("subSurface.thicknessTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:[new P(z.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",A,function(){return 1})],diffuseTransmissionTexture:{extensions:{KHR_texture_transform:W("subSurface.translucencyIntensityTexture")}},diffuseTransmissionColorFactor:[new P(z.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",me,function(){return 3})],diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:W("subSurface.translucencyColorTexture")}}}}}},Ee={KHR_lights_punctual:{lights:{__array__:{__target__:!0,color:[new Z(z.Animation.ANIMATIONTYPE_COLOR3,"diffuse",me,function(){return 3})],intensity:[new Z(z.Animation.ANIMATIONTYPE_FLOAT,"intensity",A,function(){return 1})],range:[new Z(z.Animation.ANIMATIONTYPE_FLOAT,"range",A,function(){return 1})],spot:{innerConeAngle:[new Z(z.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",H,function(){return 1})],outerConeAngle:[new Z(z.Animation.ANIMATIONTYPE_FLOAT,"angle",H,function(){return 1})]}}}}},Oe={nodes:re,materials:he,cameras:oe,extensions:Ee}},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_animation_pointer:()=>ae});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts"),me=K("../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"),Se=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),A="KHR_animation_pointer",ne=function(H){(0,_.__extends)(W,H);function W(O){return H.call(this,O,j.animationPointerTree)||this}return W}(me.GLTFPathToObjectConverter),ae=function(){function H(W){this.name=A,this._loader=W,this._pathToObjectConverter=new ne(this._loader.gltf)}return Object.defineProperty(H.prototype,"enabled",{get:function(){return this._loader.isExtensionUsed(A)},enumerable:!1,configurable:!0}),H.prototype.dispose=function(){this._loader=null,delete this._pathToObjectConverter},H.prototype._loadAnimationChannelAsync=function(W,O,P,Z,re){var oe,he=(oe=Z.target.extensions)===null||oe===void 0?void 0:oe.KHR_animation_pointer;if(!he||!this._pathToObjectConverter)return null;Z.target.path!=="pointer"&&z.Logger.Warn("".concat(W,"/target/path: Value (").concat(Z.target.path,") must be (").concat("pointer",") when using the ").concat(this.name," extension")),Z.target.node!=null&&z.Logger.Warn("".concat(W,"/target/node: Value (").concat(Z.target.node,") must not be present when using the ").concat(this.name," extension"));var Ee="".concat(W,"/extensions/").concat(this.name),Oe=he.pointer;if(!Oe)throw new Error("".concat(Ee,": Pointer is missing"));try{var Pe=this._pathToObjectConverter.convert(Oe);return this._loader._loadAnimationChannelFromTargetInfoAsync(W,O,P,Z,Pe,re)}catch{return z.Logger.Warn("".concat(Ee,"/pointer: Invalid pointer (").concat(Oe,") skipped")),null}},H}();(0,Se.unregisterGLTFExtension)(A),(0,Se.registerGLTFExtension)(A,!0,function(H){return new ae(H)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_draco_mesh_compression:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_draco_mesh_compression",Se=function(){function A(ne){this.name=me,this.useNormalizedFlagFromAccessor=!0,this._loader=ne,this.enabled=_.DracoCompression.DecoderAvailable&&this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){delete this.dracoCompression,this._loader=null},A.prototype._loadVertexDataAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){if(ae.mode!=null&&ae.mode!==4&&ae.mode!==5)throw new Error("".concat(ne,": Unsupported mode ").concat(ae.mode));var Z={},re={},oe=function(Ee,Oe){var Pe=P.attributes[Ee];if(Pe!=null&&(H._delayInfo=H._delayInfo||[],H._delayInfo.indexOf(Oe)===-1&&H._delayInfo.push(Oe),Z[Oe]=Pe,W.useNormalizedFlagFromAccessor)){var Ae=z.ArrayItem.TryGet(W._loader.gltf.accessors,ae.attributes[Ee]);Ae&&(re[Oe]=Ae.normalized||!1)}};oe("POSITION",_.VertexBuffer.PositionKind),oe("NORMAL",_.VertexBuffer.NormalKind),oe("TANGENT",_.VertexBuffer.TangentKind),oe("TEXCOORD_0",_.VertexBuffer.UVKind),oe("TEXCOORD_1",_.VertexBuffer.UV2Kind),oe("TEXCOORD_2",_.VertexBuffer.UV3Kind),oe("TEXCOORD_3",_.VertexBuffer.UV4Kind),oe("TEXCOORD_4",_.VertexBuffer.UV5Kind),oe("TEXCOORD_5",_.VertexBuffer.UV6Kind),oe("JOINTS_0",_.VertexBuffer.MatricesIndicesKind),oe("WEIGHTS_0",_.VertexBuffer.MatricesWeightsKind),oe("COLOR_0",_.VertexBuffer.ColorKind);var he=z.ArrayItem.Get(O,W._loader.gltf.bufferViews,P.bufferView);return he._dracoBabylonGeometry||(he._dracoBabylonGeometry=W._loader.loadBufferViewAsync("/bufferViews/".concat(he.index),he).then(function(Ee){var Oe=W.dracoCompression||_.DracoCompression.Default;return Oe._decodeMeshToGeometryForGltfAsync(H.name,W._loader.babylonScene,Ee,Z,re).catch(function(Pe){throw new Error("".concat(ne,": ").concat(Pe.message))})})),he._dracoBabylonGeometry})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_interactivity:()=>A});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"),j=K("../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts"),me=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),Se="KHR_interactivity",A=function(){function ne(ae){this._loader=ae,this.name=Se,this.enabled=this._loader.isExtensionUsed(Se),this._pathConverter=new j.InteractivityPathToObjectConverter(this._loader.gltf)}return ne.prototype.dispose=function(){this._loader=null,delete this._pathConverter},ne.prototype.onReady=function(){var ae;if(!(!this._loader.babylonScene||!this._pathConverter)){var H=this._loader.babylonScene,W=(ae=this._loader.gltf.extensions)===null||ae===void 0?void 0:ae.KHR_interactivity,O=(0,z.convertGLTFToSerializedFlowGraph)(W),P=new _.FlowGraphCoordinator({scene:H});_.FlowGraph.Parse(O,{coordinator:P,pathConverter:this._pathConverter}),P.start()}},ne}();(0,me.unregisterGLTFExtension)(Se),(0,me.registerGLTFExtension)(Se,!0,function(ne){return new A(ne)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_lights:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_lights_punctual",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null,delete this._lights},A.prototype.onLoading=function(){var ne=this._loader.gltf.extensions;if(ne&&ne[this.name]){var ae=ne[this.name];this._lights=ae.lights,z.ArrayItem.Assign(this._lights)}},A.prototype.loadNodeAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){return W._loader._allMaterialsDirtyRequired=!0,W._loader.loadNodeAsync(ne,ae,function(Z){var re,oe=z.ArrayItem.Get(O,W._lights,P.light),he=oe.name||Z.name;switch(W._loader.babylonScene._blockEntityCollection=!!W._loader._assetContainer,oe.type){case"directional":{var Ee=new _.DirectionalLight(he,_.Vector3.Backward(),W._loader.babylonScene);Ee.position.setAll(0),re=Ee;break}case"point":{re=new _.PointLight(he,_.Vector3.Zero(),W._loader.babylonScene);break}case"spot":{var Oe=new _.SpotLight(he,_.Vector3.Zero(),_.Vector3.Backward(),0,1,W._loader.babylonScene);Oe.angle=(oe.spot&&oe.spot.outerConeAngle||Math.PI/4)*2,Oe.innerAngle=(oe.spot&&oe.spot.innerConeAngle||0)*2,re=Oe;break}default:throw W._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(O,": Invalid light type (").concat(oe.type,")"))}re._parentContainer=W._loader._assetContainer,W._loader.babylonScene._blockEntityCollection=!1,oe._babylonLight=re,re.falloffType=_.Light.FALLOFF_GLTF,re.diffuse=oe.color?_.Color3.FromArray(oe.color):_.Color3.White(),re.intensity=oe.intensity==null?1:oe.intensity,re.range=oe.range==null?Number.MAX_VALUE:oe.range,re.parent=Z,W._loader._babylonLights.push(re),z.GLTFLoader.AddPointerMetadata(re,O),H(Z)})})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_anisotropy:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_anisotropy",Se=function(){function A(ne){this.name=me,this.order=195,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadIridescencePropertiesAsync(O,P,H)),Promise.all(Z).then(function(){})})},A.prototype._loadIridescencePropertiesAsync=function(ne,ae,H){var W,O;if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var P=new Array;return H.anisotropy.isEnabled=!0,H.anisotropy.intensity=(W=ae.anisotropyStrength)!==null&&W!==void 0?W:0,H.anisotropy.angle=(O=ae.anisotropyRotation)!==null&&O!==void 0?O:0,ae.anisotropyTexture&&P.push(this._loader.loadTextureInfoAsync("".concat(ne,"/anisotropyTexture"),ae.anisotropyTexture,function(Z){Z.name="".concat(H.name," (Anisotropy Intensity)"),H.anisotropy.texture=Z})),Promise.all(P).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_clearcoat:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_clearcoat",Se=function(){function A(ne){this.name=me,this.order=190,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadClearCoatPropertiesAsync(O,P,H)),Promise.all(Z).then(function(){})})},A.prototype._loadClearCoatPropertiesAsync=function(ne,ae,H){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var W=new Array;return H.clearCoat.isEnabled=!0,H.clearCoat.useRoughnessFromMainTexture=!1,H.clearCoat.remapF0OnInterfaceChange=!1,ae.clearcoatFactor!=null?H.clearCoat.intensity=ae.clearcoatFactor:H.clearCoat.intensity=0,ae.clearcoatTexture&&W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/clearcoatTexture"),ae.clearcoatTexture,function(O){O.name="".concat(H.name," (ClearCoat)"),H.clearCoat.texture=O})),ae.clearcoatRoughnessFactor!=null?H.clearCoat.roughness=ae.clearcoatRoughnessFactor:H.clearCoat.roughness=0,ae.clearcoatRoughnessTexture&&(ae.clearcoatRoughnessTexture.nonColorData=!0,W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/clearcoatRoughnessTexture"),ae.clearcoatRoughnessTexture,function(O){O.name="".concat(H.name," (ClearCoat Roughness)"),H.clearCoat.textureRoughness=O}))),ae.clearcoatNormalTexture&&(ae.clearcoatNormalTexture.nonColorData=!0,W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/clearcoatNormalTexture"),ae.clearcoatNormalTexture,function(O){O.name="".concat(H.name," (ClearCoat Normal)"),H.clearCoat.bumpTexture=O})),H.invertNormalMapX=!H.getScene().useRightHandedSystem,H.invertNormalMapY=H.getScene().useRightHandedSystem,ae.clearcoatNormalTexture.scale!=null&&(H.clearCoat.bumpTexture.level=ae.clearcoatNormalTexture.scale)),Promise.all(W).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_diffuse_transmission:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_diffuse_transmission",Se=function(){function A(ne){this.name=me,this.order=174,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me),this.enabled&&(ne.parent.transparencyAsCoverage=!0)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadTranslucentPropertiesAsync(O,ae,H,P)),Promise.all(Z).then(function(){})})},A.prototype._loadTranslucentPropertiesAsync=function(ne,ae,H,W){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var O=H;if(O.subSurface.isTranslucencyEnabled=!0,O.subSurface.volumeIndexOfRefraction=1,O.subSurface.minimumThickness=0,O.subSurface.maximumThickness=0,O.subSurface.useAlbedoToTintTranslucency=!1,W.diffuseTransmissionFactor!==void 0)O.subSurface.translucencyIntensity=W.diffuseTransmissionFactor;else return O.subSurface.translucencyIntensity=0,O.subSurface.isTranslucencyEnabled=!1,Promise.resolve();var P=new Array;return O.subSurface.useGltfStyleTextures=!0,W.diffuseTransmissionTexture&&(W.diffuseTransmissionTexture.nonColorData=!0,P.push(this._loader.loadTextureInfoAsync("".concat(ne,"/diffuseTransmissionTexture"),W.diffuseTransmissionTexture).then(function(Z){Z.name="".concat(H.name," (Diffuse Transmission)"),O.subSurface.translucencyIntensityTexture=Z}))),W.diffuseTransmissionColorFactor!==void 0?O.subSurface.translucencyColor=_.Color3.FromArray(W.diffuseTransmissionColorFactor):O.subSurface.translucencyColor=_.Color3.White(),W.diffuseTransmissionColorTexture&&P.push(this._loader.loadTextureInfoAsync("".concat(ne,"/diffuseTransmissionColorTexture"),W.diffuseTransmissionColorTexture).then(function(Z){Z.name="".concat(H.name," (Diffuse Transmission Color)"),O.subSurface.translucencyColorTexture=Z})),Promise.all(P).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_dispersion:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_dispersion",Se=function(){function A(ne){this.name=me,this.order=174,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadDispersionPropertiesAsync(O,ae,H,P)),Promise.all(Z).then(function(){})})},A.prototype._loadDispersionPropertiesAsync=function(ne,ae,H,W){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));return!H.subSurface.isRefractionEnabled||!W.dispersion||(H.subSurface.isDispersionEnabled=!0,H.subSurface.dispersion=W.dispersion),Promise.resolve()},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_emissive_strength:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_emissive_strength",Se=function(){function A(ne){this.name=me,this.order=170,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){return W._loader.loadMaterialPropertiesAsync(ne,ae,H).then(function(){W._loadEmissiveProperties(O,P,H)})})},A.prototype._loadEmissiveProperties=function(ne,ae,H){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));ae.emissiveStrength!==void 0&&(H.emissiveIntensity=ae.emissiveStrength)},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_ior:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_ior",Se=function(){function A(ne){this.name=me,this.order=180,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadIorPropertiesAsync(O,P,H)),Promise.all(Z).then(function(){})})},A.prototype._loadIorPropertiesAsync=function(ne,ae,H){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));return ae.ior!==void 0?H.indexOfRefraction=ae.ior:H.indexOfRefraction=A._DEFAULT_IOR,Promise.resolve()},A._DEFAULT_IOR=1.5,A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_iridescence:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_iridescence",Se=function(){function A(ne){this.name=me,this.order=195,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadIridescencePropertiesAsync(O,P,H)),Promise.all(Z).then(function(){})})},A.prototype._loadIridescencePropertiesAsync=function(ne,ae,H){var W,O,P,Z,re;if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var oe=new Array;return H.iridescence.isEnabled=!0,H.iridescence.intensity=(W=ae.iridescenceFactor)!==null&&W!==void 0?W:0,H.iridescence.indexOfRefraction=(P=(O=ae.iridescenceIor)!==null&&O!==void 0?O:ae.iridescenceIOR)!==null&&P!==void 0?P:1.3,H.iridescence.minimumThickness=(Z=ae.iridescenceThicknessMinimum)!==null&&Z!==void 0?Z:100,H.iridescence.maximumThickness=(re=ae.iridescenceThicknessMaximum)!==null&&re!==void 0?re:400,ae.iridescenceTexture&&oe.push(this._loader.loadTextureInfoAsync("".concat(ne,"/iridescenceTexture"),ae.iridescenceTexture,function(he){he.name="".concat(H.name," (Iridescence)"),H.iridescence.texture=he})),ae.iridescenceThicknessTexture&&oe.push(this._loader.loadTextureInfoAsync("".concat(ne,"/iridescenceThicknessTexture"),ae.iridescenceThicknessTexture,function(he){he.name="".concat(H.name," (Iridescence Thickness)"),H.iridescence.thicknessTexture=he})),Promise.all(oe).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_pbrSpecularGlossiness:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_pbrSpecularGlossiness",Se=function(){function A(ne){this.name=me,this.order=200,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialBasePropertiesAsync(ne,ae,H)),Z.push(W._loadSpecularGlossinessPropertiesAsync(O,P,H)),W._loader.loadMaterialAlphaProperties(ne,ae,H),Promise.all(Z).then(function(){})})},A.prototype._loadSpecularGlossinessPropertiesAsync=function(ne,ae,H){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var W=new Array;return H.metallic=null,H.roughness=null,ae.diffuseFactor?(H.albedoColor=_.Color3.FromArray(ae.diffuseFactor),H.alpha=ae.diffuseFactor[3]):H.albedoColor=_.Color3.White(),H.reflectivityColor=ae.specularFactor?_.Color3.FromArray(ae.specularFactor):_.Color3.White(),H.microSurface=ae.glossinessFactor==null?1:ae.glossinessFactor,ae.diffuseTexture&&W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/diffuseTexture"),ae.diffuseTexture,function(O){O.name="".concat(H.name," (Diffuse)"),H.albedoTexture=O})),ae.specularGlossinessTexture&&(W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/specularGlossinessTexture"),ae.specularGlossinessTexture,function(O){O.name="".concat(H.name," (Specular Glossiness)"),H.reflectivityTexture=O,H.reflectivityTexture.hasAlpha=!0})),H.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(W).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_sheen:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_sheen",Se=function(){function A(ne){this.name=me,this.order=190,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadSheenPropertiesAsync(O,P,H)),Promise.all(Z).then(function(){})})},A.prototype._loadSheenPropertiesAsync=function(ne,ae,H){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var W=new Array;return H.sheen.isEnabled=!0,H.sheen.intensity=1,ae.sheenColorFactor!=null?H.sheen.color=_.Color3.FromArray(ae.sheenColorFactor):H.sheen.color=_.Color3.Black(),ae.sheenColorTexture&&W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/sheenColorTexture"),ae.sheenColorTexture,function(O){O.name="".concat(H.name," (Sheen Color)"),H.sheen.texture=O})),ae.sheenRoughnessFactor!==void 0?H.sheen.roughness=ae.sheenRoughnessFactor:H.sheen.roughness=0,ae.sheenRoughnessTexture&&(ae.sheenRoughnessTexture.nonColorData=!0,W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/sheenRoughnessTexture"),ae.sheenRoughnessTexture,function(O){O.name="".concat(H.name," (Sheen Roughness)"),H.sheen.textureRoughness=O}))),H.sheen.albedoScaling=!0,H.sheen.useRoughnessFromMainTexture=!1,Promise.all(W).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_specular:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_specular",Se=function(){function A(ne){this.name=me,this.order=190,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadSpecularPropertiesAsync(O,P,H)),Promise.all(Z).then(function(){})})},A.prototype._loadSpecularPropertiesAsync=function(ne,ae,H){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var W=new Array;return ae.specularFactor!==void 0&&(H.metallicF0Factor=ae.specularFactor),ae.specularColorFactor!==void 0&&(H.metallicReflectanceColor=_.Color3.FromArray(ae.specularColorFactor)),ae.specularTexture&&(ae.specularTexture.nonColorData=!0,W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/specularTexture"),ae.specularTexture,function(O){O.name="".concat(H.name," (Specular)"),H.metallicReflectanceTexture=O,H.useOnlyMetallicFromMetallicReflectanceTexture=!0}))),ae.specularColorTexture&&W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/specularColorTexture"),ae.specularColorTexture,function(O){O.name="".concat(H.name," (Specular Color)"),H.reflectanceTexture=O})),Promise.all(W).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_transmission:()=>ne});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),me=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),Se=function(){function ae(H,W){var O=this;this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._options=(0,_.__assign)((0,_.__assign)({},ae._GetDefaultOptions()),H),this._scene=W,this._scene._transmissionHelper=this,this.onErrorObservable=new z.Observable,this._scene.onDisposeObservable.addOnce(function(){O.dispose()}),this._parseScene(),this._setupRenderTargets()}return ae._GetDefaultOptions=function(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:z.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}},ae.prototype.updateOptions=function(H){var W=this,O=Object.keys(H).filter(function(re){return W._options[re]!==H[re]});if(O.length){var P=(0,_.__assign)((0,_.__assign)({},this._options),H),Z=this._options;this._options=P,P.renderSize!==Z.renderSize||P.renderTargetTextureType!==Z.renderTargetTextureType||P.generateMipmaps!==Z.generateMipmaps||!this._opaqueRenderTarget?this._setupRenderTargets():(this._opaqueRenderTarget.samples=P.samples,this._opaqueRenderTarget.lodGenerationScale=P.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=P.lodGenerationOffset)}},ae.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},ae.prototype._shouldRenderAsTransmission=function(H){return H?!!(H instanceof z.PBRMaterial&&H.subSurface.isRefractionEnabled):!1},ae.prototype._addMesh=function(H){var W=this;this._materialObservers[H.uniqueId]=H.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),z.Tools.SetImmediate(function(){W._shouldRenderAsTransmission(H.material)?(H.material.refractionTexture=W._opaqueRenderTarget,W._transparentMeshesCache.indexOf(H)===-1&&W._transparentMeshesCache.push(H)):W._opaqueMeshesCache.indexOf(H)===-1&&W._opaqueMeshesCache.push(H)})},ae.prototype._removeMesh=function(H){H.onMaterialChangedObservable.remove(this._materialObservers[H.uniqueId]),delete this._materialObservers[H.uniqueId];var W=this._transparentMeshesCache.indexOf(H);W!==-1&&this._transparentMeshesCache.splice(W,1),W=this._opaqueMeshesCache.indexOf(H),W!==-1&&this._opaqueMeshesCache.splice(W,1)},ae.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},ae.prototype._onMeshMaterialChanged=function(H){var W=this._transparentMeshesCache.indexOf(H),O=this._opaqueMeshesCache.indexOf(H),P=this._shouldRenderAsTransmission(H.material);P?(H.material instanceof z.PBRMaterial&&(H.material.subSurface.refractionTexture=this._opaqueRenderTarget),O!==-1?(this._opaqueMeshesCache.splice(O,1),this._transparentMeshesCache.push(H)):W===-1&&this._transparentMeshesCache.push(H)):W!==-1?(this._transparentMeshesCache.splice(W,1),this._opaqueMeshesCache.push(H)):O===-1&&this._opaqueMeshesCache.push(H)},ae.prototype._isRenderTargetValid=function(){var H;return((H=this._opaqueRenderTarget)===null||H===void 0?void 0:H.getInternalTexture())!==null},ae.prototype._setupRenderTargets=function(){var H=this,W,O;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new z.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=(O=(W=this._options.clearColor)===null||W===void 0?void 0:W.clone())!==null&&O!==void 0?O:this._scene.clearColor.clone(),this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.renderSprites=!0,this._opaqueRenderTarget.renderParticles=!0;var P,Z;this._opaqueRenderTarget.onBeforeBindObservable.add(function(re){Z=H._scene.environmentIntensity,H._scene.environmentIntensity=1,P=H._scene.imageProcessingConfiguration.applyByPostProcess,H._options.clearColor?re.clearColor.copyFrom(H._options.clearColor):H._scene.clearColor.toLinearSpaceToRef(re.clearColor,H._scene.getEngine().useExactSrgbConversions),H._scene.imageProcessingConfiguration._applyByPostProcess=!0}),this._opaqueRenderTarget.onAfterUnbindObservable.add(function(){H._scene.environmentIntensity=Z,H._scene.imageProcessingConfiguration._applyByPostProcess=P}),this._transparentMeshesCache.forEach(function(re){H._shouldRenderAsTransmission(re.material)&&(re.material.refractionTexture=H._opaqueRenderTarget)})},ae.prototype.dispose=function(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[]},ae}(),A="KHR_materials_transmission",ne=function(){function ae(H){this.name=A,this.order=175,this._loader=H,this.enabled=this._loader.isExtensionUsed(A),this.enabled&&(H.parent.transparencyAsCoverage=!0)}return ae.prototype.dispose=function(){this._loader=null},ae.prototype.loadMaterialPropertiesAsync=function(H,W,O){var P=this;return j.GLTFLoader.LoadExtensionAsync(H,W,this.name,function(Z,re){var oe=new Array;return oe.push(P._loader.loadMaterialPropertiesAsync(H,W,O)),oe.push(P._loadTransparentPropertiesAsync(Z,W,O,re)),Promise.all(oe).then(function(){})})},ae.prototype._loadTransparentPropertiesAsync=function(H,W,O,P){var Z,re;if(!(O instanceof z.PBRMaterial))throw new Error("".concat(H,": Material type not supported"));var oe=O;if(oe.subSurface.isRefractionEnabled=!0,oe.subSurface.volumeIndexOfRefraction=1,oe.subSurface.useAlbedoToTintRefraction=!0,P.transmissionFactor!==void 0){oe.subSurface.refractionIntensity=P.transmissionFactor;var he=oe.getScene();oe.subSurface.refractionIntensity&&!he._transmissionHelper?new Se({},oe.getScene()):oe.subSurface.refractionIntensity&&!(!((Z=he._transmissionHelper)===null||Z===void 0)&&Z._isRenderTargetValid())&&((re=he._transmissionHelper)===null||re===void 0||re._setupRenderTargets())}else return oe.subSurface.refractionIntensity=0,oe.subSurface.isRefractionEnabled=!1,Promise.resolve();return oe.subSurface.minimumThickness=0,oe.subSurface.maximumThickness=0,P.transmissionTexture?(P.transmissionTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(H,"/transmissionTexture"),P.transmissionTexture,void 0).then(function(Ee){Ee.name="".concat(O.name," (Transmission)"),oe.subSurface.refractionIntensityTexture=Ee,oe.subSurface.useGltfStyleTextures=!0})):Promise.resolve()},ae}();(0,me.unregisterGLTFExtension)(A),(0,me.registerGLTFExtension)(A,!0,function(ae){return new ne(ae)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_unlit:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_unlit",Se=function(){function A(ne){this.name=me,this.order=210,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(){return W._loadUnlitPropertiesAsync(ne,ae,H)})},A.prototype._loadUnlitPropertiesAsync=function(ne,ae,H){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));var W=new Array;H.unlit=!0;var O=ae.pbrMetallicRoughness;return O&&(O.baseColorFactor?(H.albedoColor=_.Color3.FromArray(O.baseColorFactor),H.alpha=O.baseColorFactor[3]):H.albedoColor=_.Color3.White(),O.baseColorTexture&&W.push(this._loader.loadTextureInfoAsync("".concat(ne,"/baseColorTexture"),O.baseColorTexture,function(P){P.name="".concat(H.name," (Base Color)"),H.albedoTexture=P}))),ae.doubleSided&&(H.backFaceCulling=!1,H.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(ne,ae,H),Promise.all(W).then(function(){})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_variants:()=>Se});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_variants",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.GetAvailableVariants=function(ne){var ae=this._GetExtensionMetadata(ne);return ae?Object.keys(ae.variants):[]},A.prototype.getAvailableVariants=function(ne){return A.GetAvailableVariants(ne)},A.SelectVariant=function(ne,ae){var H=this._GetExtensionMetadata(ne);if(!H)throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(me," extension"));var W=function(re){var oe=H.variants[re];if(oe)for(var he=0,Ee=oe;he<Ee.length;he++){var Oe=Ee[he];Oe.mesh.material=Oe.material}};if(ae instanceof Array)for(var O=0,P=ae;O<P.length;O++){var Z=P[O];W(Z)}else W(ae);H.lastSelected=ae},A.prototype.selectVariant=function(ne,ae){A.SelectVariant(ne,ae)},A.Reset=function(ne){var ae=this._GetExtensionMetadata(ne);if(!ae)throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(me," extension"));for(var H=0,W=ae.original;H<W.length;H++){var O=W[H];O.mesh.material=O.material}ae.lastSelected=null},A.prototype.reset=function(ne){A.Reset(ne)},A.GetLastSelectedVariant=function(ne){var ae=this._GetExtensionMetadata(ne);if(!ae)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(me," extension"));return ae.lastSelected},A.prototype.getLastSelectedVariant=function(ne){return A.GetLastSelectedVariant(ne)},A._GetExtensionMetadata=function(ne){var ae,H;return((H=(ae=ne?._internalMetadata)===null||ae===void 0?void 0:ae.gltf)===null||H===void 0?void 0:H[me])||null},A.prototype.onLoading=function(){var ne=this._loader.gltf.extensions;if(ne&&ne[this.name]){var ae=ne[this.name];this._variants=ae.variants}},A.prototype._loadMeshPrimitiveAsync=function(ne,ae,H,W,O,P){var Z=this;return _.GLTFLoader.LoadExtensionAsync(ne,O,this.name,function(re,oe){var he=new Array;return he.push(Z._loader._loadMeshPrimitiveAsync(ne,ae,H,W,O,function(Ee){if(P(Ee),Ee instanceof z.Mesh){var Oe=_.GLTFLoader._GetDrawMode(ne,O.mode),Pe=Z._loader.rootBabylonMesh,Ae=Pe?Pe._internalMetadata=Pe._internalMetadata||{}:{},Ue=Ae.gltf=Ae.gltf||{},je=Ue[me]=Ue[me]||{lastSelected:null,original:[],variants:{}};je.original.push({mesh:Ee,material:Ee.material});for(var Ve=function(it){var ft=oe.mappings[it],xt=_.ArrayItem.Get("".concat(re,"/mappings/").concat(it,"/material"),Z._loader.gltf.materials,ft.material);he.push(Z._loader._loadMaterialAsync("#/materials/".concat(ft.material),xt,Ee,Oe,function(qe){for(var kt=function(gt){var tt=ft.variants[gt],Jt=_.ArrayItem.Get("/extensions/".concat(me,"/variants/").concat(tt),Z._variants,tt);je.variants[Jt.name]=je.variants[Jt.name]||[],je.variants[Jt.name].push({mesh:Ee,material:qe}),Ee.onClonedObservable.add(function(At){var gn=At,We=null,Xe=gn;do{if(Xe=Xe.parent,!Xe)return;We=A._GetExtensionMetadata(Xe)}while(We===null);if(Pe&&We===A._GetExtensionMetadata(Pe)){Xe._internalMetadata={};for(var Ze in Pe._internalMetadata)Xe._internalMetadata[Ze]=Pe._internalMetadata[Ze];Xe._internalMetadata.gltf=[];for(var Ze in Pe._internalMetadata.gltf)Xe._internalMetadata.gltf[Ze]=Pe._internalMetadata.gltf[Ze];Xe._internalMetadata.gltf[me]={lastSelected:null,original:[],variants:{}};for(var ge=0,pe=We.original;ge<pe.length;ge++){var Ce=pe[ge];Xe._internalMetadata.gltf[me].original.push({mesh:Ce.mesh,material:Ce.material})}for(var Ze in We.variants)if(Object.prototype.hasOwnProperty.call(We.variants,Ze)){Xe._internalMetadata.gltf[me].variants[Ze]=[];for(var De=0,Fe=We.variants[Ze];De<Fe.length;De++){var Le=Fe[De];Xe._internalMetadata.gltf[me].variants[Ze].push({mesh:Le.mesh,material:Le.material})}}We=Xe._internalMetadata.gltf[me]}for(var Ye=0,ct=We.original;Ye<ct.length;Ye++){var ke=ct[Ye];ke.mesh===Ee&&(ke.mesh=gn)}for(var et=0,st=We.variants[Jt.name];et<st.length;et++){var ke=st[et];ke.mesh===Ee&&(ke.mesh=gn)}})},V=0;V<ft.variants.length;++V)kt(V)}))},ot=0;ot<oe.mappings.length;++ot)Ve(ot)}})),Promise.all(he).then(function(Ee){var Oe=Ee[0];return Oe})})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_materials_volume:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_materials_volume",Se=function(){function A(ne){this.name=me,this.order=173,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me),this.enabled&&this._loader._disableInstancedMesh++}return A.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return Z.push(W._loader.loadMaterialPropertiesAsync(ne,ae,H)),Z.push(W._loadVolumePropertiesAsync(O,ae,H,P)),Promise.all(Z).then(function(){})})},A.prototype._loadVolumePropertiesAsync=function(ne,ae,H,W){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(ne,": Material type not supported"));if(!H.subSurface.isRefractionEnabled&&!H.subSurface.isTranslucencyEnabled||!W.thicknessFactor)return Promise.resolve();H.subSurface.volumeIndexOfRefraction=H.indexOfRefraction;var O=W.attenuationDistance!==void 0?W.attenuationDistance:Number.MAX_VALUE;return H.subSurface.tintColorAtDistance=O,W.attenuationColor!==void 0&&W.attenuationColor.length==3&&H.subSurface.tintColor.copyFromFloats(W.attenuationColor[0],W.attenuationColor[1],W.attenuationColor[2]),H.subSurface.minimumThickness=0,H.subSurface.maximumThickness=W.thicknessFactor,H.subSurface.useThicknessAsDepth=!0,W.thicknessTexture?(W.thicknessTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(ne,"/thicknessTexture"),W.thicknessTexture).then(function(P){P.name="".concat(H.name," (Thickness)"),H.subSurface.thicknessTexture=P,H.subSurface.useGltfStyleTextures=!0})):Promise.resolve()},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_mesh_quantization:()=>j});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),z="KHR_mesh_quantization",j=function(){function me(Se){this.name=z,this.enabled=Se.isExtensionUsed(z)}return me.prototype.dispose=function(){},me}();(0,_.unregisterGLTFExtension)(z),(0,_.registerGLTFExtension)(z,!0,function(me){return new j(me)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_texture_basisu:()=>me});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),j="KHR_texture_basisu",me=function(){function Se(A){this.name=j,this._loader=A,this.enabled=A.isExtensionUsed(j)}return Se.prototype.dispose=function(){this._loader=null},Se.prototype._loadTextureAsync=function(A,ne,ae){var H=this;return _.GLTFLoader.LoadExtensionAsync(A,ne,this.name,function(W,O){var P=ne.sampler==null?_.GLTFLoader.DefaultSampler:_.ArrayItem.Get("".concat(A,"/sampler"),H._loader.gltf.samplers,ne.sampler),Z=_.ArrayItem.Get("".concat(W,"/source"),H._loader.gltf.images,O.source);return H._loader._createTextureAsync(A,P,Z,function(re){ae(re)},ne._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!ne._textureInfo.nonColorData)})},Se}();(0,z.unregisterGLTFExtension)(j),(0,z.registerGLTFExtension)(j,!0,function(Se){return new me(Se)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_texture_transform:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="KHR_texture_transform",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadTextureInfoAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){return W._loader.loadTextureInfoAsync(ne,ae,function(Z){if(!(Z instanceof _.Texture))throw new Error("".concat(O,": Texture type not supported"));P.offset&&(Z.uOffset=P.offset[0],Z.vOffset=P.offset[1]),Z.uRotationCenter=0,Z.vRotationCenter=0,P.rotation&&(Z.wAng=-P.rotation),P.scale&&(Z.uScale=P.scale[0],Z.vScale=P.scale[1]),P.texCoord!=null&&(Z.coordinatesIndex=P.texCoord),H(Z)})})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{KHR_xmp_json_ld:()=>j});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),z="KHR_xmp_json_ld",j=function(){function me(Se){this.name=z,this.order=100,this._loader=Se,this.enabled=this._loader.isExtensionUsed(z)}return me.prototype.dispose=function(){this._loader=null},me.prototype.onLoading=function(){var Se,A,ne;if(this._loader.rootBabylonMesh!==null){var ae=(Se=this._loader.gltf.extensions)===null||Se===void 0?void 0:Se.KHR_xmp_json_ld,H=(ne=(A=this._loader.gltf.asset)===null||A===void 0?void 0:A.extensions)===null||ne===void 0?void 0:ne.KHR_xmp_json_ld;if(ae&&H){var W=+H.packet;ae.packets&&W<ae.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=ae.packets[W])}}},me}();(0,_.unregisterGLTFExtension)(z),(0,_.registerGLTFExtension)(z,!0,function(me){return new j(me)})},"../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{MSFT_audio_emitter:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="MSFT_audio_emitter",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},A.prototype.onLoading=function(){var ne=this._loader.gltf.extensions;if(ne&&ne[this.name]){var ae=ne[this.name];this._clips=ae.clips,this._emitters=ae.emitters,z.ArrayItem.Assign(this._clips),z.ArrayItem.Assign(this._emitters)}},A.prototype.loadSceneAsync=function(ne,ae){var H=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(W,O){var P=new Array;P.push(H._loader.loadSceneAsync(ne,ae));for(var Z=0,re=O.emitters;Z<re.length;Z++){var oe=re[Z],he=z.ArrayItem.Get("".concat(W,"/emitters"),H._emitters,oe);if(he.refDistance!=null||he.maxDistance!=null||he.rolloffFactor!=null||he.distanceModel!=null||he.innerAngle!=null||he.outerAngle!=null)throw new Error("".concat(W,": Direction or Distance properties are not allowed on emitters attached to a scene"));P.push(H._loadEmitterAsync("".concat(W,"/emitters/").concat(he.index),he))}return Promise.all(P).then(function(){})})},A.prototype.loadNodeAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z=new Array;return W._loader.loadNodeAsync(O,ae,function(re){for(var oe=function(Pe){var Ae=z.ArrayItem.Get("".concat(O,"/emitters"),W._emitters,Pe);Z.push(W._loadEmitterAsync("".concat(O,"/emitters/").concat(Ae.index),Ae).then(function(){for(var Ue=0,je=Ae._babylonSounds;Ue<je.length;Ue++){var Ve=je[Ue];Ve.attachToMesh(re),(Ae.innerAngle!=null||Ae.outerAngle!=null)&&(Ve.setLocalDirectionToMesh(_.Vector3.Forward()),Ve.setDirectionalCone(2*_.Tools.ToDegrees(Ae.innerAngle==null?Math.PI:Ae.innerAngle),2*_.Tools.ToDegrees(Ae.outerAngle==null?Math.PI:Ae.outerAngle),0))}}))},he=0,Ee=P.emitters;he<Ee.length;he++){var Oe=Ee[he];oe(Oe)}H(re)}).then(function(re){return Promise.all(Z).then(function(){return re})})})},A.prototype.loadAnimationAsync=function(ne,ae){var H=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(W,O){return H._loader.loadAnimationAsync(ne,ae).then(function(P){var Z=new Array;z.ArrayItem.Assign(O.events);for(var re=0,oe=O.events;re<oe.length;re++){var he=oe[re];Z.push(H._loadAnimationEventAsync("".concat(W,"/events/").concat(he.index),ne,ae,he,P))}return Promise.all(Z).then(function(){return P})})})},A.prototype._loadClipAsync=function(ne,ae){if(ae._objectURL)return ae._objectURL;var H;if(ae.uri)H=this._loader.loadUriAsync(ne,ae,ae.uri);else{var W=z.ArrayItem.Get("".concat(ne,"/bufferView"),this._loader.gltf.bufferViews,ae.bufferView);H=this._loader.loadBufferViewAsync("/bufferViews/".concat(W.index),W)}return ae._objectURL=H.then(function(O){return URL.createObjectURL(new Blob([O],{type:ae.mimeType}))}),ae._objectURL},A.prototype._loadEmitterAsync=function(ne,ae){var H=this;if(ae._babylonSounds=ae._babylonSounds||[],!ae._babylonData){for(var W=new Array,O=ae.name||"emitter".concat(ae.index),P={loop:!1,autoplay:!1,volume:ae.volume==null?1:ae.volume},Z=function(Ee){var Oe="/extensions/".concat(re.name,"/clips"),Pe=z.ArrayItem.Get(Oe,re._clips,ae.clips[Ee].clip);W.push(re._loadClipAsync("".concat(Oe,"/").concat(ae.clips[Ee].clip),Pe).then(function(Ae){var Ue=ae._babylonSounds[Ee]=new _.Sound(O,Ae,H._loader.babylonScene,null,P);Ue.refDistance=ae.refDistance||1,Ue.maxDistance=ae.maxDistance||256,Ue.rolloffFactor=ae.rolloffFactor||1,Ue.distanceModel=ae.distanceModel||"exponential"}))},re=this,oe=0;oe<ae.clips.length;oe++)Z(oe);var he=Promise.all(W).then(function(){var Ee=ae.clips.map(function(Pe){return Pe.weight||1}),Oe=new _.WeightedSound(ae.loop||!1,ae._babylonSounds,Ee);ae.innerAngle&&(Oe.directionalConeInnerAngle=2*_.Tools.ToDegrees(ae.innerAngle)),ae.outerAngle&&(Oe.directionalConeOuterAngle=2*_.Tools.ToDegrees(ae.outerAngle)),ae.volume&&(Oe.volume=ae.volume),ae._babylonData.sound=Oe});ae._babylonData={loaded:he}}return ae._babylonData.loaded},A.prototype._getEventAction=function(ne,ae,H,W,O){switch(H){case"play":return function(P){var Z=(O||0)+(P-W);ae.play(Z)};case"stop":return function(){ae.stop()};case"pause":return function(){ae.pause()};default:throw new Error("".concat(ne,": Unsupported action ").concat(H))}},A.prototype._loadAnimationEventAsync=function(ne,ae,H,W,O){var P=this;if(O.targetedAnimations.length==0)return Promise.resolve();var Z=O.targetedAnimations[0],re=W.emitter,oe=z.ArrayItem.Get("/extensions/".concat(this.name,"/emitters"),this._emitters,re);return this._loadEmitterAsync(ne,oe).then(function(){var he=oe._babylonData.sound;if(he){var Ee=new _.AnimationEvent(W.time,P._getEventAction(ne,he,W.action,W.time,W.startOffset));Z.animation.addEvent(Ee),O.onAnimationGroupEndObservable.add(function(){he.stop()}),O.onAnimationGroupPauseObservable.add(function(){he.pause()})}})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{MSFT_lod:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="MSFT_lod",Se=function(){function A(ne){var ae,H;this.name=me,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new _.Observable,this.onMaterialLODsLoadedObservable=new _.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=ne,this.maxLODsToLoad=(H=(ae=this._loader.parent.extensionOptions[me])===null||ae===void 0?void 0:ae.maxLODsToLoad)!==null&&H!==void 0?H:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},A.prototype.onReady=function(){for(var ne=this,ae=function(Z){var re=Promise.all(H._nodePromiseLODs[Z]).then(function(){Z!==0&&(ne._loader.endPerformanceCounter("Node LOD ".concat(Z)),ne._loader.log("Loaded node LOD ".concat(Z))),ne.onNodeLODsLoadedObservable.notifyObservers(Z),Z!==ne._nodePromiseLODs.length-1&&(ne._loader.startPerformanceCounter("Node LOD ".concat(Z+1)),ne._loadBufferLOD(ne._nodeBufferLODs,Z+1),ne._nodeSignalLODs[Z]&&ne._nodeSignalLODs[Z].resolve())});H._loader._completePromises.push(re)},H=this,W=0;W<this._nodePromiseLODs.length;W++)ae(W);for(var O=function(Z){var re=Promise.all(P._materialPromiseLODs[Z]).then(function(){Z!==0&&(ne._loader.endPerformanceCounter("Material LOD ".concat(Z)),ne._loader.log("Loaded material LOD ".concat(Z))),ne.onMaterialLODsLoadedObservable.notifyObservers(Z),Z!==ne._materialPromiseLODs.length-1&&(ne._loader.startPerformanceCounter("Material LOD ".concat(Z+1)),ne._loadBufferLOD(ne._materialBufferLODs,Z+1),ne._materialSignalLODs[Z]&&ne._materialSignalLODs[Z].resolve())});P._loader._completePromises.push(re)},P=this,W=0;W<this._materialPromiseLODs.length;W++)O(W)},A.prototype.loadSceneAsync=function(ne,ae){var H=this._loader.loadSceneAsync(ne,ae);return this._loadBufferLOD(this._bufferLODs,0),H},A.prototype.loadNodeAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(O,P){var Z,re=W._getLODs(O,ae,W._loader.gltf.nodes,P.ids);W._loader.logOpen("".concat(O));for(var oe=function(Ee){var Oe=re[Ee];Ee!==0&&(W._nodeIndexLOD=Ee,W._nodeSignalLODs[Ee]=W._nodeSignalLODs[Ee]||new _.Deferred);var Pe=function(Ue){H(Ue),Ue.setEnabled(!1)},Ae=W._loader.loadNodeAsync("/nodes/".concat(Oe.index),Oe,Pe).then(function(Ue){if(Ee!==0){var je=re[Ee-1];je._babylonTransformNode&&(W._disposeTransformNode(je._babylonTransformNode),delete je._babylonTransformNode)}return Ue.setEnabled(!0),Ue});W._nodePromiseLODs[Ee]=W._nodePromiseLODs[Ee]||[],Ee===0?Z=Ae:(W._nodeIndexLOD=null,W._nodePromiseLODs[Ee].push(Ae))},he=0;he<re.length;he++)oe(he);return W._loader.logClose(),Z})},A.prototype._loadMaterialAsync=function(ne,ae,H,W,O){var P=this;return this._nodeIndexLOD?null:z.GLTFLoader.LoadExtensionAsync(ne,ae,this.name,function(Z,re){var oe,he=P._getLODs(Z,ae,P._loader.gltf.materials,re.ids);P._loader.logOpen("".concat(Z));for(var Ee=function(Pe){var Ae=he[Pe];Pe!==0&&(P._materialIndexLOD=Pe);var Ue=P._loader._loadMaterialAsync("/materials/".concat(Ae.index),Ae,H,W,function(je){Pe===0&&O(je)}).then(function(je){if(Pe!==0){O(je);var Ve=he[Pe-1]._data;Ve[W]&&(P._disposeMaterials([Ve[W].babylonMaterial]),delete Ve[W])}return je});P._materialPromiseLODs[Pe]=P._materialPromiseLODs[Pe]||[],Pe===0?oe=Ue:(P._materialIndexLOD=null,P._materialPromiseLODs[Pe].push(Ue))},Oe=0;Oe<he.length;Oe++)Ee(Oe);return P._loader.logClose(),oe})},A.prototype._loadUriAsync=function(ne,ae,H){var W=this;if(this._nodeIndexLOD!==null){this._loader.log("deferred");var O=this._nodeIndexLOD-1;return this._nodeSignalLODs[O]=this._nodeSignalLODs[O]||new _.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(function(){return W._loader.loadUriAsync(ne,ae,H)})}else if(this._materialIndexLOD!==null){this._loader.log("deferred");var O=this._materialIndexLOD-1;return this._materialSignalLODs[O]=this._materialSignalLODs[O]||new _.Deferred,this._materialSignalLODs[O].promise.then(function(){return W._loader.loadUriAsync(ne,ae,H)})}return null},A.prototype.loadBufferAsync=function(ne,ae,H,W){if(this._loader.parent.useRangeRequests&&!ae.uri){if(!this._loader.bin)throw new Error("".concat(ne,": Uri is missing or the binary glTF is missing its binary chunk"));var O=function(P,Z){var re=H,oe=re+W-1,he=P[Z];return he?(he.start=Math.min(he.start,re),he.end=Math.max(he.end,oe)):(he={start:re,end:oe,loaded:new _.Deferred},P[Z]=he),he.loaded.promise.then(function(Ee){return new Uint8Array(Ee.buffer,Ee.byteOffset+H-he.start,W)})};return this._loader.log("deferred"),this._nodeIndexLOD!==null?O(this._nodeBufferLODs,this._nodeIndexLOD):this._materialIndexLOD!==null?O(this._materialBufferLODs,this._materialIndexLOD):O(this._bufferLODs,0)}return null},A.prototype._loadBufferLOD=function(ne,ae){var H=ne[ae];H&&(this._loader.log("Loading buffer range [".concat(H.start,"-").concat(H.end,"]")),this._loader.bin.readAsync(H.start,H.end-H.start+1).then(function(W){H.loaded.resolve(W)},function(W){H.loaded.reject(W)}))},A.prototype._getLODs=function(ne,ae,H,W){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var O=[],P=W.length-1;P>=0;P--)if(O.push(z.ArrayItem.Get("".concat(ne,"/ids/").concat(W[P]),H,W[P])),O.length===this.maxLODsToLoad)return O;return O.push(ae),O},A.prototype._disposeTransformNode=function(ne){var ae=this,H=[],W=ne.material;W&&H.push(W);for(var O=0,P=ne.getChildMeshes();O<P.length;O++){var Z=P[O];Z.material&&H.push(Z.material)}ne.dispose();var re=H.filter(function(oe){return ae._loader.babylonScene.meshes.every(function(he){return he.material!=oe})});this._disposeMaterials(re)},A.prototype._disposeMaterials=function(ne){for(var ae={},H=0,W=ne;H<W.length;H++){for(var O=W[H],P=0,Z=O.getActiveTextures();P<Z.length;P++){var re=Z[P];ae[re.uniqueId]=re}O.dispose()}for(var oe in ae)for(var he=0,Ee=this._loader.babylonScene.materials;he<Ee.length;he++){var O=Ee[he];O.hasTexture(ae[oe])&&delete ae[oe]}for(var oe in ae)ae[oe].dispose()},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{MSFT_minecraftMesh:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="MSFT_minecraftMesh",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtraAsync(ne,ae,this.name,function(O,P){if(P){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(O,": Material type not supported"));var Z=W._loader.loadMaterialPropertiesAsync(ne,ae,H);return H.needAlphaBlending()&&(H.forceDepthWrite=!0,H.separateCullingPass=!0),H.backFaceCulling=H.forceDepthWrite,H.twoSidedLighting=!0,Z}return null})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{MSFT_sRGBFactors:()=>Se});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"),j=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts"),me="MSFT_sRGBFactors",Se=function(){function A(ne){this.name=me,this._loader=ne,this.enabled=this._loader.isExtensionUsed(me)}return A.prototype.dispose=function(){this._loader=null},A.prototype.loadMaterialPropertiesAsync=function(ne,ae,H){var W=this;return z.GLTFLoader.LoadExtraAsync(ne,ae,this.name,function(O,P){if(P){if(!(H instanceof _.PBRMaterial))throw new Error("".concat(O,": Material type not supported"));var Z=W._loader.loadMaterialPropertiesAsync(ne,ae,H),re=H.getScene().getEngine().useExactSrgbConversions;return H.albedoTexture||H.albedoColor.toLinearSpaceToRef(H.albedoColor,re),H.reflectivityTexture||H.reflectivityColor.toLinearSpaceToRef(H.reflectivityColor,re),Z}return null})},A}();(0,j.unregisterGLTFExtension)(me),(0,j.registerGLTFExtension)(me,!0,function(A){return new Se(A)})},"../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFPathToObjectConverter:()=>_});var _=function(){function z(j,me){this._gltf=j,this._infoTree=me}return z.prototype.convert=function(j){var me=this._gltf,Se=this._infoTree,A=void 0;if(!j.startsWith("/"))throw new Error("Path must start with a /");var ne=j.split("/");ne.shift();for(var ae=0,H=ne;ae<H.length;ae++){var W=H[ae];if(Se.__array__)Se=Se.__array__;else if(Se=Se[W],!Se)throw new Error("Path ".concat(j," is invalid"));if(me===void 0)throw new Error("Path ".concat(j," is invalid"));me=me[W],Se.__target__&&(A=me)}return{object:A,info:Se}},z}()},"../../../dev/loaders/src/glTF/2.0/Extensions/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{EXT_lights_image_based:()=>_.EXT_lights_image_based,EXT_mesh_gpu_instancing:()=>z.EXT_mesh_gpu_instancing,EXT_meshopt_compression:()=>j.EXT_meshopt_compression,EXT_texture_avif:()=>Se.EXT_texture_avif,EXT_texture_webp:()=>me.EXT_texture_webp,ExtrasAsMetadata:()=>tt.ExtrasAsMetadata,KHR_animation_pointer:()=>ft.KHR_animation_pointer,KHR_draco_mesh_compression:()=>A.KHR_draco_mesh_compression,KHR_interactivity:()=>gt.KHR_interactivity,KHR_lights:()=>ne.KHR_lights,KHR_materials_anisotropy:()=>P.KHR_materials_anisotropy,KHR_materials_clearcoat:()=>W.KHR_materials_clearcoat,KHR_materials_diffuse_transmission:()=>Pe.KHR_materials_diffuse_transmission,KHR_materials_dispersion:()=>Ue.KHR_materials_dispersion,KHR_materials_emissive_strength:()=>Z.KHR_materials_emissive_strength,KHR_materials_ior:()=>he.KHR_materials_ior,KHR_materials_iridescence:()=>O.KHR_materials_iridescence,KHR_materials_pbrSpecularGlossiness:()=>ae.KHR_materials_pbrSpecularGlossiness,KHR_materials_sheen:()=>re.KHR_materials_sheen,KHR_materials_specular:()=>oe.KHR_materials_specular,KHR_materials_transmission:()=>Oe.KHR_materials_transmission,KHR_materials_unlit:()=>H.KHR_materials_unlit,KHR_materials_variants:()=>Ee.KHR_materials_variants,KHR_materials_volume:()=>Ae.KHR_materials_volume,KHR_mesh_quantization:()=>je.KHR_mesh_quantization,KHR_texture_basisu:()=>Ve.KHR_texture_basisu,KHR_texture_transform:()=>ot.KHR_texture_transform,KHR_xmp_json_ld:()=>it.KHR_xmp_json_ld,MSFT_audio_emitter:()=>xt.MSFT_audio_emitter,MSFT_lod:()=>qe.MSFT_lod,MSFT_minecraftMesh:()=>kt.MSFT_minecraftMesh,MSFT_sRGBFactors:()=>V.MSFT_sRGBFactors});var _=K("../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"),z=K("../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"),j=K("../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts"),me=K("../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts"),Se=K("../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_avif.ts"),A=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"),ne=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"),ae=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"),H=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"),W=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"),O=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"),P=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"),Z=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"),re=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"),oe=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"),he=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts"),Ee=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"),Oe=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"),Pe=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.ts"),Ae=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts"),Ue=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_dispersion.ts"),je=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts"),Ve=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"),ot=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts"),it=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"),ft=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts"),xt=K("../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"),qe=K("../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"),kt=K("../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"),V=K("../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"),gt=K("../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity.ts"),tt=K("../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts")},"../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{convertGLTFToSerializedFlowGraph:()=>A});var _=K("babylonjs/Misc/tools"),z=K("../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts");function j(ne,ae,H){if(ne.type!==void 0){var W=ae.types&&ae.types[ne.type];if(!W)throw new Error("".concat(H,": Unknown type: ").concat(ne.type));var O=W.signature;if(!O)throw new Error("".concat(H,": Type ").concat(ne.type," has no signature"));var P=z.gltfTypeToBabylonType[O];return{value:ne.value,className:P}}else return ne.value}function me(ne,ae,H){for(var W,O={},P=(W=ne.configuration)!==null&&W!==void 0?W:[],Z=0,re=P;Z<re.length;Z++){var oe=re[Z];if(oe.id==="customEvent"){var he=ae.customEvents&&ae.customEvents[oe.value];if(!he)throw new Error("/extensions/KHR_interactivity/nodes/".concat(H,": Unknown custom event: ").concat(oe.value));O.eventId=he.id,O.eventData=he.values.map(function(Pe){return Pe.id})}else if(oe.id==="variable"){var Ee=ae.variables&&ae.variables[oe.value];if(!Ee)throw new Error("/extensions/KHR_interactivity/nodes/".concat(H,": Unknown variable: ").concat(oe.value));O.variableName=Ee.id}else if(oe.id==="path"){var Oe=oe.value;O.path=Oe}else O[oe.id]=j(oe,ae,"/extensions/KHR_interactivity/nodes/".concat(H))}return O}function Se(ne,ae,H){var W=z.gltfToFlowGraphTypeMap[ae.type];if(!W)throw new Error("/extensions/KHR_interactivity/nodes/".concat(ne,": Unknown block type: ").concat(ae.type));var O=ne.toString(),P=me(ae,H,O),Z=ae.metadata,re=[],oe=[],he=[],Ee=[];return{className:W,config:P,uniqueId:O,metadata:Z,dataInputs:re,dataOutputs:oe,signalInputs:he,signalOutputs:Ee}}function A(ne){for(var ae,H,W,O={uniqueId:(0,_.RandomGUID)(),_userVariables:{},_connectionValues:{}},P=[O],Z=[],re=0;re<ne.nodes.length;re++){var oe=ne.nodes[re],he=Se(re,oe,ne);Z.push(he)}for(var re=0;re<ne.nodes.length;re++){for(var oe=ne.nodes[re],Ee=Z[re],Oe=(ae=oe.flows)!==null&&ae!==void 0?ae:[],Pe=function(Jt){var At=Jt.id,gn={uniqueId:(0,_.RandomGUID)(),name:At,_connectionType:1,connectedPointIds:[]};Ee.signalOutputs.push(gn);var We=Jt.node,Xe=Jt.socket,Ze=Z[We];if(!Ze)throw new Error("/extensions/KHR_interactivity/nodes/".concat(re,": Could not find node with id ").concat(We," that connects its input with with node ").concat(re,"'s output ").concat(At));var ge=Ze.signalInputs.find(function(pe){return pe.name===Xe});ge||(ge={uniqueId:(0,_.RandomGUID)(),name:Xe,_connectionType:0,connectedPointIds:[]},Ze.signalInputs.push(ge)),ge.connectedPointIds.push(gn.uniqueId),gn.connectedPointIds.push(ge.uniqueId)},Ae=0,Ue=Oe;Ae<Ue.length;Ae++){var je=Ue[Ae];Pe(je)}for(var Ve=(H=oe.values)!==null&&H!==void 0?H:[],ot=function(Jt){var At=Jt.id,gn={uniqueId:(0,_.RandomGUID)(),name:At,_connectionType:0,connectedPointIds:[]};if(Ee.dataInputs.push(gn),Jt.value!==void 0){var We=j(Jt,ne,"/extensions/KHR_interactivity/nodes/".concat(re));O._connectionValues[gn.uniqueId]=We}else if(Jt.node!==void 0&&Jt.socket!==void 0){var Xe=Jt.node,Ze=Jt.socket,ge=Z[Xe];if(!ge)throw new Error("/extensions/KHR_interactivity/nodes/".concat(re,": Could not find node with id ").concat(Xe," that connects its output with node").concat(re,"'s input ").concat(At));var pe=ge.dataOutputs.find(function(Ce){return Ce.name===Ze});pe||(pe={uniqueId:(0,_.RandomGUID)(),name:Ze,_connectionType:1,connectedPointIds:[]},ge.dataOutputs.push(pe)),gn.connectedPointIds.push(pe.uniqueId),pe.connectedPointIds.push(gn.uniqueId)}else throw new Error("/extensions/KHR_interactivity/nodes/".concat(re,": Invalid socket ").concat(At," in node ").concat(re))},it=0,ft=Ve;it<ft.length;it++){var xt=ft[it];ot(xt)}}for(var qe=(W=ne.variables)!==null&&W!==void 0?W:[],re=0;re<qe.length;re++){var kt=qe[re],V=kt.id;O._userVariables[V]=j(kt,ne,"/extensions/KHR_interactivity/variables/".concat(re))}return{allBlocks:Z,executionContexts:P}}},"../../../dev/loaders/src/glTF/2.0/Extensions/interactivityPathToObjectConverter.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{InteractivityPathToObjectConverter:()=>j});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("../../../dev/loaders/src/glTF/2.0/Extensions/gltfPathToObjectConverter.ts"),j=function(A){(0,_.__extends)(ne,A);function ne(ae){return A.call(this,ae,Se)||this}return ne}(z.GLTFPathToObjectConverter),me={__array__:{__target__:!0,translation:{type:"Vector3",get:function(A){var ne=A._babylonTransformNode;return ne.position},set:function(A,ne){var ae=ne._babylonTransformNode;ae.position=A},getObject:function(A){return A._babylonTransformNode}}}},Se={nodes:me}},"../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{gltfToFlowGraphTypeMap:()=>z,gltfTypeToBabylonType:()=>j});var _=K("babylonjs/Misc/tools"),z={"lifecycle/onStart":_.FlowGraphSceneReadyEventBlock.ClassName,"lifecycle/onTick":_.FlowGraphSceneTickEventBlock.ClassName,log:_.FlowGraphConsoleLogBlock.ClassName,"flow/delay":_.FlowGraphTimerBlock.ClassName,"customEvent/send":_.FlowGraphSendCustomEventBlock.ClassName,"customEvent/receive":_.FlowGraphReceiveCustomEventBlock.ClassName,"flow/sequence":_.FlowGraphSequenceBlock.ClassName,"world/get":_.FlowGraphGetPropertyBlock.ClassName,"world/set":_.FlowGraphSetPropertyBlock.ClassName,"flow/doN":_.FlowGraphDoNBlock.ClassName,"variable/get":_.FlowGraphGetVariableBlock.ClassName,"variable/set":_.FlowGraphSetVariableBlock.ClassName,"flow/whileLoop":_.FlowGraphWhileLoopBlock.ClassName,"math/random":_.FlowGraphRandomBlock.ClassName,"math/e":_.FlowGraphEBlock.ClassName,"math/pi":_.FlowGraphPiBlock.ClassName,"math/inf":_.FlowGraphInfBlock.ClassName,"math/nan":_.FlowGraphNaNBlock.ClassName,"math/abs":_.FlowGraphAbsBlock.ClassName,"math/sign":_.FlowGraphSignBlock.ClassName,"math/trunc":_.FlowGraphTruncBlock.ClassName,"math/floor":_.FlowGraphFloorBlock.ClassName,"math/ceil":_.FlowGraphCeilBlock.ClassName,"math/fract":_.FlowGraphFractBlock.ClassName,"math/neg":_.FlowGraphNegBlock.ClassName,"math/add":_.FlowGraphAddBlock.ClassName,"math/sub":_.FlowGraphSubtractBlock.ClassName,"math/mul":_.FlowGraphMultiplyBlock.ClassName,"math/div":_.FlowGraphDivideBlock.ClassName,"math/rem":_.FlowGraphRemainderBlock.ClassName,"math/min":_.FlowGraphMinBlock.ClassName,"math/max":_.FlowGraphMaxBlock.ClassName,"math/clamp":_.FlowGraphClampBlock.ClassName,"math/saturate":_.FlowGraphSaturateBlock.ClassName,"math/mix":_.FlowGraphInterpolateBlock.ClassName,"math/eq":_.FlowGraphEqBlock.ClassName,"math/lt":_.FlowGraphLessThanBlock.ClassName,"math/le":_.FlowGraphLessThanOrEqualBlock.ClassName,"math/gt":_.FlowGraphGreaterThanBlock.ClassName,"math/ge":_.FlowGraphGreaterThanOrEqualBlock.ClassName,"math/isnan":_.FlowGraphIsNanBlock.ClassName,"math/isinf":_.FlowGraphIsInfBlock.ClassName,"math/rad":_.FlowGraphDegToRadBlock.ClassName,"math/deg":_.FlowGraphRadToDegBlock.ClassName,"math/sin":_.FlowGraphSinBlock.ClassName,"math/cos":_.FlowGraphCosBlock.ClassName,"math/tan":_.FlowGraphTanBlock.ClassName,"math/asin":_.FlowGraphAsinBlock.ClassName,"math/acos":_.FlowGraphAcosBlock.ClassName,"math/atan":_.FlowGraphAtanBlock.ClassName,"math/atan2":_.FlowGraphAtan2Block.ClassName,"math/sinh":_.FlowGraphSinhBlock.ClassName,"math/cosh":_.FlowGraphCoshBlock.ClassName,"math/tanh":_.FlowGraphTanhBlock.ClassName,"math/asinh":_.FlowGraphAsinhBlock.ClassName,"math/acosh":_.FlowGraphAcoshBlock.ClassName,"math/atanh":_.FlowGraphAtanhBlock.ClassName,"math/exp":_.FlowGraphExpBlock.ClassName,"math/log":_.FlowGraphLogBlock.ClassName,"math/log2":_.FlowGraphLog2Block.ClassName,"math/log10":_.FlowGraphLog10Block.ClassName,"math/sqrt":_.FlowGraphSqrtBlock.ClassName,"math/cbrt":_.FlowGraphCubeRootBlock.ClassName,"math/pow":_.FlowGraphPowBlock.ClassName,"math/length":_.FlowGraphLengthBlock.ClassName,"math/normalize":_.FlowGraphNormalizeBlock.ClassName,"math/dot":_.FlowGraphDotBlock.ClassName,"math/cross":_.FlowGraphCrossBlock.ClassName,"math/rotate2d":_.FlowGraphRotate2DBlock.ClassName,"math/rotate3d":_.FlowGraphRotate3DBlock.ClassName,"math/transpose":_.FlowGraphTransposeBlock.ClassName,"math/determinant":_.FlowGraphDeterminantBlock.ClassName,"math/inverse":_.FlowGraphInvertMatrixBlock.ClassName,"math/matmul":_.FlowGraphMatMulBlock.ClassName,"math/not":_.FlowGraphBitwiseNotBlock.ClassName,"math/and":_.FlowGraphBitwiseAndBlock.ClassName,"math/or":_.FlowGraphBitwiseOrBlock.ClassName,"math/xor":_.FlowGraphBitwiseXorBlock.ClassName,"math/asr":_.FlowGraphBitwiseRightShiftBlock.ClassName,"math/lsl":_.FlowGraphBitwiseLeftShiftBlock.ClassName,"math/clz":_.FlowGraphCountLeadingZerosBlock.ClassName,"math/ctz":_.FlowGraphCountTrailingZerosBlock.ClassName,"math/popcnt":_.FlowGraphCountOneBitsBlock.ClassName},j={float2:"Vector2",float3:"Vector3",float4:"Vector4",float4x4:"Matrix",int:"FlowGraphInteger"}},"../../../dev/loaders/src/glTF/2.0/glTFLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{ArrayItem:()=>ne,GLTFFileLoader:()=>j.GLTFFileLoader,GLTFLoader:()=>ae});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/glTFFileLoader.ts"),me=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"),Se=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts");function A(){for(var H=[],W=0;W<arguments.length;W++)H[W]=arguments[W];var O=function(P){return P&&typeof P=="object"};return H.reduce(function(P,Z){return Object.keys(Z).forEach(function(re){var oe=P[re],he=Z[re];Array.isArray(oe)&&Array.isArray(he)?P[re]=oe.concat.apply(oe,he):O(oe)&&O(he)?P[re]=A(oe,he):P[re]=he}),P},{})}var ne=function(){function H(){}return H.Get=function(W,O,P){if(!O||P==null||!O[P])throw new Error("".concat(W,": Failed to find index (").concat(P,")"));return O[P]},H.TryGet=function(W,O){return!W||O==null||!W[O]?null:W[O]},H.Assign=function(W){if(W)for(var O=0;O<W.length;O++)W[O].index=O},H}(),ae=function(){function H(W){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,this._allMaterialsDirtyRequired=!1,this._extensions=new Array,this._disposed=!1,this._rootUrl=null,this._fileName=null,this._uniqueRootUrl=null,this._bin=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions=new Array,this._parent=W}return H.RegisterExtension=function(W,O){(0,Se.registerGLTFExtension)(W,!1,O)},H.UnregisterExtension=function(W){return(0,Se.unregisterGLTFExtension)(W)},Object.defineProperty(H.prototype,"gltf",{get:function(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"babylonScene",{get:function(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),Object.defineProperty(H.prototype,"rootUrl",{get:function(){return this._rootUrl},enumerable:!1,configurable:!0}),H.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach(function(W){return W.dispose&&W.dispose()}),this._extensions.length=0,this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())},H.prototype.importMeshAsync=function(W,O,P,Z,re,oe,he){var Ee=this;return he===void 0&&(he=""),Promise.resolve().then(function(){Ee._babylonScene=O,Ee._assetContainer=P,Ee._loadData(Z);var Oe=null;if(W){var Pe={};if(Ee._gltf.nodes)for(var Ae=0,Ue=Ee._gltf.nodes;Ae<Ue.length;Ae++){var je=Ue[Ae];je.name&&(Pe[je.name]=je.index)}var Ve=W instanceof Array?W:[W];Oe=Ve.map(function(ot){var it=Pe[ot];if(it===void 0)throw new Error("Failed to find node '".concat(ot,"'"));return it})}return Ee._loadAsync(re,he,Oe,function(){return{meshes:Ee._getMeshes(),particleSystems:[],skeletons:Ee._getSkeletons(),animationGroups:Ee._getAnimationGroups(),lights:Ee._babylonLights,transformNodes:Ee._getTransformNodes(),geometries:Ee._getGeometries(),spriteManagers:[]}})})},H.prototype.loadAsync=function(W,O,P,Z,re){var oe=this;return re===void 0&&(re=""),Promise.resolve().then(function(){return oe._babylonScene=W,oe._loadData(O),oe._loadAsync(P,re,null,function(){})})},H.prototype._loadAsync=function(W,O,P,Z){var re=this;return Promise.resolve().then(function(){return(0,_.__awaiter)(re,void 0,void 0,function(){var oe,he,Ee,Oe,Pe,Ae,Ue,je,Ve,ot,it=this;return(0,_.__generator)(this,function(ft){switch(ft.label){case 0:return this._rootUrl=W,this._uniqueRootUrl=!W.startsWith("file:")&&O?W:"".concat(W).concat(Date.now(),"/"),this._fileName=O,this._allMaterialsDirtyRequired=!1,[4,this._loadExtensionsAsync()];case 1:if(ft.sent(),oe="".concat(j.GLTFLoaderState[j.GLTFLoaderState.LOADING]," => ").concat(j.GLTFLoaderState[j.GLTFLoaderState.READY]),he="".concat(j.GLTFLoaderState[j.GLTFLoaderState.LOADING]," => ").concat(j.GLTFLoaderState[j.GLTFLoaderState.COMPLETE]),this._parent._startPerformanceCounter(oe),this._parent._startPerformanceCounter(he),this._parent._setState(j.GLTFLoaderState.LOADING),this._extensionsOnLoading(),Ee=new Array,Oe=this._babylonScene.blockMaterialDirtyMechanism,this._babylonScene.blockMaterialDirtyMechanism=!0,this.parent.loadOnlyMaterials||(P?Ee.push(this.loadSceneAsync("/nodes",{nodes:P,index:-1})):(this._gltf.scene!=null||this._gltf.scenes&&this._gltf.scenes[0])&&(Pe=ne.Get("/scene",this._gltf.scenes,this._gltf.scene||0),Ee.push(this.loadSceneAsync("/scenes/".concat(Pe.index),Pe)))),!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(Ae=0;Ae<this._gltf.materials.length;++Ae)Ue=this._gltf.materials[Ae],je="/materials/"+Ae,Ve=z.Material.TriangleFillMode,Ee.push(this._loadMaterialAsync(je,Ue,null,Ve,function(){}));return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=Oe:this._babylonScene._forceBlockMaterialDirtyMechanism(Oe),this._parent.compileMaterials&&Ee.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&Ee.push(this._compileShadowGeneratorsAsync()),ot=Promise.all(Ee).then(function(){return it._rootBabylonMesh&&it._rootBabylonMesh!==it._parent.customRootNode&&it._rootBabylonMesh.setEnabled(!0),it._extensionsOnReady(),it._parent._setState(j.GLTFLoaderState.READY),it._startAnimations(),Z()}),[2,ot.then(function(xt){return it._parent._endPerformanceCounter(oe),z.Tools.SetImmediate(function(){it._disposed||Promise.all(it._completePromises).then(function(){it._parent._endPerformanceCounter(he),it._parent._setState(j.GLTFLoaderState.COMPLETE),it._parent.onCompleteObservable.notifyObservers(void 0),it._parent.onCompleteObservable.clear(),it.dispose()},function(qe){it._parent.onErrorObservable.notifyObservers(qe),it._parent.onErrorObservable.clear(),it.dispose()})}),xt})]}})})}).catch(function(oe){throw re._disposed||(re._parent.onErrorObservable.notifyObservers(oe),re._parent.onErrorObservable.clear(),re.dispose()),oe})},H.prototype._loadData=function(W){if(this._gltf=W.json,this._setupData(),W.bin){var O=this._gltf.buffers;if(O&&O[0]&&!O[0].uri){var P=O[0];(P.byteLength<W.bin.byteLength-3||P.byteLength>W.bin.byteLength)&&z.Logger.Warn("Binary buffer length (".concat(P.byteLength,") from JSON does not match chunk length (").concat(W.bin.byteLength,")")),this._bin=W.bin}else z.Logger.Warn("Unexpected BIN chunk")}},H.prototype._setupData=function(){if(ne.Assign(this._gltf.accessors),ne.Assign(this._gltf.animations),ne.Assign(this._gltf.buffers),ne.Assign(this._gltf.bufferViews),ne.Assign(this._gltf.cameras),ne.Assign(this._gltf.images),ne.Assign(this._gltf.materials),ne.Assign(this._gltf.meshes),ne.Assign(this._gltf.nodes),ne.Assign(this._gltf.samplers),ne.Assign(this._gltf.scenes),ne.Assign(this._gltf.skins),ne.Assign(this._gltf.textures),this._gltf.nodes){for(var W={},O=0,P=this._gltf.nodes;O<P.length;O++){var Z=P[O];if(Z.children)for(var re=0,oe=Z.children;re<oe.length;re++){var he=oe[re];W[he]=Z.index}}for(var Ee=this._createRootNode(),Oe=0,Pe=this._gltf.nodes;Oe<Pe.length;Oe++){var Z=Pe[Oe],Ae=W[Z.index];Z.parent=Ae===void 0?Ee:this._gltf.nodes[Ae]}}},H.prototype._loadExtensionsAsync=function(){var W;return(0,_.__awaiter)(this,void 0,void 0,function(){var O,P,Z,re,oe,he,Ee,Oe,Pe,Ae,Ue=this;return(0,_.__generator)(this,function(je){switch(je.label){case 0:return O=[],Se.registeredGLTFExtensions.forEach(function(Ve,ot){var it;((it=Ue.parent.extensionOptions[ot])===null||it===void 0?void 0:it.enabled)===!1?Ve.isGLTFExtension&&Ue.isExtensionUsed(ot)&&z.Logger.Warn("Extension ".concat(ot," is used but has been explicitly disabled.")):(!Ve.isGLTFExtension||Ue.isExtensionUsed(ot))&&O.push(function(){return(0,_.__awaiter)(Ue,void 0,void 0,function(){var ft;return(0,_.__generator)(this,function(xt){switch(xt.label){case 0:return[4,Ve.factory(this)];case 1:return ft=xt.sent(),ft.name!==ot&&z.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(ft.name," !== ").concat(ot)),this._parent.onExtensionLoadedObservable.notifyObservers(ft),[2,ft]}})})}())}),Z=(P=(Ae=this._extensions).push).apply,re=[Ae],[4,Promise.all(O)];case 1:if(Z.apply(P,re.concat([je.sent()])),this._extensions.sort(function(Ve,ot){return(Ve.order||Number.MAX_VALUE)-(ot.order||Number.MAX_VALUE)}),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(oe=function(Ve){var ot=he._extensions.some(function(it){return it.name===Ve&&it.enabled});if(!ot)throw((W=he.parent.extensionOptions[Ve])===null||W===void 0?void 0:W.enabled)===!1?new Error("Required extension ".concat(Ve," is disabled")):new Error("Required extension ".concat(Ve," is not available"))},he=this,Ee=0,Oe=this._gltf.extensionsRequired;Ee<Oe.length;Ee++)Pe=Oe[Ee],oe(Pe);return[2]}})})},H.prototype._createRootNode=function(){if(this._parent.customRootNode!==void 0)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:this._rootBabylonMesh===null?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;var W=new z.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=W,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var O={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case j.GLTFLoaderCoordinateSystemMode.AUTO:{this._babylonScene.useRightHandedSystem||(O.rotation=[0,1,0,0],O.scale=[1,1,-1],H._LoadTransform(O,this._rootBabylonMesh));break}case j.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:{this._babylonScene.useRightHandedSystem=!0;break}default:throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode,")"))}return this._parent.onMeshLoadedObservable.notifyObservers(W),O},H.prototype.loadSceneAsync=function(W,O){var P=this,Z=this._extensionsLoadSceneAsync(W,O);if(Z)return Z;var re=new Array;if(this.logOpen("".concat(W," ").concat(O.name||"")),O.nodes)for(var oe=0,he=O.nodes;oe<he.length;oe++){var Ee=he[oe],Oe=ne.Get("".concat(W,"/nodes/").concat(Ee),this._gltf.nodes,Ee);re.push(this.loadNodeAsync("/nodes/".concat(Oe.index),Oe,function(je){je.parent=P._rootBabylonMesh}))}for(var Pe=0,Ae=this._postSceneLoadActions;Pe<Ae.length;Pe++){var Ue=Ae[Pe];Ue()}return re.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(re).then(function(){})},H.prototype._forEachPrimitive=function(W,O){if(W._primitiveBabylonMeshes)for(var P=0,Z=W._primitiveBabylonMeshes;P<Z.length;P++){var re=Z[P];O(re)}},H.prototype._getGeometries=function(){var W=[],O=this._gltf.nodes;if(O)for(var P=0,Z=O;P<Z.length;P++){var re=Z[P];this._forEachPrimitive(re,function(oe){var he=oe.geometry;he&&W.indexOf(he)===-1&&W.push(he)})}return W},H.prototype._getMeshes=function(){var W=[];this._rootBabylonMesh instanceof z.AbstractMesh&&W.push(this._rootBabylonMesh);var O=this._gltf.nodes;if(O)for(var P=0,Z=O;P<Z.length;P++){var re=Z[P];this._forEachPrimitive(re,function(oe){W.push(oe)})}return W},H.prototype._getTransformNodes=function(){var W=[],O=this._gltf.nodes;if(O)for(var P=0,Z=O;P<Z.length;P++){var re=Z[P];re._babylonTransformNode&&re._babylonTransformNode.getClassName()==="TransformNode"&&W.push(re._babylonTransformNode),re._babylonTransformNodeForSkin&&W.push(re._babylonTransformNodeForSkin)}return W},H.prototype._getSkeletons=function(){var W=[],O=this._gltf.skins;if(O)for(var P=0,Z=O;P<Z.length;P++){var re=Z[P];re._data&&W.push(re._data.babylonSkeleton)}return W},H.prototype._getAnimationGroups=function(){var W=[],O=this._gltf.animations;if(O)for(var P=0,Z=O;P<Z.length;P++){var re=Z[P];re._babylonAnimationGroup&&W.push(re._babylonAnimationGroup)}return W},H.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case j.GLTFLoaderAnimationStartMode.NONE:break;case j.GLTFLoaderAnimationStartMode.FIRST:{var W=this._getAnimationGroups();W.length!==0&&W[0].start(!0);break}case j.GLTFLoaderAnimationStartMode.ALL:{for(var W=this._getAnimationGroups(),O=0,P=W;O<P.length;O++){var Z=P[O];Z.start(!0)}break}default:{z.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"));return}}},H.prototype.loadNodeAsync=function(W,O,P){var Z=this;P===void 0&&(P=function(){});var re=this._extensionsLoadNodeAsync(W,O,P);if(re)return re;if(O._babylonTransformNode)throw new Error("".concat(W,": Invalid recursive node hierarchy"));var oe=new Array;this.logOpen("".concat(W," ").concat(O.name||""));var he=function(je){if(H.AddPointerMetadata(je,W),H._LoadTransform(O,je),O.camera!=null){var Ve=ne.Get("".concat(W,"/camera"),Z._gltf.cameras,O.camera);oe.push(Z.loadCameraAsync("/cameras/".concat(Ve.index),Ve,function(qe){qe.parent=je}))}if(O.children)for(var ot=0,it=O.children;ot<it.length;ot++){var ft=it[ot],xt=ne.Get("".concat(W,"/children/").concat(ft),Z._gltf.nodes,ft);oe.push(Z.loadNodeAsync("/nodes/".concat(xt.index),xt,function(qe){qe.parent=je}))}P(je)},Ee=O.mesh!=null,Oe=this._parent.loadSkins&&O.skin!=null;if(!Ee||Oe){var Pe=O.name||"node".concat(O.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var Ae=new z.TransformNode(Pe,this._babylonScene);Ae._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,O.mesh==null?O._babylonTransformNode=Ae:O._babylonTransformNodeForSkin=Ae,he(Ae)}if(Ee)if(Oe){var Ue=ne.Get("".concat(W,"/mesh"),this._gltf.meshes,O.mesh);oe.push(this._loadMeshAsync("/meshes/".concat(Ue.index),O,Ue,function(je){var Ve=O._babylonTransformNodeForSkin;je.metadata=A(Ve.metadata,je.metadata||{});var ot=ne.Get("".concat(W,"/skin"),Z._gltf.skins,O.skin);oe.push(Z._loadSkinAsync("/skins/".concat(ot.index),O,ot,function(it){Z._forEachPrimitive(O,function(ft){ft.skeleton=it}),Z._postSceneLoadActions.push(function(){if(ot.skeleton!=null){var ft=ne.Get("/skins/".concat(ot.index,"/skeleton"),Z._gltf.nodes,ot.skeleton).parent;O.index===ft.index?je.parent=Ve.parent:je.parent=ft._babylonTransformNode}else je.parent=Z._rootBabylonMesh;Z._parent.onSkinLoadedObservable.notifyObservers({node:Ve,skinnedNode:je})})}))}))}else{var Ue=ne.Get("".concat(W,"/mesh"),this._gltf.meshes,O.mesh);oe.push(this._loadMeshAsync("/meshes/".concat(Ue.index),O,Ue,he))}return this.logClose(),Promise.all(oe).then(function(){return Z._forEachPrimitive(O,function(je){je.geometry&&je.geometry.useBoundingInfoFromGeometry?je._updateBoundingInfo():je.refreshBoundingInfo(!0,!0)}),O._babylonTransformNode})},H.prototype._loadMeshAsync=function(W,O,P,Z){var re=P.primitives;if(!re||!re.length)throw new Error("".concat(W,": Primitives are missing"));re[0].index==null&&ne.Assign(re);var oe=new Array;this.logOpen("".concat(W," ").concat(P.name||""));var he=O.name||"node".concat(O.index);if(re.length===1){var Ee=P.primitives[0];oe.push(this._loadMeshPrimitiveAsync("".concat(W,"/primitives/").concat(Ee.index),he,O,P,Ee,function(Ae){O._babylonTransformNode=Ae,O._primitiveBabylonMeshes=[Ae]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,O._babylonTransformNode=new z.TransformNode(he,this._babylonScene),O._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,O._primitiveBabylonMeshes=[];for(var Oe=0,Pe=re;Oe<Pe.length;Oe++){var Ee=Pe[Oe];oe.push(this._loadMeshPrimitiveAsync("".concat(W,"/primitives/").concat(Ee.index),"".concat(he,"_primitive").concat(Ee.index),O,P,Ee,function(Ue){Ue.parent=O._babylonTransformNode,O._primitiveBabylonMeshes.push(Ue)}))}}return Z(O._babylonTransformNode),this.logClose(),Promise.all(oe).then(function(){return O._babylonTransformNode})},H.prototype._loadMeshPrimitiveAsync=function(W,O,P,Z,re,oe){var he=this,Ee=this._extensionsLoadMeshPrimitiveAsync(W,O,P,Z,re,oe);if(Ee)return Ee;this.logOpen("".concat(W));var Oe=this._disableInstancedMesh===0&&this._parent.createInstances&&P.skin==null&&!Z.primitives[0].targets,Pe,Ae;if(Oe&&re._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,Pe=re._instanceData.babylonSourceMesh.createInstance(O),Pe._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,Ae=re._instanceData.promise;else{var Ue=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var je=new z.Mesh(O,this._babylonScene);je._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,je.sideOrientation=this._babylonScene.useRightHandedSystem?z.Material.CounterClockWiseSideOrientation:z.Material.ClockWiseSideOrientation,this._createMorphTargets(W,P,Z,re,je),Ue.push(this._loadVertexDataAsync(W,re,je).then(function(ft){return he._loadMorphTargetsAsync(W,re,je,ft).then(function(){he._disposed||(he._babylonScene._blockEntityCollection=!!he._assetContainer,ft.applyToMesh(je),ft._parentContainer=he._assetContainer,he._babylonScene._blockEntityCollection=!1)})}));var Ve=H._GetDrawMode(W,re.mode);if(re.material==null){var ot=this._defaultBabylonMaterialData[Ve];ot||(ot=this._createDefaultMaterial("__GLTFLoader._default",Ve),this._parent.onMaterialLoadedObservable.notifyObservers(ot),this._defaultBabylonMaterialData[Ve]=ot),je.material=ot}else if(!this.parent.skipMaterials){var it=ne.Get("".concat(W,"/material"),this._gltf.materials,re.material);Ue.push(this._loadMaterialAsync("/materials/".concat(it.index),it,je,Ve,function(ft){je.material=ft}))}Ae=Promise.all(Ue),Oe&&(re._instanceData={babylonSourceMesh:je,promise:Ae}),Pe=je}return H.AddPointerMetadata(Pe,W),this._parent.onMeshLoadedObservable.notifyObservers(Pe),oe(Pe),this.logClose(),Ae.then(function(){return Pe})},H.prototype._loadVertexDataAsync=function(W,O,P){var Z=this,re=this._extensionsLoadVertexDataAsync(W,O,P);if(re)return re;var oe=O.attributes;if(!oe)throw new Error("".concat(W,": Attributes are missing"));var he=new Array,Ee=new z.Geometry(P.name,this._babylonScene);if(O.indices==null)P.isUnIndexed=!0;else{var Oe=ne.Get("".concat(W,"/indices"),this._gltf.accessors,O.indices);he.push(this._loadIndicesAccessorAsync("/accessors/".concat(Oe.index),Oe).then(function(Ae){Ee.setIndices(Ae)}))}var Pe=function(Ae,Ue,je){if(oe[Ae]!=null){P._delayInfo=P._delayInfo||[],P._delayInfo.indexOf(Ue)===-1&&P._delayInfo.push(Ue);var Ve=ne.Get("".concat(W,"/attributes/").concat(Ae),Z._gltf.accessors,oe[Ae]);he.push(Z._loadVertexAccessorAsync("/accessors/".concat(Ve.index),Ve,Ue).then(function(ot){var it,ft;if(ot.getKind()===z.VertexBuffer.PositionKind&&!Z.parent.alwaysComputeBoundingBox&&!P.skeleton&&Ve.min&&Ve.max){var xt=(it=z.TmpVectors.Vector3[0]).copyFromFloats.apply(it,Ve.min),qe=(ft=z.TmpVectors.Vector3[1]).copyFromFloats.apply(ft,Ve.max);if(Ve.normalized&&Ve.componentType!==5126){var kt=1;switch(Ve.componentType){case 5120:kt=127;break;case 5121:kt=255;break;case 5122:kt=32767;break;case 5123:kt=65535;break}var V=1/kt;xt.scaleInPlace(V),qe.scaleInPlace(V)}Ee._boundingInfo=new z.BoundingInfo(xt,qe),Ee.useBoundingInfoFromGeometry=!0}Ee.setVerticesBuffer(ot,Ve.count)})),Ue==z.VertexBuffer.MatricesIndicesExtraKind&&(P.numBoneInfluencers=8),je&&je(Ve)}};return Pe("POSITION",z.VertexBuffer.PositionKind),Pe("NORMAL",z.VertexBuffer.NormalKind),Pe("TANGENT",z.VertexBuffer.TangentKind),Pe("TEXCOORD_0",z.VertexBuffer.UVKind),Pe("TEXCOORD_1",z.VertexBuffer.UV2Kind),Pe("TEXCOORD_2",z.VertexBuffer.UV3Kind),Pe("TEXCOORD_3",z.VertexBuffer.UV4Kind),Pe("TEXCOORD_4",z.VertexBuffer.UV5Kind),Pe("TEXCOORD_5",z.VertexBuffer.UV6Kind),Pe("JOINTS_0",z.VertexBuffer.MatricesIndicesKind),Pe("WEIGHTS_0",z.VertexBuffer.MatricesWeightsKind),Pe("JOINTS_1",z.VertexBuffer.MatricesIndicesExtraKind),Pe("WEIGHTS_1",z.VertexBuffer.MatricesWeightsExtraKind),Pe("COLOR_0",z.VertexBuffer.ColorKind,function(Ae){Ae.type==="VEC4"&&(P.hasVertexAlpha=!0)}),Promise.all(he).then(function(){return Ee})},H.prototype._createMorphTargets=function(W,O,P,Z,re){if(!(!Z.targets||!this._parent.loadMorphTargets)){if(O._numMorphTargets==null)O._numMorphTargets=Z.targets.length;else if(Z.targets.length!==O._numMorphTargets)throw new Error("".concat(W,": Primitives do not have the same number of targets"));var oe=P.extras?P.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,re.morphTargetManager=new z.MorphTargetManager(this._babylonScene),re.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,re.morphTargetManager.areUpdatesFrozen=!0;for(var he=0;he<Z.targets.length;he++){var Ee=O.weights?O.weights[he]:P.weights?P.weights[he]:0,Oe=oe?oe[he]:"morphTarget".concat(he);re.morphTargetManager.addTarget(new z.MorphTarget(Oe,Ee,re.getScene()))}}},H.prototype._loadMorphTargetsAsync=function(W,O,P,Z){if(!O.targets||!this._parent.loadMorphTargets)return Promise.resolve();for(var re=new Array,oe=P.morphTargetManager,he=0;he<oe.numTargets;he++){var Ee=oe.getTarget(he);re.push(this._loadMorphTargetVertexDataAsync("".concat(W,"/targets/").concat(he),Z,O.targets[he],Ee))}return Promise.all(re).then(function(){oe.areUpdatesFrozen=!1})},H.prototype._loadMorphTargetVertexDataAsync=function(W,O,P,Z){var re=this,oe=new Array,he=function(Ee,Oe,Pe){if(P[Ee]!=null){var Ae=O.getVertexBuffer(Oe);if(Ae){var Ue=ne.Get("".concat(W,"/").concat(Ee),re._gltf.accessors,P[Ee]);oe.push(re._loadFloatAccessorAsync("/accessors/".concat(Ue.index),Ue).then(function(je){Pe(Ae,je)}))}}};return he("POSITION",z.VertexBuffer.PositionKind,function(Ee,Oe){var Pe=new Float32Array(Oe.length);Ee.forEach(Oe.length,function(Ae,Ue){Pe[Ue]=Oe[Ue]+Ae}),Z.setPositions(Pe)}),he("NORMAL",z.VertexBuffer.NormalKind,function(Ee,Oe){var Pe=new Float32Array(Oe.length);Ee.forEach(Pe.length,function(Ae,Ue){Pe[Ue]=Oe[Ue]+Ae}),Z.setNormals(Pe)}),he("TANGENT",z.VertexBuffer.TangentKind,function(Ee,Oe){var Pe=new Float32Array(Oe.length/3*4),Ae=0;Ee.forEach(Oe.length/3*4,function(Ue,je){(je+1)%4!==0&&(Pe[Ae]=Oe[Ae]+Ue,Ae++)}),Z.setTangents(Pe)}),Promise.all(oe).then(function(){})},H._LoadTransform=function(W,O){if(W.skin==null){var P=z.Vector3.Zero(),Z=z.Quaternion.Identity(),re=z.Vector3.One();if(W.matrix){var oe=z.Matrix.FromArray(W.matrix);oe.decompose(re,Z,P)}else W.translation&&(P=z.Vector3.FromArray(W.translation)),W.rotation&&(Z=z.Quaternion.FromArray(W.rotation)),W.scale&&(re=z.Vector3.FromArray(W.scale));O.position=P,O.rotationQuaternion=Z,O.scaling=re}},H.prototype._loadSkinAsync=function(W,O,P,Z){var re=this;if(!this._parent.loadSkins)return Promise.resolve();var oe=this._extensionsLoadSkinAsync(W,O,P);if(oe)return oe;if(P._data)return Z(P._data.babylonSkeleton),P._data.promise;var he="skeleton".concat(P.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var Ee=new z.Skeleton(P.name||he,he,this._babylonScene);Ee._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(W,P,Ee);var Oe=this._loadSkinInverseBindMatricesDataAsync(W,P).then(function(Pe){re._updateBoneMatrices(Ee,Pe)});return P._data={babylonSkeleton:Ee,promise:Oe},Z(Ee),Oe},H.prototype._loadBones=function(W,O,P){if(O.skeleton==null||this._parent.alwaysComputeSkeletonRootNode){var Z=this._findSkeletonRootNode("".concat(W,"/joints"),O.joints);if(Z)if(O.skeleton===void 0)O.skeleton=Z.index;else{var re=function(Ue,je){for(;je.parent;je=je.parent)if(je.parent===Ue)return!0;return!1},oe=ne.Get("".concat(W,"/skeleton"),this._gltf.nodes,O.skeleton);oe!==Z&&!re(oe,Z)&&(z.Logger.Warn("".concat(W,"/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")),O.skeleton=Z.index)}else z.Logger.Warn("".concat(W,": Failed to find common root"))}for(var he={},Ee=0,Oe=O.joints;Ee<Oe.length;Ee++){var Pe=Oe[Ee],Ae=ne.Get("".concat(W,"/joints/").concat(Pe),this._gltf.nodes,Pe);this._loadBone(Ae,O,P,he)}},H.prototype._findSkeletonRootNode=function(W,O){if(O.length===0)return null;for(var P={},Z=0,re=O;Z<re.length;Z++){for(var oe=re[Z],he=[],Ee=ne.Get("".concat(W,"/").concat(oe),this._gltf.nodes,oe);Ee.index!==-1;)he.unshift(Ee),Ee=Ee.parent;P[oe]=he}for(var Oe=null,Pe=0;;++Pe){var he=P[O[0]];if(Pe>=he.length)return Oe;for(var Ee=he[Pe],Ae=1;Ae<O.length;++Ae)if(he=P[O[Ae]],Pe>=he.length||Ee!==he[Pe])return Oe;Oe=Ee}},H.prototype._loadBone=function(W,O,P,Z){W._isJoint=!0;var re=Z[W.index];if(re)return re;var oe=null;W.index!==O.skeleton&&(W.parent&&W.parent.index!==-1?oe=this._loadBone(W.parent,O,P,Z):O.skeleton!==void 0&&z.Logger.Warn("/skins/".concat(O.index,"/skeleton: Skeleton node is not a common root")));var he=O.joints.indexOf(W.index);return re=new z.Bone(W.name||"joint".concat(W.index),P,oe,this._getNodeMatrix(W),null,null,he),Z[W.index]=re,this._postSceneLoadActions.push(function(){re.linkTransformNode(W._babylonTransformNode)}),re},H.prototype._loadSkinInverseBindMatricesDataAsync=function(W,O){if(O.inverseBindMatrices==null)return Promise.resolve(null);var P=ne.Get("".concat(W,"/inverseBindMatrices"),this._gltf.accessors,O.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(P.index),P)},H.prototype._updateBoneMatrices=function(W,O){for(var P=0,Z=W.bones;P<Z.length;P++){var re=Z[P],oe=z.Matrix.Identity(),he=re._index;O&&he!==-1&&(z.Matrix.FromArrayToRef(O,he*16,oe),oe.invertToRef(oe));var Ee=re.getParent();Ee&&oe.multiplyToRef(Ee.getAbsoluteInverseBindMatrix(),oe),re.updateMatrix(oe,!1,!1),re._updateAbsoluteBindMatrices(void 0,!1)}},H.prototype._getNodeMatrix=function(W){return W.matrix?z.Matrix.FromArray(W.matrix):z.Matrix.Compose(W.scale?z.Vector3.FromArray(W.scale):z.Vector3.One(),W.rotation?z.Quaternion.FromArray(W.rotation):z.Quaternion.Identity(),W.translation?z.Vector3.FromArray(W.translation):z.Vector3.Zero())},H.prototype.loadCameraAsync=function(W,O,P){P===void 0&&(P=function(){});var Z=this._extensionsLoadCameraAsync(W,O,P);if(Z)return Z;var re=new Array;this.logOpen("".concat(W," ").concat(O.name||"")),this._babylonScene._blockEntityCollection=!!this._assetContainer;var oe=new z.FreeCamera(O.name||"camera".concat(O.index),z.Vector3.Zero(),this._babylonScene,!1);switch(oe._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,oe.ignoreParentScaling=!0,O._babylonCamera=oe,oe.rotation.set(0,Math.PI,0),O.type){case"perspective":{var he=O.perspective;if(!he)throw new Error("".concat(W,": Camera perspective properties are missing"));oe.fov=he.yfov,oe.minZ=he.znear,oe.maxZ=he.zfar||0;break}case"orthographic":{if(!O.orthographic)throw new Error("".concat(W,": Camera orthographic properties are missing"));oe.mode=z.Camera.ORTHOGRAPHIC_CAMERA,oe.orthoLeft=-O.orthographic.xmag,oe.orthoRight=O.orthographic.xmag,oe.orthoBottom=-O.orthographic.ymag,oe.orthoTop=O.orthographic.ymag,oe.minZ=O.orthographic.znear,oe.maxZ=O.orthographic.zfar;break}default:throw new Error("".concat(W,": Invalid camera type (").concat(O.type,")"))}return H.AddPointerMetadata(oe,W),this._parent.onCameraLoadedObservable.notifyObservers(oe),P(oe),this.logClose(),Promise.all(re).then(function(){return oe})},H.prototype._loadAnimationsAsync=function(){var W=this._gltf.animations;if(!W)return Promise.resolve();for(var O=new Array,P=0;P<W.length;P++){var Z=W[P];O.push(this.loadAnimationAsync("/animations/".concat(Z.index),Z).then(function(re){re.targetedAnimations.length===0&&re.dispose()}))}return Promise.all(O).then(function(){})},H.prototype.loadAnimationAsync=function(W,O){var P=this._extensionsLoadAnimationAsync(W,O);if(P)return P;this._babylonScene._blockEntityCollection=!!this._assetContainer;var Z=new z.AnimationGroup(O.name||"animation".concat(O.index),this._babylonScene);Z._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,O._babylonAnimationGroup=Z;var re=new Array;ne.Assign(O.channels),ne.Assign(O.samplers);for(var oe=0,he=O.channels;oe<he.length;oe++){var Ee=he[oe];re.push(this._loadAnimationChannelAsync("".concat(W,"/channels/").concat(Ee.index),W,O,Ee,function(Oe,Pe){Oe.animations=Oe.animations||[],Oe.animations.push(Pe),Z.addTargetedAnimation(Pe,Oe)}))}return Promise.all(re).then(function(){return Z.normalize(0),Z})},H.prototype._loadAnimationChannelAsync=function(W,O,P,Z,re){var oe=this._extensionsLoadAnimationChannelAsync(W,O,P,Z,re);if(oe)return oe;if(Z.target.node==null)return Promise.resolve();var he=ne.Get("".concat(W,"/target/node"),this._gltf.nodes,Z.target.node),Ee=Z.target.path,Oe=Ee==="weights";if(Oe&&!he._numMorphTargets||!Oe&&!he._babylonTransformNode||!this._parent.loadNodeAnimations&&!Oe&&!he._isJoint)return Promise.resolve();var Pe;switch(Ee){case"translation":{Pe=me.nodeAnimationData.translation;break}case"rotation":{Pe=me.nodeAnimationData.rotation;break}case"scale":{Pe=me.nodeAnimationData.scale;break}case"weights":{Pe=me.nodeAnimationData.weights;break}default:throw new Error("".concat(W,"/target/path: Invalid value (").concat(Z.target.path,")"))}var Ae={object:he,info:Pe};return this._loadAnimationChannelFromTargetInfoAsync(W,O,P,Z,Ae,re)},H.prototype._loadAnimationChannelFromTargetInfoAsync=function(W,O,P,Z,re,oe){var he=this.parent.targetFps,Ee=1/he,Oe=ne.Get("".concat(W,"/sampler"),P.samplers,Z.sampler);return this._loadAnimationSamplerAsync("".concat(O,"/samplers/").concat(Z.sampler),Oe).then(function(Pe){for(var Ae=0,Ue=re.object,je=re.info,Ve=0,ot=je;Ve<ot.length;Ve++){var it=ot[Ve],ft=it.getStride(Ue),xt=Pe.input,qe=Pe.output,kt=new Array(xt.length),V=0;switch(Pe.interpolation){case"STEP":{for(var gt=0;gt<xt.length;gt++){var tt=it.getValue(Ue,qe,V,1);V+=ft,kt[gt]={frame:xt[gt]*he,value:tt,interpolation:1}}break}case"CUBICSPLINE":{for(var gt=0;gt<xt.length;gt++){var Jt=it.getValue(Ue,qe,V,Ee);V+=ft;var tt=it.getValue(Ue,qe,V,1);V+=ft;var At=it.getValue(Ue,qe,V,Ee);V+=ft,kt[gt]={frame:xt[gt]*he,inTangent:Jt,value:tt,outTangent:At}}break}case"LINEAR":{for(var gt=0;gt<xt.length;gt++){var tt=it.getValue(Ue,qe,V,1);V+=ft,kt[gt]={frame:xt[gt]*he,value:tt}}break}}if(V>0){var gn="".concat(P.name||"animation".concat(P.index),"_channel").concat(Z.index,"_").concat(Ae);it.buildAnimations(Ue,gn,he,kt,function(We,Xe){++Ae,oe(We,Xe)})}}})},H.prototype._loadAnimationSamplerAsync=function(W,O){if(O._data)return O._data;var P=O.interpolation||"LINEAR";switch(P){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(W,"/interpolation: Invalid value (").concat(O.interpolation,")"))}var Z=ne.Get("".concat(W,"/input"),this._gltf.accessors,O.input),re=ne.Get("".concat(W,"/output"),this._gltf.accessors,O.output);return O._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(Z.index),Z),this._loadFloatAccessorAsync("/accessors/".concat(re.index),re)]).then(function(oe){var he=oe[0],Ee=oe[1];return{input:he,interpolation:P,output:Ee}}),O._data},H.prototype.loadBufferAsync=function(W,O,P,Z){var re=this._extensionsLoadBufferAsync(W,O,P,Z);if(re)return re;if(!O._data)if(O.uri)O._data=this.loadUriAsync("".concat(W,"/uri"),O,O.uri);else{if(!this._bin)throw new Error("".concat(W,": Uri is missing or the binary glTF is missing its binary chunk"));O._data=this._bin.readAsync(0,O.byteLength)}return O._data.then(function(oe){try{return new Uint8Array(oe.buffer,oe.byteOffset+P,Z)}catch(he){throw new Error("".concat(W,": ").concat(he.message))}})},H.prototype.loadBufferViewAsync=function(W,O){var P=this._extensionsLoadBufferViewAsync(W,O);if(P)return P;if(O._data)return O._data;var Z=ne.Get("".concat(W,"/buffer"),this._gltf.buffers,O.buffer);return O._data=this.loadBufferAsync("/buffers/".concat(Z.index),Z,O.byteOffset||0,O.byteLength),O._data},H.prototype._loadAccessorAsync=function(W,O,P){var Z=this;if(O._data)return O._data;var re=H._GetNumComponents(W,O.type),oe=re*z.VertexBuffer.GetTypeByteLength(O.componentType),he=re*O.count;if(O.bufferView==null)O._data=Promise.resolve(new P(he));else{var Ee=ne.Get("".concat(W,"/bufferView"),this._gltf.bufferViews,O.bufferView);O._data=this.loadBufferViewAsync("/bufferViews/".concat(Ee.index),Ee).then(function(Pe){if(O.componentType===5126&&!O.normalized&&(!Ee.byteStride||Ee.byteStride===oe))return H._GetTypedArray(W,O.componentType,Pe,O.byteOffset,he);var Ae=new P(he);return z.VertexBuffer.ForEach(Pe,O.byteOffset||0,Ee.byteStride||oe,re,O.componentType,Ae.length,O.normalized||!1,function(Ue,je){Ae[je]=Ue}),Ae})}if(O.sparse){var Oe=O.sparse;O._data=O._data.then(function(Pe){var Ae=Pe,Ue=ne.Get("".concat(W,"/sparse/indices/bufferView"),Z._gltf.bufferViews,Oe.indices.bufferView),je=ne.Get("".concat(W,"/sparse/values/bufferView"),Z._gltf.bufferViews,Oe.values.bufferView);return Promise.all([Z.loadBufferViewAsync("/bufferViews/".concat(Ue.index),Ue),Z.loadBufferViewAsync("/bufferViews/".concat(je.index),je)]).then(function(Ve){var ot=Ve[0],it=Ve[1],ft=H._GetTypedArray("".concat(W,"/sparse/indices"),Oe.indices.componentType,ot,Oe.indices.byteOffset,Oe.count),xt=re*Oe.count,qe;if(O.componentType===5126&&!O.normalized)qe=H._GetTypedArray("".concat(W,"/sparse/values"),O.componentType,it,Oe.values.byteOffset,xt);else{var kt=H._GetTypedArray("".concat(W,"/sparse/values"),O.componentType,it,Oe.values.byteOffset,xt);qe=new P(xt),z.VertexBuffer.ForEach(kt,0,oe,re,O.componentType,qe.length,O.normalized||!1,function(At,gn){qe[gn]=At})}for(var V=0,gt=0;gt<ft.length;gt++)for(var tt=ft[gt]*re,Jt=0;Jt<re;Jt++)Ae[tt++]=qe[V++];return Ae})})}return O._data},H.prototype._loadFloatAccessorAsync=function(W,O){return this._loadAccessorAsync(W,O,Float32Array)},H.prototype._loadIndicesAccessorAsync=function(W,O){if(O.type!=="SCALAR")throw new Error("".concat(W,"/type: Invalid value ").concat(O.type));if(O.componentType!==5121&&O.componentType!==5123&&O.componentType!==5125)throw new Error("".concat(W,"/componentType: Invalid value ").concat(O.componentType));if(O._data)return O._data;if(O.sparse){var P=H._GetTypedArrayConstructor("".concat(W,"/componentType"),O.componentType);O._data=this._loadAccessorAsync(W,O,P)}else{var Z=ne.Get("".concat(W,"/bufferView"),this._gltf.bufferViews,O.bufferView);O._data=this.loadBufferViewAsync("/bufferViews/".concat(Z.index),Z).then(function(re){return H._GetTypedArray(W,O.componentType,re,O.byteOffset,O.count)})}return O._data},H.prototype._loadVertexBufferViewAsync=function(W){if(W._babylonBuffer)return W._babylonBuffer;var O=this._babylonScene.getEngine();return W._babylonBuffer=this.loadBufferViewAsync("/bufferViews/".concat(W.index),W).then(function(P){return new z.Buffer(O,P,!1)}),W._babylonBuffer},H.prototype._loadVertexAccessorAsync=function(W,O,P){var Z;if(!((Z=O._babylonVertexBuffer)===null||Z===void 0)&&Z[P])return O._babylonVertexBuffer[P];O._babylonVertexBuffer||(O._babylonVertexBuffer={});var re=this._babylonScene.getEngine();if(O.sparse||O.bufferView==null)O._babylonVertexBuffer[P]=this._loadFloatAccessorAsync(W,O).then(function(he){return new z.VertexBuffer(re,he,P,!1)});else{var oe=ne.Get("".concat(W,"/bufferView"),this._gltf.bufferViews,O.bufferView);O._babylonVertexBuffer[P]=this._loadVertexBufferViewAsync(oe).then(function(he){var Ee=H._GetNumComponents(W,O.type);return new z.VertexBuffer(re,he,P,!1,void 0,oe.byteStride,void 0,O.byteOffset,Ee,O.componentType,O.normalized,!0,void 0,!0)})}return O._babylonVertexBuffer[P]},H.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(W,O,P){if(!(P instanceof z.PBRMaterial))throw new Error("".concat(W,": Material type not supported"));var Z=new Array;return O&&(O.baseColorFactor?(P.albedoColor=z.Color3.FromArray(O.baseColorFactor),P.alpha=O.baseColorFactor[3]):P.albedoColor=z.Color3.White(),P.metallic=O.metallicFactor==null?1:O.metallicFactor,P.roughness=O.roughnessFactor==null?1:O.roughnessFactor,O.baseColorTexture&&Z.push(this.loadTextureInfoAsync("".concat(W,"/baseColorTexture"),O.baseColorTexture,function(re){re.name="".concat(P.name," (Base Color)"),P.albedoTexture=re})),O.metallicRoughnessTexture&&(O.metallicRoughnessTexture.nonColorData=!0,Z.push(this.loadTextureInfoAsync("".concat(W,"/metallicRoughnessTexture"),O.metallicRoughnessTexture,function(re){re.name="".concat(P.name," (Metallic Roughness)"),P.metallicTexture=re})),P.useMetallnessFromMetallicTextureBlue=!0,P.useRoughnessFromMetallicTextureGreen=!0,P.useRoughnessFromMetallicTextureAlpha=!1)),Promise.all(Z).then(function(){})},H.prototype._loadMaterialAsync=function(W,O,P,Z,re){re===void 0&&(re=function(){});var oe=this._extensionsLoadMaterialAsync(W,O,P,Z,re);if(oe)return oe;O._data=O._data||{};var he=O._data[Z];if(!he){this.logOpen("".concat(W," ").concat(O.name||""));var Ee=this.createMaterial(W,O,Z);he={babylonMaterial:Ee,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(W,O,Ee)},O._data[Z]=he,H.AddPointerMetadata(Ee,W),this._parent.onMaterialLoadedObservable.notifyObservers(Ee),this.logClose()}return P&&(he.babylonMeshes.push(P),P.onDisposeObservable.addOnce(function(){var Oe=he.babylonMeshes.indexOf(P);Oe!==-1&&he.babylonMeshes.splice(Oe,1)})),re(he.babylonMaterial),he.promise.then(function(){return he.babylonMaterial})},H.prototype._createDefaultMaterial=function(W,O){this._babylonScene._blockEntityCollection=!!this._assetContainer;var P=new z.PBRMaterial(W,this._babylonScene);return P._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,P.fillMode=O,P.enableSpecularAntiAliasing=!0,P.useRadianceOverAlpha=!this._parent.transparencyAsCoverage,P.useSpecularOverAlpha=!this._parent.transparencyAsCoverage,P.transparencyMode=z.PBRMaterial.PBRMATERIAL_OPAQUE,P.metallic=1,P.roughness=1,P},H.prototype.createMaterial=function(W,O,P){var Z=this._extensionsCreateMaterial(W,O,P);if(Z)return Z;var re=O.name||"material".concat(O.index),oe=this._createDefaultMaterial(re,P);return oe},H.prototype.loadMaterialPropertiesAsync=function(W,O,P){var Z=this._extensionsLoadMaterialPropertiesAsync(W,O,P);if(Z)return Z;var re=new Array;return re.push(this.loadMaterialBasePropertiesAsync(W,O,P)),O.pbrMetallicRoughness&&re.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(W,"/pbrMetallicRoughness"),O.pbrMetallicRoughness,P)),this.loadMaterialAlphaProperties(W,O,P),Promise.all(re).then(function(){})},H.prototype.loadMaterialBasePropertiesAsync=function(W,O,P){if(!(P instanceof z.PBRMaterial))throw new Error("".concat(W,": Material type not supported"));var Z=new Array;return P.emissiveColor=O.emissiveFactor?z.Color3.FromArray(O.emissiveFactor):new z.Color3(0,0,0),O.doubleSided&&(P.backFaceCulling=!1,P.twoSidedLighting=!0),O.normalTexture&&(O.normalTexture.nonColorData=!0,Z.push(this.loadTextureInfoAsync("".concat(W,"/normalTexture"),O.normalTexture,function(re){re.name="".concat(P.name," (Normal)"),P.bumpTexture=re})),P.invertNormalMapX=!this._babylonScene.useRightHandedSystem,P.invertNormalMapY=this._babylonScene.useRightHandedSystem,O.normalTexture.scale!=null&&P.bumpTexture&&(P.bumpTexture.level=O.normalTexture.scale),P.forceIrradianceInFragment=!0),O.occlusionTexture&&(O.occlusionTexture.nonColorData=!0,Z.push(this.loadTextureInfoAsync("".concat(W,"/occlusionTexture"),O.occlusionTexture,function(re){re.name="".concat(P.name," (Occlusion)"),P.ambientTexture=re})),P.useAmbientInGrayScale=!0,O.occlusionTexture.strength!=null&&(P.ambientTextureStrength=O.occlusionTexture.strength)),O.emissiveTexture&&Z.push(this.loadTextureInfoAsync("".concat(W,"/emissiveTexture"),O.emissiveTexture,function(re){re.name="".concat(P.name," (Emissive)"),P.emissiveTexture=re})),Promise.all(Z).then(function(){})},H.prototype.loadMaterialAlphaProperties=function(W,O,P){if(!(P instanceof z.PBRMaterial))throw new Error("".concat(W,": Material type not supported"));var Z=O.alphaMode||"OPAQUE";switch(Z){case"OPAQUE":{P.transparencyMode=z.PBRMaterial.PBRMATERIAL_OPAQUE,P.alpha=1;break}case"MASK":{P.transparencyMode=z.PBRMaterial.PBRMATERIAL_ALPHATEST,P.alphaCutOff=O.alphaCutoff==null?.5:O.alphaCutoff,P.albedoTexture&&(P.albedoTexture.hasAlpha=!0);break}case"BLEND":{P.transparencyMode=z.PBRMaterial.PBRMATERIAL_ALPHABLEND,P.albedoTexture&&(P.albedoTexture.hasAlpha=!0,P.useAlphaFromAlbedoTexture=!0);break}default:throw new Error("".concat(W,"/alphaMode: Invalid value (").concat(O.alphaMode,")"))}},H.prototype.loadTextureInfoAsync=function(W,O,P){var Z=this;P===void 0&&(P=function(){});var re=this._extensionsLoadTextureInfoAsync(W,O,P);if(re)return re;if(this.logOpen("".concat(W)),O.texCoord>=6)throw new Error("".concat(W,"/texCoord: Invalid value (").concat(O.texCoord,")"));var oe=ne.Get("".concat(W,"/index"),this._gltf.textures,O.index);oe._textureInfo=O;var he=this._loadTextureAsync("/textures/".concat(O.index),oe,function(Ee){Ee.coordinatesIndex=O.texCoord||0,H.AddPointerMetadata(Ee,W),Z._parent.onTextureLoadedObservable.notifyObservers(Ee),P(Ee)});return this.logClose(),he},H.prototype._loadTextureAsync=function(W,O,P){P===void 0&&(P=function(){});var Z=this._extensionsLoadTextureAsync(W,O,P);if(Z)return Z;this.logOpen("".concat(W," ").concat(O.name||""));var re=O.sampler==null?H.DefaultSampler:ne.Get("".concat(W,"/sampler"),this._gltf.samplers,O.sampler),oe=ne.Get("".concat(W,"/source"),this._gltf.images,O.source),he=this._createTextureAsync(W,re,oe,P,void 0,!O._textureInfo.nonColorData);return this.logClose(),he},H.prototype._createTextureAsync=function(W,O,P,Z,re,oe){var he=this;Z===void 0&&(Z=function(){});var Ee=this._loadSampler("/samplers/".concat(O.index),O),Oe=new Array,Pe=new z.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var Ae={noMipmap:Ee.noMipMaps,invertY:!1,samplingMode:Ee.samplingMode,onLoad:function(){he._disposed||Pe.resolve()},onError:function(je,Ve){he._disposed||Pe.reject(new Error("".concat(W,": ").concat(Ve&&Ve.message?Ve.message:je||"Failed to load texture")))},mimeType:P.mimeType,loaderOptions:re,useSRGBBuffer:!!oe&&this._parent.useSRGBBuffers},Ue=new z.Texture(null,this._babylonScene,Ae);return Ue._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,Oe.push(Pe.promise),Oe.push(this.loadImageAsync("/images/".concat(P.index),P).then(function(je){var Ve=P.uri||"".concat(he._fileName,"#image").concat(P.index),ot="data:".concat(he._uniqueRootUrl).concat(Ve);Ue.updateURL(ot,je)})),Ue.wrapU=Ee.wrapU,Ue.wrapV=Ee.wrapV,Z(Ue),Promise.all(Oe).then(function(){return Ue})},H.prototype._loadSampler=function(W,O){return O._data||(O._data={noMipMaps:O.minFilter===9728||O.minFilter===9729,samplingMode:H._GetTextureSamplingMode(W,O),wrapU:H._GetTextureWrapMode("".concat(W,"/wrapS"),O.wrapS),wrapV:H._GetTextureWrapMode("".concat(W,"/wrapT"),O.wrapT)}),O._data},H.prototype.loadImageAsync=function(W,O){if(!O._data){if(this.logOpen("".concat(W," ").concat(O.name||"")),O.uri)O._data=this.loadUriAsync("".concat(W,"/uri"),O,O.uri);else{var P=ne.Get("".concat(W,"/bufferView"),this._gltf.bufferViews,O.bufferView);O._data=this.loadBufferViewAsync("/bufferViews/".concat(P.index),P)}this.logClose()}return O._data},H.prototype.loadUriAsync=function(W,O,P){var Z=this,re=this._extensionsLoadUriAsync(W,O,P);if(re)return re;if(!H._ValidateUri(P))throw new Error("".concat(W,": '").concat(P,"' is invalid"));if((0,z.IsBase64DataUrl)(P)){var oe=new Uint8Array((0,z.DecodeBase64UrlToBinary)(P));return this.log("".concat(W,": Decoded ").concat(P.substring(0,64),"... (").concat(oe.length," bytes)")),Promise.resolve(oe)}return this.log("".concat(W,": Loading ").concat(P)),this._parent.preprocessUrlAsync(this._rootUrl+P).then(function(he){return new Promise(function(Ee,Oe){Z._parent._loadFile(Z._babylonScene,he,function(Pe){Z._disposed||(Z.log("".concat(W,": Loaded ").concat(P," (").concat(Pe.byteLength," bytes)")),Ee(new Uint8Array(Pe)))},!0,function(Pe){Oe(new z.LoadFileError("".concat(W,": Failed to load '").concat(P,"'").concat(Pe?": "+Pe.status+" "+Pe.statusText:""),Pe))})})})},H.AddPointerMetadata=function(W,O){W.metadata=W.metadata||{};var P=W._internalMetadata=W._internalMetadata||{},Z=P.gltf=P.gltf||{},re=Z.pointers=Z.pointers||[];re.push(O)},H._GetTextureWrapMode=function(W,O){switch(O=O??10497,O){case 33071:return z.Texture.CLAMP_ADDRESSMODE;case 33648:return z.Texture.MIRROR_ADDRESSMODE;case 10497:return z.Texture.WRAP_ADDRESSMODE;default:return z.Logger.Warn("".concat(W,": Invalid value (").concat(O,")")),z.Texture.WRAP_ADDRESSMODE}},H._GetTextureSamplingMode=function(W,O){var P=O.magFilter==null?9729:O.magFilter,Z=O.minFilter==null?9987:O.minFilter;if(P===9729)switch(Z){case 9728:return z.Texture.LINEAR_NEAREST;case 9729:return z.Texture.LINEAR_LINEAR;case 9984:return z.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return z.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return z.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return z.Texture.LINEAR_LINEAR_MIPLINEAR;default:return z.Logger.Warn("".concat(W,"/minFilter: Invalid value (").concat(Z,")")),z.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(P!==9728&&z.Logger.Warn("".concat(W,"/magFilter: Invalid value (").concat(P,")")),Z){case 9728:return z.Texture.NEAREST_NEAREST;case 9729:return z.Texture.NEAREST_LINEAR;case 9984:return z.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return z.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return z.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return z.Texture.NEAREST_LINEAR_MIPLINEAR;default:return z.Logger.Warn("".concat(W,"/minFilter: Invalid value (").concat(Z,")")),z.Texture.NEAREST_NEAREST_MIPNEAREST}},H._GetTypedArrayConstructor=function(W,O){switch(O){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(W,": Invalid component type ").concat(O))}},H._GetTypedArray=function(W,O,P,Z,re){var oe=P.buffer;Z=P.byteOffset+(Z||0);var he=H._GetTypedArrayConstructor("".concat(W,"/componentType"),O),Ee=z.VertexBuffer.GetTypeByteLength(O);return Z%Ee!==0?(z.Logger.Warn("".concat(W,": Copying buffer as byte offset (").concat(Z,") is not a multiple of component type byte length (").concat(Ee,")")),new he(oe.slice(Z,Z+re*Ee),0)):new he(oe,Z,re)},H._GetNumComponents=function(W,O){switch(O){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4;case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(W,": Invalid type (").concat(O,")"))},H._ValidateUri=function(W){return z.Tools.IsBase64(W)||W.indexOf("..")===-1},H._GetDrawMode=function(W,O){switch(O==null&&(O=4),O){case 0:return z.Material.PointListDrawMode;case 1:return z.Material.LineListDrawMode;case 2:return z.Material.LineLoopDrawMode;case 3:return z.Material.LineStripDrawMode;case 4:return z.Material.TriangleFillMode;case 5:return z.Material.TriangleStripDrawMode;case 6:return z.Material.TriangleFanDrawMode}throw new Error("".concat(W,": Invalid mesh primitive mode (").concat(O,")"))},H.prototype._compileMaterialsAsync=function(){var W=this;this._parent._startPerformanceCounter("Compile materials");var O=new Array;if(this._gltf.materials)for(var P=0,Z=this._gltf.materials;P<Z.length;P++){var re=Z[P];if(re._data)for(var oe in re._data)for(var he=re._data[oe],Ee=0,Oe=he.babylonMeshes;Ee<Oe.length;Ee++){var Pe=Oe[Ee];Pe.computeWorldMatrix(!0);var Ae=he.babylonMaterial;O.push(Ae.forceCompilationAsync(Pe)),O.push(Ae.forceCompilationAsync(Pe,{useInstances:!0})),this._parent.useClipPlane&&(O.push(Ae.forceCompilationAsync(Pe,{clipPlane:!0})),O.push(Ae.forceCompilationAsync(Pe,{clipPlane:!0,useInstances:!0})))}}return Promise.all(O).then(function(){W._parent._endPerformanceCounter("Compile materials")})},H.prototype._compileShadowGeneratorsAsync=function(){var W=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var O=new Array,P=this._babylonScene.lights,Z=0,re=P;Z<re.length;Z++){var oe=re[Z],he=oe.getShadowGenerator();he&&O.push(he.forceCompilationAsync())}return Promise.all(O).then(function(){W._parent._endPerformanceCounter("Compile shadow generators")})},H.prototype._forEachExtensions=function(W){for(var O=0,P=this._extensions;O<P.length;O++){var Z=P[O];Z.enabled&&W(Z)}},H.prototype._applyExtensions=function(W,O,P){for(var Z=0,re=this._extensions;Z<re.length;Z++){var oe=re[Z];if(oe.enabled){var he="".concat(oe.name,".").concat(O),Ee=W;Ee._activeLoaderExtensionFunctions=Ee._activeLoaderExtensionFunctions||{};var Oe=Ee._activeLoaderExtensionFunctions;if(!Oe[he]){Oe[he]=!0;try{var Pe=P(oe);if(Pe)return Pe}finally{delete Oe[he]}}}}return null},H.prototype._extensionsOnLoading=function(){this._forEachExtensions(function(W){return W.onLoading&&W.onLoading()})},H.prototype._extensionsOnReady=function(){this._forEachExtensions(function(W){return W.onReady&&W.onReady()})},H.prototype._extensionsLoadSceneAsync=function(W,O){return this._applyExtensions(O,"loadScene",function(P){return P.loadSceneAsync&&P.loadSceneAsync(W,O)})},H.prototype._extensionsLoadNodeAsync=function(W,O,P){return this._applyExtensions(O,"loadNode",function(Z){return Z.loadNodeAsync&&Z.loadNodeAsync(W,O,P)})},H.prototype._extensionsLoadCameraAsync=function(W,O,P){return this._applyExtensions(O,"loadCamera",function(Z){return Z.loadCameraAsync&&Z.loadCameraAsync(W,O,P)})},H.prototype._extensionsLoadVertexDataAsync=function(W,O,P){return this._applyExtensions(O,"loadVertexData",function(Z){return Z._loadVertexDataAsync&&Z._loadVertexDataAsync(W,O,P)})},H.prototype._extensionsLoadMeshPrimitiveAsync=function(W,O,P,Z,re,oe){return this._applyExtensions(re,"loadMeshPrimitive",function(he){return he._loadMeshPrimitiveAsync&&he._loadMeshPrimitiveAsync(W,O,P,Z,re,oe)})},H.prototype._extensionsLoadMaterialAsync=function(W,O,P,Z,re){return this._applyExtensions(O,"loadMaterial",function(oe){return oe._loadMaterialAsync&&oe._loadMaterialAsync(W,O,P,Z,re)})},H.prototype._extensionsCreateMaterial=function(W,O,P){return this._applyExtensions(O,"createMaterial",function(Z){return Z.createMaterial&&Z.createMaterial(W,O,P)})},H.prototype._extensionsLoadMaterialPropertiesAsync=function(W,O,P){return this._applyExtensions(O,"loadMaterialProperties",function(Z){return Z.loadMaterialPropertiesAsync&&Z.loadMaterialPropertiesAsync(W,O,P)})},H.prototype._extensionsLoadTextureInfoAsync=function(W,O,P){return this._applyExtensions(O,"loadTextureInfo",function(Z){return Z.loadTextureInfoAsync&&Z.loadTextureInfoAsync(W,O,P)})},H.prototype._extensionsLoadTextureAsync=function(W,O,P){return this._applyExtensions(O,"loadTexture",function(Z){return Z._loadTextureAsync&&Z._loadTextureAsync(W,O,P)})},H.prototype._extensionsLoadAnimationAsync=function(W,O){return this._applyExtensions(O,"loadAnimation",function(P){return P.loadAnimationAsync&&P.loadAnimationAsync(W,O)})},H.prototype._extensionsLoadAnimationChannelAsync=function(W,O,P,Z,re){return this._applyExtensions(P,"loadAnimationChannel",function(oe){return oe._loadAnimationChannelAsync&&oe._loadAnimationChannelAsync(W,O,P,Z,re)})},H.prototype._extensionsLoadSkinAsync=function(W,O,P){return this._applyExtensions(P,"loadSkin",function(Z){return Z._loadSkinAsync&&Z._loadSkinAsync(W,O,P)})},H.prototype._extensionsLoadUriAsync=function(W,O,P){return this._applyExtensions(O,"loadUri",function(Z){return Z._loadUriAsync&&Z._loadUriAsync(W,O,P)})},H.prototype._extensionsLoadBufferViewAsync=function(W,O){return this._applyExtensions(O,"loadBufferView",function(P){return P.loadBufferViewAsync&&P.loadBufferViewAsync(W,O)})},H.prototype._extensionsLoadBufferAsync=function(W,O,P,Z){return this._applyExtensions(O,"loadBuffer",function(re){return re.loadBufferAsync&&re.loadBufferAsync(W,O,P,Z)})},H.LoadExtensionAsync=function(W,O,P,Z){if(!O.extensions)return null;var re=O.extensions,oe=re[P];return oe?Z("".concat(W,"/extensions/").concat(P),oe):null},H.LoadExtraAsync=function(W,O,P,Z){if(!O.extras)return null;var re=O.extras,oe=re[P];return oe?Z("".concat(W,"/extras/").concat(P),oe):null},H.prototype.isExtensionUsed=function(W){return!!this._gltf.extensionsUsed&&this._gltf.extensionsUsed.indexOf(W)!==-1},H.prototype.logOpen=function(W){this._parent._logOpen(W)},H.prototype.logClose=function(){this._parent._logClose()},H.prototype.log=function(W){this._parent._log(W)},H.prototype.startPerformanceCounter=function(W){this._parent._startPerformanceCounter(W)},H.prototype.endPerformanceCounter=function(W){this._parent._endPerformanceCounter(W)},H.DefaultSampler={index:-1},H}();j.GLTFFileLoader._CreateGLTF2Loader=function(H){return new ae(H)}},"../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{AnimationPropertyInfo:()=>A,TransformNodeAnimationPropertyInfo:()=>ne,WeightAnimationPropertyInfo:()=>ae,getQuaternion:()=>me,getVector3:()=>j,getWeights:()=>Se,nodeAnimationData:()=>H});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("babylonjs/Misc/tools");function j(W,O,P,Z){return z.Vector3.FromArray(O,P).scaleInPlace(Z)}function me(W,O,P,Z){return z.Quaternion.FromArray(O,P).scaleInPlace(Z)}function Se(W,O,P,Z){for(var re=new Array(W._numMorphTargets),oe=0;oe<re.length;oe++)re[oe]=O[P++]*Z;return re}var A=function(){function W(O,P,Z,re){this.type=O,this.name=P,this.getValue=Z,this.getStride=re}return W.prototype._buildAnimation=function(O,P,Z){var re=new z.Animation(O,this.name,P,this.type);return re.setKeys(Z),re},W}(),ne=function(W){(0,_.__extends)(O,W);function O(){return W!==null&&W.apply(this,arguments)||this}return O.prototype.buildAnimations=function(P,Z,re,oe,he){he(P._babylonTransformNode,this._buildAnimation(Z,re,oe))},O}(A),ae=function(W){(0,_.__extends)(O,W);function O(){return W!==null&&W.apply(this,arguments)||this}return O.prototype.buildAnimations=function(P,Z,re,oe,he){if(P._numMorphTargets)for(var Ee=function(Ae){var Ue=new z.Animation("".concat(Z,"_").concat(Ae),Oe.name,re,Oe.type);if(Ue.setKeys(oe.map(function(xt){return{frame:xt.frame,inTangent:xt.inTangent?xt.inTangent[Ae]:void 0,value:xt.value[Ae],outTangent:xt.outTangent?xt.outTangent[Ae]:void 0,interpolation:xt.interpolation}})),P._primitiveBabylonMeshes)for(var je=0,Ve=P._primitiveBabylonMeshes;je<Ve.length;je++){var ot=Ve[je];if(ot.morphTargetManager){var it=ot.morphTargetManager.getTarget(Ae),ft=Ue.clone();it.animations.push(ft),he(it,ft)}}},Oe=this,Pe=0;Pe<P._numMorphTargets;Pe++)Ee(Pe)},O}(A),H={translation:[new ne(z.Animation.ANIMATIONTYPE_VECTOR3,"position",j,function(){return 3})],rotation:[new ne(z.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",me,function(){return 4})],scale:[new ne(z.Animation.ANIMATIONTYPE_VECTOR3,"scaling",j,function(){return 3})],weights:[new ae(z.Animation.ANIMATIONTYPE_FLOAT,"influence",Se,function(W){return W._numMorphTargets})]}},"../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts":(nt,Ne,K)=>{K.r(Ne)},"../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{registerGLTFExtension:()=>me,registeredGLTFExtensions:()=>j,unregisterGLTFExtension:()=>Se});var _=K("babylonjs/Misc/tools"),z=new Map,j=z;function me(A,ne,ae){Se(A)&&_.Logger.Warn("Extension with the name '".concat(A,"' already exists")),z.set(A,{isGLTFExtension:ne,factory:ae})}function Se(A){return z.delete(A)}},"../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts":(nt,Ne,K)=>{K.r(Ne)},"../../../dev/loaders/src/glTF/2.0/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{ArrayItem:()=>_.ArrayItem,EXT_lights_image_based:()=>j.EXT_lights_image_based,EXT_mesh_gpu_instancing:()=>j.EXT_mesh_gpu_instancing,EXT_meshopt_compression:()=>j.EXT_meshopt_compression,EXT_texture_avif:()=>j.EXT_texture_avif,EXT_texture_webp:()=>j.EXT_texture_webp,ExtrasAsMetadata:()=>j.ExtrasAsMetadata,GLTFFileLoader:()=>_.GLTFFileLoader,GLTFLoader:()=>_.GLTFLoader,KHR_animation_pointer:()=>j.KHR_animation_pointer,KHR_draco_mesh_compression:()=>j.KHR_draco_mesh_compression,KHR_interactivity:()=>j.KHR_interactivity,KHR_lights:()=>j.KHR_lights,KHR_materials_anisotropy:()=>j.KHR_materials_anisotropy,KHR_materials_clearcoat:()=>j.KHR_materials_clearcoat,KHR_materials_diffuse_transmission:()=>j.KHR_materials_diffuse_transmission,KHR_materials_dispersion:()=>j.KHR_materials_dispersion,KHR_materials_emissive_strength:()=>j.KHR_materials_emissive_strength,KHR_materials_ior:()=>j.KHR_materials_ior,KHR_materials_iridescence:()=>j.KHR_materials_iridescence,KHR_materials_pbrSpecularGlossiness:()=>j.KHR_materials_pbrSpecularGlossiness,KHR_materials_sheen:()=>j.KHR_materials_sheen,KHR_materials_specular:()=>j.KHR_materials_specular,KHR_materials_transmission:()=>j.KHR_materials_transmission,KHR_materials_unlit:()=>j.KHR_materials_unlit,KHR_materials_variants:()=>j.KHR_materials_variants,KHR_materials_volume:()=>j.KHR_materials_volume,KHR_mesh_quantization:()=>j.KHR_mesh_quantization,KHR_texture_basisu:()=>j.KHR_texture_basisu,KHR_texture_transform:()=>j.KHR_texture_transform,KHR_xmp_json_ld:()=>j.KHR_xmp_json_ld,MSFT_audio_emitter:()=>j.MSFT_audio_emitter,MSFT_lod:()=>j.MSFT_lod,MSFT_minecraftMesh:()=>j.MSFT_minecraftMesh,MSFT_sRGBFactors:()=>j.MSFT_sRGBFactors,registerGLTFExtension:()=>z.registerGLTFExtension,registeredGLTFExtensions:()=>z.registeredGLTFExtensions,unregisterGLTFExtension:()=>z.unregisterGLTFExtension});var _=K("../../../dev/loaders/src/glTF/2.0/glTFLoader.ts");K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts");var z=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderExtensionRegistry.ts");K("../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts");var j=K("../../../dev/loaders/src/glTF/2.0/Extensions/index.ts")},"../../../dev/loaders/src/glTF/glTFFileLoader.metadata.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFFileLoaderMetadata:()=>z,GLTFMagicBase64Encoded:()=>_});var _="Z2xURg",z={name:"gltf",extensions:{".gltf":{isBinary:!1},".glb":{isBinary:!0}},canDirectLoad:function(j){return j.indexOf("asset")!==-1&&j.indexOf("version")!==-1||j.startsWith("data:base64,"+_)||j.startsWith("data:;base64,"+_)||j.startsWith("data:application/octet-stream;base64,"+_)||j.startsWith("data:model/gltf-binary;base64,"+_)}}},"../../../dev/loaders/src/glTF/glTFFileLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFFileLoader:()=>O,GLTFLoaderAnimationStartMode:()=>ae,GLTFLoaderCoordinateSystemMode:()=>ne,GLTFLoaderState:()=>H});var _=K("../../../../node_modules/tslib/tslib.es6.mjs"),z=K("babylonjs/Misc/tools"),j=K("../../../dev/loaders/src/glTF/glTFValidation.ts"),me=K("../../../dev/loaders/src/glTF/glTFFileLoader.metadata.ts");function Se(P,Z,re){try{return Promise.resolve(new Uint8Array(P,Z,re))}catch(oe){return Promise.reject(oe)}}function A(P,Z,re){try{if(Z<0||Z>=P.byteLength)throw new RangeError("Offset is out of range.");if(Z+re>P.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(P.buffer,P.byteOffset+Z,re))}catch(oe){return Promise.reject(oe)}}var ne;(function(P){P[P.AUTO=0]="AUTO",P[P.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(ne||(ne={}));var ae;(function(P){P[P.NONE=0]="NONE",P[P.FIRST=1]="FIRST",P[P.ALL=2]="ALL"})(ae||(ae={}));var H;(function(P){P[P.LOADING=0]="LOADING",P[P.READY=1]="READY",P[P.COMPLETE=2]="COMPLETE"})(H||(H={}));var W=function(){function P(){this.coordinateSystemMode=ne.AUTO,this.animationStartMode=ae.FIRST,this.loadNodeAnimations=!0,this.loadSkins=!0,this.loadMorphTargets=!0,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(Z){return Promise.resolve(Z)},this.extensionOptions={}}return P.prototype.copyFrom=function(Z){var re,oe,he,Ee,Oe,Pe,Ae,Ue,je,Ve,ot,it,ft,xt,qe,kt,V,gt,tt,Jt;Z&&(this.onParsed=Z.onParsed,this.coordinateSystemMode=(re=Z.coordinateSystemMode)!==null&&re!==void 0?re:this.coordinateSystemMode,this.animationStartMode=(oe=Z.animationStartMode)!==null&&oe!==void 0?oe:this.animationStartMode,this.loadNodeAnimations=(he=Z.loadNodeAnimations)!==null&&he!==void 0?he:this.loadNodeAnimations,this.loadSkins=(Ee=Z.loadSkins)!==null&&Ee!==void 0?Ee:this.loadSkins,this.loadMorphTargets=(Oe=Z.loadMorphTargets)!==null&&Oe!==void 0?Oe:this.loadMorphTargets,this.compileMaterials=(Pe=Z.compileMaterials)!==null&&Pe!==void 0?Pe:this.compileMaterials,this.useClipPlane=(Ae=Z.useClipPlane)!==null&&Ae!==void 0?Ae:this.useClipPlane,this.compileShadowGenerators=(Ue=Z.compileShadowGenerators)!==null&&Ue!==void 0?Ue:this.compileShadowGenerators,this.transparencyAsCoverage=(je=Z.transparencyAsCoverage)!==null&&je!==void 0?je:this.transparencyAsCoverage,this.useRangeRequests=(Ve=Z.useRangeRequests)!==null&&Ve!==void 0?Ve:this.useRangeRequests,this.createInstances=(ot=Z.createInstances)!==null&&ot!==void 0?ot:this.createInstances,this.alwaysComputeBoundingBox=(it=Z.alwaysComputeBoundingBox)!==null&&it!==void 0?it:this.alwaysComputeBoundingBox,this.loadAllMaterials=(ft=Z.loadAllMaterials)!==null&&ft!==void 0?ft:this.loadAllMaterials,this.loadOnlyMaterials=(xt=Z.loadOnlyMaterials)!==null&&xt!==void 0?xt:this.loadOnlyMaterials,this.skipMaterials=(qe=Z.skipMaterials)!==null&&qe!==void 0?qe:this.skipMaterials,this.useSRGBBuffers=(kt=Z.useSRGBBuffers)!==null&&kt!==void 0?kt:this.useSRGBBuffers,this.targetFps=(V=Z.targetFps)!==null&&V!==void 0?V:this.targetFps,this.alwaysComputeSkeletonRootNode=(gt=Z.alwaysComputeSkeletonRootNode)!==null&>!==void 0?gt:this.alwaysComputeSkeletonRootNode,this.preprocessUrlAsync=(tt=Z.preprocessUrlAsync)!==null&&tt!==void 0?tt:this.preprocessUrlAsync,this.customRootNode=Z.customRootNode,this.onMeshLoaded=Z.onMeshLoaded,this.onSkinLoaded=Z.onSkinLoaded,this.onTextureLoaded=Z.onTextureLoaded,this.onMaterialLoaded=Z.onMaterialLoaded,this.onCameraLoaded=Z.onCameraLoaded,this.extensionOptions=(Jt=Z.extensionOptions)!==null&&Jt!==void 0?Jt:this.extensionOptions)},P}(),O=function(P){(0,_.__extends)(Z,P);function Z(re){var oe=P.call(this)||this;return oe.onParsedObservable=new z.Observable,oe.onMeshLoadedObservable=new z.Observable,oe.onSkinLoadedObservable=new z.Observable,oe.onTextureLoadedObservable=new z.Observable,oe.onMaterialLoadedObservable=new z.Observable,oe.onCameraLoadedObservable=new z.Observable,oe.onCompleteObservable=new z.Observable,oe.onErrorObservable=new z.Observable,oe.onDisposeObservable=new z.Observable,oe.onExtensionLoadedObservable=new z.Observable,oe.validate=!1,oe.onValidatedObservable=new z.Observable,oe._loader=null,oe._state=null,oe._requests=new Array,oe.name=me.GLTFFileLoaderMetadata.name,oe.extensions=me.GLTFFileLoaderMetadata.extensions,oe.onLoaderStateChangedObservable=new z.Observable,oe._logIndentLevel=0,oe._loggingEnabled=!1,oe._log=oe._logDisabled,oe._capturePerformanceCounters=!1,oe._startPerformanceCounter=oe._startPerformanceCounterDisabled,oe._endPerformanceCounter=oe._endPerformanceCounterDisabled,oe.copyFrom(re),oe}return Object.defineProperty(Z.prototype,"onParsed",{set:function(re){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),re&&(this._onParsedObserver=this.onParsedObservable.add(re))},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onMeshLoaded",{set:function(re){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),re&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(re))},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onSkinLoaded",{set:function(re){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),re&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(function(oe){return re(oe.node,oe.skinnedNode)}))},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onTextureLoaded",{set:function(re){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),re&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(re))},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onMaterialLoaded",{set:function(re){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),re&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(re))},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onCameraLoaded",{set:function(re){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),re&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(re))},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onComplete",{set:function(re){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(re)},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onError",{set:function(re){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(re)},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onDispose",{set:function(re){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(re)},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onExtensionLoaded",{set:function(re){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(re)},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(re){this._loggingEnabled!==re&&(this._loggingEnabled=re,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(re){this._capturePerformanceCounters!==re&&(this._capturePerformanceCounters=re,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,"onValidated",{set:function(re){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(re)},enumerable:!1,configurable:!0}),Z.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var re=0,oe=this._requests;re<oe.length;re++){var he=oe[re];he.abort()}this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=function(Ee){return Promise.resolve(Ee)},this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},Z.prototype.loadFile=function(re,oe,he,Ee,Oe,Pe,Ae,Ue){var je=this;if(ArrayBuffer.isView(oe))return this._loadBinary(re,oe,he,Ee,Ae,Ue),null;this._progressCallback=Oe;var Ve=oe.name||z.Tools.GetFilename(oe);if(Pe){if(this.useRangeRequests){this.validate&&z.Logger.Warn("glTF validation is not supported when range requests are enabled");var ot={abort:function(){},onCompleteObservable:new z.Observable},it={readAsync:function(ft,xt){return new Promise(function(qe,kt){je._loadFile(re,oe,function(V){qe(new Uint8Array(V))},!0,function(V){kt(V)},function(V){V.setRequestHeader("Range","bytes=".concat(ft,"-").concat(ft+xt-1))})})},byteLength:0};return this._unpackBinaryAsync(new z.DataReader(it)).then(function(ft){ot.onCompleteObservable.notifyObservers(ot),Ee(ft)},Ae?function(ft){return Ae(void 0,ft)}:void 0),ot}return this._loadFile(re,oe,function(ft){je._validate(re,new Uint8Array(ft,0,ft.byteLength),he,Ve),je._unpackBinaryAsync(new z.DataReader({readAsync:function(xt,qe){return Se(ft,xt,qe)},byteLength:ft.byteLength})).then(function(xt){Ee(xt)},Ae?function(xt){return Ae(void 0,xt)}:void 0)},!0,Ae)}else return this._loadFile(re,oe,function(ft){try{je._validate(re,ft,he,Ve),Ee({json:je._parseJson(ft)})}catch{Ae&&Ae()}},!1,Ae)},Z.prototype._loadBinary=function(re,oe,he,Ee,Oe,Pe){this._validate(re,new Uint8Array(oe.buffer,oe.byteOffset,oe.byteLength),he,Pe),this._unpackBinaryAsync(new z.DataReader({readAsync:function(Ae,Ue){return A(oe,Ae,Ue)},byteLength:oe.byteLength})).then(function(Ae){Ee(Ae)},Oe?function(Ae){return Oe(void 0,Ae)}:void 0)},Z.prototype.importMeshAsync=function(re,oe,he,Ee,Oe,Pe){var Ae=this;return Promise.resolve().then(function(){return Ae.onParsedObservable.notifyObservers(he),Ae.onParsedObservable.clear(),Ae._log("Loading ".concat(Pe||"")),Ae._loader=Ae._getLoader(he),Ae._loader.importMeshAsync(re,oe,null,he,Ee,Oe,Pe)})},Z.prototype.loadAsync=function(re,oe,he,Ee,Oe){var Pe=this;return Promise.resolve().then(function(){return Pe.onParsedObservable.notifyObservers(oe),Pe.onParsedObservable.clear(),Pe._log("Loading ".concat(Oe||"")),Pe._loader=Pe._getLoader(oe),Pe._loader.loadAsync(re,oe,he,Ee,Oe)})},Z.prototype.loadAssetContainerAsync=function(re,oe,he,Ee,Oe){var Pe=this;return Promise.resolve().then(function(){Pe.onParsedObservable.notifyObservers(oe),Pe.onParsedObservable.clear(),Pe._log("Loading ".concat(Oe||"")),Pe._loader=Pe._getLoader(oe);var Ae=new z.AssetContainer(re),Ue=[];Pe.onMaterialLoadedObservable.add(function(it){Ue.push(it)});var je=[];Pe.onTextureLoadedObservable.add(function(it){je.push(it)});var Ve=[];Pe.onCameraLoadedObservable.add(function(it){Ve.push(it)});var ot=[];return Pe.onMeshLoadedObservable.add(function(it){it.morphTargetManager&&ot.push(it.morphTargetManager)}),Pe._loader.importMeshAsync(null,re,Ae,oe,he,Ee,Oe).then(function(it){return Array.prototype.push.apply(Ae.geometries,it.geometries),Array.prototype.push.apply(Ae.meshes,it.meshes),Array.prototype.push.apply(Ae.particleSystems,it.particleSystems),Array.prototype.push.apply(Ae.skeletons,it.skeletons),Array.prototype.push.apply(Ae.animationGroups,it.animationGroups),Array.prototype.push.apply(Ae.materials,Ue),Array.prototype.push.apply(Ae.textures,je),Array.prototype.push.apply(Ae.lights,it.lights),Array.prototype.push.apply(Ae.transformNodes,it.transformNodes),Array.prototype.push.apply(Ae.cameras,Ve),Array.prototype.push.apply(Ae.morphTargetManagers,ot),Ae})})},Z.prototype.canDirectLoad=function(re){return me.GLTFFileLoaderMetadata.canDirectLoad(re)},Z.prototype.directLoad=function(re,oe){if(oe.startsWith("base64,"+me.GLTFMagicBase64Encoded)||oe.startsWith(";base64,"+me.GLTFMagicBase64Encoded)||oe.startsWith("application/octet-stream;base64,"+me.GLTFMagicBase64Encoded)||oe.startsWith("model/gltf-binary;base64,"+me.GLTFMagicBase64Encoded)){var he=(0,z.DecodeBase64UrlToBinary)(oe);return this._validate(re,new Uint8Array(he,0,he.byteLength)),this._unpackBinaryAsync(new z.DataReader({readAsync:function(Ee,Oe){return Se(he,Ee,Oe)},byteLength:he.byteLength}))}return this._validate(re,oe),Promise.resolve({json:this._parseJson(oe)})},Z.prototype.createPlugin=function(re){return new Z(re[me.GLTFFileLoaderMetadata.name])},Object.defineProperty(Z.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),Z.prototype.whenCompleteAsync=function(){var re=this;return new Promise(function(oe,he){re.onCompleteObservable.addOnce(function(){oe()}),re.onErrorObservable.addOnce(function(Ee){he(Ee)})})},Z.prototype._setState=function(re){this._state!==re&&(this._state=re,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(H[this._state]))},Z.prototype._loadFile=function(re,oe,he,Ee,Oe,Pe){var Ae=this,Ue=re._loadFile(oe,he,function(je){Ae._onProgress(je,Ue)},!0,Ee,Oe,Pe);return Ue.onCompleteObservable.add(function(){Ue._lengthComputable=!0,Ue._total=Ue._loaded}),this._requests.push(Ue),Ue},Z.prototype._onProgress=function(re,oe){if(this._progressCallback){oe._lengthComputable=re.lengthComputable,oe._loaded=re.loaded,oe._total=re.total;for(var he=!0,Ee=0,Oe=0,Pe=0,Ae=this._requests;Pe<Ae.length;Pe++){var Ue=Ae[Pe];if(Ue._lengthComputable===void 0||Ue._loaded===void 0||Ue._total===void 0)return;he=he&&Ue._lengthComputable,Ee+=Ue._loaded,Oe+=Ue._total}this._progressCallback({lengthComputable:he,loaded:Ee,total:he?Oe:0})}},Z.prototype._validate=function(re,oe,he,Ee){var Oe=this;he===void 0&&(he=""),Ee===void 0&&(Ee=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),j.GLTFValidation.ValidateAsync(oe,he,Ee,function(Pe){return Oe.preprocessUrlAsync(he+Pe).then(function(Ae){return re._loadFileAsync(Ae,void 0,!0,!0).then(function(Ue){return new Uint8Array(Ue,0,Ue.byteLength)})})}).then(function(Pe){Oe._endPerformanceCounter("Validate JSON"),Oe.onValidatedObservable.notifyObservers(Pe),Oe.onValidatedObservable.clear()},function(Pe){Oe._endPerformanceCounter("Validate JSON"),z.Tools.Warn("Failed to validate: ".concat(Pe.message)),Oe.onValidatedObservable.clear()}))},Z.prototype._getLoader=function(re){var oe=re.json.asset||{};this._log("Asset version: ".concat(oe.version)),oe.minVersion&&this._log("Asset minimum version: ".concat(oe.minVersion)),oe.generator&&this._log("Asset generator: ".concat(oe.generator));var he=Z._parseVersion(oe.version);if(!he)throw new Error("Invalid version: "+oe.version);if(oe.minVersion!==void 0){var Ee=Z._parseVersion(oe.minVersion);if(!Ee)throw new Error("Invalid minimum version: "+oe.minVersion);if(Z._compareVersion(Ee,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+oe.minVersion)}var Oe={1:Z._CreateGLTF1Loader,2:Z._CreateGLTF2Loader},Pe=Oe[he.major];if(!Pe)throw new Error("Unsupported version: "+oe.version);return Pe(this)},Z.prototype._parseJson=function(re){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(re.length));var oe=JSON.parse(re);return this._endPerformanceCounter("Parse JSON"),oe},Z.prototype._unpackBinaryAsync=function(re){var oe=this;return this._startPerformanceCounter("Unpack Binary"),re.loadAsync(20).then(function(){var he={Magic:1179937895},Ee=re.readUint32();if(Ee!==he.Magic)throw new z.RuntimeError("Unexpected magic: "+Ee,z.ErrorCodes.GLTFLoaderUnexpectedMagicError);var Oe=re.readUint32();oe.loggingEnabled&&oe._log("Binary version: ".concat(Oe));var Pe=re.readUint32();!oe.useRangeRequests&&Pe!==re.buffer.byteLength&&z.Logger.Warn("Length in header does not match actual data length: ".concat(Pe," != ").concat(re.buffer.byteLength));var Ae;switch(Oe){case 1:{Ae=oe._unpackBinaryV1Async(re,Pe);break}case 2:{Ae=oe._unpackBinaryV2Async(re,Pe);break}default:throw new Error("Unsupported version: "+Oe)}return oe._endPerformanceCounter("Unpack Binary"),Ae})},Z.prototype._unpackBinaryV1Async=function(re,oe){var he={JSON:0},Ee=re.readUint32(),Oe=re.readUint32();if(Oe!==he.JSON)throw new Error("Unexpected content format: ".concat(Oe));var Pe=oe-re.byteOffset,Ae={json:this._parseJson(re.readString(Ee)),bin:null};if(Pe!==0){var Ue=re.byteOffset;Ae.bin={readAsync:function(je,Ve){return re.buffer.readAsync(Ue+je,Ve)},byteLength:Pe}}return Promise.resolve(Ae)},Z.prototype._unpackBinaryV2Async=function(re,oe){var he=this,Ee={JSON:1313821514,BIN:5130562},Oe=re.readUint32(),Pe=re.readUint32();if(Pe!==Ee.JSON)throw new Error("First chunk format is not JSON");return re.byteOffset+Oe===oe?re.loadAsync(Oe).then(function(){return{json:he._parseJson(re.readString(Oe)),bin:null}}):re.loadAsync(Oe+8).then(function(){var Ae={json:he._parseJson(re.readString(Oe)),bin:null},Ue=function(){var je=re.readUint32(),Ve=re.readUint32();switch(Ve){case Ee.JSON:throw new Error("Unexpected JSON chunk");case Ee.BIN:{var ot=re.byteOffset;Ae.bin={readAsync:function(it,ft){return re.buffer.readAsync(ot+it,ft)},byteLength:je},re.skipBytes(je);break}default:{re.skipBytes(je);break}}return re.byteOffset!==oe?re.loadAsync(8).then(Ue):Promise.resolve(Ae)};return Ue()})},Z._parseVersion=function(re){if(re==="1.0"||re==="1.0.1")return{major:1,minor:0};var oe=(re+"").match(/^(\d+)\.(\d+)/);return oe?{major:parseInt(oe[1]),minor:parseInt(oe[2])}:null},Z._compareVersion=function(re,oe){return re.major>oe.major?1:re.major<oe.major?-1:re.minor>oe.minor?1:re.minor<oe.minor?-1:0},Z.prototype._logOpen=function(re){this._log(re),this._logIndentLevel++},Z.prototype._logClose=function(){--this._logIndentLevel},Z.prototype._logEnabled=function(re){var oe=Z._logSpaces.substring(0,this._logIndentLevel*2);z.Logger.Log("".concat(oe).concat(re))},Z.prototype._logDisabled=function(re){},Z.prototype._startPerformanceCounterEnabled=function(re){z.Tools.StartPerformanceCounter(re)},Z.prototype._startPerformanceCounterDisabled=function(re){},Z.prototype._endPerformanceCounterEnabled=function(re){z.Tools.EndPerformanceCounter(re)},Z.prototype._endPerformanceCounterDisabled=function(re){},Z.IncrementalLoading=!0,Z.HomogeneousCoordinates=!1,Z._logSpaces=" ",Z}(W);(0,z.registerSceneLoaderPlugin)(new O)},"../../../dev/loaders/src/glTF/glTFValidation.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFValidation:()=>me});var _=K("babylonjs/Misc/tools");function z(Se,A,ne,ae){var H={externalResourceFunction:ae};return ne&&(H.uri=A==="file:"?ne:A+ne),ArrayBuffer.isView(Se)?GLTFValidator.validateBytes(Se,H):GLTFValidator.validateString(Se,H)}function j(){var Se=[];onmessage=function(A){var ne=A.data;switch(ne.id){case"init":{importScripts(ne.url);break}case"validate":{z(ne.data,ne.rootUrl,ne.fileName,function(ae){return new Promise(function(H,W){var O=Se.length;Se.push({resolve:H,reject:W}),postMessage({id:"getExternalResource",index:O,uri:ae})})}).then(function(ae){postMessage({id:"validate.resolve",value:ae})},function(ae){postMessage({id:"validate.reject",reason:ae})});break}case"getExternalResource.resolve":{Se[ne.index].resolve(ne.value);break}case"getExternalResource.reject":{Se[ne.index].reject(ne.reason);break}}}}var me=function(){function Se(){}return Se.ValidateAsync=function(A,ne,ae,H){var W=this;return typeof Worker=="function"?new Promise(function(O,P){var Z="".concat(z,"(").concat(j,")()"),re=URL.createObjectURL(new Blob([Z],{type:"application/javascript"})),oe=new Worker(re),he=function(Pe){oe.removeEventListener("error",he),oe.removeEventListener("message",Ee),P(Pe)},Ee=function(Pe){var Ae=Pe.data;switch(Ae.id){case"getExternalResource":{H(Ae.uri).then(function(Ue){oe.postMessage({id:"getExternalResource.resolve",index:Ae.index,value:Ue},[Ue.buffer])},function(Ue){oe.postMessage({id:"getExternalResource.reject",index:Ae.index,reason:Ue})});break}case"validate.resolve":{oe.removeEventListener("error",he),oe.removeEventListener("message",Ee),O(Ae.value),oe.terminate();break}case"validate.reject":oe.removeEventListener("error",he),oe.removeEventListener("message",Ee),P(Ae.reason),oe.terminate()}};if(oe.addEventListener("error",he),oe.addEventListener("message",Ee),oe.postMessage({id:"init",url:_.Tools.GetBabylonScriptURL(W.Configuration.url)}),ArrayBuffer.isView(A)){var Oe=A.slice();oe.postMessage({id:"validate",data:Oe,rootUrl:ne,fileName:ae},[Oe.buffer])}else oe.postMessage({id:"validate",data:A,rootUrl:ne,fileName:ae})}):(this._LoadScriptPromise||(this._LoadScriptPromise=_.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(function(){return z(A,ne,ae,H)}))},Se.Configuration={url:"".concat(_.Tools._DefaultCdnUrl,"/gltf_validator.js")},Se}()},"../../../dev/loaders/src/glTF/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTF1:()=>j,GLTF2:()=>me,GLTFFileLoader:()=>_.GLTFFileLoader,GLTFLoaderAnimationStartMode:()=>_.GLTFLoaderAnimationStartMode,GLTFLoaderCoordinateSystemMode:()=>_.GLTFLoaderCoordinateSystemMode,GLTFLoaderState:()=>_.GLTFLoaderState,GLTFValidation:()=>z.GLTFValidation});var _=K("../../../dev/loaders/src/glTF/glTFFileLoader.ts"),z=K("../../../dev/loaders/src/glTF/glTFValidation.ts"),j=K("../../../dev/loaders/src/glTF/1.0/index.ts"),me=K("../../../dev/loaders/src/glTF/2.0/index.ts")},"../../../dev/loaders/src/index.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTF1:()=>_.GLTF1,GLTF2:()=>_.GLTF2,GLTFFileLoader:()=>_.GLTFFileLoader,GLTFLoaderAnimationStartMode:()=>_.GLTFLoaderAnimationStartMode,GLTFLoaderCoordinateSystemMode:()=>_.GLTFLoaderCoordinateSystemMode,GLTFLoaderState:()=>_.GLTFLoaderState,GLTFValidation:()=>_.GLTFValidation,MTLFileLoader:()=>z.MTLFileLoader,OBJFileLoader:()=>z.OBJFileLoader,SPLATFileLoader:()=>me.SPLATFileLoader,STLFileLoader:()=>j.STLFileLoader,SolidParser:()=>z.SolidParser});var _=K("../../../dev/loaders/src/glTF/index.ts"),z=K("../../../dev/loaders/src/OBJ/index.ts"),j=K("../../../dev/loaders/src/STL/index.ts"),me=K("../../../dev/loaders/src/SPLAT/index.ts")},"../../../lts/loaders/src/legacy/legacy-glTF.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTFFileLoader:()=>_.GLTFFileLoader,GLTFLoaderAnimationStartMode:()=>_.GLTFLoaderAnimationStartMode,GLTFLoaderCoordinateSystemMode:()=>_.GLTFLoaderCoordinateSystemMode,GLTFLoaderState:()=>_.GLTFLoaderState,GLTFValidation:()=>z.GLTFValidation});var _=K("../../../dev/loaders/src/glTF/glTFFileLoader.ts"),z=K("../../../dev/loaders/src/glTF/glTFValidation.ts"),j=typeof K.g<"u"?K.g:typeof window<"u"?window:void 0;if(typeof j<"u"){j.BABYLON=j.BABYLON||{};for(var me in _)j.BABYLON[me]=_[me];for(var me in z)j.BABYLON[me]=z[me]}},"../../../lts/loaders/src/legacy/legacy-glTF1.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTF1:()=>_});var _=K("../../../dev/loaders/src/glTF/1.0/index.ts"),z=typeof K.g<"u"?K.g:typeof window<"u"?window:void 0;if(typeof z<"u"){z.BABYLON=z.BABYLON||{},z.BABYLON.GLTF1=z.BABYLON.GLTF1||{};for(var j in _)z.BABYLON.GLTF1[j]=_[j]}},"../../../lts/loaders/src/legacy/legacy-glTF2.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTF2:()=>j});var _=K("../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"),z=K("../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"),j=K("../../../dev/loaders/src/glTF/2.0/index.ts"),me=typeof K.g<"u"?K.g:typeof window<"u"?window:void 0;if(typeof me<"u"){me.BABYLON=me.BABYLON||{};var Se=me.BABYLON;Se.GLTF2=Se.GLTF2||{},Se.GLTF2.Loader=Se.GLTF2.Loader||{},Se.GLTF2.Loader.Extensions=Se.GLTF2.Loader.Extensions||{};var A=[];for(var ne in _)Se.GLTF2.Loader.Extensions[ne]=_[ne],A.push(ne);for(var ne in z)Se.GLTF2.Loader[ne]=z[ne],A.push(ne);for(var ne in j)A.indexOf(ne)>-1||(Se.GLTF2[ne]=j[ne])}},"../../../lts/loaders/src/legacy/legacy-objFileLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{MTLFileLoader:()=>_.MTLFileLoader,OBJFileLoader:()=>_.OBJFileLoader,SolidParser:()=>_.SolidParser});var _=K("../../../dev/loaders/src/OBJ/index.ts"),z=typeof K.g<"u"?K.g:typeof window<"u"?window:void 0;if(typeof z<"u")for(var j in _)z.BABYLON[j]||(z.BABYLON[j]=_[j])},"../../../lts/loaders/src/legacy/legacy-stlFileLoader.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{STLFileLoader:()=>_.STLFileLoader});var _=K("../../../dev/loaders/src/STL/index.ts"),z=typeof K.g<"u"?K.g:typeof window<"u"?window:void 0;if(typeof z<"u")for(var j in _)z.BABYLON[j]||(z.BABYLON[j]=_[j])},"../../../lts/loaders/src/legacy/legacy.ts":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{GLTF1:()=>_.GLTF1,GLTF2:()=>_.GLTF2,GLTFFileLoader:()=>_.GLTFFileLoader,GLTFLoaderAnimationStartMode:()=>_.GLTFLoaderAnimationStartMode,GLTFLoaderCoordinateSystemMode:()=>_.GLTFLoaderCoordinateSystemMode,GLTFLoaderState:()=>_.GLTFLoaderState,GLTFValidation:()=>_.GLTFValidation,MTLFileLoader:()=>_.MTLFileLoader,OBJFileLoader:()=>_.OBJFileLoader,SPLATFileLoader:()=>_.SPLATFileLoader,STLFileLoader:()=>_.STLFileLoader,SolidParser:()=>_.SolidParser});var _=K("../../../dev/loaders/src/index.ts");K("../../../lts/loaders/src/legacy/legacy-glTF.ts"),K("../../../lts/loaders/src/legacy/legacy-glTF1.ts"),K("../../../lts/loaders/src/legacy/legacy-glTF2.ts"),K("../../../lts/loaders/src/legacy/legacy-objFileLoader.ts"),K("../../../lts/loaders/src/legacy/legacy-stlFileLoader.ts")},"babylonjs/Misc/tools":nt=>{nt.exports=Cn},"../../../../node_modules/tslib/tslib.es6.mjs":(nt,Ne,K)=>{K.r(Ne),K.d(Ne,{__addDisposableResource:()=>tt,__assign:()=>j,__asyncDelegator:()=>Ve,__asyncGenerator:()=>je,__asyncValues:()=>ot,__await:()=>Ue,__awaiter:()=>P,__classPrivateFieldGet:()=>kt,__classPrivateFieldIn:()=>gt,__classPrivateFieldSet:()=>V,__createBinding:()=>re,__decorate:()=>Se,__disposeResources:()=>At,__esDecorate:()=>ne,__exportStar:()=>oe,__extends:()=>z,__generator:()=>Z,__importDefault:()=>qe,__importStar:()=>xt,__makeTemplateObject:()=>it,__metadata:()=>O,__param:()=>A,__propKey:()=>H,__read:()=>Ee,__rest:()=>me,__runInitializers:()=>ae,__setFunctionName:()=>W,__spread:()=>Oe,__spreadArray:()=>Ae,__spreadArrays:()=>Pe,__values:()=>he,default:()=>gn});var _=function(We,Xe){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Ze,ge){Ze.__proto__=ge}||function(Ze,ge){for(var pe in ge)Object.prototype.hasOwnProperty.call(ge,pe)&&(Ze[pe]=ge[pe])},_(We,Xe)};function z(We,Xe){if(typeof Xe!="function"&&Xe!==null)throw new TypeError("Class extends value "+String(Xe)+" is not a constructor or null");_(We,Xe);function Ze(){this.constructor=We}We.prototype=Xe===null?Object.create(Xe):(Ze.prototype=Xe.prototype,new Ze)}var j=function(){return j=Object.assign||function(Xe){for(var Ze,ge=1,pe=arguments.length;ge<pe;ge++){Ze=arguments[ge];for(var Ce in Ze)Object.prototype.hasOwnProperty.call(Ze,Ce)&&(Xe[Ce]=Ze[Ce])}return Xe},j.apply(this,arguments)};function me(We,Xe){var Ze={};for(var ge in We)Object.prototype.hasOwnProperty.call(We,ge)&&Xe.indexOf(ge)<0&&(Ze[ge]=We[ge]);if(We!=null&&typeof Object.getOwnPropertySymbols=="function")for(var pe=0,ge=Object.getOwnPropertySymbols(We);pe<ge.length;pe++)Xe.indexOf(ge[pe])<0&&Object.prototype.propertyIsEnumerable.call(We,ge[pe])&&(Ze[ge[pe]]=We[ge[pe]]);return Ze}function Se(We,Xe,Ze,ge){var pe=arguments.length,Ce=pe<3?Xe:ge===null?ge=Object.getOwnPropertyDescriptor(Xe,Ze):ge,De;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Ce=Reflect.decorate(We,Xe,Ze,ge);else for(var Fe=We.length-1;Fe>=0;Fe--)(De=We[Fe])&&(Ce=(pe<3?De(Ce):pe>3?De(Xe,Ze,Ce):De(Xe,Ze))||Ce);return pe>3&&Ce&&Object.defineProperty(Xe,Ze,Ce),Ce}function A(We,Xe){return function(Ze,ge){Xe(Ze,ge,We)}}function ne(We,Xe,Ze,ge,pe,Ce){function De(wt){if(wt!==void 0&&typeof wt!="function")throw new TypeError("Function expected");return wt}for(var Fe=ge.kind,Le=Fe==="getter"?"get":Fe==="setter"?"set":"value",Ye=!Xe&&We?ge.static?We:We.prototype:null,ct=Xe||(Ye?Object.getOwnPropertyDescriptor(Ye,ge.name):{}),ke,et=!1,st=Ze.length-1;st>=0;st--){var Ct={};for(var bt in ge)Ct[bt]=bt==="access"?{}:ge[bt];for(var bt in ge.access)Ct.access[bt]=ge.access[bt];Ct.addInitializer=function(wt){if(et)throw new TypeError("Cannot add initializers after decoration has completed");Ce.push(De(wt||null))};var Rt=(0,Ze[st])(Fe==="accessor"?{get:ct.get,set:ct.set}:ct[Le],Ct);if(Fe==="accessor"){if(Rt===void 0)continue;if(Rt===null||typeof Rt!="object")throw new TypeError("Object expected");(ke=De(Rt.get))&&(ct.get=ke),(ke=De(Rt.set))&&(ct.set=ke),(ke=De(Rt.init))&&pe.unshift(ke)}else(ke=De(Rt))&&(Fe==="field"?pe.unshift(ke):ct[Le]=ke)}Ye&&Object.defineProperty(Ye,ge.name,ct),et=!0}function ae(We,Xe,Ze){for(var ge=arguments.length>2,pe=0;pe<Xe.length;pe++)Ze=ge?Xe[pe].call(We,Ze):Xe[pe].call(We);return ge?Ze:void 0}function H(We){return typeof We=="symbol"?We:"".concat(We)}function W(We,Xe,Ze){return typeof Xe=="symbol"&&(Xe=Xe.description?"[".concat(Xe.description,"]"):""),Object.defineProperty(We,"name",{configurable:!0,value:Ze?"".concat(Ze," ",Xe):Xe})}function O(We,Xe){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(We,Xe)}function P(We,Xe,Ze,ge){function pe(Ce){return Ce instanceof Ze?Ce:new Ze(function(De){De(Ce)})}return new(Ze||(Ze=Promise))(function(Ce,De){function Fe(ct){try{Ye(ge.next(ct))}catch(ke){De(ke)}}function Le(ct){try{Ye(ge.throw(ct))}catch(ke){De(ke)}}function Ye(ct){ct.done?Ce(ct.value):pe(ct.value).then(Fe,Le)}Ye((ge=ge.apply(We,Xe||[])).next())})}function Z(We,Xe){var Ze={label:0,sent:function(){if(Ce[0]&1)throw Ce[1];return Ce[1]},trys:[],ops:[]},ge,pe,Ce,De=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return De.next=Fe(0),De.throw=Fe(1),De.return=Fe(2),typeof Symbol=="function"&&(De[Symbol.iterator]=function(){return this}),De;function Fe(Ye){return function(ct){return Le([Ye,ct])}}function Le(Ye){if(ge)throw new TypeError("Generator is already executing.");for(;De&&(De=0,Ye[0]&&(Ze=0)),Ze;)try{if(ge=1,pe&&(Ce=Ye[0]&2?pe.return:Ye[0]?pe.throw||((Ce=pe.return)&&Ce.call(pe),0):pe.next)&&!(Ce=Ce.call(pe,Ye[1])).done)return Ce;switch(pe=0,Ce&&(Ye=[Ye[0]&2,Ce.value]),Ye[0]){case 0:case 1:Ce=Ye;break;case 4:return Ze.label++,{value:Ye[1],done:!1};case 5:Ze.label++,pe=Ye[1],Ye=[0];continue;case 7:Ye=Ze.ops.pop(),Ze.trys.pop();continue;default:if(Ce=Ze.trys,!(Ce=Ce.length>0&&Ce[Ce.length-1])&&(Ye[0]===6||Ye[0]===2)){Ze=0;continue}if(Ye[0]===3&&(!Ce||Ye[1]>Ce[0]&&Ye[1]<Ce[3])){Ze.label=Ye[1];break}if(Ye[0]===6&&Ze.label<Ce[1]){Ze.label=Ce[1],Ce=Ye;break}if(Ce&&Ze.label<Ce[2]){Ze.label=Ce[2],Ze.ops.push(Ye);break}Ce[2]&&Ze.ops.pop(),Ze.trys.pop();continue}Ye=Xe.call(We,Ze)}catch(ct){Ye=[6,ct],pe=0}finally{ge=Ce=0}if(Ye[0]&5)throw Ye[1];return{value:Ye[0]?Ye[1]:void 0,done:!0}}}var re=Object.create?function(We,Xe,Ze,ge){ge===void 0&&(ge=Ze);var pe=Object.getOwnPropertyDescriptor(Xe,Ze);(!pe||("get"in pe?!Xe.__esModule:pe.writable||pe.configurable))&&(pe={enumerable:!0,get:function(){return Xe[Ze]}}),Object.defineProperty(We,ge,pe)}:function(We,Xe,Ze,ge){ge===void 0&&(ge=Ze),We[ge]=Xe[Ze]};function oe(We,Xe){for(var Ze in We)Ze!=="default"&&!Object.prototype.hasOwnProperty.call(Xe,Ze)&&re(Xe,We,Ze)}function he(We){var Xe=typeof Symbol=="function"&&Symbol.iterator,Ze=Xe&&We[Xe],ge=0;if(Ze)return Ze.call(We);if(We&&typeof We.length=="number")return{next:function(){return We&&ge>=We.length&&(We=void 0),{value:We&&We[ge++],done:!We}}};throw new TypeError(Xe?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ee(We,Xe){var Ze=typeof Symbol=="function"&&We[Symbol.iterator];if(!Ze)return We;var ge=Ze.call(We),pe,Ce=[],De;try{for(;(Xe===void 0||Xe-- >0)&&!(pe=ge.next()).done;)Ce.push(pe.value)}catch(Fe){De={error:Fe}}finally{try{pe&&!pe.done&&(Ze=ge.return)&&Ze.call(ge)}finally{if(De)throw De.error}}return Ce}function Oe(){for(var We=[],Xe=0;Xe<arguments.length;Xe++)We=We.concat(Ee(arguments[Xe]));return We}function Pe(){for(var We=0,Xe=0,Ze=arguments.length;Xe<Ze;Xe++)We+=arguments[Xe].length;for(var ge=Array(We),pe=0,Xe=0;Xe<Ze;Xe++)for(var Ce=arguments[Xe],De=0,Fe=Ce.length;De<Fe;De++,pe++)ge[pe]=Ce[De];return ge}function Ae(We,Xe,Ze){if(Ze||arguments.length===2)for(var ge=0,pe=Xe.length,Ce;ge<pe;ge++)(Ce||!(ge in Xe))&&(Ce||(Ce=Array.prototype.slice.call(Xe,0,ge)),Ce[ge]=Xe[ge]);return We.concat(Ce||Array.prototype.slice.call(Xe))}function Ue(We){return this instanceof Ue?(this.v=We,this):new Ue(We)}function je(We,Xe,Ze){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var ge=Ze.apply(We,Xe||[]),pe,Ce=[];return pe=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),Fe("next"),Fe("throw"),Fe("return",De),pe[Symbol.asyncIterator]=function(){return this},pe;function De(st){return function(Ct){return Promise.resolve(Ct).then(st,ke)}}function Fe(st,Ct){ge[st]&&(pe[st]=function(bt){return new Promise(function(Rt,wt){Ce.push([st,bt,Rt,wt])>1||Le(st,bt)})},Ct&&(pe[st]=Ct(pe[st])))}function Le(st,Ct){try{Ye(ge[st](Ct))}catch(bt){et(Ce[0][3],bt)}}function Ye(st){st.value instanceof Ue?Promise.resolve(st.value.v).then(ct,ke):et(Ce[0][2],st)}function ct(st){Le("next",st)}function ke(st){Le("throw",st)}function et(st,Ct){st(Ct),Ce.shift(),Ce.length&&Le(Ce[0][0],Ce[0][1])}}function Ve(We){var Xe,Ze;return Xe={},ge("next"),ge("throw",function(pe){throw pe}),ge("return"),Xe[Symbol.iterator]=function(){return this},Xe;function ge(pe,Ce){Xe[pe]=We[pe]?function(De){return(Ze=!Ze)?{value:Ue(We[pe](De)),done:!1}:Ce?Ce(De):De}:Ce}}function ot(We){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var Xe=We[Symbol.asyncIterator],Ze;return Xe?Xe.call(We):(We=typeof he=="function"?he(We):We[Symbol.iterator](),Ze={},ge("next"),ge("throw"),ge("return"),Ze[Symbol.asyncIterator]=function(){return this},Ze);function ge(Ce){Ze[Ce]=We[Ce]&&function(De){return new Promise(function(Fe,Le){De=We[Ce](De),pe(Fe,Le,De.done,De.value)})}}function pe(Ce,De,Fe,Le){Promise.resolve(Le).then(function(Ye){Ce({value:Ye,done:Fe})},De)}}function it(We,Xe){return Object.defineProperty?Object.defineProperty(We,"raw",{value:Xe}):We.raw=Xe,We}var ft=Object.create?function(We,Xe){Object.defineProperty(We,"default",{enumerable:!0,value:Xe})}:function(We,Xe){We.default=Xe};function xt(We){if(We&&We.__esModule)return We;var Xe={};if(We!=null)for(var Ze in We)Ze!=="default"&&Object.prototype.hasOwnProperty.call(We,Ze)&&re(Xe,We,Ze);return ft(Xe,We),Xe}function qe(We){return We&&We.__esModule?We:{default:We}}function kt(We,Xe,Ze,ge){if(Ze==="a"&&!ge)throw new TypeError("Private accessor was defined without a getter");if(typeof Xe=="function"?We!==Xe||!ge:!Xe.has(We))throw new TypeError("Cannot read private member from an object whose class did not declare it");return Ze==="m"?ge:Ze==="a"?ge.call(We):ge?ge.value:Xe.get(We)}function V(We,Xe,Ze,ge,pe){if(ge==="m")throw new TypeError("Private method is not writable");if(ge==="a"&&!pe)throw new TypeError("Private accessor was defined without a setter");if(typeof Xe=="function"?We!==Xe||!pe:!Xe.has(We))throw new TypeError("Cannot write private member to an object whose class did not declare it");return ge==="a"?pe.call(We,Ze):pe?pe.value=Ze:Xe.set(We,Ze),Ze}function gt(We,Xe){if(Xe===null||typeof Xe!="object"&&typeof Xe!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof We=="function"?Xe===We:We.has(Xe)}function tt(We,Xe,Ze){if(Xe!=null){if(typeof Xe!="object"&&typeof Xe!="function")throw new TypeError("Object expected.");var ge,pe;if(Ze){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");ge=Xe[Symbol.asyncDispose]}if(ge===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");ge=Xe[Symbol.dispose],Ze&&(pe=ge)}if(typeof ge!="function")throw new TypeError("Object not disposable.");pe&&(ge=function(){try{pe.call(this)}catch(Ce){return Promise.reject(Ce)}}),We.stack.push({value:Xe,dispose:ge,async:Ze})}else Ze&&We.stack.push({async:!0});return Xe}var Jt=typeof SuppressedError=="function"?SuppressedError:function(We,Xe,Ze){var ge=new Error(Ze);return ge.name="SuppressedError",ge.error=We,ge.suppressed=Xe,ge};function At(We){function Xe(Ce){We.error=We.hasError?new Jt(Ce,We.error,"An error was suppressed during disposal."):Ce,We.hasError=!0}var Ze,ge=0;function pe(){for(;Ze=We.stack.pop();)try{if(!Ze.async&&ge===1)return ge=0,We.stack.push(Ze),Promise.resolve().then(pe);if(Ze.dispose){var Ce=Ze.dispose.call(Ze.value);if(Ze.async)return ge|=2,Promise.resolve(Ce).then(pe,function(De){return Xe(De),pe()})}else ge|=1}catch(De){Xe(De)}if(ge===1)return We.hasError?Promise.reject(We.error):Promise.resolve();if(We.hasError)throw We.error}return pe()}const gn={__extends:z,__assign:j,__rest:me,__decorate:Se,__param:A,__metadata:O,__awaiter:P,__generator:Z,__createBinding:re,__exportStar:oe,__values:he,__read:Ee,__spread:Oe,__spreadArrays:Pe,__spreadArray:Ae,__await:Ue,__asyncGenerator:je,__asyncDelegator:Ve,__asyncValues:ot,__makeTemplateObject:it,__importStar:xt,__importDefault:qe,__classPrivateFieldGet:kt,__classPrivateFieldSet:V,__classPrivateFieldIn:gt,__addDisposableResource:tt,__disposeResources:At}}},L={};function Hn(nt){var Ne=L[nt];if(Ne!==void 0)return Ne.exports;var K=L[nt]={exports:{}};return Zn[nt](K,K.exports,Hn),K.exports}Hn.n=nt=>{var Ne=nt&&nt.__esModule?()=>nt.default:()=>nt;return Hn.d(Ne,{a:Ne}),Ne},Hn.d=(nt,Ne)=>{for(var K in Ne)Hn.o(Ne,K)&&!Hn.o(nt,K)&&Object.defineProperty(nt,K,{enumerable:!0,get:Ne[K]})},Hn.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),Hn.o=(nt,Ne)=>Object.prototype.hasOwnProperty.call(nt,Ne),Hn.r=nt=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(nt,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(nt,"__esModule",{value:!0})};var $i={};/*!**********************!*\
|
||
!*** ./src/index.ts ***!
|
||
\**********************/Hn.r($i),Hn.d($i,{default:()=>wr,loaders:()=>dr});var dr=Hn("../../../lts/loaders/src/legacy/legacy.ts");const wr=dr;return $i=$i.default,$i})())})(W1);var Pc=W1.exports;const fL=uL(Pc),k1=hL({__proto__:null,default:fL},[Pc]),{SvelteComponent:pL,binding_callbacks:_L,detach:mL,element:gL,flush:Ta,init:vL,insert:yL,noop:NS,safe_not_equal:bL}=window.__gradio__svelte__internal,{onMount:TL}=window.__gradio__svelte__internal;function SL(vi){let mn;return{c(){mn=gL("canvas")},m(Cn,Zn){yL(Cn,mn,Zn),vi[13](mn)},p:NS,i:NS,o:NS,d(Cn){Cn&&mL(mn),vi[13](null)}}}function EL(vi,mn,Cn){let Zn,{value:L}=mn,{display_mode:Hn}=mn,{clear_color:$i}=mn,{camera_position:dr}=mn,{zoom_speed:wr}=mn,{pan_speed:nt}=mn,{resolved_url:Ne=void 0}=mn,K,_,z,j,me=null,Se=!1;TL(()=>{j=new ur.Engine(_,!0),z=new ur.Scene(j),z.createDefaultCameraOrLight(),z.useRightHandedSystem=!0,z.clearColor=z.clearColor=new ur.Color4(...$i),j.runRenderLoop(()=>{z.render()});function P(){j.resize()}return window.addEventListener("resize",P),Cn(11,Se=!0),()=>{z.dispose(),j.dispose(),window.removeEventListener("resize",P)}});function A(P){z&&(z.meshes.forEach(Z=>{Z.dispose()}),me&&(me.dispose(),me=null),P&&(ur.SceneLoader.ShowLoadingScreen=!1,ur.SceneLoader.Append(P,"",z,()=>{Hn==="point_cloud"?H(z):Hn==="wireframe"?W(z):ne(z,dr,wr,nt)},void 0,void 0,"."+L.path.split(".").pop())))}function ne(P,Z,re,oe){P.createDefaultCamera(!0,!0,!0);var he=P.activeCamera;Z[0]!==null&&(he.alpha=ur.Tools.ToRadians(Z[0])),Z[1]!==null&&(he.beta=ur.Tools.ToRadians(Z[1])),Z[2]!==null&&(he.radius=Z[2]),he.lowerRadiusLimit=.1;const Ee=()=>{he.wheelPrecision=250/(he.radius*re),he.panningSensibility=1e4*oe/he.radius};Ee(),he.attachControl(!0),he.onAfterCheckInputsObservable.add(Ee)}function ae(P,Z,re){z&&(z.removeCamera(z.activeCamera),ne(z,P,Z,re))}function H(P){const Z=P.meshes,re=[];Z.forEach(oe=>{if(oe instanceof ur.Mesh){const he=oe.getVerticesData(ur.VertexBuffer.PositionKind);if(he)for(let Ee=0;Ee<he.length;Ee+=3)re.push(new ur.Vector3(he[Ee],he[Ee+1],he[Ee+2]));oe.setEnabled(!1)}}),me=new ur.PointsCloudSystem("point_cloud_system",1,P),me.addPoints(re.length,(oe,he)=>{oe.position=re[he],oe.color=new ur.Color4(Math.random(),Math.random(),Math.random(),1)}),me.buildMeshAsync().then(oe=>{oe.alwaysSelectAsActiveMesh=!0,ne(P,dr,wr,nt)})}function W(P){P.meshes.forEach(Z=>{Z instanceof ur.Mesh&&(Z.material=new ur.StandardMaterial("wireframeMaterial",P),Z.material.wireframe=!0),ne(P,dr,wr,nt)})}function O(P){_L[P?"unshift":"push"](()=>{_=P,Cn(0,_)})}return vi.$$set=P=>{"value"in P&&Cn(2,L=P.value),"display_mode"in P&&Cn(3,Hn=P.display_mode),"clear_color"in P&&Cn(4,$i=P.clear_color),"camera_position"in P&&Cn(5,dr=P.camera_position),"zoom_speed"in P&&Cn(6,wr=P.zoom_speed),"pan_speed"in P&&Cn(7,nt=P.pan_speed),"resolved_url"in P&&Cn(1,Ne=P.resolved_url)},vi.$$.update=()=>{if(vi.$$.dirty&512&&Pc.OBJFileLoader!=null&&!Pc.OBJFileLoader.IMPORT_VERTEX_COLORS&&Cn(9,Pc.OBJFileLoader.IMPORT_VERTEX_COLORS=!0,k1),vi.$$.dirty&4&&Cn(12,Zn=L.url),vi.$$.dirty&5120&&(Cn(1,Ne=Zn),Zn)){Cn(10,K=Zn);const P=Zn;dL(Zn).then(Z=>{K===P?Cn(1,Ne=Z??void 0):Z&&URL.revokeObjectURL(Z)})}vi.$$.dirty&2050&&Se&&A(Ne)},[_,Ne,L,Hn,$i,dr,wr,nt,ae,k1,K,Se,Zn,O]}class IL extends pL{constructor(mn){super(),vL(this,mn,EL,SL,bL,{value:2,display_mode:3,clear_color:4,camera_position:5,zoom_speed:6,pan_speed:7,resolved_url:1,reset_camera_position:8})}get value(){return this.$$.ctx[2]}set value(mn){this.$$set({value:mn}),Ta()}get display_mode(){return this.$$.ctx[3]}set display_mode(mn){this.$$set({display_mode:mn}),Ta()}get clear_color(){return this.$$.ctx[4]}set clear_color(mn){this.$$set({clear_color:mn}),Ta()}get camera_position(){return this.$$.ctx[5]}set camera_position(mn){this.$$set({camera_position:mn}),Ta()}get zoom_speed(){return this.$$.ctx[6]}set zoom_speed(mn){this.$$set({zoom_speed:mn}),Ta()}get pan_speed(){return this.$$.ctx[7]}set pan_speed(mn){this.$$set({pan_speed:mn}),Ta()}get resolved_url(){return this.$$.ctx[1]}set resolved_url(mn){this.$$set({resolved_url:mn}),Ta()}get reset_camera_position(){return this.$$.ctx[8]}}export{IL as default};
|
||
//# sourceMappingURL=Canvas3D-B4hdlRYx.js.map
|