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;CnZn[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{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{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, minY : atomic, minZ : atomic, maxX : atomic, maxY : atomic, maxZ : atomic, dummy1 : i32, dummy2 : i32,};fn floatToBits(value: f32)->i32 {return bitcast(value);} fn bitsToFloat(value: i32)->f32 {return bitcast(value);} fn atomicMinFloat(atomicVar: ptr,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,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,index : f32)->mat4x4 {let offset=i32(index) *4; let m0=textureLoad(smp,vec2(offset+0,0),0);let m1=textureLoad(smp,vec2(offset+1,0),0);let m2=textureLoad(smp,vec2(offset+2,0),0);let m3=textureLoad(smp,vec2(offset+3,0),0);return mat4x4(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 positionBuffer : array;@group(0) @binding(1) var resultBuffer : array;@group(0) @binding(7) var settings : Settings; #if NUM_BONE_INFLUENCERS>0 @group(0) @binding(2) var boneSampler : texture_2d;@group(0) @binding(3) var indexBuffer : array;@group(0) @binding(4) var weightBuffer : array; #if NUM_BONE_INFLUENCERS>4 @group(0) @binding(5) var indexExtraBuffer : array;@group(0) @binding(6) var weightExtraBuffer : array; #endif #endif #ifdef MORPHTARGETS @group(0) @binding(8) var morphTargets : texture_2d_array;@group(0) @binding(9) var morphTargetInfluences : array;@group(0) @binding(10) var morphTargetTextureIndices : array; #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(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) {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;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=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;m0,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;v0&&(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{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 #include #include #include[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 #include[0..maxSimultaneousMorphTargets] mat4 finalWorld=identity; #include #include 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;m4&&(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;x0&&((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;C0){for(var g=0,S=E._metaKeys;g=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;F1&&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-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{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{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;b1&&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.lineIndex1&&this._lines.push(de);else for(var ue=fe.split(";"),U=0;U1){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":fe=de>Te;break;case"<":fe=de=":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-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=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;fe1?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=0||be.indexOf("#include <")>=0},U=0,N=g;U{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{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{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{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=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-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"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=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{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{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;D1&&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;F0&&parseInt(te[te.length-1])>=ee)continue}for(var ce=0,fe=ie;ce1?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"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=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=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=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;x1||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;dele||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-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;y1&&(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=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[y]||this.disableAttributeByIndex(y)}},S.prototype.releaseEffects=function(){for(var y=0,x=Object.keys(this._compiledEffects);y1?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>3]&1<<(7&x))&&(S[y++]=x);for(var R=y-1;y>(y-=g)&(1<>(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>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;ieq)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;k0;--k){var le=J+d[k]>>1;d[k]=J,J=le}for(k=0;k0&&(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;de0;de--){var ue;if((ue=ee[(te<=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=le&&p(Q[ve.p[J]])==(ue>>U-le&(1<>=be,U-=be;U>0;){var ve,ye;if(!(ve=ie[ue<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{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;un})},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=a.cQ)throw new Error("Wrong PIZ_COMPRESSION BITMAP_SIZE");if(f<=g)for(T=0;T{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.valueI||(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;Ch.height?h.height-C:h.scanlineBlockSize;var T=h.size=h.height))for(var y=f*h.bytesPerLine,x=(h.height-1-S)*h.outLineWidth,R=0;R{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<{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;v1)&&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{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=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{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;T0&&(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=0&&E.customRenderTargets.splice(C,1);for(var T=0,f=E.cameras;T=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();M0||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=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;v0||(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;MeJ&&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;be0&&(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;le0&&(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;ye0&&(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{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;d0){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;d1&&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+10?(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{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=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{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{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;RNumber.EPSILON){if(S<0&&(T=this._points[C],g=-g,f=this._points[E],S=-S),m.yf.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;E1)return o.I9.Zero();for(var v=m*this.length(),b=0,E=0;E=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;Cv){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;Ev+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;gf){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{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-Dd,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.xg.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 fthis._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)S._y?S._y:R)S._z?S._z:I)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(wethis.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 xMath.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;g3)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$){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;v32767)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;y128){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;F0;){for(p=0;p{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;SMath.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{function n(s,l){for(var c=[],u=0;ua,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>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;ue1;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{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>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>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;be0?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{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{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;m0)if(typeof E[0]=="object")for(var T=0;T{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;QE)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{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{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=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;C1,p.errors)throw new Error("KTX2 container - could not transcode the data. "+p.errors);for(var E=0;E=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="
").concat(u,"

");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;c0},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{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;lthis.data.length&&(this.data.length=2*(this.length+s.length));for(var l=0;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{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>2,b=(3&h)<<4|(p=g>4,E=(15&p)<<2|(m=g>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{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>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(du-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)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{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{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=0;C--)if(E-this._textureCache[C].lastUsedRenderId>100){for(var T=!1,f=0;f0&&this._textures.reset(),this.width=E,this.height=C;var S=null;if(T){for(var y=0;y=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{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;vc._alphaIndex?1:l._alphaIndexc._distanceToCamera?-1:0},s.frontToBackSortCompare=function(l,c){return l._distanceToCamerac._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{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{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 `},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(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump) #endif #if defined(DETAIL) #include(_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; icurrRayHeight) {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 #include `},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; i0.) {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; i0.) {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{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=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=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 || fragDepthfurthestDepth) { #endif return;} #ifdef USE_REVERSE_DEPTHBUFFER if (fragDepthfurthestDepth) { #else if (fragDepth>nearestDepth && fragDepth{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{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 #include `},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)yMax) || (P1.yyMax) ? yMax : yMin))/(P1.y-P0.y);} if ((P1.x>xMax) || (P1.xxMax) ? 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)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) && (rayZMaxend) {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))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.))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; i1.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{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{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 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 #endif #ifndef FROMLINEARSPACE #define FROMLINEARSPACE; #endif #ifndef SHADOWONLY #define SHADOWONLY; #endif #include #include<__decl__lightFragment>[0..maxSimultaneousLights] #include #include #include #ifdef LOGARITHMICDEPTH #extension GL_EXT_frag_depth : enable #endif #include #include #include #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) 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[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 #include #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 attribute vec3 position; #ifdef NORMAL attribute vec3 normal; #endif #include #include #include 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 #include #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 #define CUSTOM_VERTEX_DEFINITIONS void main(void) { #define CUSTOM_VERTEX_MAIN_BEGIN #ifdef REFLECTIONMAP_SKYBOX vPositionUVW=position; #endif #include #include #include #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 #include #include[0..maxSimultaneousLights] #ifdef VERTEXCOLOR vColor=color; #endif #if defined(POINTSIZE) && !defined(WEBGPU) gl_PointSize=pointSize; #endif #include #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 #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) gl_FragColor=vColor; #else gl_FragColor=color; #endif #include(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 #include #include #include #ifdef FOG uniform mat4 view; #endif #include 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 #include #include 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 #include #include #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 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 #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[SCENE_MRT_COUNT] #include #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[1..7] #include #include<__decl__lightFragment>[0..maxSimultaneousLights] #include #include #include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) #ifdef REFRACTION #ifdef REFRACTIONMAP_3D uniform samplerCube refractionCubeSampler; #else uniform sampler2D refraction2DSampler; #endif #endif #if defined(SPECULARTERM) #include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular) #endif #include #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 #endif #include #include #include #include #include #include #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include 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 #ifdef TWOSIDEDLIGHTING normalW=gl_FrontFacing ? normalW : -normalW; #endif #ifdef DIFFUSE baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset); #if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS) if (baseColor.a(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) #endif #include #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(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[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 #include #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 #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 #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[2..7] #ifdef VERTEXCOLOR attribute vec4 color; #endif #include #include #include #include #include #include[1..7] #include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) #if defined(SPECULARTERM) #include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular) #endif #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) #include(_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 #include #include #include<__decl__lightVxFragment>[0..maxSimultaneousLights] #include #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #endif #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif #include #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 #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX vPositionUVW=positionUpdated; #endif #define CUSTOM_VERTEX_UPDATE_POSITION #define CUSTOM_VERTEX_UPDATE_NORMAL #include #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 #include 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 #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[2..7] #include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) #if defined(SPECULARTERM) #include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x) #endif #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) #include #include #include #include[0..maxSimultaneousLights] #include #include #include #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 varying float vDepthMetric; #ifdef PACKED #include #endif #ifdef STORE_CAMERASPACE_Z varying vec4 vViewPos; #endif #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #include #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 #include #include #include[0..maxSimultaneousMorphTargets] #include #include 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 varying float vDepthMetric; #define CUSTOM_VERTEX_DEFINITIONS void main(void) {vec3 positionUpdated=position; #ifdef UV1 vec2 uvUpdated=uv; #endif #include #include[0..maxSimultaneousMorphTargets] #include #include #include vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); #include 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 } `;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 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=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{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 #include[SCENE_MRT_COUNT] #include #include #include void main() { #include #ifdef ALPHATEST if (texture2D(diffuseSampler,vUV).a<0.4) discard; #endif vec3 normalOutput; #ifdef BUMP vec3 normalW=normalize(vNormalW); #include #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 `,e(85637),e(58266),e(84589),e(35397),e(76898),e(49334),e(83057),e(35845);var o="geometryVertexShader",a=`precision highp float; #include #include #include #include[0..maxSimultaneousMorphTargets] #include #include<__decl__geometryVertex> #include 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 #include[0..maxSimultaneousMorphTargets] #include #if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED) vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); #endif #include #include 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 #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 } `;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 #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 #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #include 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{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 #include #include #include[0..maxSimultaneousMorphTargets] #include #include 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 #include[0..maxSimultaneousMorphTargets] #include #include #include 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 }`;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 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 #include #include #include 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>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))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)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){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){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.zfarPlane) {discard;} glFragData[0]=normPos.z=nearPlane+stepSize && normPos.z=nearPlane+2.0*stepSize && normPos.z=nearPlane+3.0*stepSize && normPos.z4 glFragData[4]=normPos.z>=nearPlane+4.0*stepSize && normPos.z=nearPlane+5.0*stepSize && normPos.z=nearPlane+6.0*stepSize && normPos.z=nearPlane+7.0*stepSize && normPos.z{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 #include #include #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[0..varyingCount] #ifdef PACKEDFLOAT #include #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[0..varyingCount] #include[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[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[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 #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 uniform vec4 color; #ifdef LOGARITHMICDEPTH #extension GL_EXT_frag_depth : enable #endif #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #include 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 #include `,e(38615),e(85637),e(59262),e(35397),e(83057),e(56458);var i="lineVertexShader",o=`#include<__decl__lineVertex> #include #include attribute vec3 position;attribute vec4 normal;uniform float width;uniform float aspectRatio; #include #define CUSTOM_VERTEX_DEFINITIONS void main(void) { #define CUSTOM_VERTEX_MAIN_BEGIN #include 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 #endif #include #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 #include #include #include[0..maxSimultaneousMorphTargets] #include void main(void) {vec3 positionUpdated=position;vec3 normalUpdated=normal; #include #include[0..maxSimultaneousMorphTargets] #include #include #include 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=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=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 #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #ifdef ALPHATEST if (texture2D(diffuseSampler,vUV).a<0.4) discard; #endif #include 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 #include #include #include[0..maxSimultaneousMorphTargets] #include uniform float offset; #include 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 #define CUSTOM_VERTEX_DEFINITIONS void main(void) {vec3 positionUpdated=position;vec3 normalUpdated=normal; #ifdef UV1 vec2 uvUpdated=uv; #endif #include #include[0..maxSimultaneousMorphTargets] vec3 offsetPosition=positionUpdated+(normalUpdated*offset); #include #include #include 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 #include } `;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 #include #include #include #include #ifdef RAMPGRADIENT varying vec4 remapRanges;uniform sampler2D rampSampler; #endif #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include 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 #include(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 #include #include #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 #include #include #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 #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[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(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) #include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity) #include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface) #include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance) #include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) #ifdef CLEARCOAT #include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat) #include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) uniform sampler2D clearCoatRoughnessSampler; #endif #include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump) #include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint) #endif #ifdef IRIDESCENCE #include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence) #include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness) #endif #ifdef SHEEN #include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen) #include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) uniform sampler2D sheenRoughnessSampler; #endif #endif #ifdef ANISOTROPIC #include(_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(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness) #include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity) #include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity) #include(_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 #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 #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 (alpha0 #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.alpha0 && 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[SCENE_MRT_COUNT] precision highp float; #include #ifndef FROMLINEARSPACE #define FROMLINEARSPACE #endif #include<__decl__pbrFragment> #include #include<__decl__lightFragment>[0..maxSimultaneousLights] #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef REFLECTION #include #endif #define CUSTOM_FRAGMENT_DEFINITIONS #include #include #include #include #include #include #include #include #include #include void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #include #include #include 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 #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 #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 #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 #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 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 #include[0..maxSimultaneousLights] #include #endif #include #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION #include #include #include(color,finalColor) #include #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 #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 #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 #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[2..7] #include[1..7] #ifdef VERTEXCOLOR attribute vec4 color; #endif #include #include #include #include #include #include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) #include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity) #include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler) #include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance) #include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance) #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) #ifdef CLEARCOAT #include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat) #include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) #include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump) #include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint) #endif #ifdef IRIDESCENCE #include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence) #include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness) #endif #ifdef SHEEN #include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen) #include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) #endif #ifdef ANISOTROPIC #include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy) #endif #ifdef SUBSURFACE #include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness) #include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity) #include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity) #include(_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 #endif #endif #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) varying vec4 vColor; #endif #include #include #include #include<__decl__lightVxFragment>[0..maxSimultaneousLights] #include #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #endif #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif #include #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 #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX vPositionUVW=positionUpdated; #endif #define CUSTOM_VERTEX_UPDATE_POSITION #define CUSTOM_VERTEX_UPDATE_NORMAL #include #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 #include vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vPositionW=vec3(worldPos); #include #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[2..7] #include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) #include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x) #include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x) #include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x) #include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x) #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) #ifdef CLEARCOAT #include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x) #include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z) #include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x) #include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x) #endif #ifdef IRIDESCENCE #include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x) #include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z) #endif #ifdef SHEEN #include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x) #include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheenRoughness,_INFONAME_,SheenInfos.z) #endif #ifdef ANISOTROPIC #include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x) #endif #ifdef SUBSURFACE #include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x) #include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x) #include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x) #include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_MATRIXNAME_,translucencyColor,_INFONAME_,TranslucencyColorInfos.x) #endif #include #include #include #include[0..maxSimultaneousLights] #include #if defined(POINTSIZE) && !defined(WEBGPU) gl_PointSize=pointSize; #endif #include #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 #include #include #include[0..maxSimultaneousMorphTargets] #include uniform mat4 viewProjection; #if defined(INSTANCES) varying vec4 vMeshID; #endif void main(void) { #include #include[0..maxSimultaneousMorphTargets] #include #include #include 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 #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 #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{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; i1. || 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 #include #include 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 #ifdef SSR_BLEND_WITH_FRESNEL #include #include 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 #endif #if SM_SOFTTRANSPARENTSHADOW==1 #include 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 #ifdef ALPHATEXTURE varying vec2 vUV;uniform sampler2D diffuseSampler; #endif #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #include #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=softTransparentShadowSM.x*alphaFromAlphaTexture) discard; #else if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x) discard; #endif #endif #include }`;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 #include `,e(50851),e(56174),n.l.IncludesShadersStore.shadowMapUboDeclaration=`layout(std140,column_major) uniform; #include #include `,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 #include #include #include[0..maxSimultaneousMorphTargets] #ifdef INSTANCES attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3; #endif #include #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 #include #define CUSTOM_VERTEX_DEFINITIONS void main(void) {vec3 positionUpdated=position; #ifdef UV1 vec2 uvUpdated=uv; #endif #ifdef NORMAL vec3 normalUpdated=normal; #endif #include #include[0..maxSimultaneousMorphTargets] #include #include #include 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 gl_Position=viewProjection*worldPos; #include #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 }`;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 #include #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 #include gl_FragColor=color; #include #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 #include #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 #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; i1.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{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 `},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;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;uniform bakedVertexAnimationSettings: vec4;var bakedVertexAnimationTexture : texture_2d; #ifdef INSTANCES attribute bakedVertexAnimationSettingsInstanced : vec4; #endif fn readMatrixFromRawSamplerVAT(smp : texture_2d,index : f32,frame : f32)->mat4x4 {let offset=i32(index)*4;let frameUV=i32(frame);let m0=textureLoad(smp,vec2(offset+0,frameUV),0);let m1=textureLoad(smp,vec2(offset+1,frameUV),0);let m2=textureLoad(smp,vec2(offset+2,frameUV),0);let m3=textureLoad(smp,vec2(offset+3,frameUV),0);return mat4x4(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;attribute matricesWeights : vec4; #if NUM_BONE_INFLUENCERS>4 attribute matricesIndicesExtra : vec4;attribute matricesWeightsExtra : vec4; #endif #ifndef BAKED_VERTEX_ANIMATION_TEXTURE #ifdef BONETEXTURE var boneSampler : texture_2d;uniform boneTextureWidth : f32; #else uniform mBones : array; #ifdef BONES_VELOCITY_ENABLED uniform mPreviousBones : array; #endif #endif #ifdef BONETEXTURE fn readMatrixFromRawSampler(smp : texture_2d,index : f32)->mat4x4 {let offset=i32(index) *4; let m0=textureLoad(smp,vec2(offset+0,0),0);let m1=textureLoad(smp,vec2(offset+1,0),0);let m2=textureLoad(smp,vec2(offset+2,0),0);let m3=textureLoad(smp,vec2(offset+3,0),0);return mat4x4(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; #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(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(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(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump) #endif #if defined(DETAIL) #include(_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; icurrRayHeight) {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( (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(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;varying fClipDistance: f32; #endif #ifdef CLIPPLANE2 uniform vClipPlane2: vec4;varying fClipDistance2: f32; #endif #ifdef CLIPPLANE3 uniform vClipPlane3: vec4;varying fClipDistance3: f32; #endif #ifdef CLIPPLANE4 uniform vClipPlane4: vec4;varying fClipDistance4: f32; #endif #ifdef CLIPPLANE5 uniform vClipPlane5: vec4;varying fClipDistance5: f32; #endif #ifdef CLIPPLANE6 uniform vClipPlane6: vec4;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 #include `},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,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; i0.) {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,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; i0.) {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=vec3 (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=inMatrix[0];let i1: vec3=inMatrix[1];let i2: vec3=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)->vec3 {let nearZeroSection: vec3=0.0773993808*color;let remainingSection: vec3=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));} fn toGammaSpaceExact(color: vec3)->vec3 {let nearZeroSection: vec3=12.92*color;let remainingSection: vec3=1.055*pow(color,vec3(0.41666))-vec3(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(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)->vec3 { #if USE_EXACT_SRGB_CONVERSIONS return toLinearSpaceExact(color); #else return pow(color,vec3(LinearEncodePowerApprox)); #endif } fn toLinearSpaceVec4(color: vec4)->vec4 { #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)->vec4 { #if USE_EXACT_SRGB_CONVERSIONS return vec4(toGammaSpaceExact(color.rgb),color.a); #else return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a); #endif } fn toGammaSpaceVec3(color: vec3)->vec3 { #if USE_EXACT_SRGB_CONVERSIONS return toGammaSpaceExact(color); #else return pow(color,vec3(GammaEncodePowerApprox)); #endif } fn squareVec3(value: vec3)->vec3 {return value*value;} fn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;} fn getLuminance(color: vec3)->f32 {return clamp(dot(color,LuminanceEncodeApprox),0.,1.);} fn getRand(seed: vec2)->f32 {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);} fn dither(seed: vec2,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)->vec4 {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 =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4(clamp(rgb,vec3(0.,0.,0.),vec3(1.,1.,1.)),D); } fn fromRGBD(rgbd: vec4)->vec3 {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;} fn parallaxCorrectNormal(vertexPos: vec3,origVec: vec3,cubeSize: vec3,cubePos: vec3)->vec3 {let invOrigVec: vec3=vec3(1.0,1.0,1.0)/origVec;let halfSize: vec3=cubeSize*0.5;let intersecAtMaxPlane: vec3=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3=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; #else var txColorTransformSampler: sampler;var txColorTransform: texture_2d; #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 (peakvec3f {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;attribute world1 : vec4;attribute world2 : vec4;attribute world3 : vec4; #ifdef INSTANCESCOLOR attribute instanceColor : vec4; #endif #if defined(THIN_INSTANCES) && !defined(WORLD_UBO) uniform world : mat4x4; #endif #if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) attribute previousWorld0 : vec4;attribute previousWorld1 : vec4;attribute previousWorld2 : vec4;attribute previousWorld3 : vec4; #ifdef THIN_INSTANCES uniform previousWorld : mat4x4; #endif #endif #else #if !defined(WORLD_UBO) uniform world : mat4x4; #endif #if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) uniform previousWorld : mat4x4; #endif #endif `},21310:(r,t,e)=>{e(98519).l.IncludesShadersStoreWGSL.instancesVertex=`#ifdef INSTANCES var finalWorld=mat4x4(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3); #if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) var finalPreviousWorld=mat4x4( 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=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 light{X} : Light{X}; #ifdef PROJECTEDLIGHTTEXTURE{X} uniform textureProjectionMatrix{X}: mat4x4f;var projectionLightTexture{X}Sampler: sampler;var projectionLightTexture{X}: texture_2d; #endif #ifdef SHADOW{X} #ifdef SHADOWCSM{X} uniform lightMatrix{X}: array;uniform viewFrustumZ{X}: array;uniform frustumLengths{X}: array;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 vPositionFromLight{X}: array;var vDepthMetric{X} : array; #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;uniform lightSizeUVCorrection{X}: array;uniform depthCorrection{X}: array;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; #endif #ifdef SHADOWCSMDEBUG{X} const vCascadeColorsMultiplier{X}: array=array ( 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; #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; #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; #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 light{X} : Light{X}; #ifdef SHADOW{X} #ifdef SHADOWCSM{X} uniform lightMatrix{X}: array;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,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, visibility : f32,};var 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=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; #ifdef MORPHTARGETS_NORMAL attribute normal{X} : vec3; #endif #ifdef MORPHTARGETS_TANGENT attribute tangent{X} : vec3; #endif #ifdef MORPHTARGETS_UV attribute uv_{X} : vec2; #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; #ifdef MORPHTARGETS_TEXTURE uniform morphTargetTextureIndices : array;uniform morphTargetTextureInfo : vec3;var morphTargets : texture_2d_array;var morphTargetsSampler : sampler;fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3 { let y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;let textureUV=vec2((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;var oitFrontColorSamplerSampler: sampler;var oitFrontColorSampler: texture_2d; #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 || fragDepthfurthestDepth) { #endif return fragmentOutputs;} #ifdef USE_REVERSE_DEPTHBUFFER if (fragDepthfurthestDepth) { #else if (fragDepth>nearestDepth && fragDepth{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 (iridescenceIORf32 {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 #include `},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; #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, #ifdef MULTIVIEW viewProjectionR : mat4x4, #endif view : mat4x4, projection : mat4x4, vEyePosition : vec4,};var 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, csZBufferSize: vec2f, #ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER csZBackBuffer: texture_2d, csZBackSizeFactor: f32, #endif csZThickness: f32, nearPlaneZ: f32, stride: f32, jitterFraction: f32, maxSteps: f32, maxRayTraceDistance: f32, selfCollisionNumSkip: f32, startPixel: ptr, hitPixel: ptr, csHitPoint: ptr, numIterations: ptr #ifdef SSRAYTRACE_DEBUG ,debugColor: ptr #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)yMax) || (P1.yyMax)))/(P1.y-P0.y);} if ((P1.x>xMax) || (P1.xxMax)))/(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)rayZMax) { var t: f32=rayZMin; rayZMin=rayZMax; rayZMax=t;} sceneZMax=textureLoad(csZBuffer,vec2(*hitPixel),0).r; #ifdef SSRAYTRACE_RIGHT_HANDED_SCENE #ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER var sceneBackZ: f32=textureLoad(csZBackBuffer,vec2(*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(*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(*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,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,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;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)),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,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,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,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,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;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.)),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,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=array ( 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=array ( 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,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array,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,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array)->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,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,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,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,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,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,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;var leftSamplerSampler: sampler;var leftSampler: texture_2d; #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 #include 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; #endif #ifdef REFLECTION #ifdef REFLECTIONMAP_3D var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube; #ifdef TEXTURELODSUPPORT #else var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube; #endif #else var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d; #ifdef TEXTURELODSUPPORT #else var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d; #endif #endif #ifdef REFLECTIONMAP_SKYBOX varying vPositionUVW: vec3f; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vDirectionW: vec3f; #endif #endif #include #endif #ifndef FROMLINEARSPACE #define FROMLINEARSPACE; #endif #ifndef SHADOWONLY #define SHADOWONLY; #endif #include #include[0..maxSimultaneousLights] #include #include #include #include #include #include #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)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 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[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 #include #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 #include attribute position: vec3f; #ifdef NORMAL attribute normal: vec3f; #endif #include #include #include 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 #include #include[0..maxSimultaneousLights] #ifdef REFLECTIONMAP_SKYBOX varying vPositionUVW: vec3f; #endif #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vDirectionW: vec3f; #endif #include #define CUSTOM_VERTEX_DEFINITIONS @vertex fn main(input : VertexInputs)->FragmentInputs { #define CUSTOM_VERTEX_MAIN_BEGIN #ifdef REFLECTIONMAP_SKYBOX vertexOutputs.vPositionUVW=input.position; #endif #include #include #include #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 #include #include[0..maxSimultaneousLights] #ifdef VERTEXCOLOR vertexOutputs.vColor=color; #endif #include #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;var normalSamplerSampler: sampler;var normalSampler: texture_2d;var depthSamplerSampler: sampler;var depthSampler: texture_2d;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;var normalSamplerSampler: sampler;var normalSampler: texture_2d;var depthSamplerSampler: sampler;var depthSampler: texture_2d;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;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;var bloomBlurSampler: sampler;var bloomBlur: texture_2d;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;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;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 #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) fragmentOutputs.color=input.vColor; #else fragmentOutputs.color=uniforms.color; #endif #include(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 #include #include #include #ifdef FOG uniform view: mat4x4f; #endif #include 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 #include #include var worldPos: vec4f=finalWorld* vec4f(input.position,1.0);vertexOutputs.position=uniforms.viewProjection*worldPos; #include #include #include #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;varying vUV: vec2f;var colorTableSampler: sampler;var colorTable: texture_2d;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;uniform screenSize: vec2f;uniform kernel: array; #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;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;varying vUV: vec2f; #include @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 #include[SCENE_MRT_COUNT] #include #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[1..7] #include #include[0..maxSimultaneousLights] #include #include #include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) #ifdef REFRACTION #ifdef REFRACTIONMAP_3D var refractionCubeSamplerSampler: sampler;var refractionCubeSampler: texture_cube; #else var refraction2DSamplerSampler: sampler;var refraction2DSampler: texture_2d; #endif #endif #if defined(SPECULARTERM) #include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular) #endif #include #ifdef REFLECTION #ifdef REFLECTIONMAP_3D var reflectionCubeSamplerSampler: sampler;var reflectionCubeSampler: texture_cube; #else var reflection2DSamplerSampler: sampler;var reflection2DSampler: texture_2d; #endif #ifdef REFLECTIONMAP_SKYBOX varying vPositionUVW: vec3f; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vDirectionW: vec3f; #endif #endif #include #endif #include #include #include #include #include #include #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include 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 #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(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) #endif #include #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(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[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 #include #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,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 #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 #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[2..7] #ifdef VERTEXCOLOR attribute color: vec4f; #endif #include #include #include #include #include #include[1..7] #include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) #if defined(SPECULARTERM) #include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular) #endif #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) #include(_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 #include #include #include<__decl__lightVxFragment>[0..maxSimultaneousLights] #include #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX varying vPositionUVW: vec3f; #endif #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vDirectionW: vec3f; #endif #include #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 #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX vertexOutputs.vPositionUVW=positionUpdated; #endif #define CUSTOM_VERTEX_UPDATE_POSITION #define CUSTOM_VERTEX_UPDATE_NORMAL #include #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 #include 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 #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[2..7] #include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) #if defined(SPECULARTERM) #include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x) #endif #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) #include #include #include #include[0..maxSimultaneousLights] #include #include #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; #endif #include varying vDepthMetric: f32; #ifdef PACKED #include #endif #ifdef STORE_CAMERASPACE_Z varying vViewPos: vec4f; #endif #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #include #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 #include #include #include[0..maxSimultaneousMorphTargets] #include #include 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 #include[0..maxSimultaneousMorphTargets] #include #include #include var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0); #include 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;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;var circleOfConfusionSamplerSampler: sampler;var circleOfConfusionSampler: texture_2d;var blurStep0Sampler: sampler;var blurStep0: texture_2d; #if BLUR_LEVEL>0 var blurStep1Sampler: sampler;var blurStep1: texture_2d; #endif #if BLUR_LEVEL>1 var blurStep2Sampler: sampler;var blurStep2: texture_2d; #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;var passSamplerSampler: sampler;var passSampler: texture_2d; #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 varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d;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;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;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;var depthSamplerSampler: sampler;var depthSampler: texture_2d; #ifdef FLUIDRENDERING_DIFFUSETEXTURE var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; #else uniform diffuseColor: vec3f; #endif #ifdef FLUIDRENDERING_FIXED_THICKNESS uniform thickness: f32;var bgDepthSamplerSampler: sampler;var bgDepthSampler: texture_2d; #else uniform minimumThickness: f32;var thicknessSamplerSampler: sampler;var thicknessSampler: texture_2d; #endif #ifdef FLUIDRENDERING_ENVIRONMENT var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube; #endif #if defined(FLUIDRENDERING_DEBUG) && defined(FLUIDRENDERING_DEBUG_TEXTURE) var debugSamplerSampler: sampler;var debugSampler: texture_2d; #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;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;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=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{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;varying vReflectivityUV: vec2f; #endif #ifdef ALBEDOTEXTURE varying vAlbedoUV: vec2f;var albedoSamplerSampler: sampler;var albedoSampler: texture_2d; #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; #endif #include #include #include #include @fragment fn main(input: FragmentInputs)->FragmentOutputs { #include #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 #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,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 #include #include #include[0..maxSimultaneousMorphTargets] #include #include #include 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 #include[0..maxSimultaneousMorphTargets] #include #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 #include 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 #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 } `;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;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;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 #endif #ifdef DIFFUSE varying vUVDiffuse: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; #endif #ifdef OPACITY varying vUVOpacity: vec2f;var opacitySamplerSampler: sampler;var opacitySampler: texture_2d;uniform var opacityIntensity: f32; #endif #ifdef EMISSIVE varying vUVEmissive: vec2f;var emissiveSamplerSampler: sampler;var emissiveSampler: texture_2d; #endif #ifdef VERTEXALPHA varying vColor: vec4f; #endif uniform glowColor: vec4f;uniform glowIntensity: f32; #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #include 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{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 #include #include #include[0..maxSimultaneousMorphTargets] #include #include 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 #include[0..maxSimultaneousMorphTargets] #include #include #include 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 }`;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; #ifdef EMISSIVE var textureSampler2Sampler: sampler;var textureSampler2: texture_2d; #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 varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d;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 #include #include #include uniform alphaG: f32;var inputTextureSampler: sampler;var inputTexture: texture_cube;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;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;var voxelYaxisSamplerSampler: sampler;var voxelYaxisSampler: texture_3d;var voxelZaxisSamplerSampler: sampler;var voxelZaxisSampler: texture_3d;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;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; var localPositionSampler: texture_2d; var textureSampler: texture_2d; var oldAccumulationSamplerSampler: sampler;var oldAccumulationSampler: texture_2d; var prevLocalPositionSamplerSampler: sampler;var prevLocalPositionSampler: texture_2d; 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 {return xFragmentOutputs {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;var debugSamplerSampler: sampler;var debugSampler: texture_2d;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;var prePass_NdcDepthSampler: sampler;var prePass_NdcDepth: texture_2d;var prePass_WorldNormalSampler: sampler;var prePass_WorldNormal: texture_2d;var prePass_PositionSampler: sampler;var prePass_Position: texture_2d;var prePass_LocalPositionSampler: sampler;var prePass_LocalPosition: texture_2d;var prePass_VelocityLinearSampler: sampler;var prePass_VelocityLinear: texture_2d;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;var worldNormalSampler: texture_2d;var textureSampler: texture_2d;uniform blurParameters: vec4f; #define stridef uniforms.blurParameters.x #define worldScale uniforms.blurParameters.y const weights=array(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>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;var worldNormalSampler: texture_2d;var worldPositionSampler: texture_2d;var blueNoiseSampler: texture_2d;var icdfxSamplerSampler: sampler;var icdfxSampler: texture_2d;var icdfySamplerSampler: sampler;var icdfySampler: texture_2d;var voxelGridSamplerSampler: sampler;var voxelGridSampler: texture_3d;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,distance_far: ptr)->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(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,B: ptr) {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 {return x)->bool { #else fn anyHitVoxels(ray_vs: Ray)->bool { #endif var stack=array(); 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<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))->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; iedge_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;@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; #else var iblSourceSampler: sampler;var iblSource: texture_2d; #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;var textureSamplerSampler: sampler;var textureSampler: texture_2d;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;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)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;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)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;var icdfySampler: sampler;var icdfy: texture_2d;var cdfxSampler: sampler;var cdfx: texture_2d;var icdfxSampler: sampler;var icdfx: texture_2d; #ifdef IBL_USE_CUBE_MAP var iblSourceSampler: sampler;var iblSource: texture_cube; #else var iblSourceSampler: sampler;var iblSource: texture_2d; #endif var textureSamplerSampler: sampler;var textureSampler: texture_2d; #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.zuniforms.farPlane) {discard;} fragmentOutputs.fragData0=select(vec4f(0.0),vec4f(1.0),normPos.z=uniforms.nearPlane+uniforms.stepSize && normPos.z=uniforms.nearPlane+2.0*uniforms.stepSize && normPos.z=uniforms.nearPlane+3.0*uniforms.stepSize && normPos.z4 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 && normPos.z=uniforms.nearPlane+6.0*uniforms.stepSize && normPos.z=uniforms.nearPlane+7.0*uniforms.stepSize && normPos.z{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;var textureSamplerSampler: sampler;var textureSampler: texture_2d;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;var voxelSlabTextureSampler: sampler;var voxelSlabTexture: texture_2d;var textureSamplerSampler: sampler;var textureSampler: texture_2d;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; #include #include #include #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;uniform delta: vec2f;varying sampleCenter: vec2f; #ifdef DOF var circleOfConfusionSamplerSampler: sampler;var circleOfConfusionSampler: texture_2d;fn sampleCoC(offset: vec2f)->f32 {var coc: f32=textureSample(circleOfConfusionSampler,circleOfConfusionSamplerSampler,offset).r;return coc; } #endif #include[0..varyingCount] #ifdef PACKEDFLOAT #include #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[0..varyingCount] #include[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[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[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;uniform color: vec4f; #include #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;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 uniform color: vec4f; #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #include 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 #include #include #include attribute position: vec3f;attribute normal: vec4f;uniform width: f32;uniform aspectRatio: f32; #include #define CUSTOM_VERTEX_DEFINITIONS @vertex fn main(input : VertexInputs)->FragmentInputs { #define CUSTOM_VERTEX_MAIN_BEGIN #include 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 #endif #include #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;@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 #include #include #include[0..maxSimultaneousMorphTargets] #include @vertex fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=input.position;var normalUpdated: vec3f=input.normal; #include #include[0..maxSimultaneousMorphTargets] #include #include #include 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;var maskTextureSamplerSampler: sampler;var maskTextureSampler: texture_2d;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;uniform motionStrength: f32;uniform motionScale: f32;uniform screenSize: vec2f; #ifdef OBJECT_BASED var velocitySamplerSampler: sampler;var velocitySampler: texture_2d; #else var depthSamplerSampler: sampler;var depthSampler: texture_2d;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;@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;var uBackColor: texture_2d;@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; #endif #include #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #ifdef ALPHATEST if (textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vUV).a<0.4) {discard;} #endif #include 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 #include #include #include[0..maxSimultaneousMorphTargets] #include uniform offset: f32; #include 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 #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 #include[0..maxSimultaneousMorphTargets] var offsetPosition: vec3f=positionUpdated+(normalUpdated*uniforms.offset); #include #include #include 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 #include } `;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; #include #include #include #include #include #ifdef RAMPGRADIENT varying remapRanges: vec4f;var rampSamplerSampler: sampler;var rampSampler: texture_2d; #endif #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include 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 #include(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 #include #include #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 #include #include #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; #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; #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[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(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) #include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity) #include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface) #include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance) #include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) #ifdef CLEARCOAT #include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat) #include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) var clearCoatRoughnessSamplerSampler: sampler;var clearCoatRoughnessSampler: texture_2d; #endif #include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump) #include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint) #endif #ifdef IRIDESCENCE #include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence) #include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness) #endif #ifdef SHEEN #include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen) #include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) var sheenRoughnessSamplerSampler: sampler;var sheenRoughnessSampler: texture_2d; #endif #endif #ifdef ANISOTROPIC #include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy) #endif #ifdef REFLECTION #ifdef REFLECTIONMAP_3D var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube; #ifdef LODBASEDMICROSFURACE #else var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube; #endif #ifdef USEIRRADIANCEMAP var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube; #endif #else var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d; #ifdef LODBASEDMICROSFURACE #else var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d; #endif #ifdef USEIRRADIANCEMAP var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d; #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; #endif #ifdef SUBSURFACE #ifdef SS_REFRACTION #ifdef SS_REFRACTIONMAP_3D var refractionSamplerSampler: sampler;var refractionSampler: texture_cube; #ifdef LODBASEDMICROSFURACE #else var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_cube;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_cube; #endif #else var refractionSamplerSampler: sampler;var refractionSampler: texture_2d; #ifdef LODBASEDMICROSFURACE #else var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_2d;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_2d; #endif #endif #endif #include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness) #include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity) #include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity) #include(_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,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 #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 #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 (alpha0 #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,I: vec3,Nref: vec3)->vec3 {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.alpha0 && 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 ,reflectionSamplerSampler: sampler ,reflectionCoords: vec3f #else ,reflectionSampler: texture_2d ,reflectionSamplerSampler: sampler ,reflectionCoords: vec2f #endif #ifndef LODBASEDMICROSFURACE #ifdef REFLECTIONMAP_3D ,reflectionLowSampler: texture_cube ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_cube ,reflectionHighSamplerSampler: sampler #else ,reflectionLowSampler: texture_2d ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_2d ,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 ,reflectionSamplerSampler: sampler #else ,reflectionSampler: texture_2d ,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 ,irradianceSamplerSampler: sampler #else ,irradianceSampler: texture_2d ,irradianceSamplerSampler: sampler #endif #endif #ifndef LODBASEDMICROSFURACE #ifdef REFLECTIONMAP_3D ,reflectionLowSampler: texture_cube ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_cube ,reflectionHighSamplerSampler: sampler #else ,reflectionLowSampler: texture_2d ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_2d ,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 ,reflectionSamplerSampler: sampler ,reflectionCoords: vec3f #else ,reflectionSampler: texture_2d ,reflectionSamplerSampler: sampler ,reflectionCoords: vec2f #endif ,NdotVUnclamped: f32 #ifndef LODBASEDMICROSFURACE #ifdef REFLECTIONMAP_3D ,reflectionLowSampler: texture_cube ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_cube ,reflectionHighSamplerSampler: sampler #else ,reflectionLowSampler: texture_2d ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_2d ,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 ,reflectionSamplerSampler: sampler #else ,reflectionSampler: texture_2d ,reflectionSamplerSampler: sampler #endif #ifndef LODBASEDMICROSFURACE #ifdef REFLECTIONMAP_3D ,reflectionLowSampler: texture_cube ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_cube ,reflectionHighSamplerSampler: sampler #else ,reflectionLowSampler: texture_2d ,reflectionLowSamplerSampler: sampler ,reflectionHighSampler: texture_2d ,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 ,refractionSamplerSampler: sampler #ifndef LODBASEDMICROSFURACE ,refractionLowSampler: texture_cube ,refractionLowSamplerSampler: sampler ,refractionHighSampler: texture_cube ,refractionHighSamplerSampler: sampler #endif #else ,refractionSampler: texture_2d ,refractionSamplerSampler: sampler #ifndef LODBASEDMICROSFURACE ,refractionLowSampler: texture_2d ,refractionLowSamplerSampler: sampler ,refractionHighSampler: texture_2d ,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 ,reflectionSamplerSampler: sampler ,vReflectionFilteringInfo: vec2f #endif #endif #ifdef USEIRRADIANCEMAP #ifdef REFLECTIONMAP_3D ,irradianceSampler: texture_cube ,irradianceSamplerSampler: sampler #else ,irradianceSampler: texture_2d ,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 ,refractionSamplerSampler: sampler #ifndef LODBASEDMICROSFURACE ,refractionLowSampler: texture_cube ,refractionLowSamplerSampler: sampler ,refractionHighSampler: texture_cube ,refractionHighSamplerSampler: sampler #endif #else ,refractionSampler: texture_2d ,refractionSamplerSampler: sampler #ifndef LODBASEDMICROSFURACE ,refractionLowSampler: texture_2d ,refractionLowSamplerSampler: sampler ,refractionHighSampler: texture_2d ,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[SCENE_MRT_COUNT] #include #ifndef FROMLINEARSPACE #define FROMLINEARSPACE #endif #include #include #include[0..maxSimultaneousLights] #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef REFLECTION #include #endif #define CUSTOM_FRAGMENT_DEFINITIONS #include #include #include #include #include #include #include #include #include #include @fragment fn main(input: FragmentInputs)->FragmentOutputs { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include #include #include #include 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 #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 #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 #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 #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 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 #include[0..maxSimultaneousLights] #include #endif #include #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION #include #include #include(color,finalColor) #include #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR #ifdef PREPASS var writeGeometryInfo: f32=select(0.0,1.0,finalColor.a>ALPHATESTVALUE);var fragData: array,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 #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 #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 #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[2..7] #include[1..7] #ifdef VERTEXCOLOR attribute color: vec4f; #endif #include #include #include #include #include #include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) #include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity) #include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler) #include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance) #include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance) #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) #ifdef CLEARCOAT #include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat) #include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) #include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump) #include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint) #endif #ifdef IRIDESCENCE #include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence) #include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness) #endif #ifdef SHEEN #include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen) #include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) #endif #ifdef ANISOTROPIC #include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy) #endif #ifdef SUBSURFACE #include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness) #include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity) #include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity) #include(_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 #endif #endif #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) varying vColor: vec4f; #endif #include #include #include #include[0..maxSimultaneousLights] #include #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX varying vPositionUVW: vec3f; #endif #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vDirectionW: vec3f; #endif #include #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 #include[0..maxSimultaneousMorphTargets] #ifdef REFLECTIONMAP_SKYBOX vertexOutputs.vPositionUVW=positionUpdated; #endif #define CUSTOM_VERTEX_UPDATE_POSITION #define CUSTOM_VERTEX_UPDATE_NORMAL #include #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 #include var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);vertexOutputs.vPositionW= worldPos.xyz; #include #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[2..7] #include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x) #include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) #include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) #include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) #include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) #include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x) #include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x) #include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x) #include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x) #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) #include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) #ifdef CLEARCOAT #include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x) #include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z) #include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x) #include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x) #endif #ifdef IRIDESCENCE #include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x) #include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z) #endif #ifdef SHEEN #include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x) #include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheenRoughness,_INFONAME_,SheenInfos.z) #endif #ifdef ANISOTROPIC #include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x) #endif #ifdef SUBSURFACE #include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x) #include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x) #include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x) #include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_MATRIXNAME_,translucencyColor,_INFONAME_,TranslucencyColorInfos.x) #endif #include #include #include #include[0..maxSimultaneousLights] #include #include #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 #include #include #include[0..maxSimultaneousMorphTargets] #include uniform viewProjection: mat4x4f; #if defined(INSTANCES) varying vMeshID: vec4f; #endif @vertex fn main(input : VertexInputs)->FragmentInputs { #include #include[0..maxSimultaneousMorphTargets] #include #include #include 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;uniform scale: vec2;varying vUV: vec2;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; #include #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; #include #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;var normalSamplerSampler: sampler;var normalSampler: texture_2d;var rsmPositionW: texture_2d;var rsmNormalW: texture_2d;var rsmFlux: texture_2d; #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(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;var normalSamplerSampler: sampler;var normalSampler: texture_2d;var rsmPositionWSampler: sampler;var rsmPositionW: texture_2d;var rsmNormalWSampler: sampler;var rsmNormalW: texture_2d;var rsmFluxSampler: sampler;var rsmFlux: texture_2d;var rsmSamples: texture_2d; #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(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;varying vUV: vec2f; #ifdef SSR_SUPPORTED var reflectivitySamplerSampler: sampler;var reflectivitySampler: texture_2d;var normalSampler: texture_2d;var depthSampler: texture_2d; #ifdef SSRAYTRACE_USE_BACK_DEPTHBUFFER var backDepthSampler: texture_2d;uniform backSizeFactor: f32; #endif #ifdef SSR_USE_ENVIRONMENT_CUBE var envCubeSamplerSampler: sampler;var envCubeSampler: texture_cube; #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 #include #include 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(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(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(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;varying vUV: vec2f;uniform texelOffsetScale: vec2f;const weights: array=array(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,denominator: ptr) {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; var mainSamplerSampler: sampler;var mainSampler: texture_2d;var reflectivitySamplerSampler: sampler;var reflectivitySampler: texture_2d;uniform strength: f32;uniform reflectionSpecularFalloffExponent: f32;uniform reflectivityThreshold: f32;varying vUV: vec2f; #include #ifdef SSR_BLEND_WITH_FRESNEL #include #include uniform projection: mat4x4f;uniform invProjectionMatrix: mat4x4f;var normalSampler: texture_2d;var depthSampler: texture_2d; #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(input.vUV*texSize),0).xyz;var depth: f32=textureLoad(depthSampler,vec2(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 #endif #if SM_SOFTTRANSPARENTSHADOW==1 #include 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 #ifdef ALPHATEXTURE varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; #endif #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #include #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=uniforms.softTransparentShadowSM.x*alphaFromAlphaTexture) {discard;} #else if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.softTransparentShadowSM.x) {discard;} #endif #endif #include }`;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 #include #include #include[0..maxSimultaneousMorphTargets] #ifdef INSTANCES attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f; #endif #include #include #include #ifdef ALPHATEXTURE varying vUV: vec2f;uniform diffuseMatrix: mat4x4f; #ifdef UV1 attribute uv: vec2f; #endif #ifdef UV2 attribute uv2: vec2f; #endif #endif #include #include #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 #include[0..maxSimultaneousMorphTargets] #include #include #include 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 vertexOutputs.position=scene.viewProjection*worldPos; #include #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 }`;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;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; #include #include #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 #include fragmentOutputs.color=color; #include #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 #include #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 #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; #ifdef SSAO const scales: array=array( 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;var randomSamplerSampler: sampler;var randomSampler: texture_2d;var normalSamplerSampler: sampler;var normalSampler: texture_2d;uniform randTextureTiles: f32;uniform samplesFactor: f32;uniform sampleSphere: array;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; i1.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; #ifdef BLUR_LEGACY fn blur13Bilateral(image: texture_2d,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{e.r(t),e.d(t,{ssaoCombinePixelShaderWGSL:()=>o});var n="ssaoCombinePixelShader",i=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d;var originalColorSampler: sampler;var originalColor: texture_2d;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;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;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=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;bethis._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;yeue.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._previousStartingPointerTimeue.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;we1&&(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;N0&&(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;le0,He=0,Ke=this._isReadyForMeshStage;He0)for(var yt=0,zt=this.activeCameras;yt0},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;k0?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=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=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=0;w--)if(this.skeletons[w].id===N)return this.skeletons[w];return null},U.prototype.getSkeletonByUniqueId=function(N){for(var w=0;w0&&((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;k0&&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;He0){var J=this.getActiveSubMeshCandidates(w),le=J.length;k=k||le===1;for(var be=0;be0&&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;He0){o.S0.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var Je=0;Je0),this._renderId++}for(var yt=0,zt=this._cameraDrawRenderTargetStage;yt-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&&J0&&J0)for(var ye=0;ye0),this._intermediateRendering=!0;for(var Qe=0;Qe0),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;ht0)for(ye=0;ye0);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-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{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{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=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]{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]-1&&this._scene.actionManagers.splice(n,1);for(var a=0,s=this._scene.meshes.filter(function(l){return l.actionManager===e});a-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,n){for(var i=0;i=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=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;i0;if(m.type===2?T.push(o):T.push(v),S){for(var y=[],x=0;x0){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=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=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;e0)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+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=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;n0&&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-1&&this._animation.runtimeAnimations.splice(t,1)},r.prototype.setValue=function(t,e){if(this._targetIsArray)for(var n=0;nn[n.length-1].frame&&(t=n[n.length-1].frame);var i=this._events;if(i.length)for(var o=0;othis._maxFrame)&&(e=this._minFrame),(nthis._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&&e0&&this.currentFrame>d||o<0&&this.currentFrame0?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=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-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-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;c0)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;ie&&(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;mn&&(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;h0?l:-l,i),d.scaleAndAddToRef(l,e)}i.normalize()}for(u=0;u0)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=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;e0)){for(var e=0;ea&&(a=h.to);for(var c=new r(t[0].name+"_merged",t[0]._scene,i),u=0,d=t;ui[0].frame&&(this._from=i[0].frame),this._to-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;nt){var s={frame:t,value:o.value,inTangent:o.inTangent,outTangent:o.outTangent,interpolation:o.interpolation};i.splice(0,0,s)}a.frame0?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-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;om[0].frame&&(u=m[0].frame),d=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),s1)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;er?(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-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;eu-i||l-dd-o||c-hh-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!(lm||cv||ub)},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.radiusWorldK_.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;el&&(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;oHe?1:we===He?0:-1}),D=0,B=T;D0))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(!(de65535);for(var i=0,o=this._meshes;i0&&(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;e0){for(var e=0;e0){for(e=0;e0){for(e=0;e-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;i0){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;h0){var p=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);if(Xt.rX)for(h=1;h0){var m=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);if(Xt.rX)for(h=1;h0){var v=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);if(Xt.rX)for(h=1;h0){var b=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);if(Xt.rX)for(h=1;h0){var E=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);if(Xt.rX)for(h=1;h0){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>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>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>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>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-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;hu-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-1&&this._parentContainer.transformNodes.splice(i,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e)for(var o=0,a=this.getChildTransformNodes(!0);oBe.$.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;n0&&(_.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;S4,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,v1||!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();s1&&!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;b1)||s||C.canIntersects(e)){var T=C.intersects(e,this._positions,this.getIndices(),n,i);if(T&&(n||!h||T.distance-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;i65535){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;upt.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;ua.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=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)-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=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=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;c0},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.distanceOrScreenCoveragei.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;il*s)return this.onLODLevelSelection&&this.onLODLevelSelection(s,this,this),this;for(var d=0;d0||this.hasThinInstances);this.computeWorldMatrix();var m=this.material||h.defaultMaterial;if(m){if(m._storeEffectOnSubMeshes)for(var v=0,b=this.subMeshes;v0){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;so){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=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.instancesBufferSizeI._distanceToCamera?-1:R._distanceToCamera1&&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;gh&&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.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=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-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;a4,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;T0&&(_.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=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=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;e0&&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;s0&&(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;a0;){var x=y.shift();T.push(x);for(var R=s.dependedBy.get(x.uniqueId),I=0,M=Array.from(R.values());I0&&(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-1&&l.animations.splice(b,1)}},u=0,d=s.animations;u0;){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();a0&&(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;E0&&(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;e0&&(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;s0?1/o:0,c=0;c>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-1&&this._meshesWithPoseMatrix.splice(e,1)},r.prototype._computeTransformMatrices=function(t,e){this.onBeforeComputeObservable.notifyObservers(this);for(var n=0;n0){for(var n=0,i=this.bones;n-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;n0&&(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-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;n0&&(t=this._meshesWithPoseMatrix[0].getPoseMatrix()),t},r.prototype.sortBones=function(){for(var t=[],e=new Array(this.bones.length),n=0;n0},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)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.diff1){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.xc.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.yc.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.zc.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;ie.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;bE&&(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)0&&f<=this.length&&y.lengthSquared()=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;l1&&this.cameraToUseForPointers!==this.activeCamera),o=this.cameraToUseForPointers||this.activeCamera,a=0;a1)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).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;th&&(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)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();sthis.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 n0&&s.lengthSquared()-c2*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):Ethis._maxYaw||fMath.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):fMath.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)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&&tn&&t=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.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;e0?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)/os&&(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)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=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;e1)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.clientXr._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=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)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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radiusthis.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.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),this.lowerHeightOffsetLimit!==null&&this.heightOffsetthis.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),this.lowerRotationOffsetLimit!==null&&this.rotationOffsetthis.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;e0.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._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;t0&&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;tthis._maxRank&&(this._maxRank=t),this._defines[t]=new Array),this._defines[t].push(e)},r.prototype.addCPUSkinningFallback=function(t,e){this._mesh=e,tthis._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;i0&&(o.computeBonesUsingShaders=!1)}}else{var l=this._defines[this._currentRank];if(l)for(i=0;i0&&(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;g0?"[".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;p0)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;g0?e[0][1]=t:Mo.push([r,t])}function rE(r){for(var t=0;t0&&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"];n0,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._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,ethis._maxX||nthis._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 nr.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.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-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&&(e._rotationLeftAsked=!1):t.x<-this._padSensibilityUp&&e._dpadPressed&&(e._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),e._rotationRightAsked?t.xthis._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&&a0&&s=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=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=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;f4&&(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;f0&&((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;h0&&(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>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=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-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;p0){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-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;othis.capacity&&this._depth-1&&this.entries.splice(n,1)}},r.prototype.addEntries=function(t){for(var e=0;e1)?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;i0)):!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();o0;)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+21&&(h.push(B),h.push(B+1),h.push(B+d+1)),(b100&&(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;to?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;c0&&(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;c1)?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;h0||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;M0||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;D0&&(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;me.x&&(e.x=n.x),n.ye.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;l0){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;dc?yc?x0){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;de3?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;C1)?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;te3?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;D0){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;Je0,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;ce2?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;M2?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;n0&&i0){for(var c=(0,qe.HighestCommonFactor)(t,e),u=t/c,d=e/c,h=1;h-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;l0;)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;an){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;n1&&(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;vs){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;m0?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;cpt.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-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;i0?(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;i0?(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=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=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;yr.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 #if NUM_BONE_INFLUENCERS == 0 attribute vec4 matricesIndices; attribute vec4 matricesWeights; #endif #include #include 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 #include #include 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 #if NUM_BONE_INFLUENCERS == 0 attribute vec4 matricesIndices; attribute vec4 matricesWeights; #endif #include #include varying vec3 vColor; void main() { vec3 positionUpdated = position; #include #include #include 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;ur.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=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;E9?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;c1e-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=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-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;n1?"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;a1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];n.drawBuffers(i)}for(a=0;a1&&(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;$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;l1?"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;ethis._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=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=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++=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=0},r.prototype._replaceFunctionCallsByCode=function(){for(var t=!1,e=0,n=this._functionDescr;e0?this._sourceCode.substring(0,u):"",g=h+1"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=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-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=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)?$/,"$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;h0?` `:"","#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=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;o0?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;i0&&(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 `).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+"":l===1?"u32":"vec"+l+"",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;v0,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=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 vertexInputs`+(this._hasNonFloatAttribute?"_":"")+` : VertexInputs; `,this._hasNonFloatAttribute&&(a+=`struct VertexInputs_ { vertexIndex : u32, instanceIndex : u32, `,a+=this._attributesWGSL.join(` `),a+=` }; var vertexInputs : VertexInputs_; `);var s=`struct FragmentInputs { @builtin(position) position : vec4, `;this._varyingsWGSL.length>0&&(s+=this._varyingsWGSL.join(` `)),e=a+(s+=` }; var 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, @builtin(front_facing) frontFacing : bool, `;this._varyingsWGSL.length>0&&(d+=this._varyingsWGSL.join(` `)),d+=` }; var 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, `),v++;for(var b=1;b<8;b++)(m=n.match(new RegExp(p+b,"g")))&&(h+=" @location(".concat(v,") fragData").concat(v,` : vec4, `),v++);n.indexOf("MRT_AND_COLOR")!==-1&&(h+=" @location(".concat(v,`) color : vec4, `),v++)}(m=n.match(/oitDepthSampler/))&&(h+=" @location(".concat(v++,`) depth : vec2, `),h+=" @location(".concat(v++,`) frontColor : vec4, `),h+=" @location(".concat(v++,`) backColor : vec4, `)),v===0&&(h+=` @location(0) color : vec4, `,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 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)?$/,"$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 ").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;n1?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, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f)); const tex = array, 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; #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, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f)); const tex = array, 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; varying vTex: vec2f; @fragment fn main(input: FragmentInputs) -> FragmentOutputs { fragmentOutputs.color = textureSample(img, imgSampler, input.vTex); } `},{vertex:$E,fragment:` var img: texture_2d; #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, 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; 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, @location(0) fragUV : vec2 } @vertex fn main( @builtin(vertex_index) VertexIndex : u32 ) -> VertexOutput { var pos = array, 4>( vec2(-1.0, 1.0), vec2( 1.0, 1.0), vec2(-1.0, -1.0), vec2( 1.0, -1.0) ); var tex = array, 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(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 ) -> @location(0) vec4 { 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 ) -> @location(0) vec4 { return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2(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;gd;)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;S1?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;n10)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=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;d0)for(var p=0;p=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":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"?"":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"?"":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"?"":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"?"":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"?"":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"?"":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"?"":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;p1?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=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._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=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=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;a0,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;a0;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;T0&&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>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)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)=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)}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;cthis._orthoRight&&(this._orthoRight=a.x),a.y>this._orthoTop&&(this._orthoTop=a.y),this.autoCalcShadowZBounds&&(a.zl&&(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;c0)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;b0,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;n0&&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;he;){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;xo/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))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; `)):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; `)):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").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")},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;n0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isDirectlyConnectedToVertexOutput",{get:function(){if(!this.hasEndpoints)return!1;for(var t=0,e=this._endpoints;t=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=this._outputs.length?null:this._outputs[e+1]},r.prototype.isAnAncestorOf=function(t){for(var e=0,n=this._outputs;e;\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;i0||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;o0);for(var t=0;t0)}},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=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-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-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;u1){var i=e.getEffectConfiguration("nodeMaterial");i||(i=e.addEffectConfiguration({enabled:!0,needsImageProcessing:!1,name:"nodeMaterial",texturesRequired:[]}));for(var o=0,a=n;o1},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;oe.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.distancec&&(l=0,p.copyFrom(n.center)),l!==-1&&l"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=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=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;n4&&(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-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;i0){this._previousStencilState=this._engine.getStencilBuffer();for(var i=0,o=n;i-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-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;e0&&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._positionXt.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._positionXi.x+i.width-this.borderLimit?this._positionX-i.x-i.width+this.borderLimit:0)>(e=this._positionYi.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;d0);for(var n=0,i=e;n0)}},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=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;T4&&(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;n1||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;en&&(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=0&&en.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=0&&e=0&&e=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=n?Math.min((this._shadowMaxZ-n)/(i-n),this._maxDistance):this._maxDistance)*o,c=l-s,u=l/s,d=0;d255){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;i0&&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=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;ethis._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=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;c0)){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-1&&this._parentContainer.morphTargetManagers.splice(t,1),this._parentContainer=null}for(var e=0,n=this._targets;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;e0&&(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;i1e3*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-n0&&this._isImpostorInContact(l))for(var c=0,u=l._onPhysicsCollideCallbacks;c3?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;c0){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;nthis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex0?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=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;i0&&(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;b0);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;vE){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;h0){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;s0&&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;c0){for(var ht=0;ht0){for(var yt=0;yt-1))for(var le=0,be=u.skeletons.length;le-1&&u.morphTargetManagers!==void 0&&u.morphTargetManagers!==null&&!(S.indexOf(ce.morphTargetManagerId)>-1))for(var Me=0,we=u.morphTargetManagers.length;Me-1&&m.splice(D,1)}I._waitingParentId=null}I._waitingData.lods&&bP(t,I)}for(var B=0,F=m;B0&&(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;a0&&(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=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;c0)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;e0 `,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;y0)for(y=0;y, 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\(_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\(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, 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=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;ivec3f/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 "+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;e0&&(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= 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=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 ").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"):"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",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(".concat(this._options.remappedVariables.join(","),")"):"#include",T=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):"#include",f=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):"#include",g="#include",S="#include";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;I0&&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;se?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;na?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 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 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 #include #include varying vec4 vColor;varying vec2 vPosition;void main () { #include float A=-dot(vPosition,vPosition);if (A<-4.0) discard;float B=exp(A)*vColor.a; #include vec3 color=vColor.rgb; #ifdef FOG #include #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 #include `,L(72153),L(62589),L(56458),Gt.l.ShadersStore.gaussianSplattingVertexShader=`#include<__decl__gaussianSplattingVertex> #ifdef LOGARITHMICDEPTH #extension GL_EXT_frag_depth : enable #endif #include #include #include 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 #include #include } `;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;sr.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=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;tl._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;oh||v.deleted||v.isDirty))for(var b=function(C){if(v.error[C]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.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;a4,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;ue0){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;x65535?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>1]/g;if(n._options.uvs)for(Q=0;Q2)for(d=0;d0&&(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;dv.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;o0){if(t.length%2!=0&&t.push(n),e===5){for(var s=Math.floor(t.length/2),l=0,c=0;l0){if(e===5){for(var a=Math.floor(t.length/2),s=0;s=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;t0},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=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;e0){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;e0?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-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;ia;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<>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._currentIndexE)){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=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;b0&&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._currentIndex0&&(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 "+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=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=.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 ")});di&&(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-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;ap&&c.y=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, age : f32, size : vec3, life : f32, seed : vec4, direction : vec3, dummy0: f32, #ifdef CUSTOMEMITTER initialPosition : vec3, dummy1: f32, #endif #ifndef COLORGRADIENTS color : vec4, #endif #ifndef BILLBOARD initialDirection : vec3, dummy2: f32, #endif #ifdef NOISE noiseCoordinates1 : vec3, dummy3: f32, noiseCoordinates2 : vec3, dummy4: f32, #endif #ifdef ANGULARSPEEDGRADIENTS angle : f32, #else angle : vec2, #endif #ifdef ANIMATESHEET cellIndex : f32, #ifdef ANIMATESHEETRANDOMSTART cellStartOffset : f32, #endif #endif };struct Particles {particles : array,};struct SimParams {currentCount : f32, timeDelta : f32, stopFactor : f32, randomTextureSize: i32, lifeTime : vec2, emitPower : vec2, #ifndef COLORGRADIENTS color1 : vec4, color2 : vec4, #endif sizeRange : vec2, scaleRange : vec4, angleRange : vec4, gravity : vec3, #ifdef LIMITVELOCITYGRADIENTS limitVelocityDamping : f32, #endif #ifdef ANIMATESHEET cellInfos : vec4, #endif #ifdef NOISE noiseStrength : vec3, #endif #ifndef LOCAL emitterWM : mat4x4, #endif #ifdef BOXEMITTER direction1 : vec3, direction2 : vec3, minEmitBox : vec3, maxEmitBox : vec3, #endif #ifdef CONEEMITTER radius : vec2, coneAngle : f32, height : vec2, #ifdef DIRECTEDCONEEMITTER direction1 : vec3, direction2 : vec3, #else directionRandomizer : f32, #endif #endif #ifdef CYLINDEREMITTER radius : f32, height : f32, radiusRange : f32, #ifdef DIRECTEDCYLINDEREMITTER direction1 : vec3, direction2 : vec3, #else directionRandomizer : f32, #endif #endif #ifdef HEMISPHERICEMITTER radius : f32, radiusRange : f32, directionRandomizer : f32, #endif #ifdef POINTEMITTER direction1 : vec3, direction2 : vec3, #endif #ifdef SPHEREEMITTER radius : f32, radiusRange : f32, #ifdef DIRECTEDSPHEREEMITTER direction1 : vec3, direction2 : vec3, #else directionRandomizer : f32, #endif #endif };@binding(0) @group(0) var params : SimParams;@binding(1) @group(0) var particlesIn : Particles;@binding(2) @group(0) var particlesOut : Particles;@binding(3) @group(0) var randomTexture : texture_2d;@binding(4) @group(0) var randomTexture2 : texture_2d; #ifdef SIZEGRADIENTS @binding(0) @group(1) var sizeGradientSampler : sampler;@binding(1) @group(1) var sizeGradientTexture : texture_2d; #endif #ifdef ANGULARSPEEDGRADIENTS @binding(2) @group(1) var angularSpeedGradientSampler : sampler;@binding(3) @group(1) var angularSpeedGradientTexture : texture_2d; #endif #ifdef VELOCITYGRADIENTS @binding(4) @group(1) var velocityGradientSampler : sampler;@binding(5) @group(1) var velocityGradientTexture : texture_2d; #endif #ifdef LIMITVELOCITYGRADIENTS @binding(6) @group(1) var limitVelocityGradientSampler : sampler;@binding(7) @group(1) var limitVelocityGradientTexture : texture_2d; #endif #ifdef DRAGGRADIENTS @binding(8) @group(1) var dragGradientSampler : sampler;@binding(9) @group(1) var dragGradientTexture : texture_2d; #endif #ifdef NOISE @binding(10) @group(1) var noiseSampler : sampler;@binding(11) @group(1) var noiseTexture : texture_2d; #endif fn getRandomVec3(offset : f32,vertexID : f32)->vec3 {return textureLoad(randomTexture2,vec2(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0).rgb;} fn getRandomVec4(offset : f32,vertexID : f32)->vec4 {return textureLoad(randomTexture,vec2(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0);} @compute @workgroup_size(64) fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3) {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=particlesIn.particles[index].seed;let direction : vec3=particlesIn.particles[index].direction;if (newAge>=life && params.stopFactor != 0.) {var newPosition : vec3;var newDirection : vec3;let randoms : vec4=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(0.,0.),0.).r; #else sizex=params.sizeRange.x+(params.sizeRange.y-params.sizeRange.x)*randoms.g; #endif particlesOut.particles[index].size=vec3( 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( 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=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=getRandomVec3(seed.z,vertexID);newPosition=vec3(0.,0.,0.);newDirection=params.direction1+(params.direction2-params.direction1)*randoms3; #elif defined(BOXEMITTER) let randoms2 : vec3=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=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=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=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(randX,abs(randY),randZ);newDirection=normalize(newPosition+params.directionRandomizer*randoms3); #elif defined(SPHEREEMITTER) let randoms2 : vec3=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=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(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=getRandomVec3(seed.y,vertexID);let randoms3 : vec3=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(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(cos(angle),(-0.5+randoms3.y)*params.directionRandomizer,sin(angle));newDirection=normalize(newDirection); #endif #elif defined(CONEEMITTER) let randoms2 : vec3=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(randX,randY,randZ); let randoms3 : vec3=getRandomVec3(seed.z,vertexID); #ifdef DIRECTEDCONEEMITTER newDirection=params.direction1+(params.direction2-params.direction1)*randoms3; #else if (abs(cos(params.coneAngle))==1.0) {newDirection=vec3(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(0.,0.,0.);newDirection=2.0*(getRandomVec3(seed.w,vertexID)-vec3(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(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=newDirection; #else let initial : vec3=(params.emitterWM*vec4(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(ageGradient,0.),0.).r; #endif #ifdef DRAGGRADIENTS directionScale=directionScale*(1.0-textureSampleLevel(dragGradientTexture,dragGradientSampler,vec2(ageGradient,0.),0.).r); #endif let position : vec3=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( textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2(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=direction+params.gravity*timeDelta; #ifdef LIMITVELOCITYGRADIENTS let limitVelocity : f32=textureSampleLevel(limitVelocityGradientTexture,limitVelocityGradientSampler,vec2(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=particlesIn.particles[index].noiseCoordinates1;let noiseCoordinates2 : vec3=particlesIn.particles[index].noiseCoordinates2;let fetchedR : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5,0.5)+vec2(0.5,0.5),0.).r;let fetchedG : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5,0.5)+vec2(0.5,0.5),0.).r;let fetchedB : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5,0.5)+vec2(0.5,0.5),0.).r;let force : vec3=vec3(-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(ageGradient,0.),0.).r;particlesOut.particles[index].angle=particlesIn.particles[index].angle+angularSpeed*timeDelta; #else let angle : vec2=particlesIn.particles[index].angle;particlesOut.particles[index].angle=vec2(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;et)n(e[0],e[0],1);else{for(var i=0;i=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;bl.gradient?1:0})},t.prototype._removeFactorGradient=function(e,n){if(e)for(var i=0,o=0,a=e;on.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.gradients.gradient?1:0}),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var n=0,i=0,o=this._colorGradients;i0&&(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;s0&&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-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=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;a0?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;p0?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 #include #include #include #include #include void main() { #include 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 #include(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 #include #include #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 #include #include }`;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;h0&&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.gradienti.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.gradients.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;l0;)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=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;i1){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;o0?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;e0&&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;om?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;pm-(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;ie65535&&(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=this.nbParticles||!this._updatable)return[];var i=this.particles,o=this.nbParticles;if(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;ie0)for(var e=0;e0&&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;b1&&(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;R0;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()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;n0},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;o0)for(var e=0,n=t._pluginDataInstances;el){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;d0&&n===void 0)for(var o=0;o0){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;e0?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;x0){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();lthis._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;n1?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-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-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;R0){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);t1){for(var i=0,o=this._cameras;i-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;n1.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;n0?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;o0.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; ishadowPixelDepth) 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 #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=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._hdrCurrentLuminancea-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;e0},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 #include #include #include[0..maxSimultaneousMorphTargets] #include 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 #include[0..maxSimultaneousMorphTargets] #include #include #include 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;pf._alphaIndex?1:T._alphaIndexf._distanceToCamera?-1:0}),v.setAlphaMode(P.Y.ALPHA_COMBINE),m=0;m=0&&I.push(M);for(var D=0;D=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:0}):t[s].sort(function(R,I){return R[1]>I[1]?-1:R[1]=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&&Tie){var He=Q;Q=ie,ie=He}(Qe=Me[Ke=Q+"_"+ie])?Qe.done||(_.Pq.Dot(we,Qe.normal)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;l0&&(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=0;t--)this.renderTargets[t].dispose();for(t=0;t>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=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=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 #include #include #include 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=5)return O.V.Error("You already reached the maximum number of diffusion profiles."),0;for(var e=0;e4&&(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;ne.object.priority?1:0})},r.prototype._removeUnusedTargetRenderers=function(){for(var t,e={},n=0;nFragmentInputs {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; #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;p0&&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._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; 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; i0.) {mt=mod(time*animationData.z,1.0);for(float f=0.; fmt){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;s0&&(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-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-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=0&&this._meshes.splice(n,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var i=0;i0&&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;c0)){for(var n=[],i=[],o=t.dataTransfer?t.dataTransfer.items:null,a=0;a0&&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;tthis.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=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var i=!0,o=!0,a=0;a0){a.animationGroups=[];for(var h=0;h0)for(a.reflectionProbes=[],n=0;n0&&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;on._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.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;nr._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;c1e-6&&h.scaleAndAddToRef(1/(h.lengthSquared()*s),d)}),d.scaleInPlace(a),l.chars[v].addInPlace(d),l.chars[v].normalize()};for(c=o.length;c4;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;n0&&(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=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>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;c0&&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;s0?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;fi.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=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;as&&(l=u,s=c);if(!(sa*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;tthis._maxT&&(this._maxT=this._t,this._maxTPosition.copyFromFloats(t,e)),!(this._vitalityn&&(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 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 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;i0},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;e0;){t(a=e.pop());for(var s=0,l=a.dataInputs;so)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=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=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=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;io})},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="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(()=>{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=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-1;)Ve.push(ot),je=ot+1;if(ot===-1&&Ve.length===0)Z.materials[Ue].dispose();else for(var it=0;it0;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;me0&&(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=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=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{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{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;pe0&&(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;Ye1?(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;Ct0&&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{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{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{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{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{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{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{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=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{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{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{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 ").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;AeW.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=he.length)return Oe;for(var Ee=he[Pe],Ae=1;Ae=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;P0){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=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{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{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;re0)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.majoroe.minor?1:re.minor{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=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;pe0&&Ce[Ce.length-1])&&(Ye[0]===6||Ye[0]===2)){Ze=0;continue}if(Ye[0]===3&&(!Ce||Ye[1]>Ce[0]&&Ye[1]=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;Xe1||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{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